From 41244661979cda16bf2b15bd802337a0ee9764dd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 14 Mar 2016 22:46:42 -0700 Subject: [PATCH 01/35] std: Fix inheriting stdin on status() This regression was accidentally introduced in #31618, and it's just flipping a boolean! Closes #32254 --- src/libstd/process.rs | 2 +- .../run-pass/process-status-inherits-stdin.rs | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 src/test/run-pass/process-status-inherits-stdin.rs diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 5813d82a315a6..9594c71267b35 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/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"); + } + } +} From bb43f580e5a291ee02a99b6dca6ec9b757151a19 Mon Sep 17 00:00:00 2001 From: Aidan Hobson Sayers Date: Sun, 20 Mar 2016 23:12:20 +0000 Subject: [PATCH 02/35] Document heap allocation location guarantee --- src/doc/reference.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/doc/reference.md b/src/doc/reference.md index 4c5fd31b96ed1..cdf54b39e6803 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -3909,6 +3909,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 From bef69a116e0042fbd92dfa08de68da73765f4c14 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sun, 20 Mar 2016 22:07:49 -0700 Subject: [PATCH 03/35] std: Add regression test for #32074 Just to make sure we don't accidentally break this in the future. --- src/libstd/ascii.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 031a9b8bec274..f0fd30a38991a 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -669,4 +669,10 @@ mod tests { &from_u32(lower).unwrap().to_string())); } } + + #[test] + fn inference_works() { + let x = "a".to_string(); + x.eq_ignore_ascii_case("A"); + } } From 3ee841c3351326a7bea83b689f54d9fee27e6e85 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Fri, 18 Mar 2016 15:49:12 +1300 Subject: [PATCH 04/35] Don't loop forever on error recovery with EOF closes #31804 --- src/libsyntax/parse/parser.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 6839f11cd709d..66912abb6f5a6 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3824,7 +3824,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; @@ -3836,6 +3838,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; @@ -3848,12 +3851,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; } } @@ -4042,6 +4049,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; From 2731dc169c3e35707049575829cb106e2bdc9801 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Tue, 22 Mar 2016 16:02:09 +1300 Subject: [PATCH 05/35] Error recovery in the tokeniser Closes #31994 --- src/libsyntax/parse/parser.rs | 83 ++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 25 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 66912abb6f5a6..3010c040914df 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,17 +2841,7 @@ impl<'a> Parser<'a> { maybe_whole!(deref self, NtTT); match self.token { token::CloseDelim(_) => { - 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(err) + panic!("should have been caught above"); }, /* we ought to allow different depths of unquotation */ token::Dollar | token::SubstNt(..) if self.quote_depth > 0 => { From 0950dc3d86c281f32439754a4cd8d616b574527f Mon Sep 17 00:00:00 2001 From: "NODA, Kai" Date: Wed, 23 Mar 2016 13:53:15 +0800 Subject: [PATCH 06/35] Remove ungrammatical dots from the error index. They were probably meant as a shorthand for omitted code. Part of #32446 but there should be a separate fix for the issue. Signed-off-by: NODA, Kai --- src/librustc/diagnostics.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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` ``` From be87650f6310e31347a173787090dc89635fb57e Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Tue, 22 Mar 2016 23:28:22 -0700 Subject: [PATCH 07/35] Add augmented assignment operator impls for time types --- src/libstd/time/duration.rs | 30 +++++++++++++++++++++++++++++- src/libstd/time/mod.rs | 30 +++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) 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 aa0a843dc9a54..414aeac2afe45 100644 --- a/src/libstd/time/mod.rs +++ b/src/libstd/time/mod.rs @@ -14,7 +14,7 @@ use error::Error; use fmt; -use ops::{Add, Sub}; +use ops::{Add, Sub, AddAssign, SubAssign}; use sys::time; use sys_common::FromInner; @@ -122,6 +122,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; @@ -131,6 +138,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; @@ -204,6 +218,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; @@ -213,6 +234,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 { From 80e7a1be359fc0de4eb17056230ae2fc130b7090 Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Wed, 23 Mar 2016 22:02:36 +0100 Subject: [PATCH 08/35] Mark str::split_at inline --- src/libcore/str/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index f9d1902bea7a7..4584c26bebcc8 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1965,6 +1965,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) { From f621193e5ea7ac54fcd37f0e730e955fd9f61200 Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Wed, 23 Mar 2016 21:57:44 +0100 Subject: [PATCH 09/35] Accept 0 as a valid str char boundary Index 0 must be a valid char boundary (invariant of str that it contains valid UTF-8 data). If we check explicitly for index == 0, that removes the need to read the byte at index 0, so it avoids a trip to the string's memory, and it optimizes out the slicing index' bounds check whenever it is zero. With this change, the following examples all change from having a read of the byte at 0 and a branch to possibly panicing, to having the bounds checking optimized away. ```rust pub fn split(s: &str) -> (&str, &str) { s.split_at(0) } pub fn both(s: &str) -> &str { &s[0..s.len()] } pub fn first(s: &str) -> &str { &s[..0] } pub fn last(s: &str) -> &str { &s[0..] } ``` --- src/libcore/str/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index 4584c26bebcc8..f033f50e59e5c 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -1892,7 +1892,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, From 180d6b55ca19c63347664f0622b6ccc37fb101f5 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Wed, 23 Mar 2016 09:24:54 +1300 Subject: [PATCH 10/35] Tests --- src/libsyntax/parse/parser.rs | 7 +++- .../issue-10636-2.rs | 8 ++--- src/test/compile-fail/issue-31804.rs | 16 +++++++++ .../compile-fail/token-error-correct-2.rs | 17 ++++++++++ .../compile-fail/token-error-correct-3.rs | 33 +++++++++++++++++++ src/test/compile-fail/token-error-correct.rs | 20 +++++++++++ src/test/parse-fail/issue-2354-1.rs | 2 +- .../macro-mismatched-delim-paren-brace.rs | 2 +- 8 files changed, 97 insertions(+), 8 deletions(-) rename src/test/{parse-fail => compile-fail}/issue-10636-2.rs (75%) create mode 100644 src/test/compile-fail/issue-31804.rs create mode 100644 src/test/compile-fail/token-error-correct-2.rs create mode 100644 src/test/compile-fail/token-error-correct-3.rs create mode 100644 src/test/compile-fail/token-error-correct.rs diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 3010c040914df..29ef105eccb72 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -2841,7 +2841,12 @@ impl<'a> Parser<'a> { maybe_whole!(deref self, NtTT); match self.token { token::CloseDelim(_) => { - panic!("should have been caught above"); + // An unexpected closing delimiter (i.e., there is no + // matching opening delimiter). + let token_str = self.this_token_to_string(); + 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 */ token::Dollar | token::SubstNt(..) if self.quote_depth > 0 => { 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/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/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: `}` From 2c48214a1b8e8a609fbe36b10bc62cbf6bd7b9e3 Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Tue, 22 Mar 2016 23:09:43 +0200 Subject: [PATCH 11/35] doc: remove needless bindings --- src/librustc_unicode/char.rs | 180 ++++++++++------------------------- 1 file changed, 48 insertions(+), 132 deletions(-) diff --git a/src/librustc_unicode/char.rs b/src/librustc_unicode/char.rs index 5bc5c78616093..dad72b0ddccd6 100644 --- a/src/librustc_unicode/char.rs +++ b/src/librustc_unicode/char.rs @@ -151,14 +151,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: @@ -167,10 +162,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()); @@ -207,25 +200,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: @@ -234,9 +217,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()); @@ -495,12 +476,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 @@ -554,21 +531,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] @@ -590,21 +559,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] @@ -626,15 +587,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] @@ -656,29 +614,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] @@ -697,11 +640,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] @@ -719,29 +659,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] @@ -776,13 +701,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] @@ -813,12 +735,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: @@ -829,9 +749,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 @@ -839,9 +757,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); /// ``` From ed2824792698c11437b58e5480da1c1dc3d54510 Mon Sep 17 00:00:00 2001 From: Doug Goldstein Date: Thu, 24 Mar 2016 13:11:08 -0500 Subject: [PATCH 12/35] configure: update required LLVM version Rust 1.7.0 and newer appears to require LLVM 3.6.0 or newer when building against a version that's out of the tree with the --llvm-root flag. Signed-off-by: Doug Goldstein --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 7124ea4f18b5b18d61af395055e261bc7d913bef Mon Sep 17 00:00:00 2001 From: Steve Klabnik Date: Thu, 24 Mar 2016 17:27:15 -0400 Subject: [PATCH 13/35] remove broken config Fixes #32412 --- src/etc/CONFIGS.md | 4 ---- 1 file changed, 4 deletions(-) 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/)) From 8d4b1d1cf38a51b92b91e020ecb22a5d442297be Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Tue, 8 Mar 2016 21:40:13 +0300 Subject: [PATCH 14/35] Introduce name resolution fallback for primitive types --- src/librustc_resolve/lib.rs | 49 +++++++++++++++++++++------- src/test/compile-fail/issue-20427.rs | 1 + 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index af8c9d8168742..8efac52158ece 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -2654,15 +2654,27 @@ 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); + 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 // OK, resolves to associated constant ::MAX, + // // not to non-existent std::u8::MAX + // } + // + // Such behavior is required for backward compatibility. + // The same fallback is used when `a` resolves to nothing. + let unqualified_def = self.resolve_identifier_with_fallback(last_ident, namespace, true); return unqualified_def.and_then(|def| self.adjust_local_def(def, span)) .map(|def| { PathResolution::new(def, path_depth) }); } - let unqualified_def = self.resolve_identifier(last_ident, namespace, false); + let unqualified_def = self.resolve_identifier_with_fallback(last_ident, namespace, false); let def = self.resolve_module_relative_path(span, segments, namespace); match (def, unqualified_def) { (Some(d), Some(ref ud)) if d == ud.def => { @@ -2678,6 +2690,28 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { def.map(mk_res) } + // Resolve a single identifier with fallback to primitive types + fn resolve_identifier_with_fallback(&mut self, + identifier: hir::Ident, + namespace: Namespace, + check_ribs: bool, + record_used: bool) + -> Option { + let def = self.resolve_identifier(identifier, namespace, check_ribs, record_used); + match def { + None | Some(LocalDef{def: Def::Mod(..), ..}) => { + if let Some(&prim_ty) = self.primitive_type_table + .primitive_types + .get(&identifier.unhygienic_name) { + Some(LocalDef::from_def(Def::PrimTy(prim_ty))) + } else { + def + } + } + _ => def + } + } + // Resolve a single identifier fn resolve_identifier(&mut self, identifier: hir::Ident, @@ -2688,15 +2722,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/test/compile-fail/issue-20427.rs b/src/test/compile-fail/issue-20427.rs index 99dd22a888cb5..7dedb9593e13c 100644 --- a/src/test/compile-fail/issue-20427.rs +++ b/src/test/compile-fail/issue-20427.rs @@ -17,6 +17,7 @@ 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 +//~^ ERROR unsupported cyclic reference between types/traits detected 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 From 77f033bac17d2767e9605f3f44d43500662c4ec7 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Wed, 9 Mar 2016 00:08:29 +0300 Subject: [PATCH 15/35] Lift the restriction on reusing names of primitive types --- src/librustc_resolve/diagnostics.rs | 45 ------------------- src/librustc_resolve/lib.rs | 40 +---------------- .../{compile-fail => run-pass}/issue-20427.rs | 36 +++++++++------ 3 files changed, 23 insertions(+), 98 deletions(-) rename src/test/{compile-fail => run-pass}/issue-20427.rs (53%) 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 8efac52158ece..a54338b636078 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1615,15 +1615,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; @@ -1633,8 +1624,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)); } @@ -1655,8 +1644,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, @@ -1691,8 +1678,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) }); @@ -1716,28 +1701,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, @@ -1918,9 +1883,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(_) | @@ -2699,7 +2661,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { -> Option { let def = self.resolve_identifier(identifier, namespace, check_ribs, record_used); match def { - None | Some(LocalDef{def: Def::Mod(..), ..}) => { + None | Some(LocalDef{def: Def::Mod(..), ..}) if namespace == TypeNS => { if let Some(&prim_ty) = self.primitive_type_table .primitive_types .get(&identifier.unhygienic_name) { diff --git a/src/test/compile-fail/issue-20427.rs b/src/test/run-pass/issue-20427.rs similarity index 53% rename from src/test/compile-fail/issue-20427.rs rename to src/test/run-pass/issue-20427.rs index 7dedb9593e13c..43674ccf54352 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. // @@ -15,12 +15,9 @@ 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 -//~^ ERROR unsupported cyclic reference between types/traits detected -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; @@ -41,29 +38,40 @@ 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); + } +} + fn main() { let bool = true; - match bool { + let _ = match bool { str @ true => if str { i32 as i64 } else { i64 }, false => i64, }; + + reuse::check::(); } From b418cd23068b1074e78d8631aec923b865bcc583 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Thu, 10 Mar 2016 22:01:38 +0300 Subject: [PATCH 16/35] Cleanup + Fix a comment and add a test based on it --- src/librustc_resolve/lib.rs | 48 ++++++++++++-------------------- src/test/run-pass/issue-20427.rs | 14 ++++++++++ 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index a54338b636078..231bf666deafc 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -2616,6 +2616,19 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { // Try to find a path to an item in a module. let last_ident = segments.last().unwrap().identifier; + // 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 + } + }; + 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. @@ -2623,20 +2636,17 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { // // use std::u8; // bring module u8 in scope // fn f() -> u8 { // OK, resolves to primitive u8, not to std::u8 - // u8::MAX // OK, resolves to associated constant ::MAX, - // // not to non-existent std::u8::MAX + // 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 = self.resolve_identifier_with_fallback(last_ident, namespace, true); - return unqualified_def.and_then(|def| self.adjust_local_def(def, span)) - .map(|def| { - PathResolution::new(def, path_depth) - }); + 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 = self.resolve_identifier_with_fallback(last_ident, namespace, false); + 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 => { @@ -2652,28 +2662,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> { def.map(mk_res) } - // Resolve a single identifier with fallback to primitive types - fn resolve_identifier_with_fallback(&mut self, - identifier: hir::Ident, - namespace: Namespace, - check_ribs: bool, - record_used: bool) - -> Option { - let def = self.resolve_identifier(identifier, namespace, check_ribs, record_used); - match def { - None | Some(LocalDef{def: Def::Mod(..), ..}) if namespace == TypeNS => { - if let Some(&prim_ty) = self.primitive_type_table - .primitive_types - .get(&identifier.unhygienic_name) { - Some(LocalDef::from_def(Def::PrimTy(prim_ty))) - } else { - def - } - } - _ => def - } - } - // Resolve a single identifier fn resolve_identifier(&mut self, identifier: hir::Ident, diff --git a/src/test/run-pass/issue-20427.rs b/src/test/run-pass/issue-20427.rs index 43674ccf54352..dd3d952224c05 100644 --- a/src/test/run-pass/issue-20427.rs +++ b/src/test/run-pass/issue-20427.rs @@ -9,6 +9,8 @@ // except according to those terms. // aux-build:i8.rs +// ignore-pretty (#23623) + extern crate i8; use std::string as i16; static i32: i32 = 0; @@ -66,6 +68,17 @@ mod reuse { } } +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; let _ = match bool { @@ -74,4 +87,5 @@ fn main() { }; reuse::check::(); + guard::check(); } From 78495d5082f51a2737619824548c9f2407b12a2b Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Fri, 25 Mar 2016 05:46:45 +0100 Subject: [PATCH 17/35] Fix unsound behaviour with null characters in thread names (issue #32475) Previously, the thread name (&str) was converted to a CString in the new thread, but outside unwind::try, causing a panic to continue into FFI. This patch changes that behaviour, so that the panic instead happens in the parent thread (where panic infrastructure is properly set up), not the new thread. This could potentially be a breaking change for architectures who don't support thread names. Signed-off-by: David Henningsson --- src/libstd/sys/unix/thread.rs | 27 +++++++++++---------------- src/libstd/sys/windows/thread.rs | 2 +- src/libstd/thread/mod.rs | 21 ++++++++++++++++++--- 3 files changed, 30 insertions(+), 20 deletions(-) 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(); From 5bc286806023ef4d63bceec4ba703399ba9ee2f7 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 3 Feb 2016 16:38:48 -0500 Subject: [PATCH 18/35] make `const_expr_to_pat` fallible (but never have it actually fail) --- src/librustc/middle/check_match.rs | 26 +++++++++++++------ src/librustc/middle/const_eval.rs | 40 ++++++++++++++++++----------- src/librustc_mir/hair/cx/pattern.rs | 12 ++++++--- 3 files changed, 52 insertions(+), 26 deletions(-) diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index b5e1d5899967f..77b0995827808 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -478,15 +478,25 @@ 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.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) => { + // TODO back-compat + 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..af1e9d60be441 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -323,10 +323,13 @@ 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, span: Span) + -> Result, DefId> { 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, span)) + .collect())), hir::ExprCall(ref callee, ref args) => { let def = *tcx.def_map.borrow().get(&callee.id).unwrap(); @@ -336,31 +339,38 @@ 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, 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, 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, span)) + .collect()); PatKind::Vec(pats, None, hir::HirVec::new()) } @@ -381,7 +391,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_mir/hair/cx/pattern.rs b/src/librustc_mir/hair/cx/pattern.rs index a987377837417..bfb8d1c401aaa 100644 --- a/src/librustc_mir/hair/cx/pattern.rs +++ b/src/librustc_mir/hair/cx/pattern.rs @@ -90,9 +90,15 @@ 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.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( From 99c2a6b335d953eca64e631f3e9946b1cc6643e1 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 11 Mar 2016 13:27:42 -0500 Subject: [PATCH 19/35] modify #[deriving(Eq)] to emit #[structural_match] to careful use of the span from deriving, we can permit it in stable code if it derives from deriving (not-even-a-pun intended) --- src/libsyntax/feature_gate.rs | 9 +++++- src/libsyntax_ext/deriving/mod.rs | 48 +++++++++++++++++++++++++++++-- src/libsyntax_ext/lib.rs | 1 + 3 files changed, 55 insertions(+), 3 deletions(-) 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_ext/deriving/mod.rs b/src/libsyntax_ext/deriving/mod.rs index 75de5c56ea139..dbd3cbd4fbaa3 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`"); @@ -107,6 +110,45 @@ fn expand_derive(cx: &mut ExtCtxt, continue; } + // RFC #1445. `#[derive(Eq)]` adds a (trusted) + // `#[structural_match]` attribute. + if &tname[..] == "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(Eq)]` attribute + // (the entire attribute, not just the `Eq` part), + // but with the current backtrace. The current + // backtrace will contain a topmost entry that IS + // this `#[deriving(Eq)]` 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))); + } + // #[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))))); @@ -117,7 +159,9 @@ fn expand_derive(cx: &mut ExtCtxt, }, |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; From 05baf645e47a0ed3893f2413696e56be180249ff Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 11 Mar 2016 13:29:06 -0500 Subject: [PATCH 20/35] do not overwrite spans as eagerly this was required to preserve the span from the #[structural_match] attribute -- but honestly I am not 100% sure if it makes sense. --- src/libsyntax/codemap.rs | 25 ++++++++++++++++++++++ src/libsyntax/ext/expand.rs | 42 +++++++++++++++++++++++++++++++------ 2 files changed, 61 insertions(+), 6 deletions(-) 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 } } From f69eb8efbe5dbc373426bf0ff021b49f37db41cb Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 11 Mar 2016 13:30:32 -0500 Subject: [PATCH 21/35] issue a future-compat lint for constants of invalid type This is a [breaking-change]: according to RFC #1445, constants used as patterns must be of a type that *derives* `Eq`. If you encounter a problem, you are most likely using a constant in an expression where the type of the constant is some struct that does not currently implement `Eq`. Something like the following: ```rust struct SomeType { ... } const SOME_CONST: SomeType = ...; match foo { SOME_CONST => ... } ``` The easiest and most future compatible fix is to annotate the type in question with `#[derive(Eq)]` (note that merely *implementing* `Eq` is not enough, it must be *derived*): ```rust struct SomeType { ... } const SOME_CONST: SomeType = ...; match foo { SOME_CONST => ... } ``` Another good option is to rewrite the match arm to use an `if` condition (this is also particularly good for floating point types, which implement `PartialEq` but not `Eq`): ```rust match foo { c if c == SOME_CONST => ... } ``` Finally, a third alternative is to tag the type with `#[structural_match]`; but this is not recommended, as the attribute is never expected to be stabilized. Please see RFC #1445 for more details. --- src/librustc/lint/builtin.rs | 15 ++++++++++ src/librustc/middle/check_match.rs | 3 +- src/librustc/middle/const_eval.rs | 46 ++++++++++++++++++++++++----- src/librustc_lint/lib.rs | 8 +++++ src/librustc_mir/hair/cx/pattern.rs | 1 + 5 files changed, 64 insertions(+), 9 deletions(-) diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index f2371c1819fc4..5d257fc7b2f22 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(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/middle/check_match.rs b/src/librustc/middle/check_match.rs index 77b0995827808..3414d509d953f 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -478,7 +478,7 @@ 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) { - match const_expr_to_pat(self.tcx, const_expr, pat.span) { + 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 @@ -487,7 +487,6 @@ impl<'a, 'tcx> Folder for StaticInliner<'a, 'tcx> { new_pat } Err(def_id) => { - // TODO back-compat self.failed = true; self.tcx.sess.span_err( pat.span, diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index af1e9d60be441..dfeb5a5e3f1ab 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -16,6 +16,7 @@ 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 middle::def::Def; @@ -323,13 +324,41 @@ impl ConstVal { } } -pub fn const_expr_to_pat(tcx: &ty::TyCtxt, expr: &Expr, span: Span) +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(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(try!(exprs.iter() - .map(|expr| const_expr_to_pat(tcx, &expr, span)) - .collect())), + .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(); @@ -347,7 +376,8 @@ pub fn const_expr_to_pat(tcx: &ty::TyCtxt, expr: &Expr, span: Span) _ => unreachable!() }; let pats = try!(args.iter() - .map(|expr| const_expr_to_pat(tcx, &**expr, span)) + .map(|expr| const_expr_to_pat(tcx, &**expr, + pat_id, span)) .collect()); PatKind::TupleStruct(path, Some(pats)) } @@ -359,7 +389,8 @@ pub fn const_expr_to_pat(tcx: &ty::TyCtxt, expr: &Expr, span: Span) span: codemap::DUMMY_SP, node: hir::FieldPat { name: field.name.node, - pat: try!(const_expr_to_pat(tcx, &field.expr, span)), + pat: try!(const_expr_to_pat(tcx, &field.expr, + pat_id, span)), is_shorthand: false, }, })) @@ -369,7 +400,8 @@ pub fn const_expr_to_pat(tcx: &ty::TyCtxt, expr: &Expr, span: Span) hir::ExprVec(ref exprs) => { let pats = try!(exprs.iter() - .map(|expr| const_expr_to_pat(tcx, &expr, span)) + .map(|expr| const_expr_to_pat(tcx, &expr, + pat_id, span)) .collect()); PatKind::Vec(pats, None, hir::HirVec::new()) } @@ -383,7 +415,7 @@ pub fn const_expr_to_pat(tcx: &ty::TyCtxt, expr: &Expr, span: Span) 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!(), } 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_mir/hair/cx/pattern.rs b/src/librustc_mir/hair/cx/pattern.rs index bfb8d1c401aaa..a582a4622a6d0 100644 --- a/src/librustc_mir/hair/cx/pattern.rs +++ b/src/librustc_mir/hair/cx/pattern.rs @@ -92,6 +92,7 @@ impl<'patcx, 'cx, 'tcx> PatCx<'patcx, 'cx, 'tcx> { Some((const_expr, _const_ty)) => { match const_eval::const_expr_to_pat(self.cx.tcx, const_expr, + pat.id, pat.span) { Ok(pat) => return self.to_pattern(&pat), From 73b4f06b83fd7a7ab4bcc9bf2ac97844f3b27df5 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 11 Mar 2016 15:36:24 -0500 Subject: [PATCH 22/35] suppress duplicate lints --- src/librustc/session/mod.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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))); From 56ebf2b046fd4f0b9d05a90ff1e8a38b62be0325 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 11 Mar 2016 13:36:46 -0500 Subject: [PATCH 23/35] fallout in existing tests --- src/libstd/num/f32.rs | 7 ++++--- src/libstd/num/f64.rs | 7 ++++--- src/test/compile-fail/issue-6804.rs | 8 ++++++++ src/test/debuginfo/constant-in-match-pattern.rs | 3 +++ src/test/run-pass/associated-const-match-patterns.rs | 1 + src/test/run-pass/empty-struct-braces.rs | 3 +++ src/test/run-pass/issue-12860.rs | 2 -- src/test/run-pass/match-arm-statics.rs | 11 ++++++++++- 8 files changed, 33 insertions(+), 9 deletions(-) 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/test/compile-fail/issue-6804.rs b/src/test/compile-fail/issue-6804.rs index ffab194149e12..1cb5dbccf2105 100644 --- a/src/test/compile-fail/issue-6804.rs +++ b/src/test/compile-fail/issue-6804.rs @@ -24,9 +24,17 @@ 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 + //~| 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 + //~| WARNING floating point constants cannot be used + //~| WARNING this was previously accepted } 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/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/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 } From 7f661ec417616ea7036f0cc4aefc7034592a3647 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 11 Mar 2016 13:36:55 -0500 Subject: [PATCH 24/35] new tests for RFC #1445 --- src/test/compile-fail/issue-6804.rs | 4 -- src/test/compile-fail/rfc1445/feature-gate.rs | 36 +++++++++++++++++ .../rfc1445/match-forbidden-without-eq.rs | 39 +++++++++++++++++++ .../rfc1445/eq-allows-match-on-ty-in-macro.rs | 32 +++++++++++++++ src/test/run-pass/rfc1445/eq-allows-match.rs | 26 +++++++++++++ 5 files changed, 133 insertions(+), 4 deletions(-) create mode 100644 src/test/compile-fail/rfc1445/feature-gate.rs create mode 100644 src/test/compile-fail/rfc1445/match-forbidden-without-eq.rs create mode 100644 src/test/run-pass/rfc1445/eq-allows-match-on-ty-in-macro.rs create mode 100644 src/test/run-pass/rfc1445/eq-allows-match.rs diff --git a/src/test/compile-fail/issue-6804.rs b/src/test/compile-fail/issue-6804.rs index 1cb5dbccf2105..f6b7e13c4f5e9 100644 --- a/src/test/compile-fail/issue-6804.rs +++ b/src/test/compile-fail/issue-6804.rs @@ -26,8 +26,6 @@ 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 - //~| WARNING floating point constants cannot be used - //~| WARNING this was previously accepted match [x, 1.0] { [NAN, _] => {}, _ => {}, @@ -35,6 +33,4 @@ 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 - //~| WARNING floating point constants cannot be used - //~| WARNING this was previously accepted } 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..b3e465688fdd4 --- /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(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/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 => { } + _ => { } + } +} From 93e44432e1055a529c4923709a6533114bb7820f Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 25 Mar 2016 10:02:56 -0400 Subject: [PATCH 25/35] check for both partialeq and eq --- src/librustc/lint/builtin.rs | 2 +- src/librustc/middle/const_eval.rs | 2 +- src/libsyntax_ext/deriving/mod.rs | 81 ++++++++++--------- .../match-requires-both-partialeq-and-eq.rs | 35 ++++++++ 4 files changed, 82 insertions(+), 38 deletions(-) create mode 100644 src/test/compile-fail/rfc1445/match-requires-both-partialeq-and-eq.rs diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 5d257fc7b2f22..879b894562092 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -146,7 +146,7 @@ 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(Eq)]`" + the struct or enum has `#[derive(PartialEq, Eq)]`" } declare_lint! { diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index dfeb5a5e3f1ab..c102822e8c126 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -345,7 +345,7 @@ pub fn const_expr_to_pat(tcx: &ty::TyCtxt, expr: &Expr, pat_id: ast::NodeId, spa span, format!("to use a constant of type `{}` \ in a pattern, \ - `{}` must be annotated with `#[derive(Eq)]`", + `{}` must be annotated with `#[derive(PartialEq, Eq)]`", tcx.item_path_str(adt_def.did), tcx.item_path_str(adt_def.did))); } diff --git a/src/libsyntax_ext/deriving/mod.rs b/src/libsyntax_ext/deriving/mod.rs index dbd3cbd4fbaa3..1774167e83000 100644 --- a/src/libsyntax_ext/deriving/mod.rs +++ b/src/libsyntax_ext/deriving/mod.rs @@ -92,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, @@ -110,43 +113,10 @@ fn expand_derive(cx: &mut ExtCtxt, continue; } - // RFC #1445. `#[derive(Eq)]` adds a (trusted) - // `#[structural_match]` attribute. if &tname[..] == "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(Eq)]` attribute - // (the entire attribute, not just the `Eq` part), - // but with the current backtrace. The current - // backtrace will contain a topmost entry that IS - // this `#[deriving(Eq)]` 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))); + found_eq = true; + } else if &tname[..] == "PartialEq" { + found_partial_eq = true; } // #[derive(Foo, Bar)] expands to #[derive_Foo] #[derive_Bar] @@ -154,6 +124,45 @@ fn expand_derive(cx: &mut ExtCtxt, 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| { 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 + _ => { } + } +} From 6ce63fb3f1bf37004868f79beacb180283c0750e Mon Sep 17 00:00:00 2001 From: Alejandro Wainzinger Date: Fri, 25 Mar 2016 23:25:40 +0900 Subject: [PATCH 26/35] Add note on `str` being an unsized type in strings section of book. --- src/doc/book/strings.md | 6 ++++++ 1 file changed, 6 insertions(+) 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 From b9a231127839ebc01bdfe1ce402553b821e4c004 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Tue, 22 Mar 2016 16:21:46 +0200 Subject: [PATCH 27/35] rustc: move middle::subst into middle::ty. --- src/librustc/lib.rs | 1 - src/librustc/middle/const_eval.rs | 4 ++-- src/librustc/middle/cstore.rs | 2 +- src/librustc/middle/def.rs | 2 +- src/librustc/middle/infer/error_reporting.rs | 2 +- src/librustc/middle/infer/mod.rs | 6 +++--- src/librustc/middle/intrinsicck.rs | 2 +- src/librustc/middle/liveness.rs | 2 +- src/librustc/middle/resolve_lifetime.rs | 2 +- src/librustc/middle/traits/coherence.rs | 2 +- src/librustc/middle/traits/mod.rs | 2 +- src/librustc/middle/traits/object_safety.rs | 2 +- src/librustc/middle/traits/project.rs | 2 +- src/librustc/middle/traits/select.rs | 2 +- src/librustc/middle/traits/specialize/mod.rs | 2 +- src/librustc/middle/traits/util.rs | 2 +- src/librustc/middle/ty/context.rs | 2 +- src/librustc/middle/ty/error.rs | 2 +- src/librustc/middle/ty/flags.rs | 2 +- src/librustc/middle/ty/fold.rs | 2 +- src/librustc/middle/ty/mod.rs | 3 ++- src/librustc/middle/ty/relate.rs | 2 +- src/librustc/middle/ty/structural_impls.rs | 2 +- src/librustc/middle/ty/sty.rs | 2 +- src/librustc/middle/{ => ty}/subst.rs | 0 src/librustc/middle/ty/util.rs | 2 +- src/librustc/middle/ty/wf.rs | 2 +- src/librustc/mir/repr.rs | 2 +- src/librustc/mir/tcx.rs | 2 +- src/librustc/util/ppaux.rs | 2 +- src/librustc_driver/test.rs | 4 ++-- src/librustc_lint/builtin.rs | 2 +- src/librustc_lint/types.rs | 2 +- src/librustc_metadata/astencode.rs | 2 +- src/librustc_metadata/decoder.rs | 2 +- src/librustc_metadata/encoder.rs | 2 +- src/librustc_metadata/tls_context.rs | 2 +- src/librustc_metadata/tydecode.rs | 4 ++-- src/librustc_metadata/tyencode.rs | 4 ++-- src/librustc_mir/build/scope.rs | 2 +- src/librustc_mir/hair/cx/mod.rs | 2 +- src/librustc_mir/hair/mod.rs | 2 +- src/librustc_resolve/lib.rs | 2 +- src/librustc_trans/trans/_match.rs | 2 +- src/librustc_trans/trans/adt.rs | 2 +- src/librustc_trans/trans/base.rs | 2 +- src/librustc_trans/trans/callee.rs | 4 ++-- src/librustc_trans/trans/collector.rs | 2 +- src/librustc_trans/trans/common.rs | 2 +- src/librustc_trans/trans/consts.rs | 2 +- src/librustc_trans/trans/context.rs | 2 +- src/librustc_trans/trans/controlflow.rs | 2 +- src/librustc_trans/trans/debuginfo/metadata.rs | 2 +- src/librustc_trans/trans/debuginfo/mod.rs | 2 +- src/librustc_trans/trans/debuginfo/type_names.rs | 2 +- src/librustc_trans/trans/expr.rs | 2 +- src/librustc_trans/trans/glue.rs | 2 +- src/librustc_trans/trans/inline.rs | 2 +- src/librustc_trans/trans/intrinsic.rs | 6 +++--- src/librustc_trans/trans/meth.rs | 4 ++-- src/librustc_trans/trans/monomorphize.rs | 4 ++-- src/librustc_trans/trans/type_of.rs | 2 +- src/librustc_typeck/astconv.rs | 2 +- src/librustc_typeck/check/_match.rs | 2 +- src/librustc_typeck/check/closure.rs | 2 +- src/librustc_typeck/check/compare_method.rs | 2 +- src/librustc_typeck/check/dropck.rs | 2 +- src/librustc_typeck/check/intrinsic.rs | 2 +- src/librustc_typeck/check/method/confirm.rs | 2 +- src/librustc_typeck/check/method/mod.rs | 2 +- src/librustc_typeck/check/method/probe.rs | 4 ++-- src/librustc_typeck/check/method/suggest.rs | 2 +- src/librustc_typeck/check/mod.rs | 2 +- src/librustc_typeck/check/regionck.rs | 2 +- src/librustc_typeck/check/wfcheck.rs | 2 +- src/librustc_typeck/coherence/mod.rs | 2 +- src/librustc_typeck/collect.rs | 2 +- src/librustc_typeck/constrained_type_params.rs | 2 +- src/librustc_typeck/lib.rs | 2 +- src/librustc_typeck/variance/constraints.rs | 4 ++-- src/librustc_typeck/variance/solve.rs | 2 +- src/librustc_typeck/variance/terms.rs | 2 +- src/librustdoc/clean/inline.rs | 2 +- src/librustdoc/clean/mod.rs | 2 +- src/librustdoc/clean/simplify.rs | 2 +- 85 files changed, 97 insertions(+), 97 deletions(-) rename src/librustc/middle/{ => ty}/subst.rs (100%) diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index d8d0079b3e398..37b6ea7872aad 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -113,7 +113,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; diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index a8c2a73e72f51..5cb5595e9e8ed 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -17,11 +17,11 @@ use self::EvalHint::*; use front::map as ast_map; use front::map::blocks::FnLikeNode; use middle::cstore::{self, CrateStore, InlinedItem}; -use middle::{infer, subst, traits}; +use middle::{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::{self, subst, Ty, TyCtxt}; use middle::ty::util::IntTypeExt; use middle::traits::ProjectionMode; use middle::astconv_util::ast_ty_to_prim_ty; diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index f85d87413843e..9a3550b65aa2d 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -455,7 +455,7 @@ pub mod tls { use std::cell::Cell; use std::mem; use middle::ty::{self, Ty, TyCtxt}; - use middle::subst::Substs; + use middle::ty::subst::Substs; use middle::def_id::DefId; pub trait EncodingContext<'tcx> { diff --git a/src/librustc/middle/def.rs b/src/librustc/middle/def.rs index 6d4799749b93a..f832a871c8b1b 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 middle::ty::subst::ParamSpace; use util::nodemap::NodeMap; use syntax::ast; use rustc_front::hir; diff --git a/src/librustc/middle/infer/error_reporting.rs b/src/librustc/middle/infer/error_reporting.rs index 089eae89d0492..7a1da77453147 100644 --- a/src/librustc/middle/infer/error_reporting.rs +++ b/src/librustc/middle/infer/error_reporting.rs @@ -82,7 +82,7 @@ use middle::def::Def; use middle::def_id::DefId; use middle::infer::{self, TypeOrigin}; use middle::region; -use middle::subst; +use middle::ty::subst; use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use middle::ty::{Region, ReFree}; use middle::ty::error::TypeError; diff --git a/src/librustc/middle/infer/mod.rs b/src/librustc/middle/infer/mod.rs index 645e5323ef4ae..ea11ade1d16dd 100644 --- a/src/librustc/middle/infer/mod.rs +++ b/src/librustc/middle/infer/mod.rs @@ -24,9 +24,9 @@ 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::ty::subst; +use middle::ty::subst::Substs; +use middle::ty::subst::Subst; use middle::traits::{self, ProjectionMode}; use middle::ty::adjustment; use middle::ty::{TyVid, IntVid, FloatVid}; diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index 233e55cdbb5dd..e3da34acb4b43 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -11,7 +11,7 @@ use dep_graph::DepNode; use middle::def::Def; use middle::def_id::DefId; -use middle::subst::{Subst, Substs, EnumeratedItems}; +use middle::ty::subst::{Subst, Substs, EnumeratedItems}; use middle::ty::{TransmuteRestriction, TyCtxt}; use middle::ty::{self, Ty, TypeFoldable}; diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 9507c379b4fe1..ee39a4fc7df6e 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -115,7 +115,7 @@ use middle::pat_util; use middle::ty::{self, TyCtxt, ParameterEnvironment}; use middle::traits::{self, ProjectionMode}; use middle::infer; -use middle::subst::Subst; +use middle::ty::subst::Subst; use lint; use util::nodemap::NodeMap; diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index a80b130e5be5f..8d3a80854b467 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -23,7 +23,7 @@ use front::map::Map; use session::Session; use middle::def::{Def, DefMap}; use middle::region; -use middle::subst; +use middle::ty::subst; use middle::ty; use std::fmt; use std::mem::replace; diff --git a/src/librustc/middle/traits/coherence.rs b/src/librustc/middle/traits/coherence.rs index 64d1c992cbf1d..547cb71f234f0 100644 --- a/src/librustc/middle/traits/coherence.rs +++ b/src/librustc/middle/traits/coherence.rs @@ -14,7 +14,7 @@ use super::{SelectionContext, Obligation, ObligationCause}; use middle::cstore::LOCAL_CRATE; use middle::def_id::DefId; -use middle::subst::TypeSpace; +use middle::ty::subst::TypeSpace; use middle::ty::{self, Ty, TyCtxt}; use middle::infer::{self, InferCtxt, TypeOrigin}; use syntax::codemap::DUMMY_SP; diff --git a/src/librustc/middle/traits/mod.rs b/src/librustc/middle/traits/mod.rs index 5f66e9e6344ad..9404731859961 100644 --- a/src/librustc/middle/traits/mod.rs +++ b/src/librustc/middle/traits/mod.rs @@ -17,7 +17,7 @@ pub use self::ObligationCauseCode::*; use middle::def_id::DefId; use middle::free_region::FreeRegionMap; -use middle::subst; +use middle::ty::subst; use middle::ty::{self, Ty, TypeFoldable}; use middle::infer::{self, fixup_err_to_string, InferCtxt}; diff --git a/src/librustc/middle/traits/object_safety.rs b/src/librustc/middle/traits/object_safety.rs index 4a0da521eef30..8777b9eb00cfd 100644 --- a/src/librustc/middle/traits/object_safety.rs +++ b/src/librustc/middle/traits/object_safety.rs @@ -21,7 +21,7 @@ use super::supertraits; use super::elaborate_predicates; use middle::def_id::DefId; -use middle::subst::{self, SelfSpace, TypeSpace}; +use middle::ty::subst::{self, SelfSpace, TypeSpace}; use middle::traits; use middle::ty::{self, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable}; use std::rc::Rc; diff --git a/src/librustc/middle/traits/project.rs b/src/librustc/middle/traits/project.rs index e86f3ed01a49d..bd075a5dc88db 100644 --- a/src/librustc/middle/traits/project.rs +++ b/src/librustc/middle/traits/project.rs @@ -25,7 +25,7 @@ use super::util; use middle::def_id::DefId; use middle::infer::{self, TypeOrigin}; -use middle::subst::Subst; +use middle::ty::subst::Subst; use middle::ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt}; use middle::ty::fold::{TypeFoldable, TypeFolder}; use syntax::parse::token; diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index 3eaf123e5be58..050468809a5ac 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -39,7 +39,7 @@ 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::subst::{Subst, Substs, TypeSpace}; use middle::ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable}; use middle::traits; use middle::ty::fast_reject; diff --git a/src/librustc/middle/traits/specialize/mod.rs b/src/librustc/middle/traits/specialize/mod.rs index 92478f2874e1e..088099d87b158 100644 --- a/src/librustc/middle/traits/specialize/mod.rs +++ b/src/librustc/middle/traits/specialize/mod.rs @@ -24,7 +24,7 @@ use middle::cstore::CrateStore; use middle::def_id::DefId; use middle::infer::{self, InferCtxt, TypeOrigin}; use middle::region; -use middle::subst::{Subst, Substs}; +use middle::ty::subst::{Subst, Substs}; use middle::traits::{self, ProjectionMode, ObligationCause, Normalized}; use middle::ty::{self, TyCtxt}; use syntax::codemap::DUMMY_SP; diff --git a/src/librustc/middle/traits/util.rs b/src/librustc/middle/traits/util.rs index 9f984bc1fc63a..f9a1b09a93d2c 100644 --- a/src/librustc/middle/traits/util.rs +++ b/src/librustc/middle/traits/util.rs @@ -10,7 +10,7 @@ use middle::def_id::DefId; use middle::infer::InferCtxt; -use middle::subst::{Subst, Substs}; +use middle::ty::subst::{Subst, Substs}; use middle::ty::{self, Ty, TyCtxt, ToPredicate, ToPolyTraitRef}; use syntax::codemap::Span; use util::common::ErrorReported; diff --git a/src/librustc/middle/ty/context.rs b/src/librustc/middle/ty/context.rs index 03c13115aea62..aa0ac62ac5719 100644 --- a/src/librustc/middle/ty/context.rs +++ b/src/librustc/middle/ty/context.rs @@ -22,7 +22,7 @@ use middle::free_region::FreeRegionMap; use middle::region::RegionMaps; use middle::resolve_lifetime; use middle::stability; -use middle::subst::{self, Subst, Substs}; +use middle::ty::subst::{self, Subst, Substs}; use middle::traits; use middle::ty::{self, TraitRef, Ty, TypeAndMut}; use middle::ty::{TyS, TypeVariants}; diff --git a/src/librustc/middle/ty/error.rs b/src/librustc/middle/ty/error.rs index 1033af5f331a7..8e1ace57e42ad 100644 --- a/src/librustc/middle/ty/error.rs +++ b/src/librustc/middle/ty/error.rs @@ -9,7 +9,7 @@ // except according to those terms. use middle::def_id::DefId; -use middle::subst; +use middle::ty::subst; use middle::infer::type_variable; use middle::ty::{self, BoundRegion, Region, Ty, TyCtxt}; diff --git a/src/librustc/middle/ty/flags.rs b/src/librustc/middle/ty/flags.rs index c874e9b7ca52d..12b2426150797 100644 --- a/src/librustc/middle/ty/flags.rs +++ b/src/librustc/middle/ty/flags.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::subst; +use middle::ty::subst; use middle::ty::{self, Ty, TypeFlags, TypeFoldable}; pub struct FlagComputation { diff --git a/src/librustc/middle/ty/fold.rs b/src/librustc/middle/ty/fold.rs index f754e5c5a0a7d..2e8782a72f691 100644 --- a/src/librustc/middle/ty/fold.rs +++ b/src/librustc/middle/ty/fold.rs @@ -40,7 +40,7 @@ //! and does not need to visit anything else. use middle::region; -use middle::subst; +use middle::ty::subst; use middle::ty::adjustment; use middle::ty::{self, Binder, Ty, TyCtxt, TypeFlags}; diff --git a/src/librustc/middle/ty/mod.rs b/src/librustc/middle/ty/mod.rs index 050024d0e94ea..c5f10c332fc0a 100644 --- a/src/librustc/middle/ty/mod.rs +++ b/src/librustc/middle/ty/mod.rs @@ -27,10 +27,10 @@ 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::subst::{Subst, Substs, VecPerParamSpace}; use middle::ty::walk::TypeWalker; use util::common::MemoizationMap; use util::nodemap::{NodeMap, NodeSet}; @@ -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/relate.rs b/src/librustc/middle/ty/relate.rs index 563ff346a6440..d648c2c588476 100644 --- a/src/librustc/middle/ty/relate.rs +++ b/src/librustc/middle/ty/relate.rs @@ -14,7 +14,7 @@ //! type equality, etc. use middle::def_id::DefId; -use middle::subst::{ParamSpace, Substs}; +use middle::ty::subst::{ParamSpace, Substs}; use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use middle::ty::error::{ExpectedFound, TypeError}; use std::rc::Rc; diff --git a/src/librustc/middle/ty/structural_impls.rs b/src/librustc/middle/ty/structural_impls.rs index 0358fa2f12455..23ec75b18e82c 100644 --- a/src/librustc/middle/ty/structural_impls.rs +++ b/src/librustc/middle/ty/structural_impls.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::subst::{self, VecPerParamSpace}; +use middle::ty::subst::{self, VecPerParamSpace}; use middle::traits; use middle::ty::{self, Lift, TraitRef, Ty, TyCtxt}; use middle::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; diff --git a/src/librustc/middle/ty/sty.rs b/src/librustc/middle/ty/sty.rs index 7a17b24df5e9d..d8f0dd2903196 100644 --- a/src/librustc/middle/ty/sty.rs +++ b/src/librustc/middle/ty/sty.rs @@ -13,7 +13,7 @@ use middle::cstore; use middle::def_id::DefId; use middle::region; -use middle::subst::{self, Substs}; +use middle::ty::subst::{self, Substs}; use middle::traits; use middle::ty::{self, AdtDef, ToPredicate, TypeFlags, Ty, TyCtxt, TyS, TypeFoldable}; use util::common::ErrorReported; diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/ty/subst.rs similarity index 100% rename from src/librustc/middle/subst.rs rename to src/librustc/middle/ty/subst.rs diff --git a/src/librustc/middle/ty/util.rs b/src/librustc/middle/ty/util.rs index 6a91592dbd52a..f6c4390b83c96 100644 --- a/src/librustc/middle/ty/util.rs +++ b/src/librustc/middle/ty/util.rs @@ -14,7 +14,7 @@ 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::ty::subst; use middle::infer; use middle::pat_util; use middle::traits::{self, ProjectionMode}; diff --git a/src/librustc/middle/ty/wf.rs b/src/librustc/middle/ty/wf.rs index 5f81d27a1f688..1becdb14fa534 100644 --- a/src/librustc/middle/ty/wf.rs +++ b/src/librustc/middle/ty/wf.rs @@ -11,7 +11,7 @@ use middle::def_id::DefId; use middle::infer::InferCtxt; use middle::ty::outlives::{self, Component}; -use middle::subst::Substs; +use middle::ty::subst::Substs; use middle::traits; use middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable}; use std::iter::once; diff --git a/src/librustc/mir/repr.rs b/src/librustc/mir/repr.rs index 47d923cbce359..20cf6d929ca7c 100644 --- a/src/librustc/mir/repr.rs +++ b/src/librustc/mir/repr.rs @@ -12,7 +12,7 @@ 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::subst::Substs; use middle::ty::{self, AdtDef, ClosureSubsts, FnOutput, Region, Ty}; use util::ppaux; use rustc_back::slice; diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index c8a2bc440ce1d..0c9e00a6c5ec4 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -14,7 +14,7 @@ */ use mir::repr::*; -use middle::subst::{Subst, Substs}; +use middle::ty::subst::{Subst, Substs}; use middle::ty::{self, AdtDef, Ty, TyCtxt}; use middle::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; use rustc_front::hir; diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 6e7f49516e8fa..f67346fe1f940 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -10,7 +10,7 @@ use middle::def_id::DefId; -use middle::subst::{self, Subst}; +use middle::ty::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}; diff --git a/src/librustc_driver/test.rs b/src/librustc_driver/test.rs index 1a5e7cb54f2e3..abbea81897173 100644 --- a/src/librustc_driver/test.rs +++ b/src/librustc_driver/test.rs @@ -20,8 +20,8 @@ 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::ty::subst; +use rustc_typeck::middle::ty::subst::Subst; use rustc_typeck::middle::traits::ProjectionMode; use rustc_typeck::middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc_typeck::middle::ty::relate::TypeRelation; diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs index 2ccb905b6ecdf..66e19cf29bf9e 100644 --- a/src/librustc_lint/builtin.rs +++ b/src/librustc_lint/builtin.rs @@ -32,7 +32,7 @@ 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::subst::Substs; use middle::ty::{self, Ty, TyCtxt}; use middle::ty::adjustment; use middle::traits::ProjectionMode; diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 1a84afab86bfc..3dfd265c5a020 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -12,7 +12,7 @@ use middle::{infer}; use middle::def_id::DefId; -use middle::subst::Substs; +use middle::ty::subst::Substs; use middle::ty::{self, Ty, TyCtxt}; use middle::const_eval::{eval_const_expr_partial, ConstVal}; use middle::const_eval::EvalHint::ExprTypeChecked; diff --git a/src/librustc_metadata/astencode.rs b/src/librustc_metadata/astencode.rs index 5c5574c3a8300..1cf6c9b53e2c5 100644 --- a/src/librustc_metadata/astencode.rs +++ b/src/librustc_metadata/astencode.rs @@ -33,7 +33,7 @@ use middle::const_qualif::ConstQualif; use middle::def::{self, Def}; use middle::def_id::DefId; use middle::region; -use middle::subst; +use middle::ty::subst; use middle::ty::{self, Ty, TyCtxt}; use syntax::{ast, ast_util, codemap}; diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 0c736feeefeee..f88552707437b 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -32,7 +32,7 @@ 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::subst; use middle::ty::{ImplContainer, TraitContainer}; use middle::ty::{self, Ty, TyCtxt, TypeFoldable, VariantKind}; diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index e677ea962f9cf..dc338048a83af 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -25,7 +25,7 @@ use middle::def; use middle::def_id::{CRATE_DEF_INDEX, DefId}; use middle::dependency_format::Linkage; use middle::stability; -use middle::subst; +use middle::ty::subst; use middle::traits::specialization_graph; use middle::ty::{self, Ty, TyCtxt}; use middle::ty::util::IntTypeExt; diff --git a/src/librustc_metadata/tls_context.rs b/src/librustc_metadata/tls_context.rs index f90abd9e1d961..2ba3e351c50aa 100644 --- a/src/librustc_metadata/tls_context.rs +++ b/src/librustc_metadata/tls_context.rs @@ -15,7 +15,7 @@ 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::subst::Substs; use rustc::middle::ty::{self, TyCtxt}; use decoder::{self, Cmd}; diff --git a/src/librustc_metadata/tydecode.rs b/src/librustc_metadata/tydecode.rs index cd9c2e828bdef..8c88a63a161f4 100644 --- a/src/librustc_metadata/tydecode.rs +++ b/src/librustc_metadata/tydecode.rs @@ -20,8 +20,8 @@ use rustc_front::hir; use middle::def_id::{DefId, DefIndex}; use middle::region; -use middle::subst; -use middle::subst::VecPerParamSpace; +use middle::ty::subst; +use middle::ty::subst::VecPerParamSpace; use middle::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable}; use rbml; diff --git a/src/librustc_metadata/tyencode.rs b/src/librustc_metadata/tyencode.rs index 4718732c8a037..5086977ea0637 100644 --- a/src/librustc_metadata/tyencode.rs +++ b/src/librustc_metadata/tyencode.rs @@ -19,8 +19,8 @@ use std::io::prelude::*; use middle::def_id::DefId; use middle::region; -use middle::subst; -use middle::subst::VecPerParamSpace; +use middle::ty::subst; +use middle::ty::subst::VecPerParamSpace; use middle::ty::ParamTy; use middle::ty::{self, Ty, TyCtxt}; use rustc::util::nodemap::FnvHashMap; diff --git a/src/librustc_mir/build/scope.rs b/src/librustc_mir/build/scope.rs index f5f6f409eaba4..033e1361d4a8c 100644 --- a/src/librustc_mir/build/scope.rs +++ b/src/librustc_mir/build/scope.rs @@ -89,7 +89,7 @@ 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::subst::{Substs, Subst, VecPerParamSpace}; use rustc::middle::ty::{self, Ty, TyCtxt}; use rustc::mir::repr::*; use syntax::codemap::{Span, DUMMY_SP}; diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index b97bfaf5aef68..d603979906dda 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -21,7 +21,7 @@ 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::subst::{Subst, Substs}; use rustc::middle::ty::{self, Ty, TyCtxt}; use syntax::codemap::Span; use syntax::parse::token; diff --git a/src/librustc_mir/hair/mod.rs b/src/librustc_mir/hair/mod.rs index 78c438df6f87a..3eca7f0a8772c 100644 --- a/src/librustc_mir/hair/mod.rs +++ b/src/librustc_mir/hair/mod.rs @@ -19,7 +19,7 @@ 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::subst::Substs; use rustc::middle::ty::{self, AdtDef, ClosureSubsts, Region, Ty}; use rustc_front::hir; use syntax::ast; diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index af8c9d8168742..62443efbe2ab9 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -55,7 +55,7 @@ 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::subst::{ParamSpace, FnSpace, TypeSpace}; use rustc::middle::ty::{Freevar, FreevarMap, TraitMap, GlobMap}; use rustc::util::nodemap::{NodeMap, FnvHashMap}; diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/trans/_match.rs index 8aea2f1ec4f4a..561fd022ecef5 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -200,7 +200,7 @@ 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 middle::ty::subst::Substs; use trans::adt; use trans::base::*; use trans::build::{AddCase, And, Br, CondBr, GEPi, InBoundsGEP, Load, PointerCast}; diff --git a/src/librustc_trans/trans/adt.rs b/src/librustc_trans/trans/adt.rs index db0fa2a64bde6..e94c4ebe3b56b 100644 --- a/src/librustc_trans/trans/adt.rs +++ b/src/librustc_trans/trans/adt.rs @@ -48,7 +48,7 @@ use std; use std::rc::Rc; use llvm::{ValueRef, True, IntEQ, IntNE}; -use middle::subst; +use middle::ty::subst; use middle::ty::{self, Ty, TyCtxt}; use syntax::ast; use syntax::attr; diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 1d8daf9d86b4a..9892cf67e8afe 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -41,7 +41,7 @@ use middle::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::ty::subst::{self, Substs}; use middle::traits; use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use middle::ty::adjustment::CustomCoerceUnsized; diff --git a/src/librustc_trans/trans/callee.rs b/src/librustc_trans/trans/callee.rs index 1013c5d64b609..ff806ac5125ee 100644 --- a/src/librustc_trans/trans/callee.rs +++ b/src/librustc_trans/trans/callee.rs @@ -23,8 +23,8 @@ 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::ty::subst; +use middle::ty::subst::{Substs}; use middle::traits; use rustc::front::map as hir_map; use trans::abi::{Abi, FnType}; diff --git a/src/librustc_trans/trans/collector.rs b/src/librustc_trans/trans/collector.rs index ab8f7d6bec3d5..fbd58fbea085d 100644 --- a/src/librustc_trans/trans/collector.rs +++ b/src/librustc_trans/trans/collector.rs @@ -195,7 +195,7 @@ 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::subst::{self, Substs, Subst}; use rustc::middle::ty::{self, Ty, TypeFoldable}; use rustc::middle::ty::adjustment::CustomCoerceUnsized; use rustc::mir::repr as mir; diff --git a/src/librustc_trans/trans/common.rs b/src/librustc_trans/trans/common.rs index db06b2352fd35..eb443a3b0b977 100644 --- a/src/librustc_trans/trans/common.rs +++ b/src/librustc_trans/trans/common.rs @@ -21,7 +21,7 @@ use middle::def::Def; use middle::def_id::DefId; use middle::infer; use middle::lang_items::LangItem; -use middle::subst::Substs; +use middle::ty::subst::Substs; use trans::abi::{Abi, FnType}; use trans::base; use trans::build; diff --git a/src/librustc_trans/trans/consts.rs b/src/librustc_trans/trans/consts.rs index 7e6b24969100b..cb4092ffb9eba 100644 --- a/src/librustc_trans/trans/consts.rs +++ b/src/librustc_trans/trans/consts.rs @@ -32,7 +32,7 @@ use trans::type_::Type; use trans::type_of; use trans::value::Value; use trans::Disr; -use middle::subst::Substs; +use middle::ty::subst::Substs; use middle::ty::adjustment::{AdjustDerefRef, AdjustReifyFnPointer}; use middle::ty::adjustment::{AdjustUnsafeFnPointer, AdjustMutToConstPointer}; use middle::ty::{self, Ty, TyCtxt}; diff --git a/src/librustc_trans/trans/context.rs b/src/librustc_trans/trans/context.rs index 046e05dd0710a..db2b5b86a7e0b 100644 --- a/src/librustc_trans/trans/context.rs +++ b/src/librustc_trans/trans/context.rs @@ -28,7 +28,7 @@ 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::subst::{Substs, VecPerParamSpace}; use middle::ty::{self, Ty, TyCtxt}; use session::config::NoDebugInfo; use session::Session; diff --git a/src/librustc_trans/trans/controlflow.rs b/src/librustc_trans/trans/controlflow.rs index 91454df156655..65f5ab1f22818 100644 --- a/src/librustc_trans/trans/controlflow.rs +++ b/src/librustc_trans/trans/controlflow.rs @@ -11,7 +11,7 @@ use llvm::ValueRef; use middle::def::Def; use middle::lang_items::{PanicFnLangItem, PanicBoundsCheckFnLangItem}; -use middle::subst::Substs; +use middle::ty::subst::Substs; use trans::base::*; use trans::basic_block::BasicBlock; use trans::build::*; diff --git a/src/librustc_trans/trans/debuginfo/metadata.rs b/src/librustc_trans/trans/debuginfo/metadata.rs index e22d42e9d28da..a654a3f37c8da 100644 --- a/src/librustc_trans/trans/debuginfo/metadata.rs +++ b/src/librustc_trans/trans/debuginfo/metadata.rs @@ -26,7 +26,7 @@ use llvm::debuginfo::{DIType, DIFile, DIScope, DIDescriptor, DICompositeType}; use middle::def_id::DefId; use middle::infer; use middle::pat_util; -use middle::subst; +use middle::ty::subst; use rustc::front::map as hir_map; use rustc_front::hir::{self, PatKind}; use trans::{type_of, adt, machine, monomorphize}; diff --git a/src/librustc_trans/trans/debuginfo/mod.rs b/src/librustc_trans/trans/debuginfo/mod.rs index 40eb29ed25050..dbba03cf4551f 100644 --- a/src/librustc_trans/trans/debuginfo/mod.rs +++ b/src/librustc_trans/trans/debuginfo/mod.rs @@ -28,7 +28,7 @@ use llvm::debuginfo::{DIFile, DIType, DIScope, DIBuilderRef, DISubprogram, DIArr DIDescriptor, FlagPrototyped}; use middle::def_id::DefId; use middle::infer::normalize_associated_type; -use middle::subst::{self, Substs}; +use middle::ty::subst::{self, Substs}; use rustc_front; use rustc_front::hir; diff --git a/src/librustc_trans/trans/debuginfo/type_names.rs b/src/librustc_trans/trans/debuginfo/type_names.rs index b71b7789affe2..a051966795d55 100644 --- a/src/librustc_trans/trans/debuginfo/type_names.rs +++ b/src/librustc_trans/trans/debuginfo/type_names.rs @@ -15,7 +15,7 @@ use super::namespace::crate_root_namespace; use trans::common::CrateContext; use middle::def_id::DefId; use middle::infer; -use middle::subst; +use middle::ty::subst; use middle::ty::{self, Ty}; use rustc_front::hir; diff --git a/src/librustc_trans/trans/expr.rs b/src/librustc_trans/trans/expr.rs index fe98fa290211c..8b7527fd7de64 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/trans/expr.rs @@ -54,7 +54,7 @@ use self::lazy_binop_ty::*; use llvm::{self, ValueRef, TypeKind}; use middle::const_qualif::ConstQualif; use middle::def::Def; -use middle::subst::Substs; +use middle::ty::subst::Substs; use trans::{_match, abi, adt, asm, base, closure, consts, controlflow}; use trans::base::*; use trans::build::*; diff --git a/src/librustc_trans/trans/glue.rs b/src/librustc_trans/trans/glue.rs index de4b1ba858a6c..02a14715ab28b 100644 --- a/src/librustc_trans/trans/glue.rs +++ b/src/librustc_trans/trans/glue.rs @@ -18,7 +18,7 @@ use back::link; use llvm; use llvm::{ValueRef, get_param}; use middle::lang_items::ExchangeFreeFnLangItem; -use middle::subst::{Substs}; +use middle::ty::subst::{Substs}; use middle::traits; use middle::ty::{self, Ty, TyCtxt}; use trans::abi::{Abi, FnType}; diff --git a/src/librustc_trans/trans/inline.rs b/src/librustc_trans/trans/inline.rs index 530b99cba920c..87b4a572884ec 100644 --- a/src/librustc_trans/trans/inline.rs +++ b/src/librustc_trans/trans/inline.rs @@ -11,7 +11,7 @@ use llvm::{AvailableExternallyLinkage, InternalLinkage, SetLinkage}; use middle::cstore::{CrateStore, FoundAst, InlinedItem}; use middle::def_id::DefId; -use middle::subst::Substs; +use middle::ty::subst::Substs; use trans::base::{push_ctxt, trans_item, trans_fn}; use trans::callee::Callee; use trans::common::*; diff --git a/src/librustc_trans/trans/intrinsic.rs b/src/librustc_trans/trans/intrinsic.rs index 9bc07c6cd8626..d3b84fbac1a9b 100644 --- a/src/librustc_trans/trans/intrinsic.rs +++ b/src/librustc_trans/trans/intrinsic.rs @@ -16,8 +16,8 @@ use libc; use llvm; use llvm::{ValueRef, TypeKind}; use middle::infer; -use middle::subst; -use middle::subst::FnSpace; +use middle::ty::subst; +use middle::ty::subst::FnSpace; use trans::abi::{Abi, FnType}; use trans::adt; use trans::attributes; @@ -38,7 +38,7 @@ use trans::machine; use trans::type_::Type; use middle::ty::{self, Ty, TypeFoldable}; use trans::Disr; -use middle::subst::Substs; +use middle::ty::subst::Substs; use rustc::dep_graph::DepNode; use rustc_front::hir; use syntax::ast; diff --git a/src/librustc_trans/trans/meth.rs b/src/librustc_trans/trans/meth.rs index ae619ceb30b01..d86f0c4e6dff3 100644 --- a/src/librustc_trans/trans/meth.rs +++ b/src/librustc_trans/trans/meth.rs @@ -15,8 +15,8 @@ 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::ty::subst::{FnSpace, Subst, Substs}; +use middle::ty::subst; use middle::traits::{self, ProjectionMode}; use trans::abi::FnType; use trans::base::*; diff --git a/src/librustc_trans/trans/monomorphize.rs b/src/librustc_trans/trans/monomorphize.rs index 63fb8c5fb5e1c..986d05af92f2c 100644 --- a/src/librustc_trans/trans/monomorphize.rs +++ b/src/librustc_trans/trans/monomorphize.rs @@ -13,8 +13,8 @@ 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::subst; +use middle::ty::subst::{Subst, Substs}; use middle::ty::fold::{TypeFolder, TypeFoldable}; use trans::attributes; use trans::base::{push_ctxt}; diff --git a/src/librustc_trans/trans/type_of.rs b/src/librustc_trans/trans/type_of.rs index 7d5218d84dafe..e81039908c173 100644 --- a/src/librustc_trans/trans/type_of.rs +++ b/src/librustc_trans/trans/type_of.rs @@ -12,7 +12,7 @@ use middle::def_id::DefId; use middle::infer; -use middle::subst; +use middle::ty::subst; use trans::abi::FnType; use trans::adt; use trans::common::*; diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 159ff90b50955..3b3d2cbad10cc 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -54,7 +54,7 @@ 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::ty::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; diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 305970db9e72e..947488bde71dd 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -12,7 +12,7 @@ use middle::def::{self, Def}; use middle::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::subst::Substs; use middle::ty::{self, Ty, TypeFoldable, LvaluePreference}; use check::{check_expr, check_expr_has_type, check_expr_with_expectation}; use check::{demand, FnCtxt, Expectation}; diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index a4fb2e381459e..54b2c8c59234e 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -13,7 +13,7 @@ use super::{check_fn, Expectation, FnCtxt}; use astconv; -use middle::subst; +use middle::ty::subst; use middle::ty::{self, ToPolyTraitRef, Ty}; use std::cmp; use syntax::abi::Abi; diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 3e59f0ba73a81..eee3fddcaea3d 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -12,7 +12,7 @@ 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 middle::ty::subst::{self, Subst, Substs, VecPerParamSpace}; use syntax::ast; use syntax::codemap::Span; diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index 7dd5db831fd75..fd5d06ea9d19e 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -14,7 +14,7 @@ use middle::def_id::DefId; use middle::free_region::FreeRegionMap; use middle::infer; use middle::region; -use middle::subst::{self, Subst}; +use middle::ty::subst::{self, Subst}; use middle::ty::{self, Ty, TyCtxt}; use middle::traits::{self, ProjectionMode}; use util::nodemap::FnvHashSet; diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index 2cd166ebe7ebe..9440be50e2106 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -13,7 +13,7 @@ use astconv::AstConv; use intrinsics; -use middle::subst::{self, Substs}; +use middle::ty::subst::{self, Substs}; use middle::ty::FnSig; use middle::ty::{self, Ty, TyCtxt}; use middle::ty::fold::TypeFolder; diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index aa4e1d0b52908..b8c1d43b7c475 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -13,7 +13,7 @@ use super::probe; use check::{self, FnCtxt, callee, demand}; use check::UnresolvedTypeAction; use middle::def_id::DefId; -use middle::subst::{self}; +use middle::ty::subst::{self}; use middle::traits; use middle::ty::{self, NoPreference, PreferMutLvalue, Ty, TyCtxt}; use middle::ty::adjustment::{AdjustDerefRef, AutoDerefRef, AutoPtr}; diff --git a/src/librustc_typeck/check/method/mod.rs b/src/librustc_typeck/check/method/mod.rs index 7f982c466a704..6648236f33ae0 100644 --- a/src/librustc_typeck/check/method/mod.rs +++ b/src/librustc_typeck/check/method/mod.rs @@ -14,7 +14,7 @@ use astconv::AstConv; use check::FnCtxt; use middle::def::Def; use middle::def_id::DefId; -use middle::subst; +use middle::ty::subst; use middle::traits; use middle::ty::{self, TyCtxt, ToPredicate, ToPolyTraitRef, TraitRef, TypeFoldable}; use middle::ty::adjustment::{AdjustDerefRef, AutoDerefRef, AutoPtr}; diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index 5f7f9703b1059..6be822aebcadf 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -16,8 +16,8 @@ use super::suggest; use check; use check::{FnCtxt, UnresolvedTypeAction}; use middle::def_id::DefId; -use middle::subst; -use middle::subst::Subst; +use middle::ty::subst; +use middle::ty::subst::Subst; use middle::traits; use middle::ty::{self, NoPreference, Ty, TyCtxt, ToPolyTraitRef, TraitRef, TypeFoldable}; use middle::infer; diff --git a/src/librustc_typeck/check/method/suggest.rs b/src/librustc_typeck/check/method/suggest.rs index 44724ca26b164..b940c073a7fec 100644 --- a/src/librustc_typeck/check/method/suggest.rs +++ b/src/librustc_typeck/check/method/suggest.rs @@ -21,7 +21,7 @@ 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::ty::subst::Substs; use middle::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..8d025e164224d 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -91,7 +91,7 @@ use middle::def_id::DefId; use middle::infer; use middle::infer::{TypeOrigin, TypeTrace, type_variable}; use middle::pat_util::{self, pat_id_map}; -use middle::subst::{self, Subst, Substs, VecPerParamSpace, ParamSpace}; +use middle::ty::subst::{self, Subst, Substs, VecPerParamSpace, ParamSpace}; use middle::traits::{self, report_fulfillment_errors, ProjectionMode}; use middle::ty::{GenericPredicates, TypeScheme}; use middle::ty::{ParamTy, ParameterEnvironment}; diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index fb4870bce8765..afbe511dda89f 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -89,7 +89,7 @@ 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::ty::subst::Substs; use middle::traits; use middle::ty::{self, Ty, TyCtxt, MethodCall, TypeFoldable}; use middle::infer::{self, GenericKind, InferCtxt, SubregionOrigin, TypeOrigin, VerifyBound}; diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index a8ada8061317e..af33b6b394e5f 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -14,7 +14,7 @@ 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::ty::subst::{self, TypeSpace, FnSpace, ParamSpace, SelfSpace}; use middle::traits; use middle::ty::{self, Ty, TyCtxt}; use middle::ty::fold::{TypeFolder}; diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 278d4d8b5b44a..af4975091055a 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -17,7 +17,7 @@ use middle::def_id::DefId; use middle::lang_items::UnsizeTraitLangItem; -use middle::subst::{self, Subst}; +use middle::ty::subst::{self, Subst}; use middle::ty::{self, TyCtxt, TypeFoldable}; use middle::traits::{self, ProjectionMode}; use middle::ty::{ImplOrTraitItemId, ConstTraitItemId}; diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 3f8f31ce3ce80..a282165d1a041 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -68,7 +68,7 @@ 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::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}; diff --git a/src/librustc_typeck/constrained_type_params.rs b/src/librustc_typeck/constrained_type_params.rs index 4446063e0c7bc..016ff3b5a067b 100644 --- a/src/librustc_typeck/constrained_type_params.rs +++ b/src/librustc_typeck/constrained_type_params.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::subst; +use middle::ty::subst; use middle::ty::{self, Ty, TyCtxt}; use std::collections::HashSet; diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index 4e1f3d3cbb7a9..ccc79b0748c20 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -105,7 +105,7 @@ 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::subst::Substs; use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; use middle::traits::ProjectionMode; use session::{config, CompileResult}; diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 5c74e9096f3a7..f46edb03b95b7 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -16,8 +16,8 @@ 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::subst; +use middle::ty::subst::ParamSpace; use middle::ty::{self, Ty, TyCtxt}; use middle::ty::maps::ItemVariances; use rustc::front::map as hir_map; diff --git a/src/librustc_typeck/variance/solve.rs b/src/librustc_typeck/variance/solve.rs index fd442a4547cf9..c5e925226d07e 100644 --- a/src/librustc_typeck/variance/solve.rs +++ b/src/librustc_typeck/variance/solve.rs @@ -15,7 +15,7 @@ //! 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::subst::VecPerParamSpace; use middle::ty; use std::rc::Rc; diff --git a/src/librustc_typeck/variance/terms.rs b/src/librustc_typeck/variance/terms.rs index ff55aefb20ff3..7148afb5e856c 100644 --- a/src/librustc_typeck/variance/terms.rs +++ b/src/librustc_typeck/variance/terms.rs @@ -21,7 +21,7 @@ use arena::TypedArena; use dep_graph::DepTrackingMapConfig; -use middle::subst::{ParamSpace, FnSpace, TypeSpace, SelfSpace, VecPerParamSpace}; +use middle::ty::subst::{ParamSpace, FnSpace, TypeSpace, SelfSpace, VecPerParamSpace}; use middle::ty::{self, TyCtxt}; use middle::ty::maps::ItemVariances; use std::fmt; diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index e9c55c56a9d72..75bf1036fa2cc 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -20,7 +20,7 @@ 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::middle::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..675bebe91c312 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -38,7 +38,7 @@ 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::subst::{self, ParamSpace, VecPerParamSpace}; use rustc::middle::ty; use rustc::middle::stability; diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs index 716b88d5534ae..4cce835899203 100644 --- a/src/librustdoc/clean/simplify.rs +++ b/src/librustdoc/clean/simplify.rs @@ -30,7 +30,7 @@ use std::mem; use std::collections::HashMap; use rustc::middle::def_id::DefId; -use rustc::middle::subst; +use rustc::middle::ty::subst; use clean::PathParameters as PP; use clean::WherePredicate as WP; From a6f69f1d5edc8cc1b1c030943d4c82daf622a711 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Tue, 22 Mar 2016 17:30:57 +0200 Subject: [PATCH 28/35] rustc: move cfg, infer, traits and ty from middle to top-level. --- src/librustc/{middle => }/cfg/construct.rs | 4 +- src/librustc/{middle => }/cfg/graphviz.rs | 2 +- src/librustc/{middle => }/cfg/mod.rs | 2 +- src/librustc/dep_graph/mod.rs | 2 +- src/librustc/{middle => }/infer/README.md | 0 src/librustc/{middle => }/infer/bivariate.rs | 6 +-- src/librustc/{middle => }/infer/combine.rs | 10 ++--- src/librustc/{middle => }/infer/equate.rs | 6 +-- .../{middle => }/infer/error_reporting.rs | 10 ++--- src/librustc/{middle => }/infer/freshen.rs | 4 +- src/librustc/{middle => }/infer/glb.rs | 4 +- .../infer/higher_ranked/README.md | 0 .../{middle => }/infer/higher_ranked/mod.rs | 6 +-- src/librustc/{middle => }/infer/lattice.rs | 6 +-- src/librustc/{middle => }/infer/lub.rs | 4 +- src/librustc/{middle => }/infer/mod.rs | 26 ++++++------ .../infer/region_inference/README.md | 0 .../infer/region_inference/graphviz.rs | 6 +-- .../infer/region_inference/mod.rs | 8 ++-- src/librustc/{middle => }/infer/resolve.rs | 2 +- src/librustc/{middle => }/infer/sub.rs | 6 +-- .../{middle => }/infer/type_variable.rs | 2 +- src/librustc/{middle => }/infer/unify_key.rs | 2 +- src/librustc/lib.rs | 12 +++--- src/librustc/lint/context.rs | 2 +- src/librustc/middle/astconv_util.rs | 2 +- src/librustc/middle/check_match.rs | 8 ++-- src/librustc/middle/const_eval.rs | 8 ++-- src/librustc/middle/cstore.rs | 6 +-- src/librustc/middle/dataflow.rs | 6 +-- src/librustc/middle/dead.rs | 6 +-- src/librustc/middle/def.rs | 2 +- src/librustc/middle/def_id.rs | 2 +- src/librustc/middle/effect.rs | 4 +- src/librustc/middle/expr_use_visitor.rs | 4 +- src/librustc/middle/free_region.rs | 4 +- src/librustc/middle/intrinsicck.rs | 6 +-- src/librustc/middle/lang_items.rs | 2 +- src/librustc/middle/liveness.rs | 8 ++-- src/librustc/middle/mem_categorization.rs | 6 +-- src/librustc/middle/pat_util.rs | 2 +- src/librustc/middle/reachable.rs | 2 +- src/librustc/middle/region.rs | 10 ++--- src/librustc/middle/resolve_lifetime.rs | 4 +- src/librustc/middle/stability.rs | 2 +- src/librustc/mir/repr.rs | 4 +- src/librustc/mir/tcx.rs | 6 +-- src/librustc/mir/transform.rs | 2 +- src/librustc/mir/visit.rs | 4 +- src/librustc/{middle => }/traits/README.md | 0 src/librustc/{middle => }/traits/coherence.rs | 6 +-- .../{middle => }/traits/error_reporting.rs | 6 +-- src/librustc/{middle => }/traits/fulfill.rs | 4 +- src/librustc/{middle => }/traits/mod.rs | 6 +-- .../{middle => }/traits/object_safety.rs | 6 +-- src/librustc/{middle => }/traits/project.rs | 8 ++-- src/librustc/{middle => }/traits/select.rs | 14 +++---- .../{middle => }/traits/specialize/mod.rs | 8 ++-- .../traits/specialize/specialization_graph.rs | 6 +-- .../{middle => }/traits/structural_impls.rs | 8 ++-- src/librustc/{middle => }/traits/util.rs | 6 +-- src/librustc/{middle => }/ty/_match.rs | 6 +-- src/librustc/{middle => }/ty/adjustment.rs | 4 +- src/librustc/{middle => }/ty/cast.rs | 2 +- src/librustc/{middle => }/ty/contents.rs | 2 +- src/librustc/{middle => }/ty/context.rs | 24 +++++------ src/librustc/{middle => }/ty/error.rs | 6 +-- src/librustc/{middle => }/ty/fast_reject.rs | 2 +- src/librustc/{middle => }/ty/flags.rs | 4 +- src/librustc/{middle => }/ty/fold.rs | 6 +-- src/librustc/{middle => }/ty/ivar.rs | 4 +- src/librustc/{middle => }/ty/maps.rs | 2 +- src/librustc/{middle => }/ty/mod.rs | 10 ++--- src/librustc/{middle => }/ty/outlives.rs | 4 +- src/librustc/{middle => }/ty/relate.rs | 6 +-- .../{middle => }/ty/structural_impls.rs | 8 ++-- src/librustc/{middle => }/ty/sty.rs | 8 ++-- src/librustc/{middle => }/ty/subst.rs | 4 +- src/librustc/{middle => }/ty/trait_def.rs | 8 ++-- src/librustc/{middle => }/ty/util.rs | 12 +++--- src/librustc/{middle => }/ty/walk.rs | 2 +- src/librustc/{middle => }/ty/wf.rs | 10 ++--- src/librustc/util/ppaux.rs | 16 ++++---- src/librustc_borrowck/borrowck/check_loans.rs | 6 +-- src/librustc_borrowck/borrowck/fragments.rs | 2 +- .../borrowck/gather_loans/gather_moves.rs | 2 +- .../borrowck/gather_loans/lifetime.rs | 2 +- .../borrowck/gather_loans/mod.rs | 6 +-- .../borrowck/gather_loans/move_error.rs | 2 +- .../borrowck/gather_loans/restrictions.rs | 2 +- .../borrowck/mir/dataflow.rs | 4 +- .../borrowck/mir/gather_moves.rs | 2 +- src/librustc_borrowck/borrowck/mod.rs | 4 +- src/librustc_borrowck/borrowck/move_data.rs | 4 +- src/librustc_borrowck/graphviz.rs | 6 +-- src/librustc_driver/driver.rs | 4 +- src/librustc_driver/pretty.rs | 6 +-- src/librustc_driver/test.rs | 30 +++++++------- src/librustc_lint/bad_style.rs | 2 +- src/librustc_lint/builtin.rs | 11 ++--- src/librustc_lint/types.rs | 6 +-- src/librustc_lint/unused.rs | 4 +- src/librustc_metadata/astencode.rs | 8 ++-- src/librustc_metadata/csearch.rs | 2 +- src/librustc_metadata/decoder.rs | 6 +-- src/librustc_metadata/encoder.rs | 8 ++-- src/librustc_metadata/tls_context.rs | 4 +- src/librustc_metadata/tydecode.rs | 6 +-- src/librustc_metadata/tyencode.rs | 8 ++-- src/librustc_mir/build/expr/into.rs | 2 +- src/librustc_mir/build/matches/mod.rs | 2 +- src/librustc_mir/build/matches/test.rs | 2 +- src/librustc_mir/build/misc.rs | 2 +- src/librustc_mir/build/mod.rs | 2 +- src/librustc_mir/build/scope.rs | 4 +- src/librustc_mir/graphviz.rs | 2 +- src/librustc_mir/hair/cx/expr.rs | 2 +- src/librustc_mir/hair/cx/mod.rs | 6 +-- src/librustc_mir/hair/cx/pattern.rs | 2 +- src/librustc_mir/hair/mod.rs | 4 +- src/librustc_mir/mir_map.rs | 6 +-- src/librustc_mir/pretty.rs | 2 +- src/librustc_mir/transform/erase_regions.rs | 2 +- src/librustc_mir/transform/no_landing_pads.rs | 2 +- .../transform/remove_dead_blocks.rs | 2 +- src/librustc_mir/transform/simplify_cfg.rs | 2 +- src/librustc_mir/transform/type_check.rs | 8 ++-- src/librustc_passes/consts.rs | 8 ++-- src/librustc_passes/rvalues.rs | 6 +-- src/librustc_platform_intrinsics/aarch64.rs | 2 +- src/librustc_platform_intrinsics/arm.rs | 2 +- src/librustc_platform_intrinsics/lib.rs | 2 +- src/librustc_platform_intrinsics/x86.rs | 2 +- src/librustc_privacy/lib.rs | 2 +- src/librustc_resolve/build_reduced_graph.rs | 2 +- src/librustc_resolve/lib.rs | 4 +- src/librustc_trans/back/link.rs | 2 +- src/librustc_trans/save/data.rs | 2 +- src/librustc_trans/save/dump_visitor.rs | 2 +- src/librustc_trans/save/mod.rs | 2 +- src/librustc_trans/trans/_match.rs | 8 ++-- src/librustc_trans/trans/abi.rs | 4 +- src/librustc_trans/trans/adt.rs | 4 +- src/librustc_trans/trans/assert_dep_graph.rs | 2 +- src/librustc_trans/trans/base.rs | 12 +++--- src/librustc_trans/trans/callee.rs | 10 ++--- src/librustc_trans/trans/cleanup.rs | 2 +- src/librustc_trans/trans/closure.rs | 6 +-- src/librustc_trans/trans/collector.rs | 10 ++--- src/librustc_trans/trans/common.rs | 12 +++--- src/librustc_trans/trans/consts.rs | 10 ++--- src/librustc_trans/trans/context.rs | 6 +-- src/librustc_trans/trans/controlflow.rs | 2 +- src/librustc_trans/trans/datum.rs | 2 +- .../trans/debuginfo/metadata.rs | 6 +-- src/librustc_trans/trans/debuginfo/mod.rs | 8 ++-- .../trans/debuginfo/type_names.rs | 6 +-- src/librustc_trans/trans/declare.rs | 4 +- src/librustc_trans/trans/disr.rs | 4 +- src/librustc_trans/trans/expr.rs | 20 +++++----- src/librustc_trans/trans/glue.rs | 6 +-- src/librustc_trans/trans/inline.rs | 2 +- src/librustc_trans/trans/intrinsic.rs | 14 +++---- src/librustc_trans/trans/meth.rs | 10 ++--- src/librustc_trans/trans/mir/block.rs | 2 +- src/librustc_trans/trans/mir/constant.rs | 2 +- src/librustc_trans/trans/mir/drop.rs | 2 +- src/librustc_trans/trans/mir/lvalue.rs | 2 +- src/librustc_trans/trans/mir/mod.rs | 2 +- src/librustc_trans/trans/mir/operand.rs | 2 +- src/librustc_trans/trans/mir/rvalue.rs | 4 +- src/librustc_trans/trans/monomorphize.rs | 10 ++--- src/librustc_trans/trans/tvec.rs | 2 +- src/librustc_trans/trans/type_of.rs | 10 ++--- src/librustc_typeck/astconv.rs | 8 ++-- src/librustc_typeck/check/_match.rs | 6 +-- src/librustc_typeck/check/assoc.rs | 6 +-- src/librustc_typeck/check/callee.rs | 4 +- src/librustc_typeck/check/cast.rs | 8 ++-- src/librustc_typeck/check/closure.rs | 4 +- src/librustc_typeck/check/coercion.rs | 20 +++++----- src/librustc_typeck/check/compare_method.rs | 8 ++-- src/librustc_typeck/check/demand.rs | 4 +- src/librustc_typeck/check/dropck.rs | 8 ++-- src/librustc_typeck/check/intrinsic.rs | 8 ++-- src/librustc_typeck/check/method/confirm.rs | 14 +++---- src/librustc_typeck/check/method/mod.rs | 10 ++--- src/librustc_typeck/check/method/probe.rs | 12 +++--- src/librustc_typeck/check/method/suggest.rs | 6 +-- src/librustc_typeck/check/mod.rs | 40 +++++++++---------- src/librustc_typeck/check/op.rs | 4 +- src/librustc_typeck/check/regionck.rs | 12 +++--- src/librustc_typeck/check/upvar.rs | 4 +- src/librustc_typeck/check/wfcheck.rs | 8 ++-- src/librustc_typeck/check/writeback.rs | 8 ++-- src/librustc_typeck/coherence/mod.rs | 26 ++++++------ src/librustc_typeck/coherence/orphan.rs | 4 +- src/librustc_typeck/coherence/overlap.rs | 6 +-- src/librustc_typeck/coherence/unsafety.rs | 2 +- src/librustc_typeck/collect.rs | 12 +++--- .../constrained_type_params.rs | 4 +- src/librustc_typeck/lib.rs | 8 ++-- src/librustc_typeck/rscope.rs | 2 +- src/librustc_typeck/variance/constraints.rs | 8 ++-- src/librustc_typeck/variance/mod.rs | 2 +- src/librustc_typeck/variance/solve.rs | 4 +- src/librustc_typeck/variance/terms.rs | 6 +-- src/librustc_typeck/variance/xform.rs | 2 +- src/librustdoc/clean/inline.rs | 4 +- src/librustdoc/clean/mod.rs | 6 +-- src/librustdoc/clean/simplify.rs | 4 +- src/librustdoc/core.rs | 2 +- src/test/auxiliary/dummy_mir_pass.rs | 2 +- ...s-based-on-type-cyclic-types-issue-4821.rs | 2 +- src/test/run-make/execution-engine/test.rs | 2 +- 215 files changed, 614 insertions(+), 613 deletions(-) rename src/librustc/{middle => }/cfg/construct.rs (99%) rename src/librustc/{middle => }/cfg/graphviz.rs (99%) rename src/librustc/{middle => }/cfg/mod.rs (98%) rename src/librustc/{middle => }/infer/README.md (100%) rename src/librustc/{middle => }/infer/bivariate.rs (97%) rename src/librustc/{middle => }/infer/combine.rs (98%) rename src/librustc/{middle => }/infer/equate.rs (96%) rename src/librustc/{middle => }/infer/error_reporting.rs (99%) rename src/librustc/{middle => }/infer/freshen.rs (98%) rename src/librustc/{middle => }/infer/glb.rs (96%) rename src/librustc/{middle => }/infer/higher_ranked/README.md (100%) rename src/librustc/{middle => }/infer/higher_ranked/mod.rs (99%) rename src/librustc/{middle => }/infer/lattice.rs (96%) rename src/librustc/{middle => }/infer/lub.rs (96%) rename src/librustc/{middle => }/infer/mod.rs (98%) rename src/librustc/{middle => }/infer/region_inference/README.md (100%) rename src/librustc/{middle => }/infer/region_inference/graphviz.rs (98%) rename src/librustc/{middle => }/infer/region_inference/mod.rs (99%) rename src/librustc/{middle => }/infer/resolve.rs (99%) rename src/librustc/{middle => }/infer/sub.rs (96%) rename src/librustc/{middle => }/infer/type_variable.rs (99%) rename src/librustc/{middle => }/infer/unify_key.rs (98%) rename src/librustc/{middle => }/traits/README.md (100%) rename src/librustc/{middle => }/traits/coherence.rs (98%) rename src/librustc/{middle => }/traits/error_reporting.rs (99%) rename src/librustc/{middle => }/traits/fulfill.rs (99%) rename src/librustc/{middle => }/traits/mod.rs (99%) rename src/librustc/{middle => }/traits/object_safety.rs (99%) rename src/librustc/{middle => }/traits/project.rs (99%) rename src/librustc/{middle => }/traits/select.rs (99%) rename src/librustc/{middle => }/traits/specialize/mod.rs (98%) rename src/librustc/{middle => }/traits/specialize/specialization_graph.rs (99%) rename src/librustc/{middle => }/traits/structural_impls.rs (98%) rename src/librustc/{middle => }/traits/util.rs (99%) rename src/librustc/{middle => }/ty/_match.rs (96%) rename src/librustc/{middle => }/ty/adjustment.rs (98%) rename src/librustc/{middle => }/ty/cast.rs (98%) rename src/librustc/{middle => }/ty/contents.rs (99%) rename src/librustc/{middle => }/ty/context.rs (98%) rename src/librustc/{middle => }/ty/error.rs (99%) rename src/librustc/{middle => }/ty/fast_reject.rs (99%) rename src/librustc/{middle => }/ty/flags.rs (98%) rename src/librustc/{middle => }/ty/fold.rs (99%) rename src/librustc/{middle => }/ty/ivar.rs (98%) rename src/librustc/{middle => }/ty/maps.rs (99%) rename src/librustc/{middle => }/ty/mod.rs (99%) rename src/librustc/{middle => }/ty/outlives.rs (99%) rename src/librustc/{middle => }/ty/relate.rs (99%) rename src/librustc/{middle => }/ty/structural_impls.rs (99%) rename src/librustc/{middle => }/ty/sty.rs (99%) rename src/librustc/{middle => }/ty/subst.rs (99%) rename src/librustc/{middle => }/ty/trait_def.rs (98%) rename src/librustc/{middle => }/ty/util.rs (99%) rename src/librustc/{middle => }/ty/walk.rs (99%) rename src/librustc/{middle => }/ty/wf.rs (99%) 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/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 7a1da77453147..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::ty::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 98% rename from src/librustc/middle/infer/mod.rs rename to src/librustc/infer/mod.rs index ea11ade1d16dd..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::ty::subst; -use middle::ty::subst::Substs; -use middle::ty::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 37b6ea7872aad..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,8 +115,6 @@ pub mod middle { pub mod recursion_limit; pub mod resolve_lifetime; pub mod stability; - pub mod traits; - pub mod ty; pub mod weak_lang_items; } @@ -127,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/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..79ec53ff0cf92 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}; diff --git a/src/librustc/middle/const_eval.rs b/src/librustc/middle/const_eval.rs index 5cb5595e9e8ed..2b1bfb144f6f3 100644 --- a/src/librustc/middle/const_eval.rs +++ b/src/librustc/middle/const_eval.rs @@ -17,13 +17,13 @@ use self::EvalHint::*; use front::map as ast_map; use front::map::blocks::FnLikeNode; use middle::cstore::{self, CrateStore, InlinedItem}; -use middle::{infer, traits}; +use {infer, traits}; use middle::def::Def; use middle::def_id::DefId; use middle::pat_util::def_to_path; -use middle::ty::{self, subst, 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; diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 9a3550b65aa2d..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::ty::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 f832a871c8b1b..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::ty::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 e3da34acb4b43..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::ty::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 ee39a4fc7df6e..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::ty::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 8d3a80854b467..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::ty::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 20cf6d929ca7c..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::ty::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 0c9e00a6c5ec4..46d99dbef8c61 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -14,9 +14,9 @@ */ use mir::repr::*; -use middle::ty::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/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 547cb71f234f0..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::ty::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 9404731859961..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::ty::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 8777b9eb00cfd..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::ty::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 bd075a5dc88db..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::ty::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 050468809a5ac..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::ty::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 088099d87b158..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::ty::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 f9a1b09a93d2c..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::ty::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 aa0ac62ac5719..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::ty::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 8e1ace57e42ad..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::ty::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 12b2426150797..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::ty::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 2e8782a72f691..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::ty::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 c5f10c332fc0a..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::traits; -use middle::ty; -use middle::ty::fold::TypeFolder; -use middle::ty::subst::{Subst, Substs, VecPerParamSpace}; -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; 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 d648c2c588476..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::ty::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 23ec75b18e82c..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::ty::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 d8f0dd2903196..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::ty::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/ty/subst.rs b/src/librustc/ty/subst.rs similarity index 99% rename from src/librustc/middle/ty/subst.rs rename to src/librustc/ty/subst.rs index b9bf550704e02..8d25728212109 100644 --- a/src/librustc/middle/ty/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 f6c4390b83c96..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::ty::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 1becdb14fa534..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::ty::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 f67346fe1f940..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::ty::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/driver.rs b/src/librustc_driver/driver.rs index 55b873c06630a..3520d74187583 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; 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 abbea81897173..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::ty::subst; -use rustc_typeck::middle::ty::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 66e19cf29bf9e..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::ty::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/types.rs b/src/librustc_lint/types.rs index 3dfd265c5a020..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::ty::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 1cf6c9b53e2c5..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::ty::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 f88552707437b..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::ty::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 dc338048a83af..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::ty::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 2ba3e351c50aa..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::ty::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 8c88a63a161f4..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::ty::subst; -use middle::ty::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 5086977ea0637..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::ty::subst; -use middle::ty::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 033e1361d4a8c..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::ty::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 d603979906dda..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::ty::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..0391d5b843469 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; diff --git a/src/librustc_mir/hair/mod.rs b/src/librustc_mir/hair/mod.rs index 3eca7f0a8772c..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::ty::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 08b5e51729013..0185024938472 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -28,7 +28,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/lib.rs b/src/librustc_resolve/lib.rs index 62443efbe2ab9..72162806d8652 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::ty::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}; diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index acb458f8cc6ee..bcb56f4baf669 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -23,7 +23,7 @@ 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 util::common::time; diff --git a/src/librustc_trans/save/data.rs b/src/librustc_trans/save/data.rs index 3eaaa3fc4930c..b9d9d58b5bdcd 100644 --- a/src/librustc_trans/save/data.rs +++ b/src/librustc_trans/save/data.rs @@ -16,7 +16,7 @@ use std::hash::Hasher; use middle::def_id::DefId; -use middle::ty; +use rustc::ty; use syntax::ast::{CrateNum, NodeId}; use syntax::codemap::Span; diff --git a/src/librustc_trans/save/dump_visitor.rs b/src/librustc_trans/save/dump_visitor.rs index 65f48d1ff5eb5..9d465d8704708 100644 --- a/src/librustc_trans/save/dump_visitor.rs +++ b/src/librustc_trans/save/dump_visitor.rs @@ -31,7 +31,7 @@ use session::Session; use middle::def::Def; use middle::def_id::DefId; -use middle::ty::{self, TyCtxt}; +use rustc::ty::{self, TyCtxt}; use std::collections::HashSet; use std::hash::*; diff --git a/src/librustc_trans/save/mod.rs b/src/librustc_trans/save/mod.rs index 78e91e00baa71..a037f8d6ea0eb 100644 --- a/src/librustc_trans/save/mod.rs +++ b/src/librustc_trans/save/mod.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use middle::ty::{self, TyCtxt}; +use rustc::ty::{self, TyCtxt}; use middle::def::Def; use middle::def_id::DefId; diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/trans/_match.rs index 561fd022ecef5..7794ac763c6a1 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -195,12 +195,12 @@ 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::ty::subst::Substs; +use rustc::ty::subst::Substs; use trans::adt; use trans::base::*; use trans::build::{AddCase, And, Br, CondBr, GEPi, InBoundsGEP, Load, PointerCast}; @@ -218,8 +218,8 @@ 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::{self, Ty, TyCtxt}; +use rustc::traits::ProjectionMode; use session::config::NoDebugInfo; use util::common::indenter; use util::nodemap::FnvHashMap; diff --git a/src/librustc_trans/trans/abi.rs b/src/librustc_trans/trans/abi.rs index fd086522b2ea3..8725392417288 100644 --- a/src/librustc_trans/trans/abi.rs +++ b/src/librustc_trans/trans/abi.rs @@ -27,7 +27,7 @@ use trans::type_::Type; use trans::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/trans/adt.rs index e94c4ebe3b56b..f14c1a573cccc 100644 --- a/src/librustc_trans/trans/adt.rs +++ b/src/librustc_trans/trans/adt.rs @@ -48,8 +48,8 @@ use std; use std::rc::Rc; use llvm::{ValueRef, True, IntEQ, IntNE}; -use middle::ty::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; diff --git a/src/librustc_trans/trans/assert_dep_graph.rs b/src/librustc_trans/trans/assert_dep_graph.rs index 11386715492b6..dcf23039e2563 100644 --- a/src/librustc_trans/trans/assert_dep_graph.rs +++ b/src/librustc_trans/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/base.rs b/src/librustc_trans/trans/base.rs index 9892cf67e8afe..ae7e6a924ab9c 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -34,17 +34,17 @@ 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::ty::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; diff --git a/src/librustc_trans/trans/callee.rs b/src/librustc_trans/trans/callee.rs index ff806ac5125ee..4c9999d49624e 100644 --- a/src/librustc_trans/trans/callee.rs +++ b/src/librustc_trans/trans/callee.rs @@ -22,10 +22,10 @@ use back::link; use llvm::{self, ValueRef, get_params}; use middle::cstore::LOCAL_CRATE; use middle::def_id::DefId; -use middle::infer; -use middle::ty::subst; -use middle::ty::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; @@ -53,7 +53,7 @@ use trans::type_::Type; use trans::type_of; use trans::value::Value; use trans::Disr; -use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; +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/trans/cleanup.rs index bd2d05915f6db..78481e0ed9251 100644 --- a/src/librustc_trans/trans/cleanup.rs +++ b/src/librustc_trans/trans/cleanup.rs @@ -130,7 +130,7 @@ use trans::glue; use middle::region; use trans::type_::Type; use trans::value::Value; -use middle::ty::{Ty, TyCtxt}; +use rustc::ty::{Ty, TyCtxt}; use std::fmt; use syntax::ast; diff --git a/src/librustc_trans/trans/closure.rs b/src/librustc_trans/trans/closure.rs index dbabc3f54c594..7b71109f5a2fa 100644 --- a/src/librustc_trans/trans/closure.rs +++ b/src/librustc_trans/trans/closure.rs @@ -12,8 +12,8 @@ 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 rustc::infer; +use rustc::traits::ProjectionMode; use trans::abi::{Abi, FnType}; use trans::adt; use trans::attributes; @@ -30,7 +30,7 @@ use trans::expr; use trans::monomorphize::{Instance}; use trans::value::Value; use trans::Disr; -use middle::ty::{self, Ty, TyCtxt}; +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/trans/collector.rs index fbd58fbea085d..07989c4290db1 100644 --- a/src/librustc_trans/trans/collector.rs +++ b/src/librustc_trans/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::ty::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; @@ -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 diff --git a/src/librustc_trans/trans/common.rs b/src/librustc_trans/trans/common.rs index eb443a3b0b977..a6953f262c8ce 100644 --- a/src/librustc_trans/trans/common.rs +++ b/src/librustc_trans/trans/common.rs @@ -16,12 +16,12 @@ 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::ty::subst::Substs; +use rustc::ty::subst::Substs; use trans::abi::{Abi, FnType}; use trans::base; use trans::build; @@ -37,9 +37,9 @@ 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::{self, Ty, TyCtxt}; +use rustc::traits::{self, SelectionContext, ProjectionMode}; +use rustc::ty::fold::{TypeFolder, TypeFoldable}; use rustc_front::hir; use util::nodemap::NodeMap; diff --git a/src/librustc_trans/trans/consts.rs b/src/librustc_trans/trans/consts.rs index cb4092ffb9eba..9cdb168df8543 100644 --- a/src/librustc_trans/trans/consts.rs +++ b/src/librustc_trans/trans/consts.rs @@ -32,11 +32,11 @@ use trans::type_::Type; use trans::type_of; use trans::value::Value; use trans::Disr; -use middle::ty::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 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/trans/context.rs index db2b5b86a7e0b..2da61c49ed20d 100644 --- a/src/librustc_trans/trans/context.rs +++ b/src/librustc_trans/trans/context.rs @@ -14,7 +14,7 @@ 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; @@ -28,8 +28,8 @@ use trans::mir::CachedMir; use trans::monomorphize::Instance; use trans::collector::{TransItem, TransItemState}; use trans::type_::{Type, TypeNames}; -use middle::ty::subst::{Substs, VecPerParamSpace}; -use middle::ty::{self, Ty, TyCtxt}; +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/trans/controlflow.rs index 65f5ab1f22818..80ff11e968a18 100644 --- a/src/librustc_trans/trans/controlflow.rs +++ b/src/librustc_trans/trans/controlflow.rs @@ -11,7 +11,7 @@ use llvm::ValueRef; use middle::def::Def; use middle::lang_items::{PanicFnLangItem, PanicBoundsCheckFnLangItem}; -use middle::ty::subst::Substs; +use rustc::ty::subst::Substs; use trans::base::*; use trans::basic_block::BasicBlock; use trans::build::*; diff --git a/src/librustc_trans/trans/datum.rs b/src/librustc_trans/trans/datum.rs index 649f6180de20b..c0858a6d93bf6 100644 --- a/src/librustc_trans/trans/datum.rs +++ b/src/librustc_trans/trans/datum.rs @@ -102,7 +102,7 @@ use trans::cleanup::{CleanupMethods, DropHintDatum, DropHintMethods}; use trans::expr; use trans::tvec; use trans::value::Value; -use middle::ty::Ty; +use rustc::ty::Ty; use std::fmt; use syntax::ast; diff --git a/src/librustc_trans/trans/debuginfo/metadata.rs b/src/librustc_trans/trans/debuginfo/metadata.rs index a654a3f37c8da..bd2a8e0193dae 100644 --- a/src/librustc_trans/trans/debuginfo/metadata.rs +++ b/src/librustc_trans/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::ty::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 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/trans/debuginfo/mod.rs index dbba03cf4551f..198a9899fdae0 100644 --- a/src/librustc_trans/trans/debuginfo/mod.rs +++ b/src/librustc_trans/trans/debuginfo/mod.rs @@ -27,8 +27,8 @@ 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::ty::subst::{self, Substs}; +use rustc::infer::normalize_associated_type; +use rustc::ty::subst::{self, Substs}; use rustc_front; use rustc_front::hir; @@ -36,8 +36,8 @@ 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 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; diff --git a/src/librustc_trans/trans/debuginfo/type_names.rs b/src/librustc_trans/trans/debuginfo/type_names.rs index a051966795d55..fc9ace89ab7c3 100644 --- a/src/librustc_trans/trans/debuginfo/type_names.rs +++ b/src/librustc_trans/trans/debuginfo/type_names.rs @@ -14,9 +14,9 @@ use super::namespace::crate_root_namespace; use trans::common::CrateContext; use middle::def_id::DefId; -use middle::infer; -use middle::ty::subst; -use middle::ty::{self, Ty}; +use rustc::infer; +use rustc::ty::subst; +use rustc::ty::{self, Ty}; use rustc_front::hir; diff --git a/src/librustc_trans/trans/declare.rs b/src/librustc_trans/trans/declare.rs index e63f17770bcec..41a87f8d6de46 100644 --- a/src/librustc_trans/trans/declare.rs +++ b/src/librustc_trans/trans/declare.rs @@ -20,8 +20,8 @@ //! * 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 rustc::ty; +use rustc::infer; use trans::abi::{Abi, FnType}; use trans::attributes; use trans::context::CrateContext; diff --git a/src/librustc_trans/trans/disr.rs b/src/librustc_trans/trans/disr.rs index d74c1ac50ad74..fc79fa813aa5a 100644 --- a/src/librustc_trans/trans/disr.rs +++ b/src/librustc_trans/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/trans/expr.rs index 8b7527fd7de64..8f9f44fb2ddf8 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/trans/expr.rs @@ -54,7 +54,7 @@ use self::lazy_binop_ty::*; use llvm::{self, ValueRef, TypeKind}; use middle::const_qualif::ConstQualif; use middle::def::Def; -use middle::ty::subst::Substs; +use rustc::ty::subst::Substs; use trans::{_match, abi, adt, asm, base, closure, consts, controlflow}; use trans::base::*; use trans::build::*; @@ -70,12 +70,12 @@ 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::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; @@ -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/trans/glue.rs index 02a14715ab28b..596d8c7e9b7a2 100644 --- a/src/librustc_trans/trans/glue.rs +++ b/src/librustc_trans/trans/glue.rs @@ -18,9 +18,9 @@ use back::link; use llvm; use llvm::{ValueRef, get_param}; use middle::lang_items::ExchangeFreeFnLangItem; -use middle::ty::subst::{Substs}; -use middle::traits; -use middle::ty::{self, Ty, TyCtxt}; +use rustc::ty::subst::{Substs}; +use rustc::traits; +use rustc::ty::{self, Ty, TyCtxt}; use trans::abi::{Abi, FnType}; use trans::adt; use trans::adt::GetDtorType; // for tcx.dtor_type() diff --git a/src/librustc_trans/trans/inline.rs b/src/librustc_trans/trans/inline.rs index 87b4a572884ec..85a2adfe0df7b 100644 --- a/src/librustc_trans/trans/inline.rs +++ b/src/librustc_trans/trans/inline.rs @@ -11,7 +11,7 @@ use llvm::{AvailableExternallyLinkage, InternalLinkage, SetLinkage}; use middle::cstore::{CrateStore, FoundAst, InlinedItem}; use middle::def_id::DefId; -use middle::ty::subst::Substs; +use rustc::ty::subst::Substs; use trans::base::{push_ctxt, trans_item, trans_fn}; use trans::callee::Callee; use trans::common::*; diff --git a/src/librustc_trans/trans/intrinsic.rs b/src/librustc_trans/trans/intrinsic.rs index d3b84fbac1a9b..9577a1817d75d 100644 --- a/src/librustc_trans/trans/intrinsic.rs +++ b/src/librustc_trans/trans/intrinsic.rs @@ -15,9 +15,9 @@ use intrinsics::{self, Intrinsic}; use libc; use llvm; use llvm::{ValueRef, TypeKind}; -use middle::infer; -use middle::ty::subst; -use middle::ty::subst::FnSpace; +use rustc::infer; +use rustc::ty::subst; +use rustc::ty::subst::FnSpace; use trans::abi::{Abi, FnType}; use trans::adt; use trans::attributes; @@ -36,9 +36,9 @@ use trans::glue; use trans::type_of; use trans::machine; use trans::type_::Type; -use middle::ty::{self, Ty, TypeFoldable}; +use rustc::ty::{self, Ty, TypeFoldable}; use trans::Disr; -use middle::ty::subst::Substs; +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/trans/meth.rs b/src/librustc_trans/trans/meth.rs index d86f0c4e6dff3..86ddc86e40744 100644 --- a/src/librustc_trans/trans/meth.rs +++ b/src/librustc_trans/trans/meth.rs @@ -14,10 +14,10 @@ use arena::TypedArena; use back::link; use llvm::{ValueRef, get_params}; use middle::def_id::DefId; -use middle::infer; -use middle::ty::subst::{FnSpace, Subst, Substs}; -use middle::ty::subst; -use middle::traits::{self, ProjectionMode}; +use rustc::infer; +use rustc::ty::subst::{FnSpace, Subst, Substs}; +use rustc::ty::subst; +use rustc::traits::{self, ProjectionMode}; use trans::abi::FnType; use trans::base::*; use trans::build::*; @@ -33,7 +33,7 @@ use trans::machine; use trans::type_::Type; use trans::type_of::*; use trans::value::Value; -use middle::ty::{self, Ty, TyCtxt, TypeFoldable}; +use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; use syntax::ast::Name; use syntax::codemap::DUMMY_SP; diff --git a/src/librustc_trans/trans/mir/block.rs b/src/librustc_trans/trans/mir/block.rs index 7abaeb44c1c29..4f76fd5668456 100644 --- a/src/librustc_trans/trans/mir/block.rs +++ b/src/librustc_trans/trans/mir/block.rs @@ -9,7 +9,7 @@ // 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; diff --git a/src/librustc_trans/trans/mir/constant.rs b/src/librustc_trans/trans/mir/constant.rs index d4934718d75ed..1e5c1c2c55a00 100644 --- a/src/librustc_trans/trans/mir/constant.rs +++ b/src/librustc_trans/trans/mir/constant.rs @@ -9,7 +9,7 @@ // 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; diff --git a/src/librustc_trans/trans/mir/drop.rs b/src/librustc_trans/trans/mir/drop.rs index 2e13abec5e36c..cc033084ace60 100644 --- a/src/librustc_trans/trans/mir/drop.rs +++ b/src/librustc_trans/trans/mir/drop.rs @@ -9,7 +9,7 @@ // except according to those terms. use llvm::ValueRef; -use rustc::middle::ty::Ty; +use rustc::ty::Ty; use trans::adt; use trans::base; use trans::common::{self, BlockAndBuilder}; diff --git a/src/librustc_trans/trans/mir/lvalue.rs b/src/librustc_trans/trans/mir/lvalue.rs index ffc3b1206746e..6271ad8d8b846 100644 --- a/src/librustc_trans/trans/mir/lvalue.rs +++ b/src/librustc_trans/trans/mir/lvalue.rs @@ -9,7 +9,7 @@ // 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; diff --git a/src/librustc_trans/trans/mir/mod.rs b/src/librustc_trans/trans/mir/mod.rs index 9df2cb712b14f..ed4aa5fe58304 100644 --- a/src/librustc_trans/trans/mir/mod.rs +++ b/src/librustc_trans/trans/mir/mod.rs @@ -10,7 +10,7 @@ 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; diff --git a/src/librustc_trans/trans/mir/operand.rs b/src/librustc_trans/trans/mir/operand.rs index 6df4502fbc827..cc1446033de33 100644 --- a/src/librustc_trans/trans/mir/operand.rs +++ b/src/librustc_trans/trans/mir/operand.rs @@ -9,7 +9,7 @@ // 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}; diff --git a/src/librustc_trans/trans/mir/rvalue.rs b/src/librustc_trans/trans/mir/rvalue.rs index 17c8aef244bb9..a78d0da5be4a7 100644 --- a/src/librustc_trans/trans/mir/rvalue.rs +++ b/src/librustc_trans/trans/mir/rvalue.rs @@ -9,8 +9,8 @@ // 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; diff --git a/src/librustc_trans/trans/monomorphize.rs b/src/librustc_trans/trans/monomorphize.rs index 986d05af92f2c..a587de2e2db92 100644 --- a/src/librustc_trans/trans/monomorphize.rs +++ b/src/librustc_trans/trans/monomorphize.rs @@ -12,17 +12,17 @@ use back::link::exported_name; use llvm::ValueRef; use llvm; use middle::def_id::DefId; -use middle::infer::normalize_associated_type; -use middle::ty::subst; -use middle::ty::subst::{Subst, Substs}; -use middle::ty::fold::{TypeFolder, TypeFoldable}; +use rustc::infer::normalize_associated_type; +use rustc::ty::subst; +use rustc::ty::subst::{Subst, Substs}; +use rustc::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 rustc::ty::{self, Ty, TyCtxt}; use trans::Disr; use rustc::front::map as hir_map; use rustc::util::ppaux; diff --git a/src/librustc_trans/trans/tvec.rs b/src/librustc_trans/trans/tvec.rs index 7a0ca86f5a270..4a7404b1fbacd 100644 --- a/src/librustc_trans/trans/tvec.rs +++ b/src/librustc_trans/trans/tvec.rs @@ -27,7 +27,7 @@ use trans::machine::llsize_of_alloc; use trans::type_::Type; use trans::type_of; use trans::value::Value; -use middle::ty::{self, Ty}; +use rustc::ty::{self, Ty}; use rustc_front::hir; diff --git a/src/librustc_trans/trans/type_of.rs b/src/librustc_trans/trans/type_of.rs index e81039908c173..00f42a3b243c7 100644 --- a/src/librustc_trans/trans/type_of.rs +++ b/src/librustc_trans/trans/type_of.rs @@ -11,13 +11,13 @@ #![allow(non_camel_case_types)] use middle::def_id::DefId; -use middle::infer; -use middle::ty::subst; +use rustc::infer; +use rustc::ty::subst; use trans::abi::FnType; use trans::adt; use trans::common::*; use trans::machine; -use middle::ty::{self, Ty, TypeFoldable}; +use rustc::ty::{self, Ty, TypeFoldable}; use trans::type_::Type; @@ -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_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 3b3d2cbad10cc..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::ty::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 947488bde71dd..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::ty::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 54b2c8c59234e..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::ty::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 eee3fddcaea3d..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::ty::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 fd5d06ea9d19e..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::ty::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 9440be50e2106..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::ty::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 b8c1d43b7c475..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::ty::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 6648236f33ae0..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::ty::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 6be822aebcadf..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::ty::subst; -use middle::ty::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 b940c073a7fec..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::ty::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 8d025e164224d..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::ty::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 afbe511dda89f..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::ty::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 af33b6b394e5f..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::ty::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 af4975091055a..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::ty::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 a282165d1a041..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::ty::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 016ff3b5a067b..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::ty::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 ccc79b0748c20..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::ty::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 f46edb03b95b7..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::ty::subst; -use middle::ty::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 c5e925226d07e..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::ty::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 7148afb5e856c..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::ty::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/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index 75bf1036fa2cc..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::ty::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 675bebe91c312..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::ty::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 4cce835899203..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::ty::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/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/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/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}; From 00e77be6c98c6ba178093ea4b430901e15ce41fb Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Tue, 22 Mar 2016 18:40:24 +0200 Subject: [PATCH 29/35] rustc_trans: move save to librustc_save_analysis. --- mk/crates.mk | 5 +-- src/librustc_driver/Cargo.toml | 1 + src/librustc_driver/lib.rs | 3 +- src/librustc_save_analysis/Cargo.toml | 15 +++++++++ .../csv_dumper.rs | 2 +- .../save => librustc_save_analysis}/data.rs | 2 +- .../save => librustc_save_analysis}/dump.rs | 0 .../dump_visitor.rs | 7 ++-- .../mod.rs => librustc_save_analysis/lib.rs} | 32 +++++++++++++++---- .../span_utils.rs | 2 +- src/librustc_trans/lib.rs | 1 - 11 files changed, 52 insertions(+), 18 deletions(-) create mode 100644 src/librustc_save_analysis/Cargo.toml rename src/{librustc_trans/save => librustc_save_analysis}/csv_dumper.rs (99%) rename src/{librustc_trans/save => librustc_save_analysis}/data.rs (99%) rename src/{librustc_trans/save => librustc_save_analysis}/dump.rs (100%) rename src/{librustc_trans/save => librustc_save_analysis}/dump_visitor.rs (99%) rename src/{librustc_trans/save/mod.rs => librustc_save_analysis/lib.rs} (97%) rename src/{librustc_trans/save => librustc_save_analysis}/span_utils.rs (99%) 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/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/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_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 b9d9d58b5bdcd..997a635f69e0d 100644 --- a/src/librustc_trans/save/data.rs +++ b/src/librustc_save_analysis/data.rs @@ -15,7 +15,7 @@ use std::hash::Hasher; -use middle::def_id::DefId; +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 9d465d8704708..88b72ccf3296c 100644 --- a/src/librustc_trans/save/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -27,10 +27,9 @@ //! 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 rustc::middle::def::Def; +use rustc::middle::def_id::DefId; +use rustc::session::Session; use rustc::ty::{self, TyCtxt}; use std::collections::HashSet; 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 a037f8d6ea0eb..5dcb6473ec2e3 100644 --- a/src/librustc_trans/save/mod.rs +++ b/src/librustc_save_analysis/lib.rs @@ -8,19 +8,37 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![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 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 middle::def::Def; -use middle::def_id::DefId; 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::session::config::CrateType::CrateTypeExecutable; - use syntax::ast::{self, NodeId, PatKind}; use syntax::ast_util; use syntax::codemap::*; 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/lib.rs b/src/librustc_trans/lib.rs index f8bbde6010940..29fde20e626d4 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -76,7 +76,6 @@ pub mod back { pub mod diagnostics; pub mod trans; -pub mod save; pub mod lib { pub use llvm; From 7eb0547b5e5ab3c40b35ade1155bc1f58db729e6 Mon Sep 17 00:00:00 2001 From: Eduard Burtescu Date: Tue, 22 Mar 2016 19:23:36 +0200 Subject: [PATCH 30/35] rustc_trans: move the contents of the trans module to top-level. --- src/librustc_driver/driver.rs | 2 +- src/librustc_trans/{trans => }/_match.rs | 36 ++++---- src/librustc_trans/{trans => }/abi.rs | 32 ++++---- src/librustc_trans/{trans => }/adt.rs | 30 +++---- src/librustc_trans/{trans => }/asm.rs | 12 +-- .../{trans => }/assert_dep_graph.rs | 0 src/librustc_trans/{trans => }/attributes.rs | 2 +- src/librustc_trans/back/link.rs | 4 +- src/librustc_trans/back/linker.rs | 2 +- src/librustc_trans/back/write.rs | 2 +- src/librustc_trans/{trans => }/base.rs | 78 +++++++++--------- src/librustc_trans/{trans => }/basic_block.rs | 2 +- src/librustc_trans/{trans => }/build.rs | 10 +-- src/librustc_trans/{trans => }/builder.rs | 10 +-- .../{trans => }/cabi_aarch64.rs | 6 +- src/librustc_trans/{trans => }/cabi_arm.rs | 6 +- src/librustc_trans/{trans => }/cabi_asmjs.rs | 4 +- src/librustc_trans/{trans => }/cabi_mips.rs | 6 +- .../{trans => }/cabi_powerpc.rs | 6 +- .../{trans => }/cabi_powerpc64.rs | 6 +- src/librustc_trans/{trans => }/cabi_x86.rs | 4 +- src/librustc_trans/{trans => }/cabi_x86_64.rs | 6 +- .../{trans => }/cabi_x86_win64.rs | 4 +- src/librustc_trans/{trans => }/callee.rs | 52 ++++++------ src/librustc_trans/{trans => }/cleanup.rs | 18 ++-- src/librustc_trans/{trans => }/closure.rs | 32 ++++---- src/librustc_trans/{trans => }/collector.rs | 14 ++-- src/librustc_trans/{trans => }/common.rs | 44 +++++----- src/librustc_trans/{trans => }/consts.rs | 30 +++---- src/librustc_trans/{trans => }/context.rs | 22 ++--- src/librustc_trans/{trans => }/controlflow.rs | 33 ++++---- src/librustc_trans/{trans => }/datum.rs | 18 ++-- .../{trans => }/debuginfo/create_scope_map.rs | 2 +- .../{trans => }/debuginfo/doc.rs | 0 .../{trans => }/debuginfo/gdb.rs | 6 +- .../{trans => }/debuginfo/metadata.rs | 8 +- .../{trans => }/debuginfo/mod.rs | 9 +- .../{trans => }/debuginfo/namespace.rs | 2 +- .../{trans => }/debuginfo/source_loc.rs | 2 +- .../{trans => }/debuginfo/type_names.rs | 4 +- .../{trans => }/debuginfo/utils.rs | 6 +- src/librustc_trans/{trans => }/declare.rs | 8 +- src/librustc_trans/{trans => }/disr.rs | 0 src/librustc_trans/{trans => }/expr.rs | 34 ++++---- src/librustc_trans/{trans => }/glue.rs | 36 ++++---- src/librustc_trans/{trans => }/inline.rs | 6 +- src/librustc_trans/{trans => }/intrinsic.rs | 38 ++++----- src/librustc_trans/lib.rs | 68 ++++++++++++++- src/librustc_trans/{trans => }/machine.rs | 4 +- src/librustc_trans/{trans => }/macros.rs | 0 src/librustc_trans/{trans => }/meth.rs | 30 +++---- src/librustc_trans/{trans => }/mir/analyze.rs | 2 +- src/librustc_trans/{trans => }/mir/block.rs | 32 ++++---- .../{trans => }/mir/constant.rs | 14 ++-- src/librustc_trans/{trans => }/mir/drop.rs | 12 +-- src/librustc_trans/{trans => }/mir/lvalue.rs | 18 ++-- src/librustc_trans/{trans => }/mir/mod.rs | 4 +- src/librustc_trans/{trans => }/mir/operand.rs | 10 +-- src/librustc_trans/{trans => }/mir/rvalue.rs | 30 +++---- .../{trans => }/mir/statement.rs | 2 +- .../{trans => }/monomorphize.rs | 14 ++-- src/librustc_trans/trans/mod.rs | 82 ------------------- src/librustc_trans/{trans => }/tvec.rs | 30 +++---- src/librustc_trans/{trans => }/type_.rs | 2 +- src/librustc_trans/{trans => }/type_of.rs | 10 +-- src/librustc_trans/{trans => }/value.rs | 4 +- 66 files changed, 521 insertions(+), 541 deletions(-) rename src/librustc_trans/{trans => }/_match.rs (99%) rename src/librustc_trans/{trans => }/abi.rs (97%) rename src/librustc_trans/{trans => }/adt.rs (99%) rename src/librustc_trans/{trans => }/asm.rs (96%) rename src/librustc_trans/{trans => }/assert_dep_graph.rs (100%) rename src/librustc_trans/{trans => }/attributes.rs (99%) rename src/librustc_trans/{trans => }/base.rs (98%) rename src/librustc_trans/{trans => }/basic_block.rs (97%) rename src/librustc_trans/{trans => }/build.rs (99%) rename src/librustc_trans/{trans => }/builder.rs (99%) rename src/librustc_trans/{trans => }/cabi_aarch64.rs (98%) rename src/librustc_trans/{trans => }/cabi_arm.rs (98%) rename src/librustc_trans/{trans => }/cabi_asmjs.rs (95%) rename src/librustc_trans/{trans => }/cabi_mips.rs (97%) rename src/librustc_trans/{trans => }/cabi_powerpc.rs (97%) rename src/librustc_trans/{trans => }/cabi_powerpc64.rs (98%) rename src/librustc_trans/{trans => }/cabi_x86.rs (97%) rename src/librustc_trans/{trans => }/cabi_x86_64.rs (99%) rename src/librustc_trans/{trans => }/cabi_x86_win64.rs (95%) rename src/librustc_trans/{trans => }/callee.rs (98%) rename src/librustc_trans/{trans => }/cleanup.rs (99%) rename src/librustc_trans/{trans => }/closure.rs (97%) rename src/librustc_trans/{trans => }/collector.rs (99%) rename src/librustc_trans/{trans => }/common.rs (98%) rename src/librustc_trans/{trans => }/consts.rs (98%) rename src/librustc_trans/{trans => }/context.rs (99%) rename src/librustc_trans/{trans => }/controlflow.rs (96%) rename src/librustc_trans/{trans => }/datum.rs (99%) rename src/librustc_trans/{trans => }/debuginfo/create_scope_map.rs (99%) rename src/librustc_trans/{trans => }/debuginfo/doc.rs (100%) rename src/librustc_trans/{trans => }/debuginfo/gdb.rs (97%) rename src/librustc_trans/{trans => }/debuginfo/metadata.rs (99%) rename src/librustc_trans/{trans => }/debuginfo/mod.rs (99%) rename src/librustc_trans/{trans => }/debuginfo/namespace.rs (99%) rename src/librustc_trans/{trans => }/debuginfo/source_loc.rs (99%) rename src/librustc_trans/{trans => }/debuginfo/type_names.rs (98%) rename src/librustc_trans/{trans => }/debuginfo/utils.rs (97%) rename src/librustc_trans/{trans => }/declare.rs (98%) rename src/librustc_trans/{trans => }/disr.rs (100%) rename src/librustc_trans/{trans => }/expr.rs (99%) rename src/librustc_trans/{trans => }/glue.rs (97%) rename src/librustc_trans/{trans => }/inline.rs (98%) rename src/librustc_trans/{trans => }/intrinsic.rs (99%) rename src/librustc_trans/{trans => }/machine.rs (98%) rename src/librustc_trans/{trans => }/macros.rs (100%) rename src/librustc_trans/{trans => }/meth.rs (97%) rename src/librustc_trans/{trans => }/mir/analyze.rs (99%) rename src/librustc_trans/{trans => }/mir/block.rs (97%) rename src/librustc_trans/{trans => }/mir/constant.rs (96%) rename src/librustc_trans/{trans => }/mir/drop.rs (87%) rename src/librustc_trans/{trans => }/mir/lvalue.rs (97%) rename src/librustc_trans/{trans => }/mir/mod.rs (99%) rename src/librustc_trans/{trans => }/mir/operand.rs (98%) rename src/librustc_trans/{trans => }/mir/rvalue.rs (98%) rename src/librustc_trans/{trans => }/mir/statement.rs (98%) rename src/librustc_trans/{trans => }/monomorphize.rs (97%) delete mode 100644 src/librustc_trans/trans/mod.rs rename src/librustc_trans/{trans => }/tvec.rs (97%) rename src/librustc_trans/{trans => }/type_.rs (99%) rename src/librustc_trans/{trans => }/type_of.rs (99%) rename src/librustc_trans/{trans => }/value.rs (98%) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 3520d74187583..a8f0d4a661474 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -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_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 7794ac763c6a1..008323ee5bf31 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/_match.rs @@ -201,23 +201,23 @@ use middle::mem_categorization as mc; use middle::mem_categorization::Categorization; use middle::pat_util::*; use rustc::ty::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 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; @@ -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 8725392417288..dd72322997af8 100644 --- a/src/librustc_trans/trans/abi.rs +++ b/src/librustc_trans/abi.rs @@ -9,22 +9,22 @@ // 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 rustc::ty::{self, Ty}; 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 f14c1a573cccc..7c190c2ff7121 100644 --- a/src/librustc_trans/trans/adt.rs +++ b/src/librustc_trans/adt.rs @@ -53,21 +53,21 @@ 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 100% rename from src/librustc_trans/trans/assert_dep_graph.rs rename to src/librustc_trans/assert_dep_graph.rs 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 bcb56f4baf669..89c0a9da6f24c 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -25,7 +25,9 @@ use middle::cstore::{LinkagePreference, NativeLibraryKind}; use middle::dependency_format::Linkage; 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 ae7e6a924ab9c..34726720afcc3 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/base.rs @@ -51,45 +51,45 @@ 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 98% rename from src/librustc_trans/trans/callee.rs rename to src/librustc_trans/callee.rs index 4c9999d49624e..d530f31b676af 100644 --- a/src/librustc_trans/trans/callee.rs +++ b/src/librustc_trans/callee.rs @@ -27,32 +27,32 @@ 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 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; 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 78481e0ed9251..3a8dc144f9c7e 100644 --- a/src/librustc_trans/trans/cleanup.rs +++ b/src/librustc_trans/cleanup.rs @@ -120,16 +120,16 @@ 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 type_::Type; +use value::Value; use rustc::ty::{Ty, TyCtxt}; use std::fmt; diff --git a/src/librustc_trans/trans/closure.rs b/src/librustc_trans/closure.rs similarity index 97% rename from src/librustc_trans/trans/closure.rs rename to src/librustc_trans/closure.rs index 7b71109f5a2fa..dd8848eb6e72b 100644 --- a/src/librustc_trans/trans/closure.rs +++ b/src/librustc_trans/closure.rs @@ -14,22 +14,22 @@ use llvm::{ValueRef, get_param, get_params}; use middle::def_id::DefId; use rustc::infer; use rustc::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 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; 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 07989c4290db1..1d81d30fbf24d 100644 --- a/src/librustc_trans/trans/collector.rs +++ b/src/librustc_trans/collector.rs @@ -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}; @@ -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 a6953f262c8ce..c5d54e30f13fa 100644 --- a/src/librustc_trans/trans/common.rs +++ b/src/librustc_trans/common.rs @@ -22,21 +22,21 @@ use middle::def_id::DefId; use rustc::infer; use middle::lang_items::LangItem; use rustc::ty::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 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}; @@ -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 9cdb168df8543..b7d4ff3f42265 100644 --- a/src/librustc_trans/trans/consts.rs +++ b/src/librustc_trans/consts.rs @@ -17,21 +17,21 @@ 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 {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}; diff --git a/src/librustc_trans/trans/context.rs b/src/librustc_trans/context.rs similarity index 99% rename from src/librustc_trans/trans/context.rs rename to src/librustc_trans/context.rs index 2da61c49ed20d..d4e0aa3a4948c 100644 --- a/src/librustc_trans/trans/context.rs +++ b/src/librustc_trans/context.rs @@ -17,17 +17,17 @@ use middle::def_id::DefId; 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 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; diff --git a/src/librustc_trans/trans/controlflow.rs b/src/librustc_trans/controlflow.rs similarity index 96% rename from src/librustc_trans/trans/controlflow.rs rename to src/librustc_trans/controlflow.rs index 80ff11e968a18..04562087af7b7 100644 --- a/src/librustc_trans/trans/controlflow.rs +++ b/src/librustc_trans/controlflow.rs @@ -12,19 +12,18 @@ use llvm::ValueRef; use middle::def::Def; use middle::lang_items::{PanicFnLangItem, PanicBoundsCheckFnLangItem}; use rustc::ty::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 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 c0858a6d93bf6..6f96b5769bfe3 100644 --- a/src/librustc_trans/trans/datum.rs +++ b/src/librustc_trans/datum.rs @@ -93,15 +93,15 @@ 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 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; 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 bd2a8e0193dae..af7ccdb6cf51e 100644 --- a/src/librustc_trans/trans/debuginfo/metadata.rs +++ b/src/librustc_trans/debuginfo/metadata.rs @@ -29,10 +29,10 @@ use middle::pat_util; 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 {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; diff --git a/src/librustc_trans/trans/debuginfo/mod.rs b/src/librustc_trans/debuginfo/mod.rs similarity index 99% rename from src/librustc_trans/trans/debuginfo/mod.rs rename to src/librustc_trans/debuginfo/mod.rs index 198a9899fdae0..66e33698389ae 100644 --- a/src/librustc_trans/trans/debuginfo/mod.rs +++ b/src/librustc_trans/debuginfo/mod.rs @@ -32,10 +32,9 @@ 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 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}; @@ -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 fc9ace89ab7c3..71dd3e432df0d 100644 --- a/src/librustc_trans/trans/debuginfo/type_names.rs +++ b/src/librustc_trans/debuginfo/type_names.rs @@ -12,7 +12,7 @@ use super::namespace::crate_root_namespace; -use trans::common::CrateContext; +use common::CrateContext; use middle::def_id::DefId; use rustc::infer; use rustc::ty::subst; @@ -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 98% rename from src/librustc_trans/trans/declare.rs rename to src/librustc_trans/declare.rs index 41a87f8d6de46..28a70fd5e0bde 100644 --- a/src/librustc_trans/trans/declare.rs +++ b/src/librustc_trans/declare.rs @@ -22,10 +22,10 @@ use llvm::{self, ValueRef}; use rustc::ty; use rustc::infer; -use trans::abi::{Abi, FnType}; -use trans::attributes; -use trans::context::CrateContext; -use trans::type_::Type; +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 100% rename from src/librustc_trans/trans/disr.rs rename to src/librustc_trans/disr.rs 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 8f9f44fb2ddf8..b2e2e93a2be4c 100644 --- a/src/librustc_trans/trans/expr.rs +++ b/src/librustc_trans/expr.rs @@ -55,21 +55,21 @@ use llvm::{self, ValueRef, TypeKind}; use middle::const_qualif::ConstQualif; use middle::def::Def; use rustc::ty::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 {_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; @@ -77,8 +77,8 @@ 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; 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 596d8c7e9b7a2..c9f31f7642fcd 100644 --- a/src/librustc_trans/trans/glue.rs +++ b/src/librustc_trans/glue.rs @@ -21,24 +21,24 @@ use middle::lang_items::ExchangeFreeFnLangItem; use rustc::ty::subst::{Substs}; use rustc::traits; use rustc::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 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 85a2adfe0df7b..50579c7de99bb 100644 --- a/src/librustc_trans/trans/inline.rs +++ b/src/librustc_trans/inline.rs @@ -12,9 +12,9 @@ use llvm::{AvailableExternallyLinkage, InternalLinkage, SetLinkage}; use middle::cstore::{CrateStore, FoundAst, InlinedItem}; use middle::def_id::DefId; use rustc::ty::subst::Substs; -use trans::base::{push_ctxt, trans_item, trans_fn}; -use trans::callee::Callee; -use trans::common::*; +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 9577a1817d75d..b7b74e44d3ed4 100644 --- a/src/librustc_trans/trans/intrinsic.rs +++ b/src/librustc_trans/intrinsic.rs @@ -18,26 +18,26 @@ use llvm::{ValueRef, TypeKind}; use rustc::infer; use rustc::ty::subst; use rustc::ty::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 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 trans::Disr; +use Disr; use rustc::ty::subst::Substs; use rustc::dep_graph::DepNode; use rustc_front::hir; diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 29fde20e626d4..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,10 +78,69 @@ pub mod back { pub mod diagnostics; -pub mod trans; +#[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 97% rename from src/librustc_trans/trans/meth.rs rename to src/librustc_trans/meth.rs index 86ddc86e40744..2a0b60842310e 100644 --- a/src/librustc_trans/trans/meth.rs +++ b/src/librustc_trans/meth.rs @@ -18,21 +18,21 @@ use rustc::infer; use rustc::ty::subst::{FnSpace, Subst, Substs}; use rustc::ty::subst; use rustc::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 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; 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 4f76fd5668456..a60b03dd72413 100644 --- a/src/librustc_trans/trans/mir/block.rs +++ b/src/librustc_trans/mir/block.rs @@ -11,19 +11,19 @@ use llvm::{self, BasicBlockRef, ValueRef, OperandBundleDef}; 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 1e5c1c2c55a00..be1c3f3b56b2c 100644 --- a/src/librustc_trans/trans/mir/constant.rs +++ b/src/librustc_trans/mir/constant.rs @@ -13,14 +13,14 @@ 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 87% rename from src/librustc_trans/trans/mir/drop.rs rename to src/librustc_trans/mir/drop.rs index cc033084ace60..623cd5a6f8cc9 100644 --- a/src/librustc_trans/trans/mir/drop.rs +++ b/src/librustc_trans/mir/drop.rs @@ -10,12 +10,12 @@ use llvm::ValueRef; use rustc::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 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 6271ad8d8b846..f5f8c23a9824b 100644 --- a/src/librustc_trans/trans/mir/lvalue.rs +++ b/src/librustc_trans/mir/lvalue.rs @@ -12,16 +12,16 @@ use llvm::ValueRef; 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 99% rename from src/librustc_trans/trans/mir/mod.rs rename to src/librustc_trans/mir/mod.rs index ed4aa5fe58304..61536f3ecae87 100644 --- a/src/librustc_trans/trans/mir/mod.rs +++ b/src/librustc_trans/mir/mod.rs @@ -13,8 +13,8 @@ use llvm::{self, ValueRef}; 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 98% rename from src/librustc_trans/trans/mir/operand.rs rename to src/librustc_trans/mir/operand.rs index cc1446033de33..3b909353f7345 100644 --- a/src/librustc_trans/trans/mir/operand.rs +++ b/src/librustc_trans/mir/operand.rs @@ -11,11 +11,11 @@ use llvm::ValueRef; 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 a78d0da5be4a7..47fa618ebad83 100644 --- a/src/librustc_trans/trans/mir/rvalue.rs +++ b/src/librustc_trans/mir/rvalue.rs @@ -15,20 +15,20 @@ 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 97% rename from src/librustc_trans/trans/monomorphize.rs rename to src/librustc_trans/monomorphize.rs index a587de2e2db92..0c49c37220965 100644 --- a/src/librustc_trans/trans/monomorphize.rs +++ b/src/librustc_trans/monomorphize.rs @@ -16,14 +16,14 @@ use rustc::infer::normalize_associated_type; use rustc::ty::subst; use rustc::ty::subst::{Subst, Substs}; use rustc::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 attributes; +use base::{push_ctxt}; +use base::trans_fn; +use base; +use common::*; +use declare; use rustc::ty::{self, Ty, TyCtxt}; -use trans::Disr; +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 4a7404b1fbacd..c42bad0bc0bd1 100644 --- a/src/librustc_trans/trans/tvec.rs +++ b/src/librustc_trans/tvec.rs @@ -12,21 +12,21 @@ 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 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 99% rename from src/librustc_trans/trans/type_of.rs rename to src/librustc_trans/type_of.rs index 00f42a3b243c7..02f659fdc2e6f 100644 --- a/src/librustc_trans/trans/type_of.rs +++ b/src/librustc_trans/type_of.rs @@ -13,13 +13,13 @@ use middle::def_id::DefId; use rustc::infer; use rustc::ty::subst; -use trans::abi::FnType; -use trans::adt; -use trans::common::*; -use trans::machine; +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; 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; From c7049f64501072b739821f03b0e91fee74dc16ff Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 25 Mar 2016 17:33:10 +0000 Subject: [PATCH 31/35] Fix the name of the 'check-cargotest' step --- src/bootstrap/mk/Makefile.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From 944dc4aa654633c0b027fa6fe30f5ed0690a73b9 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 25 Mar 2016 14:39:24 -0400 Subject: [PATCH 32/35] fix cargo.toml for new dependency --- src/libsyntax_ext/Cargo.toml | 1 + 1 file changed, 1 insertion(+) 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" } From 2536ae55a4fe3bb9d96ddd53e790631e76a6a11b Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 25 Mar 2016 15:14:45 -0400 Subject: [PATCH 33/35] fix error message --- src/test/compile-fail/rfc1445/match-forbidden-without-eq.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/compile-fail/rfc1445/match-forbidden-without-eq.rs b/src/test/compile-fail/rfc1445/match-forbidden-without-eq.rs index b3e465688fdd4..c573e3e8e28b2 100644 --- a/src/test/compile-fail/rfc1445/match-forbidden-without-eq.rs +++ b/src/test/compile-fail/rfc1445/match-forbidden-without-eq.rs @@ -24,7 +24,7 @@ fn main() { let y = Foo { x: 1 }; match y { FOO => { } - //~^ ERROR must be annotated with `#[derive(Eq)]` + //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` //~| WARNING will become a hard error _ => { } } From 88ab9382ae79346969d79c15a27c77368a928dd8 Mon Sep 17 00:00:00 2001 From: "Novotnik, Petr" Date: Fri, 25 Mar 2016 21:35:10 +0100 Subject: [PATCH 34/35] Avoid page reload upon hitting "S" when browing in local mode --- src/librustdoc/html/static/main.js | 2 -- 1 file changed, 2 deletions(-) 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'); From a755a6777f1ee90338e0eb0c62690c72f482a88e Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 17 Mar 2016 19:01:50 -0700 Subject: [PATCH 35/35] std: Rewrite Once with poisoning This commit rewrites the `std::sync::Once` primitive with poisoning in mind in light of #31688. Currently a panic in the initialization closure will cause future initialization closures to run, but the purpose of a Once is usually to initialize some global state so it's highly likely that the global state is corrupt if a panic happened. The same strategy of a mutex is taken where a panic is propagated by default. A new API, `call_once_force`, was added to subvert panics like is available on Mutex as well (for when panicking is handled internally). Adding this support was a significant enough change to the implementation that it was just completely rewritten from scratch, primarily to avoid using a `StaticMutex` which needs to have `destroy()` called on it at some point (a pain to do). Closes #31688 --- src/libstd/sync/once.rs | 419 ++++++++++++++++++++++++++++++++++------ 1 file changed, 363 insertions(+), 56 deletions(-) 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()); + + } }