Skip to content

Commit f753bc7

Browse files
committed
Auto merge of rust-lang#130249 - compiler-errors:sad-new-solver-coherence, r=lcnr
Revert "Stabilize `-Znext-solver=coherence`" This is a clean revert of rust-lang#121848, prepared by running: ``` $ git revert 17b322f -m1 ``` Which effectively reverts: * a138a92, 69fdd14, d93e047, 1a893ac see: https://rust-lang.zulipchat.com/#narrow/stream/364551-t-types.2Ftrait-system-refactor/topic/nalgebra.20hang Closes rust-lang#130056 r? lcnr
2 parents 7c7372b + e866f8a commit f753bc7

File tree

104 files changed

+578
-392
lines changed

Some content is hidden

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

104 files changed

+578
-392
lines changed

compiler/rustc_interface/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ fn test_unstable_options_tracking_hash() {
808808
tracked!(mir_opt_level, Some(4));
809809
tracked!(move_size_limit, Some(4096));
810810
tracked!(mutable_noalias, false);
811-
tracked!(next_solver, NextSolverConfig { coherence: true, globally: true });
811+
tracked!(next_solver, Some(NextSolverConfig { coherence: true, globally: false }));
812812
tracked!(no_generate_arange_section, true);
813813
tracked!(no_jump_tables, true);
814814
tracked!(no_link, true);

compiler/rustc_middle/src/ty/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3132,11 +3132,11 @@ impl<'tcx> TyCtxt<'tcx> {
31323132
}
31333133

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

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

31423142
pub fn is_impl_trait_in_trait(self, def_id: DefId) -> bool {

compiler/rustc_session/src/config.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -842,11 +842,6 @@ pub struct NextSolverConfig {
842842
/// This is only `true` if `coherence` is also enabled.
843843
pub globally: bool,
844844
}
845-
impl Default for NextSolverConfig {
846-
fn default() -> Self {
847-
NextSolverConfig { coherence: true, globally: false }
848-
}
849-
}
850845

851846
#[derive(Clone)]
852847
pub enum Input {

compiler/rustc_session/src/options.rs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ mod desc {
403403
pub(crate) const parse_unpretty: &str = "`string` or `string=string`";
404404
pub(crate) const parse_treat_err_as_bug: &str = "either no value or a non-negative number";
405405
pub(crate) const parse_next_solver_config: &str =
406-
"either `globally` (when used without an argument), `coherence` (default) or `no`";
406+
"a comma separated list of solver configurations: `globally` (default), and `coherence`";
407407
pub(crate) const parse_lto: &str =
408408
"either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted";
409409
pub(crate) const parse_linker_plugin_lto: &str =
@@ -1105,16 +1105,27 @@ mod parse {
11051105
}
11061106
}
11071107

1108-
pub(crate) fn parse_next_solver_config(slot: &mut NextSolverConfig, v: Option<&str>) -> bool {
1108+
pub(crate) fn parse_next_solver_config(
1109+
slot: &mut Option<NextSolverConfig>,
1110+
v: Option<&str>,
1111+
) -> bool {
11091112
if let Some(config) = v {
1110-
*slot = match config {
1111-
"no" => NextSolverConfig { coherence: false, globally: false },
1112-
"coherence" => NextSolverConfig { coherence: true, globally: false },
1113-
"globally" => NextSolverConfig { coherence: true, globally: true },
1114-
_ => return false,
1115-
};
1113+
let mut coherence = false;
1114+
let mut globally = true;
1115+
for c in config.split(',') {
1116+
match c {
1117+
"globally" => globally = true,
1118+
"coherence" => {
1119+
globally = false;
1120+
coherence = true;
1121+
}
1122+
_ => return false,
1123+
}
1124+
}
1125+
1126+
*slot = Some(NextSolverConfig { coherence: coherence || globally, globally });
11161127
} else {
1117-
*slot = NextSolverConfig { coherence: true, globally: true };
1128+
*slot = Some(NextSolverConfig { coherence: true, globally: true });
11181129
}
11191130

11201131
true
@@ -1867,7 +1878,7 @@ options! {
18671878
"the size at which the `large_assignments` lint starts to be emitted"),
18681879
mutable_noalias: bool = (true, parse_bool, [TRACKED],
18691880
"emit noalias metadata for mutable references (default: yes)"),
1870-
next_solver: NextSolverConfig = (NextSolverConfig::default(), parse_next_solver_config, [TRACKED],
1881+
next_solver: Option<NextSolverConfig> = (None, parse_next_solver_config, [TRACKED],
18711882
"enable and configure the next generation trait solver used by rustc"),
18721883
nll_facts: bool = (false, parse_bool, [UNTRACKED],
18731884
"dump facts from NLL analysis into side files (default: no)"),

compiler/rustc_trait_selection/src/traits/engine.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ where
3535
if infcx.next_trait_solver() {
3636
Box::new(NextFulfillmentCtxt::new(infcx))
3737
} else {
38+
let new_solver_globally =
39+
infcx.tcx.sess.opts.unstable_opts.next_solver.map_or(false, |c| c.globally);
3840
assert!(
39-
!infcx.tcx.next_trait_solver_globally(),
41+
!new_solver_globally,
4042
"using old solver even though new solver is enabled globally"
4143
);
4244
Box::new(FulfillmentContext::new(infcx))
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// regression test for #118987
1+
//@ known-bug: #118987
22
#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
33

44
trait Assoc {
@@ -15,5 +15,3 @@ trait Foo {}
1515

1616
impl Foo for <u8 as Assoc>::Output {}
1717
impl Foo for <u16 as Assoc>::Output {}
18-
//~^ ERROR the trait bound `u16: Assoc` is not satisfied
19-
fn main() {}

tests/crashes/118987.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@ known-bug: #118987
2+
#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
3+
4+
trait Assoc {
5+
type Output;
6+
}
7+
8+
default impl<T: Clone> Assoc for T {
9+
type Output = bool;
10+
}
11+
12+
impl Assoc for u8 {}
13+
14+
trait Foo {}
15+
16+
impl Foo for <u8 as Assoc>::Output {}
17+
impl Foo for <u16 as Assoc>::Output {}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1+
//@ known-bug: #124207
12
#![feature(transmutability)]
23
#![feature(type_alias_impl_trait)]
34
trait OpaqueTrait {}
45
type OpaqueType = impl OpaqueTrait;
5-
//~^ ERROR unconstrained opaque type
66
trait AnotherTrait {}
77
impl<T: std::mem::TransmuteFrom<(), ()>> AnotherTrait for T {}
8-
//~^ ERROR type provided when a constant was expected
98
impl AnotherTrait for OpaqueType {}
10-
//~^ ERROR conflicting implementations of trait `AnotherTrait`
119
pub fn main() {}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// regression test for #73299.
2-
#![feature(specialization)] //~ WARN the feature `specialization` is incomplete
1+
//@ known-bug: #74299
2+
#![feature(specialization)]
33

44
trait X {
55
type U;
@@ -18,7 +18,6 @@ trait Y {
1818

1919
impl Y for <() as X>::U {}
2020
impl Y for <i32 as X>::U {}
21-
//~^ ERROR conflicting implementations of trait `Y` for type `<() as X>::U`
2221

2322
fn main() {
2423
().f().g();

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `<_ as ToOwned>::Owned`
1+
error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `Cow<'_, _>`
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 `<_ as ToOwned>::Owned`
8+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Cow<'_, _>`
99

10-
error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `<_ as ToOwned>::Owned`
10+
error[E0119]: conflicting implementations of trait `IntoCow<'_, _>` for type `&_`
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 `<_ as ToOwned>::Owned`
17+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `&_`
1818

1919
error: aborting due to 2 previous errors
2020

0 commit comments

Comments
 (0)