Skip to content

Commit 34ae56d

Browse files
committed
Make feature(effects) require -Znext-solver
1 parent 6c34855 commit 34ae56d

File tree

6 files changed

+40
-0
lines changed

6 files changed

+40
-0
lines changed

compiler/rustc_hir_analysis/messages.ftl

+4
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ hir_analysis_drop_impl_reservation = reservation `Drop` impls are not supported
120120
hir_analysis_duplicate_precise_capture = cannot capture parameter `{$name}` twice
121121
.label = parameter captured again here
122122
123+
hir_analysis_effects_without_next_solver = using `#![feature(effects)]` without enabling next trait solver globally
124+
.note = the next trait solver must be enabled globally for the effects feature to work correctly
125+
.help = use `-Znext-solver` to enable
126+
123127
hir_analysis_empty_specialization = specialization impl does not specialize any associated items
124128
.note = impl is a specialization of this impl
125129

compiler/rustc_hir_analysis/src/errors.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1699,3 +1699,9 @@ pub struct InvalidReceiverTy<'tcx> {
16991699
pub span: Span,
17001700
pub receiver_ty: Ty<'tcx>,
17011701
}
1702+
1703+
#[derive(Diagnostic)]
1704+
#[diag(hir_analysis_effects_without_next_solver)]
1705+
#[note]
1706+
#[help]
1707+
pub struct EffectsWithoutNextSolver;

compiler/rustc_hir_analysis/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,12 @@ pub fn provide(providers: &mut Providers) {
151151
pub fn check_crate(tcx: TyCtxt<'_>) {
152152
let _prof_timer = tcx.sess.timer("type_check_crate");
153153

154+
// FIXME(effects): remove once effects is implemented in old trait solver
155+
// or if the next solver is stabilized.
156+
if tcx.features().effects && !tcx.next_trait_solver_globally() {
157+
tcx.dcx().emit_err(errors::EffectsWithoutNextSolver);
158+
}
159+
154160
tcx.sess.time("coherence_checking", || {
155161
tcx.hir().par_for_each_module(|module| {
156162
let _ = tcx.ensure().check_mod_type_wf(module);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
error: using `#![feature(effects)]` without enabling next trait solver globally
2+
|
3+
= note: the next trait solver must be enabled globally for the effects feature to work correctly
4+
= help: use `-Znext-solver` to enable
5+
6+
error: aborting due to 1 previous error
7+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// test that we error correctly when effects is used without the next-solver flag.
2+
//@ revisions: stock coherence full
3+
//@[coherence] compile-flags: -Znext-solver=coherence
4+
//@[full] compile-flags: -Znext-solver
5+
//@[full] check-pass
6+
7+
#![feature(effects)]
8+
#![allow(incomplete_features)]
9+
10+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
error: using `#![feature(effects)]` without enabling next trait solver globally
2+
|
3+
= note: the next trait solver must be enabled globally for the effects feature to work correctly
4+
= help: use `-Znext-solver` to enable
5+
6+
error: aborting due to 1 previous error
7+

0 commit comments

Comments
 (0)