about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Goulet <michael@errs.io>2024-09-24 10:53:19 -0400
committerMichael Goulet <michael@errs.io>2024-09-24 10:53:32 -0400
commitead569a06de7d1cc6758b88b4f3faa00d1196c6d (patch)
treec777e82f9e611b284fa40f17dc6bed64d589963d
parent11e760b7f4e4aaa11bf51a64d4bb7f1171f6e466 (diff)
downloadrust-ead569a06de7d1cc6758b88b4f3faa00d1196c6d.tar.gz
rust-ead569a06de7d1cc6758b88b4f3faa00d1196c6d.zip
Ban combination of GCE and new solver
-rw-r--r--compiler/rustc_ast_passes/src/feature_gate.rs23
-rw-r--r--tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr10
-rw-r--r--tests/ui/const-generics/issues/issue-88119.stderr10
-rw-r--r--tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds.stderr10
-rw-r--r--tests/ui/rfcs/rfc-2632-const-trait-impl/unsatisfied-const-trait-bound.rs5
-rw-r--r--tests/ui/rfcs/rfc-2632-const-trait-impl/unsatisfied-const-trait-bound.stderr16
6 files changed, 63 insertions, 11 deletions
diff --git a/compiler/rustc_ast_passes/src/feature_gate.rs b/compiler/rustc_ast_passes/src/feature_gate.rs
index 614a99a6e19..83931a8c1a9 100644
--- a/compiler/rustc_ast_passes/src/feature_gate.rs
+++ b/compiler/rustc_ast_passes/src/feature_gate.rs
@@ -4,9 +4,9 @@ use rustc_ast::{NodeId, PatKind, attr, token};
 use rustc_feature::{AttributeGate, BUILTIN_ATTRIBUTE_MAP, BuiltinAttribute, Features, GateIssue};
 use rustc_session::Session;
 use rustc_session::parse::{feature_err, feature_err_issue, feature_warn};
-use rustc_span::Span;
 use rustc_span::source_map::Spanned;
 use rustc_span::symbol::sym;
+use rustc_span::{Span, Symbol};
 use rustc_target::spec::abi;
 use thin_vec::ThinVec;
 
@@ -483,6 +483,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
 pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
     maybe_stage_features(sess, features, krate);
     check_incompatible_features(sess, features);
+    check_new_solver_banned_features(sess, features);
+
     let mut visitor = PostExpansionVisitor { sess, features };
 
     let spans = sess.psess.gated_spans.spans.borrow();
@@ -662,3 +664,22 @@ fn check_incompatible_features(sess: &Session, features: &Features) {
         }
     }
 }
+
+fn check_new_solver_banned_features(sess: &Session, features: &Features) {
+    if !sess.opts.unstable_opts.next_solver.is_some_and(|n| n.globally) {
+        return;
+    }
+
+    // Ban GCE with the new solver, because it does not implement GCE correctly.
+    if let Some(&(_, gce_span, _)) = features
+        .declared_lang_features
+        .iter()
+        .find(|&&(feat, _, _)| feat == sym::generic_const_exprs)
+    {
+        sess.dcx().emit_err(errors::IncompatibleFeatures {
+            spans: vec![gce_span],
+            f1: Symbol::intern("-Znext-solver=globally"),
+            f2: sym::generic_const_exprs,
+        });
+    }
+}
diff --git a/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr b/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr
index db93bcca60f..bae8249845c 100644
--- a/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr
+++ b/tests/ui/const-generics/generic_const_exprs/unify-op-with-fn-call.stderr
@@ -1,3 +1,11 @@
+error: `-Znext-solver=globally` and `generic_const_exprs` are incompatible, using them at the same time is not allowed
+  --> $DIR/unify-op-with-fn-call.rs:3:12
+   |
+LL | #![feature(generic_const_exprs, adt_const_params, const_trait_impl, effects)]
+   |            ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: remove one of these features
+
 error: const `impl` for trait `Add` which is not marked with `#[const_trait]`
   --> $DIR/unify-op-with-fn-call.rs:10:12
    |
@@ -67,7 +75,7 @@ error[E0284]: type annotations needed: cannot normalize `foo2<N>::{constant#0}`
 LL |     bar2::<{ std::ops::Add::add(N, N) }>();
    |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot normalize `foo2<N>::{constant#0}`
 
-error: aborting due to 8 previous errors
+error: aborting due to 9 previous errors
 
 Some errors have detailed explanations: E0284, E0741.
 For more information about an error, try `rustc --explain E0284`.
diff --git a/tests/ui/const-generics/issues/issue-88119.stderr b/tests/ui/const-generics/issues/issue-88119.stderr
index b5eec3046fd..98bb8196810 100644
--- a/tests/ui/const-generics/issues/issue-88119.stderr
+++ b/tests/ui/const-generics/issues/issue-88119.stderr
@@ -1,3 +1,11 @@
+error: `-Znext-solver=globally` and `generic_const_exprs` are incompatible, using them at the same time is not allowed
+  --> $DIR/issue-88119.rs:4:39
+   |
+LL | #![feature(const_trait_impl, effects, generic_const_exprs)]
+   |                                       ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: remove one of these features
+
 error[E0284]: type annotations needed: cannot normalize `<&T as ConstName>::{constant#0}`
   --> $DIR/issue-88119.rs:19:49
    |
@@ -28,6 +36,6 @@ LL | where
 LL |     [(); name_len::<T>()]:,
    |     --------------------- unsatisfied trait bound introduced here
 
-error: aborting due to 2 previous errors
+error: aborting due to 3 previous errors
 
 For more information about this error, try `rustc --explain E0284`.
diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds.stderr
index 7db6a77c77b..698b1b5b578 100644
--- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds.stderr
+++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-trait-bounds.stderr
@@ -1,3 +1,11 @@
+error: `-Znext-solver=globally` and `generic_const_exprs` are incompatible, using them at the same time is not allowed
+  --> $DIR/const-trait-bounds.rs:4:39
+   |
+LL | #![feature(const_trait_impl, effects, generic_const_exprs)]
+   |                                       ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: remove one of these features
+
 error[E0284]: type annotations needed: cannot normalize `process<T>::{constant#0}`
   --> $DIR/const-trait-bounds.rs:12:35
    |
@@ -16,6 +24,6 @@ error[E0284]: type annotations needed: cannot normalize `process<T>::{constant#1
 LL |     input
    |     ^^^^^ cannot normalize `process<T>::{constant#1}`
 
-error: aborting due to 3 previous errors
+error: aborting due to 4 previous errors
 
 For more information about this error, try `rustc --explain E0284`.
diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/unsatisfied-const-trait-bound.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/unsatisfied-const-trait-bound.rs
index c50c755f667..5fffe54fc1a 100644
--- a/tests/ui/rfcs/rfc-2632-const-trait-impl/unsatisfied-const-trait-bound.rs
+++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/unsatisfied-const-trait-bound.rs
@@ -1,3 +1,4 @@
+//@ known-bug: unknown
 // Ensure that we print unsatisfied always-const trait bounds as `const Trait` in diagnostics.
 //@ compile-flags: -Znext-solver
 
@@ -19,7 +20,7 @@ impl Trait for Ty {
 
 fn main() {
     // FIXME(effects): improve diagnostics on this
-    require::<Ty>(); //~ ERROR the trait bound `Trait::{synthetic#0}: const Compat` is not satisfied
+    require::<Ty>();
 }
 
 struct Container<const N: u32>;
@@ -27,9 +28,7 @@ struct Container<const N: u32>;
 // FIXME(effects): Somehow emit `the trait bound `T: const Trait` is not satisfied` here instead
 //                 and suggest changing `Trait` to `const Trait`.
 fn accept0<T: Trait>(_: Container<{ T::make() }>) {}
-//~^ ERROR mismatched types
 
 // FIXME(effects): Instead of suggesting `+ const Trait`, suggest
 //                 changing `~const Trait` to `const Trait`.
 const fn accept1<T: ~const Trait>(_: Container<{ T::make() }>) {}
-//~^ ERROR mismatched types
diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/unsatisfied-const-trait-bound.stderr b/tests/ui/rfcs/rfc-2632-const-trait-impl/unsatisfied-const-trait-bound.stderr
index b9f6c9e8835..0806ffa4b5d 100644
--- a/tests/ui/rfcs/rfc-2632-const-trait-impl/unsatisfied-const-trait-bound.stderr
+++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/unsatisfied-const-trait-bound.stderr
@@ -1,5 +1,13 @@
+error: `-Znext-solver=globally` and `generic_const_exprs` are incompatible, using them at the same time is not allowed
+  --> $DIR/unsatisfied-const-trait-bound.rs:5:39
+   |
+LL | #![feature(const_trait_impl, effects, generic_const_exprs)]
+   |                                       ^^^^^^^^^^^^^^^^^^^
+   |
+   = help: remove one of these features
+
 error[E0308]: mismatched types
-  --> $DIR/unsatisfied-const-trait-bound.rs:29:37
+  --> $DIR/unsatisfied-const-trait-bound.rs:30:37
    |
 LL | fn accept0<T: Trait>(_: Container<{ T::make() }>) {}
    |                                     ^^^^^^^^^ expected `false`, found `true`
@@ -17,18 +25,18 @@ LL | const fn accept1<T: ~const Trait>(_: Container<{ T::make() }>) {}
               found constant `host`
 
 error[E0277]: the trait bound `Trait::{synthetic#0}: const Compat` is not satisfied
-  --> $DIR/unsatisfied-const-trait-bound.rs:22:15
+  --> $DIR/unsatisfied-const-trait-bound.rs:23:15
    |
 LL |     require::<Ty>();
    |               ^^ the trait `const Compat` is not implemented for `Trait::{synthetic#0}`
    |
 note: required by a bound in `require`
-  --> $DIR/unsatisfied-const-trait-bound.rs:7:15
+  --> $DIR/unsatisfied-const-trait-bound.rs:8:15
    |
 LL | fn require<T: const Trait>() {}
    |               ^^^^^^^^^^^ required by this bound in `require`
 
-error: aborting due to 3 previous errors
+error: aborting due to 4 previous errors
 
 Some errors have detailed explanations: E0277, E0308.
 For more information about an error, try `rustc --explain E0277`.