Remove lifetime support in deriving code.
It's unused.
This commit is contained in:
parent
b94246693a
commit
18fef6bbd7
5 changed files with 11 additions and 32 deletions
|
@ -18,7 +18,6 @@ pub fn expand_deriving_partial_ord(
|
||||||
let ordering_ty = Literal(path_std!(cmp::Ordering));
|
let ordering_ty = Literal(path_std!(cmp::Ordering));
|
||||||
let ret_ty = Literal(Path::new_(
|
let ret_ty = Literal(Path::new_(
|
||||||
pathvec_std!(option::Option),
|
pathvec_std!(option::Option),
|
||||||
None,
|
|
||||||
vec![Box::new(ordering_ty)],
|
vec![Box::new(ordering_ty)],
|
||||||
PathKind::Std,
|
PathKind::Std,
|
||||||
));
|
));
|
||||||
|
|
|
@ -23,7 +23,7 @@ pub fn expand_deriving_rustc_decodable(
|
||||||
let trait_def = TraitDef {
|
let trait_def = TraitDef {
|
||||||
span,
|
span,
|
||||||
attributes: Vec::new(),
|
attributes: Vec::new(),
|
||||||
path: Path::new_(vec![krate, sym::Decodable], None, vec![], PathKind::Global),
|
path: Path::new_(vec![krate, sym::Decodable], vec![], PathKind::Global),
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
supports_unions: false,
|
supports_unions: false,
|
||||||
|
@ -32,19 +32,17 @@ pub fn expand_deriving_rustc_decodable(
|
||||||
generics: Bounds {
|
generics: Bounds {
|
||||||
bounds: vec![(
|
bounds: vec![(
|
||||||
typaram,
|
typaram,
|
||||||
vec![Path::new_(vec![krate, sym::Decoder], None, vec![], PathKind::Global)],
|
vec![Path::new_(vec![krate, sym::Decoder], vec![], PathKind::Global)],
|
||||||
)],
|
)],
|
||||||
},
|
},
|
||||||
explicit_self: false,
|
explicit_self: false,
|
||||||
args: vec![(Ref(Box::new(Literal(Path::new_local(typaram))), Mutability::Mut), sym::d)],
|
args: vec![(Ref(Box::new(Literal(Path::new_local(typaram))), Mutability::Mut), sym::d)],
|
||||||
ret_ty: Literal(Path::new_(
|
ret_ty: Literal(Path::new_(
|
||||||
pathvec_std!(result::Result),
|
pathvec_std!(result::Result),
|
||||||
None,
|
|
||||||
vec![
|
vec![
|
||||||
Box::new(Self_),
|
Box::new(Self_),
|
||||||
Box::new(Literal(Path::new_(
|
Box::new(Literal(Path::new_(
|
||||||
vec![typaram, sym::Error],
|
vec![typaram, sym::Error],
|
||||||
None,
|
|
||||||
vec![],
|
vec![],
|
||||||
PathKind::Local,
|
PathKind::Local,
|
||||||
))),
|
))),
|
||||||
|
|
|
@ -108,7 +108,7 @@ pub fn expand_deriving_rustc_encodable(
|
||||||
let trait_def = TraitDef {
|
let trait_def = TraitDef {
|
||||||
span,
|
span,
|
||||||
attributes: Vec::new(),
|
attributes: Vec::new(),
|
||||||
path: Path::new_(vec![krate, sym::Encodable], None, vec![], PathKind::Global),
|
path: Path::new_(vec![krate, sym::Encodable], vec![], PathKind::Global),
|
||||||
additional_bounds: Vec::new(),
|
additional_bounds: Vec::new(),
|
||||||
generics: Bounds::empty(),
|
generics: Bounds::empty(),
|
||||||
supports_unions: false,
|
supports_unions: false,
|
||||||
|
@ -117,19 +117,17 @@ pub fn expand_deriving_rustc_encodable(
|
||||||
generics: Bounds {
|
generics: Bounds {
|
||||||
bounds: vec![(
|
bounds: vec![(
|
||||||
typaram,
|
typaram,
|
||||||
vec![Path::new_(vec![krate, sym::Encoder], None, vec![], PathKind::Global)],
|
vec![Path::new_(vec![krate, sym::Encoder], vec![], PathKind::Global)],
|
||||||
)],
|
)],
|
||||||
},
|
},
|
||||||
explicit_self: true,
|
explicit_self: true,
|
||||||
args: vec![(Ref(Box::new(Literal(Path::new_local(typaram))), Mutability::Mut), sym::s)],
|
args: vec![(Ref(Box::new(Literal(Path::new_local(typaram))), Mutability::Mut), sym::s)],
|
||||||
ret_ty: Literal(Path::new_(
|
ret_ty: Literal(Path::new_(
|
||||||
pathvec_std!(result::Result),
|
pathvec_std!(result::Result),
|
||||||
None,
|
|
||||||
vec![
|
vec![
|
||||||
Box::new(Tuple(Vec::new())),
|
Box::new(Tuple(Vec::new())),
|
||||||
Box::new(Literal(Path::new_(
|
Box::new(Literal(Path::new_(
|
||||||
vec![typaram, sym::Error],
|
vec![typaram, sym::Error],
|
||||||
None,
|
|
||||||
vec![],
|
vec![],
|
||||||
PathKind::Local,
|
PathKind::Local,
|
||||||
))),
|
))),
|
||||||
|
|
|
@ -11,11 +11,10 @@ use rustc_span::symbol::{kw, Ident, Symbol};
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
/// A path, e.g., `::std::option::Option::<i32>` (global). Has support
|
/// A path, e.g., `::std::option::Option::<i32>` (global). Has support
|
||||||
/// for type parameters and a lifetime.
|
/// for type parameters.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Path {
|
pub struct Path {
|
||||||
path: Vec<Symbol>,
|
path: Vec<Symbol>,
|
||||||
lifetime: Option<Ident>,
|
|
||||||
params: Vec<Box<Ty>>,
|
params: Vec<Box<Ty>>,
|
||||||
kind: PathKind,
|
kind: PathKind,
|
||||||
}
|
}
|
||||||
|
@ -29,18 +28,13 @@ pub enum PathKind {
|
||||||
|
|
||||||
impl Path {
|
impl Path {
|
||||||
pub fn new(path: Vec<Symbol>) -> Path {
|
pub fn new(path: Vec<Symbol>) -> Path {
|
||||||
Path::new_(path, None, Vec::new(), PathKind::Std)
|
Path::new_(path, Vec::new(), PathKind::Std)
|
||||||
}
|
}
|
||||||
pub fn new_local(path: Symbol) -> Path {
|
pub fn new_local(path: Symbol) -> Path {
|
||||||
Path::new_(vec![path], None, Vec::new(), PathKind::Local)
|
Path::new_(vec![path], Vec::new(), PathKind::Local)
|
||||||
}
|
}
|
||||||
pub fn new_(
|
pub fn new_(path: Vec<Symbol>, params: Vec<Box<Ty>>, kind: PathKind) -> Path {
|
||||||
path: Vec<Symbol>,
|
Path { path, params, kind }
|
||||||
lifetime: Option<Ident>,
|
|
||||||
params: Vec<Box<Ty>>,
|
|
||||||
kind: PathKind,
|
|
||||||
) -> Path {
|
|
||||||
Path { path, lifetime, params, kind }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_ty(
|
pub fn to_ty(
|
||||||
|
@ -60,10 +54,8 @@ impl Path {
|
||||||
self_generics: &Generics,
|
self_generics: &Generics,
|
||||||
) -> ast::Path {
|
) -> ast::Path {
|
||||||
let mut idents = self.path.iter().map(|s| Ident::new(*s, span)).collect();
|
let mut idents = self.path.iter().map(|s| Ident::new(*s, span)).collect();
|
||||||
let lt = mk_lifetimes(cx, span, &self.lifetime);
|
|
||||||
let tys = self.params.iter().map(|t| t.to_ty(cx, span, self_ty, self_generics));
|
let tys = self.params.iter().map(|t| t.to_ty(cx, span, self_ty, self_generics));
|
||||||
let params =
|
let params = tys.map(GenericArg::Type).collect();
|
||||||
lt.into_iter().map(GenericArg::Lifetime).chain(tys.map(GenericArg::Type)).collect();
|
|
||||||
|
|
||||||
match self.kind {
|
match self.kind {
|
||||||
PathKind::Global => cx.path_all(span, true, idents, params),
|
PathKind::Global => cx.path_all(span, true, idents, params),
|
||||||
|
@ -98,14 +90,6 @@ pub fn nil_ty() -> Ty {
|
||||||
Tuple(Vec::new())
|
Tuple(Vec::new())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mk_lifetime(cx: &ExtCtxt<'_>, span: Span, lt: &Option<Ident>) -> Option<ast::Lifetime> {
|
|
||||||
lt.map(|ident| cx.lifetime(span, ident))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mk_lifetimes(cx: &ExtCtxt<'_>, span: Span, lt: &Option<Ident>) -> Vec<ast::Lifetime> {
|
|
||||||
mk_lifetime(cx, span, lt).into_iter().collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Ty {
|
impl Ty {
|
||||||
pub fn to_ty(
|
pub fn to_ty(
|
||||||
&self,
|
&self,
|
||||||
|
|
|
@ -15,7 +15,7 @@ pub fn expand_deriving_hash(
|
||||||
item: &Annotatable,
|
item: &Annotatable,
|
||||||
push: &mut dyn FnMut(Annotatable),
|
push: &mut dyn FnMut(Annotatable),
|
||||||
) {
|
) {
|
||||||
let path = Path::new_(pathvec_std!(hash::Hash), None, vec![], PathKind::Std);
|
let path = Path::new_(pathvec_std!(hash::Hash), vec![], PathKind::Std);
|
||||||
|
|
||||||
let typaram = sym::__H;
|
let typaram = sym::__H;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue