Skip to content

Try to fix #2080 #2081

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 9 additions & 9 deletions clippy_lints/src/lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ fn check_fn_inner<'a, 'tcx>(
.parameters
.lifetimes;
for bound in bounds {
if bound.name != "'static" && !bound.is_elided() {
if bound.name != LifetimeName::Static && !bound.is_elided() {
return;
}
bounds_lts.push(bound);
Expand Down Expand Up @@ -225,7 +225,7 @@ fn allowed_lts_from(named_lts: &[LifetimeDef]) -> HashSet<RefLt> {
let mut allowed_lts = HashSet::new();
for lt in named_lts {
if lt.bounds.is_empty() {
allowed_lts.insert(RefLt::Named(lt.lifetime.name));
allowed_lts.insert(RefLt::Named(lt.lifetime.name.name()));
}
}
allowed_lts.insert(RefLt::Unnamed);
Expand All @@ -235,8 +235,8 @@ fn allowed_lts_from(named_lts: &[LifetimeDef]) -> HashSet<RefLt> {

fn lts_from_bounds<'a, T: Iterator<Item = &'a Lifetime>>(mut vec: Vec<RefLt>, bounds_lts: T) -> Vec<RefLt> {
for lt in bounds_lts {
if lt.name != "'static" {
vec.push(RefLt::Named(lt.name));
if lt.name != LifetimeName::Static {
vec.push(RefLt::Named(lt.name.name()));
}
}

Expand Down Expand Up @@ -266,12 +266,12 @@ impl<'v, 't> RefVisitor<'v, 't> {

fn record(&mut self, lifetime: &Option<Lifetime>) {
if let Some(ref lt) = *lifetime {
if lt.name == "'static" {
if lt.name == LifetimeName::Static {
self.lts.push(RefLt::Static);
} else if lt.is_elided() {
self.lts.push(RefLt::Unnamed);
} else {
self.lts.push(RefLt::Named(lt.name));
self.lts.push(RefLt::Named(lt.name.name()));
}
} else {
self.lts.push(RefLt::Unnamed);
Expand Down Expand Up @@ -396,7 +396,7 @@ struct LifetimeChecker {
impl<'tcx> Visitor<'tcx> for LifetimeChecker {
// for lifetimes as parameters of generics
fn visit_lifetime(&mut self, lifetime: &'tcx Lifetime) {
self.map.remove(&lifetime.name);
self.map.remove(&lifetime.name.name());
}

fn visit_lifetime_def(&mut self, _: &'tcx LifetimeDef) {
Expand All @@ -415,7 +415,7 @@ fn report_extra_lifetimes<'a, 'tcx: 'a>(cx: &LateContext<'a, 'tcx>, func: &'tcx
let hs = generics
.lifetimes
.iter()
.map(|lt| (lt.lifetime.name, lt.lifetime.span))
.map(|lt| (lt.lifetime.name.name(), lt.lifetime.span))
.collect();
let mut checker = LifetimeChecker { map: hs };

Expand All @@ -434,7 +434,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 != keywords::Invalid.name() && lifetime.name != "'static" {
if lifetime.name.name() != keywords::Invalid.name() && lifetime.name != LifetimeName::Static {
self.lifetimes_used_in_body = true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion clippy_lints/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ fn check_ty(cx: &LateContext, ast_ty: &hir::Ty, is_local: bool) {
let ltopt = if lt.is_elided() {
"".to_owned()
} else {
format!("{} ", lt.name.as_str())
format!("{} ", lt.name.name().as_str())
};
let mutopt = if *mutbl == Mutability::MutMutable {
"mut "
Expand Down