]> git.lizzy.rs Git - rust.git/commitdiff
Remove some old code from libsyntax
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Fri, 22 Apr 2016 20:43:14 +0000 (23:43 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Sun, 24 Apr 2016 18:04:09 +0000 (21:04 +0300)
src/libsyntax/ast.rs
src/libsyntax/lib.rs
src/libsyntax/owned_slice.rs [deleted file]
src/libsyntax/parse/mod.rs
src/libsyntax/parse/parser.rs
src/libsyntax/print/pprust.rs
src/libsyntax/ptr.rs
src/libsyntax_ext/deriving/generic/mod.rs
src/libsyntax_ext/deriving/generic/ty.rs

index 6bcd8085315a279edbdd243b46fbb91d408f9a59..5064bcba4c36f00939266fe384a2c6a90a7578c1 100644 (file)
@@ -248,8 +248,8 @@ impl PathParameters {
     pub fn none() -> PathParameters {
         PathParameters::AngleBracketed(AngleBracketedParameterData {
             lifetimes: Vec::new(),
-            types: P::empty(),
-            bindings: P::empty(),
+            types: P::new(),
+            bindings: P::new(),
         })
     }
 
@@ -421,7 +421,7 @@ impl Default for Generics {
     fn default() ->  Generics {
         Generics {
             lifetimes: Vec::new(),
-            ty_params: P::empty(),
+            ty_params: P::new(),
             where_clause: WhereClause {
                 id: DUMMY_NODE_ID,
                 predicates: Vec::new(),
index f38720c3e5006aa52a1a16d02878bd71b66c631c..6cfa1e9847b88cbe3670d3821839148ff0770de0 100644 (file)
@@ -97,7 +97,6 @@ pub mod syntax {
 pub mod entry;
 pub mod feature_gate;
 pub mod fold;
-pub mod owned_slice;
 pub mod parse;
 pub mod ptr;
 pub mod show_span;
diff --git a/src/libsyntax/owned_slice.rs b/src/libsyntax/owned_slice.rs
deleted file mode 100644 (file)
index 33a3d57..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-/// A non-growable owned slice.
-#[unstable(feature = "rustc_private", issue = "0")]
-#[rustc_deprecated(since = "1.7.0", reason = "use `ptr::P<[T]>` instead")]
-pub type OwnedSlice<T> = ::ptr::P<[T]>;
index 7534683a206ffb63e7354fd057efb404ad5b1f36..c2050d2a8f48b38eecbdd4c366f70226c65c029e 100644 (file)
@@ -925,7 +925,7 @@ fn parser_done(p: Parser){
                                     Abi::Rust,
                                     ast::Generics{ // no idea on either of these:
                                         lifetimes: Vec::new(),
-                                        ty_params: P::empty(),
+                                        ty_params: P::new(),
                                         where_clause: ast::WhereClause {
                                             id: ast::DUMMY_NODE_ID,
                                             predicates: Vec::new(),
index 7842d9dca53639697929eb43c81fb4bf810a0020..4fb423f787e636a72a1adde3752c10ac60616bcf 100644 (file)
@@ -1160,7 +1160,7 @@ pub fn parse_for_in_type(&mut self) -> PResult<'a, TyKind> {
             let other_bounds = if self.eat(&token::BinOp(token::Plus)) {
                 self.parse_ty_param_bounds(BoundParsingMode::Bare)?
             } else {
-                P::empty()
+                P::new()
             };
             let all_bounds =
                 Some(TraitTyParamBound(poly_trait_ref, TraitBoundModifier::None)).into_iter()
@@ -4239,7 +4239,7 @@ fn parse_colon_then_ty_param_bounds(&mut self,
                                         -> PResult<'a, TyParamBounds>
     {
         if !self.eat(&token::Colon) {
-            Ok(P::empty())
+            Ok(P::new())
         } else {
             self.parse_ty_param_bounds(mode)
         }
index 798477d8fe50df046b5c060b1e9c945d91afc814..1c6ecbd3b5afdaa037650c1d3a387c9901b86440 100644 (file)
@@ -995,7 +995,7 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> io::Result<()> {
             ast::TyKind::BareFn(ref f) => {
                 let generics = ast::Generics {
                     lifetimes: f.lifetimes.clone(),
-                    ty_params: P::empty(),
+                    ty_params: P::new(),
                     where_clause: ast::WhereClause {
                         id: ast::DUMMY_NODE_ID,
                         predicates: Vec::new(),
@@ -3011,7 +3011,7 @@ pub fn print_ty_fn(&mut self,
         }
         let generics = ast::Generics {
             lifetimes: Vec::new(),
-            ty_params: P::empty(),
+            ty_params: P::new(),
             where_clause: ast::WhereClause {
                 id: ast::DUMMY_NODE_ID,
                 predicates: Vec::new(),
index fda9741d35c419285d9ea0961721a2c96983a6c9..9d04cb75daa0e7c3318d804961a89b65ddaf2c85 100644 (file)
@@ -83,10 +83,10 @@ pub fn map<F>(mut self, f: F) -> P<T> where
     }
 }
 
-impl<T> Deref for P<T> {
+impl<T: ?Sized> Deref for P<T> {
     type Target = T;
 
-    fn deref<'a>(&'a self) -> &'a T {
+    fn deref(&self) -> &T {
         &self.ptr
     }
 }
@@ -97,11 +97,12 @@ fn clone(&self) -> P<T> {
     }
 }
 
-impl<T: Debug> Debug for P<T> {
+impl<T: ?Sized + Debug> Debug for P<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        Debug::fmt(&**self, f)
+        Debug::fmt(&self.ptr, f)
     }
 }
+
 impl<T: Display> Display for P<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         Display::fmt(&**self, f)
@@ -126,19 +127,8 @@ fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
     }
 }
 
-
-impl<T:fmt::Debug> fmt::Debug for P<[T]> {
-    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-        self.ptr.fmt(fmt)
-    }
-}
-
 impl<T> P<[T]> {
     pub fn new() -> P<[T]> {
-        P::empty()
-    }
-
-    pub fn empty() -> P<[T]> {
         P { ptr: Default::default() }
     }
 
@@ -151,31 +141,11 @@ pub fn from_vec(v: Vec<T>) -> P<[T]> {
     pub fn into_vec(self) -> Vec<T> {
         self.ptr.into_vec()
     }
-
-    pub fn as_slice<'a>(&'a self) -> &'a [T] {
-        &self.ptr
-    }
-
-    pub fn move_iter(self) -> vec::IntoIter<T> {
-        self.into_vec().into_iter()
-    }
-
-    pub fn map<U, F: FnMut(&T) -> U>(&self, f: F) -> P<[U]> {
-        self.iter().map(f).collect()
-    }
-}
-
-impl<T> Deref for P<[T]> {
-    type Target = [T];
-
-    fn deref(&self) -> &[T] {
-        self.as_slice()
-    }
 }
 
 impl<T> Default for P<[T]> {
     fn default() -> P<[T]> {
-        P::empty()
+        P::new()
     }
 }
 
index a3e70cc6321a6000f9c59365c07d60142f1a2006..5251b0d08d4497abd09794ed32a62b3a55c6c28c 100644 (file)
@@ -525,7 +525,7 @@ fn create_derived_impl(&self,
                         span: self.span,
                         bound_lifetimes: wb.bound_lifetimes.clone(),
                         bounded_ty: wb.bounded_ty.clone(),
-                        bounds: P::from_vec(wb.bounds.iter().cloned().collect())
+                        bounds: wb.bounds.iter().cloned().collect(),
                     })
                 }
                 ast::WherePredicate::RegionPredicate(ref rb) => {
@@ -595,9 +595,9 @@ fn create_derived_impl(&self,
         let trait_ref = cx.trait_ref(trait_path);
 
         // Create the type parameters on the `self` path.
-        let self_ty_params = generics.ty_params.map(|ty_param| {
+        let self_ty_params = generics.ty_params.iter().map(|ty_param| {
             cx.ty_ident(self.span, ty_param.ident)
-        });
+        }).collect();
 
         let self_lifetimes: Vec<ast::Lifetime> =
             generics.lifetimes
@@ -608,7 +608,7 @@ fn create_derived_impl(&self,
         // Create the type of `self`.
         let self_type = cx.ty_path(
             cx.path_all(self.span, false, vec!( type_ident ), self_lifetimes,
-                        self_ty_params.into_vec(), Vec::new()));
+                        self_ty_params, Vec::new()));
 
         let attr = cx.attribute(
             self.span,
index e19febe2a120354e3407afc2326cc0b31fb38620..e31d45d91a59f4ef8baf5feb1dad48180ed11b0a 100644 (file)
@@ -169,15 +169,14 @@ pub fn to_path(&self,
                    -> ast::Path {
         match *self {
             Self_ => {
-                let self_params = self_generics.ty_params.map(|ty_param| {
+                let self_params = self_generics.ty_params.iter().map(|ty_param| {
                     cx.ty_ident(span, ty_param.ident)
-                });
+                }).collect();
                 let lifetimes = self_generics.lifetimes.iter()
                                                        .map(|d| d.lifetime)
                                                        .collect();
 
-                cx.path_all(span, false, vec!(self_ty), lifetimes,
-                            self_params.into_vec(), Vec::new())
+                cx.path_all(span, false, vec![self_ty], lifetimes, self_params, Vec::new())
             }
             Literal(ref p) => {
                 p.to_path(cx, span, self_ty, self_generics)