Skip to content

Rustup #10010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 40 commits into from
Dec 1, 2022
Merged

Rustup #10010

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a091438
drive-by: PolyExistentialPredicate
compiler-errors Nov 19, 2022
3597ed5
Rollup merge of #104595 - compiler-errors:poly-existential-predicate,…
matthiaskrgr Nov 21, 2022
386d0a5
Add an always-ambiguous predicate to make sure that we don't accident…
oli-obk Nov 2, 2022
ae8f75c
Unreserve braced enum variants in value namespace
petrochenkov Oct 25, 2022
46c5a5d
Merge commit 'f4850f7292efa33759b4f7f9b7621268979e9914' into clippyup
flip1995 Nov 21, 2022
28fb084
Fix declare_clippy_lint crate
flip1995 Nov 21, 2022
6fce469
Clippy: Don't import GenericParamDefKind
flip1995 Nov 21, 2022
c782822
Allow iterators instead of requiring slices that will get turned into…
oli-obk Nov 17, 2022
f60e43e
Fix clippy's missing substs
oli-obk Nov 18, 2022
595ae83
Stop passing the self-type as a separate argument.
oli-obk Nov 21, 2022
eb850ae
Use `as_closure` helper method
oli-obk Nov 21, 2022
48b10fe
Split `MacArgs` in two.
nnethercote Nov 18, 2022
e6c33e0
Auto merge of #104696 - matthiaskrgr:rollup-gi1pdb0, r=matthiaskrgr
bors Nov 22, 2022
9e09307
Auto merge of #103578 - petrochenkov:nofict, r=nagisa
bors Nov 22, 2022
e95d409
Clippy: Workaround for let_chains issue
flip1995 Nov 22, 2022
b33afd6
Auto merge of #104688 - flip1995:clippyup, r=Manishearth,flip1995
bors Nov 22, 2022
91d2ce3
Rollup merge of #103488 - oli-obk:impl_trait_for_tait, r=lcnr
Manishearth Nov 23, 2022
284ce9e
Move `get_associated_type` from `clippy` to `rustc_lint`
WaffleLapkin Nov 22, 2022
93cfced
Separate lifetime ident from resolution in HIR.
cjgillot Nov 5, 2022
2a530dc
Fix clippy code
estebank Nov 3, 2022
ac6a77e
Rollup merge of #104742 - WaffleLapkin:forbidden-SUPER-deref, r=compi…
matthiaskrgr Nov 24, 2022
1ebdcca
Avoid `GenFuture` shim when compiling async constructs
Swatinem Nov 18, 2022
0aaea40
move some layout logic to rustc_target::abi::layout
HKalbasi Nov 1, 2022
300d10f
Auto merge of #104321 - Swatinem:async-gen, r=oli-obk
bors Nov 24, 2022
42db5e5
Use kw::Empty for elided lifetimes in path.
cjgillot Nov 6, 2022
2ad5e48
Auto merge of #103693 - HKalbasi:master, r=oli-obk
bors Nov 24, 2022
53f78ae
Simplify a bunch of trait ref obligation creations
oli-obk Nov 18, 2022
3f059a4
Introduce PredicateKind::Clause
spastorino Nov 24, 2022
424ae23
RefCell::get_mut: fix typo
RalfJung Nov 25, 2022
268d230
Rollup merge of #104873 - RalfJung:therefore, r=Dylan-DPC
matthiaskrgr Nov 25, 2022
8b2f7e3
Auto merge of #104846 - spastorino:santa-clauses-make-goals-early-chr…
bors Nov 25, 2022
696ea06
Auto merge of #104048 - cjgillot:split-lifetime, r=compiler-errors
bors Nov 27, 2022
5011c67
Rename `ast::Lit` as `ast::MetaItemLit`.
nnethercote Nov 23, 2022
fc108d4
fix clippy tests
estebank Nov 28, 2022
0eaa0d3
Rollup merge of #104804 - nnethercote:MetaItemLit, r=petrochenkov
matthiaskrgr Nov 28, 2022
82c07f0
partially_normalize_... -> At::normalize
compiler-errors Nov 25, 2022
a61e2a9
FnCtxt normalization stuff
compiler-errors Nov 25, 2022
58100c0
Auto merge of #104905 - compiler-errors:normalization-changes, r=spas…
bors Nov 30, 2022
11434f2
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Dec 1, 2022
4063712
Bump nightly version -> 2022-12-01
flip1995 Dec 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clippy_dev/src/setup/git_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::verify_inside_clippy_dir;
/// Rusts setup uses `git rev-parse --git-common-dir` to get the root directory of the repo.
/// I've decided against this for the sake of simplicity and to make sure that it doesn't install
/// the hook if `clippy_dev` would be used in the rust tree. The hook also references this tool
/// for formatting and should therefor only be used in a normal clone of clippy
/// for formatting and should therefore only be used in a normal clone of clippy
const REPO_GIT_DIR: &str = ".git";
const HOOK_SOURCE_FILE: &str = "util/etc/pre-commit.sh";
const HOOK_TARGET_FILE: &str = ".git/hooks/pre-commit";
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use clippy_utils::macros::{is_panic, macro_backtrace};
use clippy_utils::msrvs::{self, Msrv};
use clippy_utils::source::{first_line_of_span, is_present_in_source, snippet_opt, without_block_comments};
use if_chain::if_chain;
use rustc_ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
use rustc_ast::{AttrKind, AttrStyle, Attribute, LitKind, MetaItemKind, MetaItemLit, NestedMetaItem};
use rustc_errors::Applicability;
use rustc_hir::{
Block, Expr, ExprKind, ImplItem, ImplItemKind, Item, ItemKind, StmtKind, TraitFn, TraitItem, TraitItemKind,
Expand Down Expand Up @@ -574,7 +574,7 @@ fn check_attrs(cx: &LateContext<'_>, span: Span, name: Symbol, attrs: &[Attribut
}
}

fn check_semver(cx: &LateContext<'_>, span: Span, lit: &Lit) {
fn check_semver(cx: &LateContext<'_>, span: Span, lit: &MetaItemLit) {
if let LitKind::Str(is, _) = lit.kind {
if Version::parse(is.as_str()).is_ok() {
return;
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/bool_assert_comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn is_impl_not_trait_with_bool_out(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
)
})
.map_or(false, |assoc_item| {
let proj = cx.tcx.mk_projection(assoc_item.def_id, cx.tcx.mk_substs_trait(ty, &[]));
let proj = cx.tcx.mk_projection(assoc_item.def_id, cx.tcx.mk_substs_trait(ty, []));
let nty = cx.tcx.normalize_erasing_regions(cx.param_env, proj);

nty.is_bool()
Expand Down
10 changes: 2 additions & 8 deletions clippy_lints/src/casts/cast_possible_truncation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ use clippy_utils::consts::{constant, Constant};
use clippy_utils::diagnostics::span_lint;
use clippy_utils::expr_or_init;
use clippy_utils::ty::{get_discriminant_value, is_isize_or_usize};
use rustc_ast::ast;
use rustc_attr::IntType;
use rustc_hir::def::{DefKind, Res};
use rustc_hir::{BinOpKind, Expr, ExprKind};
use rustc_lint::LateContext;
use rustc_middle::ty::{self, FloatTy, Ty};
use rustc_target::abi::IntegerType;

use super::{utils, CAST_ENUM_TRUNCATION, CAST_POSSIBLE_TRUNCATION};

Expand Down Expand Up @@ -119,12 +118,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
};
let to_nbits = utils::int_ty_to_nbits(cast_to, cx.tcx);

let cast_from_ptr_size = def.repr().int.map_or(true, |ty| {
matches!(
ty,
IntType::SignedInt(ast::IntTy::Isize) | IntType::UnsignedInt(ast::UintTy::Usize)
)
});
let cast_from_ptr_size = def.repr().int.map_or(true, |ty| matches!(ty, IntegerType::Pointer(_),));
let suffix = match (cast_from_ptr_size, is_isize_or_usize(cast_to)) {
(false, false) if from_nbits > to_nbits => "",
(true, false) if from_nbits > to_nbits => "",
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/crate_in_macro_def.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl EarlyLintPass for CrateInMacroDef {
if_chain! {
if item.attrs.iter().any(is_macro_export);
if let ItemKind::MacroDef(macro_def) = &item.kind;
let tts = macro_def.body.inner_tokens();
let tts = macro_def.body.tokens.clone();
if let Some(span) = contains_unhygienic_crate_reference(&tts);
then {
span_lint_and_sugg(
Expand Down
26 changes: 13 additions & 13 deletions clippy_lints/src/dereference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::mir::{Rvalue, StatementKind};
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability};
use rustc_middle::ty::{
self, Binder, BoundVariableKind, EarlyBinder, FnSig, GenericArgKind, List, ParamTy, PredicateKind,
self, Binder, BoundVariableKind, Clause, EarlyBinder, FnSig, GenericArgKind, List, ParamTy, PredicateKind,
ProjectionPredicate, Ty, TyCtxt, TypeVisitable, TypeckResults,
};
use rustc_session::{declare_tool_lint, impl_lint_pass};
Expand Down Expand Up @@ -855,14 +855,10 @@ fn walk_parents<'tcx>(
} else if let Some(trait_id) = cx.tcx.trait_of_item(id)
&& let arg_ty = cx.tcx.erase_regions(cx.typeck_results().expr_ty_adjusted(e))
&& let ty::Ref(_, sub_ty, _) = *arg_ty.kind()
&& let subs = match cx
&& let subs = cx
.typeck_results()
.node_substs_opt(parent.hir_id)
.and_then(|subs| subs.get(1..))
{
Some(subs) => cx.tcx.mk_substs(subs.iter().copied()),
None => cx.tcx.mk_substs(std::iter::empty::<ty::subst::GenericArg<'_>>()),
} && let impl_ty = if cx.tcx.fn_sig(id).skip_binder().inputs()[0].is_ref() {
.node_substs_opt(parent.hir_id).map(|subs| &subs[1..]).unwrap_or_default()
&& let impl_ty = if cx.tcx.fn_sig(id).skip_binder().inputs()[0].is_ref() {
// Trait methods taking `&self`
sub_ty
} else {
Expand All @@ -871,7 +867,11 @@ fn walk_parents<'tcx>(
} && impl_ty.is_ref()
&& let infcx = cx.tcx.infer_ctxt().build()
&& infcx
.type_implements_trait(trait_id, impl_ty, subs, cx.param_env)
.type_implements_trait(
trait_id,
[impl_ty.into()].into_iter().chain(subs.iter().copied()),
cx.param_env,
)
.must_apply_modulo_regions()
{
return Some(Position::MethodReceiverRefImpl)
Expand Down Expand Up @@ -1106,7 +1106,7 @@ fn needless_borrow_impl_arg_position<'tcx>(
let projection_predicates = predicates
.iter()
.filter_map(|predicate| {
if let PredicateKind::Projection(projection_predicate) = predicate.kind().skip_binder() {
if let PredicateKind::Clause(Clause::Projection(projection_predicate)) = predicate.kind().skip_binder() {
Some(projection_predicate)
} else {
None
Expand All @@ -1120,7 +1120,7 @@ fn needless_borrow_impl_arg_position<'tcx>(
if predicates
.iter()
.filter_map(|predicate| {
if let PredicateKind::Trait(trait_predicate) = predicate.kind().skip_binder()
if let PredicateKind::Clause(Clause::Trait(trait_predicate)) = predicate.kind().skip_binder()
&& trait_predicate.trait_ref.self_ty() == param_ty.to_ty(cx.tcx)
{
Some(trait_predicate.trait_ref.def_id)
Expand Down Expand Up @@ -1182,7 +1182,7 @@ fn needless_borrow_impl_arg_position<'tcx>(
}

predicates.iter().all(|predicate| {
if let PredicateKind::Trait(trait_predicate) = predicate.kind().skip_binder()
if let PredicateKind::Clause(Clause::Trait(trait_predicate)) = predicate.kind().skip_binder()
&& cx.tcx.is_diagnostic_item(sym::IntoIterator, trait_predicate.trait_ref.def_id)
&& let ty::Param(param_ty) = trait_predicate.self_ty().kind()
&& let GenericArgKind::Type(ty) = substs_with_referent_ty[param_ty.index as usize].unpack()
Expand Down Expand Up @@ -1333,7 +1333,7 @@ fn replace_types<'tcx>(
let item_def_id = projection_predicate.projection_ty.item_def_id;
let assoc_item = cx.tcx.associated_item(item_def_id);
let projection = cx.tcx
.mk_projection(assoc_item.def_id, cx.tcx.mk_substs_trait(new_ty, &[]));
.mk_projection(assoc_item.def_id, cx.tcx.mk_substs_trait(new_ty, []));

if let Ok(projected_ty) = cx.tcx.try_normalize_erasing_regions(cx.param_env, projection)
&& substs[term_param_ty.index as usize] != ty::GenericArg::from(projected_ty)
Expand Down
14 changes: 7 additions & 7 deletions clippy_lints/src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::hir::nested_filter;
use rustc_middle::traits::Reveal;
use rustc_middle::ty::{
self, Binder, BoundConstness, GenericParamDefKind, ImplPolarity, ParamEnv, PredicateKind, TraitPredicate, TraitRef,
Ty, TyCtxt,
self, Binder, BoundConstness, Clause, GenericParamDefKind, ImplPolarity, ParamEnv, PredicateKind, TraitPredicate,
TraitRef, Ty, TyCtxt,
};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::source_map::Span;
Expand Down Expand Up @@ -466,12 +466,12 @@ fn check_partial_eq_without_eq<'tcx>(cx: &LateContext<'tcx>, span: Span, trait_r
if let Some(def_id) = trait_ref.trait_def_id();
if cx.tcx.is_diagnostic_item(sym::PartialEq, def_id);
let param_env = param_env_for_derived_eq(cx.tcx, adt.did(), eq_trait_def_id);
if !implements_trait_with_env(cx.tcx, param_env, ty, eq_trait_def_id, &[]);
if !implements_trait_with_env(cx.tcx, param_env, ty, eq_trait_def_id, []);
// If all of our fields implement `Eq`, we can implement `Eq` too
if adt
.all_fields()
.map(|f| f.ty(cx.tcx, substs))
.all(|ty| implements_trait_with_env(cx.tcx, param_env, ty, eq_trait_def_id, &[]));
.all(|ty| implements_trait_with_env(cx.tcx, param_env, ty, eq_trait_def_id, []));
then {
span_lint_and_sugg(
cx,
Expand Down Expand Up @@ -499,7 +499,7 @@ fn param_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) ->

let ty_predicates = tcx.predicates_of(did).predicates;
for (p, _) in ty_predicates {
if let PredicateKind::Trait(p) = p.kind().skip_binder()
if let PredicateKind::Clause(Clause::Trait(p)) = p.kind().skip_binder()
&& p.trait_ref.def_id == eq_trait_id
&& let ty::Param(self_ty) = p.trait_ref.self_ty().kind()
&& p.constness == BoundConstness::NotConst
Expand All @@ -512,14 +512,14 @@ fn param_env_for_derived_eq(tcx: TyCtxt<'_>, did: DefId, eq_trait_id: DefId) ->
ParamEnv::new(
tcx.mk_predicates(ty_predicates.iter().map(|&(p, _)| p).chain(
params.iter().filter(|&&(_, needs_eq)| needs_eq).map(|&(param, _)| {
tcx.mk_predicate(Binder::dummy(PredicateKind::Trait(TraitPredicate {
tcx.mk_predicate(Binder::dummy(PredicateKind::Clause(Clause::Trait(TraitPredicate {
trait_ref: TraitRef::new(
eq_trait_id,
tcx.mk_substs(std::iter::once(tcx.mk_param_from_def(param))),
),
constness: BoundConstness::NotConst,
polarity: ImplPolarity::Positive,
})))
}))))
}),
)),
Reveal::UserFacing,
Expand Down
4 changes: 1 addition & 3 deletions clippy_lints/src/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,7 @@ fn lint_for_missing_headers(
let body = cx.tcx.hir().body(body_id);
let ret_ty = typeck.expr_ty(body.value);
if implements_trait(cx, ret_ty, future, &[]);
if let ty::Opaque(_, subs) = ret_ty.kind();
if let Some(gen) = subs.types().next();
if let ty::Generator(_, subs, _) = gen.kind();
if let ty::Generator(_, subs, _) = ret_ty.kind();
if is_type_diagnostic_item(cx, subs.as_generator().return_ty(), sym::Result);
then {
span_lint(
Expand Down
9 changes: 8 additions & 1 deletion clippy_lints/src/eta_reduction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,18 @@ impl<'tcx> LateLintPass<'tcx> for EtaReduction {
let callee_ty_unadjusted = cx.typeck_results().expr_ty(callee).peel_refs();
if !is_type_diagnostic_item(cx, callee_ty_unadjusted, sym::Arc);
if !is_type_diagnostic_item(cx, callee_ty_unadjusted, sym::Rc);
if let ty::Closure(_, substs) = *closure_ty.kind();
then {
span_lint_and_then(cx, REDUNDANT_CLOSURE, expr.span, "redundant closure", |diag| {
if let Some(mut snippet) = snippet_opt(cx, callee.span) {
if let Some(fn_mut_id) = cx.tcx.lang_items().fn_mut_trait()
&& implements_trait(cx, callee_ty.peel_refs(), fn_mut_id, &[])
&& let args = cx.tcx.erase_late_bound_regions(substs.as_closure().sig()).inputs()
&& implements_trait(
cx,
callee_ty.peel_refs(),
fn_mut_id,
&args.iter().copied().map(Into::into).collect::<Vec<_>>(),
)
&& path_to_local(callee).map_or(false, |l| local_used_after_expr(cx, l, expr))
{
// Mutable closure is used after current expr; we cannot consume it.
Expand Down
6 changes: 4 additions & 2 deletions clippy_lints/src/future_not_send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use rustc_hir::intravisit::FnKind;
use rustc_hir::{Body, FnDecl, HirId};
use rustc_infer::infer::TyCtxtInferExt;
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::{EarlyBinder, Opaque, PredicateKind::Trait};
use rustc_middle::ty::{Clause, EarlyBinder, Opaque, PredicateKind};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::{sym, Span};
use rustc_trait_selection::traits::error_reporting::suggestions::TypeErrCtxtExt;
Expand Down Expand Up @@ -91,7 +91,9 @@ impl<'tcx> LateLintPass<'tcx> for FutureNotSend {
infcx
.err_ctxt()
.maybe_note_obligation_cause_for_async_await(db, &obligation);
if let Trait(trait_pred) = obligation.predicate.kind().skip_binder() {
if let PredicateKind::Clause(Clause::Trait(trait_pred)) =
obligation.predicate.kind().skip_binder()
{
db.note(&format!(
"`{}` doesn't implement `{}`",
trait_pred.self_ty(),
Expand Down
1 change: 0 additions & 1 deletion clippy_lints/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
extern crate rustc_arena;
extern crate rustc_ast;
extern crate rustc_ast_pretty;
extern crate rustc_attr;
extern crate rustc_data_structures;
extern crate rustc_driver;
extern crate rustc_errors;
Expand Down
36 changes: 17 additions & 19 deletions clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use rustc_hir::lang_items;
use rustc_hir::FnRetTy::Return;
use rustc_hir::{
BareFnTy, BodyId, FnDecl, GenericArg, GenericBound, GenericParam, GenericParamKind, Generics, Impl, ImplItem,
ImplItemKind, Item, ItemKind, Lifetime, LifetimeName, ParamName, PolyTraitRef, PredicateOrigin, TraitFn, TraitItem,
TraitItemKind, Ty, TyKind, WherePredicate,
ImplItemKind, Item, ItemKind, Lifetime, LifetimeName, LifetimeParamKind, PolyTraitRef, PredicateOrigin, TraitFn,
TraitItem, TraitItemKind, Ty, TyKind, WherePredicate,
};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::hir::nested_filter as middle_nested_filter;
Expand Down Expand Up @@ -180,7 +180,7 @@ fn check_fn_inner<'tcx>(
_ => None,
});
for bound in lifetimes {
if bound.name != LifetimeName::Static && !bound.is_elided() {
if !bound.is_static() && !bound.is_elided() {
return;
}
}
Expand Down Expand Up @@ -414,17 +414,13 @@ impl<'a, 'tcx> RefVisitor<'a, 'tcx> {

fn record(&mut self, lifetime: &Option<Lifetime>) {
if let Some(ref lt) = *lifetime {
if lt.name == LifetimeName::Static {
if lt.is_static() {
self.lts.push(RefLt::Static);
} else if let LifetimeName::Param(_, ParamName::Fresh) = lt.name {
} else if lt.is_anonymous() {
// Fresh lifetimes generated should be ignored.
self.lts.push(RefLt::Unnamed);
} else if lt.is_elided() {
self.lts.push(RefLt::Unnamed);
} else if let LifetimeName::Param(def_id, _) = lt.name {
} else if let LifetimeName::Param(def_id) = lt.res {
self.lts.push(RefLt::Named(def_id));
} else {
self.lts.push(RefLt::Unnamed);
}
} else {
self.lts.push(RefLt::Unnamed);
Expand Down Expand Up @@ -472,7 +468,7 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
walk_item(self, item);
self.lts.truncate(len);
self.lts.extend(bounds.iter().filter_map(|bound| match bound {
GenericArg::Lifetime(l) => Some(if let LifetimeName::Param(def_id, _) = l.name {
GenericArg::Lifetime(l) => Some(if let LifetimeName::Param(def_id) = l.res {
RefLt::Named(def_id)
} else {
RefLt::Unnamed
Expand All @@ -498,10 +494,8 @@ impl<'a, 'tcx> Visitor<'tcx> for RefVisitor<'a, 'tcx> {
}

fn visit_generic_arg(&mut self, generic_arg: &'tcx GenericArg<'tcx>) {
if let GenericArg::Lifetime(l) = generic_arg
&& let LifetimeName::Param(def_id, _) = l.name
{
self.lifetime_generic_arg_spans.entry(def_id).or_insert(l.span);
if let GenericArg::Lifetime(l) = generic_arg && let LifetimeName::Param(def_id) = l.res {
self.lifetime_generic_arg_spans.entry(def_id).or_insert(l.ident.span);
}
walk_generic_arg(self, generic_arg);
}
Expand Down Expand Up @@ -570,7 +564,7 @@ where

// for lifetimes as parameters of generics
fn visit_lifetime(&mut self, lifetime: &'tcx Lifetime) {
self.map.remove(&lifetime.name.ident().name);
self.map.remove(&lifetime.ident.name);
}

fn visit_generic_param(&mut self, param: &'tcx GenericParam<'_>) {
Expand All @@ -594,7 +588,9 @@ fn report_extra_lifetimes<'tcx>(cx: &LateContext<'tcx>, func: &'tcx FnDecl<'_>,
.params
.iter()
.filter_map(|par| match par.kind {
GenericParamKind::Lifetime { .. } => Some((par.name.ident().name, par.span)),
GenericParamKind::Lifetime {
kind: LifetimeParamKind::Explicit,
} => Some((par.name.ident().name, par.span)),
_ => None,
})
.collect();
Expand All @@ -619,7 +615,9 @@ fn report_extra_impl_lifetimes<'tcx>(cx: &LateContext<'tcx>, impl_: &'tcx Impl<'
.params
.iter()
.filter_map(|par| match par.kind {
GenericParamKind::Lifetime { .. } => Some((par.name.ident().name, par.span)),
GenericParamKind::Lifetime {
kind: LifetimeParamKind::Explicit,
} => Some((par.name.ident().name, par.span)),
_ => None,
})
.collect();
Expand All @@ -646,7 +644,7 @@ struct BodyLifetimeChecker {
impl<'tcx> Visitor<'tcx> for BodyLifetimeChecker {
// for lifetimes as parameters of generics
fn visit_lifetime(&mut self, lifetime: &'tcx Lifetime) {
if lifetime.name.ident().name != kw::UnderscoreLifetime && lifetime.name.ident().name != kw::StaticLifetime {
if !lifetime.is_anonymous() && lifetime.ident.name != kw::StaticLifetime {
self.lifetimes_used_in_body = true;
}
}
Expand Down
Loading