diff --git a/src/doc/book/the-stack-and-the-heap.md b/src/doc/book/the-stack-and-the-heap.md index 9cc3e12aa04a..63b73a7fc31f 100644 --- a/src/doc/book/the-stack-and-the-heap.md +++ b/src/doc/book/the-stack-and-the-heap.md @@ -130,63 +130,64 @@ on the stack is the first one you retrieve from it. Let’s try a three-deep example: ```rust -fn bar() { +fn italic() { let i = 6; } -fn foo() { +fn bold() { let a = 5; let b = 100; let c = 1; - bar(); + italic(); } fn main() { let x = 42; - foo(); + bold(); } ``` +We have some kooky function names to make the diagrams clearer. + Okay, first, we call `main()`: | Address | Name | Value | |---------|------|-------| | 0 | x | 42 | -Next up, `main()` calls `foo()`: +Next up, `main()` calls `bold()`: | Address | Name | Value | |---------|------|-------| -| 3 | c | 1 | -| 2 | b | 100 | -| 1 | a | 5 | +| **3** | **c**|**1** | +| **2** | **b**|**100**| +| **1** | **a**| **5** | | 0 | x | 42 | -And then `foo()` calls `bar()`: +And then `bold()` calls `italic()`: | Address | Name | Value | |---------|------|-------| -| 4 | i | 6 | -| 3 | c | 1 | -| 2 | b | 100 | -| 1 | a | 5 | +| *4* | *i* | *6* | +| **3** | **c**|**1** | +| **2** | **b**|**100**| +| **1** | **a**| **5** | | 0 | x | 42 | - Whew! Our stack is growing tall. -After `bar()` is over, its frame is deallocated, leaving just `foo()` and +After `italic()` is over, its frame is deallocated, leaving just `bold()` and `main()`: | Address | Name | Value | |---------|------|-------| -| 3 | c | 1 | -| 2 | b | 100 | -| 1 | a | 5 | -| 0 | x | 42 | +| **3** | **c**|**1** | +| **2** | **b**|**100**| +| **1** | **a**| **5** | +| 0 | x | 42 | -And then `foo()` ends, leaving just `main()`: +And then `bold()` ends, leaving just `main()`: | Address | Name | Value | |---------|------|-------| @@ -578,3 +579,4 @@ comes at the cost of either significant runtime support (e.g. in the form of a garbage collector) or significant programmer effort (in the form of explicit memory management calls that require verification not provided by the Rust compiler). + diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 454e2b02b1ca..cde86230d750 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -23,12 +23,6 @@ //! nor does it provide concurrency or I/O. These things require //! platform integration, and this library is platform-agnostic. //! -//! *It is not recommended to use the core library*. The stable -//! functionality of libcore is reexported from the -//! [standard library](../std/index.html). The composition of this library is -//! subject to change over time; only the interface exposed through libstd is -//! intended to be stable. -//! //! # How to use the core library //! // FIXME: Fill me in with more detail when the interface settles diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 4f3c12567095..8abb12706a5e 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -644,7 +644,7 @@ macro_rules! int_impl { self.overflowing_shl(rhs).0 } - /// Panic-free bitwise shift-left; yields `self >> mask(rhs)`, + /// Panic-free bitwise shift-right; yields `self >> mask(rhs)`, /// where `mask` removes any high-order bits of `rhs` that /// would cause the shift to exceed the bitwidth of the type. /// @@ -1446,7 +1446,7 @@ macro_rules! uint_impl { self.overflowing_shl(rhs).0 } - /// Panic-free bitwise shift-left; yields `self >> mask(rhs)`, + /// Panic-free bitwise shift-right; yields `self >> mask(rhs)`, /// where `mask` removes any high-order bits of `rhs` that /// would cause the shift to exceed the bitwidth of the type. /// diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index cde8e7a6d1e1..6a5910074d91 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -1337,7 +1337,7 @@ explanatory comments for the same example: // `for`-loops use a protocol based on the `Iterator` // trait. Each item yielded in a `for` loop has the - // type `Iterator::Item` -- that is,I `Item` is the + // type `Iterator::Item` -- that is, `Item` is the // associated type of the concrete iterator impl. for v in &vs { // ~ ~~~ diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index e894878e43ce..d5ecb3f2e863 100644 --- a/src/librustc/middle/infer/error_reporting.rs +++ b/src/librustc/middle/infer/error_reporting.rs @@ -90,7 +90,6 @@ use std::cell::{Cell, RefCell}; use std::char::from_u32; use std::fmt; use syntax::ast; -use syntax::owned_slice::OwnedSlice; use syntax::codemap::{self, Pos, Span}; use syntax::parse::token; use syntax::ptr::P; @@ -1154,10 +1153,10 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { } fn rebuild_ty_params(&self, - ty_params: OwnedSlice, + ty_params: P<[hir::TyParam]>, lifetime: hir::Lifetime, region_names: &HashSet) - -> OwnedSlice { + -> P<[hir::TyParam]> { ty_params.map(|ty_param| { let bounds = self.rebuild_ty_param_bounds(ty_param.bounds.clone(), lifetime, @@ -1173,10 +1172,10 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { } fn rebuild_ty_param_bounds(&self, - ty_param_bounds: OwnedSlice, + ty_param_bounds: hir::TyParamBounds, lifetime: hir::Lifetime, region_names: &HashSet) - -> OwnedSlice { + -> hir::TyParamBounds { ty_param_bounds.map(|tpb| { match tpb { &hir::RegionTyParamBound(lt) => { @@ -1249,7 +1248,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { add: &Vec, keep: &HashSet, remove: &HashSet, - ty_params: OwnedSlice, + ty_params: P<[hir::TyParam]>, where_clause: hir::WhereClause) -> hir::Generics { let mut lifetimes = Vec::new(); diff --git a/src/librustc/middle/ty/structural_impls.rs b/src/librustc/middle/ty/structural_impls.rs index e6007809af5e..ecb2b85fd774 100644 --- a/src/librustc/middle/ty/structural_impls.rs +++ b/src/librustc/middle/ty/structural_impls.rs @@ -16,7 +16,7 @@ use middle::ty::fold::{TypeFoldable, TypeFolder}; use std::rc::Rc; use syntax::abi; -use syntax::owned_slice::OwnedSlice; +use syntax::ptr::P; use rustc_front::hir; @@ -555,8 +555,8 @@ impl<'tcx, T:TypeFoldable<'tcx>> TypeFoldable<'tcx> for ty::Binder { } } -impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for OwnedSlice { - fn fold_with>(&self, folder: &mut F) -> OwnedSlice { +impl<'tcx, T: TypeFoldable<'tcx>> TypeFoldable<'tcx> for P<[T]> { + fn fold_with>(&self, folder: &mut F) -> P<[T]> { self.iter().map(|t| t.fold_with(folder)).collect() } } diff --git a/src/librustc_front/fold.rs b/src/librustc_front/fold.rs index 88a34b27c318..0978c3f78e82 100644 --- a/src/librustc_front/fold.rs +++ b/src/librustc_front/fold.rs @@ -17,7 +17,6 @@ use syntax::ast::{MetaWord, MetaList, MetaNameValue}; use syntax::attr::ThinAttributesExt; use hir; use syntax::codemap::{respan, Span, Spanned}; -use syntax::owned_slice::OwnedSlice; use syntax::ptr::P; use syntax::parse::token; use syntax::util::move_map::MoveMap; @@ -211,7 +210,7 @@ pub trait Folder : Sized { noop_fold_ty_param(tp, self) } - fn fold_ty_params(&mut self, tps: OwnedSlice) -> OwnedSlice { + fn fold_ty_params(&mut self, tps: P<[TyParam]>) -> P<[TyParam]> { noop_fold_ty_params(tps, self) } @@ -220,12 +219,12 @@ pub trait Folder : Sized { } fn fold_opt_bounds(&mut self, - b: Option>) - -> Option> { + b: Option) + -> Option { noop_fold_opt_bounds(b, self) } - fn fold_bounds(&mut self, b: OwnedSlice) -> OwnedSlice { + fn fold_bounds(&mut self, b: TyParamBounds) -> TyParamBounds { noop_fold_bounds(b, self) } @@ -576,9 +575,9 @@ pub fn noop_fold_ty_param(tp: TyParam, fld: &mut T) -> TyParam { } } -pub fn noop_fold_ty_params(tps: OwnedSlice, +pub fn noop_fold_ty_params(tps: P<[TyParam]>, fld: &mut T) - -> OwnedSlice { + -> P<[TyParam]> { tps.move_map(|tp| fld.fold_ty_param(tp)) } @@ -726,9 +725,9 @@ pub fn noop_fold_mt(MutTy { ty, mutbl }: MutTy, folder: &mut T) -> Mu } } -pub fn noop_fold_opt_bounds(b: Option>, +pub fn noop_fold_opt_bounds(b: Option, folder: &mut T) - -> Option> { + -> Option { b.map(|bounds| folder.fold_bounds(bounds)) } diff --git a/src/librustc_front/hir.rs b/src/librustc_front/hir.rs index d1cb82dbeccb..1491ecc89af1 100644 --- a/src/librustc_front/hir.rs +++ b/src/librustc_front/hir.rs @@ -42,7 +42,6 @@ use syntax::abi::Abi; use syntax::ast::{Name, NodeId, DUMMY_NODE_ID, TokenTree, AsmDialect}; use syntax::ast::{Attribute, Lit, StrStyle, FloatTy, IntTy, UintTy, CrateConfig}; use syntax::attr::ThinAttributes; -use syntax::owned_slice::OwnedSlice; use syntax::parse::token::InternedString; use syntax::ptr::P; @@ -193,8 +192,8 @@ impl PathParameters { pub fn none() -> PathParameters { AngleBracketedParameters(AngleBracketedParameterData { lifetimes: Vec::new(), - types: OwnedSlice::empty(), - bindings: OwnedSlice::empty(), + types: P::empty(), + bindings: P::empty(), }) } @@ -267,10 +266,10 @@ pub struct AngleBracketedParameterData { /// The lifetime parameters for this path segment. pub lifetimes: Vec, /// The type parameters for this path segment, if present. - pub types: OwnedSlice>, + pub types: P<[P]>, /// Bindings (equality constraints) on associated types, if present. /// E.g., `Foo`. - pub bindings: OwnedSlice, + pub bindings: P<[TypeBinding]>, } impl AngleBracketedParameterData { @@ -310,7 +309,7 @@ pub enum TraitBoundModifier { Maybe, } -pub type TyParamBounds = OwnedSlice; +pub type TyParamBounds = P<[TyParamBound]>; #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct TyParam { @@ -326,7 +325,7 @@ pub struct TyParam { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct Generics { pub lifetimes: Vec, - pub ty_params: OwnedSlice, + pub ty_params: P<[TyParam]>, pub where_clause: WhereClause, } @@ -369,7 +368,7 @@ pub struct WhereBoundPredicate { /// The type being bounded pub bounded_ty: P, /// Trait and lifetime bounds (`Clone+Send+'static`) - pub bounds: OwnedSlice, + pub bounds: TyParamBounds, } /// A lifetime predicate, e.g. `'a: 'b+'c` diff --git a/src/librustc_front/lowering.rs b/src/librustc_front/lowering.rs index c0b10fb89124..614f6f0bd36d 100644 --- a/src/librustc_front/lowering.rs +++ b/src/librustc_front/lowering.rs @@ -70,7 +70,6 @@ use syntax::attr::{ThinAttributes, ThinAttributesExt}; use syntax::ext::mtwt; use syntax::ptr::P; use syntax::codemap::{respan, Spanned, Span}; -use syntax::owned_slice::OwnedSlice; use syntax::parse::token; use syntax::std_inject; use syntax::visit::{self, Visitor}; @@ -430,8 +429,8 @@ pub fn lower_ty_param(lctx: &LoweringContext, tp: &TyParam) -> hir::TyParam { } pub fn lower_ty_params(lctx: &LoweringContext, - tps: &OwnedSlice) - -> OwnedSlice { + tps: &P<[TyParam]>) + -> P<[hir::TyParam]> { tps.iter().map(|tp| lower_ty_param(lctx, tp)).collect() } @@ -583,8 +582,8 @@ pub fn lower_mt(lctx: &LoweringContext, mt: &MutTy) -> hir::MutTy { } pub fn lower_opt_bounds(lctx: &LoweringContext, - b: &Option>) - -> Option> { + b: &Option) + -> Option { b.as_ref().map(|ref bounds| lower_bounds(lctx, bounds)) } @@ -1795,8 +1794,8 @@ fn path_all(sp: Span, identifier: last_identifier, parameters: hir::AngleBracketedParameters(hir::AngleBracketedParameterData { lifetimes: lifetimes, - types: OwnedSlice::from_vec(types), - bindings: OwnedSlice::from_vec(bindings), + types: P::from_vec(types), + bindings: P::from_vec(bindings), }), }); hir::Path { diff --git a/src/librustc_front/print/pprust.rs b/src/librustc_front/print/pprust.rs index 81076b6e4027..a3bb005dfbdc 100644 --- a/src/librustc_front/print/pprust.rs +++ b/src/librustc_front/print/pprust.rs @@ -12,7 +12,6 @@ pub use self::AnnNode::*; use syntax::abi; use syntax::ast; -use syntax::owned_slice::OwnedSlice; use syntax::codemap::{self, CodeMap, BytePos, Spanned}; use syntax::diagnostic; use syntax::parse::token::{self, BinOpToken}; @@ -519,7 +518,7 @@ impl<'a> State<'a> { hir::TyBareFn(ref f) => { let generics = hir::Generics { lifetimes: f.lifetimes.clone(), - ty_params: OwnedSlice::empty(), + ty_params: P::empty(), where_clause: hir::WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), @@ -2258,7 +2257,7 @@ impl<'a> State<'a> { } let generics = hir::Generics { lifetimes: Vec::new(), - ty_params: OwnedSlice::empty(), + ty_params: P::empty(), where_clause: hir::WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), diff --git a/src/librustc_front/util.rs b/src/librustc_front/util.rs index 4dc08f7a0485..f85eb2bb4011 100644 --- a/src/librustc_front/util.rs +++ b/src/librustc_front/util.rs @@ -15,7 +15,6 @@ use syntax::ast_util; use syntax::ast::{Name, NodeId, DUMMY_NODE_ID}; use syntax::codemap::Span; use syntax::ptr::P; -use syntax::owned_slice::OwnedSlice; pub fn walk_pat(pat: &Pat, mut it: F) -> bool where F: FnMut(&Pat) -> bool @@ -336,7 +335,7 @@ pub fn is_path(e: P) -> bool { pub fn empty_generics() -> Generics { Generics { lifetimes: Vec::new(), - ty_params: OwnedSlice::empty(), + ty_params: P::empty(), where_clause: WhereClause { id: DUMMY_NODE_ID, predicates: Vec::new(), @@ -354,8 +353,8 @@ pub fn ident_to_path(s: Span, ident: Ident) -> Path { identifier: ident, parameters: hir::AngleBracketedParameters(hir::AngleBracketedParameterData { lifetimes: Vec::new(), - types: OwnedSlice::empty(), - bindings: OwnedSlice::empty(), + types: P::empty(), + bindings: P::empty(), }), }), } diff --git a/src/librustc_trans/save/dump_csv.rs b/src/librustc_trans/save/dump_csv.rs index b3e7ed7ed5e8..65a6fbc2fd33 100644 --- a/src/librustc_trans/save/dump_csv.rs +++ b/src/librustc_trans/save/dump_csv.rs @@ -42,7 +42,6 @@ use std::path::Path; use syntax::ast::{self, NodeId}; use syntax::codemap::*; use syntax::parse::token::{self, keywords}; -use syntax::owned_slice::OwnedSlice; use syntax::visit::{self, Visitor}; use syntax::print::pprust::{path_to_string, ty_to_string}; use syntax::ptr::P; @@ -574,7 +573,7 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> { fn process_trait(&mut self, item: &ast::Item, generics: &ast::Generics, - trait_refs: &OwnedSlice, + trait_refs: &ast::TyParamBounds, methods: &[P]) { let qualname = format!("::{}", self.tcx.map.path_to_string(item.id)); let val = self.span.snippet(item.span); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index b4434a56fffe..474fdb85dd3c 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -119,7 +119,6 @@ use syntax::ast; use syntax::attr; use syntax::attr::AttrMetaMethods; use syntax::codemap::{self, Span, Spanned}; -use syntax::owned_slice::OwnedSlice; use syntax::parse::token::{self, InternedString}; use syntax::ptr::P; use syntax::util::lev_distance::lev_distance; @@ -4910,7 +4909,7 @@ pub fn may_break(cx: &ty::ctxt, id: ast::NodeId, b: &hir::Block) -> bool { } pub fn check_bounds_are_used<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, - tps: &OwnedSlice, + tps: &P<[hir::TyParam]>, ty: Ty<'tcx>) { debug!("check_bounds_are_used(n_tps={}, ty={:?})", tps.len(), ty); diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 52eeb781b31c..e217e7afad73 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -112,7 +112,7 @@ impl Clean for ty::Binder where T: Clean { } } -impl, U> Clean> for syntax::owned_slice::OwnedSlice { +impl, U> Clean> for P<[T]> { fn clean(&self, cx: &DocContext) -> Vec { self.iter().map(|x| x.clean(cx)).collect() } diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index b56846327c3b..41af509c5399 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -50,7 +50,6 @@ use codemap::{Span, Spanned, DUMMY_SP, ExpnId}; use abi::Abi; use ext::base; use ext::tt::macro_parser; -use owned_slice::OwnedSlice; use parse::token::{InternedString, str_to_ident}; use parse::token; use parse::lexer; @@ -261,8 +260,8 @@ impl PathParameters { pub fn none() -> PathParameters { AngleBracketedParameters(AngleBracketedParameterData { lifetimes: Vec::new(), - types: OwnedSlice::empty(), - bindings: OwnedSlice::empty(), + types: P::empty(), + bindings: P::empty(), }) } @@ -334,10 +333,10 @@ pub struct AngleBracketedParameterData { /// The lifetime parameters for this path segment. pub lifetimes: Vec, /// The type parameters for this path segment, if present. - pub types: OwnedSlice>, + pub types: P<[P]>, /// Bindings (equality constraints) on associated types, if present. /// E.g., `Foo`. - pub bindings: OwnedSlice>, + pub bindings: P<[P]>, } impl AngleBracketedParameterData { @@ -394,7 +393,7 @@ pub enum TraitBoundModifier { Maybe, } -pub type TyParamBounds = OwnedSlice; +pub type TyParamBounds = P<[TyParamBound]>; #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct TyParam { @@ -410,7 +409,7 @@ pub struct TyParam { #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct Generics { pub lifetimes: Vec, - pub ty_params: OwnedSlice, + pub ty_params: P<[TyParam]>, pub where_clause: WhereClause, } @@ -430,7 +429,7 @@ impl Default for Generics { fn default() -> Generics { Generics { lifetimes: Vec::new(), - ty_params: OwnedSlice::empty(), + ty_params: P::empty(), where_clause: WhereClause { id: DUMMY_NODE_ID, predicates: Vec::new(), @@ -466,7 +465,7 @@ pub struct WhereBoundPredicate { /// The type being bounded pub bounded_ty: P, /// Trait and lifetime bounds (`Clone+Send+'static`) - pub bounds: OwnedSlice, + pub bounds: TyParamBounds, } /// A lifetime predicate, e.g. `'a: 'b+'c` diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 3d3d53477494..d38b771814c2 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -12,7 +12,6 @@ use ast::*; use ast; use codemap; use codemap::Span; -use owned_slice::OwnedSlice; use parse::token; use print::pprust; use ptr::P; @@ -43,8 +42,8 @@ pub fn ident_to_path(s: Span, identifier: Ident) -> Path { identifier: identifier, parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData { lifetimes: Vec::new(), - types: OwnedSlice::empty(), - bindings: OwnedSlice::empty(), + types: P::empty(), + bindings: P::empty(), }) } ), diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index cdc9cb024530..46a39b98058a 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -14,7 +14,6 @@ use ast; use attr; use codemap::{Span, respan, Spanned, DUMMY_SP, Pos}; use ext::base::ExtCtxt; -use owned_slice::OwnedSlice; use parse::token::special_idents; use parse::token::InternedString; use parse::token; @@ -56,7 +55,7 @@ pub trait AstBuilder { fn ty(&self, span: Span, ty: ast::Ty_) -> P; fn ty_path(&self, ast::Path) -> P; - fn ty_sum(&self, ast::Path, OwnedSlice) -> P; + fn ty_sum(&self, ast::Path, ast::TyParamBounds) -> P; fn ty_ident(&self, span: Span, idents: ast::Ident) -> P; fn ty_rptr(&self, span: Span, @@ -70,13 +69,13 @@ pub trait AstBuilder { fn ty_option(&self, ty: P) -> P; fn ty_infer(&self, sp: Span) -> P; - fn ty_vars(&self, ty_params: &OwnedSlice) -> Vec> ; - fn ty_vars_global(&self, ty_params: &OwnedSlice) -> Vec> ; + fn ty_vars(&self, ty_params: &P<[ast::TyParam]>) -> Vec> ; + fn ty_vars_global(&self, ty_params: &P<[ast::TyParam]>) -> Vec> ; fn typaram(&self, span: Span, id: ast::Ident, - bounds: OwnedSlice, + bounds: ast::TyParamBounds, default: Option>) -> ast::TyParam; fn trait_ref(&self, path: ast::Path) -> ast::TraitRef; @@ -331,8 +330,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> { identifier: last_identifier, parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData { lifetimes: lifetimes, - types: OwnedSlice::from_vec(types), - bindings: OwnedSlice::from_vec(bindings), + types: P::from_vec(types), + bindings: P::from_vec(bindings), }) }); ast::Path { @@ -369,8 +368,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> { identifier: ident, parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData { lifetimes: lifetimes, - types: OwnedSlice::from_vec(types), - bindings: OwnedSlice::from_vec(bindings), + types: P::from_vec(types), + bindings: P::from_vec(bindings), }) }); @@ -399,7 +398,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { self.ty(path.span, ast::TyPath(None, path)) } - fn ty_sum(&self, path: ast::Path, bounds: OwnedSlice) -> P { + fn ty_sum(&self, path: ast::Path, bounds: ast::TyParamBounds) -> P { self.ty(path.span, ast::TyObjectSum(self.ty_path(path), bounds)) @@ -448,7 +447,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn typaram(&self, span: Span, id: ast::Ident, - bounds: OwnedSlice, + bounds: ast::TyParamBounds, default: Option>) -> ast::TyParam { ast::TyParam { ident: id, @@ -462,11 +461,11 @@ impl<'a> AstBuilder for ExtCtxt<'a> { // these are strange, and probably shouldn't be used outside of // pipes. Specifically, the global version possible generates // incorrect code. - fn ty_vars(&self, ty_params: &OwnedSlice) -> Vec> { + fn ty_vars(&self, ty_params: &P<[ast::TyParam]>) -> Vec> { ty_params.iter().map(|p| self.ty_ident(DUMMY_SP, p.ident)).collect() } - fn ty_vars_global(&self, ty_params: &OwnedSlice) -> Vec> { + fn ty_vars_global(&self, ty_params: &P<[ast::TyParam]>) -> Vec> { ty_params .iter() .map(|p| self.ty_path(self.path_global(DUMMY_SP, vec!(p.ident)))) diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index cd976884d2fa..cd2210c71b89 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -23,7 +23,6 @@ use ast; use attr::{ThinAttributes, ThinAttributesExt}; use ast_util; use codemap::{respan, Span, Spanned}; -use owned_slice::OwnedSlice; use parse::token; use ptr::P; use util::small_vector::SmallVector; @@ -233,7 +232,7 @@ pub trait Folder : Sized { noop_fold_ty_param(tp, self) } - fn fold_ty_params(&mut self, tps: OwnedSlice) -> OwnedSlice { + fn fold_ty_params(&mut self, tps: P<[TyParam]>) -> P<[TyParam]> { noop_fold_ty_params(tps, self) } @@ -257,13 +256,13 @@ pub trait Folder : Sized { noop_fold_opt_lifetime(o_lt, self) } - fn fold_opt_bounds(&mut self, b: Option>) - -> Option> { + fn fold_opt_bounds(&mut self, b: Option) + -> Option { noop_fold_opt_bounds(b, self) } - fn fold_bounds(&mut self, b: OwnedSlice) - -> OwnedSlice { + fn fold_bounds(&mut self, b: TyParamBounds) + -> TyParamBounds { noop_fold_bounds(b, self) } @@ -714,8 +713,8 @@ pub fn noop_fold_ty_param(tp: TyParam, fld: &mut T) -> TyParam { } } -pub fn noop_fold_ty_params(tps: OwnedSlice, fld: &mut T) - -> OwnedSlice { +pub fn noop_fold_ty_params(tps: P<[TyParam]>, fld: &mut T) + -> P<[TyParam]> { tps.move_map(|tp| fld.fold_ty_param(tp)) } @@ -871,8 +870,8 @@ pub fn noop_fold_mt(MutTy {ty, mutbl}: MutTy, folder: &mut T) -> MutT } } -pub fn noop_fold_opt_bounds(b: Option>, folder: &mut T) - -> Option> { +pub fn noop_fold_opt_bounds(b: Option, folder: &mut T) + -> Option { b.map(|bounds| folder.fold_bounds(bounds)) } diff --git a/src/libsyntax/owned_slice.rs b/src/libsyntax/owned_slice.rs index 83369689a94d..33a3d5785981 100644 --- a/src/libsyntax/owned_slice.rs +++ b/src/libsyntax/owned_slice.rs @@ -8,100 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::default::Default; -use std::fmt; -use std::iter::{IntoIterator, FromIterator}; -use std::ops::Deref; -use std::slice; -use std::vec; -use serialize::{Encodable, Decodable, Encoder, Decoder}; - -/// A non-growable owned slice. This is a separate type to allow the -/// representation to change. -#[derive(Hash, PartialEq, Eq, PartialOrd, Ord)] -pub struct OwnedSlice { - data: Box<[T]> -} - -impl fmt::Debug for OwnedSlice { - fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - self.data.fmt(fmt) - } -} - -impl OwnedSlice { - pub fn empty() -> OwnedSlice { - OwnedSlice { data: Box::new([]) } - } - - #[inline(never)] - pub fn from_vec(v: Vec) -> OwnedSlice { - OwnedSlice { data: v.into_boxed_slice() } - } - - #[inline(never)] - pub fn into_vec(self) -> Vec { - self.data.into_vec() - } - - pub fn as_slice<'a>(&'a self) -> &'a [T] { - &*self.data - } - - pub fn move_iter(self) -> vec::IntoIter { - self.into_vec().into_iter() - } - - pub fn map U>(&self, f: F) -> OwnedSlice { - self.iter().map(f).collect() - } -} - -impl Deref for OwnedSlice { - type Target = [T]; - - fn deref(&self) -> &[T] { - self.as_slice() - } -} - -impl Default for OwnedSlice { - fn default() -> OwnedSlice { - OwnedSlice::empty() - } -} - -impl Clone for OwnedSlice { - fn clone(&self) -> OwnedSlice { - OwnedSlice::from_vec(self.to_vec()) - } -} - -impl FromIterator for OwnedSlice { - fn from_iter>(iter: I) -> OwnedSlice { - OwnedSlice::from_vec(iter.into_iter().collect()) - } -} - -impl<'a, T> IntoIterator for &'a OwnedSlice { - type Item = &'a T; - type IntoIter = slice::Iter<'a, T>; - fn into_iter(self) -> Self::IntoIter { - self.data.into_iter() - } -} - -impl Encodable for OwnedSlice { - fn encode(&self, s: &mut S) -> Result<(), S::Error> { - Encodable::encode(&**self, s) - } -} - -impl Decodable for OwnedSlice { - fn decode(d: &mut D) -> Result, D::Error> { - Ok(OwnedSlice::from_vec(match Decodable::decode(d) { - Ok(t) => t, - Err(e) => return Err(e) - })) - } -} +/// 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 = ::ptr::P<[T]>; diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index e9c8173a4d98..df2a9f30c7ac 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -668,7 +668,6 @@ mod tests { use super::*; use std::rc::Rc; use codemap::{Span, BytePos, Pos, Spanned, NO_EXPANSION}; - use owned_slice::OwnedSlice; use ast::{self, TokenTree}; use abi; use attr::{first_attr_value_str_by_name, AttrMetaMethods}; @@ -944,7 +943,7 @@ mod tests { abi::Rust, ast::Generics{ // no idea on either of these: lifetimes: Vec::new(), - ty_params: OwnedSlice::empty(), + ty_params: P::empty(), where_clause: ast::WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9398f1a57333..6849b38e5047 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -50,7 +50,7 @@ use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfValue}; use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef}; use ast::{Ty, Ty_, TypeBinding, TyMac}; use ast::{TyFixedLengthVec, TyBareFn, TyTypeof, TyInfer}; -use ast::{TyParam, TyParamBound, TyParen, TyPath, TyPolyTraitRef, TyPtr}; +use ast::{TyParam, TyParamBounds, TyParen, TyPath, TyPolyTraitRef, TyPtr}; use ast::{TyRptr, TyTup, TyU32, TyVec}; use ast::TypeTraitItem; use ast::{UnnamedField, UnsafeBlock}; @@ -73,7 +73,6 @@ use parse::{new_sub_parser_from_file, ParseSess}; use util::parser::{AssocOp, Fixity}; use print::pprust; use ptr::P; -use owned_slice::OwnedSlice; use parse::PResult; use diagnostic::FatalError; @@ -752,7 +751,7 @@ impl<'a> Parser<'a> { pub fn parse_seq_to_before_gt_or_return(&mut self, sep: Option, mut f: F) - -> PResult<(OwnedSlice, bool)> where + -> PResult<(P<[T]>, bool)> where F: FnMut(&mut Parser) -> PResult>, { let mut v = Vec::new(); @@ -773,7 +772,7 @@ impl<'a> Parser<'a> { if i % 2 == 0 { match try!(f(self)) { Some(result) => v.push(result), - None => return Ok((OwnedSlice::from_vec(v), true)) + None => return Ok((P::from_vec(v), true)) } } else { if let Some(t) = sep.as_ref() { @@ -782,7 +781,7 @@ impl<'a> Parser<'a> { } } - return Ok((OwnedSlice::from_vec(v), false)); + return Ok((P::from_vec(v), false)); } /// Parse a sequence bracketed by '<' and '>', stopping @@ -790,7 +789,7 @@ impl<'a> Parser<'a> { pub fn parse_seq_to_before_gt(&mut self, sep: Option, mut f: F) - -> PResult> where + -> PResult> where F: FnMut(&mut Parser) -> PResult, { let (result, returned) = try!(self.parse_seq_to_before_gt_or_return(sep, @@ -802,7 +801,7 @@ impl<'a> Parser<'a> { pub fn parse_seq_to_gt(&mut self, sep: Option, f: F) - -> PResult> where + -> PResult> where F: FnMut(&mut Parser) -> PResult, { let v = try!(self.parse_seq_to_before_gt(sep, f)); @@ -813,7 +812,7 @@ impl<'a> Parser<'a> { pub fn parse_seq_to_gt_or_return(&mut self, sep: Option, f: F) - -> PResult<(OwnedSlice, bool)> where + -> PResult<(P<[T]>, bool)> where F: FnMut(&mut Parser) -> PResult>, { let (v, returned) = try!(self.parse_seq_to_before_gt_or_return(sep, f)); @@ -1077,7 +1076,7 @@ impl<'a> Parser<'a> { let other_bounds = if try!(self.eat(&token::BinOp(token::Plus)) ){ try!(self.parse_ty_param_bounds(BoundParsingMode::Bare)) } else { - OwnedSlice::empty() + P::empty() }; let all_bounds = Some(TraitTyParamBound(poly_trait_ref, TraitBoundModifier::None)).into_iter() @@ -1710,8 +1709,8 @@ impl<'a> Parser<'a> { ast::AngleBracketedParameters(ast::AngleBracketedParameterData { lifetimes: lifetimes, - types: OwnedSlice::from_vec(types), - bindings: OwnedSlice::from_vec(bindings), + types: P::from_vec(types), + bindings: P::from_vec(bindings), }) } else if try!(self.eat(&token::OpenDelim(token::Paren)) ){ let lo = self.last_span.lo; @@ -1774,8 +1773,8 @@ impl<'a> Parser<'a> { identifier: identifier, parameters: ast::AngleBracketedParameters(ast::AngleBracketedParameterData { lifetimes: lifetimes, - types: OwnedSlice::from_vec(types), - bindings: OwnedSlice::from_vec(bindings), + types: P::from_vec(types), + bindings: P::from_vec(bindings), }), }); @@ -2813,16 +2812,25 @@ impl<'a> Parser<'a> { let rhs = try!(match op.fixity() { - Fixity::Right => self.with_res(restrictions, |this|{ - this.parse_assoc_expr_with(op.precedence(), LhsExpr::NotYetParsed) + Fixity::Right => self.with_res( + restrictions - Restrictions::RESTRICTION_STMT_EXPR, + |this| { + this.parse_assoc_expr_with(op.precedence(), + LhsExpr::NotYetParsed) }), - Fixity::Left => self.with_res(restrictions, |this|{ - this.parse_assoc_expr_with(op.precedence() + 1, LhsExpr::NotYetParsed) + Fixity::Left => self.with_res( + restrictions - Restrictions::RESTRICTION_STMT_EXPR, + |this| { + this.parse_assoc_expr_with(op.precedence() + 1, + LhsExpr::NotYetParsed) }), // We currently have no non-associative operators that are not handled above by // the special cases. The code is here only for future convenience. - Fixity::None => self.with_res(restrictions, |this|{ - this.parse_assoc_expr_with(op.precedence() + 1, LhsExpr::NotYetParsed) + Fixity::None => self.with_res( + restrictions - Restrictions::RESTRICTION_STMT_EXPR, + |this| { + this.parse_assoc_expr_with(op.precedence() + 1, + LhsExpr::NotYetParsed) }), }); @@ -3883,10 +3891,10 @@ impl<'a> Parser<'a> { // otherwise returns empty list. fn parse_colon_then_ty_param_bounds(&mut self, mode: BoundParsingMode) - -> PResult> + -> PResult { if !try!(self.eat(&token::Colon) ){ - Ok(OwnedSlice::empty()) + Ok(P::empty()) } else { self.parse_ty_param_bounds(mode) } @@ -3898,7 +3906,7 @@ impl<'a> Parser<'a> { // and bound = 'region | trait_ref fn parse_ty_param_bounds(&mut self, mode: BoundParsingMode) - -> PResult> + -> PResult { let mut result = vec!(); loop { @@ -3940,7 +3948,7 @@ impl<'a> Parser<'a> { } } - return Ok(OwnedSlice::from_vec(result)); + return Ok(P::from_vec(result)); } /// Matches typaram = IDENT (`?` unbound)? optbounds ( EQ ty )? diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 4e2289cb7f40..457d7d150dd9 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -17,7 +17,6 @@ use ast::Attribute; use attr::ThinAttributesExt; use util::parser::AssocOp; use attr; -use owned_slice::OwnedSlice; use attr::{AttrMetaMethods, AttributeMethods}; use codemap::{self, CodeMap, BytePos}; use diagnostic; @@ -1001,7 +1000,7 @@ impl<'a> State<'a> { ast::TyBareFn(ref f) => { let generics = ast::Generics { lifetimes: f.lifetimes.clone(), - ty_params: OwnedSlice::empty(), + ty_params: P::empty(), where_clause: ast::WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), @@ -3024,7 +3023,7 @@ impl<'a> State<'a> { } let generics = ast::Generics { lifetimes: Vec::new(), - ty_params: OwnedSlice::empty(), + ty_params: P::empty(), where_clause: ast::WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), diff --git a/src/libsyntax/ptr.rs b/src/libsyntax/ptr.rs index 83e321f110c5..1be0b08086d9 100644 --- a/src/libsyntax/ptr.rs +++ b/src/libsyntax/ptr.rs @@ -37,14 +37,15 @@ //! Moreover, a switch to, e.g. `P<'a, T>` would be easy and mostly automated. use std::fmt::{self, Display, Debug}; -use std::hash::{Hash, Hasher}; +use std::iter::FromIterator; use std::ops::Deref; -use std::ptr; +use std::{ptr, slice, vec}; use serialize::{Encodable, Decodable, Encoder, Decoder}; /// An owned smart pointer. -pub struct P { +#[derive(Hash, PartialEq, Eq, PartialOrd, Ord)] +pub struct P { ptr: Box } @@ -92,14 +93,6 @@ impl Clone for P { } } -impl PartialEq for P { - fn eq(&self, other: &P) -> bool { - **self == **other - } -} - -impl Eq for P {} - impl Debug for P { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { Debug::fmt(&**self, f) @@ -111,19 +104,12 @@ impl Display for P { } } -#[stable(feature = "rust1", since = "1.0.0")] impl fmt::Pointer for P { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Pointer::fmt(&self.ptr, f) } } -impl Hash for P { - fn hash(&self, state: &mut H) { - (**self).hash(state); - } -} - impl Decodable for P { fn decode(d: &mut D) -> Result, D::Error> { Decodable::decode(d).map(P) @@ -135,3 +121,87 @@ impl Encodable for P { (**self).encode(s) } } + + +impl fmt::Debug for P<[T]> { + fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { + self.ptr.fmt(fmt) + } +} + +impl P<[T]> { + pub fn empty() -> P<[T]> { + P { ptr: Default::default() } + } + + #[inline(never)] + pub fn from_vec(v: Vec) -> P<[T]> { + P { ptr: v.into_boxed_slice() } + } + + #[inline(never)] + pub fn into_vec(self) -> Vec { + self.ptr.into_vec() + } + + pub fn as_slice<'a>(&'a self) -> &'a [T] { + &*self.ptr + } + + pub fn move_iter(self) -> vec::IntoIter { + self.into_vec().into_iter() + } + + pub fn map U>(&self, f: F) -> P<[U]> { + self.iter().map(f).collect() + } +} + +impl Deref for P<[T]> { + type Target = [T]; + + fn deref(&self) -> &[T] { + self.as_slice() + } +} + +impl Default for P<[T]> { + fn default() -> P<[T]> { + P::empty() + } +} + +impl Clone for P<[T]> { + fn clone(&self) -> P<[T]> { + P::from_vec(self.to_vec()) + } +} + +impl FromIterator for P<[T]> { + fn from_iter>(iter: I) -> P<[T]> { + P::from_vec(iter.into_iter().collect()) + } +} + +impl<'a, T> IntoIterator for &'a P<[T]> { + type Item = &'a T; + type IntoIter = slice::Iter<'a, T>; + fn into_iter(self) -> Self::IntoIter { + self.ptr.into_iter() + } +} + +impl Encodable for P<[T]> { + fn encode(&self, s: &mut S) -> Result<(), S::Error> { + Encodable::encode(&**self, s) + } +} + +impl Decodable for P<[T]> { + fn decode(d: &mut D) -> Result, D::Error> { + Ok(P::from_vec(match Decodable::decode(d) { + Ok(t) => t, + Err(e) => return Err(e) + })) + } +} diff --git a/src/libsyntax/test.rs b/src/libsyntax/test.rs index 63fbe284a09f..e9581b9e05c5 100644 --- a/src/libsyntax/test.rs +++ b/src/libsyntax/test.rs @@ -32,7 +32,6 @@ use ext::expand::ExpansionConfig; use fold::Folder; use util::move_map::MoveMap; use fold; -use owned_slice::OwnedSlice; use parse::token::{intern, InternedString}; use parse::{token, ParseSess}; use print::pprust; diff --git a/src/libsyntax/util/move_map.rs b/src/libsyntax/util/move_map.rs index 95c24c66630f..e1078b719bf0 100644 --- a/src/libsyntax/util/move_map.rs +++ b/src/libsyntax/util/move_map.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use owned_slice::OwnedSlice; - use std::ptr; pub trait MoveMap: Sized { @@ -69,11 +67,11 @@ impl MoveMap for Vec { } } -impl MoveMap for OwnedSlice { +impl MoveMap for ::ptr::P<[T]> { fn move_flat_map(self, f: F) -> Self where F: FnMut(T) -> I, I: IntoIterator { - OwnedSlice::from_vec(self.into_vec().move_flat_map(f)) + ::ptr::P::from_vec(self.into_vec().move_flat_map(f)) } } diff --git a/src/libsyntax_ext/deriving/generic/mod.rs b/src/libsyntax_ext/deriving/generic/mod.rs index 5977144dae70..852458422685 100644 --- a/src/libsyntax_ext/deriving/generic/mod.rs +++ b/src/libsyntax_ext/deriving/generic/mod.rs @@ -205,7 +205,6 @@ use syntax::codemap::{self, DUMMY_SP}; use syntax::codemap::Span; use syntax::diagnostic::SpanHandler; use syntax::util::move_map::MoveMap; -use syntax::owned_slice::OwnedSlice; use syntax::parse::token::{intern, InternedString}; use syntax::parse::token::special_idents; use syntax::ptr::P; @@ -516,7 +515,7 @@ impl<'a> TraitDef<'a> { cx.typaram(self.span, ty_param.ident, - OwnedSlice::from_vec(bounds), + P::from_vec(bounds), None) })); @@ -528,7 +527,7 @@ impl<'a> TraitDef<'a> { span: self.span, bound_lifetimes: wb.bound_lifetimes.clone(), bounded_ty: wb.bounded_ty.clone(), - bounds: OwnedSlice::from_vec(wb.bounds.iter().cloned().collect()) + bounds: P::from_vec(wb.bounds.iter().cloned().collect()) }) } ast::WherePredicate::RegionPredicate(ref rb) => { @@ -579,7 +578,7 @@ impl<'a> TraitDef<'a> { span: self.span, bound_lifetimes: vec![], bounded_ty: ty, - bounds: OwnedSlice::from_vec(bounds), + bounds: P::from_vec(bounds), }; let predicate = ast::WherePredicate::BoundPredicate(predicate); @@ -590,7 +589,7 @@ impl<'a> TraitDef<'a> { let trait_generics = Generics { lifetimes: lifetimes, - ty_params: OwnedSlice::from_vec(ty_params), + ty_params: P::from_vec(ty_params), where_clause: where_clause }; diff --git a/src/libsyntax_ext/deriving/generic/ty.rs b/src/libsyntax_ext/deriving/generic/ty.rs index 0c4a81361aef..10564b5f6985 100644 --- a/src/libsyntax_ext/deriving/generic/ty.rs +++ b/src/libsyntax_ext/deriving/generic/ty.rs @@ -19,7 +19,6 @@ use syntax::ast::{Expr,Generics,Ident}; use syntax::ext::base::ExtCtxt; use syntax::ext::build::AstBuilder; use syntax::codemap::{Span,respan}; -use syntax::owned_slice::OwnedSlice; use syntax::parse::token::special_idents; use syntax::ptr::P; @@ -209,7 +208,7 @@ fn mk_generics(lifetimes: Vec, ty_params: Vec) -> Generics { Generics { lifetimes: lifetimes, - ty_params: OwnedSlice::from_vec(ty_params), + ty_params: P::from_vec(ty_params), where_clause: ast::WhereClause { id: ast::DUMMY_NODE_ID, predicates: Vec::new(), diff --git a/src/test/run-pass/issue-26873-multifile.rs b/src/test/run-pass/issue-26873-multifile.rs new file mode 100644 index 000000000000..e3da52203ced --- /dev/null +++ b/src/test/run-pass/issue-26873-multifile.rs @@ -0,0 +1,14 @@ +// Copyright 2015 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod issue_26873_multifile; + +fn main() {} + diff --git a/src/test/run-pass/issue-26873-onefile.rs b/src/test/run-pass/issue-26873-onefile.rs new file mode 100644 index 000000000000..a9a04fd88945 --- /dev/null +++ b/src/test/run-pass/issue-26873-onefile.rs @@ -0,0 +1,31 @@ +// Copyright 2015 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod A { + pub mod B { + use super::*; + + pub struct S; + } + + pub mod C { + use super::*; + use super::B::S; + + pub struct T; + } + + pub use self::C::T; +} + +use A::*; + +fn main() {} + diff --git a/src/test/run-pass/issue_26873_multifile/A/B.rs b/src/test/run-pass/issue_26873_multifile/A/B.rs new file mode 100644 index 000000000000..8917a98b8cf3 --- /dev/null +++ b/src/test/run-pass/issue_26873_multifile/A/B.rs @@ -0,0 +1,14 @@ +// Copyright 2015 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use super::*; + +pub struct S; + diff --git a/src/test/run-pass/issue_26873_multifile/A/C.rs b/src/test/run-pass/issue_26873_multifile/A/C.rs new file mode 100644 index 000000000000..64aaf9c27986 --- /dev/null +++ b/src/test/run-pass/issue_26873_multifile/A/C.rs @@ -0,0 +1,16 @@ +// Copyright 2015 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use super::*; + +use super::B::S; + +pub struct T { i: i32 } + diff --git a/src/test/run-pass/issue_26873_multifile/A/mod.rs b/src/test/run-pass/issue_26873_multifile/A/mod.rs new file mode 100644 index 000000000000..a2aeb1cc43f9 --- /dev/null +++ b/src/test/run-pass/issue_26873_multifile/A/mod.rs @@ -0,0 +1,15 @@ +// Copyright 2015 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub mod B; +pub mod C; + +pub use self::C::T; + diff --git a/src/test/run-pass/issue_26873_multifile/mod.rs b/src/test/run-pass/issue_26873_multifile/mod.rs new file mode 100644 index 000000000000..3643b94e31a8 --- /dev/null +++ b/src/test/run-pass/issue_26873_multifile/mod.rs @@ -0,0 +1,14 @@ +// Copyright 2015 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +mod A; + +use self::A::*; +