Skip to content

Commit 18fef6b

Browse files
committed
Remove lifetime support in deriving code.
It's unused.
1 parent b942466 commit 18fef6b

File tree

5 files changed

+11
-32
lines changed

5 files changed

+11
-32
lines changed

compiler/rustc_builtin_macros/src/deriving/cmp/partial_ord.rs

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ pub fn expand_deriving_partial_ord(
1818
let ordering_ty = Literal(path_std!(cmp::Ordering));
1919
let ret_ty = Literal(Path::new_(
2020
pathvec_std!(option::Option),
21-
None,
2221
vec![Box::new(ordering_ty)],
2322
PathKind::Std,
2423
));

compiler/rustc_builtin_macros/src/deriving/decodable.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn expand_deriving_rustc_decodable(
2323
let trait_def = TraitDef {
2424
span,
2525
attributes: Vec::new(),
26-
path: Path::new_(vec![krate, sym::Decodable], None, vec![], PathKind::Global),
26+
path: Path::new_(vec![krate, sym::Decodable], vec![], PathKind::Global),
2727
additional_bounds: Vec::new(),
2828
generics: Bounds::empty(),
2929
supports_unions: false,
@@ -32,19 +32,17 @@ pub fn expand_deriving_rustc_decodable(
3232
generics: Bounds {
3333
bounds: vec![(
3434
typaram,
35-
vec![Path::new_(vec![krate, sym::Decoder], None, vec![], PathKind::Global)],
35+
vec![Path::new_(vec![krate, sym::Decoder], vec![], PathKind::Global)],
3636
)],
3737
},
3838
explicit_self: false,
3939
args: vec![(Ref(Box::new(Literal(Path::new_local(typaram))), Mutability::Mut), sym::d)],
4040
ret_ty: Literal(Path::new_(
4141
pathvec_std!(result::Result),
42-
None,
4342
vec![
4443
Box::new(Self_),
4544
Box::new(Literal(Path::new_(
4645
vec![typaram, sym::Error],
47-
None,
4846
vec![],
4947
PathKind::Local,
5048
))),

compiler/rustc_builtin_macros/src/deriving/encodable.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub fn expand_deriving_rustc_encodable(
108108
let trait_def = TraitDef {
109109
span,
110110
attributes: Vec::new(),
111-
path: Path::new_(vec![krate, sym::Encodable], None, vec![], PathKind::Global),
111+
path: Path::new_(vec![krate, sym::Encodable], vec![], PathKind::Global),
112112
additional_bounds: Vec::new(),
113113
generics: Bounds::empty(),
114114
supports_unions: false,
@@ -117,19 +117,17 @@ pub fn expand_deriving_rustc_encodable(
117117
generics: Bounds {
118118
bounds: vec![(
119119
typaram,
120-
vec![Path::new_(vec![krate, sym::Encoder], None, vec![], PathKind::Global)],
120+
vec![Path::new_(vec![krate, sym::Encoder], vec![], PathKind::Global)],
121121
)],
122122
},
123123
explicit_self: true,
124124
args: vec![(Ref(Box::new(Literal(Path::new_local(typaram))), Mutability::Mut), sym::s)],
125125
ret_ty: Literal(Path::new_(
126126
pathvec_std!(result::Result),
127-
None,
128127
vec![
129128
Box::new(Tuple(Vec::new())),
130129
Box::new(Literal(Path::new_(
131130
vec![typaram, sym::Error],
132-
None,
133131
vec![],
134132
PathKind::Local,
135133
))),

compiler/rustc_builtin_macros/src/deriving/generic/ty.rs

+6-22
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ use rustc_span::symbol::{kw, Ident, Symbol};
1111
use rustc_span::Span;
1212

1313
/// A path, e.g., `::std::option::Option::<i32>` (global). Has support
14-
/// for type parameters and a lifetime.
14+
/// for type parameters.
1515
#[derive(Clone)]
1616
pub struct Path {
1717
path: Vec<Symbol>,
18-
lifetime: Option<Ident>,
1918
params: Vec<Box<Ty>>,
2019
kind: PathKind,
2120
}
@@ -29,18 +28,13 @@ pub enum PathKind {
2928

3029
impl Path {
3130
pub fn new(path: Vec<Symbol>) -> Path {
32-
Path::new_(path, None, Vec::new(), PathKind::Std)
31+
Path::new_(path, Vec::new(), PathKind::Std)
3332
}
3433
pub fn new_local(path: Symbol) -> Path {
35-
Path::new_(vec![path], None, Vec::new(), PathKind::Local)
34+
Path::new_(vec![path], Vec::new(), PathKind::Local)
3635
}
37-
pub fn new_(
38-
path: Vec<Symbol>,
39-
lifetime: Option<Ident>,
40-
params: Vec<Box<Ty>>,
41-
kind: PathKind,
42-
) -> Path {
43-
Path { path, lifetime, params, kind }
36+
pub fn new_(path: Vec<Symbol>, params: Vec<Box<Ty>>, kind: PathKind) -> Path {
37+
Path { path, params, kind }
4438
}
4539

4640
pub fn to_ty(
@@ -60,10 +54,8 @@ impl Path {
6054
self_generics: &Generics,
6155
) -> ast::Path {
6256
let mut idents = self.path.iter().map(|s| Ident::new(*s, span)).collect();
63-
let lt = mk_lifetimes(cx, span, &self.lifetime);
6457
let tys = self.params.iter().map(|t| t.to_ty(cx, span, self_ty, self_generics));
65-
let params =
66-
lt.into_iter().map(GenericArg::Lifetime).chain(tys.map(GenericArg::Type)).collect();
58+
let params = tys.map(GenericArg::Type).collect();
6759

6860
match self.kind {
6961
PathKind::Global => cx.path_all(span, true, idents, params),
@@ -98,14 +90,6 @@ pub fn nil_ty() -> Ty {
9890
Tuple(Vec::new())
9991
}
10092

101-
fn mk_lifetime(cx: &ExtCtxt<'_>, span: Span, lt: &Option<Ident>) -> Option<ast::Lifetime> {
102-
lt.map(|ident| cx.lifetime(span, ident))
103-
}
104-
105-
fn mk_lifetimes(cx: &ExtCtxt<'_>, span: Span, lt: &Option<Ident>) -> Vec<ast::Lifetime> {
106-
mk_lifetime(cx, span, lt).into_iter().collect()
107-
}
108-
10993
impl Ty {
11094
pub fn to_ty(
11195
&self,

compiler/rustc_builtin_macros/src/deriving/hash.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub fn expand_deriving_hash(
1515
item: &Annotatable,
1616
push: &mut dyn FnMut(Annotatable),
1717
) {
18-
let path = Path::new_(pathvec_std!(hash::Hash), None, vec![], PathKind::Std);
18+
let path = Path::new_(pathvec_std!(hash::Hash), vec![], PathKind::Std);
1919

2020
let typaram = sym::__H;
2121

0 commit comments

Comments
 (0)