Skip to content

Commit

Permalink
Make feature(effects) require -Znext-solver
Browse files Browse the repository at this point in the history
  • Loading branch information
fee1-dead committed Jun 30, 2024
1 parent 6c34855 commit 34ae56d
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/rustc_hir_analysis/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ hir_analysis_drop_impl_reservation = reservation `Drop` impls are not supported
hir_analysis_duplicate_precise_capture = cannot capture parameter `{$name}` twice
.label = parameter captured again here
hir_analysis_effects_without_next_solver = using `#![feature(effects)]` without enabling next trait solver globally
.note = the next trait solver must be enabled globally for the effects feature to work correctly
.help = use `-Znext-solver` to enable
hir_analysis_empty_specialization = specialization impl does not specialize any associated items
.note = impl is a specialization of this impl
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_hir_analysis/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1699,3 +1699,9 @@ pub struct InvalidReceiverTy<'tcx> {
pub span: Span,
pub receiver_ty: Ty<'tcx>,
}

#[derive(Diagnostic)]
#[diag(hir_analysis_effects_without_next_solver)]
#[note]
#[help]
pub struct EffectsWithoutNextSolver;
6 changes: 6 additions & 0 deletions compiler/rustc_hir_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ pub fn provide(providers: &mut Providers) {
pub fn check_crate(tcx: TyCtxt<'_>) {
let _prof_timer = tcx.sess.timer("type_check_crate");

// FIXME(effects): remove once effects is implemented in old trait solver
// or if the next solver is stabilized.
if tcx.features().effects && !tcx.next_trait_solver_globally() {
tcx.dcx().emit_err(errors::EffectsWithoutNextSolver);
}

tcx.sess.time("coherence_checking", || {
tcx.hir().par_for_each_module(|module| {
let _ = tcx.ensure().check_mod_type_wf(module);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
error: using `#![feature(effects)]` without enabling next trait solver globally
|
= note: the next trait solver must be enabled globally for the effects feature to work correctly
= help: use `-Znext-solver` to enable

error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// test that we error correctly when effects is used without the next-solver flag.
//@ revisions: stock coherence full
//@[coherence] compile-flags: -Znext-solver=coherence
//@[full] compile-flags: -Znext-solver
//@[full] check-pass

#![feature(effects)]
#![allow(incomplete_features)]

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
error: using `#![feature(effects)]` without enabling next trait solver globally
|
= note: the next trait solver must be enabled globally for the effects feature to work correctly
= help: use `-Znext-solver` to enable

error: aborting due to 1 previous error

0 comments on commit 34ae56d

Please sign in to comment.