Auto merge of #106482 - compiler-errors:rollup-g7n1p39, r=compiler-errors
Rollup of 6 pull requests Successful merges: - #105846 (Account for return-position `impl Trait` in trait in `opt_suggest_box_span`) - #106385 (Split `-Zchalk` flag into `-Ztrait-solver=(classic|chalk|next)` flag) - #106403 (Rename `hir::Map::{get_,find_}parent_node` to `hir::Map::{,opt_}parent_id`, and add `hir::Map::{get,find}_parent`) - #106462 (rustdoc: remove unnecessary wrapper around sidebar and mobile logos) - #106464 (Update Fuchsia walkthrough with new configs) - #106478 (Tweak wording of fn call with wrong number of args) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
1429899700
160 changed files with 480 additions and 394 deletions
|
@ -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
|
||||
|
|
|
@ -117,7 +117,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
Some(if movability.is_some() { "an async closure" } else { "a closure" })
|
||||
}),
|
||||
hir::Node::Expr(hir::Expr { .. }) => {
|
||||
let parent_hid = hir.get_parent_node(hir_id);
|
||||
let parent_hid = hir.parent_id(hir_id);
|
||||
if parent_hid != hir_id { self.describe_enclosure(parent_hid) } else { None }
|
||||
}
|
||||
_ => None,
|
||||
|
|
|
@ -838,8 +838,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
|
||||
let hir = self.tcx.hir();
|
||||
let hir_id = hir.local_def_id_to_hir_id(def_id.as_local()?);
|
||||
let parent_node = hir.get_parent_node(hir_id);
|
||||
match hir.find(parent_node) {
|
||||
match hir.find_parent(hir_id) {
|
||||
Some(hir::Node::Stmt(hir::Stmt { kind: hir::StmtKind::Local(local), .. })) => {
|
||||
get_name(err, &local.pat.kind)
|
||||
}
|
||||
|
@ -1421,7 +1420,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
trait_pred: ty::PolyTraitPredicate<'tcx>,
|
||||
) -> bool {
|
||||
let hir = self.tcx.hir();
|
||||
let parent_node = hir.get_parent_node(obligation.cause.body_id);
|
||||
let parent_node = hir.parent_id(obligation.cause.body_id);
|
||||
let node = hir.find(parent_node);
|
||||
if let Some(hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(sig, _, body_id), .. })) = node
|
||||
&& let hir::ExprKind::Block(blk, _) = &hir.body(*body_id).value.kind
|
||||
|
@ -1458,7 +1457,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
|
||||
fn return_type_span(&self, obligation: &PredicateObligation<'tcx>) -> Option<Span> {
|
||||
let hir = self.tcx.hir();
|
||||
let parent_node = hir.get_parent_node(obligation.cause.body_id);
|
||||
let parent_node = hir.parent_id(obligation.cause.body_id);
|
||||
let Some(hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(sig, ..), .. })) = hir.find(parent_node) else {
|
||||
return None;
|
||||
};
|
||||
|
@ -1483,7 +1482,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
|
||||
let hir = self.tcx.hir();
|
||||
let fn_hir_id = hir.get_parent_node(obligation.cause.body_id);
|
||||
let fn_hir_id = hir.parent_id(obligation.cause.body_id);
|
||||
let node = hir.find(fn_hir_id);
|
||||
let Some(hir::Node::Item(hir::Item {
|
||||
kind: hir::ItemKind::Fn(sig, _, body_id),
|
||||
|
@ -1695,7 +1694,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
|
||||
let hir = self.tcx.hir();
|
||||
let parent_node = hir.get_parent_node(obligation.cause.body_id);
|
||||
let parent_node = hir.parent_id(obligation.cause.body_id);
|
||||
let node = hir.find(parent_node);
|
||||
if let Some(hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(_, _, body_id), .. })) =
|
||||
node
|
||||
|
@ -2291,7 +2290,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
let expr = hir.expect_expr(expr_id);
|
||||
debug!("target_ty evaluated from {:?}", expr);
|
||||
|
||||
let parent = hir.get_parent_node(expr_id);
|
||||
let parent = hir.parent_id(expr_id);
|
||||
if let Some(hir::Node::Expr(e)) = hir.find(parent) {
|
||||
let parent_span = hir.span(parent);
|
||||
let parent_did = parent.owner.to_def_id();
|
||||
|
@ -2512,7 +2511,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
}
|
||||
}
|
||||
ObligationCauseCode::VariableType(hir_id) => {
|
||||
let parent_node = self.tcx.hir().get_parent_node(hir_id);
|
||||
let parent_node = self.tcx.hir().parent_id(hir_id);
|
||||
match self.tcx.hir().find(parent_node) {
|
||||
Some(Node::Local(hir::Local { ty: Some(ty), .. })) => {
|
||||
err.span_suggestion_verbose(
|
||||
|
@ -2992,7 +2991,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
span: Span,
|
||||
) {
|
||||
let body_hir_id = obligation.cause.body_id;
|
||||
let item_id = self.tcx.hir().get_parent_node(body_hir_id);
|
||||
let item_id = self.tcx.hir().parent_id(body_hir_id);
|
||||
|
||||
if let Some(body_id) =
|
||||
self.tcx.hir().maybe_body_owned_by(self.tcx.hir().local_def_id(item_id))
|
||||
|
@ -3219,7 +3218,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
if let hir::ExprKind::Path(hir::QPath::Resolved(None, path)) = expr.kind
|
||||
&& let hir::Path { res: hir::def::Res::Local(hir_id), .. } = path
|
||||
&& let Some(hir::Node::Pat(binding)) = self.tcx.hir().find(*hir_id)
|
||||
&& let parent_hir_id = self.tcx.hir().get_parent_node(binding.hir_id)
|
||||
&& let parent_hir_id = self.tcx.hir().parent_id(binding.hir_id)
|
||||
&& let Some(hir::Node::Local(local)) = self.tcx.hir().find(parent_hir_id)
|
||||
&& let Some(binding_expr) = local.init
|
||||
{
|
||||
|
@ -3287,8 +3286,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
if let hir::ExprKind::Path(hir::QPath::Resolved(None, path)) = expr.kind
|
||||
&& let hir::Path { res: hir::def::Res::Local(hir_id), .. } = path
|
||||
&& let Some(hir::Node::Pat(binding)) = self.tcx.hir().find(*hir_id)
|
||||
&& let parent_hir_id = self.tcx.hir().get_parent_node(binding.hir_id)
|
||||
&& let Some(parent) = self.tcx.hir().find(parent_hir_id)
|
||||
&& let Some(parent) = self.tcx.hir().find_parent(binding.hir_id)
|
||||
{
|
||||
// We've reached the root of the method call chain...
|
||||
if let hir::Node::Local(local) = parent
|
||||
|
|
|
@ -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)),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue