1
Fork 0

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:
bors 2023-01-05 06:47:02 +00:00
commit 1429899700
160 changed files with 480 additions and 394 deletions

View file

@ -394,7 +394,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
} }
} }
let typeck = self.infcx.tcx.typeck(self.mir_def_id()); let typeck = self.infcx.tcx.typeck(self.mir_def_id());
let hir_id = hir.get_parent_node(expr.hir_id); let hir_id = hir.parent_id(expr.hir_id);
if let Some(parent) = hir.find(hir_id) { if let Some(parent) = hir.find(hir_id) {
let (def_id, args, offset) = if let hir::Node::Expr(parent_expr) = parent let (def_id, args, offset) = if let hir::Node::Expr(parent_expr) = parent
&& let hir::ExprKind::MethodCall(_, _, args, _) = parent_expr.kind && let hir::ExprKind::MethodCall(_, _, args, _) = parent_expr.kind

View file

@ -1004,7 +1004,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
let hir = self.infcx.tcx.hir(); let hir = self.infcx.tcx.hir();
let closure_id = self.mir_hir_id(); let closure_id = self.mir_hir_id();
let closure_span = self.infcx.tcx.def_span(self.mir_def_id()); let closure_span = self.infcx.tcx.def_span(self.mir_def_id());
let fn_call_id = hir.get_parent_node(closure_id); let fn_call_id = hir.parent_id(closure_id);
let node = hir.get(fn_call_id); let node = hir.get(fn_call_id);
let def_id = hir.enclosing_body_owner(fn_call_id); let def_id = hir.enclosing_body_owner(fn_call_id);
let mut look_at_return = true; let mut look_at_return = true;

View file

@ -115,7 +115,7 @@ fn is_parent_const_stable_trait(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
let local_def_id = def_id.expect_local(); let local_def_id = def_id.expect_local();
let hir_id = tcx.local_def_id_to_hir_id(local_def_id); let hir_id = tcx.local_def_id_to_hir_id(local_def_id);
let Some(parent) = tcx.hir().find_parent_node(hir_id) else { return false }; let Some(parent) = tcx.hir().opt_parent_id(hir_id) else { return false };
let parent_def = tcx.hir().get(parent); let parent_def = tcx.hir().get(parent);
if !matches!( if !matches!(

View file

@ -3460,7 +3460,7 @@ impl<'hir> Node<'hir> {
/// ```ignore (illustrative) /// ```ignore (illustrative)
/// ctor /// ctor
/// .ctor_hir_id() /// .ctor_hir_id()
/// .and_then(|ctor_id| tcx.hir().find(tcx.hir().get_parent_node(ctor_id))) /// .and_then(|ctor_id| tcx.hir().find_parent(ctor_id))
/// .and_then(|parent| parent.ident()) /// .and_then(|parent| parent.ident())
/// ``` /// ```
pub fn ident(&self) -> Option<Ident> { pub fn ident(&self) -> Option<Ident> {

View file

@ -2936,7 +2936,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(..), ident, .. }) = let hir::Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(..), ident, .. }) =
hir.get(fn_hir_id) else { return None }; hir.get(fn_hir_id) else { return None };
let hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(i), .. }) = let hir::Node::Item(hir::Item { kind: hir::ItemKind::Impl(i), .. }) =
hir.get(hir.get_parent_node(fn_hir_id)) else { bug!("ImplItem should have Impl parent") }; hir.get_parent(fn_hir_id) else { bug!("ImplItem should have Impl parent") };
let trait_ref = self.instantiate_mono_trait_ref( let trait_ref = self.instantiate_mono_trait_ref(
i.of_trait.as_ref()?, i.of_trait.as_ref()?,

View file

@ -213,7 +213,7 @@ pub(crate) fn placeholder_type_error_diag<'tcx>(
is_fn = true; is_fn = true;
// Check if parent is const or static // Check if parent is const or static
let parent_id = tcx.hir().get_parent_node(hir_ty.hir_id); let parent_id = tcx.hir().parent_id(hir_ty.hir_id);
let parent_node = tcx.hir().get(parent_id); let parent_node = tcx.hir().get(parent_id);
is_const_or_static = matches!( is_const_or_static = matches!(
@ -1109,7 +1109,7 @@ fn fn_sig(tcx: TyCtxt<'_>, def_id: DefId) -> ty::PolyFnSig<'_> {
ImplItem(hir::ImplItem { kind: ImplItemKind::Fn(sig, _), generics, .. }) => { ImplItem(hir::ImplItem { kind: ImplItemKind::Fn(sig, _), generics, .. }) => {
// Do not try to infer the return type for a impl method coming from a trait // Do not try to infer the return type for a impl method coming from a trait
if let Item(hir::Item { kind: ItemKind::Impl(i), .. }) = if let Item(hir::Item { kind: ItemKind::Impl(i), .. }) =
tcx.hir().get(tcx.hir().get_parent_node(hir_id)) tcx.hir().get_parent(hir_id)
&& i.of_trait.is_some() && i.of_trait.is_some()
{ {
<dyn AstConv<'_>>::ty_of_fn( <dyn AstConv<'_>>::ty_of_fn(

View file

@ -103,7 +103,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
// `min_const_generics`. // `min_const_generics`.
Some(parent_def_id.to_def_id()) Some(parent_def_id.to_def_id())
} else { } else {
let parent_node = tcx.hir().get(tcx.hir().get_parent_node(hir_id)); let parent_node = tcx.hir().get_parent(hir_id);
match parent_node { match parent_node {
// HACK(eddyb) this provides the correct generics for repeat // HACK(eddyb) this provides the correct generics for repeat
// expressions' count (i.e. `N` in `[x; N]`), and explicit // expressions' count (i.e. `N` in `[x; N]`), and explicit
@ -320,7 +320,7 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
// provide junk type parameter defs for const blocks. // provide junk type parameter defs for const blocks.
if let Node::AnonConst(_) = node { if let Node::AnonConst(_) = node {
let parent_node = tcx.hir().get(tcx.hir().get_parent_node(hir_id)); let parent_node = tcx.hir().get_parent(hir_id);
if let Node::Expr(&Expr { kind: ExprKind::ConstBlock(_), .. }) = parent_node { if let Node::Expr(&Expr { kind: ExprKind::ConstBlock(_), .. }) = parent_node {
params.push(ty::GenericParamDef { params.push(ty::GenericParamDef {
index: next_index(), index: next_index(),

View file

@ -682,7 +682,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> {
}; };
let hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id); let hir_id = self.tcx.hir().local_def_id_to_hir_id(def_id);
// Ensure that the parent of the def is an item, not HRTB // Ensure that the parent of the def is an item, not HRTB
let parent_id = self.tcx.hir().get_parent_node(hir_id); let parent_id = self.tcx.hir().parent_id(hir_id);
if !parent_id.is_owner() { if !parent_id.is_owner() {
struct_span_err!( struct_span_err!(
self.tcx.sess, self.tcx.sess,

View file

@ -270,7 +270,7 @@ fn gather_explicit_predicates_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::GenericP
// We create bi-directional Outlives predicates between the original // We create bi-directional Outlives predicates between the original
// and the duplicated parameter, to ensure that they do not get out of sync. // and the duplicated parameter, to ensure that they do not get out of sync.
if let Node::Item(&Item { kind: ItemKind::OpaqueTy(..), .. }) = node { if let Node::Item(&Item { kind: ItemKind::OpaqueTy(..), .. }) = node {
let opaque_ty_id = tcx.hir().get_parent_node(hir_id); let opaque_ty_id = tcx.hir().parent_id(hir_id);
let opaque_ty_node = tcx.hir().get(opaque_ty_id); let opaque_ty_node = tcx.hir().get(opaque_ty_id);
let Node::Ty(&Ty { kind: TyKind::OpaqueDef(_, lifetimes, _), .. }) = opaque_ty_node else { let Node::Ty(&Ty { kind: TyKind::OpaqueDef(_, lifetimes, _), .. }) = opaque_ty_node else {
bug!("unexpected {opaque_ty_node:?}") bug!("unexpected {opaque_ty_node:?}")

View file

@ -28,7 +28,7 @@ pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<
_ => return None, _ => return None,
}; };
let parent_node_id = tcx.hir().get_parent_node(hir_id); let parent_node_id = tcx.hir().parent_id(hir_id);
let parent_node = tcx.hir().get(parent_node_id); let parent_node = tcx.hir().get(parent_node_id);
let (generics, arg_idx) = match parent_node { let (generics, arg_idx) = match parent_node {
@ -402,7 +402,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
} }
Node::AnonConst(_) => { Node::AnonConst(_) => {
let parent_node = tcx.hir().get(tcx.hir().get_parent_node(hir_id)); let parent_node = tcx.hir().get_parent(hir_id);
match parent_node { match parent_node {
Node::Ty(&Ty { kind: TyKind::Array(_, ref constant), .. }) Node::Ty(&Ty { kind: TyKind::Array(_, ref constant), .. })
| Node::Expr(&Expr { kind: ExprKind::Repeat(_, ref constant), .. }) | Node::Expr(&Expr { kind: ExprKind::Repeat(_, ref constant), .. })
@ -445,7 +445,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
.. ..
}, },
) if let Node::TraitRef(trait_ref) = ) if let Node::TraitRef(trait_ref) =
tcx.hir().get(tcx.hir().get_parent_node(binding_id)) tcx.hir().get_parent(binding_id)
&& e.hir_id == hir_id => && e.hir_id == hir_id =>
{ {
let Some(trait_def_id) = trait_ref.trait_def_id() else { let Some(trait_def_id) = trait_ref.trait_def_id() else {
@ -472,7 +472,7 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
Node::TypeBinding( Node::TypeBinding(
binding @ &TypeBinding { hir_id: binding_id, gen_args, ref kind, .. }, binding @ &TypeBinding { hir_id: binding_id, gen_args, ref kind, .. },
) if let Node::TraitRef(trait_ref) = ) if let Node::TraitRef(trait_ref) =
tcx.hir().get(tcx.hir().get_parent_node(binding_id)) tcx.hir().get_parent(binding_id)
&& let Some((idx, _)) = && let Some((idx, _)) =
gen_args.args.iter().enumerate().find(|(_, arg)| { gen_args.args.iter().enumerate().find(|(_, arg)| {
if let GenericArg::Const(ct) = arg { if let GenericArg::Const(ct) = arg {

View file

@ -716,7 +716,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
num = num_trait_generics_except_self, num = num_trait_generics_except_self,
); );
if let Some(parent_node) = self.tcx.hir().find_parent_node(self.path_segment.hir_id) if let Some(parent_node) = self.tcx.hir().opt_parent_id(self.path_segment.hir_id)
&& let Some(parent_node) = self.tcx.hir().find(parent_node) && let Some(parent_node) = self.tcx.hir().find(parent_node)
&& let hir::Node::Expr(expr) = parent_node { && let hir::Node::Expr(expr) = parent_node {
match expr.kind { match expr.kind {

View file

@ -289,15 +289,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
fn maybe_get_coercion_reason(&self, hir_id: hir::HirId, sp: Span) -> Option<(Span, String)> { fn maybe_get_coercion_reason(&self, hir_id: hir::HirId, sp: Span) -> Option<(Span, String)> {
let node = { let node = {
let rslt = self.tcx.hir().get_parent_node(self.tcx.hir().get_parent_node(hir_id)); let rslt = self.tcx.hir().parent_id(self.tcx.hir().parent_id(hir_id));
self.tcx.hir().get(rslt) self.tcx.hir().get(rslt)
}; };
if let hir::Node::Block(block) = node { if let hir::Node::Block(block) = node {
// check that the body's parent is an fn // check that the body's parent is an fn
let parent = self let parent = self.tcx.hir().get_parent(self.tcx.hir().parent_id(block.hir_id));
.tcx
.hir()
.get(self.tcx.hir().get_parent_node(self.tcx.hir().get_parent_node(block.hir_id)));
if let (Some(expr), hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(..), .. })) = if let (Some(expr), hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(..), .. })) =
(&block.expr, parent) (&block.expr, parent)
{ {
@ -526,7 +523,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
None None
} }
})?; })?;
let opaque_ty = self.tcx.mk_opaque(rpit_def_id, substs);
if !self.can_coerce(first_ty, expected) || !self.can_coerce(second_ty, expected) { if !self.can_coerce(first_ty, expected) || !self.can_coerce(second_ty, expected) {
return None; return None;
@ -540,13 +536,22 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{ {
let pred = pred.kind().rebind(match pred.kind().skip_binder() { let pred = pred.kind().rebind(match pred.kind().skip_binder() {
ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)) => { ty::PredicateKind::Clause(ty::Clause::Trait(trait_pred)) => {
assert_eq!(trait_pred.trait_ref.self_ty(), opaque_ty); // FIXME(rpitit): This will need to be fixed when we move to associated types
assert!(matches!(
*trait_pred.trait_ref.self_ty().kind(),
ty::Alias(_, ty::AliasTy { def_id, substs, .. })
if def_id == rpit_def_id && substs == substs
));
ty::PredicateKind::Clause(ty::Clause::Trait( ty::PredicateKind::Clause(ty::Clause::Trait(
trait_pred.with_self_ty(self.tcx, ty), trait_pred.with_self_ty(self.tcx, ty),
)) ))
} }
ty::PredicateKind::Clause(ty::Clause::Projection(mut proj_pred)) => { ty::PredicateKind::Clause(ty::Clause::Projection(mut proj_pred)) => {
assert_eq!(proj_pred.projection_ty.self_ty(), opaque_ty); assert!(matches!(
*proj_pred.projection_ty.self_ty().kind(),
ty::Alias(_, ty::AliasTy { def_id, substs, .. })
if def_id == rpit_def_id && substs == substs
));
proj_pred = proj_pred.with_self_ty(self.tcx, ty); proj_pred = proj_pred.with_self_ty(self.tcx, ty);
ty::PredicateKind::Clause(ty::Clause::Projection(proj_pred)) ty::PredicateKind::Clause(ty::Clause::Projection(proj_pred))
} }

View file

@ -288,7 +288,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
callee_span: Span, callee_span: Span,
) { ) {
let hir = self.tcx.hir(); let hir = self.tcx.hir();
let parent_hir_id = hir.get_parent_node(hir_id); let parent_hir_id = hir.parent_id(hir_id);
let parent_node = hir.get(parent_hir_id); let parent_node = hir.get(parent_hir_id);
if let ( if let (
hir::Node::Expr(hir::Expr { hir::Node::Expr(hir::Expr {
@ -303,7 +303,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
{ {
// Actually need to unwrap a few more layers of HIR to get to // Actually need to unwrap a few more layers of HIR to get to
// the _real_ closure... // the _real_ closure...
let async_closure = hir.get_parent_node(hir.get_parent_node(parent_hir_id)); let async_closure = hir.parent_id(hir.parent_id(parent_hir_id));
if let hir::Node::Expr(hir::Expr { if let hir::Node::Expr(hir::Expr {
kind: hir::ExprKind::Closure(&hir::Closure { fn_decl_span, .. }), kind: hir::ExprKind::Closure(&hir::Closure { fn_decl_span, .. }),
.. ..
@ -336,7 +336,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
call_expr: &'tcx hir::Expr<'tcx>, call_expr: &'tcx hir::Expr<'tcx>,
callee_expr: &'tcx hir::Expr<'tcx>, callee_expr: &'tcx hir::Expr<'tcx>,
) -> bool { ) -> bool {
let hir_id = self.tcx.hir().get_parent_node(call_expr.hir_id); let hir_id = self.tcx.hir().parent_id(call_expr.hir_id);
let parent_node = self.tcx.hir().get(hir_id); let parent_node = self.tcx.hir().get(hir_id);
if let ( if let (
hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Array(_), .. }), hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Array(_), .. }),

View file

@ -1547,7 +1547,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
err.span_label(cause.span, "return type is not `()`"); err.span_label(cause.span, "return type is not `()`");
} }
ObligationCauseCode::BlockTailExpression(blk_id) => { ObligationCauseCode::BlockTailExpression(blk_id) => {
let parent_id = fcx.tcx.hir().get_parent_node(blk_id); let parent_id = fcx.tcx.hir().parent_id(blk_id);
err = self.report_return_mismatched_types( err = self.report_return_mismatched_types(
cause, cause,
expected, expected,
@ -1578,7 +1578,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
None, None,
); );
if !fcx.tcx.features().unsized_locals { if !fcx.tcx.features().unsized_locals {
let id = fcx.tcx.hir().get_parent_node(id); let id = fcx.tcx.hir().parent_id(id);
unsized_return = self.is_return_ty_unsized(fcx, id); unsized_return = self.is_return_ty_unsized(fcx, id);
} }
} }
@ -1668,7 +1668,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
let mut pointing_at_return_type = false; let mut pointing_at_return_type = false;
let mut fn_output = None; let mut fn_output = None;
let parent_id = fcx.tcx.hir().get_parent_node(id); let parent_id = fcx.tcx.hir().parent_id(id);
let parent = fcx.tcx.hir().get(parent_id); let parent = fcx.tcx.hir().get(parent_id);
if let Some(expr) = expression if let Some(expr) = expression
&& let hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(&hir::Closure { body, .. }), .. }) = parent && let hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Closure(&hir::Closure { body, .. }), .. }) = parent

View file

@ -211,7 +211,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
expr: &hir::Expr<'_>, expr: &hir::Expr<'_>,
error: Option<TypeError<'tcx>>, error: Option<TypeError<'tcx>>,
) { ) {
let parent = self.tcx.hir().get_parent_node(expr.hir_id); let parent = self.tcx.hir().parent_id(expr.hir_id);
match (self.tcx.hir().find(parent), error) { match (self.tcx.hir().find(parent), error) {
(Some(hir::Node::Local(hir::Local { ty: Some(ty), init: Some(init), .. })), _) (Some(hir::Node::Local(hir::Local { ty: Some(ty), init: Some(init), .. })), _)
if init.hir_id == expr.hir_id => if init.hir_id == expr.hir_id =>
@ -258,10 +258,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
hir::Path { res: hir::def::Res::Local(hir_id), .. }, hir::Path { res: hir::def::Res::Local(hir_id), .. },
)) => { )) => {
if let Some(hir::Node::Pat(pat)) = self.tcx.hir().find(*hir_id) { if let Some(hir::Node::Pat(pat)) = self.tcx.hir().find(*hir_id) {
let parent = self.tcx.hir().get_parent_node(pat.hir_id);
primary_span = pat.span; primary_span = pat.span;
secondary_span = pat.span; secondary_span = pat.span;
match self.tcx.hir().find(parent) { match self.tcx.hir().find_parent(pat.hir_id) {
Some(hir::Node::Local(hir::Local { ty: Some(ty), .. })) => { Some(hir::Node::Local(hir::Local { ty: Some(ty), .. })) => {
primary_span = ty.span; primary_span = ty.span;
post_message = " type"; post_message = " type";
@ -326,7 +325,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
expr: &hir::Expr<'_>, expr: &hir::Expr<'_>,
error: Option<TypeError<'tcx>>, error: Option<TypeError<'tcx>>,
) { ) {
let parent = self.tcx.hir().get_parent_node(expr.hir_id); let parent = self.tcx.hir().parent_id(expr.hir_id);
let Some(TypeError::Sorts(ExpectedFound { expected, .. })) = error else {return;}; let Some(TypeError::Sorts(ExpectedFound { expected, .. })) = error else {return;};
let Some(hir::Node::Expr(hir::Expr { let Some(hir::Node::Expr(hir::Expr {
kind: hir::ExprKind::Assign(lhs, rhs, _), .. kind: hir::ExprKind::Assign(lhs, rhs, _), ..
@ -510,7 +509,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Unroll desugaring, to make sure this works for `for` loops etc. // Unroll desugaring, to make sure this works for `for` loops etc.
loop { loop {
parent = self.tcx.hir().get_parent_node(id); parent = self.tcx.hir().parent_id(id);
if let Some(parent_span) = self.tcx.hir().opt_span(parent) { if let Some(parent_span) = self.tcx.hir().opt_span(parent) {
if parent_span.find_ancestor_inside(expr.span).is_some() { if parent_span.find_ancestor_inside(expr.span).is_some() {
// The parent node is part of the same span, so is the result of the // The parent node is part of the same span, so is the result of the
@ -790,12 +789,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return None; return None;
}; };
let local_parent = self.tcx.hir().get_parent_node(local_id); let local_parent = self.tcx.hir().parent_id(local_id);
let Some(Node::Param(hir::Param { hir_id: param_hir_id, .. })) = self.tcx.hir().find(local_parent) else { let Some(Node::Param(hir::Param { hir_id: param_hir_id, .. })) = self.tcx.hir().find(local_parent) else {
return None; return None;
}; };
let param_parent = self.tcx.hir().get_parent_node(*param_hir_id); let param_parent = self.tcx.hir().parent_id(*param_hir_id);
let Some(Node::Expr(hir::Expr { let Some(Node::Expr(hir::Expr {
hir_id: expr_hir_id, hir_id: expr_hir_id,
kind: hir::ExprKind::Closure(hir::Closure { fn_decl: closure_fn_decl, .. }), kind: hir::ExprKind::Closure(hir::Closure { fn_decl: closure_fn_decl, .. }),
@ -804,7 +803,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return None; return None;
}; };
let expr_parent = self.tcx.hir().get_parent_node(*expr_hir_id); let expr_parent = self.tcx.hir().parent_id(*expr_hir_id);
let hir = self.tcx.hir().find(expr_parent); let hir = self.tcx.hir().find(expr_parent);
let closure_params_len = closure_fn_decl.inputs.len(); let closure_params_len = closure_fn_decl.inputs.len();
let ( let (
@ -857,7 +856,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
_ => None, _ => None,
}?; }?;
match hir.find(hir.get_parent_node(expr.hir_id))? { match hir.find_parent(expr.hir_id)? {
Node::ExprField(field) => { Node::ExprField(field) => {
if field.ident.name == local.name && field.is_shorthand { if field.ident.name == local.name && field.is_shorthand {
return Some(local.name); return Some(local.name);
@ -883,7 +882,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
/// Returns whether the given expression is an `else if`. /// Returns whether the given expression is an `else if`.
pub(crate) fn is_else_if_block(&self, expr: &hir::Expr<'_>) -> bool { pub(crate) fn is_else_if_block(&self, expr: &hir::Expr<'_>) -> bool {
if let hir::ExprKind::If(..) = expr.kind { if let hir::ExprKind::If(..) = expr.kind {
let parent_id = self.tcx.hir().get_parent_node(expr.hir_id); let parent_id = self.tcx.hir().parent_id(expr.hir_id);
if let Some(Node::Expr(hir::Expr { if let Some(Node::Expr(hir::Expr {
kind: hir::ExprKind::If(_, _, Some(else_expr)), kind: hir::ExprKind::If(_, _, Some(else_expr)),
.. ..
@ -1040,7 +1039,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let Some(hir::Node::Expr(hir::Expr { if let Some(hir::Node::Expr(hir::Expr {
kind: hir::ExprKind::Assign(..), kind: hir::ExprKind::Assign(..),
.. ..
})) = self.tcx.hir().find(self.tcx.hir().get_parent_node(expr.hir_id)) })) = self.tcx.hir().find_parent(expr.hir_id)
{ {
if mutability.is_mut() { if mutability.is_mut() {
// Suppressing this diagnostic, we'll properly print it in `check_expr_assign` // Suppressing this diagnostic, we'll properly print it in `check_expr_assign`
@ -1267,9 +1266,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut sugg = vec![]; let mut sugg = vec![];
if let Some(hir::Node::ExprField(field)) = if let Some(hir::Node::ExprField(field)) = self.tcx.hir().find_parent(expr.hir_id) {
self.tcx.hir().find(self.tcx.hir().get_parent_node(expr.hir_id))
{
// `expr` is a literal field for a struct, only suggest if appropriate // `expr` is a literal field for a struct, only suggest if appropriate
if field.is_shorthand { if field.is_shorthand {
// This is a field literal // This is a field literal
@ -1625,7 +1622,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
[start, end], [start, end],
_, _,
) = expr.kind else { return; }; ) = expr.kind else { return; };
let parent = self.tcx.hir().get_parent_node(expr.hir_id); let parent = self.tcx.hir().parent_id(expr.hir_id);
if let Some(hir::Node::ExprField(_)) = self.tcx.hir().find(parent) { if let Some(hir::Node::ExprField(_)) = self.tcx.hir().find(parent) {
// Ignore `Foo { field: a..Default::default() }` // Ignore `Foo { field: a..Default::default() }`
return; return;

View file

@ -920,7 +920,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
original_expr_id: HirId, original_expr_id: HirId,
then: impl FnOnce(&hir::Expr<'_>), then: impl FnOnce(&hir::Expr<'_>),
) { ) {
let mut parent = self.tcx.hir().get_parent_node(original_expr_id); let mut parent = self.tcx.hir().parent_id(original_expr_id);
while let Some(node) = self.tcx.hir().find(parent) { while let Some(node) = self.tcx.hir().find(parent) {
match node { match node {
hir::Node::Expr(hir::Expr { hir::Node::Expr(hir::Expr {
@ -943,7 +943,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}) => { }) => {
// Check if our original expression is a child of the condition of a while loop // Check if our original expression is a child of the condition of a while loop
let expr_is_ancestor = std::iter::successors(Some(original_expr_id), |id| { let expr_is_ancestor = std::iter::successors(Some(original_expr_id), |id| {
self.tcx.hir().find_parent_node(*id) self.tcx.hir().opt_parent_id(*id)
}) })
.take_while(|id| *id != parent) .take_while(|id| *id != parent)
.any(|id| id == expr.hir_id); .any(|id| id == expr.hir_id);
@ -959,7 +959,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
| hir::Node::TraitItem(_) | hir::Node::TraitItem(_)
| hir::Node::Crate(_) => break, | hir::Node::Crate(_) => break,
_ => { _ => {
parent = self.tcx.hir().get_parent_node(parent); parent = self.tcx.hir().parent_id(parent);
} }
} }
} }
@ -1083,7 +1083,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Do not suggest `if let x = y` as `==` is way more likely to be the intention. // Do not suggest `if let x = y` as `==` is way more likely to be the intention.
let hir = self.tcx.hir(); let hir = self.tcx.hir();
if let hir::Node::Expr(hir::Expr { kind: ExprKind::If { .. }, .. }) = if let hir::Node::Expr(hir::Expr { kind: ExprKind::If { .. }, .. }) =
hir.get(hir.get_parent_node(hir.get_parent_node(expr.hir_id))) hir.get_parent(hir.parent_id(expr.hir_id))
{ {
err.span_suggestion_verbose( err.span_suggestion_verbose(
expr.span.shrink_to_lo(), expr.span.shrink_to_lo(),
@ -2462,7 +2462,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.span_label(field.span, "method, not a field"); err.span_label(field.span, "method, not a field");
let expr_is_call = let expr_is_call =
if let hir::Node::Expr(hir::Expr { kind: ExprKind::Call(callee, _args), .. }) = if let hir::Node::Expr(hir::Expr { kind: ExprKind::Call(callee, _args), .. }) =
self.tcx.hir().get(self.tcx.hir().get_parent_node(expr.hir_id)) self.tcx.hir().get_parent(expr.hir_id)
{ {
expr.hir_id == callee.hir_id expr.hir_id == callee.hir_id
} else { } else {

View file

@ -1435,9 +1435,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
pub(in super::super) fn expr_in_place(&self, mut expr_id: hir::HirId) -> bool { pub(in super::super) fn expr_in_place(&self, mut expr_id: hir::HirId) -> bool {
let mut contained_in_place = false; let mut contained_in_place = false;
while let hir::Node::Expr(parent_expr) = while let hir::Node::Expr(parent_expr) = self.tcx.hir().get_parent(expr_id) {
self.tcx.hir().get(self.tcx.hir().get_parent_node(expr_id))
{
match &parent_expr.kind { match &parent_expr.kind {
hir::ExprKind::Assign(lhs, ..) | hir::ExprKind::AssignOp(_, lhs, ..) => { hir::ExprKind::Assign(lhs, ..) | hir::ExprKind::AssignOp(_, lhs, ..) => {
if lhs.hir_id == expr_id { if lhs.hir_id == expr_id {

View file

@ -473,7 +473,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
call_expr: &hir::Expr<'tcx>, call_expr: &hir::Expr<'tcx>,
) { ) {
// Next, let's construct the error // Next, let's construct the error
let (error_span, full_call_span, ctor_of, is_method) = match &call_expr.kind { let (error_span, full_call_span, call_name, is_method) = match &call_expr.kind {
hir::ExprKind::Call( hir::ExprKind::Call(
hir::Expr { hir_id, span, kind: hir::ExprKind::Path(qpath), .. }, hir::Expr { hir_id, span, kind: hir::ExprKind::Path(qpath), .. },
_, _,
@ -481,12 +481,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let Res::Def(DefKind::Ctor(of, _), _) = if let Res::Def(DefKind::Ctor(of, _), _) =
self.typeck_results.borrow().qpath_res(qpath, *hir_id) self.typeck_results.borrow().qpath_res(qpath, *hir_id)
{ {
(call_span, *span, Some(of), false) let name = match of {
CtorOf::Struct => "struct",
CtorOf::Variant => "enum variant",
};
(call_span, *span, name, false)
} else { } else {
(call_span, *span, None, false) (call_span, *span, "function", false)
} }
} }
hir::ExprKind::Call(hir::Expr { span, .. }, _) => (call_span, *span, None, false), hir::ExprKind::Call(hir::Expr { span, .. }, _) => (call_span, *span, "function", false),
hir::ExprKind::MethodCall(path_segment, _, _, span) => { hir::ExprKind::MethodCall(path_segment, _, _, span) => {
let ident_span = path_segment.ident.span; let ident_span = path_segment.ident.span;
let ident_span = if let Some(args) = path_segment.args { let ident_span = if let Some(args) = path_segment.args {
@ -494,17 +498,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else { } else {
ident_span ident_span
}; };
// methods are never ctors (*span, ident_span, "method", true)
(*span, ident_span, None, true)
} }
k => span_bug!(call_span, "checking argument types on a non-call: `{:?}`", k), k => span_bug!(call_span, "checking argument types on a non-call: `{:?}`", k),
}; };
let args_span = error_span.trim_start(full_call_span).unwrap_or(error_span); let args_span = error_span.trim_start(full_call_span).unwrap_or(error_span);
let call_name = match ctor_of {
Some(CtorOf::Struct) => "struct",
Some(CtorOf::Variant) => "enum variant",
None => "function",
};
// Don't print if it has error types or is just plain `_` // Don't print if it has error types or is just plain `_`
fn has_error_or_infer<'tcx>(tys: impl IntoIterator<Item = Ty<'tcx>>) -> bool { fn has_error_or_infer<'tcx>(tys: impl IntoIterator<Item = Ty<'tcx>>) -> bool {
@ -690,8 +688,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err = tcx.sess.struct_span_err_with_code( err = tcx.sess.struct_span_err_with_code(
full_call_span, full_call_span,
&format!( &format!(
"this {} takes {}{} but {} {} supplied", "{call_name} takes {}{} but {} {} supplied",
call_name,
if c_variadic { "at least " } else { "" }, if c_variadic { "at least " } else { "" },
potentially_plural_count( potentially_plural_count(
formal_and_expected_inputs.len(), formal_and_expected_inputs.len(),
@ -1803,7 +1800,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
hir_id: call_hir_id, hir_id: call_hir_id,
span: call_span, span: call_span,
.. ..
}) = hir.get(hir.get_parent_node(expr.hir_id)) }) = hir.get_parent(expr.hir_id)
&& callee.hir_id == expr.hir_id && callee.hir_id == expr.hir_id
{ {
if self.closure_span_overlaps_error(error, *call_span) { if self.closure_span_overlaps_error(error, *call_span) {

View file

@ -32,7 +32,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
self.typeck_results self.typeck_results
.borrow() .borrow()
.liberated_fn_sigs() .liberated_fn_sigs()
.get(self.tcx.hir().get_parent_node(self.body_id)) .get(self.tcx.hir().parent_id(self.body_id))
.copied() .copied()
} }
@ -642,7 +642,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// Check if the parent expression is a call to Pin::new. If it // Check if the parent expression is a call to Pin::new. If it
// is and we were expecting a Box, ergo Pin<Box<expected>>, we // is and we were expecting a Box, ergo Pin<Box<expected>>, we
// can suggest Box::pin. // can suggest Box::pin.
let parent = self.tcx.hir().get_parent_node(expr.hir_id); let parent = self.tcx.hir().parent_id(expr.hir_id);
let Some(Node::Expr(Expr { kind: ExprKind::Call(fn_name, _), .. })) = self.tcx.hir().find(parent) else { let Some(Node::Expr(Expr { kind: ExprKind::Call(fn_name, _), .. })) = self.tcx.hir().find(parent) else {
return false; return false;
}; };

View file

@ -140,7 +140,7 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> {
diag_expr_id: HirId, diag_expr_id: HirId,
) { ) {
let hir = self.tcx.hir(); let hir = self.tcx.hir();
let parent = match hir.find_parent_node(place_with_id.hir_id) { let parent = match hir.opt_parent_id(place_with_id.hir_id) {
Some(parent) => parent, Some(parent) => parent,
None => place_with_id.hir_id, None => place_with_id.hir_id,
}; };

View file

@ -224,7 +224,7 @@ fn typeck_with_fallback<'tcx>(
_ => None, _ => None,
}) })
.unwrap_or_else(|| match tcx.hir().get(id) { .unwrap_or_else(|| match tcx.hir().get(id) {
Node::AnonConst(_) => match tcx.hir().get(tcx.hir().get_parent_node(id)) { Node::AnonConst(_) => match tcx.hir().get(tcx.hir().parent_id(id)) {
Node::Expr(&hir::Expr { Node::Expr(&hir::Expr {
kind: hir::ExprKind::ConstBlock(ref anon_const), kind: hir::ExprKind::ConstBlock(ref anon_const),
.. ..

View file

@ -116,7 +116,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let sugg_span = if let SelfSource::MethodCall(expr) = source { let sugg_span = if let SelfSource::MethodCall(expr) = source {
// Given `foo.bar(baz)`, `expr` is `bar`, but we want to point to the whole thing. // Given `foo.bar(baz)`, `expr` is `bar`, but we want to point to the whole thing.
self.tcx.hir().expect_expr(self.tcx.hir().get_parent_node(expr.hir_id)).span self.tcx.hir().expect_expr(self.tcx.hir().parent_id(expr.hir_id)).span
} else { } else {
span span
}; };
@ -332,7 +332,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
if let SelfSource::MethodCall(rcvr_expr) = source { if let SelfSource::MethodCall(rcvr_expr) = source {
self.suggest_fn_call(&mut err, rcvr_expr, rcvr_ty, |output_ty| { self.suggest_fn_call(&mut err, rcvr_expr, rcvr_ty, |output_ty| {
let call_expr = let call_expr =
self.tcx.hir().expect_expr(self.tcx.hir().get_parent_node(rcvr_expr.hir_id)); self.tcx.hir().expect_expr(self.tcx.hir().parent_id(rcvr_expr.hir_id));
let probe = let probe =
self.lookup_probe(item_name, output_ty, call_expr, ProbeScope::AllTraits); self.lookup_probe(item_name, output_ty, call_expr, ProbeScope::AllTraits);
probe.is_ok() probe.is_ok()
@ -914,8 +914,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let msg = "remove this method call"; let msg = "remove this method call";
let mut fallback_span = true; let mut fallback_span = true;
if let SelfSource::MethodCall(expr) = source { if let SelfSource::MethodCall(expr) = source {
let call_expr = let call_expr = self.tcx.hir().expect_expr(self.tcx.hir().parent_id(expr.hir_id));
self.tcx.hir().expect_expr(self.tcx.hir().get_parent_node(expr.hir_id));
if let Some(span) = call_expr.span.trim_start(expr.span) { if let Some(span) = call_expr.span.trim_start(expr.span) {
err.span_suggestion(span, msg, "", Applicability::MachineApplicable); err.span_suggestion(span, msg, "", Applicability::MachineApplicable);
fallback_span = false; fallback_span = false;
@ -1268,7 +1267,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
Applicability::MachineApplicable, Applicability::MachineApplicable,
); );
} else { } else {
let call_expr = tcx.hir().expect_expr(tcx.hir().get_parent_node(expr.hir_id)); let call_expr = tcx.hir().expect_expr(tcx.hir().parent_id(expr.hir_id));
if let Some(span) = call_expr.span.trim_start(item_name.span) { if let Some(span) = call_expr.span.trim_start(item_name.span) {
err.span_suggestion( err.span_suggestion(
@ -1450,7 +1449,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let filename = tcx.sess.source_map().span_to_filename(span); let filename = tcx.sess.source_map().span_to_filename(span);
let parent_node = let parent_node =
self.tcx.hir().get(self.tcx.hir().get_parent_node(hir_id)); self.tcx.hir().get_parent(hir_id);
let msg = format!( let msg = format!(
"you must specify a type for this binding, like `{}`", "you must specify a type for this binding, like `{}`",
concrete_type, concrete_type,
@ -1523,7 +1522,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut visitor = LetVisitor { result: None, ident_name: seg1.ident.name }; let mut visitor = LetVisitor { result: None, ident_name: seg1.ident.name };
visitor.visit_body(&body); visitor.visit_body(&body);
let parent = self.tcx.hir().get_parent_node(seg1.hir_id); let parent = self.tcx.hir().parent_id(seg1.hir_id);
if let Some(Node::Expr(call_expr)) = self.tcx.hir().find(parent) if let Some(Node::Expr(call_expr)) = self.tcx.hir().find(parent)
&& let Some(expr) = visitor.result && let Some(expr) = visitor.result
&& let Some(self_ty) = self.node_ty_opt(expr.hir_id) && let Some(self_ty) = self.node_ty_opt(expr.hir_id)
@ -1561,7 +1560,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
&& let Some((fields, substs)) = && let Some((fields, substs)) =
self.get_field_candidates_considering_privacy(span, actual, mod_id) self.get_field_candidates_considering_privacy(span, actual, mod_id)
{ {
let call_expr = self.tcx.hir().expect_expr(self.tcx.hir().get_parent_node(expr.hir_id)); let call_expr = self.tcx.hir().expect_expr(self.tcx.hir().parent_id(expr.hir_id));
let lang_items = self.tcx.lang_items(); let lang_items = self.tcx.lang_items();
let never_mention_traits = [ let never_mention_traits = [
@ -1631,7 +1630,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
) { ) {
let tcx = self.tcx; let tcx = self.tcx;
let SelfSource::MethodCall(expr) = source else { return; }; let SelfSource::MethodCall(expr) = source else { return; };
let call_expr = tcx.hir().expect_expr(tcx.hir().get_parent_node(expr.hir_id)); let call_expr = tcx.hir().expect_expr(tcx.hir().parent_id(expr.hir_id));
let ty::Adt(kind, substs) = actual.kind() else { return; }; let ty::Adt(kind, substs) = actual.kind() else { return; };
match kind.adt_kind() { match kind.adt_kind() {
@ -2592,7 +2591,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return false; return false;
} }
let parent = self.tcx.hir().get_parent_node(expr.hir_id); let parent = self.tcx.hir().parent_id(expr.hir_id);
if let Some(Node::Expr(call_expr)) = self.tcx.hir().find(parent) && if let Some(Node::Expr(call_expr)) = self.tcx.hir().find(parent) &&
let hir::ExprKind::MethodCall( let hir::ExprKind::MethodCall(
hir::PathSegment { ident: method_name, .. }, hir::PathSegment { ident: method_name, .. },

View file

@ -692,7 +692,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let tcx = self.tcx; let tcx = self.tcx;
if let PatKind::Ref(inner, mutbl) = pat.kind if let PatKind::Ref(inner, mutbl) = pat.kind
&& let PatKind::Binding(_, _, binding, ..) = inner.kind { && let PatKind::Binding(_, _, binding, ..) = inner.kind {
let binding_parent_id = tcx.hir().get_parent_node(pat.hir_id); let binding_parent_id = tcx.hir().parent_id(pat.hir_id);
let binding_parent = tcx.hir().get(binding_parent_id); let binding_parent = tcx.hir().get(binding_parent_id);
debug!(?inner, ?pat, ?binding_parent); debug!(?inner, ?pat, ?binding_parent);
@ -936,7 +936,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
res.descr(), res.descr(),
), ),
); );
match self.tcx.hir().get(self.tcx.hir().get_parent_node(pat.hir_id)) { match self.tcx.hir().get_parent(pat.hir_id) {
hir::Node::PatField(..) => { hir::Node::PatField(..) => {
e.span_suggestion_verbose( e.span_suggestion_verbose(
ident.span.shrink_to_hi(), ident.span.shrink_to_hi(),

View file

@ -411,7 +411,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
span: Span, span: Span,
) { ) {
let hir = self.tcx.hir(); let hir = self.tcx.hir();
let fn_hir_id = hir.get_parent_node(cause.body_id); let fn_hir_id = hir.parent_id(cause.body_id);
if let Some(node) = self.tcx.hir().find(fn_hir_id) && if let Some(node) = self.tcx.hir().find(fn_hir_id) &&
let hir::Node::Item(hir::Item { let hir::Node::Item(hir::Item {
kind: hir::ItemKind::Fn(_sig, _, body_id), .. kind: hir::ItemKind::Fn(_sig, _, body_id), ..
@ -585,45 +585,42 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
let hir::StmtKind::Local(local) = &stmt.kind else { continue; }; let hir::StmtKind::Local(local) = &stmt.kind else { continue; };
local.pat.walk(&mut find_compatible_candidates); local.pat.walk(&mut find_compatible_candidates);
} }
match hir.find(hir.get_parent_node(blk.hir_id)) { match hir.find_parent(blk.hir_id) {
Some(hir::Node::Expr(hir::Expr { hir_id, .. })) => { Some(hir::Node::Expr(hir::Expr { hir_id, .. })) => match hir.find_parent(*hir_id) {
match hir.find(hir.get_parent_node(*hir_id)) { Some(hir::Node::Arm(hir::Arm { pat, .. })) => {
Some(hir::Node::Arm(hir::Arm { pat, .. })) => { pat.walk(&mut find_compatible_candidates);
pat.walk(&mut find_compatible_candidates);
}
Some(
hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(_, _, body), .. })
| hir::Node::ImplItem(hir::ImplItem {
kind: hir::ImplItemKind::Fn(_, body),
..
})
| hir::Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Fn(_, hir::TraitFn::Provided(body)),
..
})
| hir::Node::Expr(hir::Expr {
kind: hir::ExprKind::Closure(hir::Closure { body, .. }),
..
}),
) => {
for param in hir.body(*body).params {
param.pat.walk(&mut find_compatible_candidates);
}
}
Some(hir::Node::Expr(hir::Expr {
kind:
hir::ExprKind::If(
hir::Expr { kind: hir::ExprKind::Let(let_), .. },
then_block,
_,
),
..
})) if then_block.hir_id == *hir_id => {
let_.pat.walk(&mut find_compatible_candidates);
}
_ => {}
} }
} Some(
hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(_, _, body), .. })
| hir::Node::ImplItem(hir::ImplItem {
kind: hir::ImplItemKind::Fn(_, body), ..
})
| hir::Node::TraitItem(hir::TraitItem {
kind: hir::TraitItemKind::Fn(_, hir::TraitFn::Provided(body)),
..
})
| hir::Node::Expr(hir::Expr {
kind: hir::ExprKind::Closure(hir::Closure { body, .. }),
..
}),
) => {
for param in hir.body(*body).params {
param.pat.walk(&mut find_compatible_candidates);
}
}
Some(hir::Node::Expr(hir::Expr {
kind:
hir::ExprKind::If(
hir::Expr { kind: hir::ExprKind::Let(let_), .. },
then_block,
_,
),
..
})) if then_block.hir_id == *hir_id => {
let_.pat.walk(&mut find_compatible_candidates);
}
_ => {}
},
_ => {} _ => {}
} }

View file

@ -4,6 +4,7 @@ use crate::interface::parse_cfgspecs;
use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::fx::FxHashSet;
use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig}; use rustc_errors::{emitter::HumanReadableErrorType, registry, ColorConfig};
use rustc_session::config::rustc_optgroups; 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::{build_configuration, build_session_options, to_crate_config};
use rustc_session::config::{ use rustc_session::config::{
BranchProtection, Externs, OomStrategy, OutputType, OutputTypes, PAuthKey, PacRet, 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 }) pac_ret: Some(PacRet { leaf: true, key: PAuthKey::B })
}) })
); );
tracked!(chalk, true);
tracked!(codegen_backend, Some("abc".to_string())); tracked!(codegen_backend, Some("abc".to_string()));
tracked!(crate_attr, vec!["abc".to_string()]); tracked!(crate_attr, vec!["abc".to_string()]);
tracked!(debug_info_for_profiling, true); tracked!(debug_info_for_profiling, true);
@ -792,6 +792,7 @@ fn test_unstable_options_tracking_hash() {
tracked!(thinlto, Some(true)); tracked!(thinlto, Some(true));
tracked!(thir_unsafeck, true); tracked!(thir_unsafeck, true);
tracked!(tls_model, Some(TlsModel::GeneralDynamic)); tracked!(tls_model, Some(TlsModel::GeneralDynamic));
tracked!(trait_solver, TraitSolver::Chalk);
tracked!(translate_remapped_path_to_local_path, false); tracked!(translate_remapped_path_to_local_path, false);
tracked!(trap_unreachable, Some(false)); tracked!(trap_unreachable, Some(false));
tracked!(treat_err_as_bug, NonZeroUsize::new(1)); tracked!(treat_err_as_bug, NonZeroUsize::new(1));

View file

@ -1526,7 +1526,7 @@ impl<'tcx> LateLintPass<'tcx> for UnreachablePub {
fn check_field_def(&mut self, cx: &LateContext<'_>, field: &hir::FieldDef<'_>) { fn check_field_def(&mut self, cx: &LateContext<'_>, field: &hir::FieldDef<'_>) {
let map = cx.tcx.hir(); let map = cx.tcx.hir();
if matches!(map.get(map.get_parent_node(field.hir_id)), Node::Variant(_)) { if matches!(map.get_parent(field.hir_id), Node::Variant(_)) {
return; return;
} }
self.perform_lint(cx, "field", field.def_id, field.vis_span, false); self.perform_lint(cx, "field", field.def_id, field.vis_span, false);

View file

@ -143,7 +143,7 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind {
TyKind::Path(QPath::Resolved(_, path)) => { TyKind::Path(QPath::Resolved(_, path)) => {
if lint_ty_kind_usage(cx, &path.res) { if lint_ty_kind_usage(cx, &path.res) {
let hir = cx.tcx.hir(); let hir = cx.tcx.hir();
let span = match hir.find(hir.get_parent_node(ty.hir_id)) { let span = match hir.find_parent(ty.hir_id) {
Some(Node::Pat(Pat { Some(Node::Pat(Pat {
kind: kind:
PatKind::Path(qpath) PatKind::Path(qpath)

View file

@ -444,8 +444,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase {
fn check_pat(&mut self, cx: &LateContext<'_>, p: &hir::Pat<'_>) { fn check_pat(&mut self, cx: &LateContext<'_>, p: &hir::Pat<'_>) {
if let PatKind::Binding(_, hid, ident, _) = p.kind { if let PatKind::Binding(_, hid, ident, _) = p.kind {
if let hir::Node::PatField(field) = cx.tcx.hir().get(cx.tcx.hir().get_parent_node(hid)) if let hir::Node::PatField(field) = cx.tcx.hir().get_parent(hid) {
{
if !field.is_shorthand { if !field.is_shorthand {
// Only check if a new name has been introduced, to avoid warning // Only check if a new name has been introduced, to avoid warning
// on both the struct definition and this pattern. // on both the struct definition and this pattern.

View file

@ -127,10 +127,9 @@ fn lint_overflowing_range_endpoint<'tcx>(
) -> bool { ) -> bool {
// We only want to handle exclusive (`..`) ranges, // We only want to handle exclusive (`..`) ranges,
// which are represented as `ExprKind::Struct`. // which are represented as `ExprKind::Struct`.
let par_id = cx.tcx.hir().get_parent_node(expr.hir_id); let par_id = cx.tcx.hir().parent_id(expr.hir_id);
let Node::ExprField(field) = cx.tcx.hir().get(par_id) else { return false }; let Node::ExprField(field) = cx.tcx.hir().get(par_id) else { return false };
let field_par_id = cx.tcx.hir().get_parent_node(field.hir_id); let Node::Expr(struct_expr) = cx.tcx.hir().get_parent(field.hir_id) else { return false };
let Node::Expr(struct_expr) = cx.tcx.hir().get(field_par_id) else { return false };
if !is_range_literal(struct_expr) { if !is_range_literal(struct_expr) {
return false; return false;
}; };
@ -404,7 +403,7 @@ fn lint_uint_literal<'tcx>(
_ => bug!(), _ => bug!(),
}; };
if lit_val < min || lit_val > max { if lit_val < min || lit_val > max {
let parent_id = cx.tcx.hir().get_parent_node(e.hir_id); let parent_id = cx.tcx.hir().parent_id(e.hir_id);
if let Node::Expr(par_e) = cx.tcx.hir().get(parent_id) { if let Node::Expr(par_e) = cx.tcx.hir().get(parent_id) {
match par_e.kind { match par_e.kind {
hir::ExprKind::Cast(..) => { hir::ExprKind::Cast(..) => {

View file

@ -69,7 +69,7 @@ impl<'hir> Iterator for ParentHirIterator<'hir> {
} }
loop { loop {
// There are nodes that do not have entries, so we need to skip them. // There are nodes that do not have entries, so we need to skip them.
let parent_id = self.map.get_parent_node(self.current_id); let parent_id = self.map.parent_id(self.current_id);
if parent_id == self.current_id { if parent_id == self.current_id {
self.current_id = CRATE_HIR_ID; self.current_id = CRATE_HIR_ID;
@ -246,7 +246,7 @@ impl<'hir> Map<'hir> {
}, },
Node::Variant(_) => DefKind::Variant, Node::Variant(_) => DefKind::Variant,
Node::Ctor(variant_data) => { Node::Ctor(variant_data) => {
let ctor_of = match self.find(self.get_parent_node(hir_id)) { let ctor_of = match self.find_parent(hir_id) {
Some(Node::Item(..)) => def::CtorOf::Struct, Some(Node::Item(..)) => def::CtorOf::Struct,
Some(Node::Variant(..)) => def::CtorOf::Variant, Some(Node::Variant(..)) => def::CtorOf::Variant,
_ => unreachable!(), _ => unreachable!(),
@ -257,7 +257,7 @@ impl<'hir> Map<'hir> {
} }
} }
Node::AnonConst(_) => { Node::AnonConst(_) => {
let inline = match self.find(self.get_parent_node(hir_id)) { let inline = match self.find_parent(hir_id) {
Some(Node::Expr(&Expr { Some(Node::Expr(&Expr {
kind: ExprKind::ConstBlock(ref anon_const), .. kind: ExprKind::ConstBlock(ref anon_const), ..
})) if anon_const.hir_id == hir_id => true, })) if anon_const.hir_id == hir_id => true,
@ -298,7 +298,7 @@ impl<'hir> Map<'hir> {
/// Finds the id of the parent node to this one. /// Finds the id of the parent node to this one.
/// ///
/// If calling repeatedly and iterating over parents, prefer [`Map::parent_iter`]. /// If calling repeatedly and iterating over parents, prefer [`Map::parent_iter`].
pub fn find_parent_node(self, id: HirId) -> Option<HirId> { pub fn opt_parent_id(self, id: HirId) -> Option<HirId> {
if id.local_id == ItemLocalId::from_u32(0) { if id.local_id == ItemLocalId::from_u32(0) {
Some(self.tcx.hir_owner_parent(id.owner)) Some(self.tcx.hir_owner_parent(id.owner))
} else { } else {
@ -312,11 +312,19 @@ impl<'hir> Map<'hir> {
} }
#[track_caller] #[track_caller]
pub fn get_parent_node(self, hir_id: HirId) -> HirId { pub fn parent_id(self, hir_id: HirId) -> HirId {
self.find_parent_node(hir_id) self.opt_parent_id(hir_id)
.unwrap_or_else(|| bug!("No parent for node {:?}", self.node_to_string(hir_id))) .unwrap_or_else(|| bug!("No parent for node {:?}", self.node_to_string(hir_id)))
} }
pub fn get_parent(self, hir_id: HirId) -> Node<'hir> {
self.get(self.parent_id(hir_id))
}
pub fn find_parent(self, hir_id: HirId) -> Option<Node<'hir>> {
self.find(self.opt_parent_id(hir_id)?)
}
/// Retrieves the `Node` corresponding to `id`, returning `None` if cannot be found. /// Retrieves the `Node` corresponding to `id`, returning `None` if cannot be found.
pub fn find(self, id: HirId) -> Option<Node<'hir>> { pub fn find(self, id: HirId) -> Option<Node<'hir>> {
if id.local_id == ItemLocalId::from_u32(0) { if id.local_id == ItemLocalId::from_u32(0) {
@ -414,7 +422,7 @@ impl<'hir> Map<'hir> {
/// which this is the body of, i.e., a `fn`, `const` or `static` /// which this is the body of, i.e., a `fn`, `const` or `static`
/// item (possibly associated), a closure, or a `hir::AnonConst`. /// item (possibly associated), a closure, or a `hir::AnonConst`.
pub fn body_owner(self, BodyId { hir_id }: BodyId) -> HirId { pub fn body_owner(self, BodyId { hir_id }: BodyId) -> HirId {
let parent = self.get_parent_node(hir_id); let parent = self.parent_id(hir_id);
assert!(self.find(parent).map_or(false, |n| is_body_owner(n, hir_id)), "{hir_id:?}"); assert!(self.find(parent).map_or(false, |n| is_body_owner(n, hir_id)), "{hir_id:?}");
parent parent
} }
@ -642,21 +650,21 @@ impl<'hir> Map<'hir> {
} }
/// Returns an iterator for the nodes in the ancestor tree of the `current_id` /// Returns an iterator for the nodes in the ancestor tree of the `current_id`
/// until the crate root is reached. Prefer this over your own loop using `get_parent_node`. /// until the crate root is reached. Prefer this over your own loop using `parent_id`.
#[inline] #[inline]
pub fn parent_id_iter(self, current_id: HirId) -> impl Iterator<Item = HirId> + 'hir { pub fn parent_id_iter(self, current_id: HirId) -> impl Iterator<Item = HirId> + 'hir {
ParentHirIterator { current_id, map: self } ParentHirIterator { current_id, map: self }
} }
/// Returns an iterator for the nodes in the ancestor tree of the `current_id` /// Returns an iterator for the nodes in the ancestor tree of the `current_id`
/// until the crate root is reached. Prefer this over your own loop using `get_parent_node`. /// until the crate root is reached. Prefer this over your own loop using `parent_id`.
#[inline] #[inline]
pub fn parent_iter(self, current_id: HirId) -> impl Iterator<Item = (HirId, Node<'hir>)> { pub fn parent_iter(self, current_id: HirId) -> impl Iterator<Item = (HirId, Node<'hir>)> {
self.parent_id_iter(current_id).filter_map(move |id| Some((id, self.find(id)?))) self.parent_id_iter(current_id).filter_map(move |id| Some((id, self.find(id)?)))
} }
/// Returns an iterator for the nodes in the ancestor tree of the `current_id` /// Returns an iterator for the nodes in the ancestor tree of the `current_id`
/// until the crate root is reached. Prefer this over your own loop using `get_parent_node`. /// until the crate root is reached. Prefer this over your own loop using `parent_id`.
#[inline] #[inline]
pub fn parent_owner_iter(self, current_id: HirId) -> ParentOwnerIterator<'hir> { pub fn parent_owner_iter(self, current_id: HirId) -> ParentOwnerIterator<'hir> {
ParentOwnerIterator { current_id, map: self } ParentOwnerIterator { current_id, map: self }
@ -664,7 +672,7 @@ impl<'hir> Map<'hir> {
/// Checks if the node is left-hand side of an assignment. /// Checks if the node is left-hand side of an assignment.
pub fn is_lhs(self, id: HirId) -> bool { pub fn is_lhs(self, id: HirId) -> bool {
match self.find(self.get_parent_node(id)) { match self.find_parent(id) {
Some(Node::Expr(expr)) => match expr.kind { Some(Node::Expr(expr)) => match expr.kind {
ExprKind::Assign(lhs, _rhs, _span) => lhs.hir_id == id, ExprKind::Assign(lhs, _rhs, _span) => lhs.hir_id == id,
_ => false, _ => false,
@ -892,7 +900,7 @@ impl<'hir> Map<'hir> {
Node::Pat(&Pat { kind: PatKind::Binding(_, _, ident, _), .. }) => Some(ident), Node::Pat(&Pat { kind: PatKind::Binding(_, _, ident, _), .. }) => Some(ident),
// A `Ctor` doesn't have an identifier itself, but its parent // A `Ctor` doesn't have an identifier itself, but its parent
// struct/variant does. Compare with `hir::Map::opt_span`. // struct/variant does. Compare with `hir::Map::opt_span`.
Node::Ctor(..) => match self.find(self.get_parent_node(id))? { Node::Ctor(..) => match self.find_parent(id)? {
Node::Item(item) => Some(item.ident), Node::Item(item) => Some(item.ident),
Node::Variant(variant) => Some(variant.ident), Node::Variant(variant) => Some(variant.ident),
_ => unreachable!(), _ => unreachable!(),
@ -1021,7 +1029,7 @@ impl<'hir> Map<'hir> {
ForeignItemKind::Fn(decl, _, _) => until_within(item.span, decl.output.span()), ForeignItemKind::Fn(decl, _, _) => until_within(item.span, decl.output.span()),
_ => named_span(item.span, item.ident, None), _ => named_span(item.span, item.ident, None),
}, },
Node::Ctor(_) => return self.opt_span(self.get_parent_node(hir_id)), Node::Ctor(_) => return self.opt_span(self.parent_id(hir_id)),
Node::Expr(Expr { Node::Expr(Expr {
kind: ExprKind::Closure(Closure { fn_decl_span, .. }), kind: ExprKind::Closure(Closure { fn_decl_span, .. }),
span, span,
@ -1063,7 +1071,7 @@ impl<'hir> Map<'hir> {
Node::PatField(field) => field.span, Node::PatField(field) => field.span,
Node::Arm(arm) => arm.span, Node::Arm(arm) => arm.span,
Node::Block(block) => block.span, Node::Block(block) => block.span,
Node::Ctor(..) => self.span_with_body(self.get_parent_node(hir_id)), Node::Ctor(..) => self.span_with_body(self.parent_id(hir_id)),
Node::Lifetime(lifetime) => lifetime.ident.span, Node::Lifetime(lifetime) => lifetime.ident.span,
Node::GenericParam(param) => param.span, Node::GenericParam(param) => param.span,
Node::Infer(i) => i.span, Node::Infer(i) => i.span,
@ -1093,7 +1101,7 @@ impl<'hir> Map<'hir> {
/// Returns the HirId of `N` in `struct Foo<const N: usize = { ... }>` when /// Returns the HirId of `N` in `struct Foo<const N: usize = { ... }>` when
/// called with the HirId for the `{ ... }` anon const /// called with the HirId for the `{ ... }` anon const
pub fn opt_const_param_default_param_def_id(self, anon_const: HirId) -> Option<LocalDefId> { pub fn opt_const_param_default_param_def_id(self, anon_const: HirId) -> Option<LocalDefId> {
match self.get(self.get_parent_node(anon_const)) { match self.get_parent(anon_const) {
Node::GenericParam(GenericParam { Node::GenericParam(GenericParam {
def_id: param_id, def_id: param_id,
kind: GenericParamKind::Const { .. }, kind: GenericParamKind::Const { .. },

View file

@ -182,7 +182,7 @@ impl TyCtxt<'_> {
if hir.attrs(id).iter().any(|attr| Level::from_attr(attr).is_some()) { if hir.attrs(id).iter().any(|attr| Level::from_attr(attr).is_some()) {
return id; return id;
} }
let next = hir.get_parent_node(id); let next = hir.parent_id(id);
if next == id { if next == id {
bug!("lint traversal reached the root of the crate"); bug!("lint traversal reached the root of the crate");
} }

View file

@ -2506,7 +2506,7 @@ impl<'tcx> ConstantKind<'tcx> {
} }
let hir_id = tcx.hir().local_def_id_to_hir_id(def.did); let hir_id = tcx.hir().local_def_id_to_hir_id(def.did);
let parent_substs = if let Some(parent_hir_id) = tcx.hir().find_parent_node(hir_id) { let parent_substs = if let Some(parent_hir_id) = tcx.hir().opt_parent_id(hir_id) {
if let Some(parent_did) = tcx.hir().opt_local_def_id(parent_hir_id) { if let Some(parent_did) = tcx.hir().opt_local_def_id(parent_hir_id) {
InternalSubsts::identity_for_item(tcx, parent_did.to_def_id()) InternalSubsts::identity_for_item(tcx, parent_did.to_def_id())
} else { } else {

View file

@ -457,7 +457,7 @@ impl<'tcx> TyCtxt<'tcx> {
.def_id .def_id
.as_local() .as_local()
.map(|id| hir.local_def_id_to_hir_id(id)) .map(|id| hir.local_def_id_to_hir_id(id))
.and_then(|id| self.hir().find(self.hir().get_parent_node(id))) .and_then(|id| self.hir().find_parent(id))
.as_ref() .as_ref()
.and_then(|node| node.generics()) .and_then(|node| node.generics())
{ {

View file

@ -247,14 +247,14 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
fn check_let_chain(&mut self, cx: &mut MatchCheckCtxt<'p, 'tcx>, pat_id: HirId) -> bool { fn check_let_chain(&mut self, cx: &mut MatchCheckCtxt<'p, 'tcx>, pat_id: HirId) -> bool {
let hir = self.tcx.hir(); let hir = self.tcx.hir();
let parent = hir.get_parent_node(pat_id); let parent = hir.parent_id(pat_id);
// First, figure out if the given pattern is part of a let chain, // First, figure out if the given pattern is part of a let chain,
// and if so, obtain the top node of the chain. // and if so, obtain the top node of the chain.
let mut top = parent; let mut top = parent;
let mut part_of_chain = false; let mut part_of_chain = false;
loop { loop {
let new_top = hir.get_parent_node(top); let new_top = hir.parent_id(top);
if let hir::Node::Expr( if let hir::Node::Expr(
hir::Expr { hir::Expr {
kind: hir::ExprKind::Binary(Spanned { node: hir::BinOpKind::And, .. }, lhs, rhs), kind: hir::ExprKind::Binary(Spanned { node: hir::BinOpKind::And, .. }, lhs, rhs),
@ -1054,7 +1054,7 @@ pub enum LetSource {
fn let_source(tcx: TyCtxt<'_>, pat_id: HirId) -> LetSource { fn let_source(tcx: TyCtxt<'_>, pat_id: HirId) -> LetSource {
let hir = tcx.hir(); let hir = tcx.hir();
let parent = hir.get_parent_node(pat_id); let parent = hir.parent_id(pat_id);
let_source_parent(tcx, parent, Some(pat_id)) let_source_parent(tcx, parent, Some(pat_id))
} }
@ -1073,7 +1073,7 @@ fn let_source_parent(tcx: TyCtxt<'_>, parent: HirId, pat_id: Option<HirId>) -> L
_ => {} _ => {}
} }
let parent_parent = hir.get_parent_node(parent); let parent_parent = hir.parent_id(parent);
let parent_parent_node = hir.get(parent_parent); let parent_parent_node = hir.get(parent_parent);
match parent_parent_node { match parent_parent_node {
hir::Node::Stmt(hir::Stmt { kind: hir::StmtKind::Local(_), .. }) => { hir::Node::Stmt(hir::Stmt { kind: hir::StmtKind::Local(_), .. }) => {
@ -1085,8 +1085,8 @@ fn let_source_parent(tcx: TyCtxt<'_>, parent: HirId, pat_id: Option<HirId>) -> L
_ => {} _ => {}
} }
let parent_parent_parent = hir.get_parent_node(parent_parent); let parent_parent_parent = hir.parent_id(parent_parent);
let parent_parent_parent_parent = hir.get_parent_node(parent_parent_parent); let parent_parent_parent_parent = hir.parent_id(parent_parent_parent);
let parent_parent_parent_parent_node = hir.get(parent_parent_parent_parent); let parent_parent_parent_parent_node = hir.get(parent_parent_parent_parent);
if let hir::Node::Expr(hir::Expr { if let hir::Node::Expr(hir::Expr {

View file

@ -2141,7 +2141,7 @@ fn check_private_in_public(tcx: TyCtxt<'_>, (): ()) {
if !old_error_set_ancestry.insert(id) { if !old_error_set_ancestry.insert(id) {
break; break;
} }
let parent = tcx.hir().get_parent_node(id); let parent = tcx.hir().parent_id(id);
if parent == id { if parent == id {
break; break;
} }

View file

@ -600,7 +600,7 @@ impl<'tcx> SaveContext<'tcx> {
if seg.res != Res::Err { if seg.res != Res::Err {
seg.res seg.res
} else { } else {
let parent_node = self.tcx.hir().get_parent_node(hir_id); let parent_node = self.tcx.hir().parent_id(hir_id);
self.get_path_res(parent_node) self.get_path_res(parent_node)
} }
} }

View file

@ -554,6 +554,16 @@ pub enum PrintRequest {
SplitDebuginfo, 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 { pub enum Input {
/// Load source code from a file. /// Load source code from a file.
File(PathBuf), File(PathBuf),
@ -2761,7 +2771,7 @@ pub(crate) mod dep_tracking {
BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, ErrorOutputType, BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, ErrorOutputType,
InstrumentCoverage, LdImpl, LinkerPluginLto, LocationDetail, LtoCli, OomStrategy, OptLevel, InstrumentCoverage, LdImpl, LinkerPluginLto, LocationDetail, LtoCli, OomStrategy, OptLevel,
OutputType, OutputTypes, Passes, SourceFileHashAlgorithm, SplitDwarfKind, OutputType, OutputTypes, Passes, SourceFileHashAlgorithm, SplitDwarfKind,
SwitchWithOptPath, SymbolManglingVersion, TrimmedDefPaths, SwitchWithOptPath, SymbolManglingVersion, TraitSolver, TrimmedDefPaths,
}; };
use crate::lint; use crate::lint;
use crate::options::WasiExecModel; use crate::options::WasiExecModel;
@ -2861,6 +2871,7 @@ pub(crate) mod dep_tracking {
BranchProtection, BranchProtection,
OomStrategy, OomStrategy,
LanguageIdentifier, LanguageIdentifier,
TraitSolver,
); );
impl<T1, T2> DepTrackingHash for (T1, T2) impl<T1, T2> DepTrackingHash for (T1, T2)

View file

@ -382,6 +382,8 @@ mod desc {
"`all` (default), `except-unused-generics`, `except-unused-functions`, or `off`"; "`all` (default), `except-unused-generics`, `except-unused-functions`, or `off`";
pub const parse_unpretty: &str = "`string` or `string=string`"; 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_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 = pub const parse_lto: &str =
"either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted"; "either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted";
pub const parse_linker_plugin_lto: &str = 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 { pub(crate) fn parse_lto(slot: &mut LtoCli, v: Option<&str>) -> bool {
if v.is_some() { if v.is_some() {
let mut bool_arg = None; let mut bool_arg = None;
@ -1249,8 +1263,6 @@ options! {
"instrument control-flow architecture protection"), "instrument control-flow architecture protection"),
cgu_partitioning_strategy: Option<String> = (None, parse_opt_string, [TRACKED], cgu_partitioning_strategy: Option<String> = (None, parse_opt_string, [TRACKED],
"the codegen unit partitioning strategy to use"), "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], codegen_backend: Option<String> = (None, parse_opt_string, [TRACKED],
"the backend to use"), "the backend to use"),
combine_cgu: bool = (false, parse_bool, [TRACKED], combine_cgu: bool = (false, parse_bool, [TRACKED],
@ -1609,6 +1621,8 @@ options! {
"for every macro invocation, print its name and arguments (default: no)"), "for every macro invocation, print its name and arguments (default: no)"),
track_diagnostics: bool = (false, parse_bool, [UNTRACKED], track_diagnostics: bool = (false, parse_bool, [UNTRACKED],
"tracks where in rustc a diagnostic was emitted"), "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 // 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 // alongside query results and changes to translation options can affect diagnostics - so
// translation options should be tracked. // translation options should be tracked.

View file

@ -3,6 +3,7 @@ use std::fmt::Debug;
use super::TraitEngine; use super::TraitEngine;
use super::{ChalkFulfillmentContext, FulfillmentContext}; use super::{ChalkFulfillmentContext, FulfillmentContext};
use crate::solve::FulfillmentCtxt as NextFulfillmentCtxt;
use crate::traits::NormalizeExt; use crate::traits::NormalizeExt;
use rustc_data_structures::fx::FxIndexSet; use rustc_data_structures::fx::FxIndexSet;
use rustc_hir::def_id::{DefId, LocalDefId}; 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::ToPredicate;
use rustc_middle::ty::TypeFoldable; use rustc_middle::ty::TypeFoldable;
use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_session::config::TraitSolver;
use rustc_span::Span; use rustc_span::Span;
pub trait TraitEngineExt<'tcx> { pub trait TraitEngineExt<'tcx> {
@ -29,18 +31,18 @@ pub trait TraitEngineExt<'tcx> {
impl<'tcx> TraitEngineExt<'tcx> for dyn TraitEngine<'tcx> { impl<'tcx> TraitEngineExt<'tcx> for dyn TraitEngine<'tcx> {
fn new(tcx: TyCtxt<'tcx>) -> Box<Self> { fn new(tcx: TyCtxt<'tcx>) -> Box<Self> {
if tcx.sess.opts.unstable_opts.chalk { match tcx.sess.opts.unstable_opts.trait_solver {
Box::new(ChalkFulfillmentContext::new()) TraitSolver::Classic => Box::new(FulfillmentContext::new()),
} else { TraitSolver::Chalk => Box::new(ChalkFulfillmentContext::new()),
Box::new(FulfillmentContext::new()) TraitSolver::Next => Box::new(NextFulfillmentCtxt::new()),
} }
} }
fn new_in_snapshot(tcx: TyCtxt<'tcx>) -> Box<Self> { fn new_in_snapshot(tcx: TyCtxt<'tcx>) -> Box<Self> {
if tcx.sess.opts.unstable_opts.chalk { match tcx.sess.opts.unstable_opts.trait_solver {
Box::new(ChalkFulfillmentContext::new_in_snapshot()) TraitSolver::Classic => Box::new(FulfillmentContext::new_in_snapshot()),
} else { TraitSolver::Chalk => Box::new(ChalkFulfillmentContext::new_in_snapshot()),
Box::new(FulfillmentContext::new_in_snapshot()) TraitSolver::Next => Box::new(NextFulfillmentCtxt::new()),
} }
} }
} }

View file

@ -40,6 +40,7 @@ use rustc_middle::ty::{
self, SubtypePredicate, ToPolyTraitRef, ToPredicate, TraitRef, Ty, TyCtxt, TypeFoldable, self, SubtypePredicate, ToPolyTraitRef, ToPredicate, TraitRef, Ty, TyCtxt, TypeFoldable,
TypeVisitable, TypeVisitable,
}; };
use rustc_session::config::TraitSolver;
use rustc_session::Limit; use rustc_session::Limit;
use rustc_span::def_id::LOCAL_CRATE; use rustc_span::def_id::LOCAL_CRATE;
use rustc_span::symbol::sym; use rustc_span::symbol::sym;
@ -1167,7 +1168,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
} }
ty::PredicateKind::WellFormed(ty) => { 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 // WF predicates cannot themselves make
// errors. They can only block due to // errors. They can only block due to
// ambiguity; otherwise, they always // ambiguity; otherwise, they always

View file

@ -117,7 +117,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
Some(if movability.is_some() { "an async closure" } else { "a closure" }) Some(if movability.is_some() { "an async closure" } else { "a closure" })
}), }),
hir::Node::Expr(hir::Expr { .. }) => { 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 } if parent_hid != hir_id { self.describe_enclosure(parent_hid) } else { None }
} }
_ => None, _ => None,

View file

@ -838,8 +838,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
let hir = self.tcx.hir(); let hir = self.tcx.hir();
let hir_id = hir.local_def_id_to_hir_id(def_id.as_local()?); 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(hir_id) {
match hir.find(parent_node) {
Some(hir::Node::Stmt(hir::Stmt { kind: hir::StmtKind::Local(local), .. })) => { Some(hir::Node::Stmt(hir::Stmt { kind: hir::StmtKind::Local(local), .. })) => {
get_name(err, &local.pat.kind) get_name(err, &local.pat.kind)
} }
@ -1421,7 +1420,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
trait_pred: ty::PolyTraitPredicate<'tcx>, trait_pred: ty::PolyTraitPredicate<'tcx>,
) -> bool { ) -> bool {
let hir = self.tcx.hir(); 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); let node = hir.find(parent_node);
if let Some(hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(sig, _, body_id), .. })) = 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 && 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> { fn return_type_span(&self, obligation: &PredicateObligation<'tcx>) -> Option<Span> {
let hir = self.tcx.hir(); 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 { let Some(hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(sig, ..), .. })) = hir.find(parent_node) else {
return None; return None;
}; };
@ -1483,7 +1482,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
} }
let hir = self.tcx.hir(); 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 node = hir.find(fn_hir_id);
let Some(hir::Node::Item(hir::Item { let Some(hir::Node::Item(hir::Item {
kind: hir::ItemKind::Fn(sig, _, body_id), kind: hir::ItemKind::Fn(sig, _, body_id),
@ -1695,7 +1694,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
} }
let hir = self.tcx.hir(); 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); let node = hir.find(parent_node);
if let Some(hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(_, _, body_id), .. })) = if let Some(hir::Node::Item(hir::Item { kind: hir::ItemKind::Fn(_, _, body_id), .. })) =
node node
@ -2291,7 +2290,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
let expr = hir.expect_expr(expr_id); let expr = hir.expect_expr(expr_id);
debug!("target_ty evaluated from {:?}", expr); 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) { if let Some(hir::Node::Expr(e)) = hir.find(parent) {
let parent_span = hir.span(parent); let parent_span = hir.span(parent);
let parent_did = parent.owner.to_def_id(); let parent_did = parent.owner.to_def_id();
@ -2512,7 +2511,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
} }
} }
ObligationCauseCode::VariableType(hir_id) => { 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) { match self.tcx.hir().find(parent_node) {
Some(Node::Local(hir::Local { ty: Some(ty), .. })) => { Some(Node::Local(hir::Local { ty: Some(ty), .. })) => {
err.span_suggestion_verbose( err.span_suggestion_verbose(
@ -2992,7 +2991,7 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
span: Span, span: Span,
) { ) {
let body_hir_id = obligation.cause.body_id; 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) = if let Some(body_id) =
self.tcx.hir().maybe_body_owned_by(self.tcx.hir().local_def_id(item_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 if let hir::ExprKind::Path(hir::QPath::Resolved(None, path)) = expr.kind
&& let hir::Path { res: hir::def::Res::Local(hir_id), .. } = path && let hir::Path { res: hir::def::Res::Local(hir_id), .. } = path
&& let Some(hir::Node::Pat(binding)) = self.tcx.hir().find(*hir_id) && 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(hir::Node::Local(local)) = self.tcx.hir().find(parent_hir_id)
&& let Some(binding_expr) = local.init && 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 if let hir::ExprKind::Path(hir::QPath::Resolved(None, path)) = expr.kind
&& let hir::Path { res: hir::def::Res::Local(hir_id), .. } = path && let hir::Path { res: hir::def::Res::Local(hir_id), .. } = path
&& let Some(hir::Node::Pat(binding)) = self.tcx.hir().find(*hir_id) && 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(binding.hir_id)
&& let Some(parent) = self.tcx.hir().find(parent_hir_id)
{ {
// We've reached the root of the method call chain... // We've reached the root of the method call chain...
if let hir::Node::Local(local) = parent if let hir::Node::Local(local) = parent

View file

@ -15,6 +15,7 @@ use rustc_middle::ty::{
self, Binder, GenericArg, GenericArgKind, GenericParamDefKind, InternalSubsts, SubstsRef, self, Binder, GenericArg, GenericArgKind, GenericParamDefKind, InternalSubsts, SubstsRef,
ToPolyTraitRef, ToPredicate, TraitRef, Ty, TyCtxt, ToPolyTraitRef, ToPredicate, TraitRef, Ty, TyCtxt,
}; };
use rustc_session::config::TraitSolver;
use rustc_span::def_id::DefId; use rustc_span::def_id::DefId;
use crate::traits::project::{normalize_with_depth, normalize_with_depth_to}; 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"); debug!(?closure_def_id, ?trait_ref, ?nested, "confirm closure candidate obligations");
// FIXME: Chalk // FIXME: Chalk
if self.tcx().sess.opts.unstable_opts.trait_solver != TraitSolver::Chalk {
if !self.tcx().sess.opts.unstable_opts.chalk {
nested.push(obligation.with( nested.push(obligation.with(
self.tcx(), self.tcx(),
ty::Binder::dummy(ty::PredicateKind::ClosureKind(closure_def_id, substs, kind)), ty::Binder::dummy(ty::PredicateKind::ClosureKind(closure_def_id, substs, kind)),

View file

@ -2,6 +2,7 @@ use rustc_data_structures::fx::FxIndexSet;
use rustc_hir as hir; use rustc_hir as hir;
use rustc_hir::def_id::DefId; use rustc_hir::def_id::DefId;
use rustc_middle::ty::{self, Binder, Predicate, PredicateKind, ToPredicate, Ty, TyCtxt}; use rustc_middle::ty::{self, Binder, Predicate, PredicateKind, ToPredicate, Ty, TyCtxt};
use rustc_session::config::TraitSolver;
use rustc_trait_selection::traits; use rustc_trait_selection::traits;
fn sized_constraint_for_ty<'tcx>( 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 // are any errors at that point, so outside of type inference you can be
// sure that this will succeed without errors anyway. // 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); let environment = well_formed_types_in_env(tcx, def_id);
predicates.extend(environment); predicates.extend(environment);
} }
@ -161,7 +162,7 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
kind: hir::ImplItemKind::Type(..) | hir::ImplItemKind::Fn(..), kind: hir::ImplItemKind::Type(..) | hir::ImplItemKind::Fn(..),
.. ..
}) => { }) => {
let parent_hir_id = tcx.hir().get_parent_node(hir_id); let parent_hir_id = tcx.hir().parent_id(hir_id);
match tcx.hir().get(parent_hir_id) { match tcx.hir().get(parent_hir_id) {
hir::Node::Item(hir::Item { hir::Node::Item(hir::Item {
kind: hir::ItemKind::Impl(hir::Impl { constness, .. }), kind: hir::ItemKind::Impl(hir::Impl { constness, .. }),

View file

@ -198,6 +198,9 @@ target = ["<host_platform>", "aarch64-fuchsia", "x86_64-fuchsia"]
[rust] [rust]
lld = true lld = true
[llvm]
download-ci-llvm = false
[target.x86_64-fuchsia] [target.x86_64-fuchsia]
cc = "clang" cc = "clang"
cxx = "clang++" cxx = "clang++"

View file

@ -352,6 +352,7 @@ img {
.sub-logo-container, .logo-container { .sub-logo-container, .logo-container {
/* zero text boxes so that computed line height = image height exactly */ /* zero text boxes so that computed line height = image height exactly */
line-height: 0; line-height: 0;
display: block;
} }
.sub-logo-container { .sub-logo-container {
@ -495,7 +496,7 @@ ul.block, .block li {
color: var(--sidebar-link-color); color: var(--sidebar-link-color);
} }
.sidebar .current, .sidebar .current,
.sidebar a:hover { .sidebar a:hover:not(.logo-container) {
background-color: var(--sidebar-current-link-background-color); background-color: var(--sidebar-current-link-background-color);
} }
@ -1570,7 +1571,7 @@ in storage.js
/* Hide the logo and item name from the sidebar. Those are displayed /* Hide the logo and item name from the sidebar. Those are displayed
in the mobile-topbar instead. */ in the mobile-topbar instead. */
.sidebar .sidebar-logo, .sidebar .logo-container,
.sidebar .location { .sidebar .location {
display: none; display: none;
} }

View file

@ -72,28 +72,24 @@
{%- if page.css_class != "source" -%} {%- if page.css_class != "source" -%}
<nav class="mobile-topbar"> {#- -#} <nav class="mobile-topbar"> {#- -#}
<button class="sidebar-menu-toggle">&#9776;</button> {#- -#} <button class="sidebar-menu-toggle">&#9776;</button> {#- -#}
<a class="sidebar-logo" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#} <a class="logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#}
<div class="logo-container"> {#- -#} {%- if !layout.logo.is_empty() -%}
{%- if !layout.logo.is_empty() -%} <img src="{{layout.logo}}" alt="logo"> {#- -#}
<img src="{{layout.logo}}" alt="logo"> {#- -#} {%- else -%}
{%- else -%} <img class="rust-logo" src="{{static_root_path|safe}}{{files.rust_logo_svg}}" alt="logo"> {#- -#}
<img class="rust-logo" src="{{static_root_path|safe}}{{files.rust_logo_svg}}" alt="logo"> {#- -#} {%- endif -%}
{%- endif -%}
</div> {#- -#}
</a> {#- -#} </a> {#- -#}
<h2></h2> {#- -#} <h2></h2> {#- -#}
</nav> {#- -#} </nav> {#- -#}
{%- endif -%} {%- endif -%}
<nav class="sidebar"> {#- -#} <nav class="sidebar"> {#- -#}
{%- if page.css_class != "source" -%} {%- if page.css_class != "source" -%}
<a class="sidebar-logo" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#} <a class="logo-container" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#}
<div class="logo-container"> {#- -#} {%- if !layout.logo.is_empty() %}
{%- if !layout.logo.is_empty() %} <img src="{{layout.logo}}" alt="logo"> {#- -#}
<img src="{{layout.logo}}" alt="logo"> {#- -#} {%- else -%}
{%- else -%} <img class="rust-logo" src="{{static_root_path|safe}}{{files.rust_logo_svg}}" alt="logo"> {#- -#}
<img class="rust-logo" src="{{static_root_path|safe}}{{files.rust_logo_svg}}" alt="logo"> {#- -#} {%- endif -%}
{%- endif -%}
</div> {#- -#}
</a> {#- -#} </a> {#- -#}
{%- endif -%} {%- endif -%}
{{- sidebar|safe -}} {{- sidebar|safe -}}

View file

@ -82,7 +82,7 @@ pub(crate) fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -
let hir_id = cx.tcx.hir().local_def_id_to_hir_id(item.item_id.expect_def_id().expect_local()); let hir_id = cx.tcx.hir().local_def_id_to_hir_id(item.item_id.expect_def_id().expect_local());
// check if parent is trait impl // check if parent is trait impl
if let Some(parent_hir_id) = cx.tcx.hir().find_parent_node(hir_id) { if let Some(parent_hir_id) = cx.tcx.hir().opt_parent_id(hir_id) {
if let Some(parent_node) = cx.tcx.hir().find(parent_hir_id) { if let Some(parent_node) = cx.tcx.hir().find(parent_hir_id) {
if matches!( if matches!(
parent_node, parent_node,

View file

@ -8,7 +8,6 @@
-Z branch-protection=val -- set options for branch target identification and pointer authentication on AArch64 -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 cf-protection=val -- instrument control-flow architecture protection
-Z cgu-partitioning-strategy=val -- the codegen unit partitioning strategy to use -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 codegen-backend=val -- the backend to use
-Z combine-cgu=val -- combine CGUs into a single one -Z combine-cgu=val -- combine CGUs into a single one
-Z crate-attr=val -- inject the given attribute in the crate -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 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 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 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-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-directionality-markers=val -- emit directionality isolation markers in translated diagnostics
-Z translate-lang=val -- language identifier for diagnostic output -Z translate-lang=val -- language identifier for diagnostic output

View file

@ -7,7 +7,7 @@
struct Layout; struct Layout;
#[alloc_error_handler] #[alloc_error_handler]
fn oom() -> ! { //~ ERROR this function takes 0 arguments but 1 argument was supplied fn oom() -> ! { //~ ERROR function takes 0 arguments but 1 argument was supplied
loop {} loop {}
} }

View file

@ -18,11 +18,11 @@ fn permuted(_x: X, _y: Y, _z: Z) {}
fn main() { fn main() {
invalid(1.0); //~ ERROR mismatched types invalid(1.0); //~ ERROR mismatched types
extra(""); //~ ERROR this function takes extra(""); //~ ERROR function takes
missing(); //~ ERROR this function takes missing(); //~ ERROR function takes
swapped("", 1); //~ ERROR arguments to this function are incorrect swapped("", 1); //~ ERROR arguments to this function are incorrect
permuted(Y {}, Z {}, X {}); //~ ERROR arguments to this function are incorrect permuted(Y {}, Z {}, X {}); //~ ERROR arguments to this function are incorrect
let closure = |x| x; let closure = |x| x;
closure(); //~ ERROR this function takes closure(); //~ ERROR function takes
} }

View file

@ -4,5 +4,5 @@ fn foo(x: &(dyn Display + Send)) {}
fn main() { fn main() {
foo(); foo();
//~^ ERROR this function takes 1 argument but 0 arguments were supplied //~^ ERROR function takes 1 argument but 0 arguments were supplied
} }

View file

@ -1,11 +1,11 @@
fn foo<T: Fn()>(t: T) { fn foo<T: Fn()>(t: T) {
t(1i32); t(1i32);
//~^ ERROR this function takes 0 arguments but 1 argument was supplied //~^ ERROR function takes 0 arguments but 1 argument was supplied
} }
fn bar(t: impl Fn()) { fn bar(t: impl Fn()) {
t(1i32); t(1i32);
//~^ ERROR this function takes 0 arguments but 1 argument was supplied //~^ ERROR function takes 0 arguments but 1 argument was supplied
} }
fn baz() -> impl Fn() { fn baz() -> impl Fn() {
@ -14,13 +14,13 @@ fn baz() -> impl Fn() {
fn baz2() { fn baz2() {
baz()(1i32) baz()(1i32)
//~^ ERROR this function takes 0 arguments but 1 argument was supplied //~^ ERROR function takes 0 arguments but 1 argument was supplied
} }
fn qux() { fn qux() {
let x = || {}; let x = || {};
x(1i32); x(1i32);
//~^ ERROR this function takes 0 arguments but 1 argument was supplied //~^ ERROR function takes 0 arguments but 1 argument was supplied
} }
fn main() {} fn main() {}

View file

@ -5,5 +5,5 @@ extern "Rust" {
fn main() { fn main() {
dstfn(1); dstfn(1);
//~^ ERROR this function takes 2 arguments but 1 argument was supplied //~^ ERROR function takes 2 arguments but 1 argument was supplied
} }

View file

@ -4,30 +4,30 @@ fn two_arg_same(_a: i32, _b: i32) {}
fn two_arg_diff(_a: i32, _b: &str) {} fn two_arg_diff(_a: i32, _b: &str) {}
fn main() { fn main() {
empty(""); //~ ERROR this function takes empty(""); //~ ERROR function takes
one_arg(1, 1); //~ ERROR this function takes one_arg(1, 1); //~ ERROR function takes
one_arg(1, ""); //~ ERROR this function takes one_arg(1, ""); //~ ERROR function takes
one_arg(1, "", 1.0); //~ ERROR this function takes one_arg(1, "", 1.0); //~ ERROR function takes
two_arg_same(1, 1, 1); //~ ERROR this function takes two_arg_same(1, 1, 1); //~ ERROR function takes
two_arg_same(1, 1, 1.0); //~ ERROR this function takes two_arg_same(1, 1, 1.0); //~ ERROR function takes
two_arg_diff(1, 1, ""); //~ ERROR this function takes two_arg_diff(1, 1, ""); //~ ERROR function takes
two_arg_diff(1, "", ""); //~ ERROR this function takes two_arg_diff(1, "", ""); //~ ERROR function takes
two_arg_diff(1, 1, "", ""); //~ ERROR this function takes two_arg_diff(1, 1, "", ""); //~ ERROR function takes
two_arg_diff(1, "", 1, ""); //~ ERROR this function takes two_arg_diff(1, "", 1, ""); //~ ERROR function takes
// Check with weird spacing and newlines // Check with weird spacing and newlines
two_arg_same(1, 1, ""); //~ ERROR this function takes two_arg_same(1, 1, ""); //~ ERROR function takes
two_arg_diff(1, 1, ""); //~ ERROR this function takes two_arg_diff(1, 1, ""); //~ ERROR function takes
two_arg_same( //~ ERROR this function takes two_arg_same( //~ ERROR function takes
1, 1,
1, 1,
"" ""
); );
two_arg_diff( //~ ERROR this function takes two_arg_diff( //~ ERROR function takes
1, 1,
1, 1,
"" ""

View file

@ -2,6 +2,6 @@ fn foo(i: impl std::fmt::Display) {}
fn main() { fn main() {
foo::<()>(()); foo::<()>(());
//~^ ERROR this function takes 0 generic arguments but 1 generic argument was supplied //~^ ERROR function takes 0 generic arguments but 1 generic argument was supplied
//~| ERROR `()` doesn't implement `std::fmt::Display` //~| ERROR `()` doesn't implement `std::fmt::Display`
} }

View file

@ -31,7 +31,7 @@ fn three_diff(_a: T1, _b: T2, _c: T3) {}
fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {} fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {}
fn main() { fn main() {
three_diff(T2::new(0)); //~ ERROR this function takes three_diff(T2::new(0)); //~ ERROR function takes
four_shuffle(T3::default(), T4::default(), T1::default(), T2::default()); //~ ERROR 35:5: 35:17: arguments to this function are incorrect [E0308] four_shuffle(T3::default(), T4::default(), T1::default(), T2::default()); //~ ERROR 35:5: 35:17: arguments to this function are incorrect [E0308]
four_shuffle(T3::default(), T2::default(), T1::default(), T3::default()); //~ ERROR 36:5: 36:17: arguments to this function are incorrect [E0308] four_shuffle(T3::default(), T2::default(), T1::default(), T3::default()); //~ ERROR 36:5: 36:17: arguments to this function are incorrect [E0308]

View file

@ -13,7 +13,7 @@ fn f(
) {} ) {}
fn main() { fn main() {
f(C, A, A, A, B, B, C); //~ ERROR this function takes 6 arguments but 7 arguments were supplied [E0061] f(C, A, A, A, B, B, C); //~ ERROR function takes 6 arguments but 7 arguments were supplied [E0061]
f(C, C, A, A, B, B); //~ ERROR arguments to this function are incorrect [E0308] f(C, C, A, A, B, B); //~ ERROR arguments to this function are incorrect [E0308]
f(A, A, D, D, B, B); //~ arguments to this function are incorrect [E0308] f(A, A, D, D, B, B); //~ arguments to this function are incorrect [E0308]
f(C, C, B, B, A, A); //~ arguments to this function are incorrect [E0308] f(C, C, B, B, A, A); //~ arguments to this function are incorrect [E0308]

View file

@ -5,5 +5,5 @@ fn arg<T>() -> T { todo!() }
fn main() { fn main() {
let x = arg(); // `x` must be inferred let x = arg(); // `x` must be inferred
// The reference on `&x` is important to reproduce the ICE // The reference on `&x` is important to reproduce the ICE
f(&x, ""); //~ ERROR this function takes 3 arguments but 2 arguments were supplied f(&x, ""); //~ ERROR function takes 3 arguments but 2 arguments were supplied
} }

View file

@ -1,6 +1,6 @@
fn main() { fn main() {
g((), ()); g((), ());
//~^ ERROR this function takes 6 arguments but 2 arguments were supplied //~^ ERROR function takes 6 arguments but 2 arguments were supplied
} }
pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {} pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {}

View file

@ -10,5 +10,5 @@ fn foo(a: &A, d: D, e: &E, g: G) {}
fn main() { fn main() {
foo(&&A, B, C, D, E, F, G); foo(&&A, B, C, D, E, F, G);
//~^ ERROR this function takes 4 arguments but 7 arguments were supplied //~^ ERROR function takes 4 arguments but 7 arguments were supplied
} }

View file

@ -1,4 +1,4 @@
fn main() { fn main() {
(|_, ()| ())(if true {} else {return;}); (|_, ()| ())(if true {} else {return;});
//~^ ERROR this function takes 2 arguments but 1 argument was supplied //~^ ERROR function takes 2 arguments but 1 argument was supplied
} }

View file

@ -1,4 +1,4 @@
fn main() { fn main() {
(|_, ()| ())([return, ()]); (|_, ()| ())([return, ()]);
//~^ ERROR this function takes 2 arguments but 1 argument was supplied //~^ ERROR function takes 2 arguments but 1 argument was supplied
} }

View file

@ -1,5 +1,5 @@
fn main() { fn main() {
let f = |_: (), f: fn()| f; let f = |_: (), f: fn()| f;
let _f = f(main); let _f = f(main);
//~^ ERROR this function takes 2 arguments but 1 argument was supplied //~^ ERROR function takes 2 arguments but 1 argument was supplied
} }

View file

@ -7,34 +7,34 @@ fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {}
fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {}
fn main() { fn main() {
one_arg(); //~ ERROR this function takes one_arg(); //~ ERROR function takes
// The headers here show the types expected, // The headers here show the types expected,
// with formatting to emphasize which arguments are missing // with formatting to emphasize which arguments are missing
/* i32 f32 */ /* i32 f32 */
two_same( ); //~ ERROR this function takes two_same( ); //~ ERROR function takes
two_same( 1 ); //~ ERROR this function takes two_same( 1 ); //~ ERROR function takes
two_diff( ); //~ ERROR this function takes two_diff( ); //~ ERROR function takes
two_diff( 1 ); //~ ERROR this function takes two_diff( 1 ); //~ ERROR function takes
two_diff( 1.0 ); //~ ERROR this function takes two_diff( 1.0 ); //~ ERROR function takes
/* i32 i32 i32 */ /* i32 i32 i32 */
three_same( ); //~ ERROR this function takes three_same( ); //~ ERROR function takes
three_same( 1 ); //~ ERROR this function takes three_same( 1 ); //~ ERROR function takes
three_same( 1, 1 ); //~ ERROR this function takes three_same( 1, 1 ); //~ ERROR function takes
/* i32 f32 &str */ /* i32 f32 &str */
three_diff( 1.0, "" ); //~ ERROR this function takes three_diff( 1.0, "" ); //~ ERROR function takes
three_diff( 1, "" ); //~ ERROR this function takes three_diff( 1, "" ); //~ ERROR function takes
three_diff( 1, 1.0 ); //~ ERROR this function takes three_diff( 1, 1.0 ); //~ ERROR function takes
three_diff( "" ); //~ ERROR this function takes three_diff( "" ); //~ ERROR function takes
three_diff( 1.0 ); //~ ERROR this function takes three_diff( 1.0 ); //~ ERROR function takes
three_diff( 1 ); //~ ERROR this function takes three_diff( 1 ); //~ ERROR function takes
/* i32 f32 f32 &str */ /* i32 f32 f32 &str */
four_repeated( ); //~ ERROR this function takes four_repeated( ); //~ ERROR function takes
four_repeated( 1, "" ); //~ ERROR this function takes four_repeated( 1, "" ); //~ ERROR function takes
/* i32 f32 i32 f32 &str */ /* i32 f32 i32 f32 &str */
complex( ); //~ ERROR this function takes complex( ); //~ ERROR function takes
complex( 1, "" ); //~ ERROR this function takes complex( 1, "" ); //~ ERROR function takes
} }

View file

@ -7,11 +7,11 @@ fn three_args(_a: i32, _b: f32, _c: &str) {}
fn main() { fn main() {
// Extra + Invalid // Extra + Invalid
two_args(1, "", X {}); //~ ERROR this function takes two_args(1, "", X {}); //~ ERROR function takes
three_args(1, "", X {}, ""); //~ ERROR this function takes three_args(1, "", X {}, ""); //~ ERROR function takes
// Missing and Invalid // Missing and Invalid
three_args(1, X {}); //~ ERROR this function takes three_args(1, X {}); //~ ERROR function takes
// Missing and Extra // Missing and Extra
three_args(1, "", X {}); //~ ERROR arguments to this function are incorrect three_args(1, "", X {}); //~ ERROR arguments to this function are incorrect
@ -20,5 +20,5 @@ fn main() {
three_args("", X {}, 1); //~ ERROR arguments to this function are incorrect three_args("", X {}, 1); //~ ERROR arguments to this function are incorrect
// Swapped and missing // Swapped and missing
three_args("", 1); //~ ERROR this function takes three_args("", 1); //~ ERROR function takes
} }

View file

@ -4,7 +4,7 @@ error[E0308]: mismatched types
LL | qux.foo(a, b, c, d, e, f, g, h, i, j, k, l); LL | qux.foo(a, b, c, d, e, f, g, h, i, j, k, l);
| --- ^ expected `i32`, found `&i32` | --- ^ expected `i32`, found `&i32`
| | | |
| arguments to this function are incorrect | arguments to this method are incorrect
| |
note: associated function defined here note: associated function defined here
--> $DIR/too-long.rs:4:8 --> $DIR/too-long.rs:4:8

View file

@ -32,7 +32,7 @@ error[E0308]: mismatched types
LL | fn f() { ModelT.chip_paint(Blue); } LL | fn f() { ModelT.chip_paint(Blue); }
| ---------- ^^^^ expected struct `Black`, found struct `Blue` | ---------- ^^^^ expected struct `Black`, found struct `Blue`
| | | |
| arguments to this function are incorrect | arguments to this method are incorrect
| |
note: associated function defined here note: associated function defined here
--> $DIR/associated-type-projection-from-supertrait.rs:12:8 --> $DIR/associated-type-projection-from-supertrait.rs:12:8
@ -46,7 +46,7 @@ error[E0308]: mismatched types
LL | fn g() { ModelU.chip_paint(Black); } LL | fn g() { ModelU.chip_paint(Black); }
| ---------- ^^^^^ expected struct `Blue`, found struct `Black` | ---------- ^^^^^ expected struct `Blue`, found struct `Black`
| | | |
| arguments to this function are incorrect | arguments to this method are incorrect
| |
note: associated function defined here note: associated function defined here
--> $DIR/associated-type-projection-from-supertrait.rs:12:8 --> $DIR/associated-type-projection-from-supertrait.rs:12:8

View file

@ -19,8 +19,8 @@ extern "C" fn bar(f: isize, x: u8) {}
fn main() { fn main() {
unsafe { unsafe {
foo(); //~ ERROR this function takes at least 2 arguments but 0 arguments were supplied foo(); //~ ERROR function takes at least 2 arguments but 0 arguments were supplied
foo(1); //~ ERROR this function takes at least 2 arguments but 1 argument was supplied foo(1); //~ ERROR function takes at least 2 arguments but 1 argument was supplied
let x: unsafe extern "C" fn(f: isize, x: u8) = foo; //~ ERROR mismatched types let x: unsafe extern "C" fn(f: isize, x: u8) = foo; //~ ERROR mismatched types
let y: extern "C" fn(f: isize, x: u8, ...) = bar; //~ ERROR mismatched types let y: extern "C" fn(f: isize, x: u8, ...) = bar; //~ ERROR mismatched types

View file

@ -1,5 +1,5 @@
// check-pass // check-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
fn main() { fn main() {
1 + 2; 1 + 2;

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
fn main() { fn main() {
assert_eq!(1, 1); assert_eq!(1, 1);

View file

@ -1,5 +1,5 @@
// check-pass // check-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
trait Foo {} trait Foo {}

View file

@ -1,6 +1,6 @@
// check-fail // check-fail
// known-bug: unknown // known-bug: unknown
// compile-flags: -Z chalk --edition=2021 // compile-flags: -Z trait-solver=chalk --edition=2021
fn main() -> () {} fn main() -> () {}

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
// Test that `Clone` is correctly implemented for builtin types. // Test that `Clone` is correctly implemented for builtin types.

View file

@ -1,4 +1,4 @@
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
trait Foo { } trait Foo { }

View file

@ -1,4 +1,4 @@
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
fn main() -> () { fn main() -> () {
let t = || {}; let t = || {};

View file

@ -1,4 +1,4 @@
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
trait Foo { } trait Foo { }

View file

@ -1,4 +1,4 @@
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
trait Foo: Sized { } trait Foo: Sized { }

View file

@ -1,6 +1,6 @@
// Split out of impl_wf.rs to work around rust aborting compilation early // 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 { } trait Foo: Sized { }

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
trait Foo { } trait Foo { }

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
trait Foo { } trait Foo { }

View file

@ -1,5 +1,5 @@
// check-pass // check-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
#![allow(dead_code)] #![allow(dead_code)]

View file

@ -1,5 +1,5 @@
// check-pass // check-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
#![allow(dead_code)] #![allow(dead_code)]

View file

@ -1,5 +1,5 @@
// check-pass // check-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
#![allow(dead_code)] #![allow(dead_code)]

View file

@ -1,5 +1,5 @@
// check-pass // check-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
trait Foo { } trait Foo { }

View file

@ -1,5 +1,5 @@
// check-pass // check-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
struct Foo<'a, T> where Box<T>: Clone { struct Foo<'a, T> where Box<T>: Clone {
_x: std::marker::PhantomData<&'a T>, _x: std::marker::PhantomData<&'a T>,

View file

@ -1,5 +1,5 @@
// check-pass // check-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
trait Bar { } trait Bar { }

View file

@ -1,5 +1,5 @@
// check-pass // 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 trait Foo<F: ?Sized> where for<'a> F: Fn(&'a (u8, u16)) -> &'a u8
{ {

View file

@ -1,5 +1,5 @@
// check-pass // check-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
use std::borrow::Borrow; use std::borrow::Borrow;

View file

@ -1,5 +1,5 @@
// check-pass // check-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
fn main() { fn main() {
println!("hello"); println!("hello");

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
trait Foo { } trait Foo { }

View file

@ -1,6 +1,6 @@
// FIXME(chalk): should fail, see comments // FIXME(chalk): should fail, see comments
// check-fail // check-fail
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
#![feature(trivial_bounds)] #![feature(trivial_bounds)]

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
trait Foo { } trait Foo { }
trait Bar: Foo { } trait Bar: Foo { }

View file

@ -1,5 +1,5 @@
// check-pass // check-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
use std::fmt::Display; use std::fmt::Display;

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
trait Foo { } trait Foo { }
trait Bar<U> where U: Foo { } trait Bar<U> where U: Foo { }

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
trait Eq { } trait Eq { }
trait Hash: Eq { } trait Hash: Eq { }

View file

@ -1,4 +1,4 @@
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
trait Foo { } trait Foo { }
impl Foo for i32 { } impl Foo for i32 { }

View file

@ -1,5 +1,5 @@
// check-fail // check-fail
// compile-flags: -Z chalk // compile-flags: -Z trait-solver=chalk
trait Foo { } trait Foo { }

View file

@ -13,5 +13,5 @@ fn test<T, const P: usize>() where Bool<{core::mem::size_of::<T>() > 4}>: True {
fn main() { fn main() {
test::<2>(); test::<2>();
//~^ ERROR this function takes 2 generic arguments //~^ ERROR function takes 2 generic arguments
} }

View file

@ -4,8 +4,8 @@ fn foo<const X: usize, const Y: usize>() -> usize {
fn main() { fn main() {
foo::<0>(); foo::<0>();
//~^ ERROR this function takes 2 //~^ ERROR function takes 2
foo::<0, 0, 0>(); foo::<0, 0, 0>();
//~^ ERROR this function takes 2 //~^ ERROR function takes 2
} }

Some files were not shown because too many files have changed in this diff Show more