Auto merge of #10191 - flip1995:rustup, r=flip1995

Rustup

r? `@ghost`

changelog: none
This commit is contained in:
bors 2023-01-12 18:13:13 +00:00
commit 0b8ee70084
39 changed files with 64 additions and 64 deletions

View file

@ -5,6 +5,9 @@
// warn on lints, that are included in `rust-lang/rust`s bootstrap // warn on lints, that are included in `rust-lang/rust`s bootstrap
#![warn(rust_2018_idioms, unused_lifetimes)] #![warn(rust_2018_idioms, unused_lifetimes)]
// The `rustc_driver` crate seems to be required in order to use the `rust_lexer` crate.
#[allow(unused_extern_crates)]
extern crate rustc_driver;
extern crate rustc_lexer; extern crate rustc_lexer;
use std::path::PathBuf; use std::path::PathBuf;

View file

@ -68,7 +68,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, msrv: &Msrv
fn is_child_of_cast(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { fn is_child_of_cast(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
let map = cx.tcx.hir(); let map = cx.tcx.hir();
if_chain! { if_chain! {
if let Some(parent_id) = map.find_parent_node(expr.hir_id); if let Some(parent_id) = map.opt_parent_id(expr.hir_id);
if let Some(parent) = map.find(parent_id); if let Some(parent) = map.find(parent_id);
then { then {
let expr = match parent { let expr = match parent {

View file

@ -969,14 +969,14 @@ fn binding_ty_auto_deref_stability<'tcx>(
precedence: i8, precedence: i8,
binder_args: &'tcx List<BoundVariableKind>, binder_args: &'tcx List<BoundVariableKind>,
) -> Position { ) -> Position {
let TyKind::Rptr(_, ty) = &ty.kind else { let TyKind::Ref(_, ty) = &ty.kind else {
return Position::Other(precedence); return Position::Other(precedence);
}; };
let mut ty = ty; let mut ty = ty;
loop { loop {
break match ty.ty.kind { break match ty.ty.kind {
TyKind::Rptr(_, ref ref_ty) => { TyKind::Ref(_, ref ref_ty) => {
ty = ref_ty; ty = ref_ty;
continue; continue;
}, },

View file

@ -131,7 +131,7 @@ fn is_argument(map: rustc_middle::hir::map::Map<'_>, id: HirId) -> bool {
_ => return false, _ => return false,
} }
matches!(map.find(map.get_parent_node(id)), Some(Node::Param(_))) matches!(map.find_parent(id), Some(Node::Param(_)))
} }
impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> { impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
@ -156,8 +156,8 @@ impl<'a, 'tcx> Delegate<'tcx> for EscapeDelegate<'a, 'tcx> {
let map = &self.cx.tcx.hir(); let map = &self.cx.tcx.hir();
if is_argument(*map, cmt.hir_id) { if is_argument(*map, cmt.hir_id) {
// Skip closure arguments // Skip closure arguments
let parent_id = map.get_parent_node(cmt.hir_id); let parent_id = map.parent_id(cmt.hir_id);
if let Some(Node::Expr(..)) = map.find(map.get_parent_node(parent_id)) { if let Some(Node::Expr(..)) = map.find_parent(parent_id) {
return; return;
} }

View file

@ -251,7 +251,7 @@ impl<'a, 'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'a, 'tcx> {
let map = cx.tcx.hir(); let map = cx.tcx.hir();
// Checking for slice indexing // Checking for slice indexing
let parent_id = map.get_parent_node(expr.hir_id); let parent_id = map.parent_id(expr.hir_id);
if let Some(hir::Node::Expr(parent_expr)) = map.find(parent_id); if let Some(hir::Node::Expr(parent_expr)) = map.find(parent_id);
if let hir::ExprKind::Index(_, index_expr) = parent_expr.kind; if let hir::ExprKind::Index(_, index_expr) = parent_expr.kind;
if let Some((Constant::Int(index_value), _)) = constant(cx, cx.typeck_results(), index_expr); if let Some((Constant::Int(index_value), _)) = constant(cx, cx.typeck_results(), index_expr);
@ -259,7 +259,7 @@ impl<'a, 'tcx> Visitor<'tcx> for SliceIndexLintingVisitor<'a, 'tcx> {
if index_value < max_suggested_slice; if index_value < max_suggested_slice;
// Make sure that this slice index is read only // Make sure that this slice index is read only
let maybe_addrof_id = map.get_parent_node(parent_id); let maybe_addrof_id = map.parent_id(parent_id);
if let Some(hir::Node::Expr(maybe_addrof_expr)) = map.find(maybe_addrof_id); if let Some(hir::Node::Expr(maybe_addrof_expr)) = map.find(maybe_addrof_id);
if let hir::ExprKind::AddrOf(_kind, hir::Mutability::Not, _inner_expr) = maybe_addrof_expr.kind; if let hir::ExprKind::AddrOf(_kind, hir::Mutability::Not, _inner_expr) = maybe_addrof_expr.kind;
then { then {

View file

@ -63,7 +63,7 @@ pub(super) fn check<'tcx>(
if let Node::Pat(pat) = node; if let Node::Pat(pat) = node;
if let PatKind::Binding(bind_ann, ..) = pat.kind; if let PatKind::Binding(bind_ann, ..) = pat.kind;
if !matches!(bind_ann, BindingAnnotation(_, Mutability::Mut)); if !matches!(bind_ann, BindingAnnotation(_, Mutability::Mut));
let parent_node = cx.tcx.hir().get_parent_node(hir_id); let parent_node = cx.tcx.hir().parent_id(hir_id);
if let Some(Node::Local(parent_let_expr)) = cx.tcx.hir().find(parent_node); if let Some(Node::Local(parent_let_expr)) = cx.tcx.hir().find(parent_node);
if let Some(init) = parent_let_expr.init; if let Some(init) = parent_let_expr.init;
then { then {

View file

@ -152,7 +152,7 @@ fn captures_all_lifetimes(inputs: &[Ty<'_>], output_lifetimes: &[LifetimeName])
let input_lifetimes: Vec<LifetimeName> = inputs let input_lifetimes: Vec<LifetimeName> = inputs
.iter() .iter()
.filter_map(|ty| { .filter_map(|ty| {
if let TyKind::Rptr(lt, _) = ty.kind { if let TyKind::Ref(lt, _) = ty.kind {
Some(lt.res) Some(lt.res)
} else { } else {
None None

View file

@ -74,7 +74,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualRemEuclid {
&& let Some(hir_id) = path_to_local(expr3) && let Some(hir_id) = path_to_local(expr3)
&& let Some(Node::Pat(_)) = cx.tcx.hir().find(hir_id) { && let Some(Node::Pat(_)) = cx.tcx.hir().find(hir_id) {
// Apply only to params or locals with annotated types // Apply only to params or locals with annotated types
match cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) { match cx.tcx.hir().find_parent(hir_id) {
Some(Node::Param(..)) => (), Some(Node::Param(..)) => (),
Some(Node::Local(local)) => { Some(Node::Local(local)) => {
let Some(ty) = local.ty else { return }; let Some(ty) = local.ty else { return };

View file

@ -140,8 +140,8 @@ pub(crate) fn check<'a>(cx: &LateContext<'a>, ex: &Expr<'a>, arms: &[Arm<'_>], e
fn opt_parent_assign_span<'a>(cx: &LateContext<'a>, ex: &Expr<'a>) -> Option<AssignmentExpr> { fn opt_parent_assign_span<'a>(cx: &LateContext<'a>, ex: &Expr<'a>) -> Option<AssignmentExpr> {
let map = &cx.tcx.hir(); let map = &cx.tcx.hir();
if let Some(Node::Expr(parent_arm_expr)) = map.find(map.get_parent_node(ex.hir_id)) { if let Some(Node::Expr(parent_arm_expr)) = map.find_parent(ex.hir_id) {
return match map.find(map.get_parent_node(parent_arm_expr.hir_id)) { return match map.find_parent(parent_arm_expr.hir_id) {
Some(Node::Local(parent_let_expr)) => Some(AssignmentExpr::Local { Some(Node::Local(parent_let_expr)) => Some(AssignmentExpr::Local {
span: parent_let_expr.span, span: parent_let_expr.span,
pat_span: parent_let_expr.pat.span(), pat_span: parent_let_expr.pat.span(),
@ -183,8 +183,7 @@ fn sugg_with_curlies<'a>(
// If the parent is already an arm, and the body is another match statement, // If the parent is already an arm, and the body is another match statement,
// we need curly braces around suggestion // we need curly braces around suggestion
let parent_node_id = cx.tcx.hir().get_parent_node(match_expr.hir_id); if let Node::Arm(arm) = &cx.tcx.hir().get_parent(match_expr.hir_id) {
if let Node::Arm(arm) = &cx.tcx.hir().get(parent_node_id) {
if let ExprKind::Match(..) = arm.body.kind { if let ExprKind::Match(..) = arm.body.kind {
cbrace_end = format!("\n{indent}}}"); cbrace_end = format!("\n{indent}}}");
// Fix body indent due to the match // Fix body indent due to the match

View file

@ -3986,7 +3986,7 @@ impl OutType {
(Self::Unit, &hir::FnRetTy::Return(ty)) if is_unit(ty) => true, (Self::Unit, &hir::FnRetTy::Return(ty)) if is_unit(ty) => true,
(Self::Bool, &hir::FnRetTy::Return(ty)) if is_bool(ty) => true, (Self::Bool, &hir::FnRetTy::Return(ty)) if is_bool(ty) => true,
(Self::Any, &hir::FnRetTy::Return(ty)) if !is_unit(ty) => true, (Self::Any, &hir::FnRetTy::Return(ty)) if !is_unit(ty) => true,
(Self::Ref, &hir::FnRetTy::Return(ty)) => matches!(ty.kind, hir::TyKind::Rptr(_, _)), (Self::Ref, &hir::FnRetTy::Return(ty)) => matches!(ty.kind, hir::TyKind::Ref(_, _)),
_ => false, _ => false,
} }
} }

View file

@ -186,7 +186,7 @@ fn check_for_unsequenced_reads(vis: &mut ReadVisitor<'_, '_>) {
let map = &vis.cx.tcx.hir(); let map = &vis.cx.tcx.hir();
let mut cur_id = vis.write_expr.hir_id; let mut cur_id = vis.write_expr.hir_id;
loop { loop {
let parent_id = map.get_parent_node(cur_id); let parent_id = map.parent_id(cur_id);
if parent_id == cur_id { if parent_id == cur_id {
break; break;
} }

View file

@ -86,7 +86,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> {
return; return;
} }
if let hir::TyKind::Rptr( if let hir::TyKind::Ref(
_, _,
hir::MutTy { hir::MutTy {
ty: pty, ty: pty,
@ -94,7 +94,7 @@ impl<'a, 'tcx> intravisit::Visitor<'tcx> for MutVisitor<'a, 'tcx> {
}, },
) = ty.kind ) = ty.kind
{ {
if let hir::TyKind::Rptr( if let hir::TyKind::Ref(
_, _,
hir::MutTy { hir::MutTy {
mutbl: hir::Mutability::Mut, mutbl: hir::Mutability::Mut,

View file

@ -124,7 +124,7 @@ impl EarlyLintPass for NeedlessArbitrarySelfType {
check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Value, mutbl); check_param_inner(cx, path, p.span.to(p.ty.span), &Mode::Value, mutbl);
} }
}, },
TyKind::Rptr(lifetime, mut_ty) => { TyKind::Ref(lifetime, mut_ty) => {
if_chain! { if_chain! {
if let TyKind::Path(None, path) = &mut_ty.ty.kind; if let TyKind::Path(None, path) = &mut_ty.ty.kind;
if let PatKind::Ident(BindingAnnotation::NONE, _, _) = p.pat.kind; if let PatKind::Ident(BindingAnnotation::NONE, _, _) = p.pat.kind;

View file

@ -100,7 +100,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue {
} }
// Exclude non-inherent impls // Exclude non-inherent impls
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) { if let Some(Node::Item(item)) = cx.tcx.hir().find_parent(hir_id) {
if matches!( if matches!(
item.kind, item.kind,
ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..) ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..)

View file

@ -366,7 +366,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst {
let mut dereferenced_expr = expr; let mut dereferenced_expr = expr;
let mut needs_check_adjustment = true; let mut needs_check_adjustment = true;
loop { loop {
let parent_id = cx.tcx.hir().get_parent_node(cur_expr.hir_id); let parent_id = cx.tcx.hir().parent_id(cur_expr.hir_id);
if parent_id == cur_expr.hir_id { if parent_id == cur_expr.hir_id {
break; break;
} }

View file

@ -184,7 +184,7 @@ impl<'tcx> PassByRefOrValue {
if is_copy(cx, ty) if is_copy(cx, ty)
&& let Some(size) = cx.layout_of(ty).ok().map(|l| l.size.bytes()) && let Some(size) = cx.layout_of(ty).ok().map(|l| l.size.bytes())
&& size <= self.ref_min_size && size <= self.ref_min_size
&& let hir::TyKind::Rptr(_, MutTy { ty: decl_ty, .. }) = input.kind && let hir::TyKind::Ref(_, MutTy { ty: decl_ty, .. }) = input.kind
{ {
if let Some(typeck) = cx.maybe_typeck_results() { if let Some(typeck) = cx.maybe_typeck_results() {
// Don't lint if an unsafe pointer is created. // Don't lint if an unsafe pointer is created.
@ -299,7 +299,7 @@ impl<'tcx> LateLintPass<'tcx> for PassByRefOrValue {
} }
// Exclude non-inherent impls // Exclude non-inherent impls
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) { if let Some(Node::Item(item)) = cx.tcx.hir().find_parent(hir_id) {
if matches!( if matches!(
item.kind, item.kind,
ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..) ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..)

View file

@ -421,7 +421,7 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
if let ty::Ref(_, ty, mutability) = *ty.kind(); if let ty::Ref(_, ty, mutability) = *ty.kind();
if let ty::Adt(adt, substs) = *ty.kind(); if let ty::Adt(adt, substs) = *ty.kind();
if let TyKind::Rptr(lt, ref ty) = hir_ty.kind; if let TyKind::Ref(lt, ref ty) = hir_ty.kind;
if let TyKind::Path(QPath::Resolved(None, path)) = ty.ty.kind; if let TyKind::Path(QPath::Resolved(None, path)) = ty.ty.kind;
// Check that the name as typed matches the actual name of the type. // Check that the name as typed matches the actual name of the type.
@ -503,14 +503,14 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
fn check_mut_from_ref<'tcx>(cx: &LateContext<'tcx>, sig: &FnSig<'_>, body: Option<&'tcx Body<'_>>) { fn check_mut_from_ref<'tcx>(cx: &LateContext<'tcx>, sig: &FnSig<'_>, body: Option<&'tcx Body<'_>>) {
if let FnRetTy::Return(ty) = sig.decl.output if let FnRetTy::Return(ty) = sig.decl.output
&& let Some((out, Mutability::Mut, _)) = get_rptr_lm(ty) && let Some((out, Mutability::Mut, _)) = get_ref_lm(ty)
{ {
let out_region = cx.tcx.named_region(out.hir_id); let out_region = cx.tcx.named_region(out.hir_id);
let args: Option<Vec<_>> = sig let args: Option<Vec<_>> = sig
.decl .decl
.inputs .inputs
.iter() .iter()
.filter_map(get_rptr_lm) .filter_map(get_ref_lm)
.filter(|&(lt, _, _)| cx.tcx.named_region(lt.hir_id) == out_region) .filter(|&(lt, _, _)| cx.tcx.named_region(lt.hir_id) == out_region)
.map(|(_, mutability, span)| (mutability == Mutability::Not).then_some(span)) .map(|(_, mutability, span)| (mutability == Mutability::Not).then_some(span))
.collect(); .collect();
@ -704,8 +704,8 @@ fn matches_preds<'tcx>(
}) })
} }
fn get_rptr_lm<'tcx>(ty: &'tcx hir::Ty<'tcx>) -> Option<(&'tcx Lifetime, Mutability, Span)> { fn get_ref_lm<'tcx>(ty: &'tcx hir::Ty<'tcx>) -> Option<(&'tcx Lifetime, Mutability, Span)> {
if let TyKind::Rptr(lt, ref m) = ty.kind { if let TyKind::Ref(lt, ref m) = ty.kind {
Some((lt, m.mutbl, ty.span)) Some((lt, m.mutbl, ty.span))
} else { } else {
None None

View file

@ -59,7 +59,7 @@ impl RedundantStaticLifetimes {
} }
}, },
// This is what we are looking for ! // This is what we are looking for !
TyKind::Rptr(ref optional_lifetime, ref borrow_type) => { TyKind::Ref(ref optional_lifetime, ref borrow_type) => {
// Match the 'static lifetime // Match the 'static lifetime
if let Some(lifetime) = *optional_lifetime { if let Some(lifetime) = *optional_lifetime {
match borrow_type.ty.kind { match borrow_type.ty.kind {

View file

@ -39,7 +39,7 @@ declare_lint_pass!(RefOptionRef => [REF_OPTION_REF]);
impl<'tcx> LateLintPass<'tcx> for RefOptionRef { impl<'tcx> LateLintPass<'tcx> for RefOptionRef {
fn check_ty(&mut self, cx: &LateContext<'tcx>, ty: &'tcx Ty<'tcx>) { fn check_ty(&mut self, cx: &LateContext<'tcx>, ty: &'tcx Ty<'tcx>) {
if_chain! { if_chain! {
if let TyKind::Rptr(_, ref mut_ty) = ty.kind; if let TyKind::Ref(_, ref mut_ty) = ty.kind;
if mut_ty.mutbl == Mutability::Not; if mut_ty.mutbl == Mutability::Not;
if let TyKind::Path(ref qpath) = &mut_ty.ty.kind; if let TyKind::Path(ref qpath) = &mut_ty.ty.kind;
let last = last_path_segment(qpath); let last = last_path_segment(qpath);
@ -52,7 +52,7 @@ impl<'tcx> LateLintPass<'tcx> for RefOptionRef {
GenericArg::Type(inner_ty) => Some(inner_ty), GenericArg::Type(inner_ty) => Some(inner_ty),
_ => None, _ => None,
}); });
if let TyKind::Rptr(_, ref inner_mut_ty) = inner_ty.kind; if let TyKind::Ref(_, ref inner_mut_ty) = inner_ty.kind;
if inner_mut_ty.mutbl == Mutability::Not; if inner_mut_ty.mutbl == Mutability::Not;
then { then {

View file

@ -71,7 +71,7 @@ pub(super) fn check<'tcx>(
/// Gets the type `Bar` in `…::transmute<Foo, &Bar>`. /// Gets the type `Bar` in `…::transmute<Foo, &Bar>`.
fn get_explicit_type<'tcx>(path: &'tcx Path<'tcx>) -> Option<&'tcx hir::Ty<'tcx>> { fn get_explicit_type<'tcx>(path: &'tcx Path<'tcx>) -> Option<&'tcx hir::Ty<'tcx>> {
if let GenericArg::Type(ty) = path.segments.last()?.args?.args.get(1)? if let GenericArg::Type(ty) = path.segments.last()?.args?.args.get(1)?
&& let TyKind::Rptr(_, ty) = &ty.kind && let TyKind::Ref(_, ty) = &ty.kind
{ {
Some(ty.ty) Some(ty.ty)
} else { } else {

View file

@ -539,7 +539,7 @@ impl Types {
QPath::LangItem(..) => {}, QPath::LangItem(..) => {},
} }
}, },
TyKind::Rptr(lt, ref mut_ty) => { TyKind::Ref(lt, ref mut_ty) => {
context.is_nested_call = true; context.is_nested_call = true;
if !borrowed_box::check(cx, hir_ty, lt, mut_ty) { if !borrowed_box::check(cx, hir_ty, lt, mut_ty) {
self.check_ty(cx, mut_ty.ty, context); self.check_ty(cx, mut_ty.ty, context);

View file

@ -44,7 +44,7 @@ impl<'tcx> Visitor<'tcx> for TypeComplexityVisitor {
fn visit_ty(&mut self, ty: &'tcx hir::Ty<'_>) { fn visit_ty(&mut self, ty: &'tcx hir::Ty<'_>) {
let (add_score, sub_nest) = match ty.kind { let (add_score, sub_nest) = match ty.kind {
// _, &x and *x have only small overhead; don't mess with nesting level // _, &x and *x have only small overhead; don't mess with nesting level
TyKind::Infer | TyKind::Ptr(..) | TyKind::Rptr(..) => (1, 0), TyKind::Infer | TyKind::Ptr(..) | TyKind::Ref(..) => (1, 0),
// the "normal" components of a type: named types, arrays/tuples // the "normal" components of a type: named types, arrays/tuples
TyKind::Path(..) | TyKind::Slice(..) | TyKind::Tup(..) | TyKind::Array(..) => (10 * self.nest, 1), TyKind::Path(..) | TyKind::Slice(..) | TyKind::Tup(..) | TyKind::Array(..) => (10 * self.nest, 1),

View file

@ -13,7 +13,7 @@ pub(super) fn match_borrows_parameter(_cx: &LateContext<'_>, qpath: &QPath<'_>)
GenericArg::Type(ty) => Some(ty), GenericArg::Type(ty) => Some(ty),
_ => None, _ => None,
}); });
if let TyKind::Rptr(..) = ty.kind; if let TyKind::Ref(..) = ty.kind;
then { then {
return Some(ty.span); return Some(ty.span);
} }

View file

@ -21,7 +21,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
return; return;
} }
let map = &cx.tcx.hir(); let map = &cx.tcx.hir();
let opt_parent_node = map.find(map.get_parent_node(expr.hir_id)); let opt_parent_node = map.find_parent(expr.hir_id);
if_chain! { if_chain! {
if let Some(hir::Node::Expr(parent_expr)) = opt_parent_node; if let Some(hir::Node::Expr(parent_expr)) = opt_parent_node;
if is_questionmark_desugar_marked_call(parent_expr); if is_questionmark_desugar_marked_call(parent_expr);
@ -192,7 +192,7 @@ fn fmt_stmts_and_call(
let mut stmts_and_call_snippet = stmts_and_call.join(&format!("{}{}", ";\n", " ".repeat(call_expr_indent))); let mut stmts_and_call_snippet = stmts_and_call.join(&format!("{}{}", ";\n", " ".repeat(call_expr_indent)));
// expr is not in a block statement or result expression position, wrap in a block // expr is not in a block statement or result expression position, wrap in a block
let parent_node = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(call_expr.hir_id)); let parent_node = cx.tcx.hir().find_parent(call_expr.hir_id);
if !matches!(parent_node, Some(Node::Block(_))) && !matches!(parent_node, Some(Node::Stmt(_))) { if !matches!(parent_node, Some(Node::Block(_))) && !matches!(parent_node, Some(Node::Stmt(_))) {
let block_indent = call_expr_indent + 4; let block_indent = call_expr_indent + 4;
stmts_and_call_snippet = stmts_and_call_snippet =

View file

@ -91,7 +91,7 @@ impl<'tcx> LateLintPass<'tcx> for UnnecessaryWraps {
} }
// Abort if the method is implementing a trait or of it a trait method. // Abort if the method is implementing a trait or of it a trait method.
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) { if let Some(Node::Item(item)) = cx.tcx.hir().find_parent(hir_id) {
if matches!( if matches!(
item.kind, item.kind,
ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..) ItemKind::Impl(Impl { of_trait: Some(_), .. }) | ItemKind::Trait(..)

View file

@ -257,7 +257,7 @@ impl<'tcx> LateLintPass<'tcx> for LintWithoutLintPass {
} }
pub(super) fn is_lint_ref_type(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> bool { pub(super) fn is_lint_ref_type(cx: &LateContext<'_>, ty: &hir::Ty<'_>) -> bool {
if let TyKind::Rptr( if let TyKind::Ref(
_, _,
MutTy { MutTy {
ty: inner, ty: inner,

View file

@ -1058,7 +1058,7 @@ fn get_parent_local<'hir>(cx: &LateContext<'hir>, expr: &'hir hir::Expr<'hir>) -
fn get_parent_local_hir_id<'hir>(cx: &LateContext<'hir>, hir_id: hir::HirId) -> Option<&'hir hir::Local<'hir>> { fn get_parent_local_hir_id<'hir>(cx: &LateContext<'hir>, hir_id: hir::HirId) -> Option<&'hir hir::Local<'hir>> {
let map = cx.tcx.hir(); let map = cx.tcx.hir();
match map.find(map.get_parent_node(hir_id)) { match map.find_parent(hir_id) {
Some(hir::Node::Local(local)) => Some(local), Some(hir::Node::Local(local)) => Some(local),
Some(hir::Node::Pat(pattern)) => get_parent_local_hir_id(cx, pattern.hir_id), Some(hir::Node::Pat(pattern)) => get_parent_local_hir_id(cx, pattern.hir_id),
_ => None, _ => None,

View file

@ -219,7 +219,7 @@ fn path_to_matched_type(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> Option<Ve
match peel_hir_expr_refs(expr).0.kind { match peel_hir_expr_refs(expr).0.kind {
ExprKind::Path(ref qpath) => match cx.qpath_res(qpath, expr.hir_id) { ExprKind::Path(ref qpath) => match cx.qpath_res(qpath, expr.hir_id) {
Res::Local(hir_id) => { Res::Local(hir_id) => {
let parent_id = cx.tcx.hir().get_parent_node(hir_id); let parent_id = cx.tcx.hir().parent_id(hir_id);
if let Some(Node::Local(Local { init: Some(init), .. })) = cx.tcx.hir().find(parent_id) { if let Some(Node::Local(Local { init: Some(init), .. })) = cx.tcx.hir().find(parent_id) {
path_to_matched_type(cx, init) path_to_matched_type(cx, init)
} else { } else {

View file

@ -625,7 +625,7 @@ pub fn eq_ty(l: &Ty, r: &Ty) -> bool {
(Slice(l), Slice(r)) => eq_ty(l, r), (Slice(l), Slice(r)) => eq_ty(l, r),
(Array(le, ls), Array(re, rs)) => eq_ty(le, re) && eq_expr(&ls.value, &rs.value), (Array(le, ls), Array(re, rs)) => eq_ty(le, re) && eq_expr(&ls.value, &rs.value),
(Ptr(l), Ptr(r)) => l.mutbl == r.mutbl && eq_ty(&l.ty, &r.ty), (Ptr(l), Ptr(r)) => l.mutbl == r.mutbl && eq_ty(&l.ty, &r.ty),
(Rptr(ll, l), Rptr(rl, r)) => { (Ref(ll, l), Ref(rl, r)) => {
both(ll, rl, |l, r| eq_id(l.ident, r.ident)) && l.mutbl == r.mutbl && eq_ty(&l.ty, &r.ty) both(ll, rl, |l, r| eq_id(l.ident, r.ident)) && l.mutbl == r.mutbl && eq_ty(&l.ty, &r.ty)
}, },
(BareFn(l), BareFn(r)) => { (BareFn(l), BareFn(r)) => {

View file

@ -430,7 +430,7 @@ impl HirEqInterExpr<'_, '_, '_> {
(&TyKind::Slice(l_vec), &TyKind::Slice(r_vec)) => self.eq_ty(l_vec, r_vec), (&TyKind::Slice(l_vec), &TyKind::Slice(r_vec)) => self.eq_ty(l_vec, r_vec),
(&TyKind::Array(lt, ll), &TyKind::Array(rt, rl)) => self.eq_ty(lt, rt) && self.eq_array_length(ll, rl), (&TyKind::Array(lt, ll), &TyKind::Array(rt, rl)) => self.eq_ty(lt, rt) && self.eq_array_length(ll, rl),
(TyKind::Ptr(l_mut), TyKind::Ptr(r_mut)) => l_mut.mutbl == r_mut.mutbl && self.eq_ty(l_mut.ty, r_mut.ty), (TyKind::Ptr(l_mut), TyKind::Ptr(r_mut)) => l_mut.mutbl == r_mut.mutbl && self.eq_ty(l_mut.ty, r_mut.ty),
(TyKind::Rptr(_, l_rmut), TyKind::Rptr(_, r_rmut)) => { (TyKind::Ref(_, l_rmut), TyKind::Ref(_, r_rmut)) => {
l_rmut.mutbl == r_rmut.mutbl && self.eq_ty(l_rmut.ty, r_rmut.ty) l_rmut.mutbl == r_rmut.mutbl && self.eq_ty(l_rmut.ty, r_rmut.ty)
}, },
(TyKind::Path(l), TyKind::Path(r)) => self.eq_qpath(l, r), (TyKind::Path(l), TyKind::Path(r)) => self.eq_qpath(l, r),
@ -950,7 +950,7 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
self.hash_ty(mut_ty.ty); self.hash_ty(mut_ty.ty);
mut_ty.mutbl.hash(&mut self.s); mut_ty.mutbl.hash(&mut self.s);
}, },
TyKind::Rptr(lifetime, ref mut_ty) => { TyKind::Ref(lifetime, ref mut_ty) => {
self.hash_lifetime(lifetime); self.hash_lifetime(lifetime);
self.hash_ty(mut_ty.ty); self.hash_ty(mut_ty.ty);
mut_ty.mutbl.hash(&mut self.s); mut_ty.mutbl.hash(&mut self.s);

View file

@ -22,6 +22,9 @@ extern crate rustc_ast;
extern crate rustc_ast_pretty; extern crate rustc_ast_pretty;
extern crate rustc_attr; extern crate rustc_attr;
extern crate rustc_data_structures; extern crate rustc_data_structures;
// The `rustc_driver` crate seems to be required in order to use the `rust_ast` crate.
#[allow(unused_extern_crates)]
extern crate rustc_driver;
extern crate rustc_errors; extern crate rustc_errors;
extern crate rustc_hir; extern crate rustc_hir;
extern crate rustc_hir_typeck; extern crate rustc_hir_typeck;
@ -176,7 +179,7 @@ pub fn find_binding_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<
if_chain! { if_chain! {
if let Some(Node::Pat(pat)) = hir.find(hir_id); if let Some(Node::Pat(pat)) = hir.find(hir_id);
if matches!(pat.kind, PatKind::Binding(BindingAnnotation::NONE, ..)); if matches!(pat.kind, PatKind::Binding(BindingAnnotation::NONE, ..));
let parent = hir.get_parent_node(hir_id); let parent = hir.parent_id(hir_id);
if let Some(Node::Local(local)) = hir.find(parent); if let Some(Node::Local(local)) = hir.find(parent);
then { then {
return local.init; return local.init;
@ -1300,7 +1303,7 @@ pub fn contains_return(expr: &hir::Expr<'_>) -> bool {
/// Gets the parent node, if any. /// Gets the parent node, if any.
pub fn get_parent_node(tcx: TyCtxt<'_>, id: HirId) -> Option<Node<'_>> { pub fn get_parent_node(tcx: TyCtxt<'_>, id: HirId) -> Option<Node<'_>> {
tcx.hir().parent_iter(id).next().map(|(_, node)| node) tcx.hir().find_parent(id)
} }
/// Gets the parent expression, if any - this is useful to constrain a lint. /// Gets the parent expression, if any - this is useful to constrain a lint.
@ -2089,7 +2092,7 @@ pub fn is_no_core_crate(cx: &LateContext<'_>) -> bool {
/// } /// }
/// ``` /// ```
pub fn is_trait_impl_item(cx: &LateContext<'_>, hir_id: HirId) -> bool { pub fn is_trait_impl_item(cx: &LateContext<'_>, hir_id: HirId) -> bool {
if let Some(Node::Item(item)) = cx.tcx.hir().find(cx.tcx.hir().get_parent_node(hir_id)) { if let Some(Node::Item(item)) = cx.tcx.hir().find_parent(hir_id) {
matches!(item.kind, ItemKind::Impl(hir::Impl { of_trait: Some(_), .. })) matches!(item.kind, ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }))
} else { } else {
false false
@ -2290,7 +2293,7 @@ pub fn peel_hir_ty_refs<'a>(mut ty: &'a hir::Ty<'a>) -> (&'a hir::Ty<'a>, usize)
let mut count = 0; let mut count = 0;
loop { loop {
match &ty.kind { match &ty.kind {
TyKind::Rptr(_, ref_ty) => { TyKind::Ref(_, ref_ty) => {
ty = ref_ty.ty; ty = ref_ty.ty;
count += 1; count += 1;
}, },

View file

@ -812,9 +812,9 @@ pub fn deref_closure_args(cx: &LateContext<'_>, closure: &hir::Expr<'_>) -> Opti
let closure_body = cx.tcx.hir().body(body); let closure_body = cx.tcx.hir().body(body);
// is closure arg a type annotated double reference (i.e.: `|x: &&i32| ...`) // is closure arg a type annotated double reference (i.e.: `|x: &&i32| ...`)
// a type annotation is present if param `kind` is different from `TyKind::Infer` // a type annotation is present if param `kind` is different from `TyKind::Infer`
let closure_arg_is_type_annotated_double_ref = if let TyKind::Rptr(_, MutTy { ty, .. }) = fn_decl.inputs[0].kind let closure_arg_is_type_annotated_double_ref = if let TyKind::Ref(_, MutTy { ty, .. }) = fn_decl.inputs[0].kind
{ {
matches!(ty.kind, TyKind::Rptr(_, MutTy { .. })) matches!(ty.kind, TyKind::Ref(_, MutTy { .. }))
} else { } else {
false false
}; };

View file

@ -496,7 +496,7 @@ pub fn type_is_unsafe_function<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bo
/// Returns the base type for HIR references and pointers. /// Returns the base type for HIR references and pointers.
pub fn walk_ptrs_hir_ty<'tcx>(ty: &'tcx hir::Ty<'tcx>) -> &'tcx hir::Ty<'tcx> { pub fn walk_ptrs_hir_ty<'tcx>(ty: &'tcx hir::Ty<'tcx>) -> &'tcx hir::Ty<'tcx> {
match ty.kind { match ty.kind {
TyKind::Ptr(ref mut_ty) | TyKind::Rptr(_, ref mut_ty) => walk_ptrs_hir_ty(mut_ty.ty), TyKind::Ptr(ref mut_ty) | TyKind::Ref(_, ref mut_ty) => walk_ptrs_hir_ty(mut_ty.ty),
_ => ty, _ => ty,
} }
} }

View file

@ -1,3 +1,3 @@
[toolchain] [toolchain]
channel = "nightly-2022-12-29" channel = "nightly-2023-01-12"
components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"] components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"]

View file

@ -3,8 +3,7 @@ error: an async construct yields a type which is itself awaitable
| |
LL | let _h = async { LL | let _h = async {
| _____________________- | _____________________-
LL | | async { LL | |/ async {
| | _________^
LL | || 3 LL | || 3
LL | || } LL | || }
| ||_________^ awaitable value not awaited | ||_________^ awaitable value not awaited
@ -37,8 +36,7 @@ error: an async construct yields a type which is itself awaitable
| |
LL | let _j = async || { LL | let _j = async || {
| ________________________- | ________________________-
LL | | async { LL | |/ async {
| | _________^
LL | || 3 LL | || 3
LL | || } LL | || }
| ||_________^ awaitable value not awaited | ||_________^ awaitable value not awaited

View file

@ -1,4 +1,4 @@
// originally from ./src/test/ui/pattern/usefulness/consts-opaque.rs // originally from ./tests/ui/pattern/usefulness/consts-opaque.rs
// panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())', // panicked at 'assertion failed: rows.iter().all(|r| r.len() == v.len())',
// compiler/rustc_mir_build/src/thir/pattern/_match.rs:2030:5 // compiler/rustc_mir_build/src/thir/pattern/_match.rs:2030:5

View file

@ -1,4 +1,4 @@
// originally from rustc ./src/test/ui/macros/issue-78325-inconsistent-resolution.rs // originally from rustc ./tests/ui/macros/issue-78325-inconsistent-resolution.rs
// inconsistent resolution for a macro // inconsistent resolution for a macro
macro_rules! define_other_core { macro_rules! define_other_core {

View file

@ -1,4 +1,4 @@
// originally from rustc ./src/test/ui/regions/issue-78262.rs // originally from rustc ./tests/ui/regions/issue-78262.rs
// ICE: to get the signature of a closure, use substs.as_closure().sig() not fn_sig() // ICE: to get the signature of a closure, use substs.as_closure().sig() not fn_sig()
#![allow(clippy::upper_case_acronyms)] #![allow(clippy::upper_case_acronyms)]

View file

@ -19,10 +19,7 @@ LL | x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value)
error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()` error: called `map(f)` on an `Result` value where `f` is a closure that returns the unit type `()`
--> $DIR/result_map_unit_fn_unfixable.rs:29:5 --> $DIR/result_map_unit_fn_unfixable.rs:29:5
| |
LL | x.field.map(|value| { LL | // x.field.map(|value| {
| ______^
| | _____|
| ||
LL | || do_nothing(value); LL | || do_nothing(value);
LL | || do_nothing(value) LL | || do_nothing(value)
LL | || }); LL | || });