Skip to content

Commit c4ad3ec

Browse files
committed
stabilize -Znext-solver=coherence
1 parent 4cc494b commit c4ad3ec

File tree

68 files changed

+347
-329
lines changed

Some content is hidden

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

68 files changed

+347
-329
lines changed

compiler/rustc_ast_passes/src/feature_gate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ fn check_incompatible_features(sess: &Session, features: &Features) {
666666
}
667667

668668
fn check_new_solver_banned_features(sess: &Session, features: &Features) {
669-
if !sess.opts.unstable_opts.next_solver.is_some_and(|n| n.globally) {
669+
if !sess.opts.unstable_opts.next_solver.globally {
670670
return;
671671
}
672672

compiler/rustc_interface/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ fn test_unstable_options_tracking_hash() {
810810
tracked!(mir_opt_level, Some(4));
811811
tracked!(move_size_limit, Some(4096));
812812
tracked!(mutable_noalias, false);
813-
tracked!(next_solver, Some(NextSolverConfig { coherence: true, globally: false }));
813+
tracked!(next_solver, NextSolverConfig { coherence: true, globally: true });
814814
tracked!(no_generate_arange_section, true);
815815
tracked!(no_jump_tables, true);
816816
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
@@ -3126,11 +3126,11 @@ impl<'tcx> TyCtxt<'tcx> {
31263126
}
31273127

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

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

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

compiler/rustc_session/src/config.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,11 @@ 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+
}
845850

846851
#[derive(Clone)]
847852
pub enum Input {

compiler/rustc_session/src/options.rs

Lines changed: 10 additions & 21 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-
"a comma separated list of solver configurations: `globally` (default), and `coherence`";
406+
"either `globally` (when used without an argument), `coherence` (default) or `no`";
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 =
@@ -1123,27 +1123,16 @@ mod parse {
11231123
}
11241124
}
11251125

1126-
pub(crate) fn parse_next_solver_config(
1127-
slot: &mut Option<NextSolverConfig>,
1128-
v: Option<&str>,
1129-
) -> bool {
1126+
pub(crate) fn parse_next_solver_config(slot: &mut NextSolverConfig, v: Option<&str>) -> bool {
11301127
if let Some(config) = v {
1131-
let mut coherence = false;
1132-
let mut globally = true;
1133-
for c in config.split(',') {
1134-
match c {
1135-
"globally" => globally = true,
1136-
"coherence" => {
1137-
globally = false;
1138-
coherence = true;
1139-
}
1140-
_ => return false,
1141-
}
1142-
}
1143-
1144-
*slot = Some(NextSolverConfig { coherence: coherence || globally, globally });
1128+
*slot = match config {
1129+
"no" => NextSolverConfig { coherence: false, globally: false },
1130+
"coherence" => NextSolverConfig { coherence: true, globally: false },
1131+
"globally" => NextSolverConfig { coherence: true, globally: true },
1132+
_ => return false,
1133+
};
11451134
} else {
1146-
*slot = Some(NextSolverConfig { coherence: true, globally: true });
1135+
*slot = NextSolverConfig { coherence: true, globally: true };
11471136
}
11481137

11491138
true
@@ -1914,7 +1903,7 @@ options! {
19141903
"the size at which the `large_assignments` lint starts to be emitted"),
19151904
mutable_noalias: bool = (true, parse_bool, [TRACKED],
19161905
"emit noalias metadata for mutable references (default: yes)"),
1917-
next_solver: Option<NextSolverConfig> = (None, parse_next_solver_config, [TRACKED],
1906+
next_solver: NextSolverConfig = (NextSolverConfig::default(), parse_next_solver_config, [TRACKED],
19181907
"enable and configure the next generation trait solver used by rustc"),
19191908
nll_facts: bool = (false, parse_bool, [UNTRACKED],
19201909
"dump facts from NLL analysis into side files (default: no)"),

compiler/rustc_trait_selection/src/traits/engine.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,8 @@ where
3636
if infcx.next_trait_solver() {
3737
Box::new(NextFulfillmentCtxt::new(infcx))
3838
} else {
39-
let new_solver_globally =
40-
infcx.tcx.sess.opts.unstable_opts.next_solver.map_or(false, |c| c.globally);
4139
assert!(
42-
!new_solver_globally,
40+
!infcx.tcx.next_trait_solver_globally(),
4341
"using old solver even though new solver is enabled globally"
4442
);
4543
Box::new(FulfillmentContext::new(infcx))

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 `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/auto-traits/opaque_type_candidate_selection.rs

Lines changed: 0 additions & 30 deletions
This file was deleted.

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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 2 additions & 0 deletions
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

0 commit comments

Comments
 (0)