Skip to content

Commit

Permalink
Unrolled build for rust-lang#130787
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#130787 - compiler-errors:next-solver-gce, r=BoxyUwU

Ban combination of GCE and new solver

These do not work together. I don't want anyone to have the impression that they do.

I reused the conflicting features diagnostic but I guess I could make it more tailored to the new solver? OTOH I don't really about the presentation of diagnostics here; these are nightly features after all.

r? `@BoxyUwU` thoughts on this?
  • Loading branch information
rust-timer authored Sep 25, 2024
2 parents 4c62024 + ead569a commit d373ad3
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 11 deletions.
23 changes: 22 additions & 1 deletion compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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,
});
}
}
Original file line number Diff line number Diff line change
@@ -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
|
Expand Down Expand Up @@ -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`.
10 changes: 9 additions & 1 deletion tests/ui/const-generics/issues/issue-88119.stderr
Original file line number Diff line number Diff line change
@@ -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
|
Expand Down Expand Up @@ -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`.
Original file line number Diff line number Diff line change
@@ -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
|
Expand All @@ -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`.
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -19,17 +20,15 @@ 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>;

// 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
Original file line number Diff line number Diff line change
@@ -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`
Expand All @@ -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`.

0 comments on commit d373ad3

Please sign in to comment.