Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions compiler/rustc_ast_passes/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ pub(crate) struct NextSolverDisabledForGenericConstExprs {
pub span: Span,
}

#[derive(Diagnostic)]
#[diag("`-Zhigher-ranked-assumptions` is not supported with the next-generation trait solver")]
#[note("the feature flag will be superseded by `-Zassumptions-on-binders`")]
#[note("`-Znext-solver=globally` is currently enabled by default for testing")]
#[note("reverted the setting to `-Znext-solver=coherence` for this crate")]
#[note("the currently stable trait solver will be used for this crate")]
#[note("see issues #160895 <https://github.com/rust-lang/rust/issues/160895> for more information")]
pub(crate) struct NextSolverDisabledForHigherRankedAssumptions;

#[derive(Diagnostic)]
#[diag("functions in {$in_impl ->
[true] trait impls
Expand Down
15 changes: 13 additions & 2 deletions compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session, features: &Features) {
check_incompatible_features(sess, features);
check_dependent_features(sess, features);
warn_next_solver_and_gce(sess, features);
warn_next_solver_and_higher_ranked_assumptions(sess);
check_features_requiring_new_solver(sess, features);

let mut visitor = PostExpansionVisitor { sess, features };
Expand Down Expand Up @@ -703,8 +704,8 @@ fn warn_next_solver_and_gce(sess: &Session, features: &Features) {
return;
}

// Warn people who uses GCE and -Znext-solver=globally
// that their trait solver was downgraded to -Znext-solver=no
// Warn people who use GCE and -Znext-solver=globally
// that their trait solver was downgraded to -Znext-solver=coherence
if let Some(gce_span) = features
.enabled_lang_features()
.iter()
Expand All @@ -716,6 +717,16 @@ fn warn_next_solver_and_gce(sess: &Session, features: &Features) {
}
}

fn warn_next_solver_and_higher_ranked_assumptions(sess: &Session) {
// Warn people who use -Zhigher-ranked-assumptions and -Znext-solver=globally
// that their trait solver was downgraded to -Znext-solver=coherence
if sess.opts.unstable_opts.next_solver == NextSolverConfig::Globally
&& sess.opts.unstable_opts.higher_ranked_assumptions
{
sess.dcx().emit_warn(diagnostics::NextSolverDisabledForHigherRankedAssumptions);
}
}

fn check_features_requiring_new_solver(sess: &Session, features: &Features) {
if sess.opts.unstable_opts.next_solver == NextSolverConfig::Globally {
return;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2818,6 +2818,7 @@ impl<'tcx> TyCtxt<'tcx> {

pub fn next_trait_solver_globally(self) -> bool {
self.sess.opts.unstable_opts.next_solver == NextSolverConfig::Globally
&& !self.sess.opts.unstable_opts.higher_ranked_assumptions
&& !self.features().generic_const_exprs()
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_traits/src/coroutine_witnesses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn compute_assumptions<'tcx>(
def_id: DefId,
bound_tys: &'tcx ty::List<Ty<'tcx>>,
) -> &'tcx ty::List<ty::ArgOutlivesClause<'tcx>> {
if tcx.next_trait_solver_globally() || !tcx.sess.opts.unstable_opts.higher_ranked_assumptions {
if !tcx.sess.opts.unstable_opts.higher_ranked_assumptions {
return &ty::List::empty();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
warning: `-Zhigher-ranked-assumptions` is not supported with the next-generation trait solver
|
= note: the feature flag will be superseded by `-Zassumptions-on-binders`
= note: `-Znext-solver=globally` is currently enabled by default for testing
= note: reverted the setting to `-Znext-solver=coherence` for this crate
= note: the currently stable trait solver will be used for this crate
= note: see issues #160895 <https://github.com/rust-lang/rust/issues/160895> for more information

warning: 1 warning emitted

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/higher-ranked-auto-trait-1.rs:37:5
--> $DIR/higher-ranked-auto-trait-1.rs:43:5
|
LL | / async {
LL | | let _y = &();
Expand All @@ -10,13 +10,13 @@ LL | | drop(_x);
LL | | }
| |_____^ one type is more general than the other
|
= note: expected `async` block `{async block@$DIR/higher-ranked-auto-trait-1.rs:40:19: 40:29}`
found `async` block `{async block@$DIR/higher-ranked-auto-trait-1.rs:40:19: 40:29}`
= note: expected `async` block `{async block@$DIR/higher-ranked-auto-trait-1.rs:46:19: 46:29}`
found `async` block `{async block@$DIR/higher-ranked-auto-trait-1.rs:46:19: 46:29}`
= note: no two async blocks, even if identical, have the same type
= help: consider pinning your async block and casting it to a trait object

error[E0308]: mismatched types
--> $DIR/higher-ranked-auto-trait-1.rs:37:5
--> $DIR/higher-ranked-auto-trait-1.rs:43:5
|
LL | / async {
LL | | let _y = &();
Expand All @@ -27,8 +27,8 @@ LL | | drop(_x);
LL | | }
| |_____^ one type is more general than the other
|
= note: expected `async` block `{async block@$DIR/higher-ranked-auto-trait-1.rs:40:19: 40:29}`
found `async` block `{async block@$DIR/higher-ranked-auto-trait-1.rs:40:19: 40:29}`
= note: expected `async` block `{async block@$DIR/higher-ranked-auto-trait-1.rs:46:19: 46:29}`
found `async` block `{async block@$DIR/higher-ranked-auto-trait-1.rs:46:19: 46:29}`
= note: no two async blocks, even if identical, have the same type
= help: consider pinning your async block and casting it to a trait object
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
// Repro for <https://github.com/rust-lang/rust/issues/79648#issuecomment-749127947>.
//@ edition: 2021
//@ revisions: assumptions no_assumptions
//@ revisions: assumptions no_assumptions assumptions_next
//@[assumptions] compile-flags: -Zhigher-ranked-assumptions
//@[assumptions_next] compile-flags: -Zhigher-ranked-assumptions -Znext-solver
//@[assumptions] check-pass
//@[assumptions_next] check-pass
//@[no_assumptions] known-bug: #110338

// We're using this test to just check the way -Zhigher-ranked-assumptions
// interacts with the next-generation trait solver.
//[assumptions_next]~? WARN `-Zhigher-ranked-assumptions` is not supported with the next-generation trait solver

use std::future::Future;
use std::marker::PhantomData;

Expand Down
Loading