Skip to content

Commit f92a6c4

Browse files
committed
Auto merge of #127176 - fee1-dead-contrib:fx-requires-next-solver, r=compiler-errors
Make `feature(effects)` require `-Znext-solver` Per #120639 (review) I made this a hard error because otherwise it should be a lint and that seemed more complicated. Not sure if this is the best place to put the error though. r? project-const-traits
2 parents ad12a2a + daff015 commit f92a6c4

File tree

121 files changed

+543
-428
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+543
-428
lines changed

compiler/rustc_hir_analysis/messages.ftl

Lines changed: 4 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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

Lines changed: 6 additions & 0 deletions
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);

tests/crashes/119924-6.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ known-bug: #119924
2+
//@ compile-flags: -Znext-solver
23
#![feature(const_trait_impl, effects)]
34

45
struct S;

tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
//@ compile-flags: -Znext-solver
12
#![feature(effects, const_trait_impl)]
3+
#![allow(incomplete_features)]
24

35
#[const_trait]
46
pub trait Resource {}

tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//@ known-bug: #110395
2-
2+
//@ compile-flags: -Znext-solver
33
#![feature(generic_const_exprs, adt_const_params, const_trait_impl, effects)]
44
#![allow(incomplete_features)]
55

tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ LL + #[derive(ConstParamTy)]
1919
LL | struct Foo(u8);
2020
|
2121

22+
error[E0284]: type annotations needed: cannot normalize `foo<N>::{constant#0}`
23+
--> $DIR/unify-op-with-fn-call.rs:20:25
24+
|
25+
LL | fn foo<const N: Foo>(a: Evaluatable<{ N + N }>) {
26+
| ^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `foo<N>::{constant#0}`
27+
2228
error[E0741]: `Foo` must implement `ConstParamTy` to be used as the type of a const generic parameter
2329
--> $DIR/unify-op-with-fn-call.rs:20:17
2430
|
@@ -43,17 +49,25 @@ LL + #[derive(ConstParamTy)]
4349
LL | struct Foo(u8);
4450
|
4551

46-
error: unconstrained generic constant
47-
--> $DIR/unify-op-with-fn-call.rs:30:12
52+
error[E0284]: type annotations needed: cannot normalize `foo2<N>::{constant#0}`
53+
--> $DIR/unify-op-with-fn-call.rs:29:28
4854
|
49-
LL | bar2::<{ std::ops::Add::add(N, N) }>();
50-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
55+
LL | fn foo2<const N: usize>(a: Evaluatable2<{ N + N }>) {
56+
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `foo2<N>::{constant#0}`
57+
58+
error[E0284]: type annotations needed: cannot normalize `foo<N>::{constant#0}`
59+
--> $DIR/unify-op-with-fn-call.rs:21:11
5160
|
52-
help: try adding a `where` bound
61+
LL | bar::<{ std::ops::Add::add(N, N) }>();
62+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `foo<N>::{constant#0}`
63+
64+
error[E0284]: type annotations needed: cannot normalize `foo2<N>::{constant#0}`
65+
--> $DIR/unify-op-with-fn-call.rs:30:12
5366
|
54-
LL | fn foo2<const N: usize>(a: Evaluatable2<{ N + N }>) where [(); { std::ops::Add::add(N, N) }]: {
55-
| +++++++++++++++++++++++++++++++++++++++++
67+
LL | bar2::<{ std::ops::Add::add(N, N) }>();
68+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `foo2<N>::{constant#0}`
5669

57-
error: aborting due to 5 previous errors
70+
error: aborting due to 8 previous errors
5871

59-
For more information about this error, try `rustc --explain E0741`.
72+
Some errors have detailed explanations: E0284, E0741.
73+
For more information about an error, try `rustc --explain E0284`.

tests/ui/const-generics/issues/issue-88119.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
//@ check-pass
2-
1+
//@ known-bug: #110395
2+
//@ compile-flags: -Znext-solver
33
#![allow(incomplete_features)]
44
#![feature(const_trait_impl, effects, generic_const_exprs)]
55

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
error[E0284]: type annotations needed: cannot satisfy `the constant `name_len::<T>()` can be evaluated`
2+
--> $DIR/issue-88119.rs:21:5
3+
|
4+
LL | [(); name_len::<T>()]:,
5+
| ^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `the constant `name_len::<T>()` can be evaluated`
6+
|
7+
note: required by a bound in `<&T as ConstName>`
8+
--> $DIR/issue-88119.rs:21:10
9+
|
10+
LL | [(); name_len::<T>()]:,
11+
| ^^^^^^^^^^^^^^^ required by this bound in `<&T as ConstName>`
12+
13+
error[E0284]: type annotations needed: cannot satisfy `the constant `name_len::<T>()` can be evaluated`
14+
--> $DIR/issue-88119.rs:28:5
15+
|
16+
LL | [(); name_len::<T>()]:,
17+
| ^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `the constant `name_len::<T>()` can be evaluated`
18+
|
19+
note: required by a bound in `<&mut T as ConstName>`
20+
--> $DIR/issue-88119.rs:28:10
21+
|
22+
LL | [(); name_len::<T>()]:,
23+
| ^^^^^^^^^^^^^^^ required by this bound in `<&mut T as ConstName>`
24+
25+
error: aborting due to 2 previous errors
26+
27+
For more information about this error, try `rustc --explain E0284`.

tests/ui/consts/auxiliary/closure-in-foreign-crate.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
//@ compile-flags: -Znext-solver
12
#![crate_type = "lib"]
2-
#![feature(const_closures, const_trait_impl, effects)] //~ WARN the feature `effects` is incomplete
3+
#![feature(const_closures, const_trait_impl, effects)]
4+
#![allow(incomplete_features)]
35

46
pub const fn test() {
57
let cl = const || {};

0 commit comments

Comments
 (0)