diff --git a/configure b/configure index 9a0143a353275..2700a7f6fe0ee 100755 --- a/configure +++ b/configure @@ -969,11 +969,11 @@ then LLVM_VERSION=$($LLVM_CONFIG --version) case $LLVM_VERSION in - (3.[5-8]*) + (3.[6-8]*) msg "found ok version of LLVM: $LLVM_VERSION" ;; (*) - err "bad LLVM version: $LLVM_VERSION, need >=3.5" + err "bad LLVM version: $LLVM_VERSION, need >=3.6" ;; esac fi diff --git a/mk/crates.mk b/mk/crates.mk index 54733083aaeb0..ae40a8e7f70dc 100644 --- a/mk/crates.mk +++ b/mk/crates.mk @@ -57,7 +57,7 @@ TARGET_CRATES := libc std term \ RUSTC_CRATES := rustc rustc_typeck rustc_mir rustc_borrowck rustc_resolve rustc_driver \ rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \ rustc_data_structures rustc_front rustc_platform_intrinsics \ - rustc_plugin rustc_metadata rustc_passes + rustc_plugin rustc_metadata rustc_passes rustc_save_analysis HOST_CRATES := syntax syntax_ext $(RUSTC_CRATES) rustdoc fmt_macros \ flate arena graphviz rbml log serialize TOOLS := compiletest rustdoc rustc rustbook error_index_generator @@ -102,7 +102,7 @@ DEPS_rustc_data_structures := std log serialize DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \ rustc_typeck rustc_mir rustc_resolve log syntax serialize rustc_llvm \ rustc_trans rustc_privacy rustc_lint rustc_front rustc_plugin \ - rustc_metadata syntax_ext rustc_passes + rustc_metadata syntax_ext rustc_passes rustc_save_analysis DEPS_rustc_front := std syntax log serialize DEPS_rustc_lint := rustc log syntax DEPS_rustc_llvm := native:rustllvm libc std rustc_bitflags @@ -116,6 +116,7 @@ DEPS_rustc_privacy := rustc rustc_front log syntax DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back rustc_mir \ log syntax serialize rustc_llvm rustc_front rustc_platform_intrinsics \ rustc_const_eval +DEPS_rustc_save_analysis := rustc log syntax rustc_front DEPS_rustc_typeck := rustc syntax rustc_front rustc_platform_intrinsics rustc_const_eval DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts \ diff --git a/src/bootstrap/mk/Makefile.in b/src/bootstrap/mk/Makefile.in index 7dd45a95a828b..9199c755f603e 100644 --- a/src/bootstrap/mk/Makefile.in +++ b/src/bootstrap/mk/Makefile.in @@ -38,8 +38,8 @@ standalone-docs: $(Q)$(BOOTSTRAP) --step doc-standalone check: $(Q)$(BOOTSTRAP) --step check -cargotest: - $(Q)$(BOOTSTRAP) --step cargotest +check-cargotest: + $(Q)$(BOOTSTRAP) --step check-cargotest dist: $(Q)$(BOOTSTRAP) --step dist diff --git a/src/doc/book/strings.md b/src/doc/book/strings.md index 5ed1f3de06249..f5ebceedd363a 100644 --- a/src/doc/book/strings.md +++ b/src/doc/book/strings.md @@ -44,6 +44,11 @@ let s = "foo\ assert_eq!("foobar", s); ``` +Note that you normally cannot access a `str` directly, but only through a `&str` +reference. This is because `str` is an unsized type which requires additional +runtime information to be usable. For more information see the chapter on +[unsized types][ut]. + Rust has more than only `&str`s though. A `String` is a heap-allocated string. This string is growable, and is also guaranteed to be UTF-8. `String`s are commonly created by converting from a string slice using the `to_string` @@ -185,5 +190,6 @@ let hello_world = hello + &world; This is because `&String` can automatically coerce to a `&str`. This is a feature called ‘[`Deref` coercions][dc]’. +[ut]: unsized-types.html [dc]: deref-coercions.html [connect]: ../std/net/struct.TcpStream.html#method.connect diff --git a/src/doc/reference.md b/src/doc/reference.md index 3325749d94cf8..fcf9aefaba847 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -3911,6 +3911,9 @@ The _heap_ is a general term that describes boxes. The lifetime of an allocation in the heap depends on the lifetime of the box values pointing to it. Since box values may themselves be passed in and out of frames, or stored in the heap, heap allocations may outlive the frame they are allocated within. +An allocation in the heap is guaranteed to reside at a single location in the +heap for the whole lifetime of the allocation - it will never be relocated as +a result of moving a box value. ### Memory ownership diff --git a/src/etc/CONFIGS.md b/src/etc/CONFIGS.md index 74837a06faecd..cde7094cec41e 100644 --- a/src/etc/CONFIGS.md +++ b/src/etc/CONFIGS.md @@ -10,7 +10,3 @@ These are some links to repos with configs which ease the use of rust. * [kate-config](https://github.com/rust-lang/kate-config) * [nano-config](https://github.com/rust-lang/nano-config) * [zsh-config](https://github.com/rust-lang/zsh-config) - -## Community-maintained Configs - -* [.editorconfig](https://gist.github.com/derhuerst/c9d1b9309e308d9851fa) ([what is this?](http://editorconfig.org/)) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 8f21f109e81b7..d5a5e2b47419f 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1953,7 +1953,10 @@ impl StrExt for str { #[inline] fn is_char_boundary(&self, index: usize) -> bool { - if index == self.len() { return true; } + // 0 and len are always ok. + // Test for 0 explicitly so that it can optimize out the check + // easily and skip reading string data for that case. + if index == 0 || index == self.len() { return true; } match self.as_bytes().get(index) { None => false, Some(&b) => b < 128 || b >= 192, @@ -2026,6 +2029,7 @@ impl StrExt for str { self.find(pat) } + #[inline] fn split_at(&self, mid: usize) -> (&str, &str) { // is_char_boundary checks that the index is in [0, .len()] if self.is_char_boundary(mid) { diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/cfg/construct.rs similarity index 99% rename from src/librustc/middle/cfg/construct.rs rename to src/librustc/cfg/construct.rs index dcfa8d1e36a21..e75625f7fae42 100644 --- a/src/librustc/middle/cfg/construct.rs +++ b/src/librustc/cfg/construct.rs @@ -9,10 +9,10 @@ // except according to those terms. use rustc_data_structures::graph; -use middle::cfg::*; +use cfg::*; use middle::def::Def; use middle::pat_util; -use middle::ty::{self, TyCtxt}; +use ty::{self, TyCtxt}; use syntax::ast; use syntax::ptr::P; diff --git a/src/librustc/middle/cfg/graphviz.rs b/src/librustc/cfg/graphviz.rs similarity index 99% rename from src/librustc/middle/cfg/graphviz.rs rename to src/librustc/cfg/graphviz.rs index c9c712c2d6e10..c867ec94b2510 100644 --- a/src/librustc/middle/cfg/graphviz.rs +++ b/src/librustc/cfg/graphviz.rs @@ -18,7 +18,7 @@ use graphviz::IntoCow; use syntax::ast; use front::map as ast_map; -use middle::cfg; +use cfg; pub type Node<'a> = (cfg::CFGIndex, &'a cfg::CFGNode); pub type Edge<'a> = &'a cfg::CFGEdge; diff --git a/src/librustc/middle/cfg/mod.rs b/src/librustc/cfg/mod.rs similarity index 98% rename from src/librustc/middle/cfg/mod.rs rename to src/librustc/cfg/mod.rs index 394633c59114d..8df4dc5fce596 100644 --- a/src/librustc/middle/cfg/mod.rs +++ b/src/librustc/cfg/mod.rs @@ -12,7 +12,7 @@ //! Uses `Graph` as the underlying representation. use rustc_data_structures::graph; -use middle::ty::TyCtxt; +use ty::TyCtxt; use syntax::ast; use rustc_front::hir; diff --git a/src/librustc/dep_graph/mod.rs b/src/librustc/dep_graph/mod.rs index 821217d75821c..731c33868dfbf 100644 --- a/src/librustc/dep_graph/mod.rs +++ b/src/librustc/dep_graph/mod.rs @@ -11,7 +11,7 @@ use self::thread::{DepGraphThreadData, DepMessage}; use middle::def_id::DefId; use syntax::ast::NodeId; -use middle::ty::TyCtxt; +use ty::TyCtxt; use rustc_front::hir; use rustc_front::intravisit::Visitor; use std::rc::Rc; diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index f474f7d4585f9..9348c05d44461 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -1261,7 +1261,7 @@ compiled: fn foo>(x: T){} #[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"] -trait Index { ... } +trait Index { /* ... */ } foo(true); // `bool` does not implement `Index` ``` @@ -1291,7 +1291,7 @@ compiled: fn foo>(x: T){} #[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"] -trait Index { ... } +trait Index { /* ... */ } foo(true); // `bool` does not implement `Index` ``` @@ -1319,7 +1319,7 @@ compiled: fn foo>(x: T){} #[rustc_on_unimplemented = "the type `{Self}` cannot be indexed by `{Idx}`"] -trait Index { ... } +trait Index { /* ... */ } foo(true); // `bool` does not implement `Index` ``` diff --git a/src/librustc/middle/infer/README.md b/src/librustc/infer/README.md similarity index 100% rename from src/librustc/middle/infer/README.md rename to src/librustc/infer/README.md diff --git a/src/librustc/middle/infer/bivariate.rs b/src/librustc/infer/bivariate.rs similarity index 97% rename from src/librustc/middle/infer/bivariate.rs rename to src/librustc/infer/bivariate.rs index 76a87675e3da6..a9ea395e6b3cd 100644 --- a/src/librustc/middle/infer/bivariate.rs +++ b/src/librustc/infer/bivariate.rs @@ -28,9 +28,9 @@ use super::combine::{self, CombineFields}; use super::type_variable::{BiTo}; -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::TyVar; -use middle::ty::relate::{Relate, RelateResult, TypeRelation}; +use ty::{self, Ty, TyCtxt}; +use ty::TyVar; +use ty::relate::{Relate, RelateResult, TypeRelation}; pub struct Bivariate<'a, 'tcx: 'a> { fields: CombineFields<'a, 'tcx> diff --git a/src/librustc/middle/infer/combine.rs b/src/librustc/infer/combine.rs similarity index 98% rename from src/librustc/middle/infer/combine.rs rename to src/librustc/infer/combine.rs index f67389e3c3b00..2b30698882d62 100644 --- a/src/librustc/middle/infer/combine.rs +++ b/src/librustc/infer/combine.rs @@ -41,11 +41,11 @@ use super::{InferCtxt}; use super::{MiscVariable, TypeTrace}; use super::type_variable::{RelationDir, BiTo, EqTo, SubtypeOf, SupertypeOf}; -use middle::ty::{IntType, UintType}; -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::error::TypeError; -use middle::ty::fold::{TypeFolder, TypeFoldable}; -use middle::ty::relate::{Relate, RelateResult, TypeRelation}; +use ty::{IntType, UintType}; +use ty::{self, Ty, TyCtxt}; +use ty::error::TypeError; +use ty::fold::{TypeFolder, TypeFoldable}; +use ty::relate::{Relate, RelateResult, TypeRelation}; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc/middle/infer/equate.rs b/src/librustc/infer/equate.rs similarity index 96% rename from src/librustc/middle/infer/equate.rs rename to src/librustc/infer/equate.rs index dd576c75ba3b4..3c9c9c5788414 100644 --- a/src/librustc/middle/infer/equate.rs +++ b/src/librustc/infer/equate.rs @@ -13,9 +13,9 @@ use super::higher_ranked::HigherRankedRelations; use super::{Subtype}; use super::type_variable::{EqTo}; -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::TyVar; -use middle::ty::relate::{Relate, RelateResult, TypeRelation}; +use ty::{self, Ty, TyCtxt}; +use ty::TyVar; +use ty::relate::{Relate, RelateResult, TypeRelation}; /// Ensures `a` is made equal to `b`. Returns `a` on success. pub struct Equate<'a, 'tcx: 'a> { diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/infer/error_reporting.rs similarity index 99% rename from src/librustc/middle/infer/error_reporting.rs rename to src/librustc/infer/error_reporting.rs index 089eae89d0492..20c0134414484 100644 --- a/src/librustc/middle/infer/error_reporting.rs +++ b/src/librustc/infer/error_reporting.rs @@ -80,12 +80,12 @@ use rustc_front::print::pprust; use middle::cstore::CrateStore; use middle::def::Def; use middle::def_id::DefId; -use middle::infer::{self, TypeOrigin}; +use infer::{self, TypeOrigin}; use middle::region; -use middle::subst; -use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; -use middle::ty::{Region, ReFree}; -use middle::ty::error::TypeError; +use ty::subst; +use ty::{self, Ty, TyCtxt, TypeFoldable}; +use ty::{Region, ReFree}; +use ty::error::TypeError; use std::cell::{Cell, RefCell}; use std::char::from_u32; diff --git a/src/librustc/middle/infer/freshen.rs b/src/librustc/infer/freshen.rs similarity index 98% rename from src/librustc/middle/infer/freshen.rs rename to src/librustc/infer/freshen.rs index b0f6d45dc53f1..352733a595da6 100644 --- a/src/librustc/middle/infer/freshen.rs +++ b/src/librustc/infer/freshen.rs @@ -30,8 +30,8 @@ //! variable only once, and it does so as soon as it can, so it is reasonable to ask what the type //! inferencer knows "so far". -use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; -use middle::ty::fold::TypeFolder; +use ty::{self, Ty, TyCtxt, TypeFoldable}; +use ty::fold::TypeFolder; use std::collections::hash_map::{self, Entry}; use super::InferCtxt; diff --git a/src/librustc/middle/infer/glb.rs b/src/librustc/infer/glb.rs similarity index 96% rename from src/librustc/middle/infer/glb.rs rename to src/librustc/infer/glb.rs index 7779be896cf57..235428a6898a9 100644 --- a/src/librustc/middle/infer/glb.rs +++ b/src/librustc/infer/glb.rs @@ -14,8 +14,8 @@ use super::InferCtxt; use super::lattice::{self, LatticeDir}; use super::Subtype; -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::relate::{Relate, RelateResult, TypeRelation}; +use ty::{self, Ty, TyCtxt}; +use ty::relate::{Relate, RelateResult, TypeRelation}; /// "Greatest lower bound" (common subtype) pub struct Glb<'a, 'tcx: 'a> { diff --git a/src/librustc/middle/infer/higher_ranked/README.md b/src/librustc/infer/higher_ranked/README.md similarity index 100% rename from src/librustc/middle/infer/higher_ranked/README.md rename to src/librustc/infer/higher_ranked/README.md diff --git a/src/librustc/middle/infer/higher_ranked/mod.rs b/src/librustc/infer/higher_ranked/mod.rs similarity index 99% rename from src/librustc/middle/infer/higher_ranked/mod.rs rename to src/librustc/infer/higher_ranked/mod.rs index 44ba6ec4a7a7d..db4ee17bafbbd 100644 --- a/src/librustc/middle/infer/higher_ranked/mod.rs +++ b/src/librustc/infer/higher_ranked/mod.rs @@ -14,9 +14,9 @@ use super::{CombinedSnapshot, InferCtxt, HigherRankedType, SkolemizationMap}; use super::combine::CombineFields; -use middle::ty::{self, TyCtxt, Binder, TypeFoldable}; -use middle::ty::error::TypeError; -use middle::ty::relate::{Relate, RelateResult, TypeRelation}; +use ty::{self, TyCtxt, Binder, TypeFoldable}; +use ty::error::TypeError; +use ty::relate::{Relate, RelateResult, TypeRelation}; use syntax::codemap::Span; use util::nodemap::{FnvHashMap, FnvHashSet}; diff --git a/src/librustc/middle/infer/lattice.rs b/src/librustc/infer/lattice.rs similarity index 96% rename from src/librustc/middle/infer/lattice.rs rename to src/librustc/infer/lattice.rs index dc4cbd14a5da2..17ad32e742e02 100644 --- a/src/librustc/middle/infer/lattice.rs +++ b/src/librustc/infer/lattice.rs @@ -32,9 +32,9 @@ use super::combine; use super::InferCtxt; -use middle::ty::TyVar; -use middle::ty::{self, Ty}; -use middle::ty::relate::{RelateResult, TypeRelation}; +use ty::TyVar; +use ty::{self, Ty}; +use ty::relate::{RelateResult, TypeRelation}; pub trait LatticeDir<'f,'tcx> : TypeRelation<'f,'tcx> { fn infcx(&self) -> &'f InferCtxt<'f, 'tcx>; diff --git a/src/librustc/middle/infer/lub.rs b/src/librustc/infer/lub.rs similarity index 96% rename from src/librustc/middle/infer/lub.rs rename to src/librustc/infer/lub.rs index 7202e4afc5a46..00b85929b4b15 100644 --- a/src/librustc/middle/infer/lub.rs +++ b/src/librustc/infer/lub.rs @@ -14,8 +14,8 @@ use super::InferCtxt; use super::lattice::{self, LatticeDir}; use super::Subtype; -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::relate::{Relate, RelateResult, TypeRelation}; +use ty::{self, Ty, TyCtxt}; +use ty::relate::{Relate, RelateResult, TypeRelation}; /// "Least upper bound" (common supertype) pub struct Lub<'a, 'tcx: 'a> { diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/infer/mod.rs similarity index 99% rename from src/librustc/middle/infer/mod.rs rename to src/librustc/infer/mod.rs index 645e5323ef4ae..bc4c9fd2ccfcf 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -14,7 +14,7 @@ pub use self::LateBoundRegionConversionTime::*; pub use self::RegionVariableOrigin::*; pub use self::SubregionOrigin::*; pub use self::ValuePairs::*; -pub use middle::ty::IntVarValue; +pub use ty::IntVarValue; pub use self::freshen::TypeFreshener; pub use self::region_inference::{GenericKind, VerifyBound}; @@ -24,16 +24,16 @@ use middle::free_region::FreeRegionMap; use middle::mem_categorization as mc; use middle::mem_categorization::McResult; use middle::region::CodeExtent; -use middle::subst; -use middle::subst::Substs; -use middle::subst::Subst; -use middle::traits::{self, ProjectionMode}; -use middle::ty::adjustment; -use middle::ty::{TyVid, IntVid, FloatVid}; -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric}; -use middle::ty::fold::{TypeFolder, TypeFoldable}; -use middle::ty::relate::{Relate, RelateResult, TypeRelation}; +use ty::subst; +use ty::subst::Substs; +use ty::subst::Subst; +use traits::{self, ProjectionMode}; +use ty::adjustment; +use ty::{TyVid, IntVid, FloatVid}; +use ty::{self, Ty, TyCtxt}; +use ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric}; +use ty::fold::{TypeFolder, TypeFoldable}; +use ty::relate::{Relate, RelateResult, TypeRelation}; use rustc_data_structures::unify::{self, UnificationTable}; use std::cell::{RefCell, Ref}; use std::fmt; @@ -622,8 +622,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { } pub fn type_is_unconstrained_numeric(&'a self, ty: Ty) -> UnconstrainedNumeric { - use middle::ty::error::UnconstrainedNumeric::Neither; - use middle::ty::error::UnconstrainedNumeric::{UnconstrainedInt, UnconstrainedFloat}; + use ty::error::UnconstrainedNumeric::Neither; + use ty::error::UnconstrainedNumeric::{UnconstrainedInt, UnconstrainedFloat}; match ty.sty { ty::TyInfer(ty::IntVar(vid)) => { if self.int_unification_table.borrow_mut().has_value(vid) { diff --git a/src/librustc/middle/infer/region_inference/README.md b/src/librustc/infer/region_inference/README.md similarity index 100% rename from src/librustc/middle/infer/region_inference/README.md rename to src/librustc/infer/region_inference/README.md diff --git a/src/librustc/middle/infer/region_inference/graphviz.rs b/src/librustc/infer/region_inference/graphviz.rs similarity index 98% rename from src/librustc/middle/infer/region_inference/graphviz.rs rename to src/librustc/infer/region_inference/graphviz.rs index 23559e7b340eb..e561f4a354891 100644 --- a/src/librustc/middle/infer/region_inference/graphviz.rs +++ b/src/librustc/infer/region_inference/graphviz.rs @@ -18,11 +18,11 @@ /// For clarity, rename the graphviz crate locally to dot. use graphviz as dot; -use middle::ty::{self, TyCtxt}; +use ty::{self, TyCtxt}; use middle::region::CodeExtent; use super::Constraint; -use middle::infer::SubregionOrigin; -use middle::infer::region_inference::RegionVarBindings; +use infer::SubregionOrigin; +use infer::region_inference::RegionVarBindings; use util::nodemap::{FnvHashMap, FnvHashSet}; use std::borrow::Cow; diff --git a/src/librustc/middle/infer/region_inference/mod.rs b/src/librustc/infer/region_inference/mod.rs similarity index 99% rename from src/librustc/middle/infer/region_inference/mod.rs rename to src/librustc/infer/region_inference/mod.rs index 7bba495e46779..2b74dcb40c4a3 100644 --- a/src/librustc/middle/infer/region_inference/mod.rs +++ b/src/librustc/infer/region_inference/mod.rs @@ -23,10 +23,10 @@ use super::unify_key; use rustc_data_structures::graph::{self, Direction, NodeIndex}; use rustc_data_structures::unify::{self, UnificationTable}; use middle::free_region::FreeRegionMap; -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::{BoundRegion, Region, RegionVid}; -use middle::ty::{ReEmpty, ReStatic, ReFree, ReEarlyBound}; -use middle::ty::{ReLateBound, ReScope, ReVar, ReSkolemized, BrFresh}; +use ty::{self, Ty, TyCtxt}; +use ty::{BoundRegion, Region, RegionVid}; +use ty::{ReEmpty, ReStatic, ReFree, ReEarlyBound}; +use ty::{ReLateBound, ReScope, ReVar, ReSkolemized, BrFresh}; use util::common::indenter; use util::nodemap::{FnvHashMap, FnvHashSet}; diff --git a/src/librustc/middle/infer/resolve.rs b/src/librustc/infer/resolve.rs similarity index 99% rename from src/librustc/middle/infer/resolve.rs rename to src/librustc/infer/resolve.rs index 8c6105898446a..c54843410adb8 100644 --- a/src/librustc/middle/infer/resolve.rs +++ b/src/librustc/infer/resolve.rs @@ -9,7 +9,7 @@ // except according to those terms. use super::{InferCtxt, FixupError, FixupResult}; -use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; +use ty::{self, Ty, TyCtxt, TypeFoldable}; /////////////////////////////////////////////////////////////////////////// // OPPORTUNISTIC TYPE RESOLVER diff --git a/src/librustc/middle/infer/sub.rs b/src/librustc/infer/sub.rs similarity index 96% rename from src/librustc/middle/infer/sub.rs rename to src/librustc/infer/sub.rs index e94311697c35a..0505c9d627b9b 100644 --- a/src/librustc/middle/infer/sub.rs +++ b/src/librustc/infer/sub.rs @@ -13,9 +13,9 @@ use super::higher_ranked::HigherRankedRelations; use super::SubregionOrigin; use super::type_variable::{SubtypeOf, SupertypeOf}; -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::TyVar; -use middle::ty::relate::{Cause, Relate, RelateResult, TypeRelation}; +use ty::{self, Ty, TyCtxt}; +use ty::TyVar; +use ty::relate::{Cause, Relate, RelateResult, TypeRelation}; use std::mem; /// Ensures `a` is made a subtype of `b`. Returns `a` on success. diff --git a/src/librustc/middle/infer/type_variable.rs b/src/librustc/infer/type_variable.rs similarity index 99% rename from src/librustc/middle/infer/type_variable.rs rename to src/librustc/infer/type_variable.rs index fe66ea5a1ea12..c8da346085d64 100644 --- a/src/librustc/middle/infer/type_variable.rs +++ b/src/librustc/infer/type_variable.rs @@ -12,7 +12,7 @@ pub use self::RelationDir::*; use self::TypeVariableValue::*; use self::UndoEntry::*; use middle::def_id::{DefId}; -use middle::ty::{self, Ty}; +use ty::{self, Ty}; use syntax::codemap::Span; use std::cmp::min; diff --git a/src/librustc/middle/infer/unify_key.rs b/src/librustc/infer/unify_key.rs similarity index 98% rename from src/librustc/middle/infer/unify_key.rs rename to src/librustc/infer/unify_key.rs index 3f8c3fbce047a..a9eb20b82997f 100644 --- a/src/librustc/middle/infer/unify_key.rs +++ b/src/librustc/infer/unify_key.rs @@ -9,7 +9,7 @@ // except according to those terms. use syntax::ast; -use middle::ty::{self, IntVarValue, Ty, TyCtxt}; +use ty::{self, IntVarValue, Ty, TyCtxt}; use rustc_data_structures::unify::{Combine, UnifyKey}; pub trait ToType<'tcx> { diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index d8d0079b3e398..4fdfe59e2b041 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -78,6 +78,7 @@ pub mod back { pub use rustc_back::svh; } +pub mod cfg; pub mod dep_graph; pub mod front { @@ -85,10 +86,12 @@ pub mod front { pub mod map; } +pub mod infer; +pub mod lint; + pub mod middle { pub mod astconv_util; pub mod expr_use_visitor; // STAGE0: increase glitch immunity - pub mod cfg; pub mod check_match; pub mod const_eval; pub mod const_qualif; @@ -102,7 +105,6 @@ pub mod middle { pub mod entry; pub mod free_region; pub mod intrinsicck; - pub mod infer; pub mod lang_items; pub mod liveness; pub mod mem_categorization; @@ -113,9 +115,6 @@ pub mod middle { pub mod recursion_limit; pub mod resolve_lifetime; pub mod stability; - pub mod subst; - pub mod traits; - pub mod ty; pub mod weak_lang_items; } @@ -128,8 +127,8 @@ pub mod mir { } pub mod session; - -pub mod lint; +pub mod traits; +pub mod ty; pub mod util { pub use rustc_back::sha2; diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index f2371c1819fc4..879b894562092 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -136,6 +136,19 @@ declare_lint! { "type parameter default erroneously allowed in invalid location" } +declare_lint! { + pub ILLEGAL_FLOATING_POINT_CONSTANT_PATTERN, + Warn, + "floating-point constants cannot be used in patterns" +} + +declare_lint! { + pub ILLEGAL_STRUCT_OR_ENUM_CONSTANT_PATTERN, + Deny, + "constants of struct or enum type can only be used in a pattern if \ + the struct or enum has `#[derive(PartialEq, Eq)]`" +} + declare_lint! { pub MATCH_OF_UNIT_VARIANT_VIA_PAREN_DOTDOT, Deny, @@ -193,6 +206,8 @@ impl LintPass for HardwiredLints { PRIVATE_IN_PUBLIC, INACCESSIBLE_EXTERN_CRATE, INVALID_TYPE_PARAM_DEFAULT, + ILLEGAL_FLOATING_POINT_CONSTANT_PATTERN, + ILLEGAL_STRUCT_OR_ENUM_CONSTANT_PATTERN, MATCH_OF_UNIT_VARIANT_VIA_PAREN_DOTDOT, CONST_ERR, RAW_POINTER_DERIVE, diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 079a0c94cc5a5..8224422d45c97 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -27,7 +27,7 @@ use self::TargetLint::*; use dep_graph::DepNode; use middle::privacy::AccessLevels; -use middle::ty::TyCtxt; +use ty::TyCtxt; use session::{config, early_error, Session}; use lint::{Level, LevelSource, Lint, LintId, LintArray, LintPass}; use lint::{EarlyLintPass, EarlyLintPassObject, LateLintPass, LateLintPassObject}; diff --git a/src/librustc/middle/astconv_util.rs b/src/librustc/middle/astconv_util.rs index e17aaaca16e04..a6907aad297c1 100644 --- a/src/librustc/middle/astconv_util.rs +++ b/src/librustc/middle/astconv_util.rs @@ -15,7 +15,7 @@ */ use middle::def::Def; -use middle::ty::{Ty, TyCtxt}; +use ty::{Ty, TyCtxt}; use syntax::codemap::Span; use rustc_front::hir as ast; diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index b5e1d5899967f..79e4b7c0901bd 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -22,12 +22,12 @@ use middle::def_id::{DefId}; use middle::expr_use_visitor::{ConsumeMode, Delegate, ExprUseVisitor}; use middle::expr_use_visitor::{LoanCause, MutateMode}; use middle::expr_use_visitor as euv; -use middle::infer; +use infer; use middle::mem_categorization::{cmt}; use middle::pat_util::*; -use middle::traits::ProjectionMode; -use middle::ty::*; -use middle::ty; +use traits::ProjectionMode; +use ty::*; +use ty; use std::cmp::Ordering; use std::fmt; use std::iter::{FromIterator, IntoIterator, repeat}; @@ -478,15 +478,24 @@ impl<'a, 'tcx> Folder for StaticInliner<'a, 'tcx> { Some(Def::Const(did)) => { let substs = Some(self.tcx.node_id_item_substs(pat.id).substs); if let Some((const_expr, _)) = lookup_const_by_id(self.tcx, did, substs) { - const_expr_to_pat(self.tcx, const_expr, pat.span).map(|new_pat| { - - if let Some(ref mut renaming_map) = self.renaming_map { - // Record any renamings we do here - record_renamings(const_expr, &pat, renaming_map); + match const_expr_to_pat(self.tcx, const_expr, pat.id, pat.span) { + Ok(new_pat) => { + if let Some(ref mut map) = self.renaming_map { + // Record any renamings we do here + record_renamings(const_expr, &pat, map); + } + new_pat } - - new_pat - }) + Err(def_id) => { + self.failed = true; + self.tcx.sess.span_err( + pat.span, + &format!("constants of the type `{}` \ + cannot be used in patterns", + self.tcx.item_path_str(def_id))); + pat + } + } } else { self.failed = true; span_err!(self.tcx.sess, pat.span, E0158, diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index a8c2a73e72f51..fca2904979c64 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -16,14 +16,15 @@ use self::EvalHint::*; use front::map as ast_map; use front::map::blocks::FnLikeNode; +use lint; use middle::cstore::{self, CrateStore, InlinedItem}; -use middle::{infer, subst, traits}; +use {infer, traits}; use middle::def::Def; use middle::def_id::DefId; use middle::pat_util::def_to_path; -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::util::IntTypeExt; -use middle::traits::ProjectionMode; +use ty::{self, subst, Ty, TyCtxt}; +use ty::util::IntTypeExt; +use traits::ProjectionMode; use middle::astconv_util::ast_ty_to_prim_ty; use util::nodemap::NodeMap; @@ -323,10 +324,41 @@ impl ConstVal { } } -pub fn const_expr_to_pat(tcx: &TyCtxt, expr: &Expr, span: Span) -> P { +pub fn const_expr_to_pat(tcx: &ty::TyCtxt, expr: &Expr, pat_id: ast::NodeId, span: Span) + -> Result, DefId> { + let pat_ty = tcx.expr_ty(expr); + debug!("expr={:?} pat_ty={:?} pat_id={}", expr, pat_ty, pat_id); + match pat_ty.sty { + ty::TyFloat(_) => { + tcx.sess.add_lint( + lint::builtin::ILLEGAL_FLOATING_POINT_CONSTANT_PATTERN, + pat_id, + span, + format!("floating point constants cannot be used in patterns")); + } + ty::TyEnum(adt_def, _) | + ty::TyStruct(adt_def, _) => { + if !tcx.has_attr(adt_def.did, "structural_match") { + tcx.sess.add_lint( + lint::builtin::ILLEGAL_STRUCT_OR_ENUM_CONSTANT_PATTERN, + pat_id, + span, + format!("to use a constant of type `{}` \ + in a pattern, \ + `{}` must be annotated with `#[derive(PartialEq, Eq)]`", + tcx.item_path_str(adt_def.did), + tcx.item_path_str(adt_def.did))); + } + } + _ => { } + } + let pat = match expr.node { hir::ExprTup(ref exprs) => - PatKind::Tup(exprs.iter().map(|expr| const_expr_to_pat(tcx, &expr, span)).collect()), + PatKind::Tup(try!(exprs.iter() + .map(|expr| const_expr_to_pat(tcx, &expr, + pat_id, span)) + .collect())), hir::ExprCall(ref callee, ref args) => { let def = *tcx.def_map.borrow().get(&callee.id).unwrap(); @@ -336,31 +368,41 @@ pub fn const_expr_to_pat(tcx: &TyCtxt, expr: &Expr, span: Span) -> P { let path = match def.full_def() { Def::Struct(def_id) => def_to_path(tcx, def_id), Def::Variant(_, variant_did) => def_to_path(tcx, variant_did), - Def::Fn(..) => return P(hir::Pat { + Def::Fn(..) => return Ok(P(hir::Pat { id: expr.id, node: PatKind::Lit(P(expr.clone())), span: span, - }), + })), _ => unreachable!() }; - let pats = args.iter().map(|expr| const_expr_to_pat(tcx, &expr, span)).collect(); + let pats = try!(args.iter() + .map(|expr| const_expr_to_pat(tcx, &**expr, + pat_id, span)) + .collect()); PatKind::TupleStruct(path, Some(pats)) } hir::ExprStruct(ref path, ref fields, None) => { - let field_pats = fields.iter().map(|field| codemap::Spanned { - span: codemap::DUMMY_SP, - node: hir::FieldPat { - name: field.name.node, - pat: const_expr_to_pat(tcx, &field.expr, span), - is_shorthand: false, - }, - }).collect(); + let field_pats = + try!(fields.iter() + .map(|field| Ok(codemap::Spanned { + span: codemap::DUMMY_SP, + node: hir::FieldPat { + name: field.name.node, + pat: try!(const_expr_to_pat(tcx, &field.expr, + pat_id, span)), + is_shorthand: false, + }, + })) + .collect()); PatKind::Struct(path.clone(), field_pats, false) } hir::ExprVec(ref exprs) => { - let pats = exprs.iter().map(|expr| const_expr_to_pat(tcx, &expr, span)).collect(); + let pats = try!(exprs.iter() + .map(|expr| const_expr_to_pat(tcx, &expr, + pat_id, span)) + .collect()); PatKind::Vec(pats, None, hir::HirVec::new()) } @@ -373,7 +415,7 @@ pub fn const_expr_to_pat(tcx: &TyCtxt, expr: &Expr, span: Span) -> P { Some(Def::AssociatedConst(def_id)) => { let substs = Some(tcx.node_id_item_substs(expr.id).substs); let (expr, _ty) = lookup_const_by_id(tcx, def_id, substs).unwrap(); - return const_expr_to_pat(tcx, expr, span); + return const_expr_to_pat(tcx, expr, pat_id, span); }, _ => unreachable!(), } @@ -381,7 +423,7 @@ pub fn const_expr_to_pat(tcx: &TyCtxt, expr: &Expr, span: Span) -> P { _ => PatKind::Lit(P(expr.clone())) }; - P(hir::Pat { id: expr.id, node: pat, span: span }) + Ok(P(hir::Pat { id: expr.id, node: pat, span: span })) } pub fn eval_const_expr(tcx: &TyCtxt, e: &Expr) -> ConstVal { diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index f85d87413843e..53273c9e09600 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -26,7 +26,7 @@ use back::svh::Svh; use front::map as hir_map; use middle::def::{self, Def}; use middle::lang_items; -use middle::ty::{self, Ty, TyCtxt, VariantKind}; +use ty::{self, Ty, TyCtxt, VariantKind}; use middle::def_id::{DefId, DefIndex}; use mir::repr::Mir; use mir::mir_map::MirMap; @@ -454,8 +454,8 @@ pub mod tls { use serialize; use std::cell::Cell; use std::mem; - use middle::ty::{self, Ty, TyCtxt}; - use middle::subst::Substs; + use ty::{self, Ty, TyCtxt}; + use ty::subst::Substs; use middle::def_id::DefId; pub trait EncodingContext<'tcx> { diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index d8cffa3c2c9f9..6468187e219bf 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -14,9 +14,9 @@ //! and thus uses bitvectors. Your job is simply to specify the so-called //! GEN and KILL bits for each expression. -use middle::cfg; -use middle::cfg::CFGIndex; -use middle::ty::TyCtxt; +use cfg; +use cfg::CFGIndex; +use ty::TyCtxt; use std::io; use std::mem; use std::usize; diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 4ceac287d19df..2b8ed14701df5 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -17,8 +17,8 @@ use front::map as ast_map; use rustc_front::hir::{self, PatKind}; use rustc_front::intravisit::{self, Visitor}; -use middle::{pat_util, privacy, ty}; -use middle::ty::TyCtxt; +use middle::{pat_util, privacy}; +use ty::{self, TyCtxt}; use middle::def::Def; use middle::def_id::{DefId}; use lint; @@ -84,7 +84,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { } fn lookup_and_handle_definition(&mut self, id: &ast::NodeId) { - use middle::ty::TypeVariants::{TyEnum, TyStruct}; + use ty::TypeVariants::{TyEnum, TyStruct}; // If `bar` is a trait item, make sure to mark Foo as alive in `Foo::bar` self.tcx.tables.borrow().item_substs.get(id) diff --git a/src/librustc/middle/def.rs b/src/librustc/middle/def.rs index 6d4799749b93a..6cbcd41d84a40 100644 --- a/src/librustc/middle/def.rs +++ b/src/librustc/middle/def.rs @@ -9,7 +9,7 @@ // except according to those terms. use middle::def_id::DefId; -use middle::subst::ParamSpace; +use ty::subst::ParamSpace; use util::nodemap::NodeMap; use syntax::ast; use rustc_front::hir; diff --git a/src/librustc/middle/def_id.rs b/src/librustc/middle/def_id.rs index f5bdf28a4b134..a3b83ec5be4bd 100644 --- a/src/librustc/middle/def_id.rs +++ b/src/librustc/middle/def_id.rs @@ -9,7 +9,7 @@ // except according to those terms. use middle::cstore::LOCAL_CRATE; -use middle::ty; +use ty; use syntax::ast::CrateNum; use std::fmt; use std::u32; diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index d4ff4b797c839..fa949073f4e2b 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -14,8 +14,8 @@ use self::RootUnsafeContext::*; use dep_graph::DepNode; use middle::def::Def; -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::MethodCall; +use ty::{self, Ty, TyCtxt}; +use ty::MethodCall; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index ded64fa1d3057..744022d1d5ec4 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -22,9 +22,9 @@ use self::OverloadedCallType::*; use middle::pat_util; use middle::def::Def; use middle::def_id::{DefId}; -use middle::infer; +use infer; use middle::mem_categorization as mc; -use middle::ty::{self, TyCtxt, adjustment}; +use ty::{self, TyCtxt, adjustment}; use rustc_front::hir::{self, PatKind}; diff --git a/src/librustc/middle/free_region.rs b/src/librustc/middle/free_region.rs index cb45a3e2507c9..20f2c5ad43fbb 100644 --- a/src/librustc/middle/free_region.rs +++ b/src/librustc/middle/free_region.rs @@ -15,8 +15,8 @@ //! `TransitiveRelation` type and use that to decide when one free //! region outlives another and so forth. -use middle::ty::{self, TyCtxt, FreeRegion, Region}; -use middle::ty::wf::ImpliedBound; +use ty::{self, TyCtxt, FreeRegion, Region}; +use ty::wf::ImpliedBound; use rustc_data_structures::transitive_relation::TransitiveRelation; #[derive(Clone)] diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index 233e55cdbb5dd..939ea91cdd44e 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -11,9 +11,9 @@ use dep_graph::DepNode; use middle::def::Def; use middle::def_id::DefId; -use middle::subst::{Subst, Substs, EnumeratedItems}; -use middle::ty::{TransmuteRestriction, TyCtxt}; -use middle::ty::{self, Ty, TypeFoldable}; +use ty::subst::{Subst, Substs, EnumeratedItems}; +use ty::{TransmuteRestriction, TyCtxt}; +use ty::{self, Ty, TypeFoldable}; use std::fmt; diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index b08c2d6054c89..bb0b8ed91df86 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -26,7 +26,7 @@ use front::map as hir_map; use session::Session; use middle::cstore::CrateStore; use middle::def_id::DefId; -use middle::ty; +use ty; use middle::weak_lang_items; use util::nodemap::FnvHashMap; diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 9507c379b4fe1..f6eedb49e2476 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -112,10 +112,10 @@ use self::VarKind::*; use dep_graph::DepNode; use middle::def::*; use middle::pat_util; -use middle::ty::{self, TyCtxt, ParameterEnvironment}; -use middle::traits::{self, ProjectionMode}; -use middle::infer; -use middle::subst::Subst; +use ty::{self, TyCtxt, ParameterEnvironment}; +use traits::{self, ProjectionMode}; +use infer; +use ty::subst::Subst; use lint; use util::nodemap::NodeMap; diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index d2bc80a2cb203..6328f920cb741 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -73,11 +73,11 @@ use self::Aliasability::*; use middle::def_id::DefId; use front::map as ast_map; -use middle::infer; +use infer; use middle::const_qualif::ConstQualif; use middle::def::Def; -use middle::ty::adjustment; -use middle::ty::{self, Ty, TyCtxt}; +use ty::adjustment; +use ty::{self, Ty, TyCtxt}; use rustc_front::hir::{MutImmutable, MutMutable, PatKind}; use rustc_front::hir; diff --git a/src/librustc/middle/pat_util.rs b/src/librustc/middle/pat_util.rs index 81166945115bb..b2b1344c4bb75 100644 --- a/src/librustc/middle/pat_util.rs +++ b/src/librustc/middle/pat_util.rs @@ -10,7 +10,7 @@ use middle::def::*; use middle::def_id::DefId; -use middle::ty::TyCtxt; +use ty::TyCtxt; use util::nodemap::FnvHashMap; use syntax::ast; diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 601f069513d12..2e01a7fc249ec 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -19,7 +19,7 @@ use dep_graph::DepNode; use front::map as ast_map; use middle::def::Def; use middle::def_id::DefId; -use middle::ty::{self, TyCtxt}; +use ty::{self, TyCtxt}; use middle::privacy; use session::config; use util::nodemap::NodeSet; diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index eb375205deee1..1d1d05ea79f17 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -21,7 +21,7 @@ use front::map as ast_map; use session::Session; use util::nodemap::{FnvHashMap, NodeMap, NodeSet}; use middle::cstore::InlinedItem; -use middle::ty; +use ty; use std::cell::RefCell; use std::collections::hash_map::Entry; @@ -280,7 +280,7 @@ pub struct RegionMaps { /// hierarchy based on their lexical mapping. This is used to /// handle the relationships between regions in a fn and in a /// closure defined by that fn. See the "Modeling closures" - /// section of the README in middle::infer::region_inference for + /// section of the README in infer::region_inference for /// more details. fn_tree: RefCell>, } @@ -291,7 +291,7 @@ pub struct Context { /// of the innermost fn body. Each fn forms its own disjoint tree /// in the region hierarchy. These fn bodies are themselves /// arranged into a tree. See the "Modeling closures" section of - /// the README in middle::infer::region_inference for more + /// the README in infer::region_inference for more /// details. root_id: Option, @@ -460,7 +460,7 @@ impl RegionMaps { self.scope_map.borrow()[id.0 as usize].into_option() } - #[allow(dead_code)] // used in middle::cfg + #[allow(dead_code)] // used in cfg pub fn encl_scope(&self, id: CodeExtent) -> CodeExtent { //! Returns the narrowest scope that encloses `id`, if any. self.opt_encl_scope(id).unwrap() @@ -587,7 +587,7 @@ impl RegionMaps { // different functions. Compare those fn for lexical // nesting. The reasoning behind this is subtle. See the // "Modeling closures" section of the README in - // middle::infer::region_inference for more details. + // infer::region_inference for more details. let a_root_scope = self.code_extent_data(a_ancestors[a_index]); let b_root_scope = self.code_extent_data(a_ancestors[a_index]); return match (a_root_scope, b_root_scope) { diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index a80b130e5be5f..6342599bf734d 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -23,8 +23,8 @@ use front::map::Map; use session::Session; use middle::def::{Def, DefMap}; use middle::region; -use middle::subst; -use middle::ty; +use ty::subst; +use ty; use std::fmt; use std::mem::replace; use syntax::ast; diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 2d92742ed0f20..3a2f995a31824 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -20,7 +20,7 @@ use lint; use middle::cstore::{CrateStore, LOCAL_CRATE}; use middle::def::Def; use middle::def_id::{CRATE_DEF_INDEX, DefId}; -use middle::ty::{self, TyCtxt}; +use ty::{self, TyCtxt}; use middle::privacy::AccessLevels; use syntax::parse::token::InternedString; use syntax::codemap::{Span, DUMMY_SP}; diff --git a/src/librustc/mir/repr.rs b/src/librustc/mir/repr.rs index 47d923cbce359..b90738107834d 100644 --- a/src/librustc/mir/repr.rs +++ b/src/librustc/mir/repr.rs @@ -12,8 +12,8 @@ use graphviz::IntoCow; use middle::const_eval::ConstVal; use rustc_const_eval::{ConstUsize, ConstInt}; use middle::def_id::DefId; -use middle::subst::Substs; -use middle::ty::{self, AdtDef, ClosureSubsts, FnOutput, Region, Ty}; +use ty::subst::Substs; +use ty::{self, AdtDef, ClosureSubsts, FnOutput, Region, Ty}; use util::ppaux; use rustc_back::slice; use rustc_front::hir::InlineAsm; diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index c8a2bc440ce1d..46d99dbef8c61 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -14,9 +14,9 @@ */ use mir::repr::*; -use middle::subst::{Subst, Substs}; -use middle::ty::{self, AdtDef, Ty, TyCtxt}; -use middle::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; +use ty::subst::{Subst, Substs}; +use ty::{self, AdtDef, Ty, TyCtxt}; +use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; use rustc_front::hir; #[derive(Copy, Clone, Debug)] diff --git a/src/librustc/mir/transform.rs b/src/librustc/mir/transform.rs index afcb5b956319d..410e3f9d06628 100644 --- a/src/librustc/mir/transform.rs +++ b/src/librustc/mir/transform.rs @@ -10,7 +10,7 @@ use mir::mir_map::MirMap; use mir::repr::Mir; -use middle::ty::TyCtxt; +use ty::TyCtxt; use syntax::ast::NodeId; /// Various information about pass. diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index bc0056b0af02f..9fa502166ba9f 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -10,8 +10,8 @@ use middle::const_eval::ConstVal; use middle::def_id::DefId; -use middle::subst::Substs; -use middle::ty::{ClosureSubsts, FnOutput, Region, Ty}; +use ty::subst::Substs; +use ty::{ClosureSubsts, FnOutput, Region, Ty}; use mir::repr::*; use rustc_const_eval::ConstUsize; use rustc_data_structures::tuple_slice::TupleSlice; diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index b198eda181208..e0982656c69bc 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -246,7 +246,13 @@ impl Session { let lint_id = lint::LintId::of(lint); let mut lints = self.lints.borrow_mut(); match lints.get_mut(&id) { - Some(arr) => { arr.push((lint_id, sp, msg)); return; } + Some(arr) => { + let tuple = (lint_id, sp, msg); + if !arr.contains(&tuple) { + arr.push(tuple); + } + return; + } None => {} } lints.insert(id, vec!((lint_id, sp, msg))); diff --git a/src/librustc/middle/traits/README.md b/src/librustc/traits/README.md similarity index 100% rename from src/librustc/middle/traits/README.md rename to src/librustc/traits/README.md diff --git a/src/librustc/middle/traits/coherence.rs b/src/librustc/traits/coherence.rs similarity index 98% rename from src/librustc/middle/traits/coherence.rs rename to src/librustc/traits/coherence.rs index 64d1c992cbf1d..b5b5da6208034 100644 --- a/src/librustc/middle/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -14,9 +14,9 @@ use super::{SelectionContext, Obligation, ObligationCause}; use middle::cstore::LOCAL_CRATE; use middle::def_id::DefId; -use middle::subst::TypeSpace; -use middle::ty::{self, Ty, TyCtxt}; -use middle::infer::{self, InferCtxt, TypeOrigin}; +use ty::subst::TypeSpace; +use ty::{self, Ty, TyCtxt}; +use infer::{self, InferCtxt, TypeOrigin}; use syntax::codemap::DUMMY_SP; #[derive(Copy, Clone)] diff --git a/src/librustc/middle/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs similarity index 99% rename from src/librustc/middle/traits/error_reporting.rs rename to src/librustc/traits/error_reporting.rs index dd051471a4d1b..c26aaeaf14316 100644 --- a/src/librustc/middle/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -25,9 +25,9 @@ use super::{ use fmt_macros::{Parser, Piece, Position}; use middle::def_id::DefId; -use middle::infer::InferCtxt; -use middle::ty::{self, ToPredicate, ToPolyTraitRef, TraitRef, Ty, TyCtxt, TypeFoldable}; -use middle::ty::fast_reject; +use infer::InferCtxt; +use ty::{self, ToPredicate, ToPolyTraitRef, TraitRef, Ty, TyCtxt, TypeFoldable}; +use ty::fast_reject; use util::nodemap::{FnvHashMap, FnvHashSet}; use std::cmp; diff --git a/src/librustc/middle/traits/fulfill.rs b/src/librustc/traits/fulfill.rs similarity index 99% rename from src/librustc/middle/traits/fulfill.rs rename to src/librustc/traits/fulfill.rs index 937196b5e8e7a..67bb8c89ddf62 100644 --- a/src/librustc/middle/traits/fulfill.rs +++ b/src/librustc/traits/fulfill.rs @@ -9,8 +9,8 @@ // except according to those terms. use dep_graph::DepGraph; -use middle::infer::InferCtxt; -use middle::ty::{self, Ty, TyCtxt, TypeFoldable, ToPolyTraitRef}; +use infer::InferCtxt; +use ty::{self, Ty, TyCtxt, TypeFoldable, ToPolyTraitRef}; use rustc_data_structures::obligation_forest::{Backtrace, ObligationForest, Error}; use std::iter; use syntax::ast; diff --git a/src/librustc/middle/traits/mod.rs b/src/librustc/traits/mod.rs similarity index 99% rename from src/librustc/middle/traits/mod.rs rename to src/librustc/traits/mod.rs index 5f66e9e6344ad..867bd054fa9dd 100644 --- a/src/librustc/middle/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -17,9 +17,9 @@ pub use self::ObligationCauseCode::*; use middle::def_id::DefId; use middle::free_region::FreeRegionMap; -use middle::subst; -use middle::ty::{self, Ty, TypeFoldable}; -use middle::infer::{self, fixup_err_to_string, InferCtxt}; +use ty::subst; +use ty::{self, Ty, TypeFoldable}; +use infer::{self, fixup_err_to_string, InferCtxt}; use std::rc::Rc; use syntax::ast; diff --git a/src/librustc/middle/traits/object_safety.rs b/src/librustc/traits/object_safety.rs similarity index 99% rename from src/librustc/middle/traits/object_safety.rs rename to src/librustc/traits/object_safety.rs index 4a0da521eef30..7cd2ac5938d41 100644 --- a/src/librustc/middle/traits/object_safety.rs +++ b/src/librustc/traits/object_safety.rs @@ -21,9 +21,9 @@ use super::supertraits; use super::elaborate_predicates; use middle::def_id::DefId; -use middle::subst::{self, SelfSpace, TypeSpace}; -use middle::traits; -use middle::ty::{self, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable}; +use ty::subst::{self, SelfSpace, TypeSpace}; +use traits; +use ty::{self, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable}; use std::rc::Rc; use syntax::ast; diff --git a/src/librustc/middle/traits/project.rs b/src/librustc/traits/project.rs similarity index 99% rename from src/librustc/middle/traits/project.rs rename to src/librustc/traits/project.rs index e86f3ed01a49d..3adaf5fa6bb2f 100644 --- a/src/librustc/middle/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -24,10 +24,10 @@ use super::VtableImplData; use super::util; use middle::def_id::DefId; -use middle::infer::{self, TypeOrigin}; -use middle::subst::Subst; -use middle::ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt}; -use middle::ty::fold::{TypeFoldable, TypeFolder}; +use infer::{self, TypeOrigin}; +use ty::subst::Subst; +use ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt}; +use ty::fold::{TypeFoldable, TypeFolder}; use syntax::parse::token; use syntax::ast; use util::common::FN_OUTPUT_NAME; diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/traits/select.rs similarity index 99% rename from src/librustc/middle/traits/select.rs rename to src/librustc/traits/select.rs index 3eaf123e5be58..e2a48688d4bbc 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -37,13 +37,13 @@ use super::object_safety; use super::util; use middle::def_id::DefId; -use middle::infer; -use middle::infer::{InferCtxt, TypeFreshener, TypeOrigin}; -use middle::subst::{Subst, Substs, TypeSpace}; -use middle::ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable}; -use middle::traits; -use middle::ty::fast_reject; -use middle::ty::relate::TypeRelation; +use infer; +use infer::{InferCtxt, TypeFreshener, TypeOrigin}; +use ty::subst::{Subst, Substs, TypeSpace}; +use ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable}; +use traits; +use ty::fast_reject; +use ty::relate::TypeRelation; use std::cell::RefCell; use std::fmt; diff --git a/src/librustc/middle/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs similarity index 98% rename from src/librustc/middle/traits/specialize/mod.rs rename to src/librustc/traits/specialize/mod.rs index 92478f2874e1e..e0ce54115ebc2 100644 --- a/src/librustc/middle/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -22,11 +22,11 @@ use super::util::{fresh_type_vars_for_impl, impl_trait_ref_and_oblig}; use middle::cstore::CrateStore; use middle::def_id::DefId; -use middle::infer::{self, InferCtxt, TypeOrigin}; +use infer::{self, InferCtxt, TypeOrigin}; use middle::region; -use middle::subst::{Subst, Substs}; -use middle::traits::{self, ProjectionMode, ObligationCause, Normalized}; -use middle::ty::{self, TyCtxt}; +use ty::subst::{Subst, Substs}; +use traits::{self, ProjectionMode, ObligationCause, Normalized}; +use ty::{self, TyCtxt}; use syntax::codemap::DUMMY_SP; pub mod specialization_graph; diff --git a/src/librustc/middle/traits/specialize/specialization_graph.rs b/src/librustc/traits/specialize/specialization_graph.rs similarity index 99% rename from src/librustc/middle/traits/specialize/specialization_graph.rs rename to src/librustc/traits/specialize/specialization_graph.rs index f2170f75a11fe..eaafeb1a969b3 100644 --- a/src/librustc/middle/traits/specialize/specialization_graph.rs +++ b/src/librustc/traits/specialize/specialization_graph.rs @@ -15,9 +15,9 @@ use super::{Overlap, specializes}; use middle::cstore::CrateStore; use middle::def_id::DefId; -use middle::infer; -use middle::traits::{self, ProjectionMode}; -use middle::ty::{self, TyCtxt, ImplOrTraitItem, TraitDef, TypeFoldable}; +use infer; +use traits::{self, ProjectionMode}; +use ty::{self, TyCtxt, ImplOrTraitItem, TraitDef, TypeFoldable}; use syntax::ast::Name; use util::nodemap::DefIdMap; diff --git a/src/librustc/middle/traits/structural_impls.rs b/src/librustc/traits/structural_impls.rs similarity index 98% rename from src/librustc/middle/traits/structural_impls.rs rename to src/librustc/traits/structural_impls.rs index 903b7c80bafab..367e5f32ba3ec 100644 --- a/src/librustc/middle/traits/structural_impls.rs +++ b/src/librustc/traits/structural_impls.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::traits; -use middle::traits::project::Normalized; -use middle::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; +use traits; +use traits::project::Normalized; +use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; use std::fmt; -// structural impls for the structs in middle::traits +// structural impls for the structs in traits impl<'tcx, T: fmt::Debug> fmt::Debug for Normalized<'tcx, T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/librustc/middle/traits/util.rs b/src/librustc/traits/util.rs similarity index 99% rename from src/librustc/middle/traits/util.rs rename to src/librustc/traits/util.rs index 9f984bc1fc63a..f339b6e50cedd 100644 --- a/src/librustc/middle/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -9,9 +9,9 @@ // except according to those terms. use middle::def_id::DefId; -use middle::infer::InferCtxt; -use middle::subst::{Subst, Substs}; -use middle::ty::{self, Ty, TyCtxt, ToPredicate, ToPolyTraitRef}; +use infer::InferCtxt; +use ty::subst::{Subst, Substs}; +use ty::{self, Ty, TyCtxt, ToPredicate, ToPolyTraitRef}; use syntax::codemap::Span; use util::common::ErrorReported; use util::nodemap::FnvHashSet; diff --git a/src/librustc/middle/ty/_match.rs b/src/librustc/ty/_match.rs similarity index 96% rename from src/librustc/middle/ty/_match.rs rename to src/librustc/ty/_match.rs index fe54334da3db6..d0ccc3e0fdd80 100644 --- a/src/librustc/middle/ty/_match.rs +++ b/src/librustc/ty/_match.rs @@ -8,9 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::error::TypeError; -use middle::ty::relate::{self, Relate, TypeRelation, RelateResult}; +use ty::{self, Ty, TyCtxt}; +use ty::error::TypeError; +use ty::relate::{self, Relate, TypeRelation, RelateResult}; /// A type "A" *matches* "B" if the fresh types in B could be /// substituted with values so as to make it equal to A. Matching is diff --git a/src/librustc/middle/ty/adjustment.rs b/src/librustc/ty/adjustment.rs similarity index 98% rename from src/librustc/middle/ty/adjustment.rs rename to src/librustc/ty/adjustment.rs index e4c293a74e896..dc2117b1ad119 100644 --- a/src/librustc/middle/ty/adjustment.rs +++ b/src/librustc/ty/adjustment.rs @@ -11,8 +11,8 @@ pub use self::AutoAdjustment::*; pub use self::AutoRef::*; -use middle::ty::{self, Ty, TyCtxt, TypeAndMut, TypeFoldable}; -use middle::ty::LvaluePreference::{NoPreference}; +use ty::{self, Ty, TyCtxt, TypeAndMut, TypeFoldable}; +use ty::LvaluePreference::{NoPreference}; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc/middle/ty/cast.rs b/src/librustc/ty/cast.rs similarity index 98% rename from src/librustc/middle/ty/cast.rs rename to src/librustc/ty/cast.rs index b25d6e0476d98..c8d282d18af1d 100644 --- a/src/librustc/middle/ty/cast.rs +++ b/src/librustc/ty/cast.rs @@ -11,7 +11,7 @@ // Helpers for handling cast expressions, used in both // typeck and trans. -use middle::ty::{self, Ty}; +use ty::{self, Ty}; use syntax::ast; diff --git a/src/librustc/middle/ty/contents.rs b/src/librustc/ty/contents.rs similarity index 99% rename from src/librustc/middle/ty/contents.rs rename to src/librustc/ty/contents.rs index 47a15a14b41ee..cb84b198222a2 100644 --- a/src/librustc/middle/ty/contents.rs +++ b/src/librustc/ty/contents.rs @@ -9,7 +9,7 @@ // except according to those terms. use middle::def_id::{DefId}; -use middle::ty::{self, Ty, TyCtxt}; +use ty::{self, Ty, TyCtxt}; use util::common::MemoizationMap; use util::nodemap::FnvHashMap; diff --git a/src/librustc/middle/ty/context.rs b/src/librustc/ty/context.rs similarity index 98% rename from src/librustc/middle/ty/context.rs rename to src/librustc/ty/context.rs index 03c13115aea62..3803297fcc1c8 100644 --- a/src/librustc/middle/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -22,16 +22,16 @@ use middle::free_region::FreeRegionMap; use middle::region::RegionMaps; use middle::resolve_lifetime; use middle::stability; -use middle::subst::{self, Subst, Substs}; -use middle::traits; -use middle::ty::{self, TraitRef, Ty, TypeAndMut}; -use middle::ty::{TyS, TypeVariants}; -use middle::ty::{AdtDef, ClosureSubsts, ExistentialBounds, Region}; -use middle::ty::{FreevarMap}; -use middle::ty::{BareFnTy, InferTy, ParamTy, ProjectionTy, TraitTy}; -use middle::ty::{TyVar, TyVid, IntVar, IntVid, FloatVar, FloatVid}; -use middle::ty::TypeVariants::*; -use middle::ty::maps; +use ty::subst::{self, Subst, Substs}; +use traits; +use ty::{self, TraitRef, Ty, TypeAndMut}; +use ty::{TyS, TypeVariants}; +use ty::{AdtDef, ClosureSubsts, ExistentialBounds, Region}; +use ty::{FreevarMap}; +use ty::{BareFnTy, InferTy, ParamTy, ProjectionTy, TraitTy}; +use ty::{TyVar, TyVid, IntVar, IntVid, FloatVar, FloatVid}; +use ty::TypeVariants::*; +use ty::maps; use util::common::MemoizationMap; use util::nodemap::{NodeMap, NodeSet, DefIdMap, DefIdSet}; use util::nodemap::FnvHashMap; @@ -617,7 +617,7 @@ impl<'a, 'tcx> Lift<'tcx> for &'a Substs<'a> { pub mod tls { - use middle::ty::TyCtxt; + use ty::TyCtxt; use std::cell::Cell; use std::fmt; @@ -677,7 +677,7 @@ macro_rules! sty_debug_print { // variable names. #[allow(non_snake_case)] mod inner { - use middle::ty::{self, TyCtxt}; + use ty::{self, TyCtxt}; #[derive(Copy, Clone)] struct DebugStat { total: usize, diff --git a/src/librustc/middle/ty/error.rs b/src/librustc/ty/error.rs similarity index 99% rename from src/librustc/middle/ty/error.rs rename to src/librustc/ty/error.rs index 1033af5f331a7..9ab4850582853 100644 --- a/src/librustc/middle/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -9,9 +9,9 @@ // except according to those terms. use middle::def_id::DefId; -use middle::subst; -use middle::infer::type_variable; -use middle::ty::{self, BoundRegion, Region, Ty, TyCtxt}; +use ty::subst; +use infer::type_variable; +use ty::{self, BoundRegion, Region, Ty, TyCtxt}; use std::fmt; use syntax::abi; diff --git a/src/librustc/middle/ty/fast_reject.rs b/src/librustc/ty/fast_reject.rs similarity index 99% rename from src/librustc/middle/ty/fast_reject.rs rename to src/librustc/ty/fast_reject.rs index fc4db22a8a62f..0865e059f59c5 100644 --- a/src/librustc/middle/ty/fast_reject.rs +++ b/src/librustc/ty/fast_reject.rs @@ -9,7 +9,7 @@ // except according to those terms. use middle::def_id::DefId; -use middle::ty::{self, Ty, TyCtxt}; +use ty::{self, Ty, TyCtxt}; use syntax::ast; use self::SimplifiedType::*; diff --git a/src/librustc/middle/ty/flags.rs b/src/librustc/ty/flags.rs similarity index 98% rename from src/librustc/middle/ty/flags.rs rename to src/librustc/ty/flags.rs index c874e9b7ca52d..f3dcccedc594b 100644 --- a/src/librustc/middle/ty/flags.rs +++ b/src/librustc/ty/flags.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::subst; -use middle::ty::{self, Ty, TypeFlags, TypeFoldable}; +use ty::subst; +use ty::{self, Ty, TypeFlags, TypeFoldable}; pub struct FlagComputation { pub flags: TypeFlags, diff --git a/src/librustc/middle/ty/fold.rs b/src/librustc/ty/fold.rs similarity index 99% rename from src/librustc/middle/ty/fold.rs rename to src/librustc/ty/fold.rs index f754e5c5a0a7d..d04f272688c8c 100644 --- a/src/librustc/middle/ty/fold.rs +++ b/src/librustc/ty/fold.rs @@ -40,9 +40,9 @@ //! and does not need to visit anything else. use middle::region; -use middle::subst; -use middle::ty::adjustment; -use middle::ty::{self, Binder, Ty, TyCtxt, TypeFlags}; +use ty::subst; +use ty::adjustment; +use ty::{self, Binder, Ty, TyCtxt, TypeFlags}; use std::fmt; use util::nodemap::{FnvHashMap, FnvHashSet}; diff --git a/src/librustc/middle/ty/ivar.rs b/src/librustc/ty/ivar.rs similarity index 98% rename from src/librustc/middle/ty/ivar.rs rename to src/librustc/ty/ivar.rs index ffc12aa5aea19..b0f443fc19b42 100644 --- a/src/librustc/middle/ty/ivar.rs +++ b/src/librustc/ty/ivar.rs @@ -9,8 +9,8 @@ // except according to those terms. use dep_graph::DepNode; -use middle::ty::{Ty, TyS}; -use middle::ty::tls; +use ty::{Ty, TyS}; +use ty::tls; use rustc_data_structures::ivar; diff --git a/src/librustc/middle/ty/maps.rs b/src/librustc/ty/maps.rs similarity index 99% rename from src/librustc/middle/ty/maps.rs rename to src/librustc/ty/maps.rs index 8d8afc199f59e..77b6b03e48fe9 100644 --- a/src/librustc/middle/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -10,7 +10,7 @@ use dep_graph::{DepNode, DepTrackingMapConfig}; use middle::def_id::DefId; -use middle::ty; +use ty; use std::marker::PhantomData; use std::rc::Rc; use syntax::{attr, ast}; diff --git a/src/librustc/middle/ty/mod.rs b/src/librustc/ty/mod.rs similarity index 99% rename from src/librustc/middle/ty/mod.rs rename to src/librustc/ty/mod.rs index 050024d0e94ea..82f08a5a73d28 100644 --- a/src/librustc/middle/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -27,11 +27,11 @@ use middle::def::{self, Def, ExportMap}; use middle::def_id::DefId; use middle::lang_items::{FnTraitLangItem, FnMutTraitLangItem, FnOnceTraitLangItem}; use middle::region::{CodeExtent}; -use middle::subst::{self, Subst, Substs, VecPerParamSpace}; -use middle::traits; -use middle::ty; -use middle::ty::fold::TypeFolder; -use middle::ty::walk::TypeWalker; +use traits; +use ty; +use ty::fold::TypeFolder; +use ty::subst::{Subst, Substs, VecPerParamSpace}; +use ty::walk::TypeWalker; use util::common::MemoizationMap; use util::nodemap::{NodeMap, NodeSet}; use util::nodemap::FnvHashMap; @@ -90,6 +90,7 @@ pub mod _match; pub mod maps; pub mod outlives; pub mod relate; +pub mod subst; pub mod trait_def; pub mod walk; pub mod wf; diff --git a/src/librustc/middle/ty/outlives.rs b/src/librustc/ty/outlives.rs similarity index 99% rename from src/librustc/middle/ty/outlives.rs rename to src/librustc/ty/outlives.rs index 9439180a6cd21..898c9d65c7826 100644 --- a/src/librustc/middle/ty/outlives.rs +++ b/src/librustc/ty/outlives.rs @@ -12,8 +12,8 @@ // refers to rules defined in RFC 1214 (`OutlivesFooBar`), so see that // RFC for reference. -use middle::infer::InferCtxt; -use middle::ty::{self, Ty, TypeFoldable}; +use infer::InferCtxt; +use ty::{self, Ty, TypeFoldable}; #[derive(Debug)] pub enum Component<'tcx> { diff --git a/src/librustc/middle/ty/relate.rs b/src/librustc/ty/relate.rs similarity index 99% rename from src/librustc/middle/ty/relate.rs rename to src/librustc/ty/relate.rs index 563ff346a6440..bb4f13b13c1ec 100644 --- a/src/librustc/middle/ty/relate.rs +++ b/src/librustc/ty/relate.rs @@ -14,9 +14,9 @@ //! type equality, etc. use middle::def_id::DefId; -use middle::subst::{ParamSpace, Substs}; -use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; -use middle::ty::error::{ExpectedFound, TypeError}; +use ty::subst::{ParamSpace, Substs}; +use ty::{self, Ty, TyCtxt, TypeFoldable}; +use ty::error::{ExpectedFound, TypeError}; use std::rc::Rc; use syntax::abi; use rustc_front::hir as ast; diff --git a/src/librustc/middle/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs similarity index 99% rename from src/librustc/middle/ty/structural_impls.rs rename to src/librustc/ty/structural_impls.rs index 0358fa2f12455..6fca1eef701c0 100644 --- a/src/librustc/middle/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::subst::{self, VecPerParamSpace}; -use middle::traits; -use middle::ty::{self, Lift, TraitRef, Ty, TyCtxt}; -use middle::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; +use ty::subst::{self, VecPerParamSpace}; +use traits; +use ty::{self, Lift, TraitRef, Ty, TyCtxt}; +use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; use std::rc::Rc; use syntax::abi; diff --git a/src/librustc/middle/ty/sty.rs b/src/librustc/ty/sty.rs similarity index 99% rename from src/librustc/middle/ty/sty.rs rename to src/librustc/ty/sty.rs index 7a17b24df5e9d..dae12824da251 100644 --- a/src/librustc/middle/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -13,9 +13,9 @@ use middle::cstore; use middle::def_id::DefId; use middle::region; -use middle::subst::{self, Substs}; -use middle::traits; -use middle::ty::{self, AdtDef, ToPredicate, TypeFlags, Ty, TyCtxt, TyS, TypeFoldable}; +use ty::subst::{self, Substs}; +use traits; +use ty::{self, AdtDef, ToPredicate, TypeFlags, Ty, TyCtxt, TyS, TypeFoldable}; use util::common::ErrorReported; use collections::enum_set::{self, EnumSet, CLike}; @@ -732,7 +732,7 @@ pub enum InferTy { /// A `FreshTy` is one that is generated as a replacement for an /// unbound type variable. This is convenient for caching etc. See - /// `middle::infer::freshen` for more details. + /// `infer::freshen` for more details. FreshTy(u32), FreshIntTy(u32), FreshFloatTy(u32) diff --git a/src/librustc/middle/subst.rs b/src/librustc/ty/subst.rs similarity index 99% rename from src/librustc/middle/subst.rs rename to src/librustc/ty/subst.rs index b9bf550704e02..8d25728212109 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/ty/subst.rs @@ -14,8 +14,8 @@ pub use self::ParamSpace::*; use middle::cstore; use middle::def_id::DefId; -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::fold::{TypeFoldable, TypeFolder}; +use ty::{self, Ty, TyCtxt}; +use ty::fold::{TypeFoldable, TypeFolder}; use serialize::{Encodable, Encoder, Decodable, Decoder}; use std::fmt; diff --git a/src/librustc/middle/ty/trait_def.rs b/src/librustc/ty/trait_def.rs similarity index 98% rename from src/librustc/middle/ty/trait_def.rs rename to src/librustc/ty/trait_def.rs index 3d7b3bf263425..3ebf2ba4c849f 100644 --- a/src/librustc/middle/ty/trait_def.rs +++ b/src/librustc/ty/trait_def.rs @@ -10,10 +10,10 @@ use dep_graph::DepNode; use middle::def_id::DefId; -use middle::traits::{self, specialization_graph}; -use middle::ty; -use middle::ty::fast_reject; -use middle::ty::{Ty, TyCtxt, TraitRef}; +use traits::{self, specialization_graph}; +use ty; +use ty::fast_reject; +use ty::{Ty, TyCtxt, TraitRef}; use std::borrow::{Borrow}; use std::cell::{Cell, Ref, RefCell}; use syntax::ast::Name; diff --git a/src/librustc/middle/ty/util.rs b/src/librustc/ty/util.rs similarity index 99% rename from src/librustc/middle/ty/util.rs rename to src/librustc/ty/util.rs index 6a91592dbd52a..b870dc47ec76a 100644 --- a/src/librustc/middle/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -14,13 +14,13 @@ use back::svh::Svh; use middle::const_eval::{self, ConstVal, ErrKind}; use middle::const_eval::EvalHint::UncheckedExprHint; use middle::def_id::DefId; -use middle::subst; -use middle::infer; +use ty::subst; +use infer; use middle::pat_util; -use middle::traits::{self, ProjectionMode}; -use middle::ty::{self, Ty, TyCtxt, TypeAndMut, TypeFlags, TypeFoldable}; -use middle::ty::{Disr, ParameterEnvironment}; -use middle::ty::TypeVariants::*; +use traits::{self, ProjectionMode}; +use ty::{self, Ty, TyCtxt, TypeAndMut, TypeFlags, TypeFoldable}; +use ty::{Disr, ParameterEnvironment}; +use ty::TypeVariants::*; use rustc_const_eval::{ConstInt, ConstIsize, ConstUsize}; diff --git a/src/librustc/middle/ty/walk.rs b/src/librustc/ty/walk.rs similarity index 99% rename from src/librustc/middle/ty/walk.rs rename to src/librustc/ty/walk.rs index b6d93ecf78b88..fa7c9b782311f 100644 --- a/src/librustc/middle/ty/walk.rs +++ b/src/librustc/ty/walk.rs @@ -11,7 +11,7 @@ //! An iterator over the type substructure. //! WARNING: this does not keep track of the region depth. -use middle::ty::{self, Ty}; +use ty::{self, Ty}; use std::iter::Iterator; use std::vec::IntoIter; diff --git a/src/librustc/middle/ty/wf.rs b/src/librustc/ty/wf.rs similarity index 99% rename from src/librustc/middle/ty/wf.rs rename to src/librustc/ty/wf.rs index 5f81d27a1f688..e6c4e90babbf5 100644 --- a/src/librustc/middle/ty/wf.rs +++ b/src/librustc/ty/wf.rs @@ -9,11 +9,11 @@ // except according to those terms. use middle::def_id::DefId; -use middle::infer::InferCtxt; -use middle::ty::outlives::{self, Component}; -use middle::subst::Substs; -use middle::traits; -use middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable}; +use infer::InferCtxt; +use ty::outlives::{self, Component}; +use ty::subst::Substs; +use traits; +use ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable}; use std::iter::once; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 6e7f49516e8fa..20f16a1d255c7 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -10,14 +10,14 @@ use middle::def_id::DefId; -use middle::subst::{self, Subst}; -use middle::ty::{BrAnon, BrEnv, BrFresh, BrNamed}; -use middle::ty::{TyBool, TyChar, TyStruct, TyEnum}; -use middle::ty::{TyError, TyStr, TyArray, TySlice, TyFloat, TyFnDef, TyFnPtr}; -use middle::ty::{TyParam, TyRawPtr, TyRef, TyTuple}; -use middle::ty::TyClosure; -use middle::ty::{TyBox, TyTrait, TyInt, TyUint, TyInfer}; -use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; +use ty::subst::{self, Subst}; +use ty::{BrAnon, BrEnv, BrFresh, BrNamed}; +use ty::{TyBool, TyChar, TyStruct, TyEnum}; +use ty::{TyError, TyStr, TyArray, TySlice, TyFloat, TyFnDef, TyFnPtr}; +use ty::{TyParam, TyRawPtr, TyRef, TyTuple}; +use ty::TyClosure; +use ty::{TyBox, TyTrait, TyInt, TyUint, TyInfer}; +use ty::{self, Ty, TyCtxt, TypeFoldable}; use std::fmt; use syntax::abi::Abi; diff --git a/src/librustc_borrowck/borrowck/check_loans.rs b/src/librustc_borrowck/borrowck/check_loans.rs index 9186765e6d02c..aa2b7ed2cdeea 100644 --- a/src/librustc_borrowck/borrowck/check_loans.rs +++ b/src/librustc_borrowck/borrowck/check_loans.rs @@ -22,12 +22,12 @@ use borrowck::*; use borrowck::InteriorKind::{InteriorElement, InteriorField}; use rustc::middle::expr_use_visitor as euv; use rustc::middle::expr_use_visitor::MutateMode; -use rustc::middle::infer; +use rustc::infer; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; use rustc::middle::region; -use rustc::middle::ty::{self, TyCtxt}; -use rustc::middle::traits::ProjectionMode; +use rustc::ty::{self, TyCtxt}; +use rustc::traits::ProjectionMode; use syntax::ast; use syntax::codemap::Span; use rustc_front::hir; diff --git a/src/librustc_borrowck/borrowck/fragments.rs b/src/librustc_borrowck/borrowck/fragments.rs index 3d6e9c8868c92..2d38b665cf90b 100644 --- a/src/librustc_borrowck/borrowck/fragments.rs +++ b/src/librustc_borrowck/borrowck/fragments.rs @@ -21,7 +21,7 @@ use borrowck::LoanPathElem::{LpDeref, LpInterior}; use borrowck::move_data::InvalidMovePathIndex; use borrowck::move_data::{MoveData, MovePathIndex}; use rustc::middle::def_id::{DefId}; -use rustc::middle::ty::{self, TyCtxt}; +use rustc::ty::{self, TyCtxt}; use rustc::middle::mem_categorization as mc; use std::mem; diff --git a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs index 4e507284a1b46..107109c91154b 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs @@ -18,7 +18,7 @@ use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; use rustc::middle::mem_categorization::InteriorOffsetKind as Kind; -use rustc::middle::ty; +use rustc::ty; use std::rc::Rc; use syntax::ast; diff --git a/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs index 84dce6d35702a..c2492bba62473 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/lifetime.rs @@ -16,7 +16,7 @@ use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; use rustc::middle::region; -use rustc::middle::ty; +use rustc::ty; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc_borrowck/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs index 2d255c054548f..247f8121de797 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -19,12 +19,12 @@ use borrowck::*; use borrowck::move_data::MoveData; use rustc::middle::expr_use_visitor as euv; -use rustc::middle::infer; +use rustc::infer; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; use rustc::middle::region; -use rustc::middle::ty::{self, TyCtxt}; -use rustc::middle::traits::ProjectionMode; +use rustc::ty::{self, TyCtxt}; +use rustc::traits::ProjectionMode; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs index 4cb9673785ecb..f49554289b3ee 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/move_error.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/move_error.rs @@ -12,7 +12,7 @@ use borrowck::BorrowckCtxt; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; use rustc::middle::mem_categorization::InteriorOffsetKind as Kind; -use rustc::middle::ty; +use rustc::ty; use syntax::ast; use syntax::codemap; use syntax::errors::DiagnosticBuilder; diff --git a/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs b/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs index 2a0d8ef276648..ee8c3aff2ec80 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/restrictions.rs @@ -14,7 +14,7 @@ use borrowck::*; use rustc::middle::expr_use_visitor as euv; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; -use rustc::middle::ty; +use rustc::ty; use syntax::codemap::Span; use borrowck::ToInteriorKind; diff --git a/src/librustc_borrowck/borrowck/mir/dataflow.rs b/src/librustc_borrowck/borrowck/mir/dataflow.rs index 3c3a60b995ff0..a8176c060a104 100644 --- a/src/librustc_borrowck/borrowck/mir/dataflow.rs +++ b/src/librustc_borrowck/borrowck/mir/dataflow.rs @@ -10,7 +10,7 @@ use syntax::attr::AttrMetaMethods; -use rustc::middle::ty; +use rustc::ty::TyCtxt; use rustc::mir::repr::{self, Mir}; use std::io; @@ -459,7 +459,7 @@ impl DataflowState { impl<'tcx> DataflowState> { - pub fn new_move_analysis(mir: &Mir<'tcx>, tcx: &ty::TyCtxt<'tcx>) -> Self { + pub fn new_move_analysis(mir: &Mir<'tcx>, tcx: &TyCtxt<'tcx>) -> Self { let move_data = MoveData::gather_moves(mir, tcx); DataflowState::new(mir, move_data) } diff --git a/src/librustc_borrowck/borrowck/mir/gather_moves.rs b/src/librustc_borrowck/borrowck/mir/gather_moves.rs index 46eb3d3ca03e5..dbe5879934158 100644 --- a/src/librustc_borrowck/borrowck/mir/gather_moves.rs +++ b/src/librustc_borrowck/borrowck/mir/gather_moves.rs @@ -9,7 +9,7 @@ // except according to those terms. -use rustc::middle::ty::TyCtxt; +use rustc::ty::TyCtxt; use rustc::mir::repr::*; use rustc::util::nodemap::FnvHashMap; diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index bb2fe7acb9536..d985359a3dd21 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -23,7 +23,7 @@ use self::InteriorKind::*; use rustc::dep_graph::DepNode; use rustc::front::map as hir_map; use rustc::front::map::blocks::FnParts; -use rustc::middle::cfg; +use rustc::cfg; use rustc::middle::dataflow::DataFlowContext; use rustc::middle::dataflow::BitwiseOperator; use rustc::middle::dataflow::DataFlowOperator; @@ -34,7 +34,7 @@ use rustc::middle::free_region::FreeRegionMap; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; use rustc::middle::region; -use rustc::middle::ty::{self, Ty, TyCtxt}; +use rustc::ty::{self, Ty, TyCtxt}; use std::fmt; use std::mem; diff --git a/src/librustc_borrowck/borrowck/move_data.rs b/src/librustc_borrowck/borrowck/move_data.rs index 4c645d4bb69bd..00274fe1a040c 100644 --- a/src/librustc_borrowck/borrowck/move_data.rs +++ b/src/librustc_borrowck/borrowck/move_data.rs @@ -14,14 +14,14 @@ pub use self::MoveKind::*; use borrowck::*; -use rustc::middle::cfg; +use rustc::cfg; use rustc::middle::dataflow::DataFlowContext; use rustc::middle::dataflow::BitwiseOperator; use rustc::middle::dataflow::DataFlowOperator; use rustc::middle::dataflow::KillFrom; use rustc::middle::expr_use_visitor as euv; use rustc::middle::expr_use_visitor::MutateMode; -use rustc::middle::ty::TyCtxt; +use rustc::ty::TyCtxt; use rustc::util::nodemap::{FnvHashMap, NodeSet}; use std::cell::RefCell; diff --git a/src/librustc_borrowck/graphviz.rs b/src/librustc_borrowck/graphviz.rs index fd23772bcda13..0da9525efd856 100644 --- a/src/librustc_borrowck/graphviz.rs +++ b/src/librustc_borrowck/graphviz.rs @@ -14,13 +14,13 @@ pub use self::Variant::*; -pub use rustc::middle::cfg::graphviz::{Node, Edge}; -use rustc::middle::cfg::graphviz as cfg_dot; +pub use rustc::cfg::graphviz::{Node, Edge}; +use rustc::cfg::graphviz as cfg_dot; use borrowck; use borrowck::{BorrowckCtxt, LoanPath}; use dot; -use rustc::middle::cfg::CFGIndex; +use rustc::cfg::CFGIndex; use rustc::middle::dataflow::{DataFlowOperator, DataFlowContext, EntryOrExit}; use std::rc::Rc; use dot::IntoCow; diff --git a/src/librustc_driver/Cargo.toml b/src/librustc_driver/Cargo.toml index bf86e8f039ad4..c8c517934443d 100644 --- a/src/librustc_driver/Cargo.toml +++ b/src/librustc_driver/Cargo.toml @@ -25,6 +25,7 @@ rustc_plugin = { path = "../librustc_plugin" } rustc_passes = { path = "../librustc_passes" } rustc_privacy = { path = "../librustc_privacy" } rustc_resolve = { path = "../librustc_resolve" } +rustc_save_analysis = { path = "../librustc_save_analysis" } rustc_trans = { path = "../librustc_trans" } rustc_typeck = { path = "../librustc_typeck" } rustc_metadata = { path = "../librustc_metadata" } diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 55b873c06630a..a8f0d4a661474 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -17,9 +17,9 @@ use rustc::session::{Session, CompileResult, compile_result_from_err_count}; use rustc::session::config::{self, Input, OutputFilenames, OutputType}; use rustc::session::search_paths::PathKind; use rustc::lint; -use rustc::middle::{self, dependency_format, stability, ty, reachable}; +use rustc::middle::{self, dependency_format, stability, reachable}; use rustc::middle::privacy::AccessLevels; -use rustc::middle::ty::TyCtxt; +use rustc::ty::{self, TyCtxt}; use rustc::util::common::time; use rustc::util::nodemap::NodeSet; use rustc_borrowck as borrowck; @@ -29,7 +29,7 @@ use rustc_metadata::creader::LocalCrateReader; use rustc_metadata::cstore::CStore; use rustc_trans::back::link; use rustc_trans::back::write; -use rustc_trans::trans; +use rustc_trans as trans; use rustc_typeck as typeck; use rustc_privacy; use rustc_plugin::registry::Registry; diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index dc30b4f91a985..c474b0e33dc47 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -48,6 +48,7 @@ extern crate rustc_privacy; extern crate rustc_metadata; extern crate rustc_mir; extern crate rustc_resolve; +extern crate rustc_save_analysis; extern crate rustc_trans; extern crate rustc_typeck; extern crate serialize; @@ -62,8 +63,8 @@ use driver::CompileController; use pretty::{PpMode, UserIdentifiedItem}; use rustc_resolve as resolve; +use rustc_save_analysis as save; use rustc_trans::back::link; -use rustc_trans::save; use rustc::session::{config, Session, build_session, CompileResult}; use rustc::session::config::{Input, PrintRequest, OutputType, ErrorOutputType}; use rustc::session::config::{get_unstable_features_setting, OptionStability}; diff --git a/src/librustc_driver/pretty.rs b/src/librustc_driver/pretty.rs index 726dd02dd2567..31345cfdc41ab 100644 --- a/src/librustc_driver/pretty.rs +++ b/src/librustc_driver/pretty.rs @@ -20,9 +20,9 @@ use rustc_trans::back::link; use {driver, abort_on_err}; use rustc::dep_graph::DepGraph; -use rustc::middle::ty::{self, TyCtxt}; -use rustc::middle::cfg; -use rustc::middle::cfg::graphviz::LabelledCFG; +use rustc::ty::{self, TyCtxt}; +use rustc::cfg; +use rustc::cfg::graphviz::LabelledCFG; use rustc::session::Session; use rustc::session::config::Input; use rustc_borrowck as borrowck; diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 1a5e7cb54f2e3..adea9517500f2 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -14,21 +14,21 @@ use driver; use rustc::dep_graph::DepGraph; use rustc_lint; use rustc_resolve as resolve; -use rustc_typeck::middle::lang_items; -use rustc_typeck::middle::free_region::FreeRegionMap; -use rustc_typeck::middle::region::{self, CodeExtent}; -use rustc_typeck::middle::region::CodeExtentData; -use rustc_typeck::middle::resolve_lifetime; -use rustc_typeck::middle::stability; -use rustc_typeck::middle::subst; -use rustc_typeck::middle::subst::Subst; -use rustc_typeck::middle::traits::ProjectionMode; -use rustc_typeck::middle::ty::{self, Ty, TyCtxt, TypeFoldable}; -use rustc_typeck::middle::ty::relate::TypeRelation; -use rustc_typeck::middle::infer::{self, TypeOrigin}; -use rustc_typeck::middle::infer::lub::Lub; -use rustc_typeck::middle::infer::glb::Glb; -use rustc_typeck::middle::infer::sub::Sub; +use rustc::middle::lang_items; +use rustc::middle::free_region::FreeRegionMap; +use rustc::middle::region::{self, CodeExtent}; +use rustc::middle::region::CodeExtentData; +use rustc::middle::resolve_lifetime; +use rustc::middle::stability; +use rustc::ty::subst; +use rustc::ty::subst::Subst; +use rustc::traits::ProjectionMode; +use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; +use rustc::ty::relate::TypeRelation; +use rustc::infer::{self, TypeOrigin}; +use rustc::infer::lub::Lub; +use rustc::infer::glb::Glb; +use rustc::infer::sub::Sub; use rustc_metadata::cstore::CStore; use rustc::front::map as hir_map; use rustc::session::{self, config}; diff --git a/src/librustc_lint/bad_style.rs b/src/librustc_lint/bad_style.rs index e399270197e2b..66d435a7581d9 100644 --- a/src/librustc_lint/bad_style.rs +++ b/src/librustc_lint/bad_style.rs @@ -9,7 +9,7 @@ // except according to those terms. use middle::def::Def; -use middle::ty; +use rustc::ty; use lint::{LateContext, LintContext, LintArray}; use lint::{LintPass, LateLintPass}; diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 2ccb905b6ecdf..339c969b01fcd 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -28,14 +28,15 @@ //! Use the former for unit-like structs and the latter for structs with //! a `pub fn new()`. -use middle::{cfg, infer, stability, traits}; use middle::def::Def; use middle::cstore::CrateStore; use middle::def_id::DefId; -use middle::subst::Substs; -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::adjustment; -use middle::traits::ProjectionMode; +use middle::stability; +use rustc::{cfg, infer}; +use rustc::ty::subst::Substs; +use rustc::ty::{self, Ty, TyCtxt}; +use rustc::ty::adjustment; +use rustc::traits::{self, ProjectionMode}; use rustc::front::map as hir_map; use util::nodemap::{NodeSet}; use lint::{Level, LateContext, LintContext, LintArray, Lint}; diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 4288f6258ae0d..9ed21117cebca 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -179,6 +179,14 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { id: LintId::of(OVERLAPPING_INHERENT_IMPLS), reference: "issue #22889 ", }, + FutureIncompatibleInfo { + id: LintId::of(ILLEGAL_FLOATING_POINT_CONSTANT_PATTERN), + reference: "RFC 1445 ", + }, + FutureIncompatibleInfo { + id: LintId::of(ILLEGAL_STRUCT_OR_ENUM_CONSTANT_PATTERN), + reference: "RFC 1445 ", + }, ]); // We have one lint pass defined specially diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 1a84afab86bfc..6322f59257310 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -10,10 +10,10 @@ #![allow(non_snake_case)] -use middle::{infer}; use middle::def_id::DefId; -use middle::subst::Substs; -use middle::ty::{self, Ty, TyCtxt}; +use rustc::infer; +use rustc::ty::subst::Substs; +use rustc::ty::{self, Ty, TyCtxt}; use middle::const_eval::{eval_const_expr_partial, ConstVal}; use middle::const_eval::EvalHint::ExprTypeChecked; use util::nodemap::{FnvHashSet}; diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 36ed06a6c00b4..9840cd4256fcf 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -9,8 +9,8 @@ // except according to those terms. use middle::pat_util; -use middle::ty; -use middle::ty::adjustment; +use rustc::ty; +use rustc::ty::adjustment; use util::nodemap::FnvHashMap; use lint::{LateContext, EarlyContext, LintContext, LintArray}; use lint::{LintPass, EarlyLintPass, LateLintPass}; diff --git a/src/librustc_metadata/astencode.rs b/src/librustc_metadata/astencode.rs index 5c5574c3a8300..852b5f476a6d3 100644 --- a/src/librustc_metadata/astencode.rs +++ b/src/librustc_metadata/astencode.rs @@ -27,14 +27,14 @@ use tydecode; use tyencode; use middle::cstore::{InlinedItem, InlinedItemRef}; -use middle::ty::adjustment; -use middle::ty::cast; +use rustc::ty::adjustment; +use rustc::ty::cast; use middle::const_qualif::ConstQualif; use middle::def::{self, Def}; use middle::def_id::DefId; use middle::region; -use middle::subst; -use middle::ty::{self, Ty, TyCtxt}; +use rustc::ty::subst; +use rustc::ty::{self, Ty, TyCtxt}; use syntax::{ast, ast_util, codemap}; use syntax::ast::NodeIdAssigner; diff --git a/src/librustc_metadata/csearch.rs b/src/librustc_metadata/csearch.rs index 9ac7216165caf..8628198423e41 100644 --- a/src/librustc_metadata/csearch.rs +++ b/src/librustc_metadata/csearch.rs @@ -17,7 +17,7 @@ use middle::cstore::{CrateStore, CrateSource, ChildItem, FoundAst}; use middle::cstore::{NativeLibraryKind, LinkMeta, LinkagePreference}; use middle::def; use middle::lang_items; -use middle::ty::{self, Ty, TyCtxt, VariantKind}; +use rustc::ty::{self, Ty, TyCtxt, VariantKind}; use middle::def_id::{DefId, DefIndex}; use rustc::front::map as hir_map; diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 0c736feeefeee..cc7138243bd06 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -32,9 +32,9 @@ use middle::cstore::{DefLike, DlDef, DlField, DlImpl, tls}; use middle::def::Def; use middle::def_id::{DefId, DefIndex}; use middle::lang_items; -use middle::subst; -use middle::ty::{ImplContainer, TraitContainer}; -use middle::ty::{self, Ty, TyCtxt, TypeFoldable, VariantKind}; +use rustc::ty::subst; +use rustc::ty::{ImplContainer, TraitContainer}; +use rustc::ty::{self, Ty, TyCtxt, TypeFoldable, VariantKind}; use rustc_const_eval::ConstInt; diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index e677ea962f9cf..7d7ab48ee1613 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -25,10 +25,10 @@ use middle::def; use middle::def_id::{CRATE_DEF_INDEX, DefId}; use middle::dependency_format::Linkage; use middle::stability; -use middle::subst; -use middle::traits::specialization_graph; -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::util::IntTypeExt; +use rustc::ty::subst; +use rustc::traits::specialization_graph; +use rustc::ty::{self, Ty, TyCtxt}; +use rustc::ty::util::IntTypeExt; use rustc::back::svh::Svh; use rustc::front::map::{LinkedPath, PathElem, PathElems}; diff --git a/src/librustc_metadata/tls_context.rs b/src/librustc_metadata/tls_context.rs index f90abd9e1d961..6ecd7a7f50ad8 100644 --- a/src/librustc_metadata/tls_context.rs +++ b/src/librustc_metadata/tls_context.rs @@ -15,8 +15,8 @@ use rbml::opaque::Encoder as OpaqueEncoder; use rbml::opaque::Decoder as OpaqueDecoder; use rustc::middle::cstore::tls; use rustc::middle::def_id::DefId; -use rustc::middle::subst::Substs; -use rustc::middle::ty::{self, TyCtxt}; +use rustc::ty::subst::Substs; +use rustc::ty::{self, TyCtxt}; use decoder::{self, Cmd}; use encoder; diff --git a/src/librustc_metadata/tydecode.rs b/src/librustc_metadata/tydecode.rs index cd9c2e828bdef..ed59fce77a02c 100644 --- a/src/librustc_metadata/tydecode.rs +++ b/src/librustc_metadata/tydecode.rs @@ -20,9 +20,9 @@ use rustc_front::hir; use middle::def_id::{DefId, DefIndex}; use middle::region; -use middle::subst; -use middle::subst::VecPerParamSpace; -use middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable}; +use rustc::ty::subst; +use rustc::ty::subst::VecPerParamSpace; +use rustc::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable}; use rbml; use rbml::leb128; diff --git a/src/librustc_metadata/tyencode.rs b/src/librustc_metadata/tyencode.rs index 4718732c8a037..e8ff46f427b52 100644 --- a/src/librustc_metadata/tyencode.rs +++ b/src/librustc_metadata/tyencode.rs @@ -19,10 +19,10 @@ use std::io::prelude::*; use middle::def_id::DefId; use middle::region; -use middle::subst; -use middle::subst::VecPerParamSpace; -use middle::ty::ParamTy; -use middle::ty::{self, Ty, TyCtxt}; +use rustc::ty::subst; +use rustc::ty::subst::VecPerParamSpace; +use rustc::ty::ParamTy; +use rustc::ty::{self, Ty, TyCtxt}; use rustc::util::nodemap::FnvHashMap; use rustc_front::hir; diff --git a/src/librustc_mir/build/expr/into.rs b/src/librustc_mir/build/expr/into.rs index 30c039cdde0c3..231d7da10a02d 100644 --- a/src/librustc_mir/build/expr/into.rs +++ b/src/librustc_mir/build/expr/into.rs @@ -15,7 +15,7 @@ use build::expr::category::{Category, RvalueFunc}; use build::scope::LoopScope; use hair::*; use rustc::middle::region::CodeExtent; -use rustc::middle::ty; +use rustc::ty; use rustc::mir::repr::*; use syntax::codemap::Span; diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index b1286e935b684..581e8e35ee89f 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -16,7 +16,7 @@ use build::{BlockAnd, BlockAndExtension, Builder}; use rustc_data_structures::fnv::FnvHashMap; use rustc::middle::const_eval::ConstVal; -use rustc::middle::ty::{AdtDef, Ty}; +use rustc::ty::{AdtDef, Ty}; use rustc::mir::repr::*; use hair::*; use syntax::ast::{Name, NodeId}; diff --git a/src/librustc_mir/build/matches/test.rs b/src/librustc_mir/build/matches/test.rs index 3211e5849a06c..5a1c3739ef5f0 100644 --- a/src/librustc_mir/build/matches/test.rs +++ b/src/librustc_mir/build/matches/test.rs @@ -20,7 +20,7 @@ use build::matches::{Candidate, MatchPair, Test, TestKind}; use hair::*; use rustc_data_structures::fnv::FnvHashMap; use rustc::middle::const_eval::ConstVal; -use rustc::middle::ty::{self, Ty}; +use rustc::ty::{self, Ty}; use rustc::mir::repr::*; use syntax::codemap::Span; diff --git a/src/librustc_mir/build/misc.rs b/src/librustc_mir/build/misc.rs index 0d1690783301b..86f15a6319399 100644 --- a/src/librustc_mir/build/misc.rs +++ b/src/librustc_mir/build/misc.rs @@ -12,7 +12,7 @@ //! kind of thing. use build::Builder; -use rustc::middle::ty::Ty; +use rustc::ty::Ty; use rustc::mir::repr::*; use std::u32; use syntax::codemap::Span; diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index b79f492179fb9..82f7ddebf0bce 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -10,7 +10,7 @@ use hair::cx::Cx; use rustc::middle::region::{CodeExtent, CodeExtentData}; -use rustc::middle::ty::{FnOutput, Ty}; +use rustc::ty::{FnOutput, Ty}; use rustc::mir::repr::*; use rustc_data_structures::fnv::FnvHashMap; use rustc_front::hir; diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index f5f6f409eaba4..bac7b310dc701 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -89,8 +89,8 @@ should go to. use build::{BlockAnd, BlockAndExtension, Builder, CFG, ScopeAuxiliary}; use rustc::middle::region::{CodeExtent, CodeExtentData}; use rustc::middle::lang_items; -use rustc::middle::subst::{Substs, Subst, VecPerParamSpace}; -use rustc::middle::ty::{self, Ty, TyCtxt}; +use rustc::ty::subst::{Substs, Subst, VecPerParamSpace}; +use rustc::ty::{self, Ty, TyCtxt}; use rustc::mir::repr::*; use syntax::codemap::{Span, DUMMY_SP}; use syntax::parse::token::intern_and_get_ident; diff --git a/src/librustc_mir/graphviz.rs b/src/librustc_mir/graphviz.rs index a5e749ea6870e..959b1fdef5270 100644 --- a/src/librustc_mir/graphviz.rs +++ b/src/librustc_mir/graphviz.rs @@ -10,7 +10,7 @@ use dot; use rustc::mir::repr::*; -use rustc::middle::ty; +use rustc::ty; use std::fmt::Debug; use std::io::{self, Write}; use syntax::ast::NodeId; diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 4d87d926e4055..aa55ee3e3f729 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -19,7 +19,7 @@ use rustc::middle::def::Def; use rustc::middle::const_eval::{self, ConstVal}; use rustc::middle::region::CodeExtent; use rustc::middle::pat_util; -use rustc::middle::ty::{self, VariantDef, Ty}; +use rustc::ty::{self, VariantDef, Ty}; use rustc::mir::repr::*; use rustc_front::hir; use rustc_front::util as hir_util; diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index b97bfaf5aef68..30467a981d914 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -20,9 +20,9 @@ use rustc::mir::repr::*; use rustc::middle::const_eval::{self, ConstVal}; use rustc::middle::def_id::DefId; -use rustc::middle::infer::InferCtxt; -use rustc::middle::subst::{Subst, Substs}; -use rustc::middle::ty::{self, Ty, TyCtxt}; +use rustc::infer::InferCtxt; +use rustc::ty::subst::{Subst, Substs}; +use rustc::ty::{self, Ty, TyCtxt}; use syntax::codemap::Span; use syntax::parse::token; use rustc_front::hir; diff --git a/src/librustc_mir/hair/cx/pattern.rs b/src/librustc_mir/hair/cx/pattern.rs index a987377837417..0cb849555f24b 100644 --- a/src/librustc_mir/hair/cx/pattern.rs +++ b/src/librustc_mir/hair/cx/pattern.rs @@ -14,7 +14,7 @@ use rustc_data_structures::fnv::FnvHashMap; use rustc::middle::const_eval; use rustc::middle::def::Def; use rustc::middle::pat_util::{pat_is_resolved_const, pat_is_binding}; -use rustc::middle::ty::{self, Ty}; +use rustc::ty::{self, Ty}; use rustc::mir::repr::*; use rustc_front::hir::{self, PatKind}; use syntax::ast; @@ -90,9 +90,16 @@ impl<'patcx, 'cx, 'tcx> PatCx<'patcx, 'cx, 'tcx> { let substs = Some(self.cx.tcx.node_id_item_substs(pat.id).substs); match const_eval::lookup_const_by_id(self.cx.tcx, def_id, substs) { Some((const_expr, _const_ty)) => { - let pat = const_eval::const_expr_to_pat(self.cx.tcx, const_expr, - pat.span); - return self.to_pattern(&pat); + match const_eval::const_expr_to_pat(self.cx.tcx, + const_expr, + pat.id, + pat.span) { + Ok(pat) => + return self.to_pattern(&pat), + Err(_) => + self.cx.tcx.sess.span_bug( + pat.span, "illegal constant"), + } } None => { self.cx.tcx.sess.span_bug( diff --git a/src/librustc_mir/hair/mod.rs b/src/librustc_mir/hair/mod.rs index 78c438df6f87a..79c8356bb557a 100644 --- a/src/librustc_mir/hair/mod.rs +++ b/src/librustc_mir/hair/mod.rs @@ -19,8 +19,8 @@ use rustc::mir::repr::{BinOp, BorrowKind, Field, Literal, Mutability, UnOp, use rustc::middle::const_eval::ConstVal; use rustc::middle::def_id::DefId; use rustc::middle::region::CodeExtent; -use rustc::middle::subst::Substs; -use rustc::middle::ty::{self, AdtDef, ClosureSubsts, Region, Ty}; +use rustc::ty::subst::Substs; +use rustc::ty::{self, AdtDef, ClosureSubsts, Region, Ty}; use rustc_front::hir; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc_mir/mir_map.rs b/src/librustc_mir/mir_map.rs index 5a6e2edfdf9e7..21cc8d35320a3 100644 --- a/src/librustc_mir/mir_map.rs +++ b/src/librustc_mir/mir_map.rs @@ -26,9 +26,9 @@ use pretty; use hair::cx::Cx; use rustc::mir::mir_map::MirMap; -use rustc::middle::infer; -use rustc::middle::traits::ProjectionMode; -use rustc::middle::ty::{self, Ty, TyCtxt}; +use rustc::infer; +use rustc::traits::ProjectionMode; +use rustc::ty::{self, Ty, TyCtxt}; use rustc::util::common::ErrorReported; use rustc::util::nodemap::NodeMap; use rustc_front::hir; diff --git a/src/librustc_mir/pretty.rs b/src/librustc_mir/pretty.rs index 834897f8eaee0..2c50697c37f69 100644 --- a/src/librustc_mir/pretty.rs +++ b/src/librustc_mir/pretty.rs @@ -10,7 +10,7 @@ use build::{Location, ScopeAuxiliaryVec}; use rustc::mir::repr::*; -use rustc::middle::ty::{self, TyCtxt}; +use rustc::ty::{self, TyCtxt}; use rustc_data_structures::fnv::FnvHashMap; use std::fmt::Display; use std::fs; diff --git a/src/librustc_mir/transform/erase_regions.rs b/src/librustc_mir/transform/erase_regions.rs index d8aa0d9b72503..addf87e3356e5 100644 --- a/src/librustc_mir/transform/erase_regions.rs +++ b/src/librustc_mir/transform/erase_regions.rs @@ -12,7 +12,7 @@ //! We want to do this once just before trans, so trans does not have to take //! care erasing regions all over the place. -use rustc::middle::ty::{self, TyCtxt}; +use rustc::ty::{self, TyCtxt}; use rustc::mir::repr::*; use rustc::mir::visit::MutVisitor; use rustc::mir::transform::{MirPass, Pass}; diff --git a/src/librustc_mir/transform/no_landing_pads.rs b/src/librustc_mir/transform/no_landing_pads.rs index 0e9a18107870e..edfe75b8430d4 100644 --- a/src/librustc_mir/transform/no_landing_pads.rs +++ b/src/librustc_mir/transform/no_landing_pads.rs @@ -11,7 +11,7 @@ //! This pass removes the unwind branch of all the terminators when the no-landing-pads option is //! specified. -use rustc::middle::ty::TyCtxt; +use rustc::ty::TyCtxt; use rustc::mir::repr::*; use rustc::mir::visit::MutVisitor; use rustc::mir::transform::{Pass, MirPass}; diff --git a/src/librustc_mir/transform/remove_dead_blocks.rs b/src/librustc_mir/transform/remove_dead_blocks.rs index 4513aeef86d91..dc1ddad124f87 100644 --- a/src/librustc_mir/transform/remove_dead_blocks.rs +++ b/src/librustc_mir/transform/remove_dead_blocks.rs @@ -33,7 +33,7 @@ //! and does not renumber anything. use rustc_data_structures::bitvec::BitVector; -use rustc::middle::ty::TyCtxt; +use rustc::ty::TyCtxt; use rustc::mir::repr::*; use rustc::mir::transform::{Pass, MirPass}; use syntax::ast::NodeId; diff --git a/src/librustc_mir/transform/simplify_cfg.rs b/src/librustc_mir/transform/simplify_cfg.rs index 21b1d022fda60..cbde292cb995b 100644 --- a/src/librustc_mir/transform/simplify_cfg.rs +++ b/src/librustc_mir/transform/simplify_cfg.rs @@ -9,7 +9,7 @@ // except according to those terms. use rustc::middle::const_eval::ConstVal; -use rustc::middle::ty::TyCtxt; +use rustc::ty::TyCtxt; use rustc::mir::repr::*; use rustc::mir::transform::{MirPass, Pass}; use pretty; diff --git a/src/librustc_mir/transform/type_check.rs b/src/librustc_mir/transform/type_check.rs index c0605ebe6d4a8..6cfde27ac97b6 100644 --- a/src/librustc_mir/transform/type_check.rs +++ b/src/librustc_mir/transform/type_check.rs @@ -12,10 +12,10 @@ #![allow(unreachable_code)] use rustc::dep_graph::DepNode; -use rustc::middle::infer::{self, InferCtxt}; -use rustc::middle::traits::{self, ProjectionMode}; -use rustc::middle::ty::fold::TypeFoldable; -use rustc::middle::ty::{self, Ty, TyCtxt}; +use rustc::infer::{self, InferCtxt}; +use rustc::traits::{self, ProjectionMode}; +use rustc::ty::fold::TypeFoldable; +use rustc::ty::{self, Ty, TyCtxt}; use rustc::mir::repr::*; use rustc::mir::tcx::LvalueTy; use rustc::mir::transform::{MirPass, Pass}; diff --git a/src/librustc_passes/consts.rs b/src/librustc_passes/consts.rs index c2b764594180c..571d5bd9bc5a3 100644 --- a/src/librustc_passes/consts.rs +++ b/src/librustc_passes/consts.rs @@ -25,18 +25,18 @@ // by borrowck::gather_loans use rustc::dep_graph::DepNode; -use rustc::middle::ty::cast::{CastKind}; +use rustc::ty::cast::{CastKind}; use rustc::middle::const_eval::{self, ConstEvalErr}; use rustc::middle::const_eval::ErrKind::IndexOpFeatureGated; use rustc::middle::const_eval::EvalHint::ExprTypeChecked; use rustc::middle::def::Def; use rustc::middle::def_id::DefId; use rustc::middle::expr_use_visitor as euv; -use rustc::middle::infer; +use rustc::infer; use rustc::middle::mem_categorization as mc; use rustc::middle::mem_categorization::Categorization; -use rustc::middle::ty::{self, Ty, TyCtxt}; -use rustc::middle::traits::{self, ProjectionMode}; +use rustc::ty::{self, Ty, TyCtxt}; +use rustc::traits::{self, ProjectionMode}; use rustc::util::nodemap::NodeMap; use rustc::middle::const_qualif::ConstQualif; use rustc::lint::builtin::CONST_ERR; diff --git a/src/librustc_passes/rvalues.rs b/src/librustc_passes/rvalues.rs index 88048b514e1f5..98502f5a16e78 100644 --- a/src/librustc_passes/rvalues.rs +++ b/src/librustc_passes/rvalues.rs @@ -13,10 +13,10 @@ use rustc::dep_graph::DepNode; use rustc::middle::expr_use_visitor as euv; -use rustc::middle::infer; +use rustc::infer; use rustc::middle::mem_categorization as mc; -use rustc::middle::ty::{self, TyCtxt, ParameterEnvironment}; -use rustc::middle::traits::ProjectionMode; +use rustc::ty::{self, TyCtxt, ParameterEnvironment}; +use rustc::traits::ProjectionMode; use rustc_front::hir; use rustc_front::intravisit; diff --git a/src/librustc_platform_intrinsics/aarch64.rs b/src/librustc_platform_intrinsics/aarch64.rs index 59986a905a2ec..97fe632a529f8 100644 --- a/src/librustc_platform_intrinsics/aarch64.rs +++ b/src/librustc_platform_intrinsics/aarch64.rs @@ -15,7 +15,7 @@ use {Intrinsic, Type}; use IntrinsicDef::Named; -use rustc::middle::ty::TyCtxt; +use rustc::ty::TyCtxt; // The default inlining settings trigger a pathological behaviour in // LLVM, which causes makes compilation very slow. See #28273. diff --git a/src/librustc_platform_intrinsics/arm.rs b/src/librustc_platform_intrinsics/arm.rs index d71f59e8e68cd..65751d652321c 100644 --- a/src/librustc_platform_intrinsics/arm.rs +++ b/src/librustc_platform_intrinsics/arm.rs @@ -15,7 +15,7 @@ use {Intrinsic, Type}; use IntrinsicDef::Named; -use rustc::middle::ty::TyCtxt; +use rustc::ty::TyCtxt; // The default inlining settings trigger a pathological behaviour in // LLVM, which causes makes compilation very slow. See #28273. diff --git a/src/librustc_platform_intrinsics/lib.rs b/src/librustc_platform_intrinsics/lib.rs index 53976308bdc19..9736d5587693e 100644 --- a/src/librustc_platform_intrinsics/lib.rs +++ b/src/librustc_platform_intrinsics/lib.rs @@ -19,7 +19,7 @@ extern crate rustc_llvm as llvm; extern crate rustc; -use rustc::middle::ty::TyCtxt; +use rustc::ty::TyCtxt; pub struct Intrinsic { pub inputs: &'static [&'static Type], diff --git a/src/librustc_platform_intrinsics/x86.rs b/src/librustc_platform_intrinsics/x86.rs index eccdc77f33c9d..de9d3dcf3550f 100644 --- a/src/librustc_platform_intrinsics/x86.rs +++ b/src/librustc_platform_intrinsics/x86.rs @@ -15,7 +15,7 @@ use {Intrinsic, Type}; use IntrinsicDef::Named; -use rustc::middle::ty::TyCtxt; +use rustc::ty::TyCtxt; // The default inlining settings trigger a pathological behaviour in // LLVM, which causes makes compilation very slow. See #28273. diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 79ccc8fb2b21f..304932df412ad 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -42,7 +42,7 @@ use rustc::middle::cstore::CrateStore; use rustc::middle::def::{self, Def}; use rustc::middle::def_id::DefId; use rustc::middle::privacy::{AccessLevel, AccessLevels}; -use rustc::middle::ty::{self, TyCtxt}; +use rustc::ty::{self, TyCtxt}; use rustc::util::nodemap::{NodeMap, NodeSet}; use rustc::front::map as ast_map; diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 479fc5ebf907e..9caab50bb6ef2 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -27,7 +27,7 @@ use {resolve_error, resolve_struct_error, ResolutionError}; use rustc::middle::cstore::{CrateStore, ChildItem, DlDef, DlField, DlImpl}; use rustc::middle::def::*; use rustc::middle::def_id::{CRATE_DEF_INDEX, DefId}; -use rustc::middle::ty::VariantKind; +use rustc::ty::VariantKind; use syntax::ast::{Name, NodeId}; use syntax::attr::AttrMetaMethods; diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index bfd8a6f1f61f0..8a196768ae516 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -205,51 +205,6 @@ about what constitutes an Item declaration and what does not: https://doc.rust-lang.org/reference.html#statements "##, -E0317: r##" -User-defined types or type parameters cannot shadow the primitive types. -This error indicates you tried to define a type, struct or enum with the same -name as an existing primitive type: - -```compile_fail -struct u8 { - // ... -} -``` - -To fix this, simply name it something else. - -Such an error may also occur if you define a type parameter which shadows a -primitive type. An example would be something like: - -```compile_fail -impl MyTrait for Option { - // ... -} -``` - -In such a case, if you meant for `u8` to be a generic type parameter (i.e. any -type can be used in its place), use something like `T` instead: - -```ignore -impl MyTrait for Option { - // ... -} -``` - -On the other hand, if you wished to refer to the specific type `u8`, remove it -from the type parameter list: - -```ignore -impl MyTrait for Option { - // ... -} - -See the Types section of the reference for more information about the primitive -types: - -https://doc.rust-lang.org/reference.html#types -"##, - E0364: r##" Private items cannot be publicly re-exported. This error indicates that you attempted to `pub use` a type or value that was not itself public. diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 77fdc657b886f..54ab3ab0ed456 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -55,8 +55,8 @@ use rustc::middle::cstore::{CrateStore, DefLike, DlDef}; use rustc::middle::def::*; use rustc::middle::def_id::DefId; use rustc::middle::pat_util::pat_bindings; -use rustc::middle::subst::{ParamSpace, FnSpace, TypeSpace}; -use rustc::middle::ty::{Freevar, FreevarMap, TraitMap, GlobMap}; +use rustc::ty::subst::{ParamSpace, FnSpace, TypeSpace}; +use rustc::ty::{Freevar, FreevarMap, TraitMap, GlobMap}; use rustc::util::nodemap::{NodeMap, FnvHashMap}; use syntax::ast::{self, FloatTy}; @@ -1619,15 +1619,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { intravisit::walk_crate(self, krate); } - fn check_if_primitive_type_name(&self, name: Name, span: Span) { - if let Some(_) = self.primitive_type_table.primitive_types.get(&name) { - span_err!(self.session, - span, - E0317, - "user-defined types or type parameters cannot shadow the primitive types"); - } - } - fn resolve_item(&mut self, item: &Item) { let name = item.name; @@ -1637,8 +1628,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { ItemEnum(_, ref generics) | ItemTy(_, ref generics) | ItemStruct(_, ref generics) => { - self.check_if_primitive_type_name(name, item.span); - self.with_type_parameter_rib(HasTypeParameters(generics, TypeSpace, ItemRibKind), |this| intravisit::walk_item(this, item)); } @@ -1659,8 +1648,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } ItemTrait(_, ref generics, ref bounds, ref trait_items) => { - self.check_if_primitive_type_name(name, item.span); - // Create a new rib for the trait-wide type parameters. self.with_type_parameter_rib(HasTypeParameters(generics, TypeSpace, @@ -1695,8 +1682,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { }); } hir::TypeTraitItem(..) => { - this.check_if_primitive_type_name(trait_item.name, - trait_item.span); this.with_type_parameter_rib(NoTypeParameters, |this| { intravisit::walk_trait_item(this, trait_item) }); @@ -1720,28 +1705,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } ItemUse(ref view_path) => { - // check for imports shadowing primitive types - let check_rename = |this: &Self, id, name| { - match this.def_map.borrow().get(&id).map(|d| d.full_def()) { - Some(Def::Enum(..)) | Some(Def::TyAlias(..)) | Some(Def::Struct(..)) | - Some(Def::Trait(..)) | None => { - this.check_if_primitive_type_name(name, item.span); - } - _ => {} - } - }; - match view_path.node { - hir::ViewPathSimple(name, _) => { - check_rename(self, item.id, name); - } hir::ViewPathList(ref prefix, ref items) => { - for item in items { - if let Some(name) = item.node.rename() { - check_rename(self, item.node.id(), name); - } - } - // Resolve prefix of an import with empty braces (issue #28388) if items.is_empty() && !prefix.segments.is_empty() { match self.resolve_crate_relative_path(prefix.span, @@ -1922,9 +1887,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { } fn resolve_generics(&mut self, generics: &Generics) { - for type_parameter in generics.ty_params.iter() { - self.check_if_primitive_type_name(type_parameter.name, type_parameter.span); - } for predicate in &generics.where_clause.predicates { match predicate { &hir::WherePredicate::BoundPredicate(_) | @@ -2658,15 +2620,37 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { // Try to find a path to an item in a module. let last_ident = segments.last().unwrap().identifier; - if segments.len() <= 1 { - let unqualified_def = self.resolve_identifier(last_ident, namespace, true); - return unqualified_def.and_then(|def| self.adjust_local_def(def, span)) - .map(|def| { - PathResolution::new(def, path_depth) - }); - } + // Resolve a single identifier with fallback to primitive types + let resolve_identifier_with_fallback = |this: &mut Self, record_used| { + let def = this.resolve_identifier(last_ident, namespace, record_used); + match def { + None | Some(LocalDef{def: Def::Mod(..), ..}) if namespace == TypeNS => + this.primitive_type_table + .primitive_types + .get(&last_ident.unhygienic_name) + .map_or(def, |prim_ty| Some(LocalDef::from_def(Def::PrimTy(*prim_ty)))), + _ => def + } + }; - let unqualified_def = self.resolve_identifier(last_ident, namespace, false); + if segments.len() == 1 { + // In `a(::assoc_item)*` `a` cannot be a module. If `a` does resolve to a module we + // don't report an error right away, but try to fallback to a primitive type. + // So, we are still able to successfully resolve something like + // + // use std::u8; // bring module u8 in scope + // fn f() -> u8 { // OK, resolves to primitive u8, not to std::u8 + // u8::max_value() // OK, resolves to associated function ::max_value, + // // not to non-existent std::u8::max_value + // } + // + // Such behavior is required for backward compatibility. + // The same fallback is used when `a` resolves to nothing. + let unqualified_def = resolve_identifier_with_fallback(self, true); + return unqualified_def.and_then(|def| self.adjust_local_def(def, span)).map(mk_res); + } + + let unqualified_def = resolve_identifier_with_fallback(self, false); let def = self.resolve_module_relative_path(span, segments, namespace); match (def, unqualified_def) { (Some(d), Some(ref ud)) if d == ud.def => { @@ -2692,15 +2676,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { return Some(LocalDef::from_def(Def::Err)); } - // First, check to see whether the name is a primitive type. - if namespace == TypeNS { - if let Some(&prim_ty) = self.primitive_type_table - .primitive_types - .get(&identifier.unhygienic_name) { - return Some(LocalDef::from_def(Def::PrimTy(prim_ty))); - } - } - self.resolve_identifier_in_local_ribs(identifier, namespace, record_used) } diff --git a/src/librustc_save_analysis/Cargo.toml b/src/librustc_save_analysis/Cargo.toml new file mode 100644 index 0000000000000..a0cf70b57a9d4 --- /dev/null +++ b/src/librustc_save_analysis/Cargo.toml @@ -0,0 +1,15 @@ +[package] +authors = ["The Rust Project Developers"] +name = "rustc_save_analysis" +version = "0.0.0" + +[lib] +name = "rustc_save_analysis" +path = "lib.rs" +crate-type = ["dylib"] + +[dependencies] +log = { path = "../liblog" } +rustc = { path = "../librustc" } +rustc_front = { path = "../librustc_front" } +syntax = { path = "../libsyntax" } diff --git a/src/librustc_trans/save/csv_dumper.rs b/src/librustc_save_analysis/csv_dumper.rs similarity index 99% rename from src/librustc_trans/save/csv_dumper.rs rename to src/librustc_save_analysis/csv_dumper.rs index 2a5b7d9567be7..3021d4e9820b7 100644 --- a/src/librustc_trans/save/csv_dumper.rs +++ b/src/librustc_save_analysis/csv_dumper.rs @@ -10,7 +10,7 @@ use std::io::Write; -use middle::def_id::{DefId, DefIndex}; +use rustc::middle::def_id::{DefId, DefIndex}; use syntax::codemap::Span; use super::data::*; diff --git a/src/librustc_trans/save/data.rs b/src/librustc_save_analysis/data.rs similarity index 99% rename from src/librustc_trans/save/data.rs rename to src/librustc_save_analysis/data.rs index 3eaaa3fc4930c..997a635f69e0d 100644 --- a/src/librustc_trans/save/data.rs +++ b/src/librustc_save_analysis/data.rs @@ -15,8 +15,8 @@ use std::hash::Hasher; -use middle::def_id::DefId; -use middle::ty; +use rustc::middle::def_id::DefId; +use rustc::ty; use syntax::ast::{CrateNum, NodeId}; use syntax::codemap::Span; diff --git a/src/librustc_trans/save/dump.rs b/src/librustc_save_analysis/dump.rs similarity index 100% rename from src/librustc_trans/save/dump.rs rename to src/librustc_save_analysis/dump.rs diff --git a/src/librustc_trans/save/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs similarity index 99% rename from src/librustc_trans/save/dump_visitor.rs rename to src/librustc_save_analysis/dump_visitor.rs index 65f48d1ff5eb5..88b72ccf3296c 100644 --- a/src/librustc_trans/save/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -27,11 +27,10 @@ //! is used for recording the output in a format-agnostic way (see CsvDumper //! for an example). -use session::Session; - -use middle::def::Def; -use middle::def_id::DefId; -use middle::ty::{self, TyCtxt}; +use rustc::middle::def::Def; +use rustc::middle::def_id::DefId; +use rustc::session::Session; +use rustc::ty::{self, TyCtxt}; use std::collections::HashSet; use std::hash::*; diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_save_analysis/lib.rs similarity index 97% rename from src/librustc_trans/save/mod.rs rename to src/librustc_save_analysis/lib.rs index 78e91e00baa71..5dcb6473ec2e3 100644 --- a/src/librustc_trans/save/mod.rs +++ b/src/librustc_save_analysis/lib.rs @@ -8,18 +8,36 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::ty::{self, TyCtxt}; -use middle::def::Def; -use middle::def_id::DefId; +#![crate_name = "rustc_save_analysis"] +#![unstable(feature = "rustc_private", issue = "27812")] +#![crate_type = "dylib"] +#![crate_type = "rlib"] +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "https://doc.rust-lang.org/favicon.ico", + html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), deny(warnings))] + +#![feature(custom_attribute)] +#![allow(unused_attributes)] +#![feature(rustc_private)] +#![feature(staged_api)] + +extern crate rustc; +extern crate rustc_front; + +#[macro_use] extern crate log; +#[macro_use] extern crate syntax; -use std::env; -use std::fs::{self, File}; -use std::path::{Path, PathBuf}; - -use rustc_front; use rustc_front::{hir, lowering}; use rustc::front::map::NodeItem; +use rustc::middle::def::Def; +use rustc::middle::def_id::DefId; use rustc::session::config::CrateType::CrateTypeExecutable; +use rustc::ty::{self, TyCtxt}; + +use std::env; +use std::fs::{self, File}; +use std::path::{Path, PathBuf}; use syntax::ast::{self, NodeId, PatKind}; use syntax::ast_util; diff --git a/src/librustc_trans/save/span_utils.rs b/src/librustc_save_analysis/span_utils.rs similarity index 99% rename from src/librustc_trans/save/span_utils.rs rename to src/librustc_save_analysis/span_utils.rs index 2a5c61f4e9d2a..4080607eed51d 100644 --- a/src/librustc_trans/save/span_utils.rs +++ b/src/librustc_save_analysis/span_utils.rs @@ -10,7 +10,7 @@ use rustc::session::Session; -use save::generated_code; +use generated_code; use std::cell::Cell; use std::env; diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/_match.rs similarity index 99% rename from src/librustc_trans/trans/_match.rs rename to src/librustc_trans/_match.rs index 8aea2f1ec4f4a..008323ee5bf31 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/_match.rs @@ -195,31 +195,31 @@ use middle::const_eval; use middle::def::{Def, DefMap}; use middle::def_id::DefId; use middle::expr_use_visitor as euv; -use middle::infer; +use rustc::infer; use middle::lang_items::StrEqFnLangItem; use middle::mem_categorization as mc; use middle::mem_categorization::Categorization; use middle::pat_util::*; -use middle::subst::Substs; -use trans::adt; -use trans::base::*; -use trans::build::{AddCase, And, Br, CondBr, GEPi, InBoundsGEP, Load, PointerCast}; -use trans::build::{Not, Store, Sub, add_comment}; -use trans::build; -use trans::callee::{Callee, ArgVals}; -use trans::cleanup::{self, CleanupMethods, DropHintMethods}; -use trans::common::*; -use trans::consts; -use trans::datum::*; -use trans::debuginfo::{self, DebugLoc, ToDebugLoc}; -use trans::expr::{self, Dest}; -use trans::monomorphize; -use trans::tvec; -use trans::type_of; -use trans::Disr; -use trans::value::Value; -use middle::ty::{self, Ty, TyCtxt}; -use middle::traits::ProjectionMode; +use rustc::ty::subst::Substs; +use adt; +use base::*; +use build::{AddCase, And, Br, CondBr, GEPi, InBoundsGEP, Load, PointerCast}; +use build::{Not, Store, Sub, add_comment}; +use build; +use callee::{Callee, ArgVals}; +use cleanup::{self, CleanupMethods, DropHintMethods}; +use common::*; +use consts; +use datum::*; +use debuginfo::{self, DebugLoc, ToDebugLoc}; +use expr::{self, Dest}; +use monomorphize; +use tvec; +use type_of; +use Disr; +use value::Value; +use rustc::ty::{self, Ty, TyCtxt}; +use rustc::traits::ProjectionMode; use session::config::NoDebugInfo; use util::common::indenter; use util::nodemap::FnvHashMap; @@ -281,7 +281,7 @@ impl<'a, 'tcx> Opt<'a, 'tcx> { } fn trans<'blk>(&self, mut bcx: Block<'blk, 'tcx>) -> OptResult<'blk, 'tcx> { - use trans::consts::TrueConst::Yes; + use consts::TrueConst::Yes; let _icx = push_ctxt("match::trans_opt"); let ccx = bcx.ccx(); match *self { diff --git a/src/librustc_trans/trans/abi.rs b/src/librustc_trans/abi.rs similarity index 97% rename from src/librustc_trans/trans/abi.rs rename to src/librustc_trans/abi.rs index fd086522b2ea3..dd72322997af8 100644 --- a/src/librustc_trans/trans/abi.rs +++ b/src/librustc_trans/abi.rs @@ -9,25 +9,25 @@ // except according to those terms. use llvm::{self, ValueRef}; -use trans::base; -use trans::builder::Builder; -use trans::common::{type_is_fat_ptr, BlockAndBuilder}; -use trans::context::CrateContext; -use trans::cabi_x86; -use trans::cabi_x86_64; -use trans::cabi_x86_win64; -use trans::cabi_arm; -use trans::cabi_aarch64; -use trans::cabi_powerpc; -use trans::cabi_powerpc64; -use trans::cabi_mips; -use trans::cabi_asmjs; -use trans::machine::{llalign_of_min, llsize_of, llsize_of_real}; -use trans::type_::Type; -use trans::type_of; +use base; +use builder::Builder; +use common::{type_is_fat_ptr, BlockAndBuilder}; +use context::CrateContext; +use cabi_x86; +use cabi_x86_64; +use cabi_x86_win64; +use cabi_arm; +use cabi_aarch64; +use cabi_powerpc; +use cabi_powerpc64; +use cabi_mips; +use cabi_asmjs; +use machine::{llalign_of_min, llsize_of, llsize_of_real}; +use type_::Type; +use type_of; use rustc_front::hir; -use middle::ty::{self, Ty}; +use rustc::ty::{self, Ty}; use libc::c_uint; @@ -318,7 +318,7 @@ impl FnType { } ty::TyRef(b, mt) => { - use middle::ty::{BrAnon, ReLateBound}; + use rustc::ty::{BrAnon, ReLateBound}; // `&mut` pointer parameters never alias other parameters, or mutable global data // diff --git a/src/librustc_trans/trans/adt.rs b/src/librustc_trans/adt.rs similarity index 99% rename from src/librustc_trans/trans/adt.rs rename to src/librustc_trans/adt.rs index db0fa2a64bde6..7c190c2ff7121 100644 --- a/src/librustc_trans/trans/adt.rs +++ b/src/librustc_trans/adt.rs @@ -48,26 +48,26 @@ use std; use std::rc::Rc; use llvm::{ValueRef, True, IntEQ, IntNE}; -use middle::subst; -use middle::ty::{self, Ty, TyCtxt}; +use rustc::ty::subst; +use rustc::ty::{self, Ty, TyCtxt}; use syntax::ast; use syntax::attr; use syntax::attr::IntType; -use trans::_match; -use trans::abi::FAT_PTR_ADDR; -use trans::base::InitAlloca; -use trans::build::*; -use trans::cleanup; -use trans::cleanup::CleanupMethods; -use trans::common::*; -use trans::datum; -use trans::debuginfo::DebugLoc; -use trans::glue; -use trans::machine; -use trans::monomorphize; -use trans::type_::Type; -use trans::type_of; -use trans::value::Value; +use _match; +use abi::FAT_PTR_ADDR; +use base::InitAlloca; +use build::*; +use cleanup; +use cleanup::CleanupMethods; +use common::*; +use datum; +use debuginfo::DebugLoc; +use glue; +use machine; +use monomorphize; +use type_::Type; +use type_of; +use value::Value; type Hint = attr::ReprAttr; diff --git a/src/librustc_trans/trans/asm.rs b/src/librustc_trans/asm.rs similarity index 96% rename from src/librustc_trans/trans/asm.rs rename to src/librustc_trans/asm.rs index 4d0c55131f765..41f1f4ae5f8ba 100644 --- a/src/librustc_trans/trans/asm.rs +++ b/src/librustc_trans/asm.rs @@ -11,12 +11,12 @@ //! # Translation of inline assembly. use llvm::{self, ValueRef}; -use trans::base; -use trans::build::*; -use trans::common::*; -use trans::datum::{Datum, Lvalue}; -use trans::type_of; -use trans::type_::Type; +use base; +use build::*; +use common::*; +use datum::{Datum, Lvalue}; +use type_of; +use type_::Type; use rustc_front::hir as ast; use std::ffi::CString; diff --git a/src/librustc_trans/trans/assert_dep_graph.rs b/src/librustc_trans/assert_dep_graph.rs similarity index 99% rename from src/librustc_trans/trans/assert_dep_graph.rs rename to src/librustc_trans/assert_dep_graph.rs index 11386715492b6..dcf23039e2563 100644 --- a/src/librustc_trans/trans/assert_dep_graph.rs +++ b/src/librustc_trans/assert_dep_graph.rs @@ -40,7 +40,7 @@ use graphviz as dot; use rustc::dep_graph::{DepGraphQuery, DepNode}; use rustc::middle::def_id::DefId; -use rustc::middle::ty::TyCtxt; +use rustc::ty::TyCtxt; use rustc_data_structures::fnv::{FnvHashMap, FnvHashSet}; use rustc_data_structures::graph::{Direction, INCOMING, OUTGOING, NodeIndex}; use rustc_front::hir; diff --git a/src/librustc_trans/trans/attributes.rs b/src/librustc_trans/attributes.rs similarity index 99% rename from src/librustc_trans/trans/attributes.rs rename to src/librustc_trans/attributes.rs index 4ea920c57aadb..cbf176cd87f70 100644 --- a/src/librustc_trans/trans/attributes.rs +++ b/src/librustc_trans/attributes.rs @@ -14,7 +14,7 @@ use llvm::{self, ValueRef}; use session::config::NoDebugInfo; pub use syntax::attr::InlineAttr; use syntax::ast; -use trans::context::CrateContext; +use context::CrateContext; /// Mark LLVM function to use provided inline heuristic. #[inline] diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index acb458f8cc6ee..89c0a9da6f24c 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -23,9 +23,11 @@ use session::Session; use middle::cstore::{self, CrateStore, LinkMeta}; use middle::cstore::{LinkagePreference, NativeLibraryKind}; use middle::dependency_format::Linkage; -use middle::ty::{Ty, TyCtxt}; +use rustc::ty::{Ty, TyCtxt}; use rustc::front::map::DefPath; -use trans::{CrateContext, CrateTranslation, gensym_name}; +use CrateTranslation; +use common::gensym_name; +use context::CrateContext; use util::common::time; use util::sha2::{Digest, Sha256}; use util::fs::fix_windows_verbatim_for_gcc; diff --git a/src/librustc_trans/back/linker.rs b/src/librustc_trans/back/linker.rs index b6b330c3734b0..f0274eeb862c4 100644 --- a/src/librustc_trans/back/linker.rs +++ b/src/librustc_trans/back/linker.rs @@ -22,7 +22,7 @@ use session::Session; use session::config::CrateTypeDylib; use session::config; use syntax::ast; -use trans::CrateTranslation; +use CrateTranslation; /// Linker abstraction used by back::link to build up the command to invoke a /// linker. diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index 92d8b928ef428..2de650a59beda 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -16,7 +16,7 @@ use session::config::{self, OutputType}; use llvm; use llvm::{ModuleRef, TargetMachineRef, PassManagerRef, DiagnosticInfoRef, ContextRef}; use llvm::SMDiagnosticRef; -use trans::{CrateTranslation, ModuleTranslation}; +use {CrateTranslation, ModuleTranslation}; use util::common::time; use util::common::path2cstr; use syntax::codemap; diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/base.rs similarity index 98% rename from src/librustc_trans/trans/base.rs rename to src/librustc_trans/base.rs index 1d8daf9d86b4a..34726720afcc3 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/base.rs @@ -34,62 +34,62 @@ use back::link; use lint; use llvm::{BasicBlockRef, Linkage, ValueRef, Vector, get_param}; use llvm; -use middle::cfg; +use rustc::cfg; use middle::cstore::CrateStore; use middle::def_id::DefId; -use middle::infer; +use rustc::infer; use middle::lang_items::{LangItem, ExchangeMallocFnLangItem, StartFnLangItem}; use middle::weak_lang_items; use middle::pat_util::simple_name; -use middle::subst::{self, Substs}; -use middle::traits; -use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; -use middle::ty::adjustment::CustomCoerceUnsized; +use rustc::ty::subst::{self, Substs}; +use rustc::traits; +use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; +use rustc::ty::adjustment::CustomCoerceUnsized; use rustc::dep_graph::DepNode; use rustc::front::map as hir_map; use rustc::util::common::time; use rustc::mir::mir_map::MirMap; use session::config::{self, NoDebugInfo, FullDebugInfo}; use session::Session; -use trans::_match; -use trans::abi::{self, Abi, FnType}; -use trans::adt; -use trans::assert_dep_graph; -use trans::attributes; -use trans::build::*; -use trans::builder::{Builder, noname}; -use trans::callee::{Callee, CallArgs, ArgExprs, ArgVals}; -use trans::cleanup::{self, CleanupMethods, DropHint}; -use trans::closure; -use trans::common::{Block, C_bool, C_bytes_in_context, C_i32, C_int, C_uint, C_integral}; -use trans::collector::{self, TransItem, TransItemState, TransItemCollectionMode}; -use trans::common::{C_null, C_struct_in_context, C_u64, C_u8, C_undef}; -use trans::common::{CrateContext, DropFlagHintsMap, Field, FunctionContext}; -use trans::common::{Result, NodeIdAndSpan, VariantInfo}; -use trans::common::{node_id_type, fulfill_obligation}; -use trans::common::{type_is_immediate, type_is_zero_size, val_ty}; -use trans::common; -use trans::consts; -use trans::context::SharedCrateContext; -use trans::controlflow; -use trans::datum; -use trans::debuginfo::{self, DebugLoc, ToDebugLoc}; -use trans::declare; -use trans::expr; -use trans::glue; -use trans::inline; -use trans::intrinsic; -use trans::machine; -use trans::machine::{llalign_of_min, llsize_of, llsize_of_real}; -use trans::meth; -use trans::mir; -use trans::monomorphize::{self, Instance}; -use trans::tvec; -use trans::type_::Type; -use trans::type_of; -use trans::type_of::*; -use trans::value::Value; -use trans::Disr; +use _match; +use abi::{self, Abi, FnType}; +use adt; +use assert_dep_graph; +use attributes; +use build::*; +use builder::{Builder, noname}; +use callee::{Callee, CallArgs, ArgExprs, ArgVals}; +use cleanup::{self, CleanupMethods, DropHint}; +use closure; +use common::{Block, C_bool, C_bytes_in_context, C_i32, C_int, C_uint, C_integral}; +use collector::{self, TransItem, TransItemState, TransItemCollectionMode}; +use common::{C_null, C_struct_in_context, C_u64, C_u8, C_undef}; +use common::{CrateContext, DropFlagHintsMap, Field, FunctionContext}; +use common::{Result, NodeIdAndSpan, VariantInfo}; +use common::{node_id_type, fulfill_obligation}; +use common::{type_is_immediate, type_is_zero_size, val_ty}; +use common; +use consts; +use context::SharedCrateContext; +use controlflow; +use datum; +use debuginfo::{self, DebugLoc, ToDebugLoc}; +use declare; +use expr; +use glue; +use inline; +use intrinsic; +use machine; +use machine::{llalign_of_min, llsize_of, llsize_of_real}; +use meth; +use mir; +use monomorphize::{self, Instance}; +use tvec; +use type_::Type; +use type_of; +use type_of::*; +use value::Value; +use Disr; use util::common::indenter; use util::sha2::Sha256; use util::nodemap::{NodeMap, NodeSet}; diff --git a/src/librustc_trans/trans/basic_block.rs b/src/librustc_trans/basic_block.rs similarity index 97% rename from src/librustc_trans/trans/basic_block.rs rename to src/librustc_trans/basic_block.rs index d3d055cda1202..919ea49b392c6 100644 --- a/src/librustc_trans/trans/basic_block.rs +++ b/src/librustc_trans/basic_block.rs @@ -10,7 +10,7 @@ use llvm; use llvm::BasicBlockRef; -use trans::value::{Users, Value}; +use value::{Users, Value}; use std::iter::{Filter, Map}; #[derive(Copy, Clone)] diff --git a/src/librustc_trans/trans/build.rs b/src/librustc_trans/build.rs similarity index 99% rename from src/librustc_trans/trans/build.rs rename to src/librustc_trans/build.rs index 53e64c086a8db..0ce7fdb8b6d1d 100644 --- a/src/librustc_trans/trans/build.rs +++ b/src/librustc_trans/build.rs @@ -15,13 +15,13 @@ use llvm; use llvm::{AtomicBinOp, AtomicOrdering, SynchronizationScope, AsmDialect}; use llvm::{Opcode, IntPredicate, RealPredicate}; use llvm::{ValueRef, BasicBlockRef}; -use trans::common::*; +use common::*; use syntax::codemap::Span; -use trans::builder::Builder; -use trans::type_::Type; -use trans::value::Value; -use trans::debuginfo::DebugLoc; +use builder::Builder; +use type_::Type; +use value::Value; +use debuginfo::DebugLoc; use libc::{c_uint, c_char}; diff --git a/src/librustc_trans/trans/builder.rs b/src/librustc_trans/builder.rs similarity index 99% rename from src/librustc_trans/trans/builder.rs rename to src/librustc_trans/builder.rs index 869e9212b1cf6..55f65d29bfd6d 100644 --- a/src/librustc_trans/trans/builder.rs +++ b/src/librustc_trans/builder.rs @@ -14,11 +14,11 @@ use llvm; use llvm::{AtomicBinOp, AtomicOrdering, SynchronizationScope, AsmDialect}; use llvm::{Opcode, IntPredicate, RealPredicate, False, OperandBundleDef}; use llvm::{ValueRef, BasicBlockRef, BuilderRef, ModuleRef}; -use trans::base; -use trans::common::*; -use trans::machine::llalign_of_pref; -use trans::type_::Type; -use trans::value::Value; +use base; +use common::*; +use machine::llalign_of_pref; +use type_::Type; +use value::Value; use util::nodemap::FnvHashMap; use libc::{c_uint, c_char}; diff --git a/src/librustc_trans/trans/cabi_aarch64.rs b/src/librustc_trans/cabi_aarch64.rs similarity index 98% rename from src/librustc_trans/trans/cabi_aarch64.rs rename to src/librustc_trans/cabi_aarch64.rs index 6eea8d472ba55..b2929d118a6af 100644 --- a/src/librustc_trans/trans/cabi_aarch64.rs +++ b/src/librustc_trans/cabi_aarch64.rs @@ -11,9 +11,9 @@ #![allow(non_upper_case_globals)] use llvm::{Integer, Pointer, Float, Double, Struct, Array, Vector}; -use trans::abi::{FnType, ArgType}; -use trans::context::CrateContext; -use trans::type_::Type; +use abi::{FnType, ArgType}; +use context::CrateContext; +use type_::Type; use std::cmp; diff --git a/src/librustc_trans/trans/cabi_arm.rs b/src/librustc_trans/cabi_arm.rs similarity index 98% rename from src/librustc_trans/trans/cabi_arm.rs rename to src/librustc_trans/cabi_arm.rs index 14ca77836c28f..5dbcf1ef86ea5 100644 --- a/src/librustc_trans/trans/cabi_arm.rs +++ b/src/librustc_trans/cabi_arm.rs @@ -11,9 +11,9 @@ #![allow(non_upper_case_globals)] use llvm::{Integer, Pointer, Float, Double, Struct, Array, Vector}; -use trans::abi::{FnType, ArgType}; -use trans::context::CrateContext; -use trans::type_::Type; +use abi::{FnType, ArgType}; +use context::CrateContext; +use type_::Type; use std::cmp; diff --git a/src/librustc_trans/trans/cabi_asmjs.rs b/src/librustc_trans/cabi_asmjs.rs similarity index 95% rename from src/librustc_trans/trans/cabi_asmjs.rs rename to src/librustc_trans/cabi_asmjs.rs index c901442f48548..3cbc378ab0216 100644 --- a/src/librustc_trans/trans/cabi_asmjs.rs +++ b/src/librustc_trans/cabi_asmjs.rs @@ -11,8 +11,8 @@ #![allow(non_upper_case_globals)] use llvm::{Struct, Array, Attribute}; -use trans::abi::{FnType, ArgType}; -use trans::context::CrateContext; +use abi::{FnType, ArgType}; +use context::CrateContext; // Data layout: e-p:32:32-i64:64-v128:32:128-n32-S128 diff --git a/src/librustc_trans/trans/cabi_mips.rs b/src/librustc_trans/cabi_mips.rs similarity index 97% rename from src/librustc_trans/trans/cabi_mips.rs rename to src/librustc_trans/cabi_mips.rs index 0d5e81be92142..d0fce01ce73a9 100644 --- a/src/librustc_trans/trans/cabi_mips.rs +++ b/src/librustc_trans/cabi_mips.rs @@ -14,9 +14,9 @@ use libc::c_uint; use std::cmp; use llvm; use llvm::{Integer, Pointer, Float, Double, Struct, Array, Vector}; -use trans::abi::{ArgType, FnType}; -use trans::context::CrateContext; -use trans::type_::Type; +use abi::{ArgType, FnType}; +use context::CrateContext; +use type_::Type; fn align_up_to(off: usize, a: usize) -> usize { return (off + a - 1) / a * a; diff --git a/src/librustc_trans/trans/cabi_powerpc.rs b/src/librustc_trans/cabi_powerpc.rs similarity index 97% rename from src/librustc_trans/trans/cabi_powerpc.rs rename to src/librustc_trans/cabi_powerpc.rs index 9aa89a04d0a9a..c9751aa25c1e2 100644 --- a/src/librustc_trans/trans/cabi_powerpc.rs +++ b/src/librustc_trans/cabi_powerpc.rs @@ -11,9 +11,9 @@ use libc::c_uint; use llvm; use llvm::{Integer, Pointer, Float, Double, Struct, Array}; -use trans::abi::{FnType, ArgType}; -use trans::context::CrateContext; -use trans::type_::Type; +use abi::{FnType, ArgType}; +use context::CrateContext; +use type_::Type; use std::cmp; diff --git a/src/librustc_trans/trans/cabi_powerpc64.rs b/src/librustc_trans/cabi_powerpc64.rs similarity index 98% rename from src/librustc_trans/trans/cabi_powerpc64.rs rename to src/librustc_trans/cabi_powerpc64.rs index 340de235732f9..7e7033b4686e0 100644 --- a/src/librustc_trans/trans/cabi_powerpc64.rs +++ b/src/librustc_trans/cabi_powerpc64.rs @@ -16,9 +16,9 @@ // need to be fixed when PowerPC vector support is added. use llvm::{Integer, Pointer, Float, Double, Struct, Array}; -use trans::abi::{FnType, ArgType}; -use trans::context::CrateContext; -use trans::type_::Type; +use abi::{FnType, ArgType}; +use context::CrateContext; +use type_::Type; use std::cmp; diff --git a/src/librustc_trans/trans/cabi_x86.rs b/src/librustc_trans/cabi_x86.rs similarity index 97% rename from src/librustc_trans/trans/cabi_x86.rs rename to src/librustc_trans/cabi_x86.rs index 9e6c4d9af42ee..415579eb221dd 100644 --- a/src/librustc_trans/trans/cabi_x86.rs +++ b/src/librustc_trans/cabi_x86.rs @@ -9,8 +9,8 @@ // except according to those terms. use llvm::*; -use trans::abi::FnType; -use trans::type_::Type; +use abi::FnType; +use type_::Type; use super::common::*; use super::machine::*; diff --git a/src/librustc_trans/trans/cabi_x86_64.rs b/src/librustc_trans/cabi_x86_64.rs similarity index 99% rename from src/librustc_trans/trans/cabi_x86_64.rs rename to src/librustc_trans/cabi_x86_64.rs index 47d373f90431e..a08d9fb5b4095 100644 --- a/src/librustc_trans/trans/cabi_x86_64.rs +++ b/src/librustc_trans/cabi_x86_64.rs @@ -16,9 +16,9 @@ use self::RegClass::*; use llvm::{Integer, Pointer, Float, Double}; use llvm::{Struct, Array, Attribute, Vector}; -use trans::abi::{ArgType, FnType}; -use trans::context::CrateContext; -use trans::type_::Type; +use abi::{ArgType, FnType}; +use context::CrateContext; +use type_::Type; use std::cmp; diff --git a/src/librustc_trans/trans/cabi_x86_win64.rs b/src/librustc_trans/cabi_x86_win64.rs similarity index 95% rename from src/librustc_trans/trans/cabi_x86_win64.rs rename to src/librustc_trans/cabi_x86_win64.rs index 43f72c454cf02..a5077f68fb58c 100644 --- a/src/librustc_trans/trans/cabi_x86_win64.rs +++ b/src/librustc_trans/cabi_x86_win64.rs @@ -11,8 +11,8 @@ use llvm::*; use super::common::*; use super::machine::*; -use trans::abi::{ArgType, FnType}; -use trans::type_::Type; +use abi::{ArgType, FnType}; +use type_::Type; // Win64 ABI: http://msdn.microsoft.com/en-us/library/zthk2dkh.aspx diff --git a/src/librustc_trans/trans/callee.rs b/src/librustc_trans/callee.rs similarity index 97% rename from src/librustc_trans/trans/callee.rs rename to src/librustc_trans/callee.rs index 1013c5d64b609..d530f31b676af 100644 --- a/src/librustc_trans/trans/callee.rs +++ b/src/librustc_trans/callee.rs @@ -22,38 +22,38 @@ use back::link; use llvm::{self, ValueRef, get_params}; use middle::cstore::LOCAL_CRATE; use middle::def_id::DefId; -use middle::infer; -use middle::subst; -use middle::subst::{Substs}; -use middle::traits; +use rustc::infer; +use rustc::ty::subst; +use rustc::ty::subst::{Substs}; +use rustc::traits; use rustc::front::map as hir_map; -use trans::abi::{Abi, FnType}; -use trans::adt; -use trans::attributes; -use trans::base; -use trans::base::*; -use trans::build::*; -use trans::cleanup; -use trans::cleanup::CleanupMethods; -use trans::closure; -use trans::common::{self, Block, Result, CrateContext, FunctionContext}; -use trans::common::{C_uint, C_undef}; -use trans::consts; -use trans::datum::*; -use trans::debuginfo::DebugLoc; -use trans::declare; -use trans::expr; -use trans::glue; -use trans::inline; -use trans::intrinsic; -use trans::machine::{llalign_of_min, llsize_of_store}; -use trans::meth; -use trans::monomorphize::{self, Instance}; -use trans::type_::Type; -use trans::type_of; -use trans::value::Value; -use trans::Disr; -use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; +use abi::{Abi, FnType}; +use adt; +use attributes; +use base; +use base::*; +use build::*; +use cleanup; +use cleanup::CleanupMethods; +use closure; +use common::{self, Block, Result, CrateContext, FunctionContext}; +use common::{C_uint, C_undef}; +use consts; +use datum::*; +use debuginfo::DebugLoc; +use declare; +use expr; +use glue; +use inline; +use intrinsic; +use machine::{llalign_of_min, llsize_of_store}; +use meth; +use monomorphize::{self, Instance}; +use type_::Type; +use type_of; +use value::Value; +use Disr; +use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc_front::hir; use syntax::codemap::DUMMY_SP; diff --git a/src/librustc_trans/trans/cleanup.rs b/src/librustc_trans/cleanup.rs similarity index 99% rename from src/librustc_trans/trans/cleanup.rs rename to src/librustc_trans/cleanup.rs index bd2d05915f6db..3a8dc144f9c7e 100644 --- a/src/librustc_trans/trans/cleanup.rs +++ b/src/librustc_trans/cleanup.rs @@ -120,17 +120,17 @@ pub use self::EarlyExitLabel::*; pub use self::Heap::*; use llvm::{BasicBlockRef, ValueRef}; -use trans::base; -use trans::build; -use trans::common; -use trans::common::{Block, FunctionContext, NodeIdAndSpan, LandingPad}; -use trans::datum::{Datum, Lvalue}; -use trans::debuginfo::{DebugLoc, ToDebugLoc}; -use trans::glue; +use base; +use build; +use common; +use common::{Block, FunctionContext, NodeIdAndSpan, LandingPad}; +use datum::{Datum, Lvalue}; +use debuginfo::{DebugLoc, ToDebugLoc}; +use glue; use middle::region; -use trans::type_::Type; -use trans::value::Value; -use middle::ty::{Ty, TyCtxt}; +use type_::Type; +use value::Value; +use rustc::ty::{Ty, TyCtxt}; use std::fmt; use syntax::ast; diff --git a/src/librustc_trans/trans/closure.rs b/src/librustc_trans/closure.rs similarity index 96% rename from src/librustc_trans/trans/closure.rs rename to src/librustc_trans/closure.rs index dbabc3f54c594..dd8848eb6e72b 100644 --- a/src/librustc_trans/trans/closure.rs +++ b/src/librustc_trans/closure.rs @@ -12,25 +12,25 @@ use arena::TypedArena; use back::link::{self, mangle_internal_name_by_path_and_seq}; use llvm::{ValueRef, get_param, get_params}; use middle::def_id::DefId; -use middle::infer; -use middle::traits::ProjectionMode; -use trans::abi::{Abi, FnType}; -use trans::adt; -use trans::attributes; -use trans::base::*; -use trans::build::*; -use trans::callee::{self, ArgVals, Callee}; -use trans::cleanup::{CleanupMethods, CustomScope, ScopeId}; -use trans::common::*; -use trans::datum::{ByRef, Datum, lvalue_scratch_datum}; -use trans::datum::{rvalue_scratch_datum, Rvalue}; -use trans::debuginfo::{self, DebugLoc}; -use trans::declare; -use trans::expr; -use trans::monomorphize::{Instance}; -use trans::value::Value; -use trans::Disr; -use middle::ty::{self, Ty, TyCtxt}; +use rustc::infer; +use rustc::traits::ProjectionMode; +use abi::{Abi, FnType}; +use adt; +use attributes; +use base::*; +use build::*; +use callee::{self, ArgVals, Callee}; +use cleanup::{CleanupMethods, CustomScope, ScopeId}; +use common::*; +use datum::{ByRef, Datum, lvalue_scratch_datum}; +use datum::{rvalue_scratch_datum, Rvalue}; +use debuginfo::{self, DebugLoc}; +use declare; +use expr; +use monomorphize::{Instance}; +use value::Value; +use Disr; +use rustc::ty::{self, Ty, TyCtxt}; use session::config::FullDebugInfo; use syntax::ast; diff --git a/src/librustc_trans/trans/collector.rs b/src/librustc_trans/collector.rs similarity index 99% rename from src/librustc_trans/trans/collector.rs rename to src/librustc_trans/collector.rs index ab8f7d6bec3d5..1d81d30fbf24d 100644 --- a/src/librustc_trans/trans/collector.rs +++ b/src/librustc_trans/collector.rs @@ -194,10 +194,10 @@ use rustc_front::intravisit as hir_visit; use rustc::front::map as hir_map; use rustc::middle::def_id::DefId; use rustc::middle::lang_items::{ExchangeFreeFnLangItem, ExchangeMallocFnLangItem}; -use rustc::middle::traits; -use rustc::middle::subst::{self, Substs, Subst}; -use rustc::middle::ty::{self, Ty, TypeFoldable}; -use rustc::middle::ty::adjustment::CustomCoerceUnsized; +use rustc::traits; +use rustc::ty::subst::{self, Substs, Subst}; +use rustc::ty::{self, Ty, TypeFoldable}; +use rustc::ty::adjustment::CustomCoerceUnsized; use rustc::mir::repr as mir; use rustc::mir::visit as mir_visit; use rustc::mir::visit::Visitor as MirVisitor; @@ -207,13 +207,13 @@ use syntax::codemap::DUMMY_SP; use syntax::errors; use syntax::parse::token; -use trans::base::custom_coerce_unsize_info; -use trans::context::CrateContext; -use trans::common::{fulfill_obligation, normalize_and_test_predicates, +use base::custom_coerce_unsize_info; +use context::CrateContext; +use common::{fulfill_obligation, normalize_and_test_predicates, type_is_sized}; -use trans::glue; -use trans::meth; -use trans::monomorphize::{self, Instance}; +use glue; +use meth; +use monomorphize::{self, Instance}; use util::nodemap::{FnvHashSet, FnvHashMap, DefIdMap}; use std::hash::{Hash, Hasher}; @@ -580,7 +580,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, }; if let Some(destructor_did) = destructor_did { - use rustc::middle::ty::ToPolyTraitRef; + use rustc::ty::ToPolyTraitRef; let drop_trait_def_id = ccx.tcx() .lang_items @@ -1202,7 +1202,7 @@ pub fn push_unique_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, output.push_str("unsafe "); } - if abi != ::trans::abi::Abi::Rust { + if abi != ::abi::Abi::Rust { output.push_str("extern \""); output.push_str(abi.name()); output.push_str("\" "); diff --git a/src/librustc_trans/trans/common.rs b/src/librustc_trans/common.rs similarity index 98% rename from src/librustc_trans/trans/common.rs rename to src/librustc_trans/common.rs index db06b2352fd35..c5d54e30f13fa 100644 --- a/src/librustc_trans/trans/common.rs +++ b/src/librustc_trans/common.rs @@ -16,30 +16,30 @@ use session::Session; use llvm; use llvm::{ValueRef, BasicBlockRef, BuilderRef, ContextRef, TypeKind}; use llvm::{True, False, Bool, OperandBundleDef}; -use middle::cfg; +use rustc::cfg; use middle::def::Def; use middle::def_id::DefId; -use middle::infer; +use rustc::infer; use middle::lang_items::LangItem; -use middle::subst::Substs; -use trans::abi::{Abi, FnType}; -use trans::base; -use trans::build; -use trans::builder::Builder; -use trans::callee::Callee; -use trans::cleanup; -use trans::consts; -use trans::datum; -use trans::debuginfo::{self, DebugLoc}; -use trans::declare; -use trans::machine; -use trans::mir::CachedMir; -use trans::monomorphize; -use trans::type_::Type; -use trans::value::Value; -use middle::ty::{self, Ty, TyCtxt}; -use middle::traits::{self, SelectionContext, ProjectionMode}; -use middle::ty::fold::{TypeFolder, TypeFoldable}; +use rustc::ty::subst::Substs; +use abi::{Abi, FnType}; +use base; +use build; +use builder::Builder; +use callee::Callee; +use cleanup; +use consts; +use datum; +use debuginfo::{self, DebugLoc}; +use declare; +use machine; +use mir::CachedMir; +use monomorphize; +use type_::Type; +use value::Value; +use rustc::ty::{self, Ty, TyCtxt}; +use rustc::traits::{self, SelectionContext, ProjectionMode}; +use rustc::ty::fold::{TypeFolder, TypeFoldable}; use rustc_front::hir; use util::nodemap::NodeMap; @@ -54,7 +54,7 @@ use syntax::codemap::{DUMMY_SP, Span}; use syntax::parse::token::InternedString; use syntax::parse::token; -pub use trans::context::CrateContext; +pub use context::CrateContext; /// Is the type's representation size known at compile time? pub fn type_is_sized<'tcx>(tcx: &TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { @@ -75,8 +75,8 @@ pub fn type_is_fat_ptr<'tcx>(cx: &TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool { } pub fn type_is_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool { - use trans::machine::llsize_of_alloc; - use trans::type_of::sizing_type_of; + use machine::llsize_of_alloc; + use type_of::sizing_type_of; let tcx = ccx.tcx(); let simple = ty.is_scalar() || @@ -100,8 +100,8 @@ pub fn type_is_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) - /// Identify types which have size zero at runtime. pub fn type_is_zero_size<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool { - use trans::machine::llsize_of_alloc; - use trans::type_of::sizing_type_of; + use machine::llsize_of_alloc; + use type_of::sizing_type_of; let llty = sizing_type_of(ccx, ty); llsize_of_alloc(ccx, llty) == 0 } @@ -141,7 +141,7 @@ pub fn gensym_name(name: &str) -> ast::Name { * */ -use trans::Disr; +use Disr; #[derive(Copy, Clone)] pub struct NodeIdAndSpan { @@ -491,7 +491,7 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> { // Returns a ValueRef of the "eh_unwind_resume" lang item if one is defined, // otherwise declares it as an external function. pub fn eh_unwind_resume(&self) -> Callee<'tcx> { - use trans::attributes; + use attributes; let ccx = self.ccx; let tcx = ccx.tcx(); assert!(ccx.sess().target.target.options.custom_unwind_resume); diff --git a/src/librustc_trans/trans/consts.rs b/src/librustc_trans/consts.rs similarity index 98% rename from src/librustc_trans/trans/consts.rs rename to src/librustc_trans/consts.rs index 7e6b24969100b..b7d4ff3f42265 100644 --- a/src/librustc_trans/trans/consts.rs +++ b/src/librustc_trans/consts.rs @@ -17,26 +17,26 @@ use middle::const_eval::{self, ConstEvalErr}; use middle::def::Def; use middle::def_id::DefId; use rustc::front::map as hir_map; -use trans::{abi, adt, closure, debuginfo, expr, machine}; -use trans::base::{self, exported_name, imported_name, push_ctxt}; -use trans::callee::Callee; -use trans::collector::{self, TransItem}; -use trans::common::{type_is_sized, C_nil, const_get_elt}; -use trans::common::{CrateContext, C_integral, C_floating, C_bool, C_str_slice, C_bytes, val_ty}; -use trans::common::{C_struct, C_undef, const_to_opt_int, const_to_opt_uint, VariantInfo, C_uint}; -use trans::common::{type_is_fat_ptr, Field, C_vector, C_array, C_null}; -use trans::datum::{Datum, Lvalue}; -use trans::declare; -use trans::monomorphize::{self, Instance}; -use trans::type_::Type; -use trans::type_of; -use trans::value::Value; -use trans::Disr; -use middle::subst::Substs; -use middle::ty::adjustment::{AdjustDerefRef, AdjustReifyFnPointer}; -use middle::ty::adjustment::{AdjustUnsafeFnPointer, AdjustMutToConstPointer}; -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::cast::{CastTy,IntTy}; +use {abi, adt, closure, debuginfo, expr, machine}; +use base::{self, exported_name, imported_name, push_ctxt}; +use callee::Callee; +use collector::{self, TransItem}; +use common::{type_is_sized, C_nil, const_get_elt}; +use common::{CrateContext, C_integral, C_floating, C_bool, C_str_slice, C_bytes, val_ty}; +use common::{C_struct, C_undef, const_to_opt_int, const_to_opt_uint, VariantInfo, C_uint}; +use common::{type_is_fat_ptr, Field, C_vector, C_array, C_null}; +use datum::{Datum, Lvalue}; +use declare; +use monomorphize::{self, Instance}; +use type_::Type; +use type_of; +use value::Value; +use Disr; +use rustc::ty::subst::Substs; +use rustc::ty::adjustment::{AdjustDerefRef, AdjustReifyFnPointer}; +use rustc::ty::adjustment::{AdjustUnsafeFnPointer, AdjustMutToConstPointer}; +use rustc::ty::{self, Ty, TyCtxt}; +use rustc::ty::cast::{CastTy,IntTy}; use util::nodemap::NodeMap; use rustc_const_eval::{ConstInt, ConstMathErr, ConstUsize, ConstIsize}; diff --git a/src/librustc_trans/trans/context.rs b/src/librustc_trans/context.rs similarity index 98% rename from src/librustc_trans/trans/context.rs rename to src/librustc_trans/context.rs index 046e05dd0710a..d4e0aa3a4948c 100644 --- a/src/librustc_trans/trans/context.rs +++ b/src/librustc_trans/context.rs @@ -14,22 +14,22 @@ use rustc::dep_graph::{DepNode, DepTrackingMap, DepTrackingMapConfig}; use middle::cstore::LinkMeta; use middle::def::ExportMap; use middle::def_id::DefId; -use middle::traits; +use rustc::traits; use rustc::mir::mir_map::MirMap; use rustc::mir::repr as mir; -use trans::adt; -use trans::base; -use trans::builder::Builder; -use trans::common::BuilderRef_res; -use trans::debuginfo; -use trans::declare; -use trans::glue::DropGlueKind; -use trans::mir::CachedMir; -use trans::monomorphize::Instance; -use trans::collector::{TransItem, TransItemState}; -use trans::type_::{Type, TypeNames}; -use middle::subst::{Substs, VecPerParamSpace}; -use middle::ty::{self, Ty, TyCtxt}; +use adt; +use base; +use builder::Builder; +use common::BuilderRef_res; +use debuginfo; +use declare; +use glue::DropGlueKind; +use mir::CachedMir; +use monomorphize::Instance; +use collector::{TransItem, TransItemState}; +use type_::{Type, TypeNames}; +use rustc::ty::subst::{Substs, VecPerParamSpace}; +use rustc::ty::{self, Ty, TyCtxt}; use session::config::NoDebugInfo; use session::Session; use util::sha2::Sha256; diff --git a/src/librustc_trans/trans/controlflow.rs b/src/librustc_trans/controlflow.rs similarity index 95% rename from src/librustc_trans/trans/controlflow.rs rename to src/librustc_trans/controlflow.rs index 91454df156655..04562087af7b7 100644 --- a/src/librustc_trans/trans/controlflow.rs +++ b/src/librustc_trans/controlflow.rs @@ -11,20 +11,19 @@ use llvm::ValueRef; use middle::def::Def; use middle::lang_items::{PanicFnLangItem, PanicBoundsCheckFnLangItem}; -use middle::subst::Substs; -use trans::base::*; -use trans::basic_block::BasicBlock; -use trans::build::*; -use trans::callee::{Callee, ArgVals}; -use trans::cleanup::CleanupMethods; -use trans::cleanup; -use trans::common::*; -use trans::consts; -use trans::debuginfo; -use trans::debuginfo::{DebugLoc, ToDebugLoc}; -use trans::expr; -use trans::machine; -use trans; +use rustc::ty::subst::Substs; +use base::*; +use basic_block::BasicBlock; +use build::*; +use callee::{Callee, ArgVals}; +use cleanup::CleanupMethods; +use cleanup; +use common::*; +use consts; +use debuginfo; +use debuginfo::{DebugLoc, ToDebugLoc}; +use expr; +use machine; use rustc_front::hir; use rustc_front::util as ast_util; @@ -169,11 +168,11 @@ pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, if cv == 1 { // if true { .. } [else { .. }] bcx = trans_block(bcx, &thn, dest); - trans::debuginfo::clear_source_location(bcx.fcx); + debuginfo::clear_source_location(bcx.fcx); } else { if let Some(elexpr) = els { bcx = expr::trans_into(bcx, &elexpr, dest); - trans::debuginfo::clear_source_location(bcx.fcx); + debuginfo::clear_source_location(bcx.fcx); } } @@ -183,7 +182,7 @@ pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let name = format!("then-block-{}-", thn.id); let then_bcx_in = bcx.fcx.new_id_block(&name[..], thn.id); let then_bcx_out = trans_block(then_bcx_in, &thn, dest); - trans::debuginfo::clear_source_location(bcx.fcx); + debuginfo::clear_source_location(bcx.fcx); let cond_source_loc = cond.debug_loc(); @@ -206,7 +205,7 @@ pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // Clear the source location because it is still set to whatever has been translated // right before. - trans::debuginfo::clear_source_location(next_bcx.fcx); + debuginfo::clear_source_location(next_bcx.fcx); next_bcx } diff --git a/src/librustc_trans/trans/datum.rs b/src/librustc_trans/datum.rs similarity index 99% rename from src/librustc_trans/trans/datum.rs rename to src/librustc_trans/datum.rs index 649f6180de20b..6f96b5769bfe3 100644 --- a/src/librustc_trans/trans/datum.rs +++ b/src/librustc_trans/datum.rs @@ -93,16 +93,16 @@ pub use self::Expr::*; pub use self::RvalueMode::*; use llvm::ValueRef; -use trans::adt; -use trans::base::*; -use trans::build::{Load, Store}; -use trans::common::*; -use trans::cleanup; -use trans::cleanup::{CleanupMethods, DropHintDatum, DropHintMethods}; -use trans::expr; -use trans::tvec; -use trans::value::Value; -use middle::ty::Ty; +use adt; +use base::*; +use build::{Load, Store}; +use common::*; +use cleanup; +use cleanup::{CleanupMethods, DropHintDatum, DropHintMethods}; +use expr; +use tvec; +use value::Value; +use rustc::ty::Ty; use std::fmt; use syntax::ast; diff --git a/src/librustc_trans/trans/debuginfo/create_scope_map.rs b/src/librustc_trans/debuginfo/create_scope_map.rs similarity index 99% rename from src/librustc_trans/trans/debuginfo/create_scope_map.rs rename to src/librustc_trans/debuginfo/create_scope_map.rs index 41fed12e7bf3c..20e8a3fb0cfec 100644 --- a/src/librustc_trans/trans/debuginfo/create_scope_map.rs +++ b/src/librustc_trans/debuginfo/create_scope_map.rs @@ -13,7 +13,7 @@ use super::utils::DIB; use llvm; use llvm::debuginfo::{DIScope, DISubprogram}; -use trans::common::CrateContext; +use common::CrateContext; use middle::pat_util; use rustc::util::nodemap::NodeMap; diff --git a/src/librustc_trans/trans/debuginfo/doc.rs b/src/librustc_trans/debuginfo/doc.rs similarity index 100% rename from src/librustc_trans/trans/debuginfo/doc.rs rename to src/librustc_trans/debuginfo/doc.rs diff --git a/src/librustc_trans/trans/debuginfo/gdb.rs b/src/librustc_trans/debuginfo/gdb.rs similarity index 97% rename from src/librustc_trans/trans/debuginfo/gdb.rs rename to src/librustc_trans/debuginfo/gdb.rs index 4e3fadd0fa911..d9e36b4f68134 100644 --- a/src/librustc_trans/trans/debuginfo/gdb.rs +++ b/src/librustc_trans/debuginfo/gdb.rs @@ -12,9 +12,9 @@ use llvm; -use trans::common::{C_bytes, CrateContext, C_i32}; -use trans::declare; -use trans::type_::Type; +use common::{C_bytes, CrateContext, C_i32}; +use declare; +use type_::Type; use session::config::NoDebugInfo; use std::ffi::CString; diff --git a/src/librustc_trans/trans/debuginfo/metadata.rs b/src/librustc_trans/debuginfo/metadata.rs similarity index 99% rename from src/librustc_trans/trans/debuginfo/metadata.rs rename to src/librustc_trans/debuginfo/metadata.rs index e22d42e9d28da..af7ccdb6cf51e 100644 --- a/src/librustc_trans/trans/debuginfo/metadata.rs +++ b/src/librustc_trans/debuginfo/metadata.rs @@ -24,16 +24,16 @@ use llvm::{self, ValueRef}; use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor, DICompositeType}; use middle::def_id::DefId; -use middle::infer; +use rustc::infer; use middle::pat_util; -use middle::subst; +use rustc::ty::subst; use rustc::front::map as hir_map; use rustc_front::hir::{self, PatKind}; -use trans::{type_of, adt, machine, monomorphize}; -use trans::common::{self, CrateContext, FunctionContext, Block}; -use trans::_match::{BindingInfo, TransBindingMode}; -use trans::type_::Type; -use middle::ty::{self, Ty}; +use {type_of, adt, machine, monomorphize}; +use common::{self, CrateContext, FunctionContext, Block}; +use _match::{BindingInfo, TransBindingMode}; +use type_::Type; +use rustc::ty::{self, Ty}; use session::config::{self, FullDebugInfo}; use util::nodemap::FnvHashMap; use util::common::path2cstr; diff --git a/src/librustc_trans/trans/debuginfo/mod.rs b/src/librustc_trans/debuginfo/mod.rs similarity index 98% rename from src/librustc_trans/trans/debuginfo/mod.rs rename to src/librustc_trans/debuginfo/mod.rs index 40eb29ed25050..66e33698389ae 100644 --- a/src/librustc_trans/trans/debuginfo/mod.rs +++ b/src/librustc_trans/debuginfo/mod.rs @@ -27,17 +27,16 @@ use llvm::{ModuleRef, ContextRef, ValueRef}; use llvm::debuginfo::{DIFile, DIType, DIScope, DIBuilderRef, DISubprogram, DIArray, DIDescriptor, FlagPrototyped}; use middle::def_id::DefId; -use middle::infer::normalize_associated_type; -use middle::subst::{self, Substs}; +use rustc::infer::normalize_associated_type; +use rustc::ty::subst::{self, Substs}; use rustc_front; use rustc_front::hir; -use trans::abi::Abi; -use trans::common::{NodeIdAndSpan, CrateContext, FunctionContext, Block}; -use trans; -use trans::monomorphize; -use middle::infer; -use middle::ty::{self, Ty}; +use abi::Abi; +use common::{NodeIdAndSpan, CrateContext, FunctionContext, Block}; +use monomorphize; +use rustc::infer; +use rustc::ty::{self, Ty}; use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo}; use util::nodemap::{NodeMap, FnvHashMap, FnvHashSet}; use rustc::front::map as hir_map; @@ -632,7 +631,7 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, debug_loc, bcx.llbb); - llvm::LLVMSetInstDebugLocation(trans::build::B(bcx).llbuilder, instr); + llvm::LLVMSetInstDebugLocation(::build::B(bcx).llbuilder, instr); } } } diff --git a/src/librustc_trans/trans/debuginfo/namespace.rs b/src/librustc_trans/debuginfo/namespace.rs similarity index 99% rename from src/librustc_trans/trans/debuginfo/namespace.rs rename to src/librustc_trans/debuginfo/namespace.rs index 0c2c29724a1d7..552188ae2a6eb 100644 --- a/src/librustc_trans/trans/debuginfo/namespace.rs +++ b/src/librustc_trans/debuginfo/namespace.rs @@ -16,7 +16,7 @@ use llvm; use llvm::debuginfo::DIScope; use rustc::middle::def_id::DefId; use rustc::front::map as hir_map; -use trans::common::CrateContext; +use common::CrateContext; use std::ffi::CString; use std::ptr; diff --git a/src/librustc_trans/trans/debuginfo/source_loc.rs b/src/librustc_trans/debuginfo/source_loc.rs similarity index 99% rename from src/librustc_trans/trans/debuginfo/source_loc.rs rename to src/librustc_trans/debuginfo/source_loc.rs index 981a23fd664a9..2879da7d03b81 100644 --- a/src/librustc_trans/trans/debuginfo/source_loc.rs +++ b/src/librustc_trans/debuginfo/source_loc.rs @@ -16,7 +16,7 @@ use super::{FunctionDebugContext, DebugLoc}; use llvm; use llvm::debuginfo::DIScope; -use trans::common::{NodeIdAndSpan, CrateContext, FunctionContext}; +use common::{NodeIdAndSpan, CrateContext, FunctionContext}; use libc::c_uint; use std::ptr; diff --git a/src/librustc_trans/trans/debuginfo/type_names.rs b/src/librustc_trans/debuginfo/type_names.rs similarity index 98% rename from src/librustc_trans/trans/debuginfo/type_names.rs rename to src/librustc_trans/debuginfo/type_names.rs index b71b7789affe2..71dd3e432df0d 100644 --- a/src/librustc_trans/trans/debuginfo/type_names.rs +++ b/src/librustc_trans/debuginfo/type_names.rs @@ -12,11 +12,11 @@ use super::namespace::crate_root_namespace; -use trans::common::CrateContext; +use common::CrateContext; use middle::def_id::DefId; -use middle::infer; -use middle::subst; -use middle::ty::{self, Ty}; +use rustc::infer; +use rustc::ty::subst; +use rustc::ty::{self, Ty}; use rustc_front::hir; @@ -107,7 +107,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, output.push_str("unsafe "); } - if abi != ::trans::abi::Abi::Rust { + if abi != ::abi::Abi::Rust { output.push_str("extern \""); output.push_str(abi.name()); output.push_str("\" "); diff --git a/src/librustc_trans/trans/debuginfo/utils.rs b/src/librustc_trans/debuginfo/utils.rs similarity index 97% rename from src/librustc_trans/trans/debuginfo/utils.rs rename to src/librustc_trans/debuginfo/utils.rs index c1d7bb495fafd..d2ae74569e711 100644 --- a/src/librustc_trans/trans/debuginfo/utils.rs +++ b/src/librustc_trans/debuginfo/utils.rs @@ -17,9 +17,9 @@ use middle::def_id::DefId; use llvm; use llvm::debuginfo::{DIScope, DIBuilderRef, DIDescriptor, DIArray}; -use trans::machine; -use trans::common::{CrateContext, FunctionContext}; -use trans::type_::Type; +use machine; +use common::{CrateContext, FunctionContext}; +use type_::Type; use syntax::codemap::Span; use syntax::{ast, codemap}; diff --git a/src/librustc_trans/trans/declare.rs b/src/librustc_trans/declare.rs similarity index 97% rename from src/librustc_trans/trans/declare.rs rename to src/librustc_trans/declare.rs index e63f17770bcec..28a70fd5e0bde 100644 --- a/src/librustc_trans/trans/declare.rs +++ b/src/librustc_trans/declare.rs @@ -20,12 +20,12 @@ //! * Use define_* family of methods when you might be defining the ValueRef. //! * When in doubt, define. use llvm::{self, ValueRef}; -use middle::ty; -use middle::infer; -use trans::abi::{Abi, FnType}; -use trans::attributes; -use trans::context::CrateContext; -use trans::type_::Type; +use rustc::ty; +use rustc::infer; +use abi::{Abi, FnType}; +use attributes; +use context::CrateContext; +use type_::Type; use std::ffi::CString; use libc::c_uint; diff --git a/src/librustc_trans/trans/disr.rs b/src/librustc_trans/disr.rs similarity index 93% rename from src/librustc_trans/trans/disr.rs rename to src/librustc_trans/disr.rs index d74c1ac50ad74..fc79fa813aa5a 100644 --- a/src/librustc_trans/trans/disr.rs +++ b/src/librustc_trans/disr.rs @@ -24,8 +24,8 @@ impl ::std::ops::BitAnd for Disr { } } -impl From<::middle::ty::Disr> for Disr { - fn from(i: ::middle::ty::Disr) -> Disr { +impl From<::rustc::ty::Disr> for Disr { + fn from(i: ::rustc::ty::Disr) -> Disr { Disr(i.to_u64_unchecked()) } } diff --git a/src/librustc_trans/trans/expr.rs b/src/librustc_trans/expr.rs similarity index 99% rename from src/librustc_trans/trans/expr.rs rename to src/librustc_trans/expr.rs index fe98fa290211c..b2e2e93a2be4c 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/expr.rs @@ -54,31 +54,31 @@ use self::lazy_binop_ty::*; use llvm::{self, ValueRef, TypeKind}; use middle::const_qualif::ConstQualif; use middle::def::Def; -use middle::subst::Substs; -use trans::{_match, abi, adt, asm, base, closure, consts, controlflow}; -use trans::base::*; -use trans::build::*; -use trans::callee::{Callee, ArgExprs, ArgOverloadedCall, ArgOverloadedOp}; -use trans::cleanup::{self, CleanupMethods, DropHintMethods}; -use trans::common::*; -use trans::datum::*; -use trans::debuginfo::{self, DebugLoc, ToDebugLoc}; -use trans::declare; -use trans::glue; -use trans::machine; -use trans::tvec; -use trans::type_of; -use trans::value::Value; -use trans::Disr; -use middle::ty::adjustment::{AdjustDerefRef, AdjustReifyFnPointer}; -use middle::ty::adjustment::{AdjustUnsafeFnPointer, AdjustMutToConstPointer}; -use middle::ty::adjustment::CustomCoerceUnsized; -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::MethodCall; -use middle::ty::cast::{CastKind, CastTy}; +use rustc::ty::subst::Substs; +use {_match, abi, adt, asm, base, closure, consts, controlflow}; +use base::*; +use build::*; +use callee::{Callee, ArgExprs, ArgOverloadedCall, ArgOverloadedOp}; +use cleanup::{self, CleanupMethods, DropHintMethods}; +use common::*; +use datum::*; +use debuginfo::{self, DebugLoc, ToDebugLoc}; +use declare; +use glue; +use machine; +use tvec; +use type_of; +use value::Value; +use Disr; +use rustc::ty::adjustment::{AdjustDerefRef, AdjustReifyFnPointer}; +use rustc::ty::adjustment::{AdjustUnsafeFnPointer, AdjustMutToConstPointer}; +use rustc::ty::adjustment::CustomCoerceUnsized; +use rustc::ty::{self, Ty, TyCtxt}; +use rustc::ty::MethodCall; +use rustc::ty::cast::{CastKind, CastTy}; use util::common::indenter; -use trans::machine::{llsize_of, llsize_of_alloc}; -use trans::type_::Type; +use machine::{llsize_of, llsize_of_alloc}; +use type_::Type; use rustc_front; use rustc_front::hir; @@ -1859,8 +1859,8 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, id: ast::NodeId) -> DatumBlock<'blk, 'tcx, Expr> { - use middle::ty::cast::CastTy::*; - use middle::ty::cast::IntTy::*; + use rustc::ty::cast::CastTy::*; + use rustc::ty::cast::IntTy::*; fn int_cast(bcx: Block, lldsttype: Type, @@ -2194,7 +2194,7 @@ impl OverflowOpViaIntrinsic { fn to_intrinsic_name(&self, tcx: &TyCtxt, ty: Ty) -> &'static str { use syntax::ast::IntTy::*; use syntax::ast::UintTy::*; - use middle::ty::{TyInt, TyUint}; + use rustc::ty::{TyInt, TyUint}; let new_sty = match ty.sty { TyInt(Is) => match &tcx.sess.target.target.target_pointer_width[..] { diff --git a/src/librustc_trans/trans/glue.rs b/src/librustc_trans/glue.rs similarity index 97% rename from src/librustc_trans/trans/glue.rs rename to src/librustc_trans/glue.rs index de4b1ba858a6c..c9f31f7642fcd 100644 --- a/src/librustc_trans/trans/glue.rs +++ b/src/librustc_trans/glue.rs @@ -18,27 +18,27 @@ use back::link; use llvm; use llvm::{ValueRef, get_param}; use middle::lang_items::ExchangeFreeFnLangItem; -use middle::subst::{Substs}; -use middle::traits; -use middle::ty::{self, Ty, TyCtxt}; -use trans::abi::{Abi, FnType}; -use trans::adt; -use trans::adt::GetDtorType; // for tcx.dtor_type() -use trans::base::*; -use trans::build::*; -use trans::callee::{Callee, ArgVals}; -use trans::cleanup; -use trans::cleanup::CleanupMethods; -use trans::collector::{self, TransItem}; -use trans::common::*; -use trans::debuginfo::DebugLoc; -use trans::declare; -use trans::expr; -use trans::machine::*; -use trans::monomorphize; -use trans::type_of::{type_of, sizing_type_of, align_of}; -use trans::type_::Type; -use trans::value::Value; +use rustc::ty::subst::{Substs}; +use rustc::traits; +use rustc::ty::{self, Ty, TyCtxt}; +use abi::{Abi, FnType}; +use adt; +use adt::GetDtorType; // for tcx.dtor_type() +use base::*; +use build::*; +use callee::{Callee, ArgVals}; +use cleanup; +use cleanup::CleanupMethods; +use collector::{self, TransItem}; +use common::*; +use debuginfo::DebugLoc; +use declare; +use expr; +use machine::*; +use monomorphize; +use type_of::{type_of, sizing_type_of, align_of}; +use type_::Type; +use value::Value; use arena::TypedArena; use syntax::codemap::DUMMY_SP; diff --git a/src/librustc_trans/trans/inline.rs b/src/librustc_trans/inline.rs similarity index 98% rename from src/librustc_trans/trans/inline.rs rename to src/librustc_trans/inline.rs index 530b99cba920c..50579c7de99bb 100644 --- a/src/librustc_trans/trans/inline.rs +++ b/src/librustc_trans/inline.rs @@ -11,10 +11,10 @@ use llvm::{AvailableExternallyLinkage, InternalLinkage, SetLinkage}; use middle::cstore::{CrateStore, FoundAst, InlinedItem}; use middle::def_id::DefId; -use middle::subst::Substs; -use trans::base::{push_ctxt, trans_item, trans_fn}; -use trans::callee::Callee; -use trans::common::*; +use rustc::ty::subst::Substs; +use base::{push_ctxt, trans_item, trans_fn}; +use callee::Callee; +use common::*; use rustc::dep_graph::DepNode; use rustc_front::hir; diff --git a/src/librustc_trans/trans/intrinsic.rs b/src/librustc_trans/intrinsic.rs similarity index 99% rename from src/librustc_trans/trans/intrinsic.rs rename to src/librustc_trans/intrinsic.rs index 9bc07c6cd8626..b7b74e44d3ed4 100644 --- a/src/librustc_trans/trans/intrinsic.rs +++ b/src/librustc_trans/intrinsic.rs @@ -15,30 +15,30 @@ use intrinsics::{self, Intrinsic}; use libc; use llvm; use llvm::{ValueRef, TypeKind}; -use middle::infer; -use middle::subst; -use middle::subst::FnSpace; -use trans::abi::{Abi, FnType}; -use trans::adt; -use trans::attributes; -use trans::base::*; -use trans::build::*; -use trans::callee::{self, Callee}; -use trans::cleanup; -use trans::cleanup::CleanupMethods; -use trans::common::*; -use trans::consts; -use trans::datum::*; -use trans::debuginfo::DebugLoc; -use trans::declare; -use trans::expr; -use trans::glue; -use trans::type_of; -use trans::machine; -use trans::type_::Type; -use middle::ty::{self, Ty, TypeFoldable}; -use trans::Disr; -use middle::subst::Substs; +use rustc::infer; +use rustc::ty::subst; +use rustc::ty::subst::FnSpace; +use abi::{Abi, FnType}; +use adt; +use attributes; +use base::*; +use build::*; +use callee::{self, Callee}; +use cleanup; +use cleanup::CleanupMethods; +use common::*; +use consts; +use datum::*; +use debuginfo::DebugLoc; +use declare; +use expr; +use glue; +use type_of; +use machine; +use type_::Type; +use rustc::ty::{self, Ty, TypeFoldable}; +use Disr; +use rustc::ty::subst::Substs; use rustc::dep_graph::DepNode; use rustc_front::hir; use syntax::ast; @@ -1694,7 +1694,7 @@ fn generic_simd_intrinsic<'blk, 'tcx, 'a> // Returns None if the type is not an integer fn int_type_width_signed<'tcx>(sty: &ty::TypeVariants<'tcx>, ccx: &CrateContext) -> Option<(u64, bool)> { - use rustc::middle::ty::{TyInt, TyUint}; + use rustc::ty::{TyInt, TyUint}; match *sty { TyInt(t) => Some((match t { ast::IntTy::Is => { @@ -1730,7 +1730,7 @@ fn int_type_width_signed<'tcx>(sty: &ty::TypeVariants<'tcx>, ccx: &CrateContext) // Returns None if the type is not a float fn float_type_width<'tcx>(sty: &ty::TypeVariants<'tcx>) -> Option { - use rustc::middle::ty::TyFloat; + use rustc::ty::TyFloat; match *sty { TyFloat(t) => Some(match t { ast::FloatTy::F32 => 32, diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index f8bbde6010940..8ce69b55222e1 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -61,6 +61,9 @@ pub use rustc::middle; pub use rustc::lint; pub use rustc::util; +pub use base::trans_crate; +pub use disr::Disr; + pub mod back { pub use rustc_back::rpath; pub use rustc_back::svh; @@ -75,11 +78,69 @@ pub mod back { pub mod diagnostics; -pub mod trans; -pub mod save; +#[macro_use] +mod macros; + +mod abi; +mod adt; +mod asm; +mod assert_dep_graph; +mod attributes; +mod base; +mod basic_block; +mod build; +mod builder; +mod cabi_aarch64; +mod cabi_arm; +mod cabi_asmjs; +mod cabi_mips; +mod cabi_powerpc; +mod cabi_powerpc64; +mod cabi_x86; +mod cabi_x86_64; +mod cabi_x86_win64; +mod callee; +mod cleanup; +mod closure; +mod common; +mod consts; +mod context; +mod controlflow; +mod datum; +mod debuginfo; +mod declare; +mod disr; +mod expr; +mod glue; +mod inline; +mod intrinsic; +mod machine; +mod _match; +mod meth; +mod mir; +mod monomorphize; +mod collector; +mod tvec; +mod type_; +mod type_of; +mod value; + +#[derive(Copy, Clone)] +pub struct ModuleTranslation { + pub llcx: llvm::ContextRef, + pub llmod: llvm::ModuleRef, +} + +unsafe impl Send for ModuleTranslation { } +unsafe impl Sync for ModuleTranslation { } -pub mod lib { - pub use llvm; +pub struct CrateTranslation { + pub modules: Vec, + pub metadata_module: ModuleTranslation, + pub link: middle::cstore::LinkMeta, + pub metadata: Vec, + pub reachable: Vec, + pub no_builtins: bool, } __build_diagnostic_array! { librustc_trans, DIAGNOSTICS } diff --git a/src/librustc_trans/trans/machine.rs b/src/librustc_trans/machine.rs similarity index 98% rename from src/librustc_trans/trans/machine.rs rename to src/librustc_trans/machine.rs index 691fba42d5705..59020b38ddcd3 100644 --- a/src/librustc_trans/trans/machine.rs +++ b/src/librustc_trans/machine.rs @@ -13,9 +13,9 @@ #![allow(non_camel_case_types)] use llvm::{self, ValueRef}; -use trans::common::*; +use common::*; -use trans::type_::Type; +use type_::Type; pub type llbits = u64; pub type llsize = u64; diff --git a/src/librustc_trans/trans/macros.rs b/src/librustc_trans/macros.rs similarity index 100% rename from src/librustc_trans/trans/macros.rs rename to src/librustc_trans/macros.rs diff --git a/src/librustc_trans/trans/meth.rs b/src/librustc_trans/meth.rs similarity index 95% rename from src/librustc_trans/trans/meth.rs rename to src/librustc_trans/meth.rs index ae619ceb30b01..2a0b60842310e 100644 --- a/src/librustc_trans/trans/meth.rs +++ b/src/librustc_trans/meth.rs @@ -14,26 +14,26 @@ use arena::TypedArena; use back::link; use llvm::{ValueRef, get_params}; use middle::def_id::DefId; -use middle::infer; -use middle::subst::{FnSpace, Subst, Substs}; -use middle::subst; -use middle::traits::{self, ProjectionMode}; -use trans::abi::FnType; -use trans::base::*; -use trans::build::*; -use trans::callee::{Callee, Virtual, ArgVals, trans_fn_pointer_shim}; -use trans::closure; -use trans::common::*; -use trans::consts; -use trans::debuginfo::DebugLoc; -use trans::declare; -use trans::expr; -use trans::glue; -use trans::machine; -use trans::type_::Type; -use trans::type_of::*; -use trans::value::Value; -use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; +use rustc::infer; +use rustc::ty::subst::{FnSpace, Subst, Substs}; +use rustc::ty::subst; +use rustc::traits::{self, ProjectionMode}; +use abi::FnType; +use base::*; +use build::*; +use callee::{Callee, Virtual, ArgVals, trans_fn_pointer_shim}; +use closure; +use common::*; +use consts; +use debuginfo::DebugLoc; +use declare; +use expr; +use glue; +use machine; +use type_::Type; +use type_of::*; +use value::Value; +use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; use syntax::ast::Name; use syntax::codemap::DUMMY_SP; diff --git a/src/librustc_trans/trans/mir/analyze.rs b/src/librustc_trans/mir/analyze.rs similarity index 99% rename from src/librustc_trans/trans/mir/analyze.rs rename to src/librustc_trans/mir/analyze.rs index 23cca55e4d480..9aa3d6c7dd08e 100644 --- a/src/librustc_trans/trans/mir/analyze.rs +++ b/src/librustc_trans/mir/analyze.rs @@ -14,7 +14,7 @@ use rustc_data_structures::bitvec::BitVector; use rustc::mir::repr as mir; use rustc::mir::visit::{Visitor, LvalueContext}; -use trans::common::{self, Block}; +use common::{self, Block}; use super::rvalue; pub fn lvalue_temps<'bcx,'tcx>(bcx: Block<'bcx,'tcx>, diff --git a/src/librustc_trans/trans/mir/block.rs b/src/librustc_trans/mir/block.rs similarity index 97% rename from src/librustc_trans/trans/mir/block.rs rename to src/librustc_trans/mir/block.rs index 7abaeb44c1c29..a60b03dd72413 100644 --- a/src/librustc_trans/trans/mir/block.rs +++ b/src/librustc_trans/mir/block.rs @@ -9,21 +9,21 @@ // except according to those terms. use llvm::{self, BasicBlockRef, ValueRef, OperandBundleDef}; -use rustc::middle::ty; +use rustc::ty; use rustc::mir::repr as mir; -use trans::abi::{Abi, FnType}; -use trans::adt; -use trans::base; -use trans::build; -use trans::callee::{Callee, CalleeData, Fn, Intrinsic, NamedTupleConstructor, Virtual}; -use trans::common::{self, Block, BlockAndBuilder, C_undef}; -use trans::debuginfo::DebugLoc; -use trans::Disr; -use trans::machine::{llalign_of_min, llbitsize_of_real}; -use trans::meth; -use trans::type_of; -use trans::glue; -use trans::type_::Type; +use abi::{Abi, FnType}; +use adt; +use base; +use build; +use callee::{Callee, CalleeData, Fn, Intrinsic, NamedTupleConstructor, Virtual}; +use common::{self, Block, BlockAndBuilder, C_undef}; +use debuginfo::DebugLoc; +use Disr; +use machine::{llalign_of_min, llbitsize_of_real}; +use meth; +use type_of; +use glue; +use type_::Type; use super::{MirContext, drop}; use super::lvalue::{LvalueRef, load_fat_ptr}; @@ -265,9 +265,9 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { callee.reify(bcx.ccx()).val } Intrinsic => { - use trans::callee::ArgVals; - use trans::expr::{Ignore, SaveIn}; - use trans::intrinsic::trans_intrinsic_call; + use callee::ArgVals; + use expr::{Ignore, SaveIn}; + use intrinsic::trans_intrinsic_call; let (dest, llargs) = if fn_ty.ret.is_indirect() { (SaveIn(llargs[0]), &llargs[1..]) diff --git a/src/librustc_trans/trans/mir/constant.rs b/src/librustc_trans/mir/constant.rs similarity index 96% rename from src/librustc_trans/trans/mir/constant.rs rename to src/librustc_trans/mir/constant.rs index d4934718d75ed..be1c3f3b56b2c 100644 --- a/src/librustc_trans/trans/mir/constant.rs +++ b/src/librustc_trans/mir/constant.rs @@ -9,18 +9,18 @@ // except according to those terms. use llvm::ValueRef; -use middle::ty::{Ty, TypeFoldable}; +use rustc::ty::{Ty, TypeFoldable}; use rustc::middle::const_eval::{self, ConstVal}; use rustc_const_eval::ConstInt::*; use rustc::mir::repr as mir; -use trans::abi; -use trans::common::{self, BlockAndBuilder, C_bool, C_bytes, C_floating_f64, C_integral, +use abi; +use common::{self, BlockAndBuilder, C_bool, C_bytes, C_floating_f64, C_integral, C_str_slice, C_undef}; -use trans::consts; -use trans::datum; -use trans::expr; -use trans::type_of; -use trans::type_::Type; +use consts; +use datum; +use expr; +use type_of; +use type_::Type; use super::operand::{OperandRef, OperandValue}; use super::MirContext; diff --git a/src/librustc_trans/trans/mir/drop.rs b/src/librustc_trans/mir/drop.rs similarity index 85% rename from src/librustc_trans/trans/mir/drop.rs rename to src/librustc_trans/mir/drop.rs index 2e13abec5e36c..623cd5a6f8cc9 100644 --- a/src/librustc_trans/trans/mir/drop.rs +++ b/src/librustc_trans/mir/drop.rs @@ -9,13 +9,13 @@ // except according to those terms. use llvm::ValueRef; -use rustc::middle::ty::Ty; -use trans::adt; -use trans::base; -use trans::common::{self, BlockAndBuilder}; -use trans::machine; -use trans::type_of; -use trans::type_::Type; +use rustc::ty::Ty; +use adt; +use base; +use common::{self, BlockAndBuilder}; +use machine; +use type_of; +use type_::Type; pub fn drop_fill<'bcx, 'tcx>(bcx: &BlockAndBuilder<'bcx, 'tcx>, value: ValueRef, ty: Ty<'tcx>) { let llty = type_of::type_of(bcx.ccx(), ty); diff --git a/src/librustc_trans/trans/mir/lvalue.rs b/src/librustc_trans/mir/lvalue.rs similarity index 97% rename from src/librustc_trans/trans/mir/lvalue.rs rename to src/librustc_trans/mir/lvalue.rs index ffc3b1206746e..f5f8c23a9824b 100644 --- a/src/librustc_trans/trans/mir/lvalue.rs +++ b/src/librustc_trans/mir/lvalue.rs @@ -9,19 +9,19 @@ // except according to those terms. use llvm::ValueRef; -use rustc::middle::ty::{self, Ty, TypeFoldable}; +use rustc::ty::{self, Ty, TypeFoldable}; use rustc::mir::repr as mir; use rustc::mir::tcx::LvalueTy; -use trans::abi; -use trans::adt; -use trans::base; -use trans::builder::Builder; -use trans::common::{self, BlockAndBuilder, C_uint}; -use trans::consts; -use trans::machine; -use trans::mir::drop; +use abi; +use adt; +use base; +use builder::Builder; +use common::{self, BlockAndBuilder, C_uint}; +use consts; +use machine; +use mir::drop; use llvm; -use trans::Disr; +use Disr; use std::ptr; diff --git a/src/librustc_trans/trans/mir/mod.rs b/src/librustc_trans/mir/mod.rs similarity index 98% rename from src/librustc_trans/trans/mir/mod.rs rename to src/librustc_trans/mir/mod.rs index 9df2cb712b14f..61536f3ecae87 100644 --- a/src/librustc_trans/trans/mir/mod.rs +++ b/src/librustc_trans/mir/mod.rs @@ -10,11 +10,11 @@ use libc::c_uint; use llvm::{self, ValueRef}; -use middle::ty; +use rustc::ty; use rustc::mir::repr as mir; use rustc::mir::tcx::LvalueTy; -use trans::base; -use trans::common::{self, Block, BlockAndBuilder, FunctionContext}; +use base; +use common::{self, Block, BlockAndBuilder, FunctionContext}; use std::ops::Deref; use std::rc::Rc; diff --git a/src/librustc_trans/trans/mir/operand.rs b/src/librustc_trans/mir/operand.rs similarity index 97% rename from src/librustc_trans/trans/mir/operand.rs rename to src/librustc_trans/mir/operand.rs index 6df4502fbc827..3b909353f7345 100644 --- a/src/librustc_trans/trans/mir/operand.rs +++ b/src/librustc_trans/mir/operand.rs @@ -9,13 +9,13 @@ // except according to those terms. use llvm::ValueRef; -use rustc::middle::ty::Ty; +use rustc::ty::Ty; use rustc::mir::repr as mir; -use trans::base; -use trans::common::{self, Block, BlockAndBuilder}; -use trans::datum; -use trans::value::Value; -use trans::glue; +use base; +use common::{self, Block, BlockAndBuilder}; +use datum; +use value::Value; +use glue; use std::fmt; diff --git a/src/librustc_trans/trans/mir/rvalue.rs b/src/librustc_trans/mir/rvalue.rs similarity index 98% rename from src/librustc_trans/trans/mir/rvalue.rs rename to src/librustc_trans/mir/rvalue.rs index 17c8aef244bb9..47fa618ebad83 100644 --- a/src/librustc_trans/trans/mir/rvalue.rs +++ b/src/librustc_trans/mir/rvalue.rs @@ -9,26 +9,26 @@ // except according to those terms. use llvm::ValueRef; -use rustc::middle::ty::{self, Ty}; -use middle::ty::cast::{CastTy, IntTy}; +use rustc::ty::{self, Ty}; +use rustc::ty::cast::{CastTy, IntTy}; use middle::const_eval::ConstVal; use rustc_const_eval::ConstInt; use rustc::mir::repr as mir; -use trans::asm; -use trans::base; -use trans::callee::Callee; -use trans::common::{self, C_uint, BlockAndBuilder, Result}; -use trans::datum::{Datum, Lvalue}; -use trans::debuginfo::DebugLoc; -use trans::declare; -use trans::adt; -use trans::machine; -use trans::type_::Type; -use trans::type_of; -use trans::tvec; -use trans::value::Value; -use trans::Disr; +use asm; +use base; +use callee::Callee; +use common::{self, C_uint, BlockAndBuilder, Result}; +use datum::{Datum, Lvalue}; +use debuginfo::DebugLoc; +use declare; +use adt; +use machine; +use type_::Type; +use type_of; +use tvec; +use value::Value; +use Disr; use super::MirContext; use super::operand::{OperandRef, OperandValue}; @@ -138,7 +138,7 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> { use syntax::ast::DUMMY_NODE_ID; use syntax::codemap::DUMMY_SP; use syntax::ptr::P; - use trans::closure; + use closure; closure::trans_closure_expr(closure::Dest::Ignore(bcx.ccx()), &hir::FnDecl { diff --git a/src/librustc_trans/trans/mir/statement.rs b/src/librustc_trans/mir/statement.rs similarity index 98% rename from src/librustc_trans/trans/mir/statement.rs rename to src/librustc_trans/mir/statement.rs index 0307fd649c835..d291bc19db5e8 100644 --- a/src/librustc_trans/trans/mir/statement.rs +++ b/src/librustc_trans/mir/statement.rs @@ -9,7 +9,7 @@ // except according to those terms. use rustc::mir::repr as mir; -use trans::common::BlockAndBuilder; +use common::BlockAndBuilder; use super::MirContext; use super::TempRef; diff --git a/src/librustc_trans/trans/monomorphize.rs b/src/librustc_trans/monomorphize.rs similarity index 95% rename from src/librustc_trans/trans/monomorphize.rs rename to src/librustc_trans/monomorphize.rs index 63fb8c5fb5e1c..0c49c37220965 100644 --- a/src/librustc_trans/trans/monomorphize.rs +++ b/src/librustc_trans/monomorphize.rs @@ -12,18 +12,18 @@ use back::link::exported_name; use llvm::ValueRef; use llvm; use middle::def_id::DefId; -use middle::infer::normalize_associated_type; -use middle::subst; -use middle::subst::{Subst, Substs}; -use middle::ty::fold::{TypeFolder, TypeFoldable}; -use trans::attributes; -use trans::base::{push_ctxt}; -use trans::base::trans_fn; -use trans::base; -use trans::common::*; -use trans::declare; -use middle::ty::{self, Ty, TyCtxt}; -use trans::Disr; +use rustc::infer::normalize_associated_type; +use rustc::ty::subst; +use rustc::ty::subst::{Subst, Substs}; +use rustc::ty::fold::{TypeFolder, TypeFoldable}; +use attributes; +use base::{push_ctxt}; +use base::trans_fn; +use base; +use common::*; +use declare; +use rustc::ty::{self, Ty, TyCtxt}; +use Disr; use rustc::front::map as hir_map; use rustc::util::ppaux; diff --git a/src/librustc_trans/trans/mod.rs b/src/librustc_trans/trans/mod.rs deleted file mode 100644 index c5ab0d4e74421..0000000000000 --- a/src/librustc_trans/trans/mod.rs +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright 2012-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 llvm::{ContextRef, ModuleRef}; -use middle::cstore::LinkMeta; - -pub use self::base::trans_crate; -pub use self::context::CrateContext; -pub use self::common::gensym_name; -pub use self::disr::Disr; - -#[macro_use] -mod macros; - -mod abi; -mod adt; -mod asm; -mod assert_dep_graph; -mod attributes; -mod base; -mod basic_block; -mod build; -mod builder; -mod cabi_aarch64; -mod cabi_arm; -mod cabi_asmjs; -mod cabi_mips; -mod cabi_powerpc; -mod cabi_powerpc64; -mod cabi_x86; -mod cabi_x86_64; -mod cabi_x86_win64; -mod callee; -mod cleanup; -mod closure; -mod common; -mod consts; -mod context; -mod controlflow; -mod datum; -mod debuginfo; -mod declare; -mod disr; -mod expr; -mod glue; -mod inline; -mod intrinsic; -mod machine; -mod _match; -mod meth; -mod mir; -mod monomorphize; -mod collector; -mod tvec; -mod type_; -mod type_of; -mod value; - -#[derive(Copy, Clone)] -pub struct ModuleTranslation { - pub llcx: ContextRef, - pub llmod: ModuleRef, -} - -unsafe impl Send for ModuleTranslation { } -unsafe impl Sync for ModuleTranslation { } - -pub struct CrateTranslation { - pub modules: Vec, - pub metadata_module: ModuleTranslation, - pub link: LinkMeta, - pub metadata: Vec, - pub reachable: Vec, - pub no_builtins: bool, -} diff --git a/src/librustc_trans/trans/tvec.rs b/src/librustc_trans/tvec.rs similarity index 97% rename from src/librustc_trans/trans/tvec.rs rename to src/librustc_trans/tvec.rs index 7a0ca86f5a270..c42bad0bc0bd1 100644 --- a/src/librustc_trans/trans/tvec.rs +++ b/src/librustc_trans/tvec.rs @@ -12,22 +12,22 @@ use llvm; use llvm::ValueRef; -use trans::base::*; -use trans::base; -use trans::build::*; -use trans::cleanup; -use trans::cleanup::CleanupMethods; -use trans::common::*; -use trans::consts; -use trans::datum::*; -use trans::debuginfo::DebugLoc; -use trans::expr::{Dest, Ignore, SaveIn}; -use trans::expr; -use trans::machine::llsize_of_alloc; -use trans::type_::Type; -use trans::type_of; -use trans::value::Value; -use middle::ty::{self, Ty}; +use base::*; +use base; +use build::*; +use cleanup; +use cleanup::CleanupMethods; +use common::*; +use consts; +use datum::*; +use debuginfo::DebugLoc; +use expr::{Dest, Ignore, SaveIn}; +use expr; +use machine::llsize_of_alloc; +use type_::Type; +use type_of; +use value::Value; +use rustc::ty::{self, Ty}; use rustc_front::hir; diff --git a/src/librustc_trans/trans/type_.rs b/src/librustc_trans/type_.rs similarity index 99% rename from src/librustc_trans/trans/type_.rs rename to src/librustc_trans/type_.rs index 57bd0ba815816..910a1c7f729c9 100644 --- a/src/librustc_trans/trans/type_.rs +++ b/src/librustc_trans/type_.rs @@ -14,7 +14,7 @@ use llvm; use llvm::{TypeRef, Bool, False, True, TypeKind}; use llvm::{Float, Double, X86_FP80, PPC_FP128, FP128}; -use trans::context::CrateContext; +use context::CrateContext; use util::nodemap::FnvHashMap; use syntax::ast; diff --git a/src/librustc_trans/trans/type_of.rs b/src/librustc_trans/type_of.rs similarity index 97% rename from src/librustc_trans/trans/type_of.rs rename to src/librustc_trans/type_of.rs index 7d5218d84dafe..02f659fdc2e6f 100644 --- a/src/librustc_trans/trans/type_of.rs +++ b/src/librustc_trans/type_of.rs @@ -11,15 +11,15 @@ #![allow(non_camel_case_types)] use middle::def_id::DefId; -use middle::infer; -use middle::subst; -use trans::abi::FnType; -use trans::adt; -use trans::common::*; -use trans::machine; -use middle::ty::{self, Ty, TypeFoldable}; +use rustc::infer; +use rustc::ty::subst; +use abi::FnType; +use adt; +use common::*; +use machine; +use rustc::ty::{self, Ty, TypeFoldable}; -use trans::type_::Type; +use type_::Type; use syntax::ast; @@ -145,7 +145,7 @@ pub fn immediate_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> } } -/// Get the LLVM type corresponding to a Rust type, i.e. `middle::ty::Ty`. +/// Get the LLVM type corresponding to a Rust type, i.e. `rustc::ty::Ty`. /// This is the right LLVM type for an alloca containing a value of that type, /// and the pointee of an Lvalue Datum (which is always a LLVM pointer). /// For unsized types, the returned type is a fat pointer, thus the resulting @@ -163,7 +163,7 @@ pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> Type { in_memory_type_of(cx, ty) } -/// Get the LLVM type corresponding to a Rust type, i.e. `middle::ty::Ty`. +/// Get the LLVM type corresponding to a Rust type, i.e. `rustc::ty::Ty`. /// This is the right LLVM type for a field/array element of that type, /// and is the same as `type_of` for all Sized types. /// Unsized types, however, are represented by a "minimal unit", e.g. diff --git a/src/librustc_trans/trans/value.rs b/src/librustc_trans/value.rs similarity index 98% rename from src/librustc_trans/trans/value.rs rename to src/librustc_trans/value.rs index a33b7d62d2dce..00b316cc420ee 100644 --- a/src/librustc_trans/trans/value.rs +++ b/src/librustc_trans/value.rs @@ -10,8 +10,8 @@ use llvm; use llvm::{UseRef, ValueRef}; -use trans::basic_block::BasicBlock; -use trans::common::Block; +use basic_block::BasicBlock; +use common::Block; use std::fmt; diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 159ff90b50955..af40b845767d8 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -54,10 +54,10 @@ use middle::const_eval::EvalHint::UncheckedExprHint; use middle::def::{self, Def}; use middle::def_id::DefId; use middle::resolve_lifetime as rl; -use middle::subst::{FnSpace, TypeSpace, SelfSpace, Subst, Substs, ParamSpace}; -use middle::traits; -use middle::ty::{self, Ty, TyCtxt, ToPredicate, TypeFoldable}; -use middle::ty::wf::object_region_bounds; +use rustc::ty::subst::{FnSpace, TypeSpace, SelfSpace, Subst, Substs, ParamSpace}; +use rustc::traits; +use rustc::ty::{self, Ty, TyCtxt, ToPredicate, TypeFoldable}; +use rustc::ty::wf::object_region_bounds; use require_c_abi_if_variadic; use rscope::{self, UnelidableRscope, RegionScope, ElidableRscope, ObjectLifetimeDefaultRscope, ShiftedRscope, BindingRscope, diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 305970db9e72e..f8fa9c8e9b6cb 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -9,11 +9,11 @@ // except according to those terms. use middle::def::{self, Def}; -use middle::infer::{self, TypeOrigin}; +use rustc::infer::{self, TypeOrigin}; use middle::pat_util::{PatIdMap, pat_id_map, pat_is_binding}; use middle::pat_util::pat_is_resolved_const; -use middle::subst::Substs; -use middle::ty::{self, Ty, TypeFoldable, LvaluePreference}; +use rustc::ty::subst::Substs; +use rustc::ty::{self, Ty, TypeFoldable, LvaluePreference}; use check::{check_expr, check_expr_has_type, check_expr_with_expectation}; use check::{demand, FnCtxt, Expectation}; use check::{check_expr_with_lvalue_pref}; diff --git a/src/librustc_typeck/check/assoc.rs b/src/librustc_typeck/check/assoc.rs index 91916efa88277..f7726bc9cf492 100644 --- a/src/librustc_typeck/check/assoc.rs +++ b/src/librustc_typeck/check/assoc.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::infer::InferCtxt; -use middle::traits::{self, FulfillmentContext, Normalized, MiscObligation, +use rustc::infer::InferCtxt; +use rustc::traits::{self, FulfillmentContext, Normalized, MiscObligation, SelectionContext, ObligationCause}; -use middle::ty::fold::TypeFoldable; +use rustc::ty::fold::TypeFoldable; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index bf60f435a2213..4e582033c8b6a 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -28,8 +28,8 @@ use CrateCtxt; use middle::cstore::LOCAL_CRATE; use middle::def::Def; use middle::def_id::DefId; -use middle::infer; -use middle::ty::{self, LvaluePreference, Ty}; +use rustc::infer; +use rustc::ty::{self, LvaluePreference, Ty}; use syntax::codemap::Span; use syntax::parse::token; use syntax::ptr::P; diff --git a/src/librustc_typeck/check/cast.rs b/src/librustc_typeck/check/cast.rs index 31c0fea5c2d97..7ca4251e4c80b 100644 --- a/src/librustc_typeck/check/cast.rs +++ b/src/librustc_typeck/check/cast.rs @@ -45,8 +45,8 @@ use super::structurally_resolved_type; use lint; use middle::def_id::DefId; -use middle::ty::{self, Ty, TypeFoldable}; -use middle::ty::cast::{CastKind, CastTy}; +use rustc::ty::{self, Ty, TypeFoldable}; +use rustc::ty::cast::{CastKind, CastTy}; use syntax::codemap::Span; use rustc_front::hir; use syntax::ast; @@ -238,8 +238,8 @@ impl<'tcx> CastCheck<'tcx> { /// can return Ok and create type errors in the fcx rather than returning /// directly. coercion-cast is handled in check instead of here. fn do_check<'a>(&self, fcx: &FnCtxt<'a, 'tcx>) -> Result { - use middle::ty::cast::IntTy::*; - use middle::ty::cast::CastTy::*; + use rustc::ty::cast::IntTy::*; + use rustc::ty::cast::CastTy::*; let (t_from, t_cast) = match (CastTy::from_ty(self.expr_ty), CastTy::from_ty(self.cast_ty)) { diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index a4fb2e381459e..9333b10d27e4a 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -13,8 +13,8 @@ use super::{check_fn, Expectation, FnCtxt}; use astconv; -use middle::subst; -use middle::ty::{self, ToPolyTraitRef, Ty}; +use rustc::ty::subst; +use rustc::ty::{self, ToPolyTraitRef, Ty}; use std::cmp; use syntax::abi::Abi; use rustc_front::hir; diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index c62922a33de2c..dad7d7cd26ca3 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -62,16 +62,16 @@ use check::{autoderef, FnCtxt, UnresolvedTypeAction}; -use middle::infer::{Coercion, TypeOrigin, TypeTrace}; -use middle::traits::{self, ObligationCause}; -use middle::traits::{predicate_for_trait_def, report_selection_error}; -use middle::ty::adjustment::{AutoAdjustment, AutoDerefRef, AdjustDerefRef}; -use middle::ty::adjustment::{AutoPtr, AutoUnsafe, AdjustReifyFnPointer}; -use middle::ty::adjustment::{AdjustUnsafeFnPointer, AdjustMutToConstPointer}; -use middle::ty::{self, LvaluePreference, TypeAndMut, Ty, TyCtxt}; -use middle::ty::fold::TypeFoldable; -use middle::ty::error::TypeError; -use middle::ty::relate::{relate_substs, Relate, RelateResult, TypeRelation}; +use rustc::infer::{Coercion, TypeOrigin, TypeTrace}; +use rustc::traits::{self, ObligationCause}; +use rustc::traits::{predicate_for_trait_def, report_selection_error}; +use rustc::ty::adjustment::{AutoAdjustment, AutoDerefRef, AdjustDerefRef}; +use rustc::ty::adjustment::{AutoPtr, AutoUnsafe, AdjustReifyFnPointer}; +use rustc::ty::adjustment::{AdjustUnsafeFnPointer, AdjustMutToConstPointer}; +use rustc::ty::{self, LvaluePreference, TypeAndMut, Ty, TyCtxt}; +use rustc::ty::fold::TypeFoldable; +use rustc::ty::error::TypeError; +use rustc::ty::relate::{relate_substs, Relate, RelateResult, TypeRelation}; use util::common::indent; use std::cell::RefCell; diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 3e59f0ba73a81..6d429fa7b73a1 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -9,10 +9,10 @@ // except according to those terms. use middle::free_region::FreeRegionMap; -use middle::infer::{self, TypeOrigin}; -use middle::ty::{self, TyCtxt}; -use middle::traits::{self, ProjectionMode}; -use middle::subst::{self, Subst, Substs, VecPerParamSpace}; +use rustc::infer::{self, TypeOrigin}; +use rustc::ty::{self, TyCtxt}; +use rustc::traits::{self, ProjectionMode}; +use rustc::ty::subst::{self, Subst, Substs, VecPerParamSpace}; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc_typeck/check/demand.rs b/src/librustc_typeck/check/demand.rs index 1f61198bef921..d8bdf6c61aad4 100644 --- a/src/librustc_typeck/check/demand.rs +++ b/src/librustc_typeck/check/demand.rs @@ -10,8 +10,8 @@ use check::{coercion, FnCtxt}; -use middle::ty::Ty; -use middle::infer::TypeOrigin; +use rustc::ty::Ty; +use rustc::infer::TypeOrigin; use syntax::codemap::Span; use rustc_front::hir; diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index 7dd5db831fd75..bf2388ab79315 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -12,11 +12,11 @@ use check::regionck::{self, Rcx}; use middle::def_id::DefId; use middle::free_region::FreeRegionMap; -use middle::infer; +use rustc::infer; use middle::region; -use middle::subst::{self, Subst}; -use middle::ty::{self, Ty, TyCtxt}; -use middle::traits::{self, ProjectionMode}; +use rustc::ty::subst::{self, Subst}; +use rustc::ty::{self, Ty, TyCtxt}; +use rustc::traits::{self, ProjectionMode}; use util::nodemap::FnvHashSet; use syntax::ast; diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index 2cd166ebe7ebe..8720469a72476 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -13,10 +13,10 @@ use astconv::AstConv; use intrinsics; -use middle::subst::{self, Substs}; -use middle::ty::FnSig; -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::fold::TypeFolder; +use rustc::ty::subst::{self, Substs}; +use rustc::ty::FnSig; +use rustc::ty::{self, Ty, TyCtxt}; +use rustc::ty::fold::TypeFolder; use {CrateCtxt, require_same_types}; use std::collections::{HashMap}; diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index aa4e1d0b52908..310245f0a0e10 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -13,13 +13,13 @@ use super::probe; use check::{self, FnCtxt, callee, demand}; use check::UnresolvedTypeAction; use middle::def_id::DefId; -use middle::subst::{self}; -use middle::traits; -use middle::ty::{self, NoPreference, PreferMutLvalue, Ty, TyCtxt}; -use middle::ty::adjustment::{AdjustDerefRef, AutoDerefRef, AutoPtr}; -use middle::ty::fold::TypeFoldable; -use middle::infer; -use middle::infer::{InferCtxt, TypeOrigin}; +use rustc::ty::subst::{self}; +use rustc::traits; +use rustc::ty::{self, NoPreference, PreferMutLvalue, Ty, TyCtxt}; +use rustc::ty::adjustment::{AdjustDerefRef, AutoDerefRef, AutoPtr}; +use rustc::ty::fold::TypeFoldable; +use rustc::infer; +use rustc::infer::{InferCtxt, TypeOrigin}; use syntax::codemap::Span; use rustc_front::hir; diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index 7f982c466a704..11f7feba86b32 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -14,11 +14,11 @@ use astconv::AstConv; use check::FnCtxt; use middle::def::Def; use middle::def_id::DefId; -use middle::subst; -use middle::traits; -use middle::ty::{self, TyCtxt, ToPredicate, ToPolyTraitRef, TraitRef, TypeFoldable}; -use middle::ty::adjustment::{AdjustDerefRef, AutoDerefRef, AutoPtr}; -use middle::infer; +use rustc::ty::subst; +use rustc::traits; +use rustc::ty::{self, TyCtxt, ToPredicate, ToPolyTraitRef, TraitRef, TypeFoldable}; +use rustc::ty::adjustment::{AdjustDerefRef, AutoDerefRef, AutoPtr}; +use rustc::infer; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 5f7f9703b1059..4b42846297b16 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -16,12 +16,12 @@ use super::suggest; use check; use check::{FnCtxt, UnresolvedTypeAction}; use middle::def_id::DefId; -use middle::subst; -use middle::subst::Subst; -use middle::traits; -use middle::ty::{self, NoPreference, Ty, TyCtxt, ToPolyTraitRef, TraitRef, TypeFoldable}; -use middle::infer; -use middle::infer::{InferCtxt, TypeOrigin}; +use rustc::ty::subst; +use rustc::ty::subst::Subst; +use rustc::traits; +use rustc::ty::{self, NoPreference, Ty, TyCtxt, ToPolyTraitRef, TraitRef, TypeFoldable}; +use rustc::infer; +use rustc::infer::{InferCtxt, TypeOrigin}; use syntax::ast; use syntax::codemap::{Span, DUMMY_SP}; use rustc_front::hir; diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 44724ca26b164..aae7912cace40 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -16,13 +16,13 @@ use CrateCtxt; use astconv::AstConv; use check::{self, FnCtxt}; use front::map as hir_map; -use middle::ty::{self, Ty, ToPolyTraitRef, ToPredicate, TypeFoldable}; +use rustc::ty::{self, Ty, ToPolyTraitRef, ToPredicate, TypeFoldable}; use middle::cstore::{self, CrateStore}; use middle::def::Def; use middle::def_id::DefId; use middle::lang_items::FnOnceTraitLangItem; -use middle::subst::Substs; -use middle::traits::{Obligation, SelectionContext}; +use rustc::ty::subst::Substs; +use rustc::traits::{Obligation, SelectionContext}; use util::nodemap::{FnvHashSet}; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 6eb663e604791..c5a0657594eb2 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -88,21 +88,21 @@ use middle::astconv_util::prohibit_type_params; use middle::cstore::LOCAL_CRATE; use middle::def::{self, Def}; use middle::def_id::DefId; -use middle::infer; -use middle::infer::{TypeOrigin, TypeTrace, type_variable}; +use rustc::infer; +use rustc::infer::{TypeOrigin, TypeTrace, type_variable}; use middle::pat_util::{self, pat_id_map}; -use middle::subst::{self, Subst, Substs, VecPerParamSpace, ParamSpace}; -use middle::traits::{self, report_fulfillment_errors, ProjectionMode}; -use middle::ty::{GenericPredicates, TypeScheme}; -use middle::ty::{ParamTy, ParameterEnvironment}; -use middle::ty::{LvaluePreference, NoPreference, PreferMutLvalue}; -use middle::ty::{self, ToPolyTraitRef, Ty, TyCtxt}; -use middle::ty::{MethodCall, MethodCallee}; -use middle::ty::adjustment; -use middle::ty::error::TypeError; -use middle::ty::fold::{TypeFolder, TypeFoldable}; -use middle::ty::relate::TypeRelation; -use middle::ty::util::{Representability, IntTypeExt}; +use rustc::ty::subst::{self, Subst, Substs, VecPerParamSpace, ParamSpace}; +use rustc::traits::{self, report_fulfillment_errors, ProjectionMode}; +use rustc::ty::{GenericPredicates, TypeScheme}; +use rustc::ty::{ParamTy, ParameterEnvironment}; +use rustc::ty::{LvaluePreference, NoPreference, PreferMutLvalue}; +use rustc::ty::{self, ToPolyTraitRef, Ty, TyCtxt}; +use rustc::ty::{MethodCall, MethodCallee}; +use rustc::ty::adjustment; +use rustc::ty::error::TypeError; +use rustc::ty::fold::{TypeFolder, TypeFoldable}; +use rustc::ty::relate::TypeRelation; +use rustc::ty::util::{Representability, IntTypeExt}; use require_c_abi_if_variadic; use rscope::{ElisionFailureInfo, RegionScope}; use session::{Session, CompileResult}; @@ -1769,8 +1769,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { /// Apply "fallbacks" to some types /// ! gets replaced with (), unconstrained ints with i32, and unconstrained floats with f64. fn default_type_parameters(&self) { - use middle::ty::error::UnconstrainedNumeric::Neither; - use middle::ty::error::UnconstrainedNumeric::{UnconstrainedInt, UnconstrainedFloat}; + use rustc::ty::error::UnconstrainedNumeric::Neither; + use rustc::ty::error::UnconstrainedNumeric::{UnconstrainedInt, UnconstrainedFloat}; for ty in &self.infcx().unsolved_variables() { let resolved = self.infcx().resolve_type_vars_if_possible(ty); if self.infcx().type_var_diverges(resolved) { @@ -1805,8 +1805,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { } fn new_select_all_obligations_and_apply_defaults(&self) { - use middle::ty::error::UnconstrainedNumeric::Neither; - use middle::ty::error::UnconstrainedNumeric::{UnconstrainedInt, UnconstrainedFloat}; + use rustc::ty::error::UnconstrainedNumeric::Neither; + use rustc::ty::error::UnconstrainedNumeric::{UnconstrainedInt, UnconstrainedFloat}; // For the time being this errs on the side of being memory wasteful but provides better // error reporting. @@ -1978,8 +1978,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { default_map: &FnvHashMap<&Ty<'tcx>, type_variable::Default<'tcx>>, conflict: Ty<'tcx>) -> Option> { - use middle::ty::error::UnconstrainedNumeric::Neither; - use middle::ty::error::UnconstrainedNumeric::{UnconstrainedInt, UnconstrainedFloat}; + use rustc::ty::error::UnconstrainedNumeric::Neither; + use rustc::ty::error::UnconstrainedNumeric::{UnconstrainedInt, UnconstrainedFloat}; // Ensure that we apply the conflicting default first let mut unbound_tyvars = Vec::with_capacity(unbound_vars.len() + 1); diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index f4841b75d13d5..281564af6158a 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -19,7 +19,7 @@ use super::{ FnCtxt, }; use middle::def_id::DefId; -use middle::ty::{Ty, TypeFoldable, PreferMutLvalue}; +use rustc::ty::{Ty, TypeFoldable, PreferMutLvalue}; use syntax::ast; use syntax::parse::token; use rustc_front::hir; @@ -335,7 +335,7 @@ fn lookup_op_method<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>, let method_ty = method.ty; // HACK(eddyb) Fully qualified path to work around a resolve bug. - let method_call = ::middle::ty::MethodCall::expr(expr.id); + let method_call = ::rustc::ty::MethodCall::expr(expr.id); fcx.inh.tables.borrow_mut().method_map.insert(method_call, method); // extract return type for method; all late bound regions diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index fb4870bce8765..533d24686e71f 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -89,13 +89,13 @@ use middle::free_region::FreeRegionMap; use middle::mem_categorization as mc; use middle::mem_categorization::Categorization; use middle::region::{self, CodeExtent}; -use middle::subst::Substs; -use middle::traits; -use middle::ty::{self, Ty, TyCtxt, MethodCall, TypeFoldable}; -use middle::infer::{self, GenericKind, InferCtxt, SubregionOrigin, TypeOrigin, VerifyBound}; +use rustc::ty::subst::Substs; +use rustc::traits; +use rustc::ty::{self, Ty, TyCtxt, MethodCall, TypeFoldable}; +use rustc::infer::{self, GenericKind, InferCtxt, SubregionOrigin, TypeOrigin, VerifyBound}; use middle::pat_util; -use middle::ty::adjustment; -use middle::ty::wf::ImpliedBound; +use rustc::ty::adjustment; +use rustc::ty::wf::ImpliedBound; use std::mem; use syntax::ast; diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index 2bb8c874d20d6..69e49e6a98646 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -46,8 +46,8 @@ use check::demand; use middle::expr_use_visitor as euv; use middle::mem_categorization as mc; use middle::mem_categorization::Categorization; -use middle::ty::{self, Ty, TyCtxt}; -use middle::infer::{InferCtxt, UpvarRegion}; +use rustc::ty::{self, Ty, TyCtxt}; +use rustc::infer::{InferCtxt, UpvarRegion}; use std::collections::HashSet; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index a8ada8061317e..047dfec1796eb 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -14,10 +14,10 @@ use constrained_type_params::{identify_constrained_type_params, Parameter}; use CrateCtxt; use middle::def_id::DefId; use middle::region::{CodeExtent}; -use middle::subst::{self, TypeSpace, FnSpace, ParamSpace, SelfSpace}; -use middle::traits; -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::fold::{TypeFolder}; +use rustc::ty::subst::{self, TypeSpace, FnSpace, ParamSpace, SelfSpace}; +use rustc::traits; +use rustc::ty::{self, Ty, TyCtxt}; +use rustc::ty::fold::{TypeFolder}; use std::cell::RefCell; use std::collections::HashSet; diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 20c86f9a17c8d..7ede85454e90f 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -17,10 +17,10 @@ use astconv::AstConv; use check::FnCtxt; use middle::def_id::DefId; use middle::pat_util; -use middle::ty::{self, Ty, TyCtxt, MethodCall, MethodCallee}; -use middle::ty::adjustment; -use middle::ty::fold::{TypeFolder,TypeFoldable}; -use middle::infer; +use rustc::ty::{self, Ty, TyCtxt, MethodCall, MethodCallee}; +use rustc::ty::adjustment; +use rustc::ty::fold::{TypeFolder,TypeFoldable}; +use rustc::infer; use write_substs_to_tcx; use write_ty_to_tcx; diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 278d4d8b5b44a..c3b46ef83acef 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -17,21 +17,21 @@ use middle::def_id::DefId; use middle::lang_items::UnsizeTraitLangItem; -use middle::subst::{self, Subst}; -use middle::ty::{self, TyCtxt, TypeFoldable}; -use middle::traits::{self, ProjectionMode}; -use middle::ty::{ImplOrTraitItemId, ConstTraitItemId}; -use middle::ty::{MethodTraitItemId, TypeTraitItemId, ParameterEnvironment}; -use middle::ty::{Ty, TyBool, TyChar, TyEnum, TyError}; -use middle::ty::{TyParam, TyRawPtr}; -use middle::ty::{TyRef, TyStruct, TyTrait, TyTuple}; -use middle::ty::{TyStr, TyArray, TySlice, TyFloat, TyInfer, TyInt}; -use middle::ty::{TyUint, TyClosure, TyBox, TyFnDef, TyFnPtr}; -use middle::ty::TyProjection; -use middle::ty::util::CopyImplementationError; +use rustc::ty::subst::{self, Subst}; +use rustc::ty::{self, TyCtxt, TypeFoldable}; +use rustc::traits::{self, ProjectionMode}; +use rustc::ty::{ImplOrTraitItemId, ConstTraitItemId}; +use rustc::ty::{MethodTraitItemId, TypeTraitItemId, ParameterEnvironment}; +use rustc::ty::{Ty, TyBool, TyChar, TyEnum, TyError}; +use rustc::ty::{TyParam, TyRawPtr}; +use rustc::ty::{TyRef, TyStruct, TyTrait, TyTuple}; +use rustc::ty::{TyStr, TyArray, TySlice, TyFloat, TyInfer, TyInt}; +use rustc::ty::{TyUint, TyClosure, TyBox, TyFnDef, TyFnPtr}; +use rustc::ty::TyProjection; +use rustc::ty::util::CopyImplementationError; use middle::free_region::FreeRegionMap; use CrateCtxt; -use middle::infer::{self, InferCtxt, TypeOrigin, new_infer_ctxt}; +use rustc::infer::{self, InferCtxt, TypeOrigin, new_infer_ctxt}; use std::cell::RefCell; use std::rc::Rc; use syntax::ast; diff --git a/src/librustc_typeck/coherence/orphan.rs b/src/librustc_typeck/coherence/orphan.rs index 56e6d0399036d..eba3e56c72207 100644 --- a/src/librustc_typeck/coherence/orphan.rs +++ b/src/librustc_typeck/coherence/orphan.rs @@ -13,8 +13,8 @@ use middle::cstore::LOCAL_CRATE; use middle::def_id::DefId; -use middle::traits; -use middle::ty::{self, TyCtxt}; +use rustc::traits; +use rustc::ty::{self, TyCtxt}; use syntax::ast; use syntax::codemap::Span; use rustc::dep_graph::DepNode; diff --git a/src/librustc_typeck/coherence/overlap.rs b/src/librustc_typeck/coherence/overlap.rs index 78ae8fa65f840..d7d4560a4eac3 100644 --- a/src/librustc_typeck/coherence/overlap.rs +++ b/src/librustc_typeck/coherence/overlap.rs @@ -14,9 +14,9 @@ use middle::cstore::CrateStore; use middle::def_id::DefId; -use middle::traits::{self, ProjectionMode}; -use middle::infer; -use middle::ty::{self, TyCtxt}; +use rustc::traits::{self, ProjectionMode}; +use rustc::infer; +use rustc::ty::{self, TyCtxt}; use syntax::ast; use rustc::dep_graph::DepNode; use rustc_front::hir; diff --git a/src/librustc_typeck/coherence/unsafety.rs b/src/librustc_typeck/coherence/unsafety.rs index fbb1653b06a07..6d77200daa384 100644 --- a/src/librustc_typeck/coherence/unsafety.rs +++ b/src/librustc_typeck/coherence/unsafety.rs @@ -11,7 +11,7 @@ //! Unsafety checker: every impl either implements a trait defined in this //! crate or pertains to a type defined in this crate. -use middle::ty::TyCtxt; +use rustc::ty::TyCtxt; use rustc_front::intravisit; use rustc_front::hir; diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 3f8f31ce3ce80..0b447b2009b58 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -68,12 +68,12 @@ use middle::lang_items::SizedTraitLangItem; use middle::resolve_lifetime; use middle::const_eval::{self, ConstVal}; use middle::const_eval::EvalHint::UncheckedExprHint; -use middle::subst::{Substs, FnSpace, ParamSpace, SelfSpace, TypeSpace, VecPerParamSpace}; -use middle::ty::{ToPredicate, ImplContainer, ImplOrTraitItemContainer, TraitContainer}; -use middle::ty::{self, ToPolyTraitRef, Ty, TyCtxt, TypeScheme}; -use middle::ty::{VariantKind}; -use middle::ty::fold::{TypeFolder}; -use middle::ty::util::IntTypeExt; +use rustc::ty::subst::{Substs, FnSpace, ParamSpace, SelfSpace, TypeSpace, VecPerParamSpace}; +use rustc::ty::{ToPredicate, ImplContainer, ImplOrTraitItemContainer, TraitContainer}; +use rustc::ty::{self, ToPolyTraitRef, Ty, TyCtxt, TypeScheme}; +use rustc::ty::{VariantKind}; +use rustc::ty::fold::{TypeFolder}; +use rustc::ty::util::IntTypeExt; use rscope::*; use rustc::dep_graph::DepNode; use rustc::front::map as hir_map; diff --git a/src/librustc_typeck/constrained_type_params.rs b/src/librustc_typeck/constrained_type_params.rs index 4446063e0c7bc..7e8b08c58539b 100644 --- a/src/librustc_typeck/constrained_type_params.rs +++ b/src/librustc_typeck/constrained_type_params.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::subst; -use middle::ty::{self, Ty, TyCtxt}; +use rustc::ty::subst; +use rustc::ty::{self, Ty, TyCtxt}; use std::collections::HashSet; diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 4e1f3d3cbb7a9..9b0fdd8a2e327 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -104,10 +104,10 @@ pub use rustc::util; use dep_graph::DepNode; use front::map as hir_map; use middle::def::Def; -use middle::infer::{self, TypeOrigin}; -use middle::subst::Substs; -use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; -use middle::traits::ProjectionMode; +use rustc::infer::{self, TypeOrigin}; +use rustc::ty::subst::Substs; +use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; +use rustc::traits::ProjectionMode; use session::{config, CompileResult}; use util::common::time; use rustc_front::hir; diff --git a/src/librustc_typeck/rscope.rs b/src/librustc_typeck/rscope.rs index 1b02c736dce3b..793dba1e3f5f8 100644 --- a/src/librustc_typeck/rscope.rs +++ b/src/librustc_typeck/rscope.rs @@ -9,7 +9,7 @@ // except according to those terms. -use middle::ty; +use rustc::ty; use std::cell::Cell; use syntax::codemap::Span; diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 5c74e9096f3a7..1ed355c90a546 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -16,10 +16,10 @@ use dep_graph::DepTrackingMapConfig; use middle::def_id::DefId; use middle::resolve_lifetime as rl; -use middle::subst; -use middle::subst::ParamSpace; -use middle::ty::{self, Ty, TyCtxt}; -use middle::ty::maps::ItemVariances; +use rustc::ty::subst; +use rustc::ty::subst::ParamSpace; +use rustc::ty::{self, Ty, TyCtxt}; +use rustc::ty::maps::ItemVariances; use rustc::front::map as hir_map; use syntax::ast; use rustc_front::hir; diff --git a/src/librustc_typeck/variance/mod.rs b/src/librustc_typeck/variance/mod.rs index ab37ef952c9a9..ee9f317f20fd0 100644 --- a/src/librustc_typeck/variance/mod.rs +++ b/src/librustc_typeck/variance/mod.rs @@ -12,7 +12,7 @@ //! parameters. See README.md for details. use arena; -use middle::ty::TyCtxt; +use rustc::ty::TyCtxt; /// Defines the `TermsContext` basically houses an arena where we can /// allocate terms. diff --git a/src/librustc_typeck/variance/solve.rs b/src/librustc_typeck/variance/solve.rs index fd442a4547cf9..0763cfd7e2e60 100644 --- a/src/librustc_typeck/variance/solve.rs +++ b/src/librustc_typeck/variance/solve.rs @@ -15,8 +15,8 @@ //! optimal solution to the constraints. The final variance for each //! inferred is then written into the `variance_map` in the tcx. -use middle::subst::VecPerParamSpace; -use middle::ty; +use rustc::ty::subst::VecPerParamSpace; +use rustc::ty; use std::rc::Rc; use super::constraints::*; diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs index ff55aefb20ff3..c6f82ba42e6be 100644 --- a/src/librustc_typeck/variance/terms.rs +++ b/src/librustc_typeck/variance/terms.rs @@ -21,9 +21,9 @@ use arena::TypedArena; use dep_graph::DepTrackingMapConfig; -use middle::subst::{ParamSpace, FnSpace, TypeSpace, SelfSpace, VecPerParamSpace}; -use middle::ty::{self, TyCtxt}; -use middle::ty::maps::ItemVariances; +use rustc::ty::subst::{ParamSpace, FnSpace, TypeSpace, SelfSpace, VecPerParamSpace}; +use rustc::ty::{self, TyCtxt}; +use rustc::ty::maps::ItemVariances; use std::fmt; use std::rc::Rc; use syntax::ast; diff --git a/src/librustc_typeck/variance/xform.rs b/src/librustc_typeck/variance/xform.rs index 2749dce5c73f4..02a2ceb360d7f 100644 --- a/src/librustc_typeck/variance/xform.rs +++ b/src/librustc_typeck/variance/xform.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::ty; +use rustc::ty; pub trait Xform { fn xform(self, v: Self) -> Self; diff --git a/src/librustc_unicode/char.rs b/src/librustc_unicode/char.rs index e2440227cf44b..7b9296bb4c893 100644 --- a/src/librustc_unicode/char.rs +++ b/src/librustc_unicode/char.rs @@ -153,14 +153,9 @@ impl char { /// Basic usage: /// /// ``` - /// let d = '1'; - /// - /// assert!(d.is_digit(10)); - /// - /// let d = 'f'; - /// - /// assert!(d.is_digit(16)); - /// assert!(!d.is_digit(10)); + /// assert!('1'.is_digit(10)); + /// assert!('f'.is_digit(16)); + /// assert!(!'f'.is_digit(10)); /// ``` /// /// Passing a large radix, causing a panic: @@ -169,10 +164,8 @@ impl char { /// use std::thread; /// /// let result = thread::spawn(|| { - /// let d = '1'; - /// /// // this panics - /// d.is_digit(37); + /// '1'.is_digit(37); /// }).join(); /// /// assert!(result.is_err()); @@ -209,25 +202,15 @@ impl char { /// Basic usage: /// /// ``` - /// let d = '1'; - /// - /// assert_eq!(d.to_digit(10), Some(1)); - /// - /// let d = 'f'; - /// - /// assert_eq!(d.to_digit(16), Some(15)); + /// assert_eq!('1'.to_digit(10), Some(1)); + /// assert_eq!('f'.to_digit(16), Some(15)); /// ``` /// /// Passing a non-digit results in failure: /// /// ``` - /// let d = 'f'; - /// - /// assert_eq!(d.to_digit(10), None); - /// - /// let d = 'z'; - /// - /// assert_eq!(d.to_digit(16), None); + /// assert_eq!('f'.to_digit(10), None); + /// assert_eq!('z'.to_digit(16), None); /// ``` /// /// Passing a large radix, causing a panic: @@ -236,9 +219,7 @@ impl char { /// use std::thread; /// /// let result = thread::spawn(|| { - /// let d = '1'; - /// - /// d.to_digit(37); + /// '1'.to_digit(37); /// }).join(); /// /// assert!(result.is_err()); @@ -463,12 +444,8 @@ impl char { /// Basic usage: /// /// ``` - /// let c = 'a'; - /// - /// assert!(c.is_alphabetic()); - /// - /// let c = '京'; - /// assert!(c.is_alphabetic()); + /// assert!('a'.is_alphabetic()); + /// assert!('京'.is_alphabetic()); /// /// let c = '💝'; /// // love is many things, but it is not alphabetic @@ -522,21 +499,13 @@ impl char { /// Basic usage: /// /// ``` - /// let c = 'a'; - /// assert!(c.is_lowercase()); - /// - /// let c = 'δ'; - /// assert!(c.is_lowercase()); - /// - /// let c = 'A'; - /// assert!(!c.is_lowercase()); - /// - /// let c = 'Δ'; - /// assert!(!c.is_lowercase()); + /// assert!('a'.is_lowercase()); + /// assert!('δ'.is_lowercase()); + /// assert!(!'A'.is_lowercase()); + /// assert!(!'Δ'.is_lowercase()); /// /// // The various Chinese scripts do not have case, and so: - /// let c = '中'; - /// assert!(!c.is_lowercase()); + /// assert!(!'中'.is_lowercase()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -558,21 +527,13 @@ impl char { /// Basic usage: /// /// ``` - /// let c = 'a'; - /// assert!(!c.is_uppercase()); - /// - /// let c = 'δ'; - /// assert!(!c.is_uppercase()); - /// - /// let c = 'A'; - /// assert!(c.is_uppercase()); - /// - /// let c = 'Δ'; - /// assert!(c.is_uppercase()); + /// assert!(!'a'.is_uppercase()); + /// assert!(!'δ'.is_uppercase()); + /// assert!('A'.is_uppercase()); + /// assert!('Δ'.is_uppercase()); /// /// // The various Chinese scripts do not have case, and so: - /// let c = '中'; - /// assert!(!c.is_uppercase()); + /// assert!(!'中'.is_uppercase()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -594,15 +555,12 @@ impl char { /// Basic usage: /// /// ``` - /// let c = ' '; - /// assert!(c.is_whitespace()); + /// assert!(' '.is_whitespace()); /// /// // a non-breaking space - /// let c = '\u{A0}'; - /// assert!(c.is_whitespace()); + /// assert!('\u{A0}'.is_whitespace()); /// - /// let c = '越'; - /// assert!(!c.is_whitespace()); + /// assert!(!'越'.is_whitespace()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -624,29 +582,14 @@ impl char { /// Basic usage: /// /// ``` - /// let c = '٣'; - /// assert!(c.is_alphanumeric()); - /// - /// let c = '7'; - /// assert!(c.is_alphanumeric()); - /// - /// let c = '৬'; - /// assert!(c.is_alphanumeric()); - /// - /// let c = 'K'; - /// assert!(c.is_alphanumeric()); - /// - /// let c = 'و'; - /// assert!(c.is_alphanumeric()); - /// - /// let c = '藏'; - /// assert!(c.is_alphanumeric()); - /// - /// let c = '¾'; - /// assert!(!c.is_alphanumeric()); - /// - /// let c = '①'; - /// assert!(!c.is_alphanumeric()); + /// assert!('٣'.is_alphanumeric()); + /// assert!('7'.is_alphanumeric()); + /// assert!('৬'.is_alphanumeric()); + /// assert!('K'.is_alphanumeric()); + /// assert!('و'.is_alphanumeric()); + /// assert!('藏'.is_alphanumeric()); + /// assert!(!'¾'.is_alphanumeric()); + /// assert!(!'①'.is_alphanumeric()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -665,11 +608,8 @@ impl char { /// /// ``` /// // U+009C, STRING TERMINATOR - /// let c = 'œ'; - /// assert!(c.is_control()); - /// - /// let c = 'q'; - /// assert!(!c.is_control()); + /// assert!('œ'.is_control()); + /// assert!(!'q'.is_control()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -687,29 +627,14 @@ impl char { /// Basic usage: /// /// ``` - /// let c = '٣'; - /// assert!(c.is_numeric()); - /// - /// let c = '7'; - /// assert!(c.is_numeric()); - /// - /// let c = '৬'; - /// assert!(c.is_numeric()); - /// - /// let c = 'K'; - /// assert!(!c.is_numeric()); - /// - /// let c = 'و'; - /// assert!(!c.is_numeric()); - /// - /// let c = '藏'; - /// assert!(!c.is_numeric()); - /// - /// let c = '¾'; - /// assert!(!c.is_numeric()); - /// - /// let c = '①'; - /// assert!(!c.is_numeric()); + /// assert!('٣'.is_numeric()); + /// assert!('7'.is_numeric()); + /// assert!('৬'.is_numeric()); + /// assert!(!'K'.is_numeric()); + /// assert!(!'و'.is_numeric()); + /// assert!(!'藏'.is_numeric()); + /// assert!(!'¾'.is_numeric()); + /// assert!(!'①'.is_numeric()); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -744,13 +669,10 @@ impl char { /// Basic usage: /// /// ``` - /// let c = 'C'; - /// - /// assert_eq!(c.to_lowercase().next(), Some('c')); + /// assert_eq!('C'.to_lowercase().next(), Some('c')); /// /// // Japanese scripts do not have case, and so: - /// let c = '山'; - /// assert_eq!(c.to_lowercase().next(), Some('山')); + /// assert_eq!('山'.to_lowercase().next(), Some('山')); /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[inline] @@ -781,12 +703,10 @@ impl char { /// Basic usage: /// /// ``` - /// let c = 'c'; - /// assert_eq!(c.to_uppercase().next(), Some('C')); + /// assert_eq!('c'.to_uppercase().next(), Some('C')); /// /// // Japanese does not have case, and so: - /// let c = '山'; - /// assert_eq!(c.to_uppercase().next(), Some('山')); + /// assert_eq!('山'.to_uppercase().next(), Some('山')); /// ``` /// /// In Turkish, the equivalent of 'i' in Latin has five forms instead of two: @@ -797,9 +717,7 @@ impl char { /// Note that the lowercase dotted 'i' is the same as the Latin. Therefore: /// /// ``` - /// let i = 'i'; - /// - /// let upper_i = i.to_uppercase().next(); + /// let upper_i = 'i'.to_uppercase().next(); /// ``` /// /// The value of `upper_i` here relies on the language of the text: if we're @@ -807,9 +725,7 @@ impl char { /// be `Some('İ')`. `to_uppercase()` does not take this into account, and so: /// /// ``` - /// let i = 'i'; - /// - /// let upper_i = i.to_uppercase().next(); + /// let upper_i = 'i'.to_uppercase().next(); /// /// assert_eq!(Some('I'), upper_i); /// ``` diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index e9c55c56a9d72..94dead3c00577 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -19,8 +19,8 @@ use rustc_front::hir; use rustc::middle::cstore::{self, CrateStore}; use rustc::middle::def::Def; use rustc::middle::def_id::DefId; -use rustc::middle::ty::{self, TyCtxt}; -use rustc::middle::subst; +use rustc::ty::{self, TyCtxt}; +use rustc::ty::subst; use rustc::middle::stability; use rustc::middle::const_eval; diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 15aeca9204a64..d21fd5364b054 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -38,8 +38,8 @@ use rustc_trans::back::link; use rustc::middle::cstore::{self, CrateStore}; use rustc::middle::def::Def; use rustc::middle::def_id::{DefId, DefIndex}; -use rustc::middle::subst::{self, ParamSpace, VecPerParamSpace}; -use rustc::middle::ty; +use rustc::ty::subst::{self, ParamSpace, VecPerParamSpace}; +use rustc::ty; use rustc::middle::stability; use rustc_front::hir; @@ -831,7 +831,7 @@ impl Clean for hir::WherePredicate { impl<'a> Clean for ty::Predicate<'a> { fn clean(&self, cx: &DocContext) -> WherePredicate { - use rustc::middle::ty::Predicate; + use rustc::ty::Predicate; match *self { Predicate::Trait(ref pred) => pred.clean(cx), diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs index 716b88d5534ae..e6a4d882c0449 100644 --- a/src/librustdoc/clean/simplify.rs +++ b/src/librustdoc/clean/simplify.rs @@ -11,7 +11,7 @@ //! Simplification of where clauses and parameter bounds into a prettier and //! more canonical form. //! -//! Currently all cross-crate-inlined function use `middle::ty` to reconstruct +//! Currently all cross-crate-inlined function use `rustc::ty` to reconstruct //! the AST (e.g. see all of `clean::inline`), but this is not always a //! non-lossy transformation. The current format of storage for where clauses //! for functions and such is simply a list of predicates. One example of this @@ -30,7 +30,7 @@ use std::mem; use std::collections::HashMap; use rustc::middle::def_id::DefId; -use rustc::middle::subst; +use rustc::ty::subst; use clean::PathParameters as PP; use clean::WherePredicate as WP; diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index c30fd39616c44..15a10a84e4362 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -15,7 +15,7 @@ use rustc::dep_graph::DepGraph; use rustc::session::{self, config}; use rustc::middle::def_id::DefId; use rustc::middle::privacy::AccessLevels; -use rustc::middle::ty::{self, TyCtxt}; +use rustc::ty::{self, TyCtxt}; use rustc::front::map as hir_map; use rustc::lint; use rustc_trans::back::link; diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 8fb58f58e8a5f..1d1e78926f120 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -742,8 +742,6 @@ if ($(this).val().length === 0) { if (browserSupportsHistoryApi()) { history.replaceState("", "std - Rust", "?search="); - } else { - location.replace("?search="); } $('#main.content').removeClass('hidden'); $('#search.content').addClass('hidden'); diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index a8a3353da4c00..3ae3cf8504ea4 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -567,4 +567,10 @@ mod tests { &from_u32(lower).unwrap().to_string())); } } + + #[test] + fn inference_works() { + let x = "a".to_string(); + x.eq_ignore_ascii_case("A"); + } } diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index e78d46b22e940..6fc26bb7eed71 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -1152,9 +1152,10 @@ impl f32 { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn asinh(self) -> f32 { - match self { - NEG_INFINITY => NEG_INFINITY, - x => (x + ((x * x) + 1.0).sqrt()).ln(), + if self == NEG_INFINITY { + NEG_INFINITY + } else { + (self + ((self * self) + 1.0).sqrt()).ln() } } diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index cea5a9edd680b..93e5969a275c3 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -1023,9 +1023,10 @@ impl f64 { #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn asinh(self) -> f64 { - match self { - NEG_INFINITY => NEG_INFINITY, - x => (x + ((x * x) + 1.0).sqrt()).ln(), + if self == NEG_INFINITY { + NEG_INFINITY + } else { + (self + ((self * self) + 1.0).sqrt()).ln() } } diff --git a/src/libstd/process.rs b/src/libstd/process.rs index e86026758aa08..c1ef60852a7c8 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -339,7 +339,7 @@ impl Command { /// ``` #[stable(feature = "process", since = "1.0.0")] pub fn status(&mut self) -> io::Result { - self.inner.spawn(imp::Stdio::Inherit, false).map(Child::from_inner) + self.inner.spawn(imp::Stdio::Inherit, true).map(Child::from_inner) .and_then(|mut p| p.wait()) } } diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index a91e1321149a3..13ff97503c957 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -13,9 +13,60 @@ //! This primitive is meant to be used to run one-time initialization. An //! example use case would be for initializing an FFI library. -use isize; -use sync::atomic::{AtomicIsize, Ordering}; -use sync::StaticMutex; +// A "once" is a relatively simple primitive, and it's also typically provided +// by the OS as well (see `pthread_once` or `InitOnceExecuteOnce`). The OS +// primitives, however, tend to have surprising restrictions, such as the Unix +// one doesn't allow an argument to be passed to the function. +// +// As a result, we end up implementing it ourselves in the standard library. +// This also gives us the opportunity to optimize the implementation a bit which +// should help the fast path on call sites. Consequently, let's explain how this +// primitive works now! +// +// So to recap, the guarantees of a Once are that it will call the +// initialization closure at most once, and it will never return until the one +// that's running has finished running. This means that we need some form of +// blocking here while the custom callback is running at the very least. +// Additionally, we add on the restriction of **poisoning**. Whenever an +// initialization closure panics, the Once enters a "poisoned" state which means +// that all future calls will immediately panic as well. +// +// So to implement this, one might first reach for a `StaticMutex`, but those +// unfortunately need to be deallocated (e.g. call `destroy()`) to free memory +// on all OSes (some of the BSDs allocate memory for mutexes). It also gets a +// lot harder with poisoning to figure out when the mutex needs to be +// deallocated because it's not after the closure finishes, but after the first +// successful closure finishes. +// +// All in all, this is instead implemented with atomics and lock-free +// operations! Whee! Each `Once` has one word of atomic state, and this state is +// CAS'd on to determine what to do. There are four possible state of a `Once`: +// +// * Incomplete - no initialization has run yet, and no thread is currently +// using the Once. +// * Poisoned - some thread has previously attempted to initialize the Once, but +// it panicked, so the Once is now poisoned. There are no other +// threads currently accessing this Once. +// * Running - some thread is currently attempting to run initialization. It may +// succeed, so all future threads need to wait for it to finish. +// Note that this state is accompanied with a payload, described +// below. +// * Complete - initialization has completed and all future calls should finish +// immediately. +// +// With 4 states we need 2 bits to encode this, and we use the remaining bits +// in the word we have allocated as a queue of threads waiting for the thread +// responsible for entering the RUNNING state. This queue is just a linked list +// of Waiter nodes which is monotonically increasing in size. Each node is +// allocated on the stack, and whenever the running closure finishes it will +// consume the entire queue and notify all waiters they should try again. +// +// You'll find a few more details in the implementation, but that's the gist of +// it! + +use marker; +use sync::atomic::{AtomicUsize, AtomicBool, Ordering}; +use thread::{self, Thread}; /// A synchronization primitive which can be used to run a one-time global /// initialization. Useful for one-time initialization for FFI or related @@ -35,23 +86,62 @@ use sync::StaticMutex; /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub struct Once { - mutex: StaticMutex, - cnt: AtomicIsize, - lock_cnt: AtomicIsize, + // This `state` word is actually an encoded version of just a pointer to a + // `Waiter`, so we add the `PhantomData` appropriately. + state: AtomicUsize, + _marker: marker::PhantomData<*mut Waiter>, +} + +// The `PhantomData` of a raw pointer removes these two auto traits, but we +// enforce both below in the implementation so this should be safe to add. +#[stable(feature = "rust1", since = "1.0.0")] +unsafe impl Sync for Once {} +#[stable(feature = "rust1", since = "1.0.0")] +unsafe impl Send for Once {} + +/// State yielded to the `call_once_force` method which can be used to query +/// whether the `Once` was previously poisoned or not. +#[unstable(feature = "once_poison", issue = "31688")] +pub struct OnceState { + poisoned: bool, } /// Initialization value for static `Once` values. #[stable(feature = "rust1", since = "1.0.0")] pub const ONCE_INIT: Once = Once::new(); +// Four states that a Once can be in, encoded into the lower bits of `state` in +// the Once structure. +const INCOMPLETE: usize = 0x0; +const POISONED: usize = 0x1; +const RUNNING: usize = 0x2; +const COMPLETE: usize = 0x3; + +// Mask to learn about the state. All other bits are the queue of waiters if +// this is in the RUNNING state. +const STATE_MASK: usize = 0x3; + +// Representation of a node in the linked list of waiters in the RUNNING state. +struct Waiter { + thread: Option, + signaled: AtomicBool, + next: *mut Waiter, +} + +// Helper struct used to clean up after a closure call with a `Drop` +// implementation to also run on panic. +struct Finish { + panicked: bool, + me: &'static Once, +} + impl Once { /// Creates a new `Once` value. #[stable(feature = "once_new", since = "1.2.0")] pub const fn new() -> Once { Once { - mutex: StaticMutex::new(), - cnt: AtomicIsize::new(0), - lock_cnt: AtomicIsize::new(0), + state: AtomicUsize::new(INCOMPLETE), + _marker: marker::PhantomData, } } @@ -68,73 +158,223 @@ impl Once { /// be reliably observed by other threads at this point (there is a /// happens-before relation between the closure and code executing after the /// return). + /// + /// # Examples + /// + /// ``` + /// use std::sync::{Once, ONCE_INIT}; + /// + /// static mut VAL: usize = 0; + /// static INIT: Once = ONCE_INIT; + /// + /// // Accessing a `static mut` is unsafe much of the time, but if we do so + /// // in a synchronized fashion (e.g. write once or read all) then we're + /// // good to go! + /// // + /// // This function will only call `expensive_computation` once, and will + /// // otherwise always return the value returned from the first invocation. + /// fn get_cached_val() -> usize { + /// unsafe { + /// INIT.call_once(|| { + /// VAL = expensive_computation(); + /// }); + /// VAL + /// } + /// } + /// + /// fn expensive_computation() -> usize { + /// // ... + /// # 2 + /// } + /// ``` + /// + /// # Panics + /// + /// The closure `f` will only be executed once if this is called + /// concurrently amongst many threads. If that closure panics, however, then + /// it will *poison* this `Once` instance, causing all future invocations of + /// `call_once` to also panic. + /// + /// This is similar to [poisoning with mutexes][poison]. + /// + /// [poison]: struct.Mutex.html#poisoning #[stable(feature = "rust1", since = "1.0.0")] pub fn call_once(&'static self, f: F) where F: FnOnce() { - // Optimize common path: load is much cheaper than fetch_add. - if self.cnt.load(Ordering::SeqCst) < 0 { + // Fast path, just see if we've completed initialization. + if self.state.load(Ordering::SeqCst) == COMPLETE { return } - // Implementation-wise, this would seem like a fairly trivial primitive. - // The stickler part is where our mutexes currently require an - // allocation, and usage of a `Once` shouldn't leak this allocation. - // - // This means that there must be a deterministic destroyer of the mutex - // contained within (because it's not needed after the initialization - // has run). - // - // The general scheme here is to gate all future threads once - // initialization has completed with a "very negative" count, and to - // allow through threads to lock the mutex if they see a non negative - // count. For all threads grabbing the mutex, exactly one of them should - // be responsible for unlocking the mutex, and this should only be done - // once everyone else is done with the mutex. - // - // This atomicity is achieved by swapping a very negative value into the - // shared count when the initialization routine has completed. This will - // read the number of threads which will at some point attempt to - // acquire the mutex. This count is then squirreled away in a separate - // variable, and the last person on the way out of the mutex is then - // responsible for destroying the mutex. - // - // It is crucial that the negative value is swapped in *after* the - // initialization routine has completed because otherwise new threads - // calling `call_once` will return immediately before the initialization - // has completed. - - let prev = self.cnt.fetch_add(1, Ordering::SeqCst); - if prev < 0 { - // Make sure we never overflow, we'll never have isize::MIN - // simultaneous calls to `call_once` to make this value go back to 0 - self.cnt.store(isize::MIN, Ordering::SeqCst); + let mut f = Some(f); + self.call_inner(false, &mut |_| f.take().unwrap()()); + } + + /// Performs the same function as `call_once` except ignores poisoning. + /// + /// If this `Once` has been poisoned (some initialization panicked) then + /// this function will continue to attempt to call initialization functions + /// until one of them doesn't panic. + /// + /// The closure `f` is yielded a structure which can be used to query the + /// state of this `Once` (whether initialization has previously panicked or + /// not). + /// poisoned or not. + #[unstable(feature = "once_poison", issue = "31688")] + pub fn call_once_force(&'static self, f: F) where F: FnOnce(&OnceState) { + // same as above, just with a different parameter to `call_inner`. + if self.state.load(Ordering::SeqCst) == COMPLETE { return } - // If the count is negative, then someone else finished the job, - // otherwise we run the job and record how many people will try to grab - // this lock - let guard = self.mutex.lock(); - if self.cnt.load(Ordering::SeqCst) > 0 { - f(); - let prev = self.cnt.swap(isize::MIN, Ordering::SeqCst); - self.lock_cnt.store(prev, Ordering::SeqCst); + let mut f = Some(f); + self.call_inner(true, &mut |p| { + f.take().unwrap()(&OnceState { poisoned: p }) + }); + } + + // This is a non-generic function to reduce the monomorphization cost of + // using `call_once` (this isn't exactly a trivial or small implementation). + // + // Additionally, this is tagged with `#[cold]` as it should indeed be cold + // and it helps let LLVM know that calls to this function should be off the + // fast path. Essentially, this should help generate more straight line code + // in LLVM. + // + // Finally, this takes an `FnMut` instead of a `FnOnce` because there's + // currently no way to take an `FnOnce` and call it via virtual dispatch + // without some allocation overhead. + #[cold] + fn call_inner(&'static self, + ignore_poisoning: bool, + mut init: &mut FnMut(bool)) { + let mut state = self.state.load(Ordering::SeqCst); + + 'outer: loop { + match state { + // If we're complete, then there's nothing to do, we just + // jettison out as we shouldn't run the closure. + COMPLETE => return, + + // If we're poisoned and we're not in a mode to ignore + // poisoning, then we panic here to propagate the poison. + POISONED if !ignore_poisoning => { + panic!("Once instance has previously been poisoned"); + } + + // Otherwise if we see a poisoned or otherwise incomplete state + // we will attempt to move ourselves into the RUNNING state. If + // we succeed, then the queue of waiters starts at null (all 0 + // bits). + POISONED | + INCOMPLETE => { + let old = self.state.compare_and_swap(state, RUNNING, + Ordering::SeqCst); + if old != state { + state = old; + continue + } + + // Run the initialization routine, letting it know if we're + // poisoned or not. The `Finish` struct is then dropped, and + // the `Drop` implementation here is responsible for waking + // up other waiters both in the normal return and panicking + // case. + let mut complete = Finish { + panicked: true, + me: self, + }; + init(state == POISONED); + complete.panicked = false; + return + } + + // All other values we find should correspond to the RUNNING + // state with an encoded waiter list in the more significant + // bits. We attempt to enqueue ourselves by moving us to the + // head of the list and bail out if we ever see a state that's + // not RUNNING. + _ => { + assert!(state & STATE_MASK == RUNNING); + let mut node = Waiter { + thread: Some(thread::current()), + signaled: AtomicBool::new(false), + next: 0 as *mut Waiter, + }; + let me = &mut node as *mut Waiter as usize; + assert!(me & STATE_MASK == 0); + + while state & STATE_MASK == RUNNING { + node.next = (state & !STATE_MASK) as *mut Waiter; + let old = self.state.compare_and_swap(state, + me | RUNNING, + Ordering::SeqCst); + if old != state { + state = old; + continue + } + + // Once we've enqueued ourselves, wait in a loop. + // Aftewards reload the state and continue with what we + // were doing from before. + while !node.signaled.load(Ordering::SeqCst) { + thread::park(); + } + state = self.state.load(Ordering::SeqCst); + continue 'outer + } + } + } } - drop(guard); + } +} - // Last one out cleans up after everyone else, no leaks! - if self.lock_cnt.fetch_add(-1, Ordering::SeqCst) == 1 { - unsafe { self.mutex.destroy() } +impl Drop for Finish { + fn drop(&mut self) { + // Swap out our state with however we finished. We should only ever see + // an old state which was RUNNING. + let queue = if self.panicked { + self.me.state.swap(POISONED, Ordering::SeqCst) + } else { + self.me.state.swap(COMPLETE, Ordering::SeqCst) + }; + assert_eq!(queue & STATE_MASK, RUNNING); + + // Decode the RUNNING to a list of waiters, then walk that entire list + // and wake them up. Note that it is crucial that after we store `true` + // in the node it can be free'd! As a result we load the `thread` to + // signal ahead of time and then unpark it after the store. + unsafe { + let mut queue = (queue & !STATE_MASK) as *mut Waiter; + while !queue.is_null() { + let next = (*queue).next; + let thread = (*queue).thread.take().unwrap(); + (*queue).signaled.store(true, Ordering::SeqCst); + thread.unpark(); + queue = next; + } } } } +impl OnceState { + /// Returns whether the associated `Once` has been poisoned. + /// + /// Once an initalization routine for a `Once` has panicked it will forever + /// indicate to future forced initialization routines that it is poisoned. + #[unstable(feature = "once_poison", issue = "31688")] + pub fn poisoned(&self) -> bool { + self.poisoned + } +} + #[cfg(test)] mod tests { use prelude::v1::*; + use panic; + use sync::mpsc::channel; use thread; use super::Once; - use sync::mpsc::channel; #[test] fn smoke_once() { @@ -179,4 +419,71 @@ mod tests { rx.recv().unwrap(); } } + + #[test] + fn poison_bad() { + static O: Once = Once::new(); + + // poison the once + let t = panic::recover(|| { + O.call_once(|| panic!()); + }); + assert!(t.is_err()); + + // poisoning propagates + let t = panic::recover(|| { + O.call_once(|| {}); + }); + assert!(t.is_err()); + + // we can subvert poisoning, however + let mut called = false; + O.call_once_force(|poisoned| { + called = true; + assert!(poisoned) + }); + assert!(called); + + // once any success happens, we stop propagating the poison + O.call_once(|| {}); + } + + #[test] + fn wait_for_force_to_finish() { + static O: Once = Once::new(); + + // poison the once + let t = panic::recover(|| { + O.call_once(|| panic!()); + }); + assert!(t.is_err()); + + // make sure someone's waiting inside the once via a force + let (tx1, rx1) = channel(); + let (tx2, rx2) = channel(); + let t1 = thread::spawn(move || { + O.call_once_force(|p| { + assert!(p); + tx1.send(()).unwrap(); + rx2.recv().unwrap(); + }); + }); + + rx1.recv().unwrap(); + + // put another waiter on the once + let t2 = thread::spawn(|| { + let mut called = false; + O.call_once(|| { + called = true; + }); + assert!(!called); + }); + + tx2.send(()).unwrap(); + + assert!(t1.join().is_ok()); + assert!(t2.join().is_ok()); + + } } diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index 793a2ecae89f1..6d966a0f6944c 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -13,7 +13,7 @@ use prelude::v1::*; use alloc::boxed::FnBox; use cmp; #[cfg(not(any(target_env = "newlib", target_os = "solaris")))] -use ffi::CString; +use ffi::CStr; use io; use libc; use mem; @@ -84,15 +84,12 @@ impl Thread { #[cfg(any(target_os = "linux", target_os = "android", target_os = "emscripten"))] - pub fn set_name(name: &str) { + pub fn set_name(name: &CStr) { const PR_SET_NAME: libc::c_int = 15; - let cname = CString::new(name).unwrap_or_else(|_| { - panic!("thread name may not contain interior null bytes") - }); // pthread wrapper only appeared in glibc 2.12, so we use syscall // directly. unsafe { - libc::prctl(PR_SET_NAME, cname.as_ptr() as libc::c_ulong, 0, 0, 0); + libc::prctl(PR_SET_NAME, name.as_ptr() as libc::c_ulong, 0, 0, 0); } } @@ -100,32 +97,30 @@ impl Thread { target_os = "dragonfly", target_os = "bitrig", target_os = "openbsd"))] - pub fn set_name(name: &str) { - let cname = CString::new(name).unwrap(); + pub fn set_name(name: &CStr) { unsafe { - libc::pthread_set_name_np(libc::pthread_self(), cname.as_ptr()); + libc::pthread_set_name_np(libc::pthread_self(), name.as_ptr()); } } #[cfg(any(target_os = "macos", target_os = "ios"))] - pub fn set_name(name: &str) { - let cname = CString::new(name).unwrap(); + pub fn set_name(name: &CStr) { unsafe { - libc::pthread_setname_np(cname.as_ptr()); + libc::pthread_setname_np(name.as_ptr()); } } #[cfg(target_os = "netbsd")] - pub fn set_name(name: &str) { + pub fn set_name(name: &CStr) { + use ffi::CString; let cname = CString::new(&b"%s"[..]).unwrap(); - let carg = CString::new(name).unwrap(); unsafe { libc::pthread_setname_np(libc::pthread_self(), cname.as_ptr(), - carg.as_ptr() as *mut libc::c_void); + name.as_ptr() as *mut libc::c_void); } } #[cfg(any(target_env = "newlib", target_os = "solaris"))] - pub fn set_name(_name: &str) { + pub fn set_name(_name: &CStr) { // Newlib and Illumos has no way to set a thread name. } diff --git a/src/libstd/sys/windows/thread.rs b/src/libstd/sys/windows/thread.rs index b18772c0c2438..6908775e86fc1 100644 --- a/src/libstd/sys/windows/thread.rs +++ b/src/libstd/sys/windows/thread.rs @@ -54,7 +54,7 @@ impl Thread { } } - pub fn set_name(_name: &str) { + pub fn set_name(_name: &CStr) { // Windows threads are nameless // The names in MSVC debugger are obtained using a "magic" exception, // which requires a use of MS C++ extensions. diff --git a/src/libstd/thread/mod.rs b/src/libstd/thread/mod.rs index f3139aaf98d83..b3549dc12645a 100644 --- a/src/libstd/thread/mod.rs +++ b/src/libstd/thread/mod.rs @@ -166,6 +166,8 @@ use any::Any; use cell::UnsafeCell; use fmt; use io; +use str; +use ffi::{CStr, CString}; use sync::{Mutex, Condvar, Arc}; use sys::thread as imp; use sys_common::thread_info; @@ -267,7 +269,7 @@ impl Builder { let their_packet = my_packet.clone(); let main = move || { - if let Some(name) = their_thread.name() { + if let Some(name) = their_thread.cname() { imp::Thread::set_name(name); } unsafe { @@ -450,7 +452,7 @@ pub fn park_timeout(dur: Duration) { /// The internal representation of a `Thread` handle struct Inner { - name: Option, + name: Option, // Guaranteed to be UTF-8 lock: Mutex, // true when there is a buffered unpark cvar: Condvar, } @@ -465,9 +467,12 @@ pub struct Thread { impl Thread { // Used only internally to construct a thread object without spawning fn new(name: Option) -> Thread { + let cname = name.map(|n| CString::new(n).unwrap_or_else(|_| { + panic!("thread name may not contain interior null bytes") + })); Thread { inner: Arc::new(Inner { - name: name, + name: cname, lock: Mutex::new(false), cvar: Condvar::new(), }) @@ -489,6 +494,10 @@ impl Thread { /// Gets the thread's name. #[stable(feature = "rust1", since = "1.0.0")] pub fn name(&self) -> Option<&str> { + self.cname().map(|s| unsafe { str::from_utf8_unchecked(s.to_bytes()) } ) + } + + fn cname(&self) -> Option<&CStr> { self.inner.name.as_ref().map(|s| &**s) } } @@ -622,6 +631,12 @@ mod tests { }).unwrap().join().unwrap(); } + #[test] + #[should_panic] + fn test_invalid_named_thread() { + let _ = Builder::new().name("ada l\0velace".to_string()).spawn(|| {}); + } + #[test] fn test_run_basic() { let (tx, rx) = channel(); diff --git a/src/libstd/time/duration.rs b/src/libstd/time/duration.rs index 7c3240b4a40c4..945eb6a42e5a7 100644 --- a/src/libstd/time/duration.rs +++ b/src/libstd/time/duration.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ops::{Add, Sub, Mul, Div}; +use ops::{Add, Sub, Mul, Div, AddAssign, SubAssign, MulAssign, DivAssign}; const NANOS_PER_SEC: u32 = 1_000_000_000; const NANOS_PER_MILLI: u32 = 1_000_000; @@ -105,6 +105,13 @@ impl Add for Duration { } } +#[stable(feature = "time_augmented_assignment", since = "1.9.0")] +impl AddAssign for Duration { + fn add_assign(&mut self, rhs: Duration) { + *self = *self + rhs; + } +} + #[stable(feature = "duration", since = "1.3.0")] impl Sub for Duration { type Output = Duration; @@ -124,6 +131,13 @@ impl Sub for Duration { } } +#[stable(feature = "time_augmented_assignment", since = "1.9.0")] +impl SubAssign for Duration { + fn sub_assign(&mut self, rhs: Duration) { + *self = *self - rhs; + } +} + #[stable(feature = "duration", since = "1.3.0")] impl Mul for Duration { type Output = Duration; @@ -141,6 +155,13 @@ impl Mul for Duration { } } +#[stable(feature = "time_augmented_assignment", since = "1.9.0")] +impl MulAssign for Duration { + fn mul_assign(&mut self, rhs: u32) { + *self = *self * rhs; + } +} + #[stable(feature = "duration", since = "1.3.0")] impl Div for Duration { type Output = Duration; @@ -155,6 +176,13 @@ impl Div for Duration { } } +#[stable(feature = "time_augmented_assignment", since = "1.9.0")] +impl DivAssign for Duration { + fn div_assign(&mut self, rhs: u32) { + *self = *self / rhs; + } +} + #[cfg(test)] mod tests { use super::Duration; diff --git a/src/libstd/time/mod.rs b/src/libstd/time/mod.rs index 0c32feebecbca..bc50b0d3a7066 100644 --- a/src/libstd/time/mod.rs +++ b/src/libstd/time/mod.rs @@ -24,7 +24,7 @@ use error::Error; use fmt; -use ops::{Add, Sub}; +use ops::{Add, Sub, AddAssign, SubAssign}; use sys::time; use sys_common::FromInner; @@ -172,6 +172,13 @@ impl Add for Instant { } } +#[stable(feature = "time_augmented_assignment", since = "1.9.0")] +impl AddAssign for Instant { + fn add_assign(&mut self, other: Duration) { + *self = *self + other; + } +} + #[stable(feature = "time2", since = "1.8.0")] impl Sub for Instant { type Output = Instant; @@ -181,6 +188,13 @@ impl Sub for Instant { } } +#[stable(feature = "time_augmented_assignment", since = "1.9.0")] +impl SubAssign for Instant { + fn sub_assign(&mut self, other: Duration) { + *self = *self - other; + } +} + #[stable(feature = "time2", since = "1.8.0")] impl Sub for Instant { type Output = Duration; @@ -254,6 +268,13 @@ impl Add for SystemTime { } } +#[stable(feature = "time_augmented_assignment", since = "1.9.0")] +impl AddAssign for SystemTime { + fn add_assign(&mut self, other: Duration) { + *self = *self + other; + } +} + #[stable(feature = "time2", since = "1.8.0")] impl Sub for SystemTime { type Output = SystemTime; @@ -263,6 +284,13 @@ impl Sub for SystemTime { } } +#[stable(feature = "time_augmented_assignment", since = "1.9.0")] +impl SubAssign for SystemTime { + fn sub_assign(&mut self, other: Duration) { + *self = *self - other; + } +} + #[stable(feature = "time2", since = "1.8.0")] impl fmt::Debug for SystemTime { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 804ca6705ecbb..f771ee95bd121 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -1304,6 +1304,31 @@ impl CodeMap { return a; } + /// Check if the backtrace `subtrace` contains `suptrace` as a prefix. + pub fn more_specific_trace(&self, + mut subtrace: ExpnId, + suptrace: ExpnId) + -> bool { + loop { + if subtrace == suptrace { + return true; + } + + let stop = self.with_expn_info(subtrace, |opt_expn_info| { + if let Some(expn_info) = opt_expn_info { + subtrace = expn_info.call_site.expn_id; + false + } else { + true + } + }); + + if stop { + return false; + } + } + } + pub fn record_expansion(&self, expn_info: ExpnInfo) -> ExpnId { let mut expansions = self.expansions.borrow_mut(); expansions.push(expn_info); diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 5bfdab791d638..8550617560df3 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -33,7 +33,7 @@ use visit::Visitor; use std_inject; use std::collections::HashSet; - +use std::env; pub fn expand_expr(e: P, fld: &mut MacroExpander) -> P { let expr_span = e.span; @@ -1275,11 +1275,41 @@ impl<'a, 'b> MacroExpander<'a, 'b> { } fn new_span(cx: &ExtCtxt, sp: Span) -> Span { - /* this discards information in the case of macro-defining macros */ - Span { - lo: sp.lo, - hi: sp.hi, - expn_id: cx.backtrace(), + debug!("new_span(sp={:?})", sp); + + if cx.codemap().more_specific_trace(sp.expn_id, cx.backtrace()) { + // If the span we are looking at has a backtrace that has more + // detail than our current backtrace, then we keep that + // backtrace. Honestly, I have no idea if this makes sense, + // because I have no idea why we are stripping the backtrace + // below. But the reason I made this change is because, in + // deriving, we were generating attributes with a specific + // backtrace, which was essential for `#[structural_match]` to + // be properly supported, but these backtraces were being + // stripped and replaced with a null backtrace. Sort of + // unclear why this is the case. --nmatsakis + debug!("new_span: keeping trace from {:?} because it is more specific", + sp.expn_id); + sp + } else { + // This discards information in the case of macro-defining macros. + // + // The comment above was originally added in + // b7ec2488ff2f29681fe28691d20fd2c260a9e454 in Feb 2012. I + // *THINK* the reason we are doing this is because we want to + // replace the backtrace of the macro contents with the + // backtrace that contains the macro use. But it's pretty + // unclear to me. --nmatsakis + let sp1 = Span { + lo: sp.lo, + hi: sp.hi, + expn_id: cx.backtrace(), + }; + debug!("new_span({:?}) = {:?}", sp, sp1); + if sp.expn_id.into_u32() == 0 && env::var_os("NDM").is_some() { + panic!("NDM"); + } + sp1 } } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 299b7d8b9ba07..8e7f4876ee2ab 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -109,6 +109,8 @@ const KNOWN_FEATURES: &'static [(&'static str, &'static str, Option, Status // to bootstrap fix for #5723. ("issue_5723_bootstrap", "1.0.0", None, Accepted), + ("structural_match", "1.8.0", Some(31434), Active), + // A way to temporarily opt out of opt in copy. This will *never* be accepted. ("opt_out_copy", "1.0.0", None, Removed), @@ -304,6 +306,11 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGat ("link_args", Normal, Ungated), ("macro_escape", Normal, Ungated), + // RFC #1445. + ("structural_match", Whitelisted, Gated("structural_match", + "the semantics of constant patterns is \ + not yet settled")), + // Not used any more, but we can't feature gate it ("no_stack_check", Normal, Ungated), @@ -676,7 +683,7 @@ impl<'a> Context<'a> { fn gate_feature(&self, feature: &str, span: Span, explain: &str) { let has_feature = self.has_feature(feature); debug!("gate_feature(feature = {:?}, span = {:?}); has? {}", feature, span, has_feature); - if !has_feature { + if !has_feature && !self.cm.span_allows_unstable(span) { emit_feature_err(self.span_handler, feature, span, GateIssue::Language, explain); } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a1adc99055f08..82715f263c96d 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -268,8 +268,8 @@ pub struct Parser<'a> { /// Used to determine the path to externally loaded source files pub filename: Option, pub mod_path_stack: Vec, - /// Stack of spans of open delimiters. Used for error message. - pub open_braces: Vec, + /// Stack of open delimiters and their spans. Used for error message. + pub open_braces: Vec<(token::DelimToken, Span)>, /// Flag if this parser "owns" the directory that it is currently parsing /// in. This will affect how nested files are looked up. pub owns_directory: bool, @@ -895,7 +895,7 @@ impl<'a> Parser<'a> { sep: SeqSep, f: F) -> Vec - where F: FnMut(&mut Parser<'a>) -> PResult<'a, T>, + where F: FnMut(&mut Parser<'a>) -> PResult<'a, T> { self.parse_seq_to_before_tokens(&[ket], sep, f, |mut e| e.emit()) } @@ -2755,8 +2755,8 @@ impl<'a> Parser<'a> { let mut err: DiagnosticBuilder<'a> = self.diagnostic().struct_span_err(self.span, "this file contains an un-closed delimiter"); - for sp in &self.open_braces { - err.span_help(*sp, "did you mean to close this delimiter?"); + for &(_, sp) in &self.open_braces { + err.span_help(sp, "did you mean to close this delimiter?"); } Err(err) @@ -2766,23 +2766,66 @@ impl<'a> Parser<'a> { let pre_span = self.span; // Parse the open delimiter. - self.open_braces.push(self.span); + self.open_braces.push((delim, self.span)); let open_span = self.span; self.bump(); - // Parse the token trees within the delimiters - let tts = self.parse_seq_to_before_end(&token::CloseDelim(delim), - SeqSep::none(), - |p| p.parse_token_tree()); + // Parse the token trees within the delimiters. + // We stop at any delimiter so we can try to recover if the user + // uses an incorrect delimiter. + let tts = self.parse_seq_to_before_tokens(&[&token::CloseDelim(token::Brace), + &token::CloseDelim(token::Paren), + &token::CloseDelim(token::Bracket)], + SeqSep::none(), + |p| p.parse_token_tree(), + |mut e| e.emit()); - // Parse the close delimiter. let close_span = self.span; - self.bump(); - self.open_braces.pop().unwrap(); - // Expand to cover the entire delimited token tree let span = Span { hi: close_span.hi, ..pre_span }; + match self.token { + // Correct delmiter. + token::CloseDelim(d) if d == delim => { + self.open_braces.pop().unwrap(); + + // Parse the close delimiter. + self.bump(); + } + // Incorect delimiter. + token::CloseDelim(other) => { + let token_str = self.this_token_to_string(); + let mut err = self.diagnostic().struct_span_err(self.span, + &format!("incorrect close delimiter: `{}`", token_str)); + // This is a conservative error: only report the last unclosed delimiter. + // The previous unclosed delimiters could actually be closed! The parser + // just hasn't gotten to them yet. + if let Some(&(_, sp)) = self.open_braces.last() { + err.span_note(sp, "unclosed delimiter"); + }; + err.emit(); + + self.open_braces.pop().unwrap(); + + // If the incorrect delimter matches an earlier opening + // delimiter, then don't consume it (it can be used to + // close the earlier one)Otherwise, consume it. + // E.g., we try to recover from: + // fn foo() { + // bar(baz( + // } // Incorrect delimiter but matches the earlier `{` + if !self.open_braces.iter().any(|&(b, _)| b == other) { + self.bump(); + } + } + token::Eof => { + // Silently recover, the EOF token will be seen again + // and an error emitted then. Thus we don't pop from + // self.open_braces here. + }, + _ => unreachable!(), + } + Ok(TokenTree::Delimited(span, Rc::new(Delimited { delim: delim, open_span: open_span, @@ -2798,16 +2841,11 @@ impl<'a> Parser<'a> { maybe_whole!(deref self, NtTT); match self.token { token::CloseDelim(_) => { + // An unexpected closing delimiter (i.e., there is no + // matching opening delimiter). let token_str = self.this_token_to_string(); - let mut err = self.diagnostic().struct_span_err(self.span, - &format!("incorrect close delimiter: `{}`", token_str)); - // This is a conservative error: only report the last unclosed delimiter. - // The previous unclosed delimiters could actually be closed! The parser - // just hasn't gotten to them yet. - if let Some(&sp) = self.open_braces.last() { - err.span_note(sp, "unclosed delimiter"); - }; - + let err = self.diagnostic().struct_span_err(self.span, + &format!("unexpected close delimiter: `{}`", token_str)); Err(err) }, /* we ought to allow different depths of unquotation */ @@ -3825,7 +3863,9 @@ impl<'a> Parser<'a> { fn recover_stmt_(&mut self, break_on_semi: SemiColonMode) { let mut brace_depth = 0; let mut bracket_depth = 0; + debug!("recover_stmt_ enter loop"); loop { + debug!("recover_stmt_ loop {:?}", self.token); match self.token { token::OpenDelim(token::DelimToken::Brace) => { brace_depth += 1; @@ -3837,6 +3877,7 @@ impl<'a> Parser<'a> { } token::CloseDelim(token::DelimToken::Brace) => { if brace_depth == 0 { + debug!("recover_stmt_ return - close delim {:?}", self.token); return; } brace_depth -= 1; @@ -3849,12 +3890,16 @@ impl<'a> Parser<'a> { } self.bump(); } - token::Eof => return, + token::Eof => { + debug!("recover_stmt_ return - Eof"); + return; + } token::Semi => { self.bump(); if break_on_semi == SemiColonMode::Break && brace_depth == 0 && bracket_depth == 0 { + debug!("recover_stmt_ return - Semi"); return; } } @@ -4043,6 +4088,8 @@ impl<'a> Parser<'a> { while !self.eat(&token::CloseDelim(token::Brace)) { let Spanned {node, span} = if let Some(s) = self.parse_stmt_() { s + } else if self.token == token::Eof { + break; } else { // Found only `;` or `}`. continue; diff --git a/src/libsyntax_ext/Cargo.toml b/src/libsyntax_ext/Cargo.toml index e137815cd32fd..671f3e4a7e330 100644 --- a/src/libsyntax_ext/Cargo.toml +++ b/src/libsyntax_ext/Cargo.toml @@ -10,4 +10,5 @@ crate-type = ["dylib"] [dependencies] fmt_macros = { path = "../libfmt_macros" } +log = { path = "../liblog" } syntax = { path = "../libsyntax" } diff --git a/src/libsyntax_ext/deriving/mod.rs b/src/libsyntax_ext/deriving/mod.rs index 75de5c56ea139..1774167e83000 100644 --- a/src/libsyntax_ext/deriving/mod.rs +++ b/src/libsyntax_ext/deriving/mod.rs @@ -78,7 +78,10 @@ fn expand_derive(cx: &mut ExtCtxt, mitem: &MetaItem, annotatable: Annotatable) -> Annotatable { - annotatable.map_item_or(|item| { + debug!("expand_derive: span = {:?}", span); + debug!("expand_derive: mitem = {:?}", mitem); + debug!("expand_derive: annotatable input = {:?}", annotatable); + let annot = annotatable.map_item_or(|item| { item.map(|mut item| { if mitem.value_str().is_some() { cx.span_err(mitem.span, "unexpected value in `derive`"); @@ -89,6 +92,9 @@ fn expand_derive(cx: &mut ExtCtxt, cx.span_warn(mitem.span, "empty trait list in `derive`"); } + let mut found_partial_eq = false; + let mut found_eq = false; + for titem in traits.iter().rev() { let tname = match titem.node { MetaItemKind::Word(ref tname) => tname, @@ -107,17 +113,64 @@ fn expand_derive(cx: &mut ExtCtxt, continue; } + if &tname[..] == "Eq" { + found_eq = true; + } else if &tname[..] == "PartialEq" { + found_partial_eq = true; + } + // #[derive(Foo, Bar)] expands to #[derive_Foo] #[derive_Bar] item.attrs.push(cx.attribute(titem.span, cx.meta_word(titem.span, intern_and_get_ident(&format!("derive_{}", tname))))); } + // RFC #1445. `#[derive(PartialEq, Eq)]` adds a (trusted) + // `#[structural_match]` attribute. + if found_partial_eq && found_eq { + // This span is **very** sensitive and crucial to + // getting the stability behavior we want. What we are + // doing is marking `#[structural_match]` with the + // span of the `#[deriving(...)]` attribute (the + // entire attribute, not just the `PartialEq` or `Eq` + // part), but with the current backtrace. The current + // backtrace will contain a topmost entry that IS this + // `#[deriving(...)]` attribute and with the + // "allow-unstable" flag set to true. + // + // Note that we do NOT use the span of the `Eq` + // text itself. You might think this is + // equivalent, because the `Eq` appears within the + // `#[deriving(Eq)]` attribute, and hence we would + // inherit the "allows unstable" from the + // backtrace. But in fact this is not always the + // case. The actual source text that led to + // deriving can be `#[$attr]`, for example, where + // `$attr == deriving(Eq)`. In that case, the + // "#[structural_match]" would be considered to + // originate not from the deriving call but from + // text outside the deriving call, and hence would + // be forbidden from using unstable + // content. + // + // See tests src/run-pass/rfc1445 for + // examples. --nmatsakis + let span = Span { expn_id: cx.backtrace(), .. span }; + assert!(cx.parse_sess.codemap().span_allows_unstable(span)); + debug!("inserting structural_match with span {:?}", span); + let structural_match = intern_and_get_ident("structural_match"); + item.attrs.push(cx.attribute(span, + cx.meta_word(span, + structural_match))); + } + item }) }, |a| { cx.span_err(span, "`derive` can only be applied to items"); a - }) + }); + debug!("expand_derive: annotatable output = {:?}", annot); + annot } macro_rules! derive_traits { diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs index 97531d4279d4b..f214ecdc3368d 100644 --- a/src/libsyntax_ext/lib.rs +++ b/src/libsyntax_ext/lib.rs @@ -24,6 +24,7 @@ #![feature(str_char)] extern crate fmt_macros; +#[macro_use] extern crate log; #[macro_use] extern crate syntax; diff --git a/src/test/auxiliary/dummy_mir_pass.rs b/src/test/auxiliary/dummy_mir_pass.rs index fdfbc98b0078a..3e1b46522a98d 100644 --- a/src/test/auxiliary/dummy_mir_pass.rs +++ b/src/test/auxiliary/dummy_mir_pass.rs @@ -22,7 +22,7 @@ extern crate syntax; use rustc::mir::transform::{self, MirPass}; use rustc::mir::repr::{Mir, Literal}; use rustc::mir::visit::MutVisitor; -use rustc::middle::ty; +use rustc::ty; use rustc::middle::const_eval::ConstVal; use rustc_const_eval::ConstInt; use rustc_plugin::Registry; diff --git a/src/test/parse-fail/issue-10636-2.rs b/src/test/compile-fail/issue-10636-2.rs similarity index 75% rename from src/test/parse-fail/issue-10636-2.rs rename to src/test/compile-fail/issue-10636-2.rs index 41a3b06e6556e..eaccaf3cdbd27 100644 --- a/src/test/parse-fail/issue-10636-2.rs +++ b/src/test/compile-fail/issue-10636-2.rs @@ -1,4 +1,4 @@ -// Copyright 2013 The Rust Project Developers. See the COPYRIGHT +// Copyright 2013-2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -11,11 +11,9 @@ // FIXME(31528) we emit a bunch of silly errors here due to continuing past the // first one. This would be easy-ish to address by better recovery in tokenisation. -// compile-flags: -Z parse-only - -pub fn trace_option(option: Option) { //~ HELP did you mean to close this delimiter? +pub fn trace_option(option: Option) { option.map(|some| 42; //~ NOTE: unclosed delimiter //~^ ERROR: expected one of + //~^^ ERROR: mismatched types } //~ ERROR: incorrect close delimiter //~^ ERROR: expected one of -//~ ERROR: this file contains an un-closed delimiter diff --git a/src/test/compile-fail/issue-31804.rs b/src/test/compile-fail/issue-31804.rs new file mode 100644 index 0000000000000..b6a04bee85d4f --- /dev/null +++ b/src/test/compile-fail/issue-31804.rs @@ -0,0 +1,16 @@ +// Copyright 2016 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. + +// Test that error recovery in the parser to an EOF does not give an infinite +// spew of errors. + +fn main() { + let +} //~ ERROR unexpected token: `}` diff --git a/src/test/compile-fail/issue-6804.rs b/src/test/compile-fail/issue-6804.rs index ffab194149e12..f6b7e13c4f5e9 100644 --- a/src/test/compile-fail/issue-6804.rs +++ b/src/test/compile-fail/issue-6804.rs @@ -24,9 +24,13 @@ fn main() { //~ ERROR compilation successful _ => {}, }; //~^^^ WARNING unmatchable NaN in pattern, use the is_nan method in a guard instead + //~| WARNING floating point constants cannot be used + //~| WARNING this was previously accepted match [x, 1.0] { [NAN, _] => {}, _ => {}, }; //~^^^ WARNING unmatchable NaN in pattern, use the is_nan method in a guard instead + //~| WARNING floating point constants cannot be used + //~| WARNING this was previously accepted } diff --git a/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs b/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs index 865784c2f1eed..0c4aae8cfad36 100644 --- a/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs +++ b/src/test/compile-fail/moves-based-on-type-cyclic-types-issue-4821.rs @@ -10,7 +10,7 @@ // Test for a subtle failure computing kinds of cyclic types, in which // temporary kinds wound up being stored in a cache and used later. -// See middle::ty::type_contents() for more information. +// See rustc::ty::type_contents() for more information. struct List { key: isize, next: Option> } diff --git a/src/test/compile-fail/rfc1445/feature-gate.rs b/src/test/compile-fail/rfc1445/feature-gate.rs new file mode 100644 index 0000000000000..1f2d7819e26d8 --- /dev/null +++ b/src/test/compile-fail/rfc1445/feature-gate.rs @@ -0,0 +1,36 @@ +// Copyright 2012 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. + +// Test that structural match is only permitted with a feature gate, +// and that if a feature gate is supplied, it permits the type to be +// used in a match. + +// revisions: with_gate no_gate + +#![allow(dead_code)] +#![deny(future_incompatible)] +#![feature(rustc_attrs)] +#![cfg_attr(with_gate, feature(structural_match))] + +#[structural_match] //[no_gate]~ ERROR semantics of constant patterns is not yet settled +struct Foo { + x: u32 +} + +const FOO: Foo = Foo { x: 0 }; + +#[rustc_error] +fn main() { //[with_gate]~ ERROR compilation successful + let y = Foo { x: 1 }; + match y { + FOO => { } + _ => { } + } +} diff --git a/src/test/compile-fail/rfc1445/match-forbidden-without-eq.rs b/src/test/compile-fail/rfc1445/match-forbidden-without-eq.rs new file mode 100644 index 0000000000000..c573e3e8e28b2 --- /dev/null +++ b/src/test/compile-fail/rfc1445/match-forbidden-without-eq.rs @@ -0,0 +1,39 @@ +// Copyright 2012 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. + +#![allow(dead_code)] +#![deny(future_incompatible)] + +use std::f32; + +#[derive(PartialEq)] +struct Foo { + x: u32 +} + +const FOO: Foo = Foo { x: 0 }; + +fn main() { + let y = Foo { x: 1 }; + match y { + FOO => { } + //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + //~| WARNING will become a hard error + _ => { } + } + + let x = 0.0; + match x { + f32::INFINITY => { } + //~^ ERROR floating point constants cannot be used in patterns + //~| WARNING will become a hard error + _ => { } + } +} diff --git a/src/test/compile-fail/rfc1445/match-requires-both-partialeq-and-eq.rs b/src/test/compile-fail/rfc1445/match-requires-both-partialeq-and-eq.rs new file mode 100644 index 0000000000000..029df08ebc37a --- /dev/null +++ b/src/test/compile-fail/rfc1445/match-requires-both-partialeq-and-eq.rs @@ -0,0 +1,35 @@ +// Copyright 2012 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. + +#![allow(dead_code)] +#![deny(future_incompatible)] + +#[derive(Eq)] +struct Foo { + x: u32 +} + +impl PartialEq for Foo { + fn eq(&self, _: &Foo) -> bool { + false // ha ha sucker! + } +} + +const FOO: Foo = Foo { x: 0 }; + +fn main() { + let y = Foo { x: 1 }; + match y { + FOO => { } + //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + //~| WARNING will become a hard error + _ => { } + } +} diff --git a/src/test/compile-fail/token-error-correct-2.rs b/src/test/compile-fail/token-error-correct-2.rs new file mode 100644 index 0000000000000..ab429ab878073 --- /dev/null +++ b/src/test/compile-fail/token-error-correct-2.rs @@ -0,0 +1,17 @@ +// Copyright 2016 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. + +// Test that we do some basic error correcton in the tokeniser (and don't ICE). + +fn main() { + if foo { //~ NOTE: unclosed delimiter + //~^ ERROR: unresolved name `foo` + ) //~ ERROR: incorrect close delimiter: `)` +} diff --git a/src/test/compile-fail/token-error-correct-3.rs b/src/test/compile-fail/token-error-correct-3.rs new file mode 100644 index 0000000000000..fe8c9f690139f --- /dev/null +++ b/src/test/compile-fail/token-error-correct-3.rs @@ -0,0 +1,33 @@ +// Copyright 2016 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. + +// Test that we do some basic error correcton in the tokeniser (and don't spew +// too many bogus errors). + +pub mod raw { + use std::{io, fs}; + use std::path::Path; + + pub fn ensure_dir_exists, F: FnOnce(&Path)>(path: P, + callback: F) + -> io::Result { + if !is_directory(path.as_ref()) { //~ ERROR: unresolved name `is_directory` + callback(path.as_ref(); //~ NOTE: unclosed delimiter + //~^ ERROR: expected one of + fs::create_dir_all(path.as_ref()).map(|()| true) //~ ERROR: expected one of + } else { //~ ERROR: incorrect close delimiter: `}` + Ok(false); + } + + panic!(); + } +} + +fn main() {} diff --git a/src/test/compile-fail/token-error-correct.rs b/src/test/compile-fail/token-error-correct.rs new file mode 100644 index 0000000000000..6c54acd7bdbf6 --- /dev/null +++ b/src/test/compile-fail/token-error-correct.rs @@ -0,0 +1,20 @@ +// Copyright 2016 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. + +// Test that we do some basic error correcton in the tokeniser. + +fn main() { + foo(bar(; //~ NOTE: unclosed delimiter + //~^ NOTE: unclosed delimiter + //~^^ ERROR: unexpected token: `;` + //~^^^ ERROR: unresolved name `bar` + //~^^^^ ERROR: unresolved name `foo` +} //~ ERROR: incorrect close delimiter: `}` +//~^ ERROR: incorrect close delimiter: `}` diff --git a/src/test/debuginfo/constant-in-match-pattern.rs b/src/test/debuginfo/constant-in-match-pattern.rs index fb40400a4429c..6974238ac72f2 100644 --- a/src/test/debuginfo/constant-in-match-pattern.rs +++ b/src/test/debuginfo/constant-in-match-pattern.rs @@ -21,15 +21,18 @@ const CONSTANT: u64 = 3; +#[derive(PartialEq, Eq)] struct Struct { a: isize, b: usize, } const STRUCT: Struct = Struct { a: 1, b: 2 }; +#[derive(PartialEq, Eq)] struct TupleStruct(u32); const TUPLE_STRUCT: TupleStruct = TupleStruct(4); +#[derive(PartialEq, Eq)] enum Enum { Variant1(char), Variant2 { a: u8 }, diff --git a/src/test/parse-fail/issue-2354-1.rs b/src/test/parse-fail/issue-2354-1.rs index e65f95780bb96..f24c544073578 100644 --- a/src/test/parse-fail/issue-2354-1.rs +++ b/src/test/parse-fail/issue-2354-1.rs @@ -10,4 +10,4 @@ // compile-flags: -Z parse-only -static foo: isize = 2; } //~ ERROR incorrect close delimiter: +static foo: isize = 2; } //~ ERROR unexpected close delimiter: diff --git a/src/test/parse-fail/macro-mismatched-delim-paren-brace.rs b/src/test/parse-fail/macro-mismatched-delim-paren-brace.rs index 84094ab6ca89c..cbc0ed0ccdb84 100644 --- a/src/test/parse-fail/macro-mismatched-delim-paren-brace.rs +++ b/src/test/parse-fail/macro-mismatched-delim-paren-brace.rs @@ -14,4 +14,4 @@ fn main() { foo! ( bar, "baz", 1, 2.0 } //~ ERROR incorrect close delimiter -} +} //~ ERROR unexpected close delimiter: `}` diff --git a/src/test/run-make/execution-engine/test.rs b/src/test/run-make/execution-engine/test.rs index 4ff531d4755c8..7454bbfb53146 100644 --- a/src/test/run-make/execution-engine/test.rs +++ b/src/test/run-make/execution-engine/test.rs @@ -30,7 +30,7 @@ use rustc::dep_graph::DepGraph; use rustc::front::map as ast_map; use rustc::llvm; use rustc::middle::cstore::{CrateStore, LinkagePreference}; -use rustc::middle::ty; +use rustc::ty; use rustc::session::config::{self, basic_options, build_configuration, Input, Options}; use rustc::session::build_session; use rustc_driver::{driver, abort_on_err}; diff --git a/src/test/run-pass/associated-const-match-patterns.rs b/src/test/run-pass/associated-const-match-patterns.rs index 605ca6b65e2cf..01d1b27bfc99f 100644 --- a/src/test/run-pass/associated-const-match-patterns.rs +++ b/src/test/run-pass/associated-const-match-patterns.rs @@ -17,6 +17,7 @@ use empty_struct::XEmpty2 as XFoo; struct Foo; +#[derive(PartialEq, Eq)] enum Bar { Var1, Var2, diff --git a/src/test/run-pass/empty-struct-braces.rs b/src/test/run-pass/empty-struct-braces.rs index 85ae77f20f155..0060150fbece0 100644 --- a/src/test/run-pass/empty-struct-braces.rs +++ b/src/test/run-pass/empty-struct-braces.rs @@ -18,7 +18,10 @@ use empty_struct::*; struct Empty1 {} struct Empty2; + +#[derive(PartialEq, Eq)] struct Empty3 {} + const Empty3: Empty3 = Empty3 {}; enum E { diff --git a/src/test/run-pass/issue-12860.rs b/src/test/run-pass/issue-12860.rs index c854747bcf7bd..5c9ee74472b12 100644 --- a/src/test/run-pass/issue-12860.rs +++ b/src/test/run-pass/issue-12860.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// pretty-expanded FIXME #23616 - #![feature(collections)] extern crate collections; diff --git a/src/test/compile-fail/issue-20427.rs b/src/test/run-pass/issue-20427.rs similarity index 55% rename from src/test/compile-fail/issue-20427.rs rename to src/test/run-pass/issue-20427.rs index 99dd22a888cb5..dd3d952224c05 100644 --- a/src/test/compile-fail/issue-20427.rs +++ b/src/test/run-pass/issue-20427.rs @@ -1,4 +1,4 @@ -// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // @@ -9,17 +9,17 @@ // except according to those terms. // aux-build:i8.rs +// ignore-pretty (#23623) + extern crate i8; use std::string as i16; static i32: i32 = 0; const i64: i64 = 0; fn u8(f32: f32) {} fn f(f64: f64) {} -//~^ ERROR user-defined types or type parameters cannot shadow the primitive types -type u16 = u16; //~ ERROR user-defined types or type parameters cannot shadow the primitive types -enum u32 {} //~ ERROR user-defined types or type parameters cannot shadow the primitive types -struct u64; //~ ERROR user-defined types or type parameters cannot shadow the primitive types -trait bool {} //~ ERROR user-defined types or type parameters cannot shadow the primitive types +enum u32 {} +struct u64; +trait bool {} mod char { extern crate i8; @@ -40,29 +40,52 @@ mod char { use super::u8_ as u8; use super::f_ as f64; use super::u16_ as u16; - //~^ ERROR user-defined types or type parameters cannot shadow the primitive types use super::u32_ as u32; - //~^ ERROR user-defined types or type parameters cannot shadow the primitive types use super::u64_ as u64; - //~^ ERROR user-defined types or type parameters cannot shadow the primitive types use super::bool_ as bool; - //~^ ERROR user-defined types or type parameters cannot shadow the primitive types use super::{bool_ as str}; - //~^ ERROR user-defined types or type parameters cannot shadow the primitive types use super::char_ as char; } } trait isize_ { - type isize; //~ ERROR user-defined types or type parameters cannot shadow the primitive types + type isize; } fn usize<'usize>(usize: &'usize usize) -> &'usize usize { usize } +mod reuse { + use std::mem::size_of; + + type u8 = u64; + use std::string::String as i16; + + pub fn check() { + assert_eq!(size_of::(), 8); + assert_eq!(size_of::<::u64>(), 0); + assert_eq!(size_of::(), 3 * size_of::<*const ()>()); + assert_eq!(size_of::(), 0); + } +} + +mod guard { + pub fn check() { + use std::u8; // bring module u8 in scope + fn f() -> u8 { // OK, resolves to primitive u8, not to std::u8 + u8::max_value() // OK, resolves to associated function ::max_value, + // not to non-existent std::u8::max_value + } + assert_eq!(f(), u8::MAX); // OK, resolves to std::u8::MAX + } +} + fn main() { let bool = true; - match bool { + let _ = match bool { str @ true => if str { i32 as i64 } else { i64 }, false => i64, }; + + reuse::check::(); + guard::check(); } diff --git a/src/test/run-pass/match-arm-statics.rs b/src/test/run-pass/match-arm-statics.rs index 43ff69fe75e6c..9700ed247959b 100644 --- a/src/test/run-pass/match-arm-statics.rs +++ b/src/test/run-pass/match-arm-statics.rs @@ -9,18 +9,24 @@ // except according to those terms. +#[derive(PartialEq, Eq)] struct NewBool(bool); +#[derive(PartialEq, Eq)] enum Direction { North, East, South, West } + +#[derive(PartialEq, Eq)] struct Foo { bar: Option, baz: NewBool } + +#[derive(PartialEq, Eq)] enum EnumWithStructVariants { Variant1(bool), Variant2 { @@ -37,7 +43,7 @@ const VARIANT2_NORTH: EnumWithStructVariants = EnumWithStructVariants::Variant2 dir: Direction::North }; pub mod glfw { - #[derive(Copy, Clone)] + #[derive(Copy, Clone, PartialEq, Eq)] pub struct InputState(usize); pub const RELEASE : InputState = InputState(0); @@ -82,6 +88,7 @@ fn issue_14576() { _ => unreachable!() } + #[derive(PartialEq, Eq)] enum C { D = 3, E = 4 } const F : C = C::D; @@ -89,6 +96,7 @@ fn issue_14576() { } fn issue_13731() { + #[derive(PartialEq, Eq)] enum A { AA(()) } const B: A = A::AA(()); @@ -99,6 +107,7 @@ fn issue_13731() { fn issue_15393() { #![allow(dead_code)] + #[derive(PartialEq, Eq)] struct Flags { bits: usize } diff --git a/src/test/run-pass/process-status-inherits-stdin.rs b/src/test/run-pass/process-status-inherits-stdin.rs new file mode 100644 index 0000000000000..2ad47c4f116ae --- /dev/null +++ b/src/test/run-pass/process-status-inherits-stdin.rs @@ -0,0 +1,41 @@ +// Copyright 2016 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 std::env; +use std::io; +use std::io::Write; +use std::process::{Command, Stdio}; + +fn main() { + let mut args = env::args(); + let me = args.next().unwrap(); + let arg = args.next(); + match arg.as_ref().map(|s| &s[..]) { + None => { + let mut s = Command::new(&me) + .arg("a1") + .stdin(Stdio::piped()) + .spawn() + .unwrap(); + s.stdin.take().unwrap().write_all(b"foo\n").unwrap(); + let s = s.wait().unwrap(); + assert!(s.success()); + } + Some("a1") => { + let s = Command::new(&me).arg("a2").status().unwrap(); + assert!(s.success()); + } + Some(..) => { + let mut s = String::new(); + io::stdin().read_line(&mut s).unwrap(); + assert_eq!(s, "foo\n"); + } + } +} diff --git a/src/test/run-pass/rfc1445/eq-allows-match-on-ty-in-macro.rs b/src/test/run-pass/rfc1445/eq-allows-match-on-ty-in-macro.rs new file mode 100644 index 0000000000000..241fe6c6ab1e9 --- /dev/null +++ b/src/test/run-pass/rfc1445/eq-allows-match-on-ty-in-macro.rs @@ -0,0 +1,32 @@ +// Copyright 2012 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. + +#![allow(dead_code)] + +macro_rules! foo { + (#[$attr:meta] $x:ident) => { + #[$attr] + struct $x { + x: u32 + } + } +} + +foo! { #[derive(PartialEq, Eq)] Foo } + +const FOO: Foo = Foo { x: 0 }; + +fn main() { + let y = Foo { x: 1 }; + match y { + FOO => { } + _ => { } + } +} diff --git a/src/test/run-pass/rfc1445/eq-allows-match.rs b/src/test/run-pass/rfc1445/eq-allows-match.rs new file mode 100644 index 0000000000000..f02a45625c9f6 --- /dev/null +++ b/src/test/run-pass/rfc1445/eq-allows-match.rs @@ -0,0 +1,26 @@ +// Copyright 2012 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. + +#![allow(dead_code)] + +#[derive(PartialEq, Eq)] +struct Foo { + x: u32 +} + +const FOO: Foo = Foo { x: 0 }; + +fn main() { + let y = Foo { x: 1 }; + match y { + FOO => { } + _ => { } + } +}