Skip to content

Commit f899a56

Browse files
committed
stabilize -Znext-solver=coherence
1 parent 0700ec0 commit f899a56

File tree

43 files changed

+241
-156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+241
-156
lines changed

compiler/rustc_session/src/config.rs

+10
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,16 @@ pub struct NextSolverConfig {
736736
pub dump_tree: DumpSolverProofTree,
737737
}
738738

739+
impl Default for NextSolverConfig {
740+
fn default() -> Self {
741+
NextSolverConfig {
742+
coherence: true,
743+
globally: false,
744+
dump_tree: DumpSolverProofTree::default(),
745+
}
746+
}
747+
}
748+
739749
#[derive(Default, Debug, Copy, Clone, Hash, PartialEq, Eq)]
740750
pub enum DumpSolverProofTree {
741751
Always,

compiler/rustc_session/src/options.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ mod desc {
398398
pub const parse_instrument_xray: &str = "either a boolean (`yes`, `no`, `on`, `off`, etc), or a comma separated list of settings: `always` or `never` (mutually exclusive), `ignore-loops`, `instruction-threshold=N`, `skip-entry`, `skip-exit`";
399399
pub const parse_unpretty: &str = "`string` or `string=string`";
400400
pub const parse_treat_err_as_bug: &str = "either no value or a non-negative number";
401-
pub const parse_next_solver_config: &str = "a comma separated list of solver configurations: `globally` (default), `coherence`, `dump-tree`, `dump-tree-on-error";
401+
pub const parse_next_solver_config: &str = "a comma separated list of solver configurations: `globally` (default), `no`, `dump-tree`, `dump-tree-on-error";
402402
pub const parse_lto: &str =
403403
"either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted";
404404
pub const parse_linker_plugin_lto: &str =
@@ -1023,6 +1023,10 @@ mod parse {
10231023
let mut dump_tree = None;
10241024
for c in config.split(',') {
10251025
match c {
1026+
"no" => {
1027+
*slot = None;
1028+
return true;
1029+
}
10261030
"globally" => globally = true,
10271031
"coherence" => {
10281032
globally = false;
@@ -1736,7 +1740,7 @@ options! {
17361740
"the size at which the `large_assignments` lint starts to be emitted"),
17371741
mutable_noalias: bool = (true, parse_bool, [TRACKED],
17381742
"emit noalias metadata for mutable references (default: yes)"),
1739-
next_solver: Option<NextSolverConfig> = (None, parse_next_solver_config, [TRACKED],
1743+
next_solver: Option<NextSolverConfig> = (Some(NextSolverConfig::default()), parse_next_solver_config, [TRACKED],
17401744
"enable and configure the next generation trait solver used by rustc"),
17411745
nll_facts: bool = (false, parse_bool, [UNTRACKED],
17421746
"dump facts from NLL analysis into side files (default: no)"),

tests/ui/associated-types/associated-types-coherence-failure.stderr

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

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

1919
error: aborting due to 2 previous errors
2020

tests/ui/coherence/coherence-negative-outlives-lifetimes.stock.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ LL | impl<'a, T: MyPredicate<'a>> MyTrait<'a> for T {}
55
| ---------------------------------------------- first implementation here
66
LL | impl<'a, T> MyTrait<'a> for &'a T {}
77
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
8+
|
9+
= note: downstream crates may implement trait `MyPredicate<'_>` for type `&_`
810

911
error: aborting due to 1 previous error
1012

tests/ui/coherence/coherence-negative-outlives-lifetimes.with_negative_coherence.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ LL | impl<'a, T: MyPredicate<'a>> MyTrait<'a> for T {}
55
| ---------------------------------------------- first implementation here
66
LL | impl<'a, T> MyTrait<'a> for &'a T {}
77
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
8+
|
9+
= note: downstream crates may implement trait `MyPredicate<'_>` for type `&_`
810

911
error: aborting due to 1 previous error
1012

tests/ui/coherence/coherence-overlap-negate-not-use-feature-gate.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ LL | impl<T: DerefMut> Foo for T {}
55
| --------------------------- first implementation here
66
LL | impl<U> Foo for &U {}
77
| ^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
8+
|
9+
= note: downstream crates may implement trait `std::ops::DerefMut` for type `&_`
810

911
error: aborting due to 1 previous error
1012

tests/ui/coherence/negative-coherence-check-placeholder-outlives.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ LL | impl<T> Bar for T where T: Foo {}
55
| ------------------------------ first implementation here
66
LL | impl<T> Bar for Box<T> {}
77
| ^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Box<_>`
8+
|
9+
= note: downstream crates may implement trait `Foo` for type `std::boxed::Box<_>`
810

911
error: aborting due to 1 previous error
1012

tests/ui/coherence/negative-coherence-considering-regions.any_lt.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ LL | impl<T> Bar for T where T: Foo {}
66
...
77
LL | impl<T> Bar for &T {}
88
| ^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
9+
|
10+
= note: downstream crates may implement trait `Foo` for type `&_`
911

1012
error: aborting due to 1 previous error
1113

tests/ui/coherence/negative-coherence-placeholder-region-constraints-on-unification.explicit.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ LL | impl<T: ?Sized> FnMarker for fn(&T) {}
88
|
99
= warning: the behavior may change in a future release
1010
= note: for more information, see issue #56105 <https://github.com/rust-lang/rust/issues/56105>
11+
= note: downstream crates may implement trait `Marker` for type `&_`
1112
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
1213
note: the lint level is defined here
1314
--> $DIR/negative-coherence-placeholder-region-constraints-on-unification.rs:4:11

tests/ui/coherence/normalize-for-errors.current.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
error[E0119]: conflicting implementations of trait `MyTrait<_>` for type `(Box<(MyType,)>, _)`
1+
error[E0119]: conflicting implementations of trait `MyTrait<_>` for type `(Box<(MyType,)>, <_ as Iterator>::Item)`
22
--> $DIR/normalize-for-errors.rs:16:1
33
|
44
LL | impl<T: Copy, S: Iterator> MyTrait<S> for (T, S::Item) {}
55
| ------------------------------------------------------ first implementation here
66
LL |
77
LL | impl<S: Iterator> MyTrait<S> for (Box<<(MyType,) as Mirror>::Assoc>, S::Item) {}
8-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(Box<(MyType,)>, _)`
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(Box<(MyType,)>, <_ as Iterator>::Item)`
99
|
1010
= note: upstream crates may add a new impl of trait `std::marker::Copy` for type `std::boxed::Box<(MyType,)>` in future versions
1111

tests/ui/coherence/occurs-check/associated-type.old.stderr

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
2-
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
32
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
4-
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
53
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
6-
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
74
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, ReBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
8-
WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, RePlaceholder(!2_BoundRegion { var: 0, kind: BrNamed(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), 'a) })], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit) }
9-
error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), _)>` for type `for<'a> fn(&'a (), _)`
5+
error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), ())>` for type `for<'a> fn(&'a (), ())`
106
--> $DIR/associated-type.rs:31:1
117
|
128
LL | impl<T> Overlap<T> for T {
@@ -16,7 +12,7 @@ LL | / impl<T> Overlap<for<'a> fn(&'a (), Assoc<'a, T>)> for T
1612
LL | |
1713
LL | | where
1814
LL | | for<'a> *const T: ToUnit<'a>,
19-
| |_________________________________^ conflicting implementation for `for<'a> fn(&'a (), _)`
15+
| |_________________________________^ conflicting implementation for `for<'a> fn(&'a (), ())`
2016
|
2117
= note: this behavior recently changed as a result of a bug fix; see rust-lang/rust#56105 for details
2218

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0119]: conflicting implementations of trait `Trait<_>`
2+
--> $DIR/opaques.rs:27:1
3+
|
4+
LL | impl<T> Trait<T> for T {
5+
| ---------------------- first implementation here
6+
...
7+
LL | impl<T> Trait<T> for defining_scope::Alias<T> {
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
9+
10+
error: aborting due to 1 previous error
11+
12+
For more information about this error, try `rustc --explain E0119`.

tests/ui/coherence/occurs-check/opaques.next.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0119]: conflicting implementations of trait `Trait<_>`
2-
--> $DIR/opaques.rs:30:1
2+
--> $DIR/opaques.rs:27:1
33
|
44
LL | impl<T> Trait<T> for T {
55
| ---------------------- first implementation here
@@ -8,7 +8,7 @@ LL | impl<T> Trait<T> for defining_scope::Alias<T> {
88
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
99

1010
error[E0282]: type annotations needed
11-
--> $DIR/opaques.rs:13:20
11+
--> $DIR/opaques.rs:10:20
1212
|
1313
LL | pub fn cast<T>(x: Container<Alias<T>, T>) -> Container<T, T> {
1414
| ^ cannot infer type for struct `Container<T, T>`

tests/ui/coherence/occurs-check/opaques.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
//@revisions: old next
1+
//@revisions: current next
22
//@[next] compile-flags: -Znext-solver
33

44
// A regression test for #105787
5-
6-
//@[old] known-bug: #105787
7-
//@[old] check-pass
85
#![feature(type_alias_impl_trait)]
96
mod defining_scope {
107
use super::*;
@@ -28,7 +25,7 @@ impl<T> Trait<T> for T {
2825
type Assoc = Box<u32>;
2926
}
3027
impl<T> Trait<T> for defining_scope::Alias<T> {
31-
//[next]~^ ERROR conflicting implementations of trait
28+
//~^ ERROR conflicting implementations of trait
3229
type Assoc = usize;
3330
}
3431

tests/ui/dyn-star/param-env-region-infer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@ revisions: current
22
//@ incremental
33

4-
// FIXME(-Znext-solver): THis currently results in unstable query results:
4+
// FIXME(-Znext-solver): This currently results in unstable query results:
55
// `normalizes-to(opaque, opaque)` changes from `Maybe(Ambiguous)` to `Maybe(Overflow)`
66
// once the hidden type of the opaque is already defined to be itself.
77

tests/ui/error-codes/e0119/issue-23563.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0119]: conflicting implementations of trait `LolFrom<&[_]>` for type `LocalType<_>`
1+
error[E0119]: conflicting implementations of trait `LolFrom<&[u8]>` for type `LocalType<u8>`
22
--> $DIR/issue-23563.rs:13:1
33
|
44
LL | impl<'a, T> LolFrom<&'a [T]> for LocalType<T> {

tests/ui/feature-gates/feature-gate-with_negative_coherence.stderr

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ LL | impl<T: std::ops::DerefMut> Foo for T { }
66
LL |
77
LL | impl<T> Foo for &T { }
88
| ^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
9+
|
10+
= note: downstream crates may implement trait `std::ops::DerefMut` for type `&_`
911

1012
error: aborting due to 1 previous error
1113

tests/ui/impl-trait/auto-trait-coherence.old.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
1+
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<_>`
22
--> $DIR/auto-trait-coherence.rs:24:1
33
|
44
LL | impl<T: Send> AnotherTrait for T {}
55
| -------------------------------- first implementation here
66
...
77
LL | impl AnotherTrait for D<OpaqueType> {
8-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>`
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<_>`
99

1010
error: aborting due to 1 previous error
1111

tests/ui/impl-trait/auto-trait-coherence.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
//@ revisions: old next
2-
//@[next] compile-flags: -Znext-solver
3-
41
// Tests that type alias impls traits do not leak auto-traits for
52
// the purposes of coherence checking
63
#![feature(type_alias_impl_trait)]
@@ -22,8 +19,7 @@ impl<T: Send> AnotherTrait for T {}
2219
// (We treat opaque types as "foreign types" that could grow more impls
2320
// in the future.)
2421
impl AnotherTrait for D<OpaqueType> {
25-
//[old]~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
26-
//[next]~^^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<_>`
22+
//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<_>`
2723
}
2824

2925
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<_>`
2+
--> $DIR/auto-trait-coherence.rs:21:1
3+
|
4+
LL | impl<T: Send> AnotherTrait for T {}
5+
| -------------------------------- first implementation here
6+
...
7+
LL | impl AnotherTrait for D<OpaqueType> {
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<_>`
9+
10+
error: aborting due to 1 previous error
11+
12+
For more information about this error, try `rustc --explain E0119`.

tests/ui/impl-trait/coherence-treats-tait-ambig.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ type T = impl Sized;
55
struct Foo;
66

77
impl Into<T> for Foo {
8-
//~^ ERROR conflicting implementations of trait `Into<T>` for type `Foo`
8+
//~^ ERROR conflicting implementations of trait `Into<_>` for type `Foo`
99
fn into(self) -> T {
1010
Foo
1111
}

tests/ui/impl-trait/coherence-treats-tait-ambig.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error[E0119]: conflicting implementations of trait `Into<T>` for type `Foo`
1+
error[E0119]: conflicting implementations of trait `Into<_>` for type `Foo`
22
--> $DIR/coherence-treats-tait-ambig.rs:7:1
33
|
44
LL | impl Into<T> for Foo {

tests/ui/impl-trait/negative-reasoning.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ impl<T: std::fmt::Debug> AnotherTrait for T {}
1717

1818
// This is in error, because we cannot assume that `OpaqueType: !Debug`
1919
impl AnotherTrait for D<OpaqueType> {
20-
//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
20+
//~^ ERROR conflicting implementations of trait `AnotherTrait` for type `D<_>`
2121
}
2222

2323
fn main() {}

tests/ui/impl-trait/negative-reasoning.stderr

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<OpaqueType>`
1+
error[E0119]: conflicting implementations of trait `AnotherTrait` for type `D<_>`
22
--> $DIR/negative-reasoning.rs:19:1
33
|
44
LL | impl<T: std::fmt::Debug> AnotherTrait for T {}
55
| ------------------------------------------- first implementation here
66
...
77
LL | impl AnotherTrait for D<OpaqueType> {
8-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<OpaqueType>`
9-
|
10-
= note: upstream crates may add a new impl of trait `std::marker::FnPtr` for type `OpaqueType` in future versions
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `D<_>`
119

1210
error: aborting due to 1 previous error
1311

0 commit comments

Comments
 (0)