Skip to content

Commit

Permalink
Auto merge of rust-lang#127176 - fee1-dead-contrib:fx-requires-next-s…
Browse files Browse the repository at this point in the history
…olver, r=compiler-errors

Make `feature(effects)` require `-Znext-solver`

Per rust-lang#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
  • Loading branch information
bors committed Jul 1, 2024
2 parents ad12a2a + daff015 commit f92a6c4
Show file tree
Hide file tree
Showing 121 changed files with 543 additions and 428 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
1 change: 1 addition & 0 deletions tests/crashes/119924-6.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ known-bug: #119924
//@ compile-flags: -Znext-solver
#![feature(const_trait_impl, effects)]

struct S;
Expand Down
2 changes: 2 additions & 0 deletions tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//@ compile-flags: -Znext-solver
#![feature(effects, const_trait_impl)]
#![allow(incomplete_features)]

#[const_trait]
pub trait Resource {}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ known-bug: #110395

//@ compile-flags: -Znext-solver
#![feature(generic_const_exprs, adt_const_params, const_trait_impl, effects)]
#![allow(incomplete_features)]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ LL + #[derive(ConstParamTy)]
LL | struct Foo(u8);
|

error[E0284]: type annotations needed: cannot normalize `foo<N>::{constant#0}`
--> $DIR/unify-op-with-fn-call.rs:20:25
|
LL | fn foo<const N: Foo>(a: Evaluatable<{ N + N }>) {
| ^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `foo<N>::{constant#0}`

error[E0741]: `Foo` must implement `ConstParamTy` to be used as the type of a const generic parameter
--> $DIR/unify-op-with-fn-call.rs:20:17
|
Expand All @@ -43,17 +49,25 @@ LL + #[derive(ConstParamTy)]
LL | struct Foo(u8);
|

error: unconstrained generic constant
--> $DIR/unify-op-with-fn-call.rs:30:12
error[E0284]: type annotations needed: cannot normalize `foo2<N>::{constant#0}`
--> $DIR/unify-op-with-fn-call.rs:29:28
|
LL | bar2::<{ std::ops::Add::add(N, N) }>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | fn foo2<const N: usize>(a: Evaluatable2<{ N + N }>) {
| ^^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `foo2<N>::{constant#0}`

error[E0284]: type annotations needed: cannot normalize `foo<N>::{constant#0}`
--> $DIR/unify-op-with-fn-call.rs:21:11
|
help: try adding a `where` bound
LL | bar::<{ std::ops::Add::add(N, N) }>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `foo<N>::{constant#0}`

error[E0284]: type annotations needed: cannot normalize `foo2<N>::{constant#0}`
--> $DIR/unify-op-with-fn-call.rs:30:12
|
LL | fn foo2<const N: usize>(a: Evaluatable2<{ N + N }>) where [(); { std::ops::Add::add(N, N) }]: {
| +++++++++++++++++++++++++++++++++++++++++
LL | bar2::<{ std::ops::Add::add(N, N) }>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `foo2<N>::{constant#0}`

error: aborting due to 5 previous errors
error: aborting due to 8 previous errors

For more information about this error, try `rustc --explain E0741`.
Some errors have detailed explanations: E0284, E0741.
For more information about an error, try `rustc --explain E0284`.
4 changes: 2 additions & 2 deletions tests/ui/const-generics/issues/issue-88119.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ check-pass

//@ known-bug: #110395
//@ compile-flags: -Znext-solver
#![allow(incomplete_features)]
#![feature(const_trait_impl, effects, generic_const_exprs)]

Expand Down
27 changes: 27 additions & 0 deletions tests/ui/const-generics/issues/issue-88119.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
error[E0284]: type annotations needed: cannot satisfy `the constant `name_len::<T>()` can be evaluated`
--> $DIR/issue-88119.rs:21:5
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `the constant `name_len::<T>()` can be evaluated`
|
note: required by a bound in `<&T as ConstName>`
--> $DIR/issue-88119.rs:21:10
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^ required by this bound in `<&T as ConstName>`

error[E0284]: type annotations needed: cannot satisfy `the constant `name_len::<T>()` can be evaluated`
--> $DIR/issue-88119.rs:28:5
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `the constant `name_len::<T>()` can be evaluated`
|
note: required by a bound in `<&mut T as ConstName>`
--> $DIR/issue-88119.rs:28:10
|
LL | [(); name_len::<T>()]:,
| ^^^^^^^^^^^^^^^ required by this bound in `<&mut T as ConstName>`

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0284`.
4 changes: 3 additions & 1 deletion tests/ui/consts/auxiliary/closure-in-foreign-crate.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//@ compile-flags: -Znext-solver
#![crate_type = "lib"]
#![feature(const_closures, const_trait_impl, effects)] //~ WARN the feature `effects` is incomplete
#![feature(const_closures, const_trait_impl, effects)]
#![allow(incomplete_features)]

pub const fn test() {
let cl = const || {};
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/consts/const-float-classify.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//@ compile-flags: -Zmir-opt-level=0
//@ compile-flags: -Zmir-opt-level=0 -Znext-solver
//@ known-bug: #110395
// FIXME(effects) run-pass

Expand Down
7 changes: 6 additions & 1 deletion tests/ui/consts/const-try.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
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: const `impl` for trait `FromResidual` which is not marked with `#[const_trait]`
--> $DIR/const-try.rs:16:12
|
Expand All @@ -16,5 +21,5 @@ LL | impl const Try for TryMe {
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change

error: aborting due to 2 previous errors
error: aborting due to 3 previous errors

21 changes: 13 additions & 8 deletions tests/ui/consts/const_cmp_type_id.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
//@ known-bug: #110395
#![feature(const_type_id)]
#![feature(const_trait_impl, effects)]
//@ check-pass
//@ compile-flags: -Znext-solver
#![feature(const_type_id, const_trait_impl, effects)]
#![allow(incomplete_features)]

use std::any::TypeId;

const fn main() {
assert!(TypeId::of::<u8>() == TypeId::of::<u8>());
assert!(TypeId::of::<()>() != TypeId::of::<u8>());
const _A: bool = TypeId::of::<u8>() < TypeId::of::<u16>();
// can't assert `_A` because it is not deterministic
fn main() {
const {
// FIXME(effects) this isn't supposed to pass (right now) but it did.
// revisit binops typeck please.
assert!(TypeId::of::<u8>() == TypeId::of::<u8>());
assert!(TypeId::of::<()>() != TypeId::of::<u8>());
let _a = TypeId::of::<u8>() < TypeId::of::<u16>();
// can't assert `_a` because it is not deterministic
}
}
25 changes: 0 additions & 25 deletions tests/ui/consts/const_cmp_type_id.stderr

This file was deleted.

7 changes: 6 additions & 1 deletion tests/ui/consts/constifconst-call-in-const-position.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
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[E0308]: mismatched types
--> $DIR/constifconst-call-in-const-position.rs:17:38
|
Expand All @@ -16,6 +21,6 @@ LL | [0; T::a()]
= note: expected constant `false`
found constant `host`

error: aborting due to 2 previous errors
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0308`.
5 changes: 3 additions & 2 deletions tests/ui/consts/rustc-impl-const-stability.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//@ compile-flags: -Znext-solver
//@ known-bug: #110395

#![crate_type = "lib"]
#![feature(staged_api)]
#![feature(const_trait_impl, effects)]
#![feature(staged_api, const_trait_impl, effects)]
#![allow(incomplete_features)]
#![stable(feature = "foo", since = "1.0.0")]

#[stable(feature = "potato", since = "1.27.0")]
Expand Down
13 changes: 2 additions & 11 deletions tests/ui/consts/rustc-impl-const-stability.stderr
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
warning: the feature `effects` is incomplete and may not be safe to use and/or cause compiler crashes
--> $DIR/rustc-impl-const-stability.rs:5:30
|
LL | #![feature(const_trait_impl, effects)]
| ^^^^^^^
|
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
= note: `#[warn(incomplete_features)]` on by default

error: const `impl` for trait `Default` which is not marked with `#[const_trait]`
--> $DIR/rustc-impl-const-stability.rs:15:12
--> $DIR/rustc-impl-const-stability.rs:16:12
|
LL | impl const Default for Data {
| ^^^^^^^
|
= note: marking a trait with `#[const_trait]` ensures all default method bodies are `const`
= note: adding a non-const method body in the future would be a breaking change

error: aborting due to 1 previous error; 1 warning emitted
error: aborting due to 1 previous error

2 changes: 1 addition & 1 deletion tests/ui/generic-const-items/const-trait-impl.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//@ check-pass

//@ compile-flags: -Znext-solver
// Test that we can call methods from const trait impls inside of generic const items.

#![feature(generic_const_items, const_trait_impl, effects)]
Expand Down
4 changes: 3 additions & 1 deletion tests/ui/parser/impls-nested-within-fns-semantic-1.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Regression test for part of issue #119924.
//@ check-pass
//@ compile-flags: -Znext-solver

#![feature(const_trait_impl, effects)] //~ WARN the feature `effects` is incomplete
#![allow(incomplete_features)]
#![feature(const_trait_impl, effects)]

#[const_trait]
trait Trait {
Expand Down
11 changes: 0 additions & 11 deletions tests/ui/parser/impls-nested-within-fns-semantic-1.stderr

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
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[E0277]: the trait bound `Trait::{synthetic#0}: Compat` is not satisfied
--> $DIR/assoc-type-const-bound-usage-0.rs:13:5
|
Expand Down Expand Up @@ -28,6 +33,6 @@ LL | #[const_trait]
LL | fn func() -> i32;
| ---- required by a bound in this associated function

error: aborting due to 2 previous errors
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
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[E0277]: the trait bound `Trait::{synthetic#0}: Compat` is not satisfied
--> $DIR/assoc-type-const-bound-usage-1.rs:15:44
|
Expand Down Expand Up @@ -28,6 +33,6 @@ LL | #[const_trait]
LL | fn func() -> i32;
| ---- required by a bound in this associated function

error: aborting due to 2 previous errors
error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0277`.
7 changes: 6 additions & 1 deletion tests/ui/rfcs/rfc-2632-const-trait-impl/assoc-type.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ LL | #![feature(const_trait_impl, effects)]
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
= note: `#[warn(incomplete_features)]` on by default

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[E0277]: the trait bound `Add::{synthetic#0}: Compat` is not satisfied
--> $DIR/assoc-type.rs:41:15
|
Expand All @@ -18,6 +23,6 @@ help: consider further restricting the associated type
LL | trait Baz where Add::{synthetic#0}: Compat {
| ++++++++++++++++++++++++++++++++

error: aborting due to 1 previous error; 1 warning emitted
error: aborting due to 2 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0277`.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ compile-flags: -Znext-solver
#![allow(incomplete_features)]
#![feature(const_trait_impl, effects)]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#![feature(const_trait_impl, effects)] //~ WARN the feature `effects` is incomplete
//@ compile-flags: -Znext-solver
#![allow(incomplete_features)]
#![feature(const_trait_impl, effects)]
#![feature(staged_api)]
#![stable(feature = "rust1", since = "1.0.0")]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ LL | #![feature(const_trait_impl, effects)]
= note: see issue #102090 <https://github.com/rust-lang/rust/issues/102090> for more information
= note: `#[warn(incomplete_features)]` on by default

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[E0277]: the trait bound `Runtime: ~const Compat` is not satisfied
--> $DIR/call-const-trait-method-fail.rs:25:5
|
Expand All @@ -23,6 +28,6 @@ LL | pub trait Plus {
LL | fn plus(self, rhs: Self) -> Self;
| ---- required by a bound in this associated function

error: aborting due to 1 previous error; 1 warning emitted
error: aborting due to 2 previous errors; 1 warning emitted

For more information about this error, try `rustc --explain E0277`.
Loading

0 comments on commit f92a6c4

Please sign in to comment.