Skip to content

Commit

Permalink
Delete replacement of elided lifetimes in impl heading
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Mar 4, 2023
1 parent f81548d commit 5883ac8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
9 changes: 1 addition & 8 deletions src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ pub fn expand(input: &mut Item, is_local: bool) {
}
}
Item::Impl(input) => {
let mut lifetimes = CollectLifetimes::new("'impl");
lifetimes.visit_type_mut(&mut *input.self_ty);
lifetimes.visit_path_mut(&mut input.trait_.as_mut().unwrap().1);
let params = &input.generics.params;
let elided = lifetimes.elided;
input.generics.params = parse_quote!(#(#elided,)* #params);

let mut associated_type_impl_traits = Set::new();
for inner in &input.items {
if let ImplItem::Type(assoc) = inner {
Expand Down Expand Up @@ -167,7 +160,7 @@ fn transform_sig(
ReturnType::Type(arrow, ret) => (*arrow, quote!(#ret)),
};

let mut lifetimes = CollectLifetimes::new("'life");
let mut lifetimes = CollectLifetimes::new();
for arg in sig.inputs.iter_mut() {
match arg {
FnArg::Receiver(arg) => lifetimes.visit_receiver_mut(arg),
Expand Down
6 changes: 2 additions & 4 deletions src/lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ use syn::{
pub struct CollectLifetimes {
pub elided: Vec<Lifetime>,
pub explicit: Vec<Lifetime>,
pub name: &'static str,
}

impl CollectLifetimes {
pub fn new(name: &'static str) -> Self {
pub fn new() -> Self {
CollectLifetimes {
elided: Vec::new(),
explicit: Vec::new(),
name,
}
}

Expand All @@ -37,7 +35,7 @@ impl CollectLifetimes {
}

fn next_lifetime(&mut self, span: Span) -> Lifetime {
let name = format!("{}{}", self.name, self.elided.len());
let name = format!("'life{}", self.elided.len());
let life = Lifetime::new(&name, span);
self.elided.push(life.clone());
life
Expand Down

0 comments on commit 5883ac8

Please sign in to comment.