Skip to content

Commit 9108fb7

Browse files
committed
Remove some old code from libsyntax
1 parent a97f60e commit 9108fb7

File tree

9 files changed

+21
-67
lines changed

9 files changed

+21
-67
lines changed

src/libsyntax/ast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ impl PathParameters {
248248
pub fn none() -> PathParameters {
249249
PathParameters::AngleBracketed(AngleBracketedParameterData {
250250
lifetimes: Vec::new(),
251-
types: P::empty(),
252-
bindings: P::empty(),
251+
types: P::new(),
252+
bindings: P::new(),
253253
})
254254
}
255255

@@ -421,7 +421,7 @@ impl Default for Generics {
421421
fn default() -> Generics {
422422
Generics {
423423
lifetimes: Vec::new(),
424-
ty_params: P::empty(),
424+
ty_params: P::new(),
425425
where_clause: WhereClause {
426426
id: DUMMY_NODE_ID,
427427
predicates: Vec::new(),

src/libsyntax/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ pub mod config;
9797
pub mod entry;
9898
pub mod feature_gate;
9999
pub mod fold;
100-
pub mod owned_slice;
101100
pub mod parse;
102101
pub mod ptr;
103102
pub mod show_span;

src/libsyntax/owned_slice.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/libsyntax/parse/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ mod tests {
925925
Abi::Rust,
926926
ast::Generics{ // no idea on either of these:
927927
lifetimes: Vec::new(),
928-
ty_params: P::empty(),
928+
ty_params: P::new(),
929929
where_clause: ast::WhereClause {
930930
id: ast::DUMMY_NODE_ID,
931931
predicates: Vec::new(),

src/libsyntax/parse/parser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,7 @@ impl<'a> Parser<'a> {
11601160
let other_bounds = if self.eat(&token::BinOp(token::Plus)) {
11611161
self.parse_ty_param_bounds(BoundParsingMode::Bare)?
11621162
} else {
1163-
P::empty()
1163+
P::new()
11641164
};
11651165
let all_bounds =
11661166
Some(TraitTyParamBound(poly_trait_ref, TraitBoundModifier::None)).into_iter()
@@ -4239,7 +4239,7 @@ impl<'a> Parser<'a> {
42394239
-> PResult<'a, TyParamBounds>
42404240
{
42414241
if !self.eat(&token::Colon) {
4242-
Ok(P::empty())
4242+
Ok(P::new())
42434243
} else {
42444244
self.parse_ty_param_bounds(mode)
42454245
}

src/libsyntax/print/pprust.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,7 +995,7 @@ impl<'a> State<'a> {
995995
ast::TyKind::BareFn(ref f) => {
996996
let generics = ast::Generics {
997997
lifetimes: f.lifetimes.clone(),
998-
ty_params: P::empty(),
998+
ty_params: P::new(),
999999
where_clause: ast::WhereClause {
10001000
id: ast::DUMMY_NODE_ID,
10011001
predicates: Vec::new(),
@@ -3011,7 +3011,7 @@ impl<'a> State<'a> {
30113011
}
30123012
let generics = ast::Generics {
30133013
lifetimes: Vec::new(),
3014-
ty_params: P::empty(),
3014+
ty_params: P::new(),
30153015
where_clause: ast::WhereClause {
30163016
id: ast::DUMMY_NODE_ID,
30173017
predicates: Vec::new(),

src/libsyntax/ptr.rs

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ impl<T: 'static> P<T> {
8383
}
8484
}
8585

86-
impl<T> Deref for P<T> {
86+
impl<T: ?Sized> Deref for P<T> {
8787
type Target = T;
8888

89-
fn deref<'a>(&'a self) -> &'a T {
89+
fn deref(&self) -> &T {
9090
&self.ptr
9191
}
9292
}
@@ -97,11 +97,12 @@ impl<T: 'static + Clone> Clone for P<T> {
9797
}
9898
}
9999

100-
impl<T: Debug> Debug for P<T> {
100+
impl<T: ?Sized + Debug> Debug for P<T> {
101101
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
102-
Debug::fmt(&**self, f)
102+
Debug::fmt(&self.ptr, f)
103103
}
104104
}
105+
105106
impl<T: Display> Display for P<T> {
106107
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
107108
Display::fmt(&**self, f)
@@ -126,19 +127,8 @@ impl<T: Encodable> Encodable for P<T> {
126127
}
127128
}
128129

129-
130-
impl<T:fmt::Debug> fmt::Debug for P<[T]> {
131-
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
132-
self.ptr.fmt(fmt)
133-
}
134-
}
135-
136130
impl<T> P<[T]> {
137131
pub fn new() -> P<[T]> {
138-
P::empty()
139-
}
140-
141-
pub fn empty() -> P<[T]> {
142132
P { ptr: Default::default() }
143133
}
144134

@@ -151,31 +141,11 @@ impl<T> P<[T]> {
151141
pub fn into_vec(self) -> Vec<T> {
152142
self.ptr.into_vec()
153143
}
154-
155-
pub fn as_slice<'a>(&'a self) -> &'a [T] {
156-
&self.ptr
157-
}
158-
159-
pub fn move_iter(self) -> vec::IntoIter<T> {
160-
self.into_vec().into_iter()
161-
}
162-
163-
pub fn map<U, F: FnMut(&T) -> U>(&self, f: F) -> P<[U]> {
164-
self.iter().map(f).collect()
165-
}
166-
}
167-
168-
impl<T> Deref for P<[T]> {
169-
type Target = [T];
170-
171-
fn deref(&self) -> &[T] {
172-
self.as_slice()
173-
}
174144
}
175145

176146
impl<T> Default for P<[T]> {
177147
fn default() -> P<[T]> {
178-
P::empty()
148+
P::new()
179149
}
180150
}
181151

src/libsyntax_ext/deriving/generic/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ impl<'a> TraitDef<'a> {
525525
span: self.span,
526526
bound_lifetimes: wb.bound_lifetimes.clone(),
527527
bounded_ty: wb.bounded_ty.clone(),
528-
bounds: P::from_vec(wb.bounds.iter().cloned().collect())
528+
bounds: wb.bounds.iter().cloned().collect(),
529529
})
530530
}
531531
ast::WherePredicate::RegionPredicate(ref rb) => {
@@ -595,9 +595,9 @@ impl<'a> TraitDef<'a> {
595595
let trait_ref = cx.trait_ref(trait_path);
596596

597597
// Create the type parameters on the `self` path.
598-
let self_ty_params = generics.ty_params.map(|ty_param| {
598+
let self_ty_params = generics.ty_params.iter().map(|ty_param| {
599599
cx.ty_ident(self.span, ty_param.ident)
600-
});
600+
}).collect();
601601

602602
let self_lifetimes: Vec<ast::Lifetime> =
603603
generics.lifetimes
@@ -608,7 +608,7 @@ impl<'a> TraitDef<'a> {
608608
// Create the type of `self`.
609609
let self_type = cx.ty_path(
610610
cx.path_all(self.span, false, vec!( type_ident ), self_lifetimes,
611-
self_ty_params.into_vec(), Vec::new()));
611+
self_ty_params, Vec::new()));
612612

613613
let attr = cx.attribute(
614614
self.span,

src/libsyntax_ext/deriving/generic/ty.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,14 @@ impl<'a> Ty<'a> {
169169
-> ast::Path {
170170
match *self {
171171
Self_ => {
172-
let self_params = self_generics.ty_params.map(|ty_param| {
172+
let self_params = self_generics.ty_params.iter().map(|ty_param| {
173173
cx.ty_ident(span, ty_param.ident)
174-
});
174+
}).collect();
175175
let lifetimes = self_generics.lifetimes.iter()
176176
.map(|d| d.lifetime)
177177
.collect();
178178

179-
cx.path_all(span, false, vec!(self_ty), lifetimes,
180-
self_params.into_vec(), Vec::new())
179+
cx.path_all(span, false, vec![self_ty], lifetimes, self_params, Vec::new())
181180
}
182181
Literal(ref p) => {
183182
p.to_path(cx, span, self_ty, self_generics)

0 commit comments

Comments
 (0)