Skip to content

Commit c7ac816

Browse files
committed
Clippy fallout.
1 parent 031b2c5 commit c7ac816

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

src/tools/clippy/clippy_lints/src/inherent_to_string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_help;
22
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
33
use clippy_utils::{get_trait_def_id, paths, return_ty, trait_ref_of_method};
44
use if_chain::if_chain;
5-
use rustc_hir::{ImplItem, ImplItemKind};
5+
use rustc_hir::{GenericParamKind, ImplItem, ImplItemKind};
66
use rustc_lint::{LateContext, LateLintPass};
77
use rustc_session::{declare_lint_pass, declare_tool_lint};
88
use rustc_span::sym;
@@ -102,7 +102,7 @@ impl<'tcx> LateLintPass<'tcx> for InherentToString {
102102
let decl = &signature.decl;
103103
if decl.implicit_self.has_implicit_self();
104104
if decl.inputs.len() == 1;
105-
if impl_item.generics.params.is_empty();
105+
if impl_item.generics.params.iter().all(|p| matches!(p.kind, GenericParamKind::Lifetime { .. }));
106106

107107
// Check if return type is String
108108
if is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id()), sym::String);

src/tools/clippy/clippy_lints/src/lifetimes.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ use rustc_hir::intravisit::{
99
use rustc_hir::FnRetTy::Return;
1010
use rustc_hir::{
1111
BareFnTy, BodyId, FnDecl, GenericArg, GenericBound, GenericParam, GenericParamKind, Generics, Impl, ImplItem,
12-
ImplItemKind, Item, ItemKind, LangItem, Lifetime, LifetimeName, ParamName, PolyTraitRef, PredicateOrigin,
13-
TraitBoundModifier, TraitFn, TraitItem, TraitItemKind, Ty, TyKind, WherePredicate,
12+
ImplItemKind, Item, ItemKind, LangItem, Lifetime, LifetimeName, LifetimeParamKind, ParamName, PolyTraitRef,
13+
PredicateOrigin, TraitBoundModifier, TraitFn, TraitItem, TraitItemKind, Ty, TyKind, WherePredicate,
1414
};
1515
use rustc_lint::{LateContext, LateLintPass};
1616
use rustc_middle::hir::nested_filter as middle_nested_filter;
@@ -338,7 +338,10 @@ fn could_use_elision<'tcx>(
338338
fn allowed_lts_from(named_generics: &[GenericParam<'_>]) -> FxHashSet<RefLt> {
339339
let mut allowed_lts = FxHashSet::default();
340340
for par in named_generics.iter() {
341-
if let GenericParamKind::Lifetime { .. } = par.kind {
341+
if let GenericParamKind::Lifetime {
342+
kind: LifetimeParamKind::Explicit,
343+
} = par.kind
344+
{
342345
allowed_lts.insert(RefLt::Named(par.name.ident().name));
343346
}
344347
}
@@ -379,6 +382,7 @@ impl<'a, 'tcx> RefVisitor<'a, 'tcx> {
379382
self.lts.push(RefLt::Static);
380383
} else if let LifetimeName::Param(_, ParamName::Fresh) = lt.name {
381384
// Fresh lifetimes generated should be ignored.
385+
self.lts.push(RefLt::Unnamed);
382386
} else if lt.is_elided() {
383387
self.lts.push(RefLt::Unnamed);
384388
} else {

src/tools/clippy/clippy_lints/src/ptr.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -495,12 +495,13 @@ fn check_mut_from_ref<'tcx>(cx: &LateContext<'tcx>, sig: &FnSig<'_>, body: Optio
495495
if let FnRetTy::Return(ty) = sig.decl.output
496496
&& let Some((out, Mutability::Mut, _)) = get_rptr_lm(ty)
497497
{
498+
let out_region = cx.tcx.named_region(out.hir_id);
498499
let args: Option<Vec<_>> = sig
499500
.decl
500501
.inputs
501502
.iter()
502503
.filter_map(get_rptr_lm)
503-
.filter(|&(lt, _, _)| lt.name == out.name)
504+
.filter(|&(lt, _, _)| cx.tcx.named_region(lt.hir_id) == out_region)
504505
.map(|(_, mutability, span)| (mutability == Mutability::Not).then(|| span))
505506
.collect();
506507
if let Some(args) = args

src/tools/clippy/clippy_lints/src/types/borrowed_box.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub(super) fn check(cx: &LateContext<'_>, hir_ty: &hir::Ty<'_>, lt: &Lifetime, m
3131
return false;
3232
}
3333

34-
let ltopt = if lt.is_elided() {
34+
let ltopt = if lt.name.is_anonymous() {
3535
String::new()
3636
} else {
3737
format!("{} ", lt.name.ident().as_str())

0 commit comments

Comments
 (0)