Rollup merge of #106385 - compiler-errors:new-solver-flag, r=jackh726
Split `-Zchalk` flag into `-Ztrait-solver=(classic|chalk|next)` flag We'll eventually need a way to select more than chalk + not-chalk. Does this need an MCP since it's touching a `-Z` flag? Or perhaps I should preserve `-Zchalk` for the time being... maybe I could make it a warning to use that flag? cc ``@rust-lang/types`` r? types
This commit is contained in:
commit
13bb8a8b15
39 changed files with 78 additions and 48 deletions
|
@ -4,6 +4,7 @@ use crate::interface::parse_cfgspecs;
|
|||
use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig};
|
||||
use rustc_session::config::rustc_optgroups;
|
||||
use rustc_session::config::TraitSolver;
|
||||
use rustc_session::config::{build_configuration, build_session_options, to_crate_config};
|
||||
use rustc_session::config::{
|
||||
BranchProtection, Externs, OomStrategy, OutputType, OutputTypes, PAuthKey, PacRet,
|
||||
|
@ -722,7 +723,6 @@ fn test_unstable_options_tracking_hash() {
|
|||
pac_ret: Some(PacRet { leaf: true, key: PAuthKey::B })
|
||||
})
|
||||
);
|
||||
tracked!(chalk, true);
|
||||
tracked!(codegen_backend, Some("abc".to_string()));
|
||||
tracked!(crate_attr, vec!["abc".to_string()]);
|
||||
tracked!(debug_info_for_profiling, true);
|
||||
|
@ -792,6 +792,7 @@ fn test_unstable_options_tracking_hash() {
|
|||
tracked!(thinlto, Some(true));
|
||||
tracked!(thir_unsafeck, true);
|
||||
tracked!(tls_model, Some(TlsModel::GeneralDynamic));
|
||||
tracked!(trait_solver, TraitSolver::Chalk);
|
||||
tracked!(translate_remapped_path_to_local_path, false);
|
||||
tracked!(trap_unreachable, Some(false));
|
||||
tracked!(treat_err_as_bug, NonZeroUsize::new(1));
|
||||
|
|
|
@ -554,6 +554,16 @@ pub enum PrintRequest {
|
|||
SplitDebuginfo,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
pub enum TraitSolver {
|
||||
/// Classic trait solver in `rustc_trait_selection::traits::select`
|
||||
Classic,
|
||||
/// Chalk trait solver
|
||||
Chalk,
|
||||
/// Experimental trait solver in `rustc_trait_selection::solve`
|
||||
Next,
|
||||
}
|
||||
|
||||
pub enum Input {
|
||||
/// Load source code from a file.
|
||||
File(PathBuf),
|
||||
|
@ -2761,7 +2771,7 @@ pub(crate) mod dep_tracking {
|
|||
BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, ErrorOutputType,
|
||||
InstrumentCoverage, LdImpl, LinkerPluginLto, LocationDetail, LtoCli, OomStrategy, OptLevel,
|
||||
OutputType, OutputTypes, Passes, SourceFileHashAlgorithm, SplitDwarfKind,
|
||||
SwitchWithOptPath, SymbolManglingVersion, TrimmedDefPaths,
|
||||
SwitchWithOptPath, SymbolManglingVersion, TraitSolver, TrimmedDefPaths,
|
||||
};
|
||||
use crate::lint;
|
||||
use crate::options::WasiExecModel;
|
||||
|
@ -2861,6 +2871,7 @@ pub(crate) mod dep_tracking {
|
|||
BranchProtection,
|
||||
OomStrategy,
|
||||
LanguageIdentifier,
|
||||
TraitSolver,
|
||||
);
|
||||
|
||||
impl<T1, T2> DepTrackingHash for (T1, T2)
|
||||
|
|
|
@ -382,6 +382,8 @@ mod desc {
|
|||
"`all` (default), `except-unused-generics`, `except-unused-functions`, or `off`";
|
||||
pub const parse_unpretty: &str = "`string` or `string=string`";
|
||||
pub const parse_treat_err_as_bug: &str = "either no value or a number bigger than 0";
|
||||
pub const parse_trait_solver: &str =
|
||||
"one of the supported solver modes (`classic`, `chalk`, or `next`)";
|
||||
pub const parse_lto: &str =
|
||||
"either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted";
|
||||
pub const parse_linker_plugin_lto: &str =
|
||||
|
@ -880,6 +882,18 @@ mod parse {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn parse_trait_solver(slot: &mut TraitSolver, v: Option<&str>) -> bool {
|
||||
match v {
|
||||
Some("classic") => *slot = TraitSolver::Classic,
|
||||
Some("chalk") => *slot = TraitSolver::Chalk,
|
||||
Some("next") => *slot = TraitSolver::Next,
|
||||
// default trait solver is subject to change..
|
||||
Some("default") => *slot = TraitSolver::Classic,
|
||||
_ => return false,
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
pub(crate) fn parse_lto(slot: &mut LtoCli, v: Option<&str>) -> bool {
|
||||
if v.is_some() {
|
||||
let mut bool_arg = None;
|
||||
|
@ -1249,8 +1263,6 @@ options! {
|
|||
"instrument control-flow architecture protection"),
|
||||
cgu_partitioning_strategy: Option<String> = (None, parse_opt_string, [TRACKED],
|
||||
"the codegen unit partitioning strategy to use"),
|
||||
chalk: bool = (false, parse_bool, [TRACKED],
|
||||
"enable the experimental Chalk-based trait solving engine"),
|
||||
codegen_backend: Option<String> = (None, parse_opt_string, [TRACKED],
|
||||
"the backend to use"),
|
||||
combine_cgu: bool = (false, parse_bool, [TRACKED],
|
||||
|
@ -1609,6 +1621,8 @@ options! {
|
|||
"for every macro invocation, print its name and arguments (default: no)"),
|
||||
track_diagnostics: bool = (false, parse_bool, [UNTRACKED],
|
||||
"tracks where in rustc a diagnostic was emitted"),
|
||||
trait_solver: TraitSolver = (TraitSolver::Classic, parse_trait_solver, [TRACKED],
|
||||
"specify the trait solver mode used by rustc (default: classic)"),
|
||||
// Diagnostics are considered side-effects of a query (see `QuerySideEffects`) and are saved
|
||||
// alongside query results and changes to translation options can affect diagnostics - so
|
||||
// translation options should be tracked.
|
||||
|
|
|
@ -3,6 +3,7 @@ use std::fmt::Debug;
|
|||
|
||||
use super::TraitEngine;
|
||||
use super::{ChalkFulfillmentContext, FulfillmentContext};
|
||||
use crate::solve::FulfillmentCtxt as NextFulfillmentCtxt;
|
||||
use crate::traits::NormalizeExt;
|
||||
use rustc_data_structures::fx::FxIndexSet;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
|
@ -20,6 +21,7 @@ use rustc_middle::ty::error::TypeError;
|
|||
use rustc_middle::ty::ToPredicate;
|
||||
use rustc_middle::ty::TypeFoldable;
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
use rustc_session::config::TraitSolver;
|
||||
use rustc_span::Span;
|
||||
|
||||
pub trait TraitEngineExt<'tcx> {
|
||||
|
@ -29,18 +31,18 @@ pub trait TraitEngineExt<'tcx> {
|
|||
|
||||
impl<'tcx> TraitEngineExt<'tcx> for dyn TraitEngine<'tcx> {
|
||||
fn new(tcx: TyCtxt<'tcx>) -> Box<Self> {
|
||||
if tcx.sess.opts.unstable_opts.chalk {
|
||||
Box::new(ChalkFulfillmentContext::new())
|
||||
} else {
|
||||
Box::new(FulfillmentContext::new())
|
||||
match tcx.sess.opts.unstable_opts.trait_solver {
|
||||
TraitSolver::Classic => Box::new(FulfillmentContext::new()),
|
||||
TraitSolver::Chalk => Box::new(ChalkFulfillmentContext::new()),
|
||||
TraitSolver::Next => Box::new(NextFulfillmentCtxt::new()),
|
||||
}
|
||||
}
|
||||
|
||||
fn new_in_snapshot(tcx: TyCtxt<'tcx>) -> Box<Self> {
|
||||
if tcx.sess.opts.unstable_opts.chalk {
|
||||
Box::new(ChalkFulfillmentContext::new_in_snapshot())
|
||||
} else {
|
||||
Box::new(FulfillmentContext::new_in_snapshot())
|
||||
match tcx.sess.opts.unstable_opts.trait_solver {
|
||||
TraitSolver::Classic => Box::new(FulfillmentContext::new_in_snapshot()),
|
||||
TraitSolver::Chalk => Box::new(ChalkFulfillmentContext::new_in_snapshot()),
|
||||
TraitSolver::Next => Box::new(NextFulfillmentCtxt::new()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ use rustc_middle::ty::{
|
|||
self, SubtypePredicate, ToPolyTraitRef, ToPredicate, TraitRef, Ty, TyCtxt, TypeFoldable,
|
||||
TypeVisitable,
|
||||
};
|
||||
use rustc_session::config::TraitSolver;
|
||||
use rustc_session::Limit;
|
||||
use rustc_span::def_id::LOCAL_CRATE;
|
||||
use rustc_span::symbol::sym;
|
||||
|
@ -1167,7 +1168,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
|
||||
ty::PredicateKind::WellFormed(ty) => {
|
||||
if !self.tcx.sess.opts.unstable_opts.chalk {
|
||||
if self.tcx.sess.opts.unstable_opts.trait_solver != TraitSolver::Chalk {
|
||||
// WF predicates cannot themselves make
|
||||
// errors. They can only block due to
|
||||
// ambiguity; otherwise, they always
|
||||
|
|
|
@ -15,6 +15,7 @@ use rustc_middle::ty::{
|
|||
self, Binder, GenericArg, GenericArgKind, GenericParamDefKind, InternalSubsts, SubstsRef,
|
||||
ToPolyTraitRef, ToPredicate, TraitRef, Ty, TyCtxt,
|
||||
};
|
||||
use rustc_session::config::TraitSolver;
|
||||
use rustc_span::def_id::DefId;
|
||||
|
||||
use crate::traits::project::{normalize_with_depth, normalize_with_depth_to};
|
||||
|
@ -767,8 +768,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
debug!(?closure_def_id, ?trait_ref, ?nested, "confirm closure candidate obligations");
|
||||
|
||||
// FIXME: Chalk
|
||||
|
||||
if !self.tcx().sess.opts.unstable_opts.chalk {
|
||||
if self.tcx().sess.opts.unstable_opts.trait_solver != TraitSolver::Chalk {
|
||||
nested.push(obligation.with(
|
||||
self.tcx(),
|
||||
ty::Binder::dummy(ty::PredicateKind::ClosureKind(closure_def_id, substs, kind)),
|
||||
|
|
|
@ -2,6 +2,7 @@ use rustc_data_structures::fx::FxIndexSet;
|
|||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::ty::{self, Binder, Predicate, PredicateKind, ToPredicate, Ty, TyCtxt};
|
||||
use rustc_session::config::TraitSolver;
|
||||
use rustc_trait_selection::traits;
|
||||
|
||||
fn sized_constraint_for_ty<'tcx>(
|
||||
|
@ -121,7 +122,7 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
|
|||
// are any errors at that point, so outside of type inference you can be
|
||||
// sure that this will succeed without errors anyway.
|
||||
|
||||
if tcx.sess.opts.unstable_opts.chalk {
|
||||
if tcx.sess.opts.unstable_opts.trait_solver == TraitSolver::Chalk {
|
||||
let environment = well_formed_types_in_env(tcx, def_id);
|
||||
predicates.extend(environment);
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
-Z branch-protection=val -- set options for branch target identification and pointer authentication on AArch64
|
||||
-Z cf-protection=val -- instrument control-flow architecture protection
|
||||
-Z cgu-partitioning-strategy=val -- the codegen unit partitioning strategy to use
|
||||
-Z chalk=val -- enable the experimental Chalk-based trait solving engine
|
||||
-Z codegen-backend=val -- the backend to use
|
||||
-Z combine-cgu=val -- combine CGUs into a single one
|
||||
-Z crate-attr=val -- inject the given attribute in the crate
|
||||
|
@ -175,6 +174,7 @@
|
|||
-Z tls-model=val -- choose the TLS model to use (`rustc --print tls-models` for details)
|
||||
-Z trace-macros=val -- for every macro invocation, print its name and arguments (default: no)
|
||||
-Z track-diagnostics=val -- tracks where in rustc a diagnostic was emitted
|
||||
-Z trait-solver=val -- specify the trait solver mode used by rustc (default: classic)
|
||||
-Z translate-additional-ftl=val -- additional fluent translation to preferentially use (for testing translation)
|
||||
-Z translate-directionality-markers=val -- emit directionality isolation markers in translated diagnostics
|
||||
-Z translate-lang=val -- language identifier for diagnostic output
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// check-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
fn main() {
|
||||
1 + 2;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// run-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
fn main() {
|
||||
assert_eq!(1, 1);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// check-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
trait Foo {}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// check-fail
|
||||
// known-bug: unknown
|
||||
// compile-flags: -Z chalk --edition=2021
|
||||
// compile-flags: -Z trait-solver=chalk --edition=2021
|
||||
|
||||
fn main() -> () {}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// run-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
// Test that `Clone` is correctly implemented for builtin types.
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
trait Foo { }
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
fn main() -> () {
|
||||
let t = || {};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
trait Foo { }
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
trait Foo: Sized { }
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Split out of impl_wf.rs to work around rust aborting compilation early
|
||||
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
trait Foo: Sized { }
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// run-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
trait Foo { }
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// run-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
trait Foo { }
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// check-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// check-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// check-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
#![allow(dead_code)]
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// check-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
trait Foo { }
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// check-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
struct Foo<'a, T> where Box<T>: Clone {
|
||||
_x: std::marker::PhantomData<&'a T>,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// check-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
trait Bar { }
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// check-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
trait Foo<F: ?Sized> where for<'a> F: Fn(&'a (u8, u16)) -> &'a u8
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// check-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
use std::borrow::Borrow;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// check-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
fn main() {
|
||||
println!("hello");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// run-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
trait Foo { }
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// FIXME(chalk): should fail, see comments
|
||||
// check-fail
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
#![feature(trivial_bounds)]
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// run-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
trait Foo { }
|
||||
trait Bar: Foo { }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// check-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
use std::fmt::Display;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// run-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
trait Foo { }
|
||||
trait Bar<U> where U: Foo { }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// run-pass
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
trait Eq { }
|
||||
trait Hash: Eq { }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
trait Foo { }
|
||||
impl Foo for i32 { }
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// check-fail
|
||||
// compile-flags: -Z chalk
|
||||
// compile-flags: -Z trait-solver=chalk
|
||||
|
||||
trait Foo { }
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// A test exploiting the bug behind #25860 except with
|
||||
// implied trait bounds which currently don't exist without `-Zchalk`.
|
||||
// implied trait bounds which currently don't exist without `-Ztrait-solver=chalk`.
|
||||
use std::marker::PhantomData;
|
||||
struct Foo<'a, 'b, T>(PhantomData<(&'a (), &'b (), T)>)
|
||||
where
|
||||
|
|
|
@ -2011,7 +2011,7 @@ impl<'test> TestCx<'test> {
|
|||
rustc.args(&["-Zpolonius"]);
|
||||
}
|
||||
Some(CompareMode::Chalk) => {
|
||||
rustc.args(&["-Zchalk"]);
|
||||
rustc.args(&["-Ztrait-solver=chalk"]);
|
||||
}
|
||||
Some(CompareMode::SplitDwarf) if self.config.target.contains("windows") => {
|
||||
rustc.args(&["-Csplit-debuginfo=unpacked", "-Zunstable-options"]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue