Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stabilize -Znext-solver=coherence again #130654

Merged
merged 4 commits into from
Oct 15, 2024
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
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ 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) {
if !sess.opts.unstable_opts.next_solver.globally {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_interface/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ fn test_unstable_options_tracking_hash() {
tracked!(mir_opt_level, Some(4));
tracked!(move_size_limit, Some(4096));
tracked!(mutable_noalias, false);
tracked!(next_solver, Some(NextSolverConfig { coherence: true, globally: false }));
tracked!(next_solver, NextSolverConfig { coherence: true, globally: true });
tracked!(no_generate_arange_section, true);
tracked!(no_jump_tables, true);
tracked!(no_link, true);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3128,11 +3128,11 @@ impl<'tcx> TyCtxt<'tcx> {
}

pub fn next_trait_solver_globally(self) -> bool {
self.sess.opts.unstable_opts.next_solver.map_or(false, |c| c.globally)
self.sess.opts.unstable_opts.next_solver.globally
}

pub fn next_trait_solver_in_coherence(self) -> bool {
self.sess.opts.unstable_opts.next_solver.map_or(false, |c| c.coherence)
self.sess.opts.unstable_opts.next_solver.coherence
}

pub fn is_impl_trait_in_trait(self, def_id: DefId) -> bool {
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,11 @@ pub struct NextSolverConfig {
/// This is only `true` if `coherence` is also enabled.
pub globally: bool,
}
impl Default for NextSolverConfig {
fn default() -> Self {
NextSolverConfig { coherence: true, globally: false }
}
}

#[derive(Clone)]
pub enum Input {
Expand Down
31 changes: 10 additions & 21 deletions compiler/rustc_session/src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ mod desc {
pub(crate) const parse_unpretty: &str = "`string` or `string=string`";
pub(crate) const parse_treat_err_as_bug: &str = "either no value or a non-negative number";
pub(crate) const parse_next_solver_config: &str =
"a comma separated list of solver configurations: `globally` (default), and `coherence`";
"either `globally` (when used without an argument), `coherence` (default) or `no`";
pub(crate) const parse_lto: &str =
"either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted";
pub(crate) const parse_linker_plugin_lto: &str =
Expand Down Expand Up @@ -1123,27 +1123,16 @@ mod parse {
}
}

pub(crate) fn parse_next_solver_config(
slot: &mut Option<NextSolverConfig>,
v: Option<&str>,
) -> bool {
pub(crate) fn parse_next_solver_config(slot: &mut NextSolverConfig, v: Option<&str>) -> bool {
if let Some(config) = v {
let mut coherence = false;
let mut globally = true;
for c in config.split(',') {
match c {
"globally" => globally = true,
"coherence" => {
globally = false;
coherence = true;
}
_ => return false,
}
}

*slot = Some(NextSolverConfig { coherence: coherence || globally, globally });
*slot = match config {
"no" => NextSolverConfig { coherence: false, globally: false },
"coherence" => NextSolverConfig { coherence: true, globally: false },
"globally" => NextSolverConfig { coherence: true, globally: true },
_ => return false,
};
} else {
*slot = Some(NextSolverConfig { coherence: true, globally: true });
*slot = NextSolverConfig { coherence: true, globally: true };
}

true
Expand Down Expand Up @@ -1914,7 +1903,7 @@ options! {
"the size at which the `large_assignments` lint starts to be emitted"),
mutable_noalias: bool = (true, parse_bool, [TRACKED],
"emit noalias metadata for mutable references (default: yes)"),
next_solver: Option<NextSolverConfig> = (None, parse_next_solver_config, [TRACKED],
next_solver: NextSolverConfig = (NextSolverConfig::default(), parse_next_solver_config, [TRACKED],
"enable and configure the next generation trait solver used by rustc"),
nll_facts: bool = (false, parse_bool, [UNTRACKED],
"dump facts from NLL analysis into side files (default: no)"),
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_trait_selection/src/traits/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@ where
if infcx.next_trait_solver() {
Box::new(NextFulfillmentCtxt::new(infcx))
} else {
let new_solver_globally =
infcx.tcx.sess.opts.unstable_opts.next_solver.map_or(false, |c| c.globally);
assert!(
!new_solver_globally,
!infcx.tcx.next_trait_solver_globally(),
"using old solver even though new solver is enabled globally"
);
Box::new(FulfillmentContext::new(infcx))
Expand Down
17 changes: 0 additions & 17 deletions tests/crashes/118987.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `Cow<'_, _>`
error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `<_ as ToOwned>::Owned`
--> $DIR/associated-types-coherence-failure.rs:21:1
|
LL | impl<'a, B: ?Sized> IntoCow<'a, B> for <B as ToOwned>::Owned where B: ToOwned {
| ----------------------------------------------------------------------------- first implementation here
...
LL | impl<'a, B: ?Sized> IntoCow<'a, B> for Cow<'a, B> where B: ToOwned {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Cow<'_, _>`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `<_ as ToOwned>::Owned`

error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `&_`
error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `<_ as ToOwned>::Owned`
--> $DIR/associated-types-coherence-failure.rs:28:1
|
LL | impl<'a, B: ?Sized> IntoCow<'a, B> for <B as ToOwned>::Owned where B: ToOwned {
| ----------------------------------------------------------------------------- first implementation here
...
LL | impl<'a, B: ?Sized> IntoCow<'a, B> for &'a B where B: ToOwned {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `<_ as ToOwned>::Owned`

error: aborting due to 2 previous errors

Expand Down
30 changes: 0 additions & 30 deletions tests/ui/auto-traits/opaque_type_candidate_selection.rs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ LL | impl<'a, T: MyPredicate<'a>> MyTrait<'a> for T {}
| ---------------------------------------------- first implementation here
LL | impl<'a, T> MyTrait<'a> for &'a T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
|
= note: downstream crates may implement trait `MyPredicate<'_>` for type `&_`

error: aborting due to 1 previous error

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ LL | impl<'a, T: MyPredicate<'a>> MyTrait<'a> for T {}
| ---------------------------------------------- first implementation here
LL | impl<'a, T> MyTrait<'a> for &'a T {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
|
= note: downstream crates may implement trait `MyPredicate<'_>` for type `&_`

error: aborting due to 1 previous error

Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions tests/ui/coherence/coherence-overlap-downstream-inherent.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//@ revisions: old next
//@[next] compile-flags: -Znext-solver

// Tests that we consider `T: Sugar + Fruit` to be ambiguous, even
// though no impls are found.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0592]: duplicate definitions with name `dummy`
--> $DIR/coherence-overlap-downstream-inherent.rs:10:26
--> $DIR/coherence-overlap-downstream-inherent.rs:7:26
|
LL | impl<T:Sugar> Sweet<T> { fn dummy(&self) { } }
| ^^^^^^^^^^^^^^^ duplicate definitions for `dummy`
Expand All @@ -8,7 +8,7 @@ LL | impl<T:Fruit> Sweet<T> { fn dummy(&self) { } }
| --------------- other definition for `dummy`

error[E0592]: duplicate definitions with name `f`
--> $DIR/coherence-overlap-downstream-inherent.rs:16:38
--> $DIR/coherence-overlap-downstream-inherent.rs:13:38
|
LL | impl<X, T> A<T, X> where T: Bar<X> { fn f(&self) {} }
| ^^^^^^^^^^^ duplicate definitions for `f`
Expand Down
21 changes: 0 additions & 21 deletions tests/ui/coherence/coherence-overlap-downstream.next.stderr

This file was deleted.

3 changes: 0 additions & 3 deletions tests/ui/coherence/coherence-overlap-downstream.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//@ revisions: old next
//@[next] compile-flags: -Znext-solver

// Tests that we consider `T: Sugar + Fruit` to be ambiguous, even
// though no impls are found.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
error[E0119]: conflicting implementations of trait `Sweet`
--> $DIR/coherence-overlap-downstream.rs:11:1
--> $DIR/coherence-overlap-downstream.rs:8:1
|
LL | impl<T:Sugar> Sweet for T { }
| ------------------------- first implementation here
LL | impl<T:Fruit> Sweet for T { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation

error[E0119]: conflicting implementations of trait `Foo<_>` for type `i32`
--> $DIR/coherence-overlap-downstream.rs:17:1
--> $DIR/coherence-overlap-downstream.rs:14:1
|
LL | impl<X, T> Foo<X> for T where T: Bar<X> {}
| --------------------------------------- first implementation here
Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions tests/ui/coherence/coherence-overlap-issue-23516-inherent.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//@ revisions: old next
//@[next] compile-flags: -Znext-solver

// Tests that we consider `Box<U>: !Sugar` to be ambiguous, even
// though we see no impl of `Sugar` for `Box`. Therefore, an overlap
// error is reported for the following pair of impls (#23516).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0592]: duplicate definitions with name `dummy`
--> $DIR/coherence-overlap-issue-23516-inherent.rs:12:25
--> $DIR/coherence-overlap-issue-23516-inherent.rs:9:25
|
LL | impl<T:Sugar> Cake<T> { fn dummy(&self) { } }
| ^^^^^^^^^^^^^^^ duplicate definitions for `dummy`
Expand Down
13 changes: 0 additions & 13 deletions tests/ui/coherence/coherence-overlap-issue-23516.old.stderr

This file was deleted.

3 changes: 0 additions & 3 deletions tests/ui/coherence/coherence-overlap-issue-23516.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
//@ revisions: old next
//@[next] compile-flags: -Znext-solver

// Tests that we consider `Box<U>: !Sugar` to be ambiguous, even
// though we see no impl of `Sugar` for `Box`. Therefore, an overlap
// error is reported for the following pair of impls (#23516).
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `Sweet` for type `Box<_>`
--> $DIR/coherence-overlap-issue-23516.rs:11:1
--> $DIR/coherence-overlap-issue-23516.rs:8:1
|
LL | impl<T:Sugar> Sweet for T { }
| ------------------------- first implementation here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ LL | impl<T: DerefMut> Foo for T {}
| --------------------------- first implementation here
LL | impl<U> Foo for &U {}
| ^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
|
= note: downstream crates may implement trait `std::ops::DerefMut` for type `&_`

error: aborting due to 1 previous error

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// "Coherence incorrectly considers `unnormalizable_projection: Trait` to not hold even if it could"
#![crate_type = "lib"]

//@ revisions: classic next
//@[next] compile-flags: -Znext-solver

trait WhereBound {}
impl WhereBound for () {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0119]: conflicting implementations of trait `Trait` for type `Box<_>`
--> $DIR/coherence-overlap-unnormalizable-projection-0.rs:27:1
--> $DIR/coherence-overlap-unnormalizable-projection-0.rs:24:1
|
LL | / impl<T> Trait for T
LL | | where
Expand Down
Loading
Loading