Remove name from GenericParamKind::Lifetime
This commit is contained in:
parent
c4e8e71880
commit
6015edf9af
10 changed files with 30 additions and 59 deletions
|
|
@ -736,9 +736,7 @@ pub fn walk_param_bound<'v, V: Visitor<'v>>(visitor: &mut V, bound: &'v ParamBou
|
|||
TraitTyParamBound(ref typ, modifier) => {
|
||||
visitor.visit_poly_trait_ref(typ, modifier);
|
||||
}
|
||||
Outlives(ref lifetime) => {
|
||||
visitor.visit_lifetime(lifetime);
|
||||
}
|
||||
Outlives(ref lifetime) => visitor.visit_lifetime(lifetime),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -706,13 +706,8 @@ impl<'a> LoweringContext<'a> {
|
|||
kind: hir::GenericParamKind::Lifetime {
|
||||
lt_name: hir_name,
|
||||
in_band: true,
|
||||
lifetime: hir::Lifetime {
|
||||
id: def_node_id,
|
||||
span,
|
||||
name: hir_name,
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.chain(in_band_ty_params.into_iter())
|
||||
.collect();
|
||||
|
|
@ -1423,12 +1418,7 @@ impl<'a> LoweringContext<'a> {
|
|||
kind: hir::GenericParamKind::Lifetime {
|
||||
lt_name: name,
|
||||
in_band: false,
|
||||
lifetime: hir::Lifetime {
|
||||
id: def_node_id,
|
||||
span: lifetime.span,
|
||||
name,
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1947,21 +1937,20 @@ impl<'a> LoweringContext<'a> {
|
|||
-> hir::GenericParam {
|
||||
let mut bounds = self.lower_param_bounds(¶m.bounds, itctx);
|
||||
match param.kind {
|
||||
GenericParamKind::Lifetime { ref lifetime } => {
|
||||
GenericParamKind::Lifetime => {
|
||||
let was_collecting_in_band = self.is_collecting_in_band_lifetimes;
|
||||
self.is_collecting_in_band_lifetimes = false;
|
||||
|
||||
let lifetime = self.lower_lifetime(lifetime);
|
||||
let lt = self.lower_lifetime(&Lifetime { id: param.id, ident: param.ident });
|
||||
let param = hir::GenericParam {
|
||||
id: lifetime.id,
|
||||
name: lifetime.name.name(),
|
||||
span: lifetime.span,
|
||||
id: lt.id,
|
||||
name: lt.name.name(),
|
||||
span: lt.span,
|
||||
pure_wrt_drop: attr::contains_name(¶m.attrs, "may_dangle"),
|
||||
bounds,
|
||||
kind: hir::GenericParamKind::Lifetime {
|
||||
lt_name: lifetime.name,
|
||||
lt_name: lt.name,
|
||||
in_band: false,
|
||||
lifetime,
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -454,8 +454,6 @@ pub enum GenericParamKind {
|
|||
// as a result of an in-band lifetime usage like:
|
||||
// `fn foo(x: &'a u8) -> &'a u8 { x }`
|
||||
in_band: bool,
|
||||
// We keep a `Lifetime` around for now just so we can `visit_lifetime`.
|
||||
lifetime: Lifetime,
|
||||
},
|
||||
Type {
|
||||
default: Option<P<Ty>>,
|
||||
|
|
|
|||
|
|
@ -209,10 +209,9 @@ impl<'a> HashStable<StableHashingContext<'a>> for hir::GenericParamKind {
|
|||
hasher: &mut StableHasher<W>) {
|
||||
mem::discriminant(self).hash_stable(hcx, hasher);
|
||||
match self {
|
||||
hir::GenericParamKind::Lifetime { lt_name, in_band, ref lifetime } => {
|
||||
hir::GenericParamKind::Lifetime { lt_name, in_band } => {
|
||||
lt_name.hash_stable(hcx, hasher);
|
||||
in_band.hash_stable(hcx, hasher);
|
||||
lifetime.hash_stable(hcx, hasher);
|
||||
}
|
||||
hir::GenericParamKind::Type { ref default, synthetic, attrs } => {
|
||||
default.hash_stable(hcx, hasher);
|
||||
|
|
|
|||
|
|
@ -301,9 +301,7 @@ pub type ParamBounds = Vec<ParamBound>;
|
|||
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]
|
||||
pub enum GenericParamKind {
|
||||
/// A lifetime definition, e.g. `'a: 'b+'c+'d`.
|
||||
Lifetime {
|
||||
lifetime: Lifetime,
|
||||
},
|
||||
Lifetime,
|
||||
Type {
|
||||
default: Option<P<Ty>>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -484,9 +484,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> {
|
|||
id: lifetime.id,
|
||||
attrs: attrs.into(),
|
||||
bounds,
|
||||
kind: ast::GenericParamKind::Lifetime {
|
||||
lifetime,
|
||||
}
|
||||
kind: ast::GenericParamKind::Lifetime,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4877,9 +4877,7 @@ impl<'a> Parser<'a> {
|
|||
id: lifetime.id,
|
||||
attrs: attrs.into(),
|
||||
bounds,
|
||||
kind: ast::GenericParamKind::Lifetime {
|
||||
lifetime,
|
||||
}
|
||||
kind: ast::GenericParamKind::Lifetime,
|
||||
});
|
||||
if seen_ty_param {
|
||||
self.span_err(self.prev_span,
|
||||
|
|
|
|||
|
|
@ -308,8 +308,8 @@ pub fn expr_to_string(e: &ast::Expr) -> String {
|
|||
to_string(|s| s.print_expr(e))
|
||||
}
|
||||
|
||||
pub fn lifetime_to_string(e: &ast::Lifetime) -> String {
|
||||
to_string(|s| s.print_lifetime(e))
|
||||
pub fn lifetime_to_string(lt: &ast::Lifetime) -> String {
|
||||
to_string(|s| s.print_lifetime(*lt))
|
||||
}
|
||||
|
||||
pub fn tt_to_string(tt: tokenstream::TokenTree) -> String {
|
||||
|
|
@ -1008,10 +1008,9 @@ impl<'a> State<'a> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn print_opt_lifetime(&mut self,
|
||||
lifetime: &Option<ast::Lifetime>) -> io::Result<()> {
|
||||
if let Some(l) = *lifetime {
|
||||
self.print_lifetime(&l)?;
|
||||
pub fn print_opt_lifetime(&mut self, lifetime: &Option<ast::Lifetime>) -> io::Result<()> {
|
||||
if let Some(lt) = *lifetime {
|
||||
self.print_lifetime(lt)?;
|
||||
self.nbsp()?;
|
||||
}
|
||||
Ok(())
|
||||
|
|
@ -1019,7 +1018,7 @@ impl<'a> State<'a> {
|
|||
|
||||
pub fn print_generic_arg(&mut self, generic_arg: &GenericArg) -> io::Result<()> {
|
||||
match generic_arg {
|
||||
GenericArg::Lifetime(lt) => self.print_lifetime(lt),
|
||||
GenericArg::Lifetime(lt) => self.print_lifetime(*lt),
|
||||
GenericArg::Type(ty) => self.print_type(ty),
|
||||
}
|
||||
}
|
||||
|
|
@ -2833,26 +2832,19 @@ impl<'a> State<'a> {
|
|||
}
|
||||
self.print_poly_trait_ref(tref)?;
|
||||
}
|
||||
Outlives(lt) => {
|
||||
self.print_lifetime(lt)?;
|
||||
}
|
||||
Outlives(lt) => self.print_lifetime(*lt)?,
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn print_lifetime(&mut self,
|
||||
lifetime: &ast::Lifetime)
|
||||
-> io::Result<()>
|
||||
{
|
||||
pub fn print_lifetime(&mut self, lifetime: ast::Lifetime) -> io::Result<()> {
|
||||
self.print_name(lifetime.ident.name)
|
||||
}
|
||||
|
||||
pub fn print_lifetime_bounds(&mut self,
|
||||
lifetime: &ast::Lifetime,
|
||||
bounds: &ast::ParamBounds)
|
||||
-> io::Result<()>
|
||||
pub fn print_lifetime_bounds(&mut self, lifetime: ast::Lifetime, bounds: &ast::ParamBounds)
|
||||
-> io::Result<()>
|
||||
{
|
||||
self.print_lifetime(lifetime)?;
|
||||
if !bounds.is_empty() {
|
||||
|
|
@ -2862,7 +2854,7 @@ impl<'a> State<'a> {
|
|||
self.s.word(" + ")?;
|
||||
}
|
||||
match bound {
|
||||
ast::ParamBound::Outlives(lt) => self.print_lifetime(lt)?,
|
||||
ast::ParamBound::Outlives(lt) => self.print_lifetime(*lt)?,
|
||||
_ => panic!(),
|
||||
}
|
||||
}
|
||||
|
|
@ -2882,9 +2874,10 @@ impl<'a> State<'a> {
|
|||
|
||||
self.commasep(Inconsistent, &generic_params, |s, param| {
|
||||
match param.kind {
|
||||
ast::GenericParamKind::Lifetime { ref lifetime } => {
|
||||
ast::GenericParamKind::Lifetime => {
|
||||
s.print_outer_attributes_inline(¶m.attrs)?;
|
||||
s.print_lifetime_bounds(lifetime, ¶m.bounds)
|
||||
let lt = ast::Lifetime { id: param.id, ident: param.ident };
|
||||
s.print_lifetime_bounds(lt, ¶m.bounds)
|
||||
},
|
||||
ast::GenericParamKind::Type { ref default } => {
|
||||
s.print_outer_attributes_inline(¶m.attrs)?;
|
||||
|
|
@ -2934,7 +2927,7 @@ impl<'a> State<'a> {
|
|||
ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate{ref lifetime,
|
||||
ref bounds,
|
||||
..}) => {
|
||||
self.print_lifetime_bounds(lifetime, bounds)?;
|
||||
self.print_lifetime_bounds(*lifetime, bounds)?;
|
||||
}
|
||||
ast::WherePredicate::EqPredicate(ast::WhereEqPredicate{ref lhs_ty,
|
||||
ref rhs_ty,
|
||||
|
|
|
|||
|
|
@ -665,8 +665,8 @@ impl<'a> TraitDef<'a> {
|
|||
let trait_ref = cx.trait_ref(trait_path);
|
||||
|
||||
let self_params: Vec<_> = generics.params.iter().map(|param| match param.kind {
|
||||
GenericParamKind::Lifetime { ref lifetime, .. } => {
|
||||
GenericArg::Lifetime(*lifetime)
|
||||
GenericParamKind::Lifetime { .. } => {
|
||||
GenericArg::Lifetime(ast::Lifetime { id: param.id, ident: param.ident })
|
||||
}
|
||||
GenericParamKind::Type { .. } => {
|
||||
GenericArg::Type(cx.ty_ident(self.span, param.ident))
|
||||
|
|
|
|||
|
|
@ -190,8 +190,8 @@ impl<'a> Ty<'a> {
|
|||
match *self {
|
||||
Self_ => {
|
||||
let params: Vec<_> = generics.params.iter().map(|param| match param.kind {
|
||||
GenericParamKind::Lifetime { ref lifetime, .. } => {
|
||||
GenericArg::Lifetime(*lifetime)
|
||||
GenericParamKind::Lifetime { .. } => {
|
||||
GenericArg::Lifetime(ast::Lifetime { id: param.id, ident: param.ident })
|
||||
}
|
||||
GenericParamKind::Type { .. } => {
|
||||
GenericArg::Type(cx.ty_ident(span, param.ident))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue