diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs index f97522140a8a1..6214e1ce24587 100644 --- a/src/liballoc/collections/binary_heap.rs +++ b/src/liballoc/collections/binary_heap.rs @@ -248,14 +248,18 @@ impl Drop for PeekMut<'_, T> { impl Deref for PeekMut<'_, T> { type Target = T; fn deref(&self) -> &T { - &self.heap.data[0] + debug_assert!(!self.heap.is_empty()); + // SAFE: PeekMut is only instantiated for non-empty heaps + unsafe { self.heap.data.get_unchecked(0) } } } #[stable(feature = "binary_heap_peek_mut", since = "1.12.0")] impl DerefMut for PeekMut<'_, T> { fn deref_mut(&mut self) -> &mut T { - &mut self.heap.data[0] + debug_assert!(!self.heap.is_empty()); + // SAFE: PeekMut is only instantiated for non-empty heaps + unsafe { self.heap.data.get_unchecked_mut(0) } } } @@ -865,7 +869,8 @@ impl<'a, T> Hole<'a, T> { #[inline] unsafe fn new(data: &'a mut [T], pos: usize) -> Self { debug_assert!(pos < data.len()); - let elt = ptr::read(&data[pos]); + // SAFE: pos should be inside the slice + let elt = ptr::read(data.get_unchecked(pos)); Hole { data, elt: ManuallyDrop::new(elt), diff --git a/src/libcore/iter/sources.rs b/src/libcore/iter/sources.rs index 2b741e66170aa..6f45f082d6a37 100644 --- a/src/libcore/iter/sources.rs +++ b/src/libcore/iter/sources.rs @@ -504,10 +504,8 @@ pub fn once_with A>(gen: F) -> OnceWith { /// [`FusedIterator`]: trait.FusedIterator.html /// [`Iterator::size_hint`]: trait.Iterator.html#method.size_hint /// -/// The closure can use its its captures and environment -/// to track state across iterations. -/// Depending on how the iterator is used, -/// this may require specifying the `move` keyword on the closure. +/// The closure can use captures and its environment to track state across iterations. Depending on +/// how the iterator is used, this may require specifying the `move` keyword on the closure. /// /// # Examples /// diff --git a/src/libproc_macro/Cargo.toml b/src/libproc_macro/Cargo.toml index f903f79f9afc0..b3d0ee94f0e12 100644 --- a/src/libproc_macro/Cargo.toml +++ b/src/libproc_macro/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "proc_macro" version = "0.0.0" +edition = "2018" [lib] path = "lib.rs" diff --git a/src/libproc_macro/bridge/buffer.rs b/src/libproc_macro/bridge/buffer.rs index 8bc4f0fec85a8..0d8cc552d61ab 100644 --- a/src/libproc_macro/bridge/buffer.rs +++ b/src/libproc_macro/bridge/buffer.rs @@ -6,7 +6,7 @@ use std::ops::{Deref, DerefMut}; use std::slice; #[repr(C)] -struct Slice<'a, T: 'a> { +struct Slice<'a, T> { data: &'a [T; 0], len: usize, } @@ -42,7 +42,7 @@ pub struct Buffer { data: *mut T, len: usize, capacity: usize, - extend_from_slice: extern "C" fn(Buffer, Slice) -> Buffer, + extend_from_slice: extern "C" fn(Buffer, Slice<'_, T>) -> Buffer, drop: extern "C" fn(Buffer), } @@ -139,7 +139,7 @@ impl From> for Buffer { } } - extern "C" fn extend_from_slice(b: Buffer, xs: Slice) -> Buffer { + extern "C" fn extend_from_slice(b: Buffer, xs: Slice<'_, T>) -> Buffer { let mut v = to_vec(b); v.extend_from_slice(&xs); Buffer::from(v) diff --git a/src/libproc_macro/bridge/client.rs b/src/libproc_macro/bridge/client.rs index 3095c8041f2c1..b198bdb144699 100644 --- a/src/libproc_macro/bridge/client.rs +++ b/src/libproc_macro/bridge/client.rs @@ -66,7 +66,7 @@ macro_rules! define_handles { impl DecodeMut<'_, '_, HandleStore>> for Marked { - fn decode(r: &mut Reader, s: &mut HandleStore>) -> Self { + fn decode(r: &mut Reader<'_>, s: &mut HandleStore>) -> Self { s.$oty.take(handle::Handle::decode(r, &mut ())) } } @@ -80,7 +80,7 @@ macro_rules! define_handles { impl Decode<'_, 's, HandleStore>> for &'s Marked { - fn decode(r: &mut Reader, s: &'s HandleStore>) -> Self { + fn decode(r: &mut Reader<'_>, s: &'s HandleStore>) -> Self { &s.$oty[handle::Handle::decode(r, &mut ())] } } @@ -94,7 +94,10 @@ macro_rules! define_handles { impl DecodeMut<'_, 's, HandleStore>> for &'s mut Marked { - fn decode(r: &mut Reader, s: &'s mut HandleStore>) -> Self { + fn decode( + r: &mut Reader<'_>, + s: &'s mut HandleStore> + ) -> Self { &mut s.$oty[handle::Handle::decode(r, &mut ())] } } @@ -108,7 +111,7 @@ macro_rules! define_handles { } impl DecodeMut<'_, '_, S> for $oty { - fn decode(r: &mut Reader, s: &mut S) -> Self { + fn decode(r: &mut Reader<'_>, s: &mut S) -> Self { $oty(handle::Handle::decode(r, s)) } } @@ -130,7 +133,7 @@ macro_rules! define_handles { impl DecodeMut<'_, '_, HandleStore>> for Marked { - fn decode(r: &mut Reader, s: &mut HandleStore>) -> Self { + fn decode(r: &mut Reader<'_>, s: &mut HandleStore>) -> Self { s.$ity.copy(handle::Handle::decode(r, &mut ())) } } @@ -144,7 +147,7 @@ macro_rules! define_handles { } impl DecodeMut<'_, '_, S> for $ity { - fn decode(r: &mut Reader, s: &mut S) -> Self { + fn decode(r: &mut Reader<'_>, s: &mut S) -> Self { $ity(handle::Handle::decode(r, s)) } } @@ -200,7 +203,7 @@ impl Clone for Literal { // FIXME(eddyb) `Literal` should not expose internal `Debug` impls. impl fmt::Debug for Literal { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(&self.debug()) } } @@ -212,7 +215,7 @@ impl Clone for SourceFile { } impl fmt::Debug for Span { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(&self.debug()) } } @@ -275,7 +278,7 @@ impl BridgeState<'_> { /// /// N.B., while `f` is running, the thread-local state /// is `BridgeState::InUse`. - fn with(f: impl FnOnce(&mut BridgeState) -> R) -> R { + fn with(f: impl FnOnce(&mut BridgeState<'_>) -> R) -> R { BRIDGE_STATE.with(|state| { state.replace(BridgeState::InUse, |mut state| { // FIXME(#52812) pass `f` directly to `replace` when `RefMutL` is gone @@ -306,7 +309,7 @@ impl Bridge<'_> { BRIDGE_STATE.with(|state| state.set(BridgeState::Connected(self), f)) } - fn with(f: impl FnOnce(&mut Bridge) -> R) -> R { + fn with(f: impl FnOnce(&mut Bridge<'_>) -> R) -> R { BridgeState::with(|state| match state { BridgeState::NotConnected => { panic!("procedural macro API is used outside of a procedural macro"); @@ -331,15 +334,15 @@ impl Bridge<'_> { #[derive(Copy, Clone)] pub struct Client { pub(super) get_handle_counters: extern "C" fn() -> &'static HandleCounters, - pub(super) run: extern "C" fn(Bridge, F) -> Buffer, + pub(super) run: extern "C" fn(Bridge<'_>, F) -> Buffer, pub(super) f: F, } // FIXME(#53451) public to work around `Cannot create local mono-item` ICE, // affecting not only the function itself, but also the `BridgeState` `thread_local!`. pub extern "C" fn __run_expand1( - mut bridge: Bridge, - f: fn(::TokenStream) -> ::TokenStream, + mut bridge: Bridge<'_>, + f: fn(crate::TokenStream) -> crate::TokenStream, ) -> Buffer { // The initial `cached_buffer` contains the input. let mut b = bridge.cached_buffer.take(); @@ -352,7 +355,7 @@ pub extern "C" fn __run_expand1( // Put the `cached_buffer` back in the `Bridge`, for requests. Bridge::with(|bridge| bridge.cached_buffer = b.take()); - let output = f(::TokenStream(input)).0; + let output = f(crate::TokenStream(input)).0; // Take the `cached_buffer` back out, for the output value. b = Bridge::with(|bridge| bridge.cached_buffer.take()); @@ -378,8 +381,8 @@ pub extern "C" fn __run_expand1( b } -impl Client ::TokenStream> { - pub const fn expand1(f: fn(::TokenStream) -> ::TokenStream) -> Self { +impl Client crate::TokenStream> { + pub const fn expand1(f: fn(crate::TokenStream) -> crate::TokenStream) -> Self { Client { get_handle_counters: HandleCounters::get, run: __run_expand1, @@ -391,8 +394,8 @@ impl Client ::TokenStream> { // FIXME(#53451) public to work around `Cannot create local mono-item` ICE, // affecting not only the function itself, but also the `BridgeState` `thread_local!`. pub extern "C" fn __run_expand2( - mut bridge: Bridge, - f: fn(::TokenStream, ::TokenStream) -> ::TokenStream, + mut bridge: Bridge<'_>, + f: fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream, ) -> Buffer { // The initial `cached_buffer` contains the input. let mut b = bridge.cached_buffer.take(); @@ -406,7 +409,7 @@ pub extern "C" fn __run_expand2( // Put the `cached_buffer` back in the `Bridge`, for requests. Bridge::with(|bridge| bridge.cached_buffer = b.take()); - let output = f(::TokenStream(input), ::TokenStream(input2)).0; + let output = f(crate::TokenStream(input), crate::TokenStream(input2)).0; // Take the `cached_buffer` back out, for the output value. b = Bridge::with(|bridge| bridge.cached_buffer.take()); @@ -432,8 +435,10 @@ pub extern "C" fn __run_expand2( b } -impl Client ::TokenStream> { - pub const fn expand2(f: fn(::TokenStream, ::TokenStream) -> ::TokenStream) -> Self { +impl Client crate::TokenStream> { + pub const fn expand2( + f: fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream + ) -> Self { Client { get_handle_counters: HandleCounters::get, run: __run_expand2, @@ -448,17 +453,17 @@ pub enum ProcMacro { CustomDerive { trait_name: &'static str, attributes: &'static [&'static str], - client: Client ::TokenStream>, + client: Client crate::TokenStream>, }, Attr { name: &'static str, - client: Client ::TokenStream>, + client: Client crate::TokenStream>, }, Bang { name: &'static str, - client: Client ::TokenStream>, + client: Client crate::TokenStream>, }, } @@ -466,7 +471,7 @@ impl ProcMacro { pub const fn custom_derive( trait_name: &'static str, attributes: &'static [&'static str], - expand: fn(::TokenStream) -> ::TokenStream, + expand: fn(crate::TokenStream) -> crate::TokenStream, ) -> Self { ProcMacro::CustomDerive { trait_name, @@ -477,7 +482,7 @@ impl ProcMacro { pub const fn attr( name: &'static str, - expand: fn(::TokenStream, ::TokenStream) -> ::TokenStream, + expand: fn(crate::TokenStream, crate::TokenStream) -> crate::TokenStream, ) -> Self { ProcMacro::Attr { name, @@ -485,7 +490,10 @@ impl ProcMacro { } } - pub const fn bang(name: &'static str, expand: fn(::TokenStream) -> ::TokenStream) -> Self { + pub const fn bang( + name: &'static str, + expand: fn(crate::TokenStream) -> crate::TokenStream + ) -> Self { ProcMacro::Bang { name, client: Client::expand1(expand), diff --git a/src/libproc_macro/bridge/mod.rs b/src/libproc_macro/bridge/mod.rs index 6c3e534bf9197..3173651b03951 100644 --- a/src/libproc_macro/bridge/mod.rs +++ b/src/libproc_macro/bridge/mod.rs @@ -17,7 +17,7 @@ use std::panic; use std::sync::atomic::AtomicUsize; use std::sync::Once; use std::thread; -use {Delimiter, Level, LineColumn, Spacing}; +use crate::{Delimiter, Level, LineColumn, Spacing}; /// Higher-order macro describing the server RPC API, allowing automatic /// generation of type-safe Rust APIs, both client-side and server-side. @@ -196,9 +196,9 @@ mod scoped_cell; #[forbid(unsafe_code)] pub mod server; -use self::buffer::Buffer; -pub use self::rpc::PanicMessage; -use self::rpc::{Decode, DecodeMut, Encode, Reader, Writer}; +use buffer::Buffer; +pub use rpc::PanicMessage; +use rpc::{Decode, DecodeMut, Encode, Reader, Writer}; /// An active connection between a server and a client. /// The server creates the bridge (`Bridge::run_server` in `server.rs`), diff --git a/src/libproc_macro/bridge/rpc.rs b/src/libproc_macro/bridge/rpc.rs index 74ae711a47372..a3bc0d2290846 100644 --- a/src/libproc_macro/bridge/rpc.rs +++ b/src/libproc_macro/bridge/rpc.rs @@ -40,7 +40,7 @@ macro_rules! rpc_encode_decode { } impl DecodeMut<'_, '_, S> for $ty { - fn decode(r: &mut Reader, s: &mut S) -> Self { + fn decode(r: &mut Reader<'_>, s: &mut S) -> Self { let mut byte = 0x80; let mut v = 0; let mut shift = 0; @@ -61,7 +61,7 @@ macro_rules! rpc_encode_decode { } impl DecodeMut<'_, '_, S> for $name { - fn decode(r: &mut Reader, s: &mut S) -> Self { + fn decode(r: &mut Reader<'_>, s: &mut S) -> Self { $name { $($field: DecodeMut::decode(r, s)),* } @@ -119,7 +119,7 @@ impl Encode for () { } impl DecodeMut<'_, '_, S> for () { - fn decode(_: &mut Reader, _: &mut S) -> Self {} + fn decode(_: &mut Reader<'_>, _: &mut S) -> Self {} } impl Encode for u8 { @@ -129,7 +129,7 @@ impl Encode for u8 { } impl DecodeMut<'_, '_, S> for u8 { - fn decode(r: &mut Reader, _: &mut S) -> Self { + fn decode(r: &mut Reader<'_>, _: &mut S) -> Self { let x = r[0]; *r = &r[1..]; x @@ -146,7 +146,7 @@ impl Encode for bool { } impl DecodeMut<'_, '_, S> for bool { - fn decode(r: &mut Reader, s: &mut S) -> Self { + fn decode(r: &mut Reader<'_>, s: &mut S) -> Self { match u8::decode(r, s) { 0 => false, 1 => true, @@ -162,7 +162,7 @@ impl Encode for char { } impl DecodeMut<'_, '_, S> for char { - fn decode(r: &mut Reader, s: &mut S) -> Self { + fn decode(r: &mut Reader<'_>, s: &mut S) -> Self { char::from_u32(u32::decode(r, s)).unwrap() } } @@ -174,7 +174,7 @@ impl Encode for NonZeroU32 { } impl DecodeMut<'_, '_, S> for NonZeroU32 { - fn decode(r: &mut Reader, s: &mut S) -> Self { + fn decode(r: &mut Reader<'_>, s: &mut S) -> Self { Self::new(u32::decode(r, s)).unwrap() } } @@ -251,7 +251,7 @@ impl Encode for String { } impl DecodeMut<'_, '_, S> for String { - fn decode(r: &mut Reader, s: &mut S) -> Self { + fn decode(r: &mut Reader<'_>, s: &mut S) -> Self { <&str>::decode(r, s).to_string() } } @@ -306,7 +306,7 @@ impl Encode for PanicMessage { } impl DecodeMut<'_, '_, S> for PanicMessage { - fn decode(r: &mut Reader, s: &mut S) -> Self { + fn decode(r: &mut Reader<'_>, s: &mut S) -> Self { match Option::::decode(r, s) { Some(s) => PanicMessage::String(s), None => PanicMessage::Unknown, diff --git a/src/libproc_macro/bridge/server.rs b/src/libproc_macro/bridge/server.rs index 9a7cb1318dbe4..75806eb9d1760 100644 --- a/src/libproc_macro/bridge/server.rs +++ b/src/libproc_macro/bridge/server.rs @@ -131,7 +131,7 @@ pub trait ExecutionStrategy { &self, dispatcher: &mut impl DispatcherTrait, input: Buffer, - run_client: extern "C" fn(Bridge, D) -> Buffer, + run_client: extern "C" fn(Bridge<'_>, D) -> Buffer, client_data: D, ) -> Buffer; } @@ -143,7 +143,7 @@ impl ExecutionStrategy for SameThread { &self, dispatcher: &mut impl DispatcherTrait, input: Buffer, - run_client: extern "C" fn(Bridge, D) -> Buffer, + run_client: extern "C" fn(Bridge<'_>, D) -> Buffer, client_data: D, ) -> Buffer { let mut dispatch = |b| dispatcher.dispatch(b); @@ -168,7 +168,7 @@ impl ExecutionStrategy for CrossThread1 { &self, dispatcher: &mut impl DispatcherTrait, input: Buffer, - run_client: extern "C" fn(Bridge, D) -> Buffer, + run_client: extern "C" fn(Bridge<'_>, D) -> Buffer, client_data: D, ) -> Buffer { use std::sync::mpsc::channel; @@ -206,7 +206,7 @@ impl ExecutionStrategy for CrossThread2 { &self, dispatcher: &mut impl DispatcherTrait, input: Buffer, - run_client: extern "C" fn(Bridge, D) -> Buffer, + run_client: extern "C" fn(Bridge<'_>, D) -> Buffer, client_data: D, ) -> Buffer { use std::sync::{Arc, Mutex}; @@ -273,7 +273,7 @@ fn run_server< handle_counters: &'static client::HandleCounters, server: S, input: I, - run_client: extern "C" fn(Bridge, D) -> Buffer, + run_client: extern "C" fn(Bridge<'_>, D) -> Buffer, client_data: D, ) -> Result { let mut dispatcher = Dispatcher { @@ -289,7 +289,7 @@ fn run_server< Result::decode(&mut &b[..], &mut dispatcher.handle_store) } -impl client::Client ::TokenStream> { +impl client::Client crate::TokenStream> { pub fn run( &self, strategy: &impl ExecutionStrategy, @@ -313,7 +313,7 @@ impl client::Client ::TokenStream> { } } -impl client::Client ::TokenStream> { +impl client::Client crate::TokenStream> { pub fn run( &self, strategy: &impl ExecutionStrategy, diff --git a/src/libproc_macro/diagnostic.rs b/src/libproc_macro/diagnostic.rs index 64d0c3893c730..7a0c9419f6234 100644 --- a/src/libproc_macro/diagnostic.rs +++ b/src/libproc_macro/diagnostic.rs @@ -1,4 +1,4 @@ -use Span; +use crate::Span; /// An enum representing a diagnostic level. #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] @@ -80,7 +80,7 @@ macro_rules! diagnostic_child_methods { /// Iterator over the children diagnostics of a `Diagnostic`. #[derive(Debug, Clone)] #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] -pub struct Children<'a>(::std::slice::Iter<'a, Diagnostic>); +pub struct Children<'a>(std::slice::Iter<'a, Diagnostic>); #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] impl<'a> Iterator for Children<'a> { @@ -161,22 +161,22 @@ impl Diagnostic { /// Returns an iterator over the children diagnostics of `self`. #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] - pub fn children(&self) -> Children { + pub fn children(&self) -> Children<'_> { Children(self.children.iter()) } /// Emit the diagnostic. #[unstable(feature = "proc_macro_diagnostic", issue = "54140")] pub fn emit(self) { - fn to_internal(spans: Vec) -> ::bridge::client::MultiSpan { - let mut multi_span = ::bridge::client::MultiSpan::new(); + fn to_internal(spans: Vec) -> crate::bridge::client::MultiSpan { + let mut multi_span = crate::bridge::client::MultiSpan::new(); for span in spans { multi_span.push(span.0); } multi_span } - let mut diag = ::bridge::client::Diagnostic::new( + let mut diag = crate::bridge::client::Diagnostic::new( self.level, &self.message[..], to_internal(self.spans), diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 868190d01057d..bb6f5e234f7c2 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -17,7 +17,8 @@ test(no_crate_inject, attr(deny(warnings))), test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))] -#![feature(nll)] +#![deny(rust_2018_idioms)] + #![feature(staged_api)] #![feature(const_fn)] #![feature(extern_types)] @@ -114,7 +115,7 @@ impl ToString for TokenStream { /// with `Delimiter::None` delimiters and negative numeric literals. #[stable(feature = "proc_macro_lib", since = "1.15.0")] impl fmt::Display for TokenStream { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(&self.to_string()) } } @@ -122,7 +123,7 @@ impl fmt::Display for TokenStream { /// Prints token in a form convenient for debugging. #[stable(feature = "proc_macro_lib", since = "1.15.0")] impl fmt::Debug for TokenStream { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("TokenStream ")?; f.debug_list().entries(self.clone()).finish() } @@ -183,7 +184,7 @@ impl Extend for TokenStream { /// Public implementation details for the `TokenStream` type, such as iterators. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] pub mod token_stream { - use {bridge, Group, Ident, Literal, Punct, TokenTree, TokenStream}; + use crate::{bridge, Group, Ident, Literal, Punct, TokenTree, TokenStream}; /// An iterator over `TokenStream`'s `TokenTree`s. /// The iteration is "shallow", e.g., the iterator doesn't recurse into delimited groups, @@ -340,7 +341,7 @@ impl Span { /// Prints a span in a form convenient for debugging. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Debug for Span { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.0.fmt(f) } } @@ -398,7 +399,7 @@ impl SourceFile { #[unstable(feature = "proc_macro_span", issue = "54725")] impl fmt::Debug for SourceFile { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("SourceFile") .field("path", &self.path()) .field("is_real", &self.is_real()) @@ -483,7 +484,7 @@ impl TokenTree { /// Prints token tree in a form convenient for debugging. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Debug for TokenTree { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // Each of these has the name in the struct type in the derived debug, // so don't bother with an extra layer of indirection match *self { @@ -542,7 +543,7 @@ impl ToString for TokenTree { /// with `Delimiter::None` delimiters and negative numeric literals. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Display for TokenTree { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(&self.to_string()) } } @@ -667,14 +668,14 @@ impl ToString for Group { /// with `Delimiter::None` delimiters. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Display for Group { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(&self.to_string()) } } #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Debug for Group { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Group") .field("delimiter", &self.delimiter()) .field("stream", &self.stream()) @@ -763,14 +764,14 @@ impl ToString for Punct { /// back into the same character. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Display for Punct { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(&self.to_string()) } } #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Debug for Punct { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Punct") .field("ch", &self.as_char()) .field("spacing", &self.spacing()) @@ -842,14 +843,14 @@ impl ToString for Ident { /// back into the same identifier. #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Display for Ident { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(&self.to_string()) } } #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Debug for Ident { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Ident") .field("ident", &self.to_string()) .field("span", &self.span()) @@ -1092,14 +1093,14 @@ impl ToString for Literal { /// back into the same literal (except for possible rounding for floating point literals). #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Display for Literal { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(&self.to_string()) } } #[stable(feature = "proc_macro_lib2", since = "1.29.0")] impl fmt::Debug for Literal { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // FIXME(eddyb) `Literal` should not expose internal `Debug` impls. self.0.fmt(f) } diff --git a/src/libproc_macro/quote.rs b/src/libproc_macro/quote.rs index bd7e96210a950..e3d31b78f4a09 100644 --- a/src/libproc_macro/quote.rs +++ b/src/libproc_macro/quote.rs @@ -4,7 +4,7 @@ //! This quasiquoter uses macros 2.0 hygiene to reliably access //! items from `proc_macro`, to build a `proc_macro::TokenStream`. -use {Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree}; +use crate::{Delimiter, Group, Ident, Literal, Punct, Spacing, Span, TokenStream, TokenTree}; macro_rules! quote_tt { (($($t:tt)*)) => { Group::new(Delimiter::Parenthesis, quote!($($t)*)) }; @@ -63,7 +63,7 @@ macro_rules! quote { #[unstable(feature = "proc_macro_quote", issue = "54722")] pub fn quote(stream: TokenStream) -> TokenStream { if stream.is_empty() { - return quote!(::TokenStream::new()); + return quote!(crate::TokenStream::new()); } let mut after_dollar = false; let tokens = stream @@ -73,7 +73,7 @@ pub fn quote(stream: TokenStream) -> TokenStream { after_dollar = false; match tree { TokenTree::Ident(_) => { - return Some(quote!(Into::<::TokenStream>::into( + return Some(quote!(Into::::into( Clone::clone(&(@ tree))),)); } TokenTree::Punct(ref tt) if tt.as_char() == '$' => {} @@ -86,33 +86,33 @@ pub fn quote(stream: TokenStream) -> TokenStream { } } - Some(quote!(::TokenStream::from((@ match tree { - TokenTree::Punct(tt) => quote!(::TokenTree::Punct(::Punct::new( + Some(quote!(crate::TokenStream::from((@ match tree { + TokenTree::Punct(tt) => quote!(crate::TokenTree::Punct(crate::Punct::new( (@ TokenTree::from(Literal::character(tt.as_char()))), (@ match tt.spacing() { - Spacing::Alone => quote!(::Spacing::Alone), - Spacing::Joint => quote!(::Spacing::Joint), + Spacing::Alone => quote!(crate::Spacing::Alone), + Spacing::Joint => quote!(crate::Spacing::Joint), }), ))), - TokenTree::Group(tt) => quote!(::TokenTree::Group(::Group::new( + TokenTree::Group(tt) => quote!(crate::TokenTree::Group(crate::Group::new( (@ match tt.delimiter() { - Delimiter::Parenthesis => quote!(::Delimiter::Parenthesis), - Delimiter::Brace => quote!(::Delimiter::Brace), - Delimiter::Bracket => quote!(::Delimiter::Bracket), - Delimiter::None => quote!(::Delimiter::None), + Delimiter::Parenthesis => quote!(crate::Delimiter::Parenthesis), + Delimiter::Brace => quote!(crate::Delimiter::Brace), + Delimiter::Bracket => quote!(crate::Delimiter::Bracket), + Delimiter::None => quote!(crate::Delimiter::None), }), (@ quote(tt.stream())), ))), - TokenTree::Ident(tt) => quote!(::TokenTree::Ident(::Ident::new( + TokenTree::Ident(tt) => quote!(crate::TokenTree::Ident(crate::Ident::new( (@ TokenTree::from(Literal::string(&tt.to_string()))), (@ quote_span(tt.span())), ))), - TokenTree::Literal(tt) => quote!(::TokenTree::Literal({ + TokenTree::Literal(tt) => quote!(crate::TokenTree::Literal({ let mut iter = (@ TokenTree::from(Literal::string(&tt.to_string()))) - .parse::<::TokenStream>() + .parse::() .unwrap() .into_iter(); - if let (Some(::TokenTree::Literal(mut lit)), None) = + if let (Some(crate::TokenTree::Literal(mut lit)), None) = (iter.next(), iter.next()) { lit.set_span((@ quote_span(tt.span()))); @@ -129,12 +129,12 @@ pub fn quote(stream: TokenStream) -> TokenStream { panic!("unexpected trailing `$` in `quote!`"); } - quote!([(@ tokens)].iter().cloned().collect::<::TokenStream>()) + quote!([(@ tokens)].iter().cloned().collect::()) } /// Quote a `Span` into a `TokenStream`. /// This is needed to implement a custom quoter. #[unstable(feature = "proc_macro_quote", issue = "54722")] pub fn quote_span(_: Span) -> TokenStream { - quote!(::Span::def_site()) + quote!(crate::Span::def_site()) } diff --git a/src/libprofiler_builtins/Cargo.toml b/src/libprofiler_builtins/Cargo.toml index 7c95cf0a0542a..0d36bd0b39d76 100644 --- a/src/libprofiler_builtins/Cargo.toml +++ b/src/libprofiler_builtins/Cargo.toml @@ -3,6 +3,7 @@ authors = ["The Rust Project Developers"] build = "build.rs" name = "profiler_builtins" version = "0.0.0" +edition = "2018" [lib] name = "profiler_builtins" diff --git a/src/libprofiler_builtins/build.rs b/src/libprofiler_builtins/build.rs index b66cd66448748..ff52a03d9dd97 100644 --- a/src/libprofiler_builtins/build.rs +++ b/src/libprofiler_builtins/build.rs @@ -2,8 +2,6 @@ //! //! See the build.rs for libcompiler_builtins crate for details. -extern crate cc; - use std::env; use std::path::Path; diff --git a/src/libprofiler_builtins/lib.rs b/src/libprofiler_builtins/lib.rs index 0d12ba01c87a2..9c8d3a13b0812 100644 --- a/src/libprofiler_builtins/lib.rs +++ b/src/libprofiler_builtins/lib.rs @@ -5,5 +5,5 @@ reason = "internal implementation detail of rustc right now", issue = "0")] #![allow(unused_features)] -#![feature(nll)] #![feature(staged_api)] +#![deny(rust_2018_idioms)] diff --git a/src/librustc/Cargo.toml b/src/librustc/Cargo.toml index a5521effc7d8d..c9a04f4c6834d 100644 --- a/src/librustc/Cargo.toml +++ b/src/librustc/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc" version = "0.0.0" +edition = "2018" [lib] name = "rustc" diff --git a/src/librustc/cfg/construct.rs b/src/librustc/cfg/construct.rs index 669c2998d1cb2..f7ffbe8c65833 100644 --- a/src/librustc/cfg/construct.rs +++ b/src/librustc/cfg/construct.rs @@ -1,11 +1,11 @@ -use cfg::*; -use middle::region; +use crate::cfg::*; +use crate::middle::region; use rustc_data_structures::graph::implementation as graph; use syntax::ptr::P; -use ty::{self, TyCtxt}; +use crate::ty::{self, TyCtxt}; -use hir::{self, PatKind}; -use hir::def_id::DefId; +use crate::hir::{self, PatKind}; +use crate::hir::def_id::DefId; struct CFGBuilder<'a, 'tcx: 'a> { tcx: TyCtxt<'a, 'tcx, 'tcx>, diff --git a/src/librustc/cfg/graphviz.rs b/src/librustc/cfg/graphviz.rs index 6dec421760899..969c38bd66329 100644 --- a/src/librustc/cfg/graphviz.rs +++ b/src/librustc/cfg/graphviz.rs @@ -4,9 +4,9 @@ // For clarity, rename the graphviz crate locally to dot. use graphviz as dot; -use cfg; -use hir; -use ty::TyCtxt; +use crate::cfg; +use crate::hir; +use crate::ty::TyCtxt; pub type Node<'a> = (cfg::CFGIndex, &'a cfg::CFGNode); pub type Edge<'a> = &'a cfg::CFGEdge; diff --git a/src/librustc/cfg/mod.rs b/src/librustc/cfg/mod.rs index e58557839f9b9..345dff88b5f0b 100644 --- a/src/librustc/cfg/mod.rs +++ b/src/librustc/cfg/mod.rs @@ -2,9 +2,9 @@ //! Uses `Graph` as the underlying representation. use rustc_data_structures::graph::implementation as graph; -use ty::TyCtxt; -use hir; -use hir::def_id::DefId; +use crate::ty::TyCtxt; +use crate::hir; +use crate::hir::def_id::DefId; mod construct; pub mod graphviz; diff --git a/src/librustc/dep_graph/cgu_reuse_tracker.rs b/src/librustc/dep_graph/cgu_reuse_tracker.rs index e8d1b71048705..13f6f95332973 100644 --- a/src/librustc/dep_graph/cgu_reuse_tracker.rs +++ b/src/librustc/dep_graph/cgu_reuse_tracker.rs @@ -2,7 +2,7 @@ //! compilation. This is used for incremental compilation tests and debug //! output. -use session::Session; +use crate::session::Session; use rustc_data_structures::fx::FxHashMap; use std::sync::{Arc, Mutex}; use syntax_pos::Span; diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index cda469657ed87..58087b76266b5 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -49,25 +49,25 @@ //! user of the `DepNode` API of having to know how to compute the expected //! fingerprint for a given set of node parameters. -use mir::interpret::GlobalId; -use hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX}; -use hir::map::DefPathHash; -use hir::HirId; +use crate::mir::interpret::GlobalId; +use crate::hir::def_id::{CrateNum, DefId, DefIndex, CRATE_DEF_INDEX}; +use crate::hir::map::DefPathHash; +use crate::hir::HirId; -use ich::{Fingerprint, StableHashingContext}; +use crate::ich::{Fingerprint, StableHashingContext}; use rustc_data_structures::stable_hasher::{StableHasher, HashStable}; use std::fmt; use std::hash::Hash; use syntax_pos::symbol::InternedString; -use traits; -use traits::query::{ +use crate::traits; +use crate::traits::query::{ CanonicalProjectionGoal, CanonicalTyGoal, CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpSubtypeGoal, CanonicalPredicateGoal, CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpNormalizeGoal, }; -use ty::{TyCtxt, FnSig, Instance, InstanceDef, +use crate::ty::{TyCtxt, FnSig, Instance, InstanceDef, ParamEnv, ParamEnvAnd, Predicate, PolyFnSig, PolyTraitRef, Ty}; -use ty::subst::Substs; +use crate::ty::subst::Substs; // erase!() just makes tokens go away. It's used to specify which macro argument // is repeated (i.e., which sub-expression of the macro we are in) but don't need @@ -389,7 +389,7 @@ impl fmt::Debug for DepNode { write!(f, "(")?; - ::ty::tls::with_opt(|opt_tcx| { + crate::ty::tls::with_opt(|opt_tcx| { if let Some(tcx) = opt_tcx { if let Some(def_id) = self.extract_def_id(tcx) { write!(f, "{}", tcx.def_path_debug_str(def_id))?; @@ -825,6 +825,6 @@ impl WorkProductId { } } -impl_stable_hash_for!(struct ::dep_graph::WorkProductId { +impl_stable_hash_for!(struct crate::dep_graph::WorkProductId { hash }); diff --git a/src/librustc/dep_graph/dep_tracking_map.rs b/src/librustc/dep_graph/dep_tracking_map.rs index 331a9c6109c4c..a296a3379c2ac 100644 --- a/src/librustc/dep_graph/dep_tracking_map.rs +++ b/src/librustc/dep_graph/dep_tracking_map.rs @@ -2,7 +2,7 @@ use rustc_data_structures::fx::FxHashMap; use std::cell::RefCell; use std::hash::Hash; use std::marker::PhantomData; -use util::common::MemoizationMap; +use crate::util::common::MemoizationMap; use super::{DepKind, DepNodeIndex, DepGraph}; diff --git a/src/librustc/dep_graph/graph.rs b/src/librustc/dep_graph/graph.rs index c9353a451e2cd..663c408ac22fd 100644 --- a/src/librustc/dep_graph/graph.rs +++ b/src/librustc/dep_graph/graph.rs @@ -1,4 +1,4 @@ -use errors::{Diagnostic, DiagnosticBuilder}; +use crate::errors::{Diagnostic, DiagnosticBuilder}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; @@ -7,11 +7,11 @@ use rustc_data_structures::sync::{Lrc, Lock, AtomicU32, Ordering}; use std::env; use std::hash::Hash; use std::collections::hash_map::Entry; -use ty::{self, TyCtxt}; -use util::common::{ProfileQueriesMsg, profq_msg}; +use crate::ty::{self, TyCtxt}; +use crate::util::common::{ProfileQueriesMsg, profq_msg}; use parking_lot::{Mutex, Condvar}; -use ich::{StableHashingContext, StableHashingContextProvider, Fingerprint}; +use crate::ich::{StableHashingContext, StableHashingContextProvider, Fingerprint}; use super::debug::EdgeFilter; use super::dep_node::{DepNode, DepKind, WorkProductId}; @@ -669,7 +669,7 @@ impl DepGraph { // We failed to mark it green, so we try to force the query. debug!("try_mark_previous_green({:?}) --- trying to force \ dependency {:?}", dep_node, dep_dep_node); - if ::ty::query::force_from_dep_node(tcx, dep_dep_node) { + if crate::ty::query::force_from_dep_node(tcx, dep_dep_node) { let dep_dep_node_color = data.colors.get(dep_dep_node_index); match dep_dep_node_color { diff --git a/src/librustc/dep_graph/prev.rs b/src/librustc/dep_graph/prev.rs index ea5350ac97fee..d971690bbe317 100644 --- a/src/librustc/dep_graph/prev.rs +++ b/src/librustc/dep_graph/prev.rs @@ -1,4 +1,4 @@ -use ich::Fingerprint; +use crate::ich::Fingerprint; use rustc_data_structures::fx::FxHashMap; use super::dep_node::DepNode; use super::serialized::{SerializedDepGraph, SerializedDepNodeIndex}; diff --git a/src/librustc/dep_graph/safe.rs b/src/librustc/dep_graph/safe.rs index f1e8224a70d14..fc767defe9c71 100644 --- a/src/librustc/dep_graph/safe.rs +++ b/src/librustc/dep_graph/safe.rs @@ -1,9 +1,9 @@ //! The `DepGraphSafe` trait -use hir::BodyId; -use hir::def_id::DefId; +use crate::hir::BodyId; +use crate::hir::def_id::DefId; use syntax::ast::NodeId; -use ty::TyCtxt; +use crate::ty::TyCtxt; /// The `DepGraphSafe` trait is used to specify what kinds of values /// are safe to "leak" into a task. The idea is that this should be diff --git a/src/librustc/dep_graph/serialized.rs b/src/librustc/dep_graph/serialized.rs index 3c04f01a5e1eb..b64f71ed908d8 100644 --- a/src/librustc/dep_graph/serialized.rs +++ b/src/librustc/dep_graph/serialized.rs @@ -1,7 +1,7 @@ //! The data that we will serialize and deserialize. -use dep_graph::DepNode; -use ich::Fingerprint; +use crate::dep_graph::DepNode; +use crate::ich::Fingerprint; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; newtype_index! { diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index 4ce41fec18240..75710210d7722 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -5,12 +5,12 @@ //! item. -use ty::TyCtxt; -use ty::query::Providers; +use crate::ty::TyCtxt; +use crate::ty::query::Providers; -use hir; -use hir::def_id::DefId; -use hir::intravisit::{self, Visitor, NestedVisitorMap}; +use crate::hir; +use crate::hir::def_id::DefId; +use crate::hir::intravisit::{self, Visitor, NestedVisitorMap}; use std::fmt::{self, Display}; use syntax_pos::Span; diff --git a/src/librustc/hir/def.rs b/src/librustc/hir/def.rs index f8f27992b3ea8..6566c6041b6e5 100644 --- a/src/librustc/hir/def.rs +++ b/src/librustc/hir/def.rs @@ -1,10 +1,10 @@ -use hir::def_id::DefId; -use util::nodemap::{NodeMap, DefIdMap}; +use crate::hir::def_id::DefId; +use crate::util::nodemap::{NodeMap, DefIdMap}; use syntax::ast; use syntax::ext::base::MacroKind; use syntax_pos::Span; -use hir; -use ty; +use crate::hir; +use crate::ty; use self::Namespace::*; diff --git a/src/librustc/hir/def_id.rs b/src/librustc/hir/def_id.rs index 9181076740ba0..e06f09e21cbf3 100644 --- a/src/librustc/hir/def_id.rs +++ b/src/librustc/hir/def_id.rs @@ -1,6 +1,6 @@ -use ty; -use ty::TyCtxt; -use hir::map::definitions::FIRST_FREE_HIGH_DEF_INDEX; +use crate::ty; +use crate::ty::TyCtxt; +use crate::hir::map::definitions::FIRST_FREE_HIGH_DEF_INDEX; use rustc_data_structures::indexed_vec::Idx; use serialize; use std::fmt; diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 5f85e33fb87ee..86c3fb9e4fcd7 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -33,9 +33,9 @@ use syntax::ast::{NodeId, CRATE_NODE_ID, Ident, Name, Attribute}; use syntax_pos::Span; -use hir::*; -use hir::def::Def; -use hir::map::Map; +use crate::hir::*; +use crate::hir::def::Def; +use crate::hir::map::Map; use super::itemlikevisit::DeepVisitor; #[derive(Copy, Clone)] diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index e3c913313adee..d0fd5bd6844b0 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -30,24 +30,24 @@ //! get confused if the spans from leaf AST nodes occur in multiple places //! in the HIR, especially for multiple identifiers. -use dep_graph::DepGraph; -use errors::Applicability; -use hir::{self, ParamName}; -use hir::HirVec; -use hir::map::{DefKey, DefPathData, Definitions}; -use hir::def_id::{DefId, DefIndex, DefIndexAddressSpace, CRATE_DEF_INDEX}; -use hir::def::{Def, PathResolution, PerNS}; -use hir::GenericArg; -use lint::builtin::{self, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, +use crate::dep_graph::DepGraph; +use crate::errors::Applicability; +use crate::hir::{self, ParamName}; +use crate::hir::HirVec; +use crate::hir::map::{DefKey, DefPathData, Definitions}; +use crate::hir::def_id::{DefId, DefIndex, DefIndexAddressSpace, CRATE_DEF_INDEX}; +use crate::hir::def::{Def, PathResolution, PerNS}; +use crate::hir::GenericArg; +use crate::lint::builtin::{self, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES, ELIDED_LIFETIMES_IN_PATHS}; -use middle::cstore::CrateStore; +use crate::middle::cstore::CrateStore; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::indexed_vec::IndexVec; use rustc_data_structures::thin_vec::ThinVec; -use session::Session; -use session::config::nightly_options; -use util::common::FN_OUTPUT_NAME; -use util::nodemap::{DefIdMap, NodeMap}; +use crate::session::Session; +use crate::session::config::nightly_options; +use crate::util::common::FN_OUTPUT_NAME; +use crate::util::nodemap::{DefIdMap, NodeMap}; use std::collections::{BTreeSet, BTreeMap}; use std::fmt::Debug; diff --git a/src/librustc/hir/map/blocks.rs b/src/librustc/hir/map/blocks.rs index f61b8551927bb..d5fb578d8d492 100644 --- a/src/librustc/hir/map/blocks.rs +++ b/src/librustc/hir/map/blocks.rs @@ -11,10 +11,10 @@ //! nested within a uniquely determined `FnLike`), and users can ask //! for the `Code` associated with a particular NodeId. -use hir as ast; -use hir::map; -use hir::{Expr, FnDecl, Node}; -use hir::intravisit::FnKind; +use crate::hir as ast; +use crate::hir::map; +use crate::hir::{Expr, FnDecl, Node}; +use crate::hir::intravisit::FnKind; use syntax::ast::{Attribute, Ident, NodeId}; use syntax_pos::Span; diff --git a/src/librustc/hir/map/collector.rs b/src/librustc/hir/map/collector.rs index 9c4fa9e127287..f84bb77e29b27 100644 --- a/src/librustc/hir/map/collector.rs +++ b/src/librustc/hir/map/collector.rs @@ -1,19 +1,19 @@ use super::*; -use dep_graph::{DepGraph, DepKind, DepNodeIndex}; -use hir; -use hir::def_id::{LOCAL_CRATE, CrateNum}; -use hir::intravisit::{Visitor, NestedVisitorMap}; +use crate::dep_graph::{DepGraph, DepKind, DepNodeIndex}; +use crate::hir; +use crate::hir::def_id::{LOCAL_CRATE, CrateNum}; +use crate::hir::intravisit::{Visitor, NestedVisitorMap}; use rustc_data_structures::svh::Svh; -use ich::Fingerprint; -use middle::cstore::CrateStore; -use session::CrateDisambiguator; -use session::Session; +use crate::ich::Fingerprint; +use crate::middle::cstore::CrateStore; +use crate::session::CrateDisambiguator; +use crate::session::Session; use std::iter::repeat; use syntax::ast::{NodeId, CRATE_NODE_ID}; use syntax::source_map::SourceMap; use syntax_pos::Span; -use ich::StableHashingContext; +use crate::ich::StableHashingContext; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; /// A Visitor that walks over the HIR and collects Nodes into a HIR map @@ -253,7 +253,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> { None => format!("{:?}", node) }; - let forgot_str = if hir_id == ::hir::DUMMY_HIR_ID { + let forgot_str = if hir_id == crate::hir::DUMMY_HIR_ID { format!("\nMaybe you forgot to lower the node id {:?}?", id) } else { String::new() diff --git a/src/librustc/hir/map/def_collector.rs b/src/librustc/hir/map/def_collector.rs index c9b4b2bb99717..710170674f761 100644 --- a/src/librustc/hir/map/def_collector.rs +++ b/src/librustc/hir/map/def_collector.rs @@ -1,6 +1,6 @@ -use hir::map::definitions::*; -use hir::def_id::{CRATE_DEF_INDEX, DefIndex, DefIndexAddressSpace}; -use session::CrateDisambiguator; +use crate::hir::map::definitions::*; +use crate::hir::def_id::{CRATE_DEF_INDEX, DefIndex, DefIndexAddressSpace}; +use crate::session::CrateDisambiguator; use syntax::ast::*; use syntax::ext::hygiene::Mark; @@ -10,7 +10,7 @@ use syntax::symbol::Symbol; use syntax::parse::token::{self, Token}; use syntax_pos::Span; -use hir::map::{ITEM_LIKE_SPACE, REGULAR_SPACE}; +use crate::hir::map::{ITEM_LIKE_SPACE, REGULAR_SPACE}; /// Creates def ids for nodes in the AST. pub struct DefCollector<'a> { diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs index 4c622adefbdb1..a8193e1d34837 100644 --- a/src/librustc/hir/map/definitions.rs +++ b/src/librustc/hir/map/definitions.rs @@ -4,15 +4,15 @@ //! There are also some rather random cases (like const initializer //! expressions) that are mostly just leftovers. -use hir; -use hir::def_id::{CrateNum, DefId, DefIndex, LOCAL_CRATE, DefIndexAddressSpace, +use crate::hir; +use crate::hir::def_id::{CrateNum, DefId, DefIndex, LOCAL_CRATE, DefIndexAddressSpace, CRATE_DEF_INDEX}; -use ich::Fingerprint; +use crate::ich::Fingerprint; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::{IndexVec}; use rustc_data_structures::stable_hasher::StableHasher; use serialize::{Encodable, Decodable, Encoder, Decoder}; -use session::CrateDisambiguator; +use crate::session::CrateDisambiguator; use std::borrow::Borrow; use std::fmt::Write; use std::hash::Hash; @@ -20,7 +20,7 @@ use syntax::ast; use syntax::ext::hygiene::Mark; use syntax::symbol::{Symbol, InternedString}; use syntax_pos::{Span, DUMMY_SP}; -use util::nodemap::NodeMap; +use crate::util::nodemap::NodeMap; /// The DefPathTable maps DefIndexes to DefKeys and vice versa. /// Internally the DefPathTable holds a tree of DefKeys, where each DefKey diff --git a/src/librustc/hir/map/hir_id_validator.rs b/src/librustc/hir/map/hir_id_validator.rs index 91c8c29144406..2c3ff4c9b5c05 100644 --- a/src/librustc/hir/map/hir_id_validator.rs +++ b/src/librustc/hir/map/hir_id_validator.rs @@ -1,7 +1,7 @@ -use hir::def_id::{DefId, DefIndex, CRATE_DEF_INDEX}; -use hir::{self, intravisit, HirId, ItemLocalId}; +use crate::hir::def_id::{DefId, DefIndex, CRATE_DEF_INDEX}; +use crate::hir::{self, intravisit, HirId, ItemLocalId}; use syntax::ast::NodeId; -use hir::itemlikevisit::ItemLikeVisitor; +use crate::hir::itemlikevisit::ItemLikeVisitor; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::{Lock, ParallelIterator, par_iter}; diff --git a/src/librustc/hir/map/mod.rs b/src/librustc/hir/map/mod.rs index d35306ba353a3..91fc12639baf5 100644 --- a/src/librustc/hir/map/mod.rs +++ b/src/librustc/hir/map/mod.rs @@ -3,11 +3,11 @@ pub use self::def_collector::{DefCollector, MacroInvocationData}; pub use self::definitions::{Definitions, DefKey, DefPath, DefPathData, DisambiguatedDefPathData, DefPathHash}; -use dep_graph::{DepGraph, DepNode, DepKind, DepNodeIndex}; +use crate::dep_graph::{DepGraph, DepNode, DepKind, DepNodeIndex}; -use hir::def_id::{CRATE_DEF_INDEX, DefId, LocalDefId, DefIndexAddressSpace}; +use crate::hir::def_id::{CRATE_DEF_INDEX, DefId, LocalDefId, DefIndexAddressSpace}; -use middle::cstore::CrateStoreDyn; +use crate::middle::cstore::CrateStoreDyn; use rustc_target::spec::abi::Abi; use rustc_data_structures::svh::Svh; @@ -17,15 +17,15 @@ use syntax::source_map::Spanned; use syntax::ext::base::MacroKind; use syntax_pos::{Span, DUMMY_SP}; -use hir::*; -use hir::itemlikevisit::ItemLikeVisitor; -use hir::print::Nested; -use util::nodemap::FxHashMap; -use util::common::time; +use crate::hir::*; +use crate::hir::itemlikevisit::ItemLikeVisitor; +use crate::hir::print::Nested; +use crate::util::nodemap::FxHashMap; +use crate::util::common::time; use std::io; use std::result::Result::Err; -use ty::TyCtxt; +use crate::ty::TyCtxt; pub mod blocks; mod collector; @@ -1212,13 +1212,13 @@ impl Named for StructField { fn name(&self) -> Name { self.ident.name } } impl Named for TraitItem { fn name(&self) -> Name { self.ident.name } } impl Named for ImplItem { fn name(&self) -> Name { self.ident.name } } -pub fn map_crate<'hir>(sess: &::session::Session, +pub fn map_crate<'hir>(sess: &crate::session::Session, cstore: &CrateStoreDyn, forest: &'hir Forest, definitions: &'hir Definitions) -> Map<'hir> { let ((map, crate_hash), hir_to_node_id) = join(|| { - let hcx = ::ich::StableHashingContext::new(sess, &forest.krate, definitions, cstore); + let hcx = crate::ich::StableHashingContext::new(sess, &forest.krate, definitions, cstore); let mut collector = NodeCollector::root(sess, &forest.krate, @@ -1329,7 +1329,7 @@ fn node_id_to_string(map: &Map<'_>, id: NodeId, include_id: bool) -> String { let path_str = || { // This functionality is used for debugging, try to use TyCtxt to get // the user-friendly path, otherwise fall back to stringifying DefPath. - ::ty::tls::with_opt(|tcx| { + crate::ty::tls::with_opt(|tcx| { if let Some(tcx) = tcx { tcx.node_path_str(id) } else if let Some(path) = map.def_path_from_id(id) { diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index 924b044da5fc3..f8fb2b88e2750 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -10,11 +10,11 @@ pub use self::PrimTy::*; pub use self::UnOp::*; pub use self::UnsafeSource::*; -use errors::FatalError; -use hir::def::Def; -use hir::def_id::{DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX}; -use util::nodemap::{NodeMap, FxHashSet}; -use mir::mono::Linkage; +use crate::errors::FatalError; +use crate::hir::def::Def; +use crate::hir::def_id::{DefId, DefIndex, LocalDefId, CRATE_DEF_INDEX}; +use crate::util::nodemap::{NodeMap, FxHashSet}; +use crate::mir::mono::Linkage; use syntax_pos::{Span, DUMMY_SP, symbol::InternedString}; use syntax::source_map::Spanned; @@ -27,8 +27,8 @@ use syntax::ptr::P; use syntax::symbol::{Symbol, keywords}; use syntax::tokenstream::TokenStream; use syntax::util::parser::ExprPrecedence; -use ty::AdtKind; -use ty::query::Providers; +use crate::ty::AdtKind; +use crate::ty::query::Providers; use rustc_data_structures::sync::{ParallelIterator, par_iter, Send, Sync, scope}; use rustc_data_structures::thin_vec::ThinVec; diff --git a/src/librustc/hir/pat_util.rs b/src/librustc/hir/pat_util.rs index e2a03c638764d..c92cbc9b96c93 100644 --- a/src/librustc/hir/pat_util.rs +++ b/src/librustc/hir/pat_util.rs @@ -1,6 +1,6 @@ -use hir::def::Def; -use hir::def_id::DefId; -use hir::{self, HirId, PatKind}; +use crate::hir::def::Def; +use crate::hir::def_id::DefId; +use crate::hir::{self, HirId, PatKind}; use syntax::ast; use syntax_pos::Span; diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 89b5b7a190df6..9b6fcf259be14 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -11,9 +11,9 @@ use syntax::symbol::keywords; use syntax::util::parser::{self, AssocOp, Fixity}; use syntax_pos::{self, BytePos, FileName}; -use hir; -use hir::{PatKind, GenericBound, TraitBoundModifier, RangeEnd}; -use hir::{GenericParam, GenericParamKind, GenericArg}; +use crate::hir; +use crate::hir::{PatKind, GenericBound, TraitBoundModifier, RangeEnd}; +use crate::hir::{GenericParam, GenericParamKind, GenericArg}; use std::borrow::Cow; use std::cell::Cell; @@ -2401,7 +2401,7 @@ fn stmt_ends_with_semi(stmt: &hir::StmtKind) -> bool { } fn bin_op_to_assoc_op(op: hir::BinOpKind) -> AssocOp { - use hir::BinOpKind::*; + use crate::hir::BinOpKind::*; match op { Add => AssocOp::Add, Sub => AssocOp::Subtract, diff --git a/src/librustc/ich/hcx.rs b/src/librustc/ich/hcx.rs index d5c9d9ff16dcb..e60fdd62debd1 100644 --- a/src/librustc/ich/hcx.rs +++ b/src/librustc/ich/hcx.rs @@ -1,11 +1,11 @@ -use hir; -use hir::def_id::{DefId, DefIndex}; -use hir::map::DefPathHash; -use hir::map::definitions::Definitions; -use ich::{self, CachingSourceMapView, Fingerprint}; -use middle::cstore::CrateStore; -use ty::{TyCtxt, fast_reject}; -use session::Session; +use crate::hir; +use crate::hir::def_id::{DefId, DefIndex}; +use crate::hir::map::DefPathHash; +use crate::hir::map::definitions::Definitions; +use crate::ich::{self, CachingSourceMapView, Fingerprint}; +use crate::middle::cstore::CrateStore; +use crate::ty::{TyCtxt, fast_reject}; +use crate::session::Session; use std::cmp::Ord; use std::hash as std_hash; @@ -218,7 +218,7 @@ impl<'a> StableHashingContextProvider<'a> for StableHashingContext<'a> { } } -impl<'a> ::dep_graph::DepGraphSafe for StableHashingContext<'a> { +impl<'a> crate::dep_graph::DepGraphSafe for StableHashingContext<'a> { } diff --git a/src/librustc/ich/impls_cstore.rs b/src/librustc/ich/impls_cstore.rs index fdea62a1dd8f6..17ed1a79d45e0 100644 --- a/src/librustc/ich/impls_cstore.rs +++ b/src/librustc/ich/impls_cstore.rs @@ -1,23 +1,21 @@ //! This module contains `HashStable` implementations for various data types //! from rustc::middle::cstore in no particular order. -use middle; - -impl_stable_hash_for!(enum middle::cstore::DepKind { +impl_stable_hash_for!(enum crate::middle::cstore::DepKind { UnexportedMacrosOnly, MacrosOnly, Implicit, Explicit }); -impl_stable_hash_for!(enum middle::cstore::NativeLibraryKind { +impl_stable_hash_for!(enum crate::middle::cstore::NativeLibraryKind { NativeStatic, NativeStaticNobundle, NativeFramework, NativeUnknown }); -impl_stable_hash_for!(struct middle::cstore::NativeLibrary { +impl_stable_hash_for!(struct crate::middle::cstore::NativeLibrary { kind, name, cfg, @@ -25,30 +23,30 @@ impl_stable_hash_for!(struct middle::cstore::NativeLibrary { wasm_import_module }); -impl_stable_hash_for!(struct middle::cstore::ForeignModule { +impl_stable_hash_for!(struct crate::middle::cstore::ForeignModule { foreign_items, def_id }); -impl_stable_hash_for!(enum middle::cstore::LinkagePreference { +impl_stable_hash_for!(enum crate::middle::cstore::LinkagePreference { RequireDynamic, RequireStatic }); -impl_stable_hash_for!(struct middle::cstore::ExternCrate { +impl_stable_hash_for!(struct crate::middle::cstore::ExternCrate { src, span, path_len, direct }); -impl_stable_hash_for!(enum middle::cstore::ExternCrateSource { +impl_stable_hash_for!(enum crate::middle::cstore::ExternCrateSource { Extern(def_id), Use, Path, }); -impl_stable_hash_for!(struct middle::cstore::CrateSource { +impl_stable_hash_for!(struct crate::middle::cstore::CrateSource { dylib, rlib, rmeta diff --git a/src/librustc/ich/impls_hir.rs b/src/librustc/ich/impls_hir.rs index 1061ea752af11..2b359428b1fa1 100644 --- a/src/librustc/ich/impls_hir.rs +++ b/src/librustc/ich/impls_hir.rs @@ -1,10 +1,10 @@ //! This module contains `HashStable` implementations for various HIR data //! types in no particular order. -use hir; -use hir::map::DefPathHash; -use hir::def_id::{DefId, LocalDefId, CrateNum, CRATE_DEF_INDEX}; -use ich::{StableHashingContext, NodeIdHashingMode, Fingerprint}; +use crate::hir; +use crate::hir::map::DefPathHash; +use crate::hir::def_id::{DefId, LocalDefId, CrateNum, CRATE_DEF_INDEX}; +use crate::ich::{StableHashingContext, NodeIdHashingMode, Fingerprint}; use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, StableHasher, StableHasherResult}; use std::mem; @@ -619,7 +619,7 @@ impl<'a> HashStable> for hir::MatchSource { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - use hir::MatchSource; + use crate::hir::MatchSource; mem::discriminant(self).hash_stable(hcx, hasher); match *self { @@ -1116,12 +1116,12 @@ impl_stable_hash_for!(struct hir::def::Export { span }); -impl_stable_hash_for!(struct ::middle::lib_features::LibFeatures { +impl_stable_hash_for!(struct crate::middle::lib_features::LibFeatures { stable, unstable }); -impl<'a> HashStable> for ::middle::lang_items::LangItem { +impl<'a> HashStable> for crate::middle::lang_items::LangItem { fn hash_stable(&self, _: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { @@ -1129,7 +1129,7 @@ impl<'a> HashStable> for ::middle::lang_items::LangItem } } -impl_stable_hash_for!(struct ::middle::lang_items::LanguageItems { +impl_stable_hash_for!(struct crate::middle::lang_items::LanguageItems { items, missing }); diff --git a/src/librustc/ich/impls_mir.rs b/src/librustc/ich/impls_mir.rs index 002ac7cc7a9bb..51fc78ffc8669 100644 --- a/src/librustc/ich/impls_mir.rs +++ b/src/librustc/ich/impls_mir.rs @@ -1,8 +1,8 @@ //! This module contains `HashStable` implementations for various MIR data //! types in no particular order. -use ich::StableHashingContext; -use mir; +use crate::ich::StableHashingContext; +use crate::mir; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; use std::mem; diff --git a/src/librustc/ich/impls_misc.rs b/src/librustc/ich/impls_misc.rs index f79adc8109a7f..8a388fafce5e8 100644 --- a/src/librustc/ich/impls_misc.rs +++ b/src/librustc/ich/impls_misc.rs @@ -1,7 +1,7 @@ //! This module contains `HashStable` implementations for various data types //! that don't fit into any of the other impls_xxx modules. -impl_stable_hash_for!(enum ::session::search_paths::PathKind { +impl_stable_hash_for!(enum crate::session::search_paths::PathKind { Native, Crate, Dependency, diff --git a/src/librustc/ich/impls_syntax.rs b/src/librustc/ich/impls_syntax.rs index e10359636f749..f34423ccca655 100644 --- a/src/librustc/ich/impls_syntax.rs +++ b/src/librustc/ich/impls_syntax.rs @@ -1,7 +1,7 @@ //! This module contains `HashStable` implementations for various data types //! from libsyntax in no particular order. -use ich::StableHashingContext; +use crate::ich::StableHashingContext; use std::hash as std_hash; use std::mem; @@ -13,7 +13,7 @@ use syntax::symbol::{InternedString, LocalInternedString}; use syntax::tokenstream; use syntax_pos::SourceFile; -use hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX}; +use crate::hir::def_id::{DefId, CrateNum, CRATE_DEF_INDEX}; use smallvec::SmallVec; use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index bd2349161f74a..1e1dbd0b621ec 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -1,18 +1,18 @@ //! This module contains `HashStable` implementations for various data types //! from rustc::ty in no particular order. -use ich::{Fingerprint, StableHashingContext, NodeIdHashingMode}; +use crate::ich::{Fingerprint, StableHashingContext, NodeIdHashingMode}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, StableHasher, StableHasherResult}; use std::cell::RefCell; use std::hash as std_hash; use std::mem; -use middle::region; -use infer; -use traits; -use ty; -use mir; +use crate::middle::region; +use crate::infer; +use crate::traits; +use crate::ty; +use crate::mir; impl<'a, 'gcx, T> HashStable> for &'gcx ty::List @@ -306,7 +306,7 @@ impl_stable_hash_for!( ByRef(id, alloc, offset), } ); -impl_stable_hash_for!(struct ::mir::interpret::RawConst<'tcx> { +impl_stable_hash_for!(struct crate::mir::interpret::RawConst<'tcx> { alloc_id, ty, }); @@ -512,20 +512,22 @@ impl_stable_hash_for!(enum ty::GenericParamDefKind { }); impl_stable_hash_for!( - impl for enum ::middle::resolve_lifetime::Set1 [ ::middle::resolve_lifetime::Set1 ] { + impl for enum crate::middle::resolve_lifetime::Set1 + [ crate::middle::resolve_lifetime::Set1 ] + { Empty, Many, One(value), } ); -impl_stable_hash_for!(enum ::middle::resolve_lifetime::LifetimeDefOrigin { +impl_stable_hash_for!(enum crate::middle::resolve_lifetime::LifetimeDefOrigin { ExplicitOrElided, InBand, Error, }); -impl_stable_hash_for!(enum ::middle::resolve_lifetime::Region { +impl_stable_hash_for!(enum crate::middle::resolve_lifetime::Region { Static, EarlyBound(index, decl, is_in_band), LateBound(db_index, decl, is_in_band), @@ -547,9 +549,9 @@ impl_stable_hash_for!(enum ty::cast::CastKind { FnPtrAddrCast }); -impl_stable_hash_for!(struct ::middle::region::Scope { id, data }); +impl_stable_hash_for!(struct crate::middle::region::Scope { id, data }); -impl_stable_hash_for!(enum ::middle::region::ScopeData { +impl_stable_hash_for!(enum crate::middle::region::ScopeData { Node, CallSite, Arguments, @@ -588,7 +590,7 @@ for ty::TyKind<'gcx> fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - use ty::TyKind::*; + use crate::ty::TyKind::*; mem::discriminant(self).hash_stable(hcx, hasher); match *self { @@ -882,7 +884,7 @@ impl_stable_hash_for!(enum traits::Reveal { All }); -impl_stable_hash_for!(enum ::middle::privacy::AccessLevel { +impl_stable_hash_for!(enum crate::middle::privacy::AccessLevel { ReachableFromImplTrait, Reachable, Exported, @@ -890,12 +892,12 @@ impl_stable_hash_for!(enum ::middle::privacy::AccessLevel { }); impl<'a> HashStable> -for ::middle::privacy::AccessLevels { +for crate::middle::privacy::AccessLevels { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { hcx.with_node_id_hashing_mode(NodeIdHashingMode::HashDefPath, |hcx| { - let ::middle::privacy::AccessLevels { + let crate::middle::privacy::AccessLevels { ref map } = *self; @@ -908,14 +910,14 @@ impl_stable_hash_for!(struct ty::CrateInherentImpls { inherent_impls }); -impl_stable_hash_for!(enum ::session::CompileIncomplete { +impl_stable_hash_for!(enum crate::session::CompileIncomplete { Stopped, Errored(error_reported) }); -impl_stable_hash_for!(struct ::util::common::ErrorReported {}); +impl_stable_hash_for!(struct crate::util::common::ErrorReported {}); -impl_stable_hash_for!(tuple_struct ::middle::reachable::ReachableSet { +impl_stable_hash_for!(tuple_struct crate::middle::reachable::ReachableSet { reachable_set }); @@ -924,7 +926,7 @@ for traits::Vtable<'gcx, N> where N: HashStable> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - use traits::Vtable::*; + use crate::traits::Vtable::*; mem::discriminant(self).hash_stable(hcx, hasher); @@ -1105,7 +1107,7 @@ impl<'a, 'tcx> HashStable> for traits::WhereClause<'tcx fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - use traits::WhereClause::*; + use crate::traits::WhereClause::*; mem::discriminant(self).hash_stable(hcx, hasher); match self { @@ -1121,7 +1123,7 @@ impl<'a, 'tcx> HashStable> for traits::WellFormed<'tcx> fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - use traits::WellFormed::*; + use crate::traits::WellFormed::*; mem::discriminant(self).hash_stable(hcx, hasher); match self { @@ -1135,7 +1137,7 @@ impl<'a, 'tcx> HashStable> for traits::FromEnv<'tcx> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - use traits::FromEnv::*; + use crate::traits::FromEnv::*; mem::discriminant(self).hash_stable(hcx, hasher); match self { @@ -1149,7 +1151,7 @@ impl<'a, 'tcx> HashStable> for traits::DomainGoal<'tcx> fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - use traits::DomainGoal::*; + use crate::traits::DomainGoal::*; mem::discriminant(self).hash_stable(hcx, hasher); match self { @@ -1165,7 +1167,7 @@ impl<'a, 'tcx> HashStable> for traits::Goal<'tcx> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - use traits::GoalKind::*; + use crate::traits::GoalKind::*; mem::discriminant(self).hash_stable(hcx, hasher); match self { @@ -1208,7 +1210,7 @@ impl<'a, 'tcx> HashStable> for traits::Clause<'tcx> { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - use traits::Clause::*; + use crate::traits::Clause::*; mem::discriminant(self).hash_stable(hcx, hasher); match self { diff --git a/src/librustc/infer/at.rs b/src/librustc/infer/at.rs index 328d518ca66aa..7b2b1184a6336 100644 --- a/src/librustc/infer/at.rs +++ b/src/librustc/infer/at.rs @@ -27,7 +27,7 @@ use super::*; -use ty::relate::{Relate, TypeRelation}; +use crate::ty::relate::{Relate, TypeRelation}; pub struct At<'a, 'gcx: 'tcx, 'tcx: 'a> { pub infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, diff --git a/src/librustc/infer/canonical/canonicalizer.rs b/src/librustc/infer/canonical/canonicalizer.rs index 408cba42ae04b..4e1c797a2c72a 100644 --- a/src/librustc/infer/canonical/canonicalizer.rs +++ b/src/librustc/infer/canonical/canonicalizer.rs @@ -5,15 +5,15 @@ //! //! [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html -use infer::canonical::{ +use crate::infer::canonical::{ Canonical, CanonicalTyVarKind, CanonicalVarInfo, CanonicalVarKind, Canonicalized, OriginalQueryValues, }; -use infer::InferCtxt; +use crate::infer::InferCtxt; use std::sync::atomic::Ordering; -use ty::fold::{TypeFoldable, TypeFolder}; -use ty::subst::Kind; -use ty::{self, BoundVar, Lift, List, Ty, TyCtxt, TypeFlags}; +use crate::ty::fold::{TypeFoldable, TypeFolder}; +use crate::ty::subst::Kind; +use crate::ty::{self, BoundVar, Lift, List, Ty, TyCtxt, TypeFlags}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::indexed_vec::Idx; diff --git a/src/librustc/infer/canonical/mod.rs b/src/librustc/infer/canonical/mod.rs index eaf72f5a68710..6f28c0b131f61 100644 --- a/src/librustc/infer/canonical/mod.rs +++ b/src/librustc/infer/canonical/mod.rs @@ -21,16 +21,16 @@ //! //! [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html -use infer::{InferCtxt, RegionVariableOrigin, TypeVariableOrigin}; +use crate::infer::{InferCtxt, RegionVariableOrigin, TypeVariableOrigin}; use rustc_data_structures::indexed_vec::IndexVec; use rustc_data_structures::sync::Lrc; use serialize::UseSpecializedDecodable; use smallvec::SmallVec; use std::ops::Index; use syntax::source_map::Span; -use ty::fold::TypeFoldable; -use ty::subst::Kind; -use ty::{self, BoundVar, Lift, List, Region, TyCtxt}; +use crate::ty::fold::TypeFoldable; +use crate::ty::subst::Kind; +use crate::ty::{self, BoundVar, Lift, List, Region, TyCtxt}; mod canonicalizer; @@ -393,14 +393,14 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { } CloneTypeFoldableAndLiftImpls! { - ::infer::canonical::Certainty, - ::infer::canonical::CanonicalVarInfo, - ::infer::canonical::CanonicalVarKind, + crate::infer::canonical::Certainty, + crate::infer::canonical::CanonicalVarInfo, + crate::infer::canonical::CanonicalVarKind, } CloneTypeFoldableImpls! { for <'tcx> { - ::infer::canonical::CanonicalVarInfos<'tcx>, + crate::infer::canonical::CanonicalVarInfos<'tcx>, } } @@ -431,7 +431,7 @@ impl<'tcx> CanonicalVarValues<'tcx> { /// we'll return a substitution `subst` with: /// `subst.var_values == [Type(^0), Lifetime(^1), Type(^2)]`. pub fn make_identity<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Self { - use ty::subst::UnpackedKind; + use crate::ty::subst::UnpackedKind; CanonicalVarValues { var_values: self.var_values.iter() diff --git a/src/librustc/infer/canonical/query_response.rs b/src/librustc/infer/canonical/query_response.rs index 7f113f07276d8..409afca43203d 100644 --- a/src/librustc/infer/canonical/query_response.rs +++ b/src/librustc/infer/canonical/query_response.rs @@ -7,26 +7,26 @@ //! //! [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html -use infer::canonical::substitute::substitute_value; -use infer::canonical::{ +use crate::infer::canonical::substitute::substitute_value; +use crate::infer::canonical::{ Canonical, CanonicalVarValues, CanonicalizedQueryResponse, Certainty, OriginalQueryValues, QueryRegionConstraint, QueryResponse, }; -use infer::region_constraints::{Constraint, RegionConstraintData}; -use infer::InferCtxtBuilder; -use infer::{InferCtxt, InferOk, InferResult}; +use crate::infer::region_constraints::{Constraint, RegionConstraintData}; +use crate::infer::InferCtxtBuilder; +use crate::infer::{InferCtxt, InferOk, InferResult}; use rustc_data_structures::indexed_vec::Idx; use rustc_data_structures::indexed_vec::IndexVec; use rustc_data_structures::sync::Lrc; use std::fmt::Debug; use syntax_pos::DUMMY_SP; -use traits::query::{Fallible, NoSolution}; -use traits::TraitEngine; -use traits::{Obligation, ObligationCause, PredicateObligation}; -use ty::fold::TypeFoldable; -use ty::subst::{Kind, UnpackedKind}; -use ty::{self, BoundVar, Lift, Ty, TyCtxt}; -use util::captures::Captures; +use crate::traits::query::{Fallible, NoSolution}; +use crate::traits::TraitEngine; +use crate::traits::{Obligation, ObligationCause, PredicateObligation}; +use crate::ty::fold::TypeFoldable; +use crate::ty::subst::{Kind, UnpackedKind}; +use crate::ty::{self, BoundVar, Lift, Ty, TyCtxt}; +use crate::util::captures::Captures; impl<'cx, 'gcx, 'tcx> InferCtxtBuilder<'cx, 'gcx, 'tcx> { /// The "main method" for a canonicalized trait query. Given the diff --git a/src/librustc/infer/canonical/substitute.rs b/src/librustc/infer/canonical/substitute.rs index d3ed00481dcee..5af4e8366818b 100644 --- a/src/librustc/infer/canonical/substitute.rs +++ b/src/librustc/infer/canonical/substitute.rs @@ -6,10 +6,10 @@ //! //! [c]: https://rust-lang.github.io/rustc-guide/traits/canonicalization.html -use infer::canonical::{Canonical, CanonicalVarValues}; -use ty::fold::TypeFoldable; -use ty::subst::UnpackedKind; -use ty::{self, TyCtxt}; +use crate::infer::canonical::{Canonical, CanonicalVarValues}; +use crate::ty::fold::TypeFoldable; +use crate::ty::subst::UnpackedKind; +use crate::ty::{self, TyCtxt}; impl<'tcx, V> Canonical<'tcx, V> { /// Instantiate the wrapped value, replacing each canonical value diff --git a/src/librustc/infer/combine.rs b/src/librustc/infer/combine.rs index 40c11695d51e2..7e22521473491 100644 --- a/src/librustc/infer/combine.rs +++ b/src/librustc/infer/combine.rs @@ -29,13 +29,13 @@ use super::lub::Lub; use super::sub::Sub; use super::type_variable::TypeVariableValue; -use hir::def_id::DefId; -use ty::{IntType, UintType}; -use ty::{self, Ty, TyCtxt}; -use ty::error::TypeError; -use ty::relate::{self, Relate, RelateResult, TypeRelation}; -use ty::subst::Substs; -use traits::{Obligation, PredicateObligations}; +use crate::hir::def_id::DefId; +use crate::ty::{IntType, UintType}; +use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::error::TypeError; +use crate::ty::relate::{self, Relate, RelateResult, TypeRelation}; +use crate::ty::subst::Substs; +use crate::traits::{Obligation, PredicateObligations}; use syntax::ast; use syntax_pos::Span; diff --git a/src/librustc/infer/equate.rs b/src/librustc/infer/equate.rs index 60a7eb0d54f8b..a4b62307a60b8 100644 --- a/src/librustc/infer/equate.rs +++ b/src/librustc/infer/equate.rs @@ -1,12 +1,12 @@ use super::combine::{CombineFields, RelationDir}; use super::{Subtype}; -use hir::def_id::DefId; +use crate::hir::def_id::DefId; -use ty::{self, Ty, TyCtxt}; -use ty::TyVar; -use ty::subst::Substs; -use ty::relate::{self, Relate, RelateResult, TypeRelation}; +use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::TyVar; +use crate::ty::subst::Substs; +use crate::ty::relate::{self, Relate, RelateResult, TypeRelation}; /// Ensures `a` is made equal to `b`. Returns `a` on success. pub struct Equate<'combine, 'infcx: 'combine, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 66e4cd49c807f..8510533391287 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -48,19 +48,19 @@ use super::lexical_region_resolve::RegionResolutionError; use super::region_constraints::GenericKind; use super::{InferCtxt, RegionVariableOrigin, SubregionOrigin, TypeTrace, ValuePairs}; -use infer::{self, SuppressRegionErrors}; +use crate::infer::{self, SuppressRegionErrors}; -use errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString}; -use hir; -use hir::def_id::DefId; -use hir::Node; -use middle::region; +use crate::errors::{Applicability, DiagnosticBuilder, DiagnosticStyledString}; +use crate::hir; +use crate::hir::def_id::DefId; +use crate::hir::Node; +use crate::middle::region; use std::{cmp, fmt}; use syntax::ast::DUMMY_NODE_ID; use syntax_pos::{Pos, Span}; -use traits::{ObligationCause, ObligationCauseCode}; -use ty::error::TypeError; -use ty::{self, subst::Subst, Region, Ty, TyCtxt, TyKind, TypeFoldable}; +use crate::traits::{ObligationCause, ObligationCauseCode}; +use crate::ty::error::TypeError; +use crate::ty::{self, subst::Subst, Region, Ty, TyCtxt, TyKind, TypeFoldable}; mod note; @@ -1479,7 +1479,7 @@ enum FailureCode { impl<'tcx> ObligationCause<'tcx> { fn as_failure_code(&self, terr: &TypeError<'tcx>) -> FailureCode { use self::FailureCode::*; - use traits::ObligationCauseCode::*; + use crate::traits::ObligationCauseCode::*; match self.code { CompareImplMethodObligation { .. } => Error0308("method not compatible with trait"), MatchExpressionArm { source, .. } => Error0308(match source { @@ -1509,7 +1509,7 @@ impl<'tcx> ObligationCause<'tcx> { } fn as_requirement_str(&self) -> &'static str { - use traits::ObligationCauseCode::*; + use crate::traits::ObligationCauseCode::*; match self.code { CompareImplMethodObligation { .. } => "method type is compatible with trait", ExprAssignable => "expression is assignable", diff --git a/src/librustc/infer/error_reporting/need_type_info.rs b/src/librustc/infer/error_reporting/need_type_info.rs index 8ee367c87c3ea..fac498bd6dd78 100644 --- a/src/librustc/infer/error_reporting/need_type_info.rs +++ b/src/librustc/infer/error_reporting/need_type_info.rs @@ -1,11 +1,11 @@ -use hir::{self, Local, Pat, Body, HirId}; -use hir::intravisit::{self, Visitor, NestedVisitorMap}; -use infer::InferCtxt; -use infer::type_variable::TypeVariableOrigin; -use ty::{self, Ty, Infer, TyVar}; +use crate::hir::{self, Local, Pat, Body, HirId}; +use crate::hir::intravisit::{self, Visitor, NestedVisitorMap}; +use crate::infer::InferCtxt; +use crate::infer::type_variable::TypeVariableOrigin; +use crate::ty::{self, Ty, Infer, TyVar}; use syntax::source_map::CompilerDesugaringKind; use syntax_pos::Span; -use errors::DiagnosticBuilder; +use crate::errors::DiagnosticBuilder; struct FindLocalByTypeVisitor<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> { infcx: &'a InferCtxt<'a, 'gcx, 'tcx>, diff --git a/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs b/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs index 8be49b2792441..0f4401517792c 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/different_lifetimes.rs @@ -1,9 +1,9 @@ //! Error Reporting for Anonymous Region Lifetime Errors //! where both the regions are anonymous. -use infer::error_reporting::nice_region_error::NiceRegionError; -use infer::error_reporting::nice_region_error::util::AnonymousArgInfo; -use util::common::ErrorReported; +use crate::infer::error_reporting::nice_region_error::NiceRegionError; +use crate::infer::error_reporting::nice_region_error::util::AnonymousArgInfo; +use crate::util::common::ErrorReported; impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { /// Print the error message for lifetime errors when both the concerned regions are anonymous. diff --git a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs index ebaef4977f400..ea748874fc4e2 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/find_anon_type.rs @@ -1,9 +1,9 @@ -use hir; -use ty::{self, Region, TyCtxt}; -use hir::Node; -use middle::resolve_lifetime as rl; -use hir::intravisit::{self, NestedVisitorMap, Visitor}; -use infer::error_reporting::nice_region_error::NiceRegionError; +use crate::hir; +use crate::ty::{self, Region, TyCtxt}; +use crate::hir::Node; +use crate::middle::resolve_lifetime as rl; +use crate::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use crate::infer::error_reporting::nice_region_error::NiceRegionError; impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { /// This function calls the `visit_ty` method for the parameters diff --git a/src/librustc/infer/error_reporting/nice_region_error/mod.rs b/src/librustc/infer/error_reporting/nice_region_error/mod.rs index d34b71c33f4b4..dad1e3ba80da3 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/mod.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/mod.rs @@ -1,9 +1,9 @@ -use infer::InferCtxt; -use infer::lexical_region_resolve::RegionResolutionError; -use infer::lexical_region_resolve::RegionResolutionError::*; +use crate::infer::InferCtxt; +use crate::infer::lexical_region_resolve::RegionResolutionError; +use crate::infer::lexical_region_resolve::RegionResolutionError::*; use syntax::source_map::Span; -use ty::{self, TyCtxt}; -use util::common::ErrorReported; +use crate::ty::{self, TyCtxt}; +use crate::util::common::ErrorReported; mod different_lifetimes; mod find_anon_type; diff --git a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs index 05333f4337336..d66bb274b34ce 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/named_anon_conflict.rs @@ -1,9 +1,9 @@ //! Error Reporting for Anonymous Region Lifetime Errors //! where one region is named and the other is anonymous. -use infer::error_reporting::nice_region_error::NiceRegionError; -use ty; -use util::common::ErrorReported; -use errors::Applicability; +use crate::infer::error_reporting::nice_region_error::NiceRegionError; +use crate::ty; +use crate::util::common::ErrorReported; +use crate::errors::Applicability; impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { /// When given a `ConcreteFailure` for a function with arguments containing a named region and diff --git a/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs b/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs index cbd36a8b2db8a..6432780de0670 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs @@ -1,13 +1,13 @@ //! Error Reporting for Anonymous Region Lifetime Errors //! where both the regions are anonymous. -use infer::error_reporting::nice_region_error::NiceRegionError; -use infer::SubregionOrigin; -use ty::RegionKind; -use hir::{Expr, ExprKind::Closure}; -use hir::Node; -use util::common::ErrorReported; -use infer::lexical_region_resolve::RegionResolutionError::SubSupConflict; +use crate::infer::error_reporting::nice_region_error::NiceRegionError; +use crate::infer::SubregionOrigin; +use crate::ty::RegionKind; +use crate::hir::{Expr, ExprKind::Closure}; +use crate::hir::Node; +use crate::util::common::ErrorReported; +use crate::infer::lexical_region_resolve::RegionResolutionError::SubSupConflict; impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { /// Print the error message for lifetime errors when binding escapes a closure. diff --git a/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs b/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs index ebac5a0c2a69e..6893a1fb168b8 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs @@ -1,15 +1,15 @@ -use errors::DiagnosticBuilder; -use hir::def_id::DefId; -use infer::error_reporting::nice_region_error::NiceRegionError; -use infer::lexical_region_resolve::RegionResolutionError; -use infer::ValuePairs; -use infer::{SubregionOrigin, TypeTrace}; -use traits::{ObligationCause, ObligationCauseCode}; -use ty; -use ty::error::ExpectedFound; -use ty::subst::Substs; -use util::common::ErrorReported; -use util::ppaux::RegionHighlightMode; +use crate::errors::DiagnosticBuilder; +use crate::hir::def_id::DefId; +use crate::infer::error_reporting::nice_region_error::NiceRegionError; +use crate::infer::lexical_region_resolve::RegionResolutionError; +use crate::infer::ValuePairs; +use crate::infer::{SubregionOrigin, TypeTrace}; +use crate::traits::{ObligationCause, ObligationCauseCode}; +use crate::ty; +use crate::ty::error::ExpectedFound; +use crate::ty::subst::Substs; +use crate::util::common::ErrorReported; +use crate::util::ppaux::RegionHighlightMode; impl NiceRegionError<'me, 'gcx, 'tcx> { /// When given a `ConcreteFailure` for a function with arguments containing a named region and diff --git a/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs b/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs index 4331518d403dd..3f0297952278a 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/static_impl_trait.rs @@ -1,10 +1,10 @@ //! Error Reporting for static impl Traits. -use infer::error_reporting::nice_region_error::NiceRegionError; -use infer::lexical_region_resolve::RegionResolutionError; -use ty::{BoundRegion, FreeRegion, RegionKind}; -use util::common::ErrorReported; -use errors::Applicability; +use crate::infer::error_reporting::nice_region_error::NiceRegionError; +use crate::infer::lexical_region_resolve::RegionResolutionError; +use crate::ty::{BoundRegion, FreeRegion, RegionKind}; +use crate::util::common::ErrorReported; +use crate::errors::Applicability; impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { /// Print the error message for lifetime errors when the return type is a static impl Trait. diff --git a/src/librustc/infer/error_reporting/nice_region_error/util.rs b/src/librustc/infer/error_reporting/nice_region_error/util.rs index dd8a33829eb53..f73f8d8bb82be 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/util.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/util.rs @@ -1,10 +1,10 @@ //! Helper functions corresponding to lifetime errors due to //! anonymous regions. -use hir; -use infer::error_reporting::nice_region_error::NiceRegionError; -use ty::{self, Region, Ty}; -use hir::def_id::DefId; +use crate::hir; +use crate::infer::error_reporting::nice_region_error::NiceRegionError; +use crate::ty::{self, Region, Ty}; +use crate::hir::def_id::DefId; use syntax_pos::Span; // The struct contains the information about the anonymous region diff --git a/src/librustc/infer/error_reporting/note.rs b/src/librustc/infer/error_reporting/note.rs index e45a4b17cdd9c..efd7f3c55e900 100644 --- a/src/librustc/infer/error_reporting/note.rs +++ b/src/librustc/infer/error_reporting/note.rs @@ -1,8 +1,8 @@ -use infer::{self, InferCtxt, SubregionOrigin}; -use middle::region; -use ty::{self, Region}; -use ty::error::TypeError; -use errors::DiagnosticBuilder; +use crate::infer::{self, InferCtxt, SubregionOrigin}; +use crate::middle::region; +use crate::ty::{self, Region}; +use crate::ty::error::TypeError; +use crate::errors::DiagnosticBuilder; impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { pub(super) fn note_region_origin(&self, diff --git a/src/librustc/infer/freshen.rs b/src/librustc/infer/freshen.rs index 74abcf82529cb..201717b34ee41 100644 --- a/src/librustc/infer/freshen.rs +++ b/src/librustc/infer/freshen.rs @@ -31,9 +31,9 @@ //! 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 ty::{self, Ty, TyCtxt, TypeFoldable}; -use ty::fold::TypeFolder; -use util::nodemap::FxHashMap; +use crate::ty::{self, Ty, TyCtxt, TypeFoldable}; +use crate::ty::fold::TypeFolder; +use crate::util::nodemap::FxHashMap; use std::collections::hash_map::Entry; diff --git a/src/librustc/infer/fudge.rs b/src/librustc/infer/fudge.rs index a38db5d210f7b..d205cfcf73b7e 100644 --- a/src/librustc/infer/fudge.rs +++ b/src/librustc/infer/fudge.rs @@ -1,6 +1,6 @@ -use infer::type_variable::TypeVariableMap; -use ty::{self, Ty, TyCtxt}; -use ty::fold::{TypeFoldable, TypeFolder}; +use crate::infer::type_variable::TypeVariableMap; +use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::fold::{TypeFoldable, TypeFolder}; use super::InferCtxt; use super::RegionVariableOrigin; diff --git a/src/librustc/infer/glb.rs b/src/librustc/infer/glb.rs index 635a6d00270b7..910c6571853dc 100644 --- a/src/librustc/infer/glb.rs +++ b/src/librustc/infer/glb.rs @@ -3,9 +3,9 @@ use super::InferCtxt; use super::lattice::{self, LatticeDir}; use super::Subtype; -use traits::ObligationCause; -use ty::{self, Ty, TyCtxt}; -use ty::relate::{Relate, RelateResult, TypeRelation}; +use crate::traits::ObligationCause; +use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::relate::{Relate, RelateResult, TypeRelation}; /// "Greatest lower bound" (common subtype) pub struct Glb<'combine, 'infcx: 'combine, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { diff --git a/src/librustc/infer/higher_ranked/mod.rs b/src/librustc/infer/higher_ranked/mod.rs index 709e8c0ba9b24..c7fc446b9787b 100644 --- a/src/librustc/infer/higher_ranked/mod.rs +++ b/src/librustc/infer/higher_ranked/mod.rs @@ -4,8 +4,8 @@ use super::combine::CombineFields; use super::{HigherRankedType, InferCtxt, PlaceholderMap}; -use ty::relate::{Relate, RelateResult, TypeRelation}; -use ty::{self, Binder, TypeFoldable}; +use crate::ty::relate::{Relate, RelateResult, TypeRelation}; +use crate::ty::{self, Binder, TypeFoldable}; impl<'a, 'gcx, 'tcx> CombineFields<'a, 'gcx, 'tcx> { pub fn higher_ranked_sub( diff --git a/src/librustc/infer/lattice.rs b/src/librustc/infer/lattice.rs index a8794b4076a9d..dfa086a64de61 100644 --- a/src/librustc/infer/lattice.rs +++ b/src/librustc/infer/lattice.rs @@ -22,10 +22,10 @@ use super::InferCtxt; use super::type_variable::TypeVariableOrigin; -use traits::ObligationCause; -use ty::TyVar; -use ty::{self, Ty}; -use ty::relate::{RelateResult, TypeRelation}; +use crate::traits::ObligationCause; +use crate::ty::TyVar; +use crate::ty::{self, Ty}; +use crate::ty::relate::{RelateResult, TypeRelation}; pub trait LatticeDir<'f, 'gcx: 'f+'tcx, 'tcx: 'f> : TypeRelation<'f, 'gcx, 'tcx> { fn infcx(&self) -> &'f InferCtxt<'f, 'gcx, 'tcx>; diff --git a/src/librustc/infer/lexical_region_resolve/graphviz.rs b/src/librustc/infer/lexical_region_resolve/graphviz.rs index 7ce2aba54f5cc..073a3f74422c6 100644 --- a/src/librustc/infer/lexical_region_resolve/graphviz.rs +++ b/src/librustc/infer/lexical_region_resolve/graphviz.rs @@ -8,14 +8,14 @@ /// For clarity, rename the graphviz crate locally to dot. use graphviz as dot; -use hir::def_id::DefIndex; -use ty; -use middle::free_region::RegionRelations; -use middle::region; +use crate::hir::def_id::DefIndex; +use crate::ty; +use crate::middle::free_region::RegionRelations; +use crate::middle::region; use super::Constraint; -use infer::SubregionOrigin; -use infer::region_constraints::RegionConstraintData; -use util::nodemap::{FxHashMap, FxHashSet}; +use crate::infer::SubregionOrigin; +use crate::infer::region_constraints::RegionConstraintData; +use crate::util::nodemap::{FxHashMap, FxHashSet}; use std::borrow::Cow; use std::collections::hash_map::Entry::Vacant; diff --git a/src/librustc/infer/lexical_region_resolve/mod.rs b/src/librustc/infer/lexical_region_resolve/mod.rs index c0952fefac0e1..7add8a26ede09 100644 --- a/src/librustc/infer/lexical_region_resolve/mod.rs +++ b/src/librustc/infer/lexical_region_resolve/mod.rs @@ -1,13 +1,13 @@ //! The code to do lexical region resolution. -use infer::region_constraints::Constraint; -use infer::region_constraints::GenericKind; -use infer::region_constraints::RegionConstraintData; -use infer::region_constraints::VarInfos; -use infer::region_constraints::VerifyBound; -use infer::RegionVariableOrigin; -use infer::SubregionOrigin; -use middle::free_region::RegionRelations; +use crate::infer::region_constraints::Constraint; +use crate::infer::region_constraints::GenericKind; +use crate::infer::region_constraints::RegionConstraintData; +use crate::infer::region_constraints::VarInfos; +use crate::infer::region_constraints::VerifyBound; +use crate::infer::RegionVariableOrigin; +use crate::infer::SubregionOrigin; +use crate::middle::free_region::RegionRelations; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::graph::implementation::{ Direction, Graph, NodeIndex, INCOMING, OUTGOING, @@ -16,11 +16,11 @@ use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use smallvec::SmallVec; use std::fmt; use std::u32; -use ty::fold::TypeFoldable; -use ty::{self, Ty, TyCtxt}; -use ty::{ReEarlyBound, ReEmpty, ReErased, ReFree, ReStatic}; -use ty::{ReLateBound, ReScope, RePlaceholder, ReVar}; -use ty::{Region, RegionVid}; +use crate::ty::fold::TypeFoldable; +use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::{ReEarlyBound, ReEmpty, ReErased, ReFree, ReStatic}; +use crate::ty::{ReLateBound, ReScope, RePlaceholder, ReVar}; +use crate::ty::{Region, RegionVid}; mod graphviz; diff --git a/src/librustc/infer/lub.rs b/src/librustc/infer/lub.rs index 0b9839f69fa2a..f9eb60d82d17b 100644 --- a/src/librustc/infer/lub.rs +++ b/src/librustc/infer/lub.rs @@ -3,9 +3,9 @@ use super::InferCtxt; use super::lattice::{self, LatticeDir}; use super::Subtype; -use traits::ObligationCause; -use ty::{self, Ty, TyCtxt}; -use ty::relate::{Relate, RelateResult, TypeRelation}; +use crate::traits::ObligationCause; +use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::relate::{Relate, RelateResult, TypeRelation}; /// "Least upper bound" (common supertype) pub struct Lub<'combine, 'infcx: 'combine, 'gcx: 'infcx+'tcx, 'tcx: 'infcx> { diff --git a/src/librustc/infer/mod.rs b/src/librustc/infer/mod.rs index 958982545750f..06c94d133344c 100644 --- a/src/librustc/infer/mod.rs +++ b/src/librustc/infer/mod.rs @@ -5,31 +5,31 @@ pub use self::LateBoundRegionConversionTime::*; pub use self::RegionVariableOrigin::*; pub use self::SubregionOrigin::*; pub use self::ValuePairs::*; -pub use ty::IntVarValue; +pub use crate::ty::IntVarValue; use arena::SyncDroplessArena; -use errors::DiagnosticBuilder; -use hir::def_id::DefId; -use infer::canonical::{Canonical, CanonicalVarValues}; -use middle::free_region::RegionRelations; -use middle::lang_items; -use middle::region; +use crate::errors::DiagnosticBuilder; +use crate::hir::def_id::DefId; +use crate::infer::canonical::{Canonical, CanonicalVarValues}; +use crate::middle::free_region::RegionRelations; +use crate::middle::lang_items; +use crate::middle::region; use rustc_data_structures::unify as ut; -use session::config::BorrowckMode; +use crate::session::config::BorrowckMode; use std::cell::{Cell, Ref, RefCell, RefMut}; use std::collections::BTreeMap; use std::fmt; use syntax::ast; use syntax_pos::symbol::InternedString; use syntax_pos::{self, Span}; -use traits::{self, ObligationCause, PredicateObligations, TraitEngine}; -use ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric}; -use ty::fold::TypeFoldable; -use ty::relate::RelateResult; -use ty::subst::{Kind, Substs}; -use ty::{self, GenericParamDefKind, Ty, TyCtxt, CtxtInterners}; -use ty::{FloatVid, IntVid, TyVid}; -use util::nodemap::FxHashMap; +use crate::traits::{self, ObligationCause, PredicateObligations, TraitEngine}; +use crate::ty::error::{ExpectedFound, TypeError, UnconstrainedNumeric}; +use crate::ty::fold::TypeFoldable; +use crate::ty::relate::RelateResult; +use crate::ty::subst::{Kind, Substs}; +use crate::ty::{self, GenericParamDefKind, Ty, TyCtxt, CtxtInterners}; +use crate::ty::{FloatVid, IntVid, TyVid}; +use crate::util::nodemap::FxHashMap; use self::combine::CombineFields; use self::lexical_region_resolve::LexicalRegionResolutions; @@ -617,8 +617,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } pub fn type_is_unconstrained_numeric(&'a self, ty: Ty<'_>) -> UnconstrainedNumeric { - use ty::error::UnconstrainedNumeric::Neither; - use ty::error::UnconstrainedNumeric::{UnconstrainedFloat, UnconstrainedInt}; + use crate::ty::error::UnconstrainedNumeric::Neither; + use crate::ty::error::UnconstrainedNumeric::{UnconstrainedFloat, UnconstrainedInt}; match ty.sty { ty::Infer(ty::IntVar(vid)) => { if self.int_unification_table diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs index 5e94bb1f877fb..e28157f05f15f 100644 --- a/src/librustc/infer/opaque_types/mod.rs +++ b/src/librustc/infer/opaque_types/mod.rs @@ -1,16 +1,16 @@ -use hir::def_id::DefId; -use hir; -use hir::Node; -use infer::{self, InferCtxt, InferOk, TypeVariableOrigin}; -use infer::outlives::free_region_map::FreeRegionRelations; +use crate::hir::def_id::DefId; +use crate::hir; +use crate::hir::Node; +use crate::infer::{self, InferCtxt, InferOk, TypeVariableOrigin}; +use crate::infer::outlives::free_region_map::FreeRegionRelations; use rustc_data_structures::fx::FxHashMap; use syntax::ast; -use traits::{self, PredicateObligation}; -use ty::{self, Ty, TyCtxt, GenericParamDefKind}; -use ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder}; -use ty::outlives::Component; -use ty::subst::{Kind, Substs, UnpackedKind}; -use util::nodemap::DefIdMap; +use crate::traits::{self, PredicateObligation}; +use crate::ty::{self, Ty, TyCtxt, GenericParamDefKind}; +use crate::ty::fold::{BottomUpFolder, TypeFoldable, TypeFolder}; +use crate::ty::outlives::Component; +use crate::ty::subst::{Kind, Substs, UnpackedKind}; +use crate::util::nodemap::DefIdMap; pub type OpaqueTypeMap<'tcx> = DefIdMap>; diff --git a/src/librustc/infer/outlives/env.rs b/src/librustc/infer/outlives/env.rs index 677b6136ea03b..20d03f3c6edb5 100644 --- a/src/librustc/infer/outlives/env.rs +++ b/src/librustc/infer/outlives/env.rs @@ -1,10 +1,10 @@ -use infer::outlives::free_region_map::FreeRegionMap; -use infer::{GenericKind, InferCtxt}; +use crate::infer::outlives::free_region_map::FreeRegionMap; +use crate::infer::{GenericKind, InferCtxt}; use rustc_data_structures::fx::FxHashMap; use syntax::ast; use syntax_pos::Span; -use traits::query::outlives_bounds::{self, OutlivesBound}; -use ty::{self, Ty}; +use crate::traits::query::outlives_bounds::{self, OutlivesBound}; +use crate::ty::{self, Ty}; /// The `OutlivesEnvironment` collects information about what outlives /// what in a given type-checking setting. For example, if we have a diff --git a/src/librustc/infer/outlives/free_region_map.rs b/src/librustc/infer/outlives/free_region_map.rs index a6703c9d679da..7daf6d71980f6 100644 --- a/src/librustc/infer/outlives/free_region_map.rs +++ b/src/librustc/infer/outlives/free_region_map.rs @@ -1,4 +1,4 @@ -use ty::{self, Lift, TyCtxt, Region}; +use crate::ty::{self, Lift, TyCtxt, Region}; use rustc_data_structures::transitive_relation::TransitiveRelation; #[derive(Clone, RustcEncodable, RustcDecodable, Debug, Default)] diff --git a/src/librustc/infer/outlives/obligations.rs b/src/librustc/infer/outlives/obligations.rs index abe835c9211a5..884bd58b4023b 100644 --- a/src/librustc/infer/outlives/obligations.rs +++ b/src/librustc/infer/outlives/obligations.rs @@ -59,14 +59,14 @@ //! might later infer `?U` to something like `&'b u32`, which would //! imply that `'b: 'a`. -use infer::outlives::env::RegionBoundPairs; -use infer::outlives::verify::VerifyBoundCx; -use infer::{self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, VerifyBound}; +use crate::infer::outlives::env::RegionBoundPairs; +use crate::infer::outlives::verify::VerifyBoundCx; +use crate::infer::{self, GenericKind, InferCtxt, RegionObligation, SubregionOrigin, VerifyBound}; use rustc_data_structures::fx::FxHashMap; use syntax::ast; -use traits::ObligationCause; -use ty::outlives::Component; -use ty::{self, Region, Ty, TyCtxt, TypeFoldable}; +use crate::traits::ObligationCause; +use crate::ty::outlives::Component; +use crate::ty::{self, Region, Ty, TyCtxt, TypeFoldable}; impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { /// Registers that the given region obligation must be resolved diff --git a/src/librustc/infer/outlives/verify.rs b/src/librustc/infer/outlives/verify.rs index 4e9a8e9ded899..0457e7179461c 100644 --- a/src/librustc/infer/outlives/verify.rs +++ b/src/librustc/infer/outlives/verify.rs @@ -1,10 +1,10 @@ -use hir::def_id::DefId; -use infer::outlives::env::RegionBoundPairs; -use infer::{GenericKind, VerifyBound}; -use traits; -use ty::subst::{Subst, Substs}; -use ty::{self, Ty, TyCtxt}; -use util::captures::Captures; +use crate::hir::def_id::DefId; +use crate::infer::outlives::env::RegionBoundPairs; +use crate::infer::{GenericKind, VerifyBound}; +use crate::traits; +use crate::ty::subst::{Subst, Substs}; +use crate::ty::{self, Ty, TyCtxt}; +use crate::util::captures::Captures; /// The `TypeOutlives` struct has the job of "lowering" a `T: 'a` /// obligation into a series of `'a: 'b` constraints and "verifys", as diff --git a/src/librustc/infer/region_constraints/mod.rs b/src/librustc/infer/region_constraints/mod.rs index 56ae850226c91..500497dc011e1 100644 --- a/src/librustc/infer/region_constraints/mod.rs +++ b/src/librustc/infer/region_constraints/mod.rs @@ -9,10 +9,10 @@ use super::{MiscVariable, RegionVariableOrigin, SubregionOrigin}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_data_structures::indexed_vec::IndexVec; use rustc_data_structures::unify as ut; -use ty::ReStatic; -use ty::{self, Ty, TyCtxt}; -use ty::{BrFresh, ReLateBound, ReVar}; -use ty::{Region, RegionVid}; +use crate::ty::ReStatic; +use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::{BrFresh, ReLateBound, ReVar}; +use crate::ty::{Region, RegionVid}; use std::collections::BTreeMap; use std::{cmp, fmt, mem, u32}; diff --git a/src/librustc/infer/resolve.rs b/src/librustc/infer/resolve.rs index f6131c01b372f..4a8f0c34ead11 100644 --- a/src/librustc/infer/resolve.rs +++ b/src/librustc/infer/resolve.rs @@ -1,6 +1,6 @@ use super::{InferCtxt, FixupError, FixupResult}; -use ty::{self, Ty, TyCtxt, TypeFoldable}; -use ty::fold::{TypeFolder, TypeVisitor}; +use crate::ty::{self, Ty, TyCtxt, TypeFoldable}; +use crate::ty::fold::{TypeFolder, TypeVisitor}; /////////////////////////////////////////////////////////////////////////// // OPPORTUNISTIC TYPE RESOLVER diff --git a/src/librustc/infer/sub.rs b/src/librustc/infer/sub.rs index df76d1d3afb34..0cff42742c30a 100644 --- a/src/librustc/infer/sub.rs +++ b/src/librustc/infer/sub.rs @@ -1,11 +1,11 @@ use super::SubregionOrigin; use super::combine::{CombineFields, RelationDir}; -use traits::Obligation; -use ty::{self, Ty, TyCtxt}; -use ty::TyVar; -use ty::fold::TypeFoldable; -use ty::relate::{Cause, Relate, RelateResult, TypeRelation}; +use crate::traits::Obligation; +use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::TyVar; +use crate::ty::fold::TypeFoldable; +use crate::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/infer/type_variable.rs b/src/librustc/infer/type_variable.rs index 3ec27bdcf1bcd..14f3261bfc203 100644 --- a/src/librustc/infer/type_variable.rs +++ b/src/librustc/infer/type_variable.rs @@ -1,6 +1,6 @@ use syntax::symbol::InternedString; use syntax_pos::Span; -use ty::{self, Ty}; +use crate::ty::{self, Ty}; use std::cmp; use std::marker::PhantomData; diff --git a/src/librustc/infer/unify_key.rs b/src/librustc/infer/unify_key.rs index 068ff0c90e7fc..09f800d9f9bfc 100644 --- a/src/librustc/infer/unify_key.rs +++ b/src/librustc/infer/unify_key.rs @@ -1,4 +1,4 @@ -use ty::{self, FloatVarValue, IntVarValue, Ty, TyCtxt}; +use crate::ty::{self, FloatVarValue, IntVarValue, Ty, TyCtxt}; use rustc_data_structures::unify::{NoError, EqUnifyValue, UnifyKey, UnifyValue}; pub trait ToType { diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index f886e50246ac0..d19513515201e 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -30,6 +30,9 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] +#![deny(rust_2018_idioms)] +#![allow(explicit_outlives_requirements)] + #![feature(box_patterns)] #![feature(box_syntax)] #![feature(core_intrinsics)] @@ -64,41 +67,24 @@ #![warn(elided_lifetimes_in_paths)] -extern crate arena; #[macro_use] extern crate bitflags; -extern crate core; -extern crate fmt_macros; extern crate getopts; -extern crate graphviz; -extern crate num_cpus; #[macro_use] extern crate lazy_static; #[macro_use] extern crate scoped_tls; #[cfg(windows)] extern crate libc; -extern crate polonius_engine; -extern crate rustc_target; #[macro_use] extern crate rustc_data_structures; -extern crate serialize; -extern crate parking_lot; -extern crate rustc_errors as errors; -extern crate rustc_rayon as rayon; -extern crate rustc_rayon_core as rayon_core; + #[macro_use] extern crate log; #[macro_use] extern crate syntax; -extern crate syntax_pos; -extern crate jobserver; -extern crate proc_macro; -extern crate chalk_engine; -extern crate rustc_fs_util; -extern crate serialize as rustc_serialize; // used by deriving +// FIXME: This import is used by deriving `RustcDecodable` and `RustcEncodable`. Removing this +// results in a bunch of "failed to resolve" errors. Hopefully, the compiler moves to serde or +// something, and we can get rid of this. +#[allow(rust_2018_idioms)] +extern crate serialize as rustc_serialize; -extern crate rustc_apfloat; -extern crate byteorder; -extern crate backtrace; - -#[macro_use] -extern crate smallvec; +#[macro_use] extern crate smallvec; // Note that librustc doesn't actually depend on these crates, see the note in // `Cargo.toml` for this crate about why these are here. @@ -166,9 +152,11 @@ pub mod util { // `libstd` uses the same trick. #[doc(hidden)] mod rustc { - pub use lint; + pub use crate::lint; } +use rustc_errors as errors; + // FIXME(#27438): right now the unit tests of librustc don't refer to any actual // functions generated in librustc_data_structures (all // references are through generic functions), but statics are diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 3fe544d690640..6ae7448645a20 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -4,9 +4,9 @@ //! compiler code, rather than using their own custom pass. Those //! lints are all available in `rustc_lint::builtin`. -use errors::{Applicability, DiagnosticBuilder}; -use lint::{LintPass, LateLintPass, LintArray}; -use session::Session; +use crate::errors::{Applicability, DiagnosticBuilder}; +use crate::lint::{LintPass, LateLintPass, LintArray}; +use crate::session::Session; use syntax::ast; use syntax::source_map::Span; diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 394e404fb881f..27ead805d5dbd 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -18,26 +18,26 @@ use self::TargetLint::*; use std::slice; use rustc_data_structures::sync::ReadGuard; -use lint::{EarlyLintPass, EarlyLintPassObject, LateLintPassObject}; -use lint::{LintArray, Level, Lint, LintId, LintPass, LintBuffer}; -use lint::builtin::BuiltinLintDiagnostics; -use lint::levels::{LintLevelSets, LintLevelsBuilder}; -use middle::privacy::AccessLevels; -use rustc_serialize::{Decoder, Decodable, Encoder, Encodable}; -use session::{config, early_error, Session}; -use ty::{self, TyCtxt, Ty}; -use ty::layout::{LayoutError, LayoutOf, TyLayout}; -use util::nodemap::FxHashMap; -use util::common::time; +use crate::lint::{EarlyLintPass, EarlyLintPassObject, LateLintPassObject}; +use crate::lint::{LintArray, Level, Lint, LintId, LintPass, LintBuffer}; +use crate::lint::builtin::BuiltinLintDiagnostics; +use crate::lint::levels::{LintLevelSets, LintLevelsBuilder}; +use crate::middle::privacy::AccessLevels; +use crate::rustc_serialize::{Decoder, Decodable, Encoder, Encodable}; +use crate::session::{config, early_error, Session}; +use crate::ty::{self, TyCtxt, Ty}; +use crate::ty::layout::{LayoutError, LayoutOf, TyLayout}; +use crate::util::nodemap::FxHashMap; +use crate::util::common::time; use std::default::Default as StdDefault; use syntax::ast; use syntax::edition; use syntax_pos::{MultiSpan, Span, symbol::{LocalInternedString, Symbol}}; -use errors::DiagnosticBuilder; -use hir; -use hir::def_id::LOCAL_CRATE; -use hir::intravisit as hir_visit; +use crate::errors::DiagnosticBuilder; +use crate::hir; +use crate::hir::def_id::LOCAL_CRATE; +use crate::hir::intravisit as hir_visit; use syntax::util::lev_distance::find_best_match_for_name; use syntax::visit as ast_visit; diff --git a/src/librustc/lint/levels.rs b/src/librustc/lint/levels.rs index 616915769435d..62bd54de7c929 100644 --- a/src/librustc/lint/levels.rs +++ b/src/librustc/lint/levels.rs @@ -1,20 +1,20 @@ use std::cmp; -use errors::{Applicability, DiagnosticBuilder}; -use hir::HirId; -use ich::StableHashingContext; -use lint::builtin; -use lint::context::CheckLintNameResult; -use lint::{self, Lint, LintId, Level, LintSource}; +use crate::errors::{Applicability, DiagnosticBuilder}; +use crate::hir::HirId; +use crate::ich::StableHashingContext; +use crate::lint::builtin; +use crate::lint::context::CheckLintNameResult; +use crate::lint::{self, Lint, LintId, Level, LintSource}; use rustc_data_structures::stable_hasher::{HashStable, ToStableHashKey, StableHasher, StableHasherResult}; -use session::Session; +use crate::session::Session; use syntax::ast; use syntax::attr; use syntax::feature_gate; use syntax::source_map::MultiSpan; use syntax::symbol::Symbol; -use util::nodemap::FxHashMap; +use crate::util::nodemap::FxHashMap; pub struct LintLevelSets { list: Vec, diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index a95fa350bf1c3..4e6bf753b01aa 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -23,13 +23,13 @@ pub use self::LintSource::*; use rustc_data_structures::sync::{self, Lrc}; -use errors::{DiagnosticBuilder, DiagnosticId}; -use hir::def_id::{CrateNum, LOCAL_CRATE}; -use hir::intravisit; -use hir; -use lint::builtin::BuiltinLintDiagnostics; -use lint::builtin::parser::{QUESTION_MARK_MACRO_SEP, ILL_FORMED_ATTRIBUTE_INPUT}; -use session::{Session, DiagnosticMessageId}; +use crate::errors::{DiagnosticBuilder, DiagnosticId}; +use crate::hir::def_id::{CrateNum, LOCAL_CRATE}; +use crate::hir::intravisit; +use crate::hir; +use crate::lint::builtin::BuiltinLintDiagnostics; +use crate::lint::builtin::parser::{QUESTION_MARK_MACRO_SEP, ILL_FORMED_ATTRIBUTE_INPUT}; +use crate::session::{Session, DiagnosticMessageId}; use std::{hash, ptr}; use syntax::ast; use syntax::source_map::{MultiSpan, ExpnFormat}; @@ -37,11 +37,11 @@ use syntax::early_buffered_lints::BufferedEarlyLintId; use syntax::edition::Edition; use syntax::symbol::Symbol; use syntax_pos::Span; -use ty::TyCtxt; -use ty::query::Providers; -use util::nodemap::NodeMap; +use crate::ty::TyCtxt; +use crate::ty::query::Providers; +use crate::util::nodemap::NodeMap; -pub use lint::context::{LateContext, EarlyContext, LintContext, LintStore, +pub use crate::lint::context::{LateContext, EarlyContext, LintContext, LintStore, check_crate, check_ast_crate, CheckLintNameResult, FutureIncompatibleInfo, BufferedEarlyLint}; @@ -678,7 +678,7 @@ pub fn struct_lint_level<'a>(sess: &'a Session, "this was previously accepted by the compiler but is being phased out; \ it will become a hard error"; - let explanation = if lint_id == LintId::of(::lint::builtin::UNSTABLE_NAME_COLLISIONS) { + let explanation = if lint_id == LintId::of(crate::lint::builtin::UNSTABLE_NAME_COLLISIONS) { "once this method is added to the standard library, \ the ambiguity may cause an error or change in behavior!" .to_owned() diff --git a/src/librustc/middle/borrowck.rs b/src/librustc/middle/borrowck.rs index 120ba6b1d4e9f..2799f9424d919 100644 --- a/src/librustc/middle/borrowck.rs +++ b/src/librustc/middle/borrowck.rs @@ -1,6 +1,6 @@ -use ich::StableHashingContext; -use hir::HirId; -use util::nodemap::FxHashSet; +use crate::ich::StableHashingContext; +use crate::hir::HirId; +use crate::util::nodemap::FxHashSet; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 9168bbf907f1e..6e9552a1e9209 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -2,13 +2,13 @@ //! are *mostly* used as a part of that interface, but these should //! probably get a better home if someone can find one. -use hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; -use hir::map as hir_map; -use hir::map::definitions::{DefKey, DefPathTable}; +use crate::hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; +use crate::hir::map as hir_map; +use crate::hir::map::definitions::{DefKey, DefPathTable}; use rustc_data_structures::svh::Svh; -use ty::{self, TyCtxt}; -use session::{Session, CrateDisambiguator}; -use session::search_paths::PathKind; +use crate::ty::{self, TyCtxt}; +use crate::session::{Session, CrateDisambiguator}; +use crate::session::search_paths::PathKind; use std::any::Any; use std::path::{Path, PathBuf}; diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index abbf0ae210c25..6dffe8efba612 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -2,18 +2,18 @@ // closely. The idea is that all reachable symbols are live, codes called // from live codes are live, and everything else is dead. -use hir::Node; -use hir::{self, PatKind}; -use hir::intravisit::{self, Visitor, NestedVisitorMap}; -use hir::itemlikevisit::ItemLikeVisitor; - -use hir::def::Def; -use hir::CodegenFnAttrFlags; -use hir::def_id::{DefId, LOCAL_CRATE}; -use lint; -use middle::privacy; -use ty::{self, TyCtxt}; -use util::nodemap::FxHashSet; +use crate::hir::Node; +use crate::hir::{self, PatKind}; +use crate::hir::intravisit::{self, Visitor, NestedVisitorMap}; +use crate::hir::itemlikevisit::ItemLikeVisitor; + +use crate::hir::def::Def; +use crate::hir::CodegenFnAttrFlags; +use crate::hir::def_id::{DefId, LOCAL_CRATE}; +use crate::lint; +use crate::middle::privacy; +use crate::ty::{self, TyCtxt}; +use crate::util::nodemap::FxHashSet; use rustc_data_structures::fx::FxHashMap; diff --git a/src/librustc/middle/dependency_format.rs b/src/librustc/middle/dependency_format.rs index 16c9344a03722..a24d25cba1184 100644 --- a/src/librustc/middle/dependency_format.rs +++ b/src/librustc/middle/dependency_format.rs @@ -51,13 +51,13 @@ //! Additionally, the algorithm is geared towards finding *any* solution rather //! than finding a number of solutions (there are normally quite a few). -use hir::def_id::CrateNum; +use crate::hir::def_id::CrateNum; -use session::config; -use ty::TyCtxt; -use middle::cstore::{self, DepKind}; -use middle::cstore::LinkagePreference::{self, RequireStatic, RequireDynamic}; -use util::nodemap::FxHashMap; +use crate::session::config; +use crate::ty::TyCtxt; +use crate::middle::cstore::{self, DepKind}; +use crate::middle::cstore::LinkagePreference::{self, RequireStatic, RequireDynamic}; +use crate::util::nodemap::FxHashMap; use rustc_target::spec::PanicStrategy; /// A list of dependencies for a certain crate type. diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 218ca3b7553c0..2d0e6c3917bb8 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -1,15 +1,15 @@ -use hir::map as hir_map; -use hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, LOCAL_CRATE}; -use session::{config, Session}; -use session::config::EntryFnType; +use crate::hir::map as hir_map; +use crate::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, LOCAL_CRATE}; +use crate::session::{config, Session}; +use crate::session::config::EntryFnType; use syntax::ast::NodeId; use syntax::attr; use syntax::entry::EntryPointType; use syntax_pos::Span; -use hir::{Item, ItemKind, ImplItem, TraitItem}; -use hir::itemlikevisit::ItemLikeVisitor; -use ty::TyCtxt; -use ty::query::Providers; +use crate::hir::{Item, ItemKind, ImplItem, TraitItem}; +use crate::hir::itemlikevisit::ItemLikeVisitor; +use crate::ty::TyCtxt; +use crate::ty::query::Providers; struct EntryContext<'a, 'tcx: 'a> { session: &'a Session, diff --git a/src/librustc/middle/exported_symbols.rs b/src/librustc/middle/exported_symbols.rs index a0a73ea0b81fb..6c43068a22772 100644 --- a/src/librustc/middle/exported_symbols.rs +++ b/src/librustc/middle/exported_symbols.rs @@ -1,11 +1,11 @@ -use hir::def_id::{DefId, LOCAL_CRATE}; -use ich::StableHashingContext; +use crate::hir::def_id::{DefId, LOCAL_CRATE}; +use crate::ich::StableHashingContext; use rustc_data_structures::stable_hasher::{StableHasher, HashStable, StableHasherResult}; use std::cmp; use std::mem; -use ty; -use ty::subst::Substs; +use crate::ty; +use crate::ty::subst::Substs; /// The SymbolExportLevel of a symbols specifies from which kinds of crates /// the symbol will be exported. `C` symbols will be exported from any diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 08210c3f075ce..0939f07f43bb3 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -9,20 +9,20 @@ pub use self::MatchMode::*; use self::TrackMatchMode::*; use self::OverloadedCallType::*; -use hir::def::Def; -use hir::def_id::DefId; -use infer::InferCtxt; -use middle::mem_categorization as mc; -use middle::region; -use ty::{self, TyCtxt, adjustment}; - -use hir::{self, PatKind}; +use crate::hir::def::Def; +use crate::hir::def_id::DefId; +use crate::infer::InferCtxt; +use crate::middle::mem_categorization as mc; +use crate::middle::region; +use crate::ty::{self, TyCtxt, adjustment}; + +use crate::hir::{self, PatKind}; use rustc_data_structures::sync::Lrc; use std::rc::Rc; use syntax::ast; use syntax::ptr::P; use syntax_pos::Span; -use util::nodemap::ItemLocalSet; +use crate::util::nodemap::ItemLocalSet; /////////////////////////////////////////////////////////////////////////// // The Delegate trait diff --git a/src/librustc/middle/free_region.rs b/src/librustc/middle/free_region.rs index 6e9eadca6a521..e752643e842aa 100644 --- a/src/librustc/middle/free_region.rs +++ b/src/librustc/middle/free_region.rs @@ -5,10 +5,10 @@ //! `TransitiveRelation` type and use that to decide when one free //! region outlives another and so forth. -use infer::outlives::free_region_map::{FreeRegionMap, FreeRegionRelations}; -use hir::def_id::DefId; -use middle::region; -use ty::{self, TyCtxt, Region}; +use crate::infer::outlives::free_region_map::{FreeRegionMap, FreeRegionRelations}; +use crate::hir::def_id::DefId; +use crate::middle::region; +use crate::ty::{self, TyCtxt, Region}; /// Combines a `region::ScopeTree` (which governs relationships between /// scopes) and a `FreeRegionMap` (which governs relationships between diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index 29d3713900ad9..ee361e9776313 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -1,14 +1,14 @@ -use hir::def::Def; -use hir::def_id::DefId; -use ty::{self, Ty, TyCtxt}; -use ty::layout::{LayoutError, Pointer, SizeSkeleton, VariantIdx}; -use ty::query::Providers; +use crate::hir::def::Def; +use crate::hir::def_id::DefId; +use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::layout::{LayoutError, Pointer, SizeSkeleton, VariantIdx}; +use crate::ty::query::Providers; use rustc_target::spec::abi::Abi::RustIntrinsic; use rustc_data_structures::indexed_vec::Idx; use syntax_pos::Span; -use hir::intravisit::{self, Visitor, NestedVisitorMap}; -use hir; +use crate::hir::intravisit::{self, Visitor, NestedVisitorMap}; +use crate::hir; pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) { for &module in tcx.hir().krate().modules.keys() { diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 87107f727a05d..3f9230ab551d5 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -11,17 +11,17 @@ pub use self::LangItem::*; -use hir::def_id::DefId; -use hir::check_attr::Target; -use ty::{self, TyCtxt}; -use middle::weak_lang_items; -use util::nodemap::FxHashMap; +use crate::hir::def_id::DefId; +use crate::hir::check_attr::Target; +use crate::ty::{self, TyCtxt}; +use crate::middle::weak_lang_items; +use crate::util::nodemap::FxHashMap; use syntax::ast; use syntax::symbol::Symbol; use syntax_pos::Span; -use hir::itemlikevisit::ItemLikeVisitor; -use hir; +use crate::hir::itemlikevisit::ItemLikeVisitor; +use crate::hir; // The actual lang items defined come at the end of this file in one handy table. // So you probably just want to nip down to the end. diff --git a/src/librustc/middle/lib_features.rs b/src/librustc/middle/lib_features.rs index 8c23377324f1f..45095d9bc986b 100644 --- a/src/librustc/middle/lib_features.rs +++ b/src/librustc/middle/lib_features.rs @@ -4,13 +4,13 @@ // and `#[unstable (..)]`), but are not declared in one single location // (unlike lang features), which means we need to collect them instead. -use ty::TyCtxt; +use crate::ty::TyCtxt; use syntax::symbol::Symbol; use syntax::ast::{Attribute, MetaItem, MetaItemKind}; use syntax_pos::Span; -use hir::intravisit::{self, NestedVisitorMap, Visitor}; +use crate::hir::intravisit::{self, NestedVisitorMap, Visitor}; use rustc_data_structures::fx::{FxHashSet, FxHashMap}; -use errors::DiagnosticId; +use crate::errors::DiagnosticId; pub struct LibFeatures { // A map from feature to stabilisation version. diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index d47ad009c1db6..ce4a0f69c2864 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -97,13 +97,13 @@ use self::LoopKind::*; use self::LiveNodeKind::*; use self::VarKind::*; -use hir::def::*; -use hir::Node; -use ty::{self, TyCtxt}; -use ty::query::Providers; -use lint; -use errors::Applicability; -use util::nodemap::{NodeMap, HirIdMap, HirIdSet}; +use crate::hir::def::*; +use crate::hir::Node; +use crate::ty::{self, TyCtxt}; +use crate::ty::query::Providers; +use crate::lint; +use crate::errors::Applicability; +use crate::util::nodemap::{NodeMap, HirIdMap, HirIdSet}; use std::collections::{BTreeMap, VecDeque}; use std::{fmt, u32}; @@ -115,10 +115,10 @@ use syntax::ptr::P; use syntax::symbol::keywords; use syntax_pos::Span; -use hir; -use hir::{Expr, HirId}; -use hir::def_id::DefId; -use hir::intravisit::{self, Visitor, FnKind, NestedVisitorMap}; +use crate::hir; +use crate::hir::{Expr, HirId}; +use crate::hir::def_id::DefId; +use crate::hir::intravisit::{self, Visitor, FnKind, NestedVisitorMap}; /// For use with `propagate_through_loop`. enum LoopKind<'a> { @@ -406,7 +406,7 @@ fn add_from_pat<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, pat: &P) { let mut pats = VecDeque::new(); pats.push_back(pat); while let Some(pat) = pats.pop_front() { - use hir::PatKind::*; + use crate::hir::PatKind::*; match pat.node { Binding(_, _, _, _, ref inner_pat) => { pats.extend(inner_pat.iter()); diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 370f0d1a6c6d7..04e4a0b39a2ca 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -58,19 +58,19 @@ pub use self::Note::*; use self::Aliasability::*; -use middle::region; -use hir::def_id::{DefId, LocalDefId}; -use hir::Node; -use infer::InferCtxt; -use hir::def::{Def, CtorKind}; -use ty::adjustment; -use ty::{self, Ty, TyCtxt}; -use ty::fold::TypeFoldable; -use ty::layout::VariantIdx; - -use hir::{MutImmutable, MutMutable, PatKind}; -use hir::pat_util::EnumerateAndAdjustIterator; -use hir; +use crate::middle::region; +use crate::hir::def_id::{DefId, LocalDefId}; +use crate::hir::Node; +use crate::infer::InferCtxt; +use crate::hir::def::{Def, CtorKind}; +use crate::ty::adjustment; +use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::fold::TypeFoldable; +use crate::ty::layout::VariantIdx; + +use crate::hir::{MutImmutable, MutMutable, PatKind}; +use crate::hir::pat_util::EnumerateAndAdjustIterator; +use crate::hir; use syntax::ast::{self, Name}; use syntax_pos::Span; @@ -80,7 +80,7 @@ use std::hash::{Hash, Hasher}; use rustc_data_structures::sync::Lrc; use rustc_data_structures::indexed_vec::Idx; use std::rc::Rc; -use util::nodemap::ItemLocalSet; +use crate::util::nodemap::ItemLocalSet; #[derive(Clone, Debug, PartialEq)] pub enum Categorization<'tcx> { diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 3baf0f0ea39ff..1655d8356a5a7 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -2,7 +2,7 @@ //! outside their scopes. This pass will also generate a set of exported items //! which are available for use externally when compiled as a library. -use util::nodemap::{DefIdSet, FxHashMap}; +use crate::util::nodemap::{DefIdSet, FxHashMap}; use std::hash::Hash; use std::fmt; diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 10deca836fff3..73ba47d411915 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -5,24 +5,24 @@ // makes all other generics or inline functions that it references // reachable as well. -use hir::{CodegenFnAttrs, CodegenFnAttrFlags}; -use hir::Node; -use hir::def::Def; -use hir::def_id::{DefId, CrateNum}; +use crate::hir::{CodegenFnAttrs, CodegenFnAttrFlags}; +use crate::hir::Node; +use crate::hir::def::Def; +use crate::hir::def_id::{DefId, CrateNum}; use rustc_data_structures::sync::Lrc; -use ty::{self, TyCtxt}; -use ty::query::Providers; -use middle::privacy; -use session::config; -use util::nodemap::{NodeSet, FxHashSet}; +use crate::ty::{self, TyCtxt}; +use crate::ty::query::Providers; +use crate::middle::privacy; +use crate::session::config; +use crate::util::nodemap::{NodeSet, FxHashSet}; use rustc_target::spec::abi::Abi; use syntax::ast; -use hir; -use hir::def_id::LOCAL_CRATE; -use hir::intravisit::{Visitor, NestedVisitorMap}; -use hir::itemlikevisit::ItemLikeVisitor; -use hir::intravisit; +use crate::hir; +use crate::hir::def_id::LOCAL_CRATE; +use crate::hir::intravisit::{Visitor, NestedVisitorMap}; +use crate::hir::itemlikevisit::ItemLikeVisitor; +use crate::hir::intravisit; // Returns true if the given item must be inlined because it may be // monomorphized or it was marked with `#[inline]`. This will only return diff --git a/src/librustc/middle/recursion_limit.rs b/src/librustc/middle/recursion_limit.rs index 1eabd7f59e689..ea077220e0be3 100644 --- a/src/librustc/middle/recursion_limit.rs +++ b/src/librustc/middle/recursion_limit.rs @@ -5,7 +5,7 @@ // this via an attribute on the crate like `#![recursion_limit="22"]`. This pass // just peeks and looks for that attribute. -use session::Session; +use crate::session::Session; use syntax::ast; use rustc_data_structures::sync::Once; diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index db52cc3074b9a..788d2185d6da2 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -6,9 +6,9 @@ //! //! [rustc guide]: https://rust-lang.github.io/rustc-guide/mir/borrowck.html -use ich::{StableHashingContext, NodeIdHashingMode}; -use util::nodemap::{FxHashMap, FxHashSet}; -use ty; +use crate::ich::{StableHashingContext, NodeIdHashingMode}; +use crate::util::nodemap::{FxHashMap, FxHashSet}; +use crate::ty; use std::mem; use std::fmt; @@ -16,14 +16,14 @@ use rustc_data_structures::sync::Lrc; use syntax::source_map; use syntax::ast; use syntax_pos::{Span, DUMMY_SP}; -use ty::TyCtxt; -use ty::query::Providers; - -use hir; -use hir::Node; -use hir::def_id::DefId; -use hir::intravisit::{self, Visitor, NestedVisitorMap}; -use hir::{Block, Arm, Pat, PatKind, Stmt, Expr, Local}; +use crate::ty::TyCtxt; +use crate::ty::query::Providers; + +use crate::hir; +use crate::hir::Node; +use crate::hir::def_id::DefId; +use crate::hir::intravisit::{self, Visitor, NestedVisitorMap}; +use crate::hir::{Block, Arm, Pat, PatKind, Stmt, Expr, Local}; use rustc_data_structures::indexed_vec::Idx; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; @@ -154,7 +154,7 @@ newtype_index! { pub struct FirstStatementIndex { .. } } -impl_stable_hash_for!(struct ::middle::region::FirstStatementIndex { private }); +impl_stable_hash_for!(struct crate::middle::region::FirstStatementIndex { private }); // compilation error if size of `ScopeData` is not the same as a `u32` static_assert!(ASSERT_SCOPE_DATA: mem::size_of::() == 4); diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 34db30a1706b9..f7cd241236498 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -5,16 +5,16 @@ //! used between functions, and they operate in a purely top-down //! way. Therefore we break lifetime name resolution into a separate pass. -use hir::def::Def; -use hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE}; -use hir::map::Map; -use hir::{GenericArg, GenericParam, ItemLocalId, LifetimeName, Node, ParamName}; -use ty::{self, DefIdTree, GenericParamDefKind, TyCtxt}; - -use errors::{Applicability, DiagnosticBuilder}; -use rustc::lint; +use crate::hir::def::Def; +use crate::hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE}; +use crate::hir::map::Map; +use crate::hir::{GenericArg, GenericParam, ItemLocalId, LifetimeName, Node, ParamName}; +use crate::ty::{self, DefIdTree, GenericParamDefKind, TyCtxt}; + +use crate::errors::{Applicability, DiagnosticBuilder}; +use crate::rustc::lint; use rustc_data_structures::sync::Lrc; -use session::Session; +use crate::session::Session; use std::borrow::Cow; use std::cell::Cell; use std::mem::replace; @@ -23,10 +23,10 @@ use syntax::attr; use syntax::ptr::P; use syntax::symbol::keywords; use syntax_pos::Span; -use util::nodemap::{DefIdMap, FxHashMap, FxHashSet, NodeMap, NodeSet}; +use crate::util::nodemap::{DefIdMap, FxHashMap, FxHashSet, NodeMap, NodeSet}; -use hir::intravisit::{self, NestedVisitorMap, Visitor}; -use hir::{self, GenericParamKind, LifetimeParamKind}; +use crate::hir::intravisit::{self, NestedVisitorMap, Visitor}; +use crate::hir::{self, GenericParamKind, LifetimeParamKind}; /// The origin of a named lifetime definition. /// @@ -216,7 +216,7 @@ pub struct ResolveLifetimes { FxHashMap>>>>, } -impl_stable_hash_for!(struct ::middle::resolve_lifetime::ResolveLifetimes { +impl_stable_hash_for!(struct crate::middle::resolve_lifetime::ResolveLifetimes { defs, late_bound, object_lifetime_defaults diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index c726885337ea8..34c77d08f5a7e 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -3,14 +3,14 @@ pub use self::StabilityLevel::*; -use lint::{self, Lint}; -use hir::{self, Item, Generics, StructField, Variant, HirId}; -use hir::def::Def; -use hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, LOCAL_CRATE}; -use hir::intravisit::{self, Visitor, NestedVisitorMap}; -use ty::query::Providers; -use middle::privacy::AccessLevels; -use session::{DiagnosticMessageId, Session}; +use crate::lint::{self, Lint}; +use crate::hir::{self, Item, Generics, StructField, Variant, HirId}; +use crate::hir::def::Def; +use crate::hir::def_id::{CrateNum, CRATE_DEF_INDEX, DefId, LOCAL_CRATE}; +use crate::hir::intravisit::{self, Visitor, NestedVisitorMap}; +use crate::ty::query::Providers; +use crate::middle::privacy::AccessLevels; +use crate::session::{DiagnosticMessageId, Session}; use syntax::symbol::Symbol; use syntax_pos::{Span, MultiSpan}; use syntax::ast; @@ -18,8 +18,8 @@ use syntax::ast::{NodeId, Attribute}; use syntax::errors::Applicability; use syntax::feature_gate::{GateIssue, emit_feature_err}; use syntax::attr::{self, Stability, Deprecation}; -use ty::{self, TyCtxt}; -use util::nodemap::{FxHashSet, FxHashMap}; +use crate::ty::{self, TyCtxt}; +use crate::util::nodemap::{FxHashSet, FxHashMap}; use std::mem::replace; use std::cmp::Ordering; diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs index 82f19cbb82a19..119e855c58551 100644 --- a/src/librustc/middle/weak_lang_items.rs +++ b/src/librustc/middle/weak_lang_items.rs @@ -1,18 +1,18 @@ //! Validity checking for weak lang items -use session::config; -use middle::lang_items; +use crate::session::config; +use crate::middle::lang_items; use rustc_data_structures::fx::FxHashSet; use rustc_target::spec::PanicStrategy; use syntax::ast; use syntax::symbol::Symbol; use syntax_pos::Span; -use hir::def_id::DefId; -use hir::intravisit::{Visitor, NestedVisitorMap}; -use hir::intravisit; -use hir; -use ty::TyCtxt; +use crate::hir::def_id::DefId; +use crate::hir::intravisit::{Visitor, NestedVisitorMap}; +use crate::hir::intravisit; +use crate::hir; +use crate::ty::TyCtxt; macro_rules! weak_lang_items { ($($name:ident, $item:ident, $sym:ident;)*) => ( diff --git a/src/librustc/mir/cache.rs b/src/librustc/mir/cache.rs index 56ab263c47740..1cc927b1f720f 100644 --- a/src/librustc/mir/cache.rs +++ b/src/librustc/mir/cache.rs @@ -2,10 +2,10 @@ use rustc_data_structures::indexed_vec::IndexVec; use rustc_data_structures::sync::{RwLock, MappedReadGuard, ReadGuard}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; -use ich::StableHashingContext; -use mir::{Mir, BasicBlock}; +use crate::ich::StableHashingContext; +use crate::mir::{Mir, BasicBlock}; -use rustc_serialize as serialize; +use crate::rustc_serialize as serialize; #[derive(Clone, Debug)] pub struct Cache { diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs index 7ed29c5afd03f..7761e1fdafac5 100644 --- a/src/librustc/mir/interpret/allocation.rs +++ b/src/librustc/mir/interpret/allocation.rs @@ -5,10 +5,10 @@ use super::{ truncate, }; -use ty::layout::{Size, Align}; +use crate::ty::layout::{Size, Align}; use syntax::ast::Mutability; use std::iter; -use mir; +use crate::mir; use std::ops::{Deref, DerefMut}; use rustc_data_structures::sorted_map::SortedMap; use rustc_target::abi::HasDataLayout; diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index c3fe5d773ab16..870a51f95df1c 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -1,17 +1,17 @@ use std::{fmt, env}; -use hir::map::definitions::DefPathData; -use mir; -use ty::{self, Ty, layout}; -use ty::layout::{Size, Align, LayoutError}; +use crate::hir::map::definitions::DefPathData; +use crate::mir; +use crate::ty::{self, Ty, layout}; +use crate::ty::layout::{Size, Align, LayoutError}; use rustc_target::spec::abi::Abi; use super::{RawConst, Pointer, InboundsCheck, ScalarMaybeUndef}; use backtrace::Backtrace; -use ty::query::TyCtxtAt; -use errors::DiagnosticBuilder; +use crate::ty::query::TyCtxtAt; +use crate::errors::DiagnosticBuilder; use syntax_pos::{Pos, Span}; use syntax::ast; @@ -42,7 +42,7 @@ pub type ConstEvalResult<'tcx> = Result, ErrorHandled>; #[derive(Clone, Debug, RustcEncodable, RustcDecodable)] pub struct ConstEvalErr<'tcx> { pub span: Span, - pub error: ::mir::interpret::EvalErrorKind<'tcx, u64>, + pub error: crate::mir::interpret::EvalErrorKind<'tcx, u64>, pub stacktrace: Vec>, } @@ -136,7 +136,7 @@ impl<'a, 'gcx, 'tcx> ConstEvalErr<'tcx> { .next() .unwrap_or(lint_root); tcx.struct_span_lint_node( - ::rustc::lint::builtin::CONST_ERR, + crate::rustc::lint::builtin::CONST_ERR, node_id, tcx.span, message, diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index e6a560b2ad7b6..efd233f1f3854 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -25,17 +25,17 @@ pub use self::allocation::{ pub use self::pointer::{Pointer, PointerArithmetic}; use std::fmt; -use mir; -use hir::def_id::DefId; -use ty::{self, TyCtxt, Instance}; -use ty::layout::{self, Size}; +use crate::mir; +use crate::hir::def_id::DefId; +use crate::ty::{self, TyCtxt, Instance}; +use crate::ty::layout::{self, Size}; use std::io; -use rustc_serialize::{Encoder, Decodable, Encodable}; +use crate::rustc_serialize::{Encoder, Decodable, Encodable}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::{Lock as Mutex, HashMapExt}; use rustc_data_structures::tiny_list::TinyList; use byteorder::{WriteBytesExt, ReadBytesExt, LittleEndian, BigEndian}; -use ty::codec::TyDecoder; +use crate::ty::codec::TyDecoder; use std::sync::atomic::{AtomicU32, Ordering}; use std::num::NonZeroU32; @@ -53,8 +53,8 @@ pub struct GlobalId<'tcx> { #[derive(Copy, Clone, Eq, Hash, Ord, PartialEq, PartialOrd, Debug)] pub struct AllocId(pub u64); -impl ::rustc_serialize::UseSpecializedEncodable for AllocId {} -impl ::rustc_serialize::UseSpecializedDecodable for AllocId {} +impl crate::rustc_serialize::UseSpecializedEncodable for AllocId {} +impl crate::rustc_serialize::UseSpecializedDecodable for AllocId {} #[derive(RustcDecodable, RustcEncodable)] enum AllocDiscriminant { diff --git a/src/librustc/mir/interpret/pointer.rs b/src/librustc/mir/interpret/pointer.rs index 498c0b5b917e9..551e7b2fd41ec 100644 --- a/src/librustc/mir/interpret/pointer.rs +++ b/src/librustc/mir/interpret/pointer.rs @@ -1,5 +1,5 @@ -use mir; -use ty::layout::{self, HasDataLayout, Size}; +use crate::mir; +use crate::ty::layout::{self, HasDataLayout, Size}; use super::{ AllocId, EvalResult, InboundsCheck, diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs index 1328a1aeeab96..73917342814de 100644 --- a/src/librustc/mir/interpret/value.rs +++ b/src/librustc/mir/interpret/value.rs @@ -515,7 +515,7 @@ impl<'tcx, Tag> ScalarMaybeUndef { } } -impl_stable_hash_for!(enum ::mir::interpret::ScalarMaybeUndef { +impl_stable_hash_for!(enum crate::mir::interpret::ScalarMaybeUndef { Scalar(v), Undef }); diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 82083b4f69964..009997bfcf2c4 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -2,11 +2,11 @@ //! //! [rustc guide]: https://rust-lang.github.io/rustc-guide/mir/index.html -use hir::def::CtorKind; -use hir::def_id::DefId; -use hir::{self, HirId, InlineAsm}; -use mir::interpret::{ConstValue, EvalErrorKind, Scalar}; -use mir::visit::MirVisitable; +use crate::hir::def::CtorKind; +use crate::hir::def_id::DefId; +use crate::hir::{self, HirId, InlineAsm}; +use crate::mir::interpret::{ConstValue, EvalErrorKind, Scalar}; +use crate::mir::visit::MirVisitable; use rustc_apfloat::ieee::{Double, Single}; use rustc_apfloat::Float; use rustc_data_structures::fx::FxHashSet; @@ -15,7 +15,7 @@ use rustc_data_structures::graph::{self, GraphPredecessors, GraphSuccessors}; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc_data_structures::sync::Lrc; use rustc_data_structures::sync::MappedReadGuard; -use rustc_serialize::{self as serialize}; +use crate::rustc_serialize::{self as serialize}; use smallvec::SmallVec; use std::borrow::Cow; use std::fmt::{self, Debug, Formatter, Write}; @@ -26,16 +26,16 @@ use std::{iter, mem, option, u32}; use syntax::ast::{self, Name}; use syntax::symbol::InternedString; use syntax_pos::{Span, DUMMY_SP}; -use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; -use ty::subst::{Subst, Substs}; -use ty::layout::VariantIdx; -use ty::{ +use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; +use crate::ty::subst::{Subst, Substs}; +use crate::ty::layout::VariantIdx; +use crate::ty::{ self, AdtDef, CanonicalUserTypeAnnotations, ClosureSubsts, GeneratorSubsts, Region, Ty, TyCtxt, UserTypeAnnotationIndex, }; -use util::ppaux; +use crate::util::ppaux; -pub use mir::interpret::AssertMessage; +pub use crate::mir::interpret::AssertMessage; mod cache; pub mod interpret; @@ -676,7 +676,7 @@ impl_stable_hash_for!(enum self::MirPhase { }); mod binding_form_impl { - use ich::StableHashingContext; + use crate::ich::StableHashingContext; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; impl<'a, 'tcx> HashStable> for super::BindingForm<'tcx> { @@ -2625,7 +2625,7 @@ CloneTypeFoldableAndLiftImpls! { ProjectionKind<'tcx>, } impl<'tcx> TypeFoldable<'tcx> for UserTypeProjection<'tcx> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { - use mir::ProjectionElem::*; + use crate::mir::ProjectionElem::*; let base = self.base.fold_with(folder); let projs: Vec<_> = self.projs @@ -2671,7 +2671,7 @@ pub fn fmt_lazy_const_val(f: &mut impl Write, const_val: &ty::LazyConst<'_>) -> /// Write a `ConstValue` in a way closer to the original source code than the `Debug` output. pub fn fmt_const_val(f: &mut impl Write, const_val: ty::Const<'_>) -> fmt::Result { - use ty::TyKind::*; + use crate::ty::TyKind::*; let value = const_val.val; let ty = const_val.ty; // print some primitives @@ -3116,7 +3116,7 @@ EnumTypeFoldableImpl! { impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { - use mir::TerminatorKind::*; + use crate::mir::TerminatorKind::*; let kind = match self.kind { Goto { target } => Goto { target }, @@ -3229,7 +3229,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> { } fn super_visit_with>(&self, visitor: &mut V) -> bool { - use mir::TerminatorKind::*; + use crate::mir::TerminatorKind::*; match self.kind { SwitchInt { @@ -3301,7 +3301,7 @@ impl<'tcx> TypeFoldable<'tcx> for Place<'tcx> { impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { - use mir::Rvalue::*; + use crate::mir::Rvalue::*; match *self { Use(ref op) => Use(op.fold_with(folder)), Repeat(ref op, len) => Repeat(op.fold_with(folder), len), @@ -3343,7 +3343,7 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> { } fn super_visit_with>(&self, visitor: &mut V) -> bool { - use mir::Rvalue::*; + use crate::mir::Rvalue::*; match *self { Use(ref op) => op.visit_with(visitor), Repeat(ref op, _) => op.visit_with(visitor), @@ -3395,7 +3395,7 @@ where T: TypeFoldable<'tcx>, { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { - use mir::ProjectionElem::*; + use crate::mir::ProjectionElem::*; let base = self.base.fold_with(folder); let elem = match self.elem { @@ -3409,7 +3409,7 @@ where } fn super_visit_with>(&self, visitor: &mut Vs) -> bool { - use mir::ProjectionElem::*; + use crate::mir::ProjectionElem::*; self.base.visit_with(visitor) || match self.elem { Field(_, ref ty) => ty.visit_with(visitor), diff --git a/src/librustc/mir/mono.rs b/src/librustc/mir/mono.rs index 55f5c36cde66d..affa9f9fdd4d7 100644 --- a/src/librustc/mir/mono.rs +++ b/src/librustc/mir/mono.rs @@ -1,12 +1,12 @@ -use hir::def_id::{DefId, CrateNum, LOCAL_CRATE}; +use crate::hir::def_id::{DefId, CrateNum, LOCAL_CRATE}; use syntax::ast::NodeId; use syntax::symbol::{Symbol, InternedString}; -use ty::{Instance, TyCtxt}; -use util::nodemap::FxHashMap; +use crate::ty::{Instance, TyCtxt}; +use crate::util::nodemap::FxHashMap; use rustc_data_structures::base_n; use rustc_data_structures::stable_hasher::{HashStable, StableHasherResult, StableHasher}; -use ich::{Fingerprint, StableHashingContext, NodeIdHashingMode}; +use crate::ich::{Fingerprint, StableHashingContext, NodeIdHashingMode}; use std::fmt; use std::hash::Hash; diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index 649370059f0ea..ac3a97898b405 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -3,12 +3,12 @@ * building is complete. */ -use mir::*; -use ty::subst::{Subst, Substs}; -use ty::{self, AdtDef, Ty, TyCtxt}; -use ty::layout::VariantIdx; -use hir; -use ty::util::IntTypeExt; +use crate::mir::*; +use crate::ty::subst::{Subst, Substs}; +use crate::ty::{self, AdtDef, Ty, TyCtxt}; +use crate::ty::layout::VariantIdx; +use crate::hir; +use crate::ty::util::IntTypeExt; #[derive(Copy, Clone, Debug)] pub enum PlaceTy<'tcx> { diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index 598303f29328f..0180256661630 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -1,7 +1,7 @@ -use hir::def_id::DefId; -use ty::subst::Substs; -use ty::{CanonicalUserTypeAnnotation, ClosureSubsts, GeneratorSubsts, Region, Ty}; -use mir::*; +use crate::hir::def_id::DefId; +use crate::ty::subst::Substs; +use crate::ty::{CanonicalUserTypeAnnotation, ClosureSubsts, GeneratorSubsts, Region, Ty}; +use crate::mir::*; use syntax_pos::Span; // # The MIR Visitor @@ -567,7 +567,7 @@ macro_rules! make_mir_visitor { fn super_assert_message(&mut self, msg: & $($mutability)* AssertMessage<'tcx>, location: Location) { - use mir::interpret::EvalErrorKind::*; + use crate::mir::interpret::EvalErrorKind::*; if let BoundsCheck { ref $($mutability)* len, ref $($mutability)* index diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 3c2f454eefec7..1a92f2c0f7aa1 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -3,13 +3,13 @@ use std::str::FromStr; -use session::{early_error, early_warn, Session}; -use session::search_paths::SearchPath; +use crate::session::{early_error, early_warn, Session}; +use crate::session::search_paths::SearchPath; use rustc_target::spec::{LinkerFlavor, MergeFunctions, PanicStrategy, RelroLevel}; use rustc_target::spec::{Target, TargetTriple}; -use lint; -use middle::cstore; +use crate::lint; +use crate::middle::cstore; use syntax::ast::{self, IntTy, UintTy, MetaItemKind}; use syntax::source_map::{FileName, FilePathMapping}; @@ -19,7 +19,7 @@ use syntax::parse; use syntax::symbol::Symbol; use syntax::feature_gate::UnstableFeatures; -use errors::{ColorConfig, FatalError, Handler}; +use crate::errors::{ColorConfig, FatalError, Handler}; use getopts; use std::collections::{BTreeMap, BTreeSet}; @@ -2344,7 +2344,7 @@ pub mod nightly_options { use getopts; use syntax::feature_gate::UnstableFeatures; use super::{ErrorOutputType, OptionStability, RustcOptGroup}; - use session::early_error; + use crate::session::early_error; pub fn is_unstable_enabled(matches: &getopts::Matches) -> bool { is_nightly_build() @@ -2433,8 +2433,8 @@ impl fmt::Display for CrateType { /// we have an opt-in scheme here, so one is hopefully forced to think about /// how the hash should be calculated when adding a new command-line argument. mod dep_tracking { - use lint; - use middle::cstore; + use crate::lint; + use crate::middle::cstore; use std::collections::BTreeMap; use std::hash::Hash; use std::path::PathBuf; @@ -2567,14 +2567,14 @@ mod dep_tracking { #[cfg(test)] mod tests { - use errors; + use crate::errors; use getopts; - use lint; - use middle::cstore; - use session::config::{build_configuration, build_session_options_and_crate_config}; - use session::config::{LtoCli, CrossLangLto}; - use session::build_session; - use session::search_paths::SearchPath; + use crate::lint; + use crate::middle::cstore; + use crate::session::config::{build_configuration, build_session_options_and_crate_config}; + use crate::session::config::{LtoCli, CrossLangLto}; + use crate::session::build_session; + use crate::session::search_paths::SearchPath; use std::collections::{BTreeMap, BTreeSet}; use std::iter::FromIterator; use std::path::PathBuf; diff --git a/src/librustc/session/filesearch.rs b/src/librustc/session/filesearch.rs index 19f1c7a18fad1..77f190e281229 100644 --- a/src/librustc/session/filesearch.rs +++ b/src/librustc/session/filesearch.rs @@ -7,7 +7,7 @@ use std::env; use std::fs; use std::path::{Path, PathBuf}; -use session::search_paths::{SearchPath, PathKind}; +use crate::session::search_paths::{SearchPath, PathKind}; use rustc_fs_util::fix_windows_verbatim_for_gcc; #[derive(Copy, Clone)] diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index c5034415d6ffb..d2beb64b38861 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -1,19 +1,19 @@ pub use self::code_stats::{DataTypeKind, SizeKind, FieldInfo, VariantInfo}; use self::code_stats::CodeStats; -use dep_graph::cgu_reuse_tracker::CguReuseTracker; -use hir::def_id::CrateNum; +use crate::dep_graph::cgu_reuse_tracker::CguReuseTracker; +use crate::hir::def_id::CrateNum; use rustc_data_structures::fingerprint::Fingerprint; -use lint; -use lint::builtin::BuiltinLintDiagnostics; -use middle::allocator::AllocatorKind; -use middle::dependency_format; -use session::config::{OutputType, Lto}; -use session::search_paths::{PathKind, SearchPath}; -use util::nodemap::{FxHashMap, FxHashSet}; -use util::common::{duration_to_secs_str, ErrorReported}; -use util::common::ProfileQueriesMsg; +use crate::lint; +use crate::lint::builtin::BuiltinLintDiagnostics; +use crate::middle::allocator::AllocatorKind; +use crate::middle::dependency_format; +use crate::session::config::{OutputType, Lto}; +use crate::session::search_paths::{PathKind, SearchPath}; +use crate::util::nodemap::{FxHashMap, FxHashSet}; +use crate::util::common::{duration_to_secs_str, ErrorReported}; +use crate::util::common::ProfileQueriesMsg; use rustc_data_structures::base_n; use rustc_data_structures::sync::{ @@ -21,8 +21,8 @@ use rustc_data_structures::sync::{ Ordering::SeqCst, }; -use errors::{self, DiagnosticBuilder, DiagnosticId, Applicability}; -use errors::emitter::{Emitter, EmitterWriter}; +use crate::errors::{self, DiagnosticBuilder, DiagnosticId, Applicability}; +use crate::errors::emitter::{Emitter, EmitterWriter}; use syntax::ast::{self, NodeId}; use syntax::edition::Edition; use syntax::feature_gate::{self, AttributeType}; @@ -30,7 +30,7 @@ use syntax::json::JsonEmitter; use syntax::source_map; use syntax::parse::{self, ParseSess}; use syntax_pos::{MultiSpan, Span}; -use util::profiling::SelfProfiler; +use crate::util::profiling::SelfProfiler; use rustc_target::spec::{PanicStrategy, RelroLevel, Target, TargetTriple}; use rustc_data_structures::flock; diff --git a/src/librustc/session/search_paths.rs b/src/librustc/session/search_paths.rs index 85d64b1571266..a950258cefd0c 100644 --- a/src/librustc/session/search_paths.rs +++ b/src/librustc/session/search_paths.rs @@ -1,6 +1,6 @@ use std::path::{Path, PathBuf}; -use session::{early_error, config}; -use session::filesearch::make_target_lib_path; +use crate::session::{early_error, config}; +use crate::session::filesearch::make_target_lib_path; #[derive(Clone, Debug)] pub struct SearchPath { diff --git a/src/librustc/traits/auto_trait.rs b/src/librustc/traits/auto_trait.rs index 92004ece26d00..d1db49e05f190 100644 --- a/src/librustc/traits/auto_trait.rs +++ b/src/librustc/traits/auto_trait.rs @@ -6,12 +6,12 @@ use super::*; use std::collections::hash_map::Entry; use std::collections::VecDeque; -use infer::region_constraints::{Constraint, RegionConstraintData}; -use infer::InferCtxt; +use crate::infer::region_constraints::{Constraint, RegionConstraintData}; +use crate::infer::InferCtxt; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; -use ty::fold::TypeFolder; -use ty::{Region, RegionVid}; +use crate::ty::fold::TypeFolder; +use crate::ty::{Region, RegionVid}; // FIXME(twk): this is obviously not nice to duplicate like that #[derive(Eq, PartialEq, Hash, Copy, Clone, Debug)] diff --git a/src/librustc/traits/chalk_fulfill.rs b/src/librustc/traits/chalk_fulfill.rs index df4e08e0eb5f3..d9eb6d8157dfb 100644 --- a/src/librustc/traits/chalk_fulfill.rs +++ b/src/librustc/traits/chalk_fulfill.rs @@ -1,4 +1,4 @@ -use traits::{ +use crate::traits::{ Environment, InEnvironment, TraitEngine, @@ -8,10 +8,10 @@ use traits::{ FulfillmentErrorCode, SelectionError, }; -use traits::query::NoSolution; -use infer::InferCtxt; -use infer::canonical::{Canonical, OriginalQueryValues}; -use ty::{self, Ty}; +use crate::traits::query::NoSolution; +use crate::infer::InferCtxt; +use crate::infer::canonical::{Canonical, OriginalQueryValues}; +use crate::ty::{self, Ty}; use rustc_data_structures::fx::FxHashSet; pub type CanonicalGoal<'tcx> = Canonical<'tcx, InEnvironment<'tcx, ty::Predicate<'tcx>>>; diff --git a/src/librustc/traits/codegen/mod.rs b/src/librustc/traits/codegen/mod.rs index 94d56c2cbfc88..eed9345afae16 100644 --- a/src/librustc/traits/codegen/mod.rs +++ b/src/librustc/traits/codegen/mod.rs @@ -3,16 +3,16 @@ // seems likely that they should eventually be merged into more // general routines. -use dep_graph::{DepKind, DepTrackingMapConfig}; +use crate::dep_graph::{DepKind, DepTrackingMapConfig}; use std::marker::PhantomData; use syntax_pos::DUMMY_SP; -use infer::InferCtxt; +use crate::infer::InferCtxt; use syntax_pos::Span; -use traits::{FulfillmentContext, Obligation, ObligationCause, SelectionContext, +use crate::traits::{FulfillmentContext, Obligation, ObligationCause, SelectionContext, TraitEngine, Vtable}; -use ty::{self, Ty, TyCtxt}; -use ty::subst::{Subst, Substs}; -use ty::fold::TypeFoldable; +use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::subst::{Subst, Substs}; +use crate::ty::fold::TypeFoldable; /// Attempts to resolve an obligation to a vtable.. The result is /// a shallow vtable resolution -- meaning that we do not diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index 4c7049c366207..4fe7a1507f737 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -4,17 +4,17 @@ //! [trait-resolution]: https://rust-lang.github.io/rustc-guide/traits/resolution.html //! [trait-specialization]: https://rust-lang.github.io/rustc-guide/traits/specialization.html -use infer::CombinedSnapshot; -use hir::def_id::{DefId, LOCAL_CRATE}; +use crate::infer::CombinedSnapshot; +use crate::hir::def_id::{DefId, LOCAL_CRATE}; use syntax_pos::DUMMY_SP; -use traits::{self, Normalized, SelectionContext, Obligation, ObligationCause}; -use traits::IntercrateMode; -use traits::select::IntercrateAmbiguityCause; -use ty::{self, Ty, TyCtxt}; -use ty::fold::TypeFoldable; -use ty::subst::Subst; +use crate::traits::{self, Normalized, SelectionContext, Obligation, ObligationCause}; +use crate::traits::IntercrateMode; +use crate::traits::select::IntercrateAmbiguityCause; +use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::fold::TypeFoldable; +use crate::ty::subst::Subst; -use infer::{InferOk}; +use crate::infer::{InferOk}; /// Whether we do the orphan check relative to this crate or /// to some remote crate. @@ -39,7 +39,7 @@ pub struct OverlapResult<'tcx> { pub involves_placeholder: bool, } -pub fn add_placeholder_note(err: &mut ::errors::DiagnosticBuilder<'_>) { +pub fn add_placeholder_note(err: &mut crate::errors::DiagnosticBuilder<'_>) { err.note(&format!( "this behavior recently changed as a result of a bug fix; \ see rust-lang/rust#56105 for details" diff --git a/src/librustc/traits/engine.rs b/src/librustc/traits/engine.rs index c759a9ddf2ce6..2f019d823ff5d 100644 --- a/src/librustc/traits/engine.rs +++ b/src/librustc/traits/engine.rs @@ -1,7 +1,7 @@ -use infer::InferCtxt; -use ty::{self, Ty, TyCtxt, ToPredicate}; -use traits::Obligation; -use hir::def_id::DefId; +use crate::infer::InferCtxt; +use crate::ty::{self, Ty, TyCtxt, ToPredicate}; +use crate::traits::Obligation; +use crate::hir::def_id::DefId; use super::{ChalkFulfillmentContext, FulfillmentContext, FulfillmentError}; use super::{ObligationCause, PredicateObligation}; diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index ea3ea59c7613f..79afc593a4676 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -17,23 +17,23 @@ use super::{ Overflow, }; -use errors::{Applicability, DiagnosticBuilder}; -use hir; -use hir::Node; -use hir::def_id::DefId; -use infer::{self, InferCtxt}; -use infer::type_variable::TypeVariableOrigin; +use crate::errors::{Applicability, DiagnosticBuilder}; +use crate::hir; +use crate::hir::Node; +use crate::hir::def_id::DefId; +use crate::infer::{self, InferCtxt}; +use crate::infer::type_variable::TypeVariableOrigin; use std::fmt; use syntax::ast; -use session::DiagnosticMessageId; -use ty::{self, AdtKind, ToPredicate, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable}; -use ty::GenericParamDefKind; -use ty::error::ExpectedFound; -use ty::fast_reject; -use ty::fold::TypeFolder; -use ty::subst::Subst; -use ty::SubtypePredicate; -use util::nodemap::{FxHashMap, FxHashSet}; +use crate::session::DiagnosticMessageId; +use crate::ty::{self, AdtKind, ToPredicate, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable}; +use crate::ty::GenericParamDefKind; +use crate::ty::error::ExpectedFound; +use crate::ty::fast_reject; +use crate::ty::fold::TypeFolder; +use crate::ty::subst::Subst; +use crate::ty::SubtypePredicate; +use crate::util::nodemap::{FxHashMap, FxHashSet}; use syntax_pos::{DUMMY_SP, Span, ExpnInfo, ExpnFormat}; diff --git a/src/librustc/traits/fulfill.rs b/src/librustc/traits/fulfill.rs index 2e00d4d4b7c3b..98784bccb6f82 100644 --- a/src/librustc/traits/fulfill.rs +++ b/src/librustc/traits/fulfill.rs @@ -1,7 +1,7 @@ -use infer::InferCtxt; -use mir::interpret::{GlobalId, ErrorHandled}; -use ty::{self, Ty, TypeFoldable, ToPolyTraitRef}; -use ty::error::ExpectedFound; +use crate::infer::InferCtxt; +use crate::mir::interpret::{GlobalId, ErrorHandled}; +use crate::ty::{self, Ty, TypeFoldable, ToPolyTraitRef}; +use crate::ty::error::ExpectedFound; use rustc_data_structures::obligation_forest::{DoCompleted, Error, ForestObligation}; use rustc_data_structures::obligation_forest::{ObligationForest, ObligationProcessor}; use rustc_data_structures::obligation_forest::{ProcessResult}; diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index 68383bef37a6a..d1be8d377a84d 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -20,20 +20,20 @@ mod util; pub mod query; use chalk_engine; -use hir; -use hir::def_id::DefId; -use infer::{InferCtxt, SuppressRegionErrors}; -use infer::outlives::env::OutlivesEnvironment; -use middle::region; -use mir::interpret::ErrorHandled; +use crate::hir; +use crate::hir::def_id::DefId; +use crate::infer::{InferCtxt, SuppressRegionErrors}; +use crate::infer::outlives::env::OutlivesEnvironment; +use crate::middle::region; +use crate::mir::interpret::ErrorHandled; use rustc_data_structures::sync::Lrc; use syntax::ast; use syntax_pos::{Span, DUMMY_SP}; -use ty::subst::Substs; -use ty::{self, AdtKind, List, Ty, TyCtxt, GenericParamDefKind, ToPredicate}; -use ty::error::{ExpectedFound, TypeError}; -use ty::fold::{TypeFolder, TypeFoldable, TypeVisitor}; -use util::common::ErrorReported; +use crate::ty::subst::Substs; +use crate::ty::{self, AdtKind, List, Ty, TyCtxt, GenericParamDefKind, ToPredicate}; +use crate::ty::error::{ExpectedFound, TypeError}; +use crate::ty::fold::{TypeFolder, TypeFoldable, TypeVisitor}; +use crate::util::common::ErrorReported; use std::fmt::Debug; use std::rc::Rc; diff --git a/src/librustc/traits/object_safety.rs b/src/librustc/traits/object_safety.rs index c37dc2a855ed0..75eaa67e767c2 100644 --- a/src/librustc/traits/object_safety.rs +++ b/src/librustc/traits/object_safety.rs @@ -10,11 +10,11 @@ use super::elaborate_predicates; -use hir::def_id::DefId; -use lint; -use traits::{self, Obligation, ObligationCause}; -use ty::{self, Ty, TyCtxt, TypeFoldable, Predicate, ToPredicate}; -use ty::subst::{Subst, Substs}; +use crate::hir::def_id::DefId; +use crate::lint; +use crate::traits::{self, Obligation, ObligationCause}; +use crate::ty::{self, Ty, TyCtxt, TypeFoldable, Predicate, ToPredicate}; +use crate::ty::subst::{Subst, Substs}; use std::borrow::Cow; use std::iter::{self}; use syntax::ast::{self, Name}; @@ -341,7 +341,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { } else { // sanity check to make sure the receiver actually has the layout of a pointer - use ty::layout::Abi; + use crate::ty::layout::Abi; let param_env = self.param_env(method.def_id); diff --git a/src/librustc/traits/on_unimplemented.rs b/src/librustc/traits/on_unimplemented.rs index 3ec901f50e4cc..f61c32614cc93 100644 --- a/src/librustc/traits/on_unimplemented.rs +++ b/src/librustc/traits/on_unimplemented.rs @@ -1,9 +1,9 @@ use fmt_macros::{Parser, Piece, Position}; -use hir::def_id::DefId; -use ty::{self, TyCtxt, GenericParamDefKind}; -use util::common::ErrorReported; -use util::nodemap::FxHashMap; +use crate::hir::def_id::DefId; +use crate::ty::{self, TyCtxt, GenericParamDefKind}; +use crate::util::common::ErrorReported; +use crate::util::nodemap::FxHashMap; use syntax::ast::{MetaItem, NestedMetaItem}; use syntax::attr; diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs index bec45046cb93e..99107a1a6d4e1 100644 --- a/src/librustc/traits/project.rs +++ b/src/librustc/traits/project.rs @@ -12,16 +12,16 @@ use super::SelectionError; use super::{VtableImplData, VtableClosureData, VtableGeneratorData, VtableFnPointerData}; use super::util; -use hir::def_id::DefId; -use infer::{InferCtxt, InferOk, LateBoundRegionConversionTime}; -use infer::type_variable::TypeVariableOrigin; -use mir::interpret::{GlobalId}; +use crate::hir::def_id::DefId; +use crate::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime}; +use crate::infer::type_variable::TypeVariableOrigin; +use crate::mir::interpret::{GlobalId}; use rustc_data_structures::snapshot_map::{Snapshot, SnapshotMap}; use syntax::ast::Ident; -use ty::subst::{Subst, Substs}; -use ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt}; -use ty::fold::{TypeFoldable, TypeFolder}; -use util::common::FN_OUTPUT_NAME; +use crate::ty::subst::{Subst, Substs}; +use crate::ty::{self, ToPredicate, ToPolyTraitRef, Ty, TyCtxt}; +use crate::ty::fold::{TypeFoldable, TypeFolder}; +use crate::util::common::FN_OUTPUT_NAME; /// Depending on the stage of compilation, we want projection to be /// more or less conservative. diff --git a/src/librustc/traits/query/dropck_outlives.rs b/src/librustc/traits/query/dropck_outlives.rs index 1fd2172212d3c..47ca416e6b5aa 100644 --- a/src/librustc/traits/query/dropck_outlives.rs +++ b/src/librustc/traits/query/dropck_outlives.rs @@ -1,10 +1,10 @@ -use infer::at::At; -use infer::InferOk; -use infer::canonical::OriginalQueryValues; +use crate::infer::at::At; +use crate::infer::InferOk; +use crate::infer::canonical::OriginalQueryValues; use std::iter::FromIterator; use syntax::source_map::Span; -use ty::subst::Kind; -use ty::{self, Ty, TyCtxt}; +use crate::ty::subst::Kind; +use crate::ty::{self, Ty, TyCtxt}; impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> { /// Given a type `ty` of some value being dropped, computes a set diff --git a/src/librustc/traits/query/evaluate_obligation.rs b/src/librustc/traits/query/evaluate_obligation.rs index fdae7d833734e..d5230f15c2565 100644 --- a/src/librustc/traits/query/evaluate_obligation.rs +++ b/src/librustc/traits/query/evaluate_obligation.rs @@ -1,6 +1,6 @@ -use infer::InferCtxt; -use infer::canonical::OriginalQueryValues; -use traits::{EvaluationResult, PredicateObligation, SelectionContext, +use crate::infer::InferCtxt; +use crate::infer::canonical::OriginalQueryValues; +use crate::traits::{EvaluationResult, PredicateObligation, SelectionContext, TraitQueryMode, OverflowError}; impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { diff --git a/src/librustc/traits/query/method_autoderef.rs b/src/librustc/traits/query/method_autoderef.rs index b4984e1237857..6b9bdfd63f4d0 100644 --- a/src/librustc/traits/query/method_autoderef.rs +++ b/src/librustc/traits/query/method_autoderef.rs @@ -1,6 +1,6 @@ use rustc_data_structures::sync::Lrc; -use infer::canonical::{Canonical, QueryResponse}; -use ty::Ty; +use crate::infer::canonical::{Canonical, QueryResponse}; +use crate::ty::Ty; #[derive(Debug)] pub struct CandidateStep<'tcx> { diff --git a/src/librustc/traits/query/mod.rs b/src/librustc/traits/query/mod.rs index 59f786025b224..112a1d0e09c94 100644 --- a/src/librustc/traits/query/mod.rs +++ b/src/librustc/traits/query/mod.rs @@ -5,9 +5,9 @@ //! The providers for the queries defined here can be found in //! `librustc_traits`. -use infer::canonical::Canonical; -use ty::error::TypeError; -use ty::{self, Ty}; +use crate::infer::canonical::Canonical; +use crate::ty::error::TypeError; +use crate::ty::{self, Ty}; pub mod dropck_outlives; pub mod evaluate_obligation; diff --git a/src/librustc/traits/query/normalize.rs b/src/librustc/traits/query/normalize.rs index be05445cfc61a..f477f161bbb32 100644 --- a/src/librustc/traits/query/normalize.rs +++ b/src/librustc/traits/query/normalize.rs @@ -2,15 +2,15 @@ //! which folds deeply, invoking the underlying //! `normalize_projection_ty` query when it encounters projections. -use infer::at::At; -use infer::canonical::OriginalQueryValues; -use infer::{InferCtxt, InferOk}; -use mir::interpret::GlobalId; -use traits::project::Normalized; -use traits::{Obligation, ObligationCause, PredicateObligation, Reveal}; -use ty::fold::{TypeFoldable, TypeFolder}; -use ty::subst::{Subst, Substs}; -use ty::{self, Ty, TyCtxt}; +use crate::infer::at::At; +use crate::infer::canonical::OriginalQueryValues; +use crate::infer::{InferCtxt, InferOk}; +use crate::mir::interpret::GlobalId; +use crate::traits::project::Normalized; +use crate::traits::{Obligation, ObligationCause, PredicateObligation, Reveal}; +use crate::ty::fold::{TypeFoldable, TypeFolder}; +use crate::ty::subst::{Subst, Substs}; +use crate::ty::{self, Ty, TyCtxt}; use super::NoSolution; diff --git a/src/librustc/traits/query/normalize_erasing_regions.rs b/src/librustc/traits/query/normalize_erasing_regions.rs index e7034065bdf2e..4fc61077e268a 100644 --- a/src/librustc/traits/query/normalize_erasing_regions.rs +++ b/src/librustc/traits/query/normalize_erasing_regions.rs @@ -7,8 +7,8 @@ //! `normalize_ty_after_erasing_regions` query for each type found //! within. (This underlying query is what is cached.) -use ty::{self, Ty, TyCtxt}; -use ty::fold::{TypeFoldable, TypeFolder}; +use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::fold::{TypeFoldable, TypeFolder}; impl<'cx, 'tcx> TyCtxt<'cx, 'tcx, 'tcx> { /// Erase the regions in `value` and then fully normalize all the diff --git a/src/librustc/traits/query/outlives_bounds.rs b/src/librustc/traits/query/outlives_bounds.rs index 1134cb1b2f5d0..e57236b999bab 100644 --- a/src/librustc/traits/query/outlives_bounds.rs +++ b/src/librustc/traits/query/outlives_bounds.rs @@ -1,12 +1,12 @@ -use infer::InferCtxt; -use infer::canonical::OriginalQueryValues; +use crate::infer::InferCtxt; +use crate::infer::canonical::OriginalQueryValues; use syntax::ast; use syntax::source_map::Span; -use traits::{FulfillmentContext, ObligationCause, TraitEngine, TraitEngineExt}; -use traits::query::NoSolution; -use ty::{self, Ty, TyCtxt}; +use crate::traits::{FulfillmentContext, ObligationCause, TraitEngine, TraitEngineExt}; +use crate::traits::query::NoSolution; +use crate::ty::{self, Ty, TyCtxt}; -use ich::StableHashingContext; +use crate::ich::StableHashingContext; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; use std::mem; diff --git a/src/librustc/traits/query/type_op/ascribe_user_type.rs b/src/librustc/traits/query/type_op/ascribe_user_type.rs index 15f627b3ee8c4..d9f573eb7e291 100644 --- a/src/librustc/traits/query/type_op/ascribe_user_type.rs +++ b/src/librustc/traits/query/type_op/ascribe_user_type.rs @@ -1,8 +1,8 @@ -use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; -use traits::query::Fallible; -use hir::def_id::DefId; -use ty::{ParamEnvAnd, Ty, TyCtxt}; -use ty::subst::UserSubsts; +use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; +use crate::traits::query::Fallible; +use crate::hir::def_id::DefId; +use crate::ty::{ParamEnvAnd, Ty, TyCtxt}; +use crate::ty::subst::UserSubsts; #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] pub struct AscribeUserType<'tcx> { diff --git a/src/librustc/traits/query/type_op/custom.rs b/src/librustc/traits/query/type_op/custom.rs index 0756d2eed8aea..7e38282cc1adc 100644 --- a/src/librustc/traits/query/type_op/custom.rs +++ b/src/librustc/traits/query/type_op/custom.rs @@ -1,12 +1,12 @@ -use infer::{InferCtxt, InferOk}; +use crate::infer::{InferCtxt, InferOk}; use std::fmt; -use traits::query::Fallible; +use crate::traits::query::Fallible; -use infer::canonical::query_response; -use infer::canonical::QueryRegionConstraint; +use crate::infer::canonical::query_response; +use crate::infer::canonical::QueryRegionConstraint; use std::rc::Rc; use syntax::source_map::DUMMY_SP; -use traits::{ObligationCause, TraitEngine, TraitEngineExt}; +use crate::traits::{ObligationCause, TraitEngine, TraitEngineExt}; pub struct CustomTypeOp { closure: F, diff --git a/src/librustc/traits/query/type_op/eq.rs b/src/librustc/traits/query/type_op/eq.rs index 7acb8ccb0d319..5c3ccc9a99537 100644 --- a/src/librustc/traits/query/type_op/eq.rs +++ b/src/librustc/traits/query/type_op/eq.rs @@ -1,6 +1,6 @@ -use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; -use traits::query::Fallible; -use ty::{ParamEnvAnd, Ty, TyCtxt}; +use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; +use crate::traits::query::Fallible; +use crate::ty::{ParamEnvAnd, Ty, TyCtxt}; #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] pub struct Eq<'tcx> { diff --git a/src/librustc/traits/query/type_op/implied_outlives_bounds.rs b/src/librustc/traits/query/type_op/implied_outlives_bounds.rs index f4a825a669b48..c48ca33b13fbc 100644 --- a/src/librustc/traits/query/type_op/implied_outlives_bounds.rs +++ b/src/librustc/traits/query/type_op/implied_outlives_bounds.rs @@ -1,7 +1,7 @@ -use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; -use traits::query::outlives_bounds::OutlivesBound; -use traits::query::Fallible; -use ty::{ParamEnvAnd, Ty, TyCtxt}; +use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; +use crate::traits::query::outlives_bounds::OutlivesBound; +use crate::traits::query::Fallible; +use crate::ty::{ParamEnvAnd, Ty, TyCtxt}; #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] pub struct ImpliedOutlivesBounds<'tcx> { diff --git a/src/librustc/traits/query/type_op/mod.rs b/src/librustc/traits/query/type_op/mod.rs index 6e5a6080976c0..fd13acc7796f8 100644 --- a/src/librustc/traits/query/type_op/mod.rs +++ b/src/librustc/traits/query/type_op/mod.rs @@ -1,14 +1,14 @@ -use infer::canonical::{ +use crate::infer::canonical::{ Canonical, Canonicalized, CanonicalizedQueryResponse, OriginalQueryValues, QueryRegionConstraint, QueryResponse, }; -use infer::{InferCtxt, InferOk}; +use crate::infer::{InferCtxt, InferOk}; use std::fmt; use std::rc::Rc; -use traits::query::Fallible; -use traits::ObligationCause; -use ty::fold::TypeFoldable; -use ty::{Lift, ParamEnvAnd, TyCtxt}; +use crate::traits::query::Fallible; +use crate::traits::ObligationCause; +use crate::ty::fold::TypeFoldable; +use crate::ty::{Lift, ParamEnvAnd, TyCtxt}; pub mod ascribe_user_type; pub mod custom; diff --git a/src/librustc/traits/query/type_op/normalize.rs b/src/librustc/traits/query/type_op/normalize.rs index 98afe2abdbf05..346c18516234c 100644 --- a/src/librustc/traits/query/type_op/normalize.rs +++ b/src/librustc/traits/query/type_op/normalize.rs @@ -1,8 +1,8 @@ -use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; +use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; use std::fmt; -use traits::query::Fallible; -use ty::fold::TypeFoldable; -use ty::{self, Lift, ParamEnvAnd, Ty, TyCtxt}; +use crate::traits::query::Fallible; +use crate::ty::fold::TypeFoldable; +use crate::ty::{self, Lift, ParamEnvAnd, Ty, TyCtxt}; #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] pub struct Normalize { diff --git a/src/librustc/traits/query/type_op/outlives.rs b/src/librustc/traits/query/type_op/outlives.rs index 108aa373e039c..fc0c1c022fc80 100644 --- a/src/librustc/traits/query/type_op/outlives.rs +++ b/src/librustc/traits/query/type_op/outlives.rs @@ -1,8 +1,8 @@ -use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; -use traits::query::dropck_outlives::trivial_dropck_outlives; -use traits::query::dropck_outlives::DropckOutlivesResult; -use traits::query::Fallible; -use ty::{ParamEnvAnd, Ty, TyCtxt}; +use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; +use crate::traits::query::dropck_outlives::trivial_dropck_outlives; +use crate::traits::query::dropck_outlives::DropckOutlivesResult; +use crate::traits::query::Fallible; +use crate::ty::{ParamEnvAnd, Ty, TyCtxt}; #[derive(Copy, Clone, Debug)] pub struct DropckOutlives<'tcx> { diff --git a/src/librustc/traits/query/type_op/prove_predicate.rs b/src/librustc/traits/query/type_op/prove_predicate.rs index d9eb89c9fc7c8..50dedf6e87f40 100644 --- a/src/librustc/traits/query/type_op/prove_predicate.rs +++ b/src/librustc/traits/query/type_op/prove_predicate.rs @@ -1,6 +1,6 @@ -use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; -use traits::query::Fallible; -use ty::{ParamEnvAnd, Predicate, TyCtxt}; +use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; +use crate::traits::query::Fallible; +use crate::ty::{ParamEnvAnd, Predicate, TyCtxt}; #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] pub struct ProvePredicate<'tcx> { diff --git a/src/librustc/traits/query/type_op/subtype.rs b/src/librustc/traits/query/type_op/subtype.rs index f001c7ea10a17..c45fb06313e16 100644 --- a/src/librustc/traits/query/type_op/subtype.rs +++ b/src/librustc/traits/query/type_op/subtype.rs @@ -1,6 +1,6 @@ -use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; -use traits::query::Fallible; -use ty::{ParamEnvAnd, Ty, TyCtxt}; +use crate::infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResponse, QueryResponse}; +use crate::traits::query::Fallible; +use crate::ty::{ParamEnvAnd, Ty, TyCtxt}; #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] pub struct Subtype<'tcx> { diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 6fe4a7a52be86..1e4cd145e1760 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -27,17 +27,17 @@ use super::{ VtableGeneratorData, VtableImplData, VtableObjectData, VtableTraitAliasData, }; -use dep_graph::{DepKind, DepNodeIndex}; -use hir::def_id::DefId; -use infer::{InferCtxt, InferOk, TypeFreshener}; -use middle::lang_items; -use mir::interpret::GlobalId; -use ty::fast_reject; -use ty::relate::TypeRelation; -use ty::subst::{Subst, Substs}; -use ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable}; - -use hir; +use crate::dep_graph::{DepKind, DepNodeIndex}; +use crate::hir::def_id::DefId; +use crate::infer::{InferCtxt, InferOk, TypeFreshener}; +use crate::middle::lang_items; +use crate::mir::interpret::GlobalId; +use crate::ty::fast_reject; +use crate::ty::relate::TypeRelation; +use crate::ty::subst::{Subst, Substs}; +use crate::ty::{self, ToPolyTraitRef, ToPredicate, Ty, TyCtxt, TypeFoldable}; + +use crate::hir; use rustc_data_structures::bit_set::GrowableBitSet; use rustc_data_structures::sync::Lock; use rustc_target::spec::abi::Abi; @@ -45,7 +45,7 @@ use std::cmp; use std::fmt::{self, Display}; use std::iter; use std::rc::Rc; -use util::nodemap::{FxHashMap, FxHashSet}; +use crate::util::nodemap::{FxHashMap, FxHashSet}; pub struct SelectionContext<'cx, 'gcx: 'cx + 'tcx, 'tcx: 'cx> { infcx: &'cx InferCtxt<'cx, 'gcx, 'tcx>, @@ -103,7 +103,7 @@ impl IntercrateAmbiguityCause { /// See #23980 for details. pub fn add_intercrate_ambiguity_hint<'a, 'tcx>( &self, - err: &mut ::errors::DiagnosticBuilder<'_>, + err: &mut crate::errors::DiagnosticBuilder<'_>, ) { err.note(&self.intercrate_ambiguity_hint()); } diff --git a/src/librustc/traits/specialize/mod.rs b/src/librustc/traits/specialize/mod.rs index e5ed16e755860..e7187005c132a 100644 --- a/src/librustc/traits/specialize/mod.rs +++ b/src/librustc/traits/specialize/mod.rs @@ -11,16 +11,16 @@ pub mod specialization_graph; -use hir::def_id::DefId; -use infer::{InferCtxt, InferOk}; -use lint; -use traits::{self, coherence, FutureCompatOverlapErrorKind, ObligationCause, TraitEngine}; +use crate::hir::def_id::DefId; +use crate::infer::{InferCtxt, InferOk}; +use crate::lint; +use crate::traits::{self, coherence, FutureCompatOverlapErrorKind, ObligationCause, TraitEngine}; use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::sync::Lrc; use syntax_pos::DUMMY_SP; -use traits::select::IntercrateAmbiguityCause; -use ty::{self, TyCtxt, TypeFoldable}; -use ty::subst::{Subst, Substs}; +use crate::traits::select::IntercrateAmbiguityCause; +use crate::ty::{self, TyCtxt, TypeFoldable}; +use crate::ty::subst::{Subst, Substs}; use super::{SelectionContext, FulfillmentContext}; use super::util::impl_trait_ref_and_oblig; diff --git a/src/librustc/traits/specialize/specialization_graph.rs b/src/librustc/traits/specialize/specialization_graph.rs index e5780a26a1918..010555744b6c3 100644 --- a/src/librustc/traits/specialize/specialization_graph.rs +++ b/src/librustc/traits/specialize/specialization_graph.rs @@ -1,16 +1,16 @@ use super::OverlapError; -use hir::def_id::DefId; -use ich::{self, StableHashingContext}; +use crate::hir::def_id::DefId; +use crate::ich::{self, StableHashingContext}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; -use traits; -use ty::{self, TyCtxt, TypeFoldable}; -use ty::fast_reject::{self, SimplifiedType}; +use crate::traits; +use crate::ty::{self, TyCtxt, TypeFoldable}; +use crate::ty::fast_reject::{self, SimplifiedType}; use rustc_data_structures::sync::Lrc; use syntax::ast::Ident; -use util::captures::Captures; -use util::nodemap::{DefIdMap, FxHashMap}; +use crate::util::captures::Captures; +use crate::util::nodemap::{DefIdMap, FxHashMap}; /// A per-trait graph of impls in specialization order. At the moment, this /// graph forms a tree rooted with the trait itself, with all other nodes @@ -489,7 +489,7 @@ impl<'a, 'gcx, 'tcx> Ancestors { trait_def_id: DefId, ) -> impl Iterator> + Captures<'gcx> + Captures<'tcx> + 'a { self.flat_map(move |node| { - use ty::AssociatedKind::*; + use crate::ty::AssociatedKind::*; node.items(tcx).filter(move |impl_item| match (trait_item_kind, impl_item.kind) { | (Const, Const) | (Method, Method) diff --git a/src/librustc/traits/structural_impls.rs b/src/librustc/traits/structural_impls.rs index 2f5df022218fe..c5cc9e8b40182 100644 --- a/src/librustc/traits/structural_impls.rs +++ b/src/librustc/traits/structural_impls.rs @@ -1,9 +1,9 @@ use chalk_engine; use smallvec::SmallVec; -use traits; -use traits::project::Normalized; -use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; -use ty::{self, Lift, TyCtxt}; +use crate::traits; +use crate::traits::project::Normalized; +use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; +use crate::ty::{self, Lift, TyCtxt}; use syntax::symbol::InternedString; use std::fmt; @@ -163,7 +163,7 @@ impl<'tcx> fmt::Debug for traits::MismatchedProjectionTypes<'tcx> { impl<'tcx> fmt::Display for traits::WhereClause<'tcx> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - use traits::WhereClause::*; + use crate::traits::WhereClause::*; // Bypass ppaux because it does not print out anonymous regions. fn write_region_name<'tcx>( @@ -206,7 +206,7 @@ impl<'tcx> fmt::Display for traits::WhereClause<'tcx> { impl<'tcx> fmt::Display for traits::WellFormed<'tcx> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - use traits::WellFormed::*; + use crate::traits::WellFormed::*; match self { Trait(trait_ref) => write!(fmt, "WellFormed({})", trait_ref), @@ -217,7 +217,7 @@ impl<'tcx> fmt::Display for traits::WellFormed<'tcx> { impl<'tcx> fmt::Display for traits::FromEnv<'tcx> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - use traits::FromEnv::*; + use crate::traits::FromEnv::*; match self { Trait(trait_ref) => write!(fmt, "FromEnv({})", trait_ref), @@ -228,7 +228,7 @@ impl<'tcx> fmt::Display for traits::FromEnv<'tcx> { impl<'tcx> fmt::Display for traits::DomainGoal<'tcx> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - use traits::DomainGoal::*; + use crate::traits::DomainGoal::*; match self { Holds(wc) => write!(fmt, "{}", wc), @@ -246,7 +246,7 @@ impl<'tcx> fmt::Display for traits::DomainGoal<'tcx> { impl fmt::Display for traits::QuantifierKind { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - use traits::QuantifierKind::*; + use crate::traits::QuantifierKind::*; match self { Universal => write!(fmt, "forall"), @@ -361,7 +361,7 @@ impl<'tcx> TypeVisitor<'tcx> for BoundNamesCollector { impl<'tcx> fmt::Display for traits::Goal<'tcx> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - use traits::GoalKind::*; + use crate::traits::GoalKind::*; match self { Implies(hypotheses, goal) => { @@ -420,7 +420,7 @@ impl<'tcx> fmt::Display for traits::ProgramClause<'tcx> { impl<'tcx> fmt::Display for traits::Clause<'tcx> { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - use traits::Clause::*; + use crate::traits::Clause::*; match self { Implies(clause) => write!(fmt, "{}", clause), diff --git a/src/librustc/traits/util.rs b/src/librustc/traits/util.rs index 5b7ba5386725e..67c919ac91610 100644 --- a/src/librustc/traits/util.rs +++ b/src/librustc/traits/util.rs @@ -1,10 +1,10 @@ -use hir; -use hir::def_id::DefId; -use traits::specialize::specialization_graph::NodeItem; -use ty::{self, Ty, TyCtxt, ToPredicate, ToPolyTraitRef}; -use ty::outlives::Component; -use ty::subst::{Kind, Subst, Substs}; -use util::nodemap::FxHashSet; +use crate::hir; +use crate::hir::def_id::DefId; +use crate::traits::specialize::specialization_graph::NodeItem; +use crate::ty::{self, Ty, TyCtxt, ToPredicate, ToPolyTraitRef}; +use crate::ty::outlives::Component; +use crate::ty::subst::{Kind, Subst, Substs}; +use crate::util::nodemap::FxHashSet; use super::{Obligation, ObligationCause, PredicateObligation, SelectionContext, Normalized}; diff --git a/src/librustc/ty/_match.rs b/src/librustc/ty/_match.rs index 34b94d4217d8b..07fa441bb8076 100644 --- a/src/librustc/ty/_match.rs +++ b/src/librustc/ty/_match.rs @@ -1,6 +1,6 @@ -use ty::{self, Ty, TyCtxt}; -use ty::error::TypeError; -use ty::relate::{self, Relate, TypeRelation, RelateResult}; +use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::error::TypeError; +use crate::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/ty/adjustment.rs b/src/librustc/ty/adjustment.rs index 117112c0c75f4..68e7bd6e16abe 100644 --- a/src/librustc/ty/adjustment.rs +++ b/src/librustc/ty/adjustment.rs @@ -1,7 +1,7 @@ -use hir; -use hir::def_id::DefId; -use ty::{self, Ty, TyCtxt}; -use ty::subst::Substs; +use crate::hir; +use crate::hir::def_id::DefId; +use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::subst::Substs; /// Represents coercing a value to a different type of value. diff --git a/src/librustc/ty/binding.rs b/src/librustc/ty/binding.rs index 2ab14642406b1..1290141b0a6b0 100644 --- a/src/librustc/ty/binding.rs +++ b/src/librustc/ty/binding.rs @@ -1,6 +1,6 @@ -use hir::BindingAnnotation::*; -use hir::BindingAnnotation; -use hir::Mutability; +use crate::hir::BindingAnnotation::*; +use crate::hir::BindingAnnotation; +use crate::hir::Mutability; #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] pub enum BindingMode { diff --git a/src/librustc/ty/cast.rs b/src/librustc/ty/cast.rs index 0f067de3649bf..0b2112f42d595 100644 --- a/src/librustc/ty/cast.rs +++ b/src/librustc/ty/cast.rs @@ -1,7 +1,7 @@ // Helpers for handling cast expressions, used in both // typeck and codegen. -use ty::{self, Ty}; +use crate::ty::{self, Ty}; use syntax::ast; diff --git a/src/librustc/ty/codec.rs b/src/librustc/ty/codec.rs index e0e4d9c362a6c..c9775b1029315 100644 --- a/src/librustc/ty/codec.rs +++ b/src/librustc/ty/codec.rs @@ -6,15 +6,15 @@ // The functionality in here is shared between persisting to crate metadata and // persisting to incr. comp. caches. -use hir::def_id::{DefId, CrateNum}; -use infer::canonical::{CanonicalVarInfo, CanonicalVarInfos}; +use crate::hir::def_id::{DefId, CrateNum}; +use crate::infer::canonical::{CanonicalVarInfo, CanonicalVarInfos}; use rustc_data_structures::fx::FxHashMap; -use rustc_serialize::{Decodable, Decoder, Encoder, Encodable, opaque}; +use crate::rustc_serialize::{Decodable, Decoder, Encoder, Encodable, opaque}; use std::hash::Hash; use std::intrinsics; -use ty::{self, Ty, TyCtxt}; -use ty::subst::Substs; -use mir::interpret::Allocation; +use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::subst::Substs; +use crate::mir::interpret::Allocation; /// The shorthand encoding uses an enum's variant index `usize` /// and is offset by this value so it never matches a real variant. @@ -283,7 +283,7 @@ macro_rules! implement_ty_decoder { use $crate::ty::codec::*; use $crate::ty::subst::Substs; use $crate::hir::def_id::{CrateNum}; - use rustc_serialize::{Decoder, SpecializedDecoder}; + use crate::rustc_serialize::{Decoder, SpecializedDecoder}; use std::borrow::Cow; impl<$($typaram ),*> Decoder for $DecoderName<$($typaram),*> { diff --git a/src/librustc/ty/constness.rs b/src/librustc/ty/constness.rs index 3741f4051b896..1bb6386728917 100644 --- a/src/librustc/ty/constness.rs +++ b/src/librustc/ty/constness.rs @@ -1,9 +1,9 @@ -use ty::query::Providers; -use hir::def_id::DefId; -use hir; -use ty::TyCtxt; +use crate::ty::query::Providers; +use crate::hir::def_id::DefId; +use crate::hir; +use crate::ty::TyCtxt; use syntax_pos::symbol::Symbol; -use hir::map::blocks::FnLikeNode; +use crate::hir::map::blocks::FnLikeNode; use syntax::attr; impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index b379b5ba02494..140c772256d3f 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1,48 +1,48 @@ //! type context book-keeping -use dep_graph::DepGraph; -use dep_graph::{DepNode, DepConstructor}; -use errors::DiagnosticBuilder; -use session::Session; -use session::config::{BorrowckMode, OutputFilenames}; -use session::config::CrateType; -use middle; -use hir::{TraitCandidate, HirId, ItemKind, ItemLocalId, Node}; -use hir::def::{Def, Export}; -use hir::def_id::{CrateNum, DefId, DefIndex, LOCAL_CRATE}; -use hir::map as hir_map; -use hir::map::DefPathHash; -use lint::{self, Lint}; -use ich::{StableHashingContext, NodeIdHashingMode}; -use infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos}; -use infer::outlives::free_region_map::FreeRegionMap; -use middle::cstore::CrateStoreDyn; -use middle::cstore::EncodedMetadata; -use middle::lang_items; -use middle::resolve_lifetime::{self, ObjectLifetimeDefault}; -use middle::stability; -use mir::{self, Mir, interpret, ProjectionKind}; -use mir::interpret::Allocation; -use ty::subst::{Kind, Substs, Subst}; -use ty::ReprOptions; -use traits; -use traits::{Clause, Clauses, GoalKind, Goal, Goals}; -use ty::{self, Ty, TypeAndMut}; -use ty::{TyS, TyKind, List}; -use ty::{AdtKind, AdtDef, ClosureSubsts, GeneratorSubsts, Region, Const, LazyConst}; -use ty::{PolyFnSig, InferTy, ParamTy, ProjectionTy, ExistentialPredicate, Predicate}; -use ty::RegionKind; -use ty::{TyVar, TyVid, IntVar, IntVid, FloatVar, FloatVid}; -use ty::TyKind::*; -use ty::GenericParamDefKind; -use ty::layout::{LayoutDetails, TargetDataLayout, VariantIdx}; -use ty::query; -use ty::steal::Steal; -use ty::subst::{UserSubsts, UnpackedKind}; -use ty::{BoundVar, BindingMode}; -use ty::CanonicalPolyFnSig; -use util::nodemap::{DefIdMap, DefIdSet, ItemLocalMap}; -use util::nodemap::{FxHashMap, FxHashSet}; +use crate::dep_graph::DepGraph; +use crate::dep_graph::{DepNode, DepConstructor}; +use crate::errors::DiagnosticBuilder; +use crate::session::Session; +use crate::session::config::{BorrowckMode, OutputFilenames}; +use crate::session::config::CrateType; +use crate::middle; +use crate::hir::{TraitCandidate, HirId, ItemKind, ItemLocalId, Node}; +use crate::hir::def::{Def, Export}; +use crate::hir::def_id::{CrateNum, DefId, DefIndex, LOCAL_CRATE}; +use crate::hir::map as hir_map; +use crate::hir::map::DefPathHash; +use crate::lint::{self, Lint}; +use crate::ich::{StableHashingContext, NodeIdHashingMode}; +use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos}; +use crate::infer::outlives::free_region_map::FreeRegionMap; +use crate::middle::cstore::CrateStoreDyn; +use crate::middle::cstore::EncodedMetadata; +use crate::middle::lang_items; +use crate::middle::resolve_lifetime::{self, ObjectLifetimeDefault}; +use crate::middle::stability; +use crate::mir::{self, Mir, interpret, ProjectionKind}; +use crate::mir::interpret::Allocation; +use crate::ty::subst::{Kind, Substs, Subst}; +use crate::ty::ReprOptions; +use crate::traits; +use crate::traits::{Clause, Clauses, GoalKind, Goal, Goals}; +use crate::ty::{self, Ty, TypeAndMut}; +use crate::ty::{TyS, TyKind, List}; +use crate::ty::{AdtKind, AdtDef, ClosureSubsts, GeneratorSubsts, Region, Const, LazyConst}; +use crate::ty::{PolyFnSig, InferTy, ParamTy, ProjectionTy, ExistentialPredicate, Predicate}; +use crate::ty::RegionKind; +use crate::ty::{TyVar, TyVid, IntVar, IntVid, FloatVar, FloatVid}; +use crate::ty::TyKind::*; +use crate::ty::GenericParamDefKind; +use crate::ty::layout::{LayoutDetails, TargetDataLayout, VariantIdx}; +use crate::ty::query; +use crate::ty::steal::Steal; +use crate::ty::subst::{UserSubsts, UnpackedKind}; +use crate::ty::{BoundVar, BindingMode}; +use crate::ty::CanonicalPolyFnSig; +use crate::util::nodemap::{DefIdMap, DefIdSet, ItemLocalMap}; +use crate::util::nodemap::{FxHashMap, FxHashSet}; use rustc_data_structures::interner::HashInterner; use smallvec::SmallVec; use rustc_data_structures::stable_hasher::{HashStable, hash_stable_hashmap, @@ -73,7 +73,7 @@ use syntax::feature_gate; use syntax::symbol::{Symbol, keywords, InternedString}; use syntax_pos::Span; -use hir; +use crate::hir; pub struct AllArenas<'tcx> { pub global: WorkerLocal>, @@ -1822,18 +1822,18 @@ pub mod tls { use std::marker::PhantomData; use std::ptr; use syntax_pos; - use ty::query; - use errors::{Diagnostic, TRACK_DIAGNOSTICS}; + use crate::ty::query; + use crate::errors::{Diagnostic, TRACK_DIAGNOSTICS}; use rustc_data_structures::OnDrop; use rustc_data_structures::sync::{self, Lrc, Lock}; use rustc_data_structures::thin_vec::ThinVec; - use dep_graph::TaskDeps; + use crate::dep_graph::TaskDeps; #[cfg(not(parallel_compiler))] use std::cell::Cell; #[cfg(parallel_compiler)] - use rayon_core; + use rustc_rayon_core as rayon_core; /// This is the implicit state of rustc. It contains the current /// TyCtxt and query. It is updated when creating a local interner or @@ -2114,8 +2114,8 @@ macro_rules! sty_debug_print { // variable names. #[allow(non_snake_case)] mod inner { - use ty::{self, TyCtxt}; - use ty::context::Interned; + use crate::ty::{self, TyCtxt}; + use crate::ty::context::Interned; #[derive(Copy, Clone)] struct DebugStat { diff --git a/src/librustc/ty/erase_regions.rs b/src/librustc/ty/erase_regions.rs index da7e021b2d54b..0431afcc76c9e 100644 --- a/src/librustc/ty/erase_regions.rs +++ b/src/librustc/ty/erase_regions.rs @@ -1,5 +1,5 @@ -use ty::{self, Ty, TyCtxt, TypeFlags}; -use ty::fold::{TypeFolder, TypeFoldable}; +use crate::ty::{self, Ty, TyCtxt, TypeFlags}; +use crate::ty::fold::{TypeFolder, TypeFoldable}; pub(super) fn provide(providers: &mut ty::query::Providers<'_>) { *providers = ty::query::Providers { diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index f444013e2a3bd..d0c9677ea6ecb 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -1,13 +1,13 @@ -use hir::def_id::DefId; -use ty::{self, Region, Ty, TyCtxt}; +use crate::hir::def_id::DefId; +use crate::ty::{self, Region, Ty, TyCtxt}; use std::borrow::Cow; use std::fmt; use rustc_target::spec::abi; use syntax::ast; -use errors::{Applicability, DiagnosticBuilder}; +use crate::errors::{Applicability, DiagnosticBuilder}; use syntax_pos::Span; -use hir; +use crate::hir; #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub struct ExpectedFound { diff --git a/src/librustc/ty/fast_reject.rs b/src/librustc/ty/fast_reject.rs index 2b41fc4fe341f..59ab4561f2c87 100644 --- a/src/librustc/ty/fast_reject.rs +++ b/src/librustc/ty/fast_reject.rs @@ -1,12 +1,12 @@ -use hir::def_id::DefId; -use ich::StableHashingContext; +use crate::hir::def_id::DefId; +use crate::ich::StableHashingContext; use rustc_data_structures::stable_hasher::{StableHasher, StableHasherResult, HashStable}; use std::fmt::Debug; use std::hash::Hash; use std::mem; use syntax::ast; -use ty::{self, Ty, TyCtxt}; +use crate::ty::{self, Ty, TyCtxt}; use self::SimplifiedTypeGen::*; diff --git a/src/librustc/ty/flags.rs b/src/librustc/ty/flags.rs index 4fa13a01d5a92..25ec3e49cdf67 100644 --- a/src/librustc/ty/flags.rs +++ b/src/librustc/ty/flags.rs @@ -1,5 +1,5 @@ -use ty::subst::Substs; -use ty::{self, Ty, TypeFlags, TypeFoldable}; +use crate::ty::subst::Substs; +use crate::ty::{self, Ty, TypeFlags, TypeFoldable}; #[derive(Debug)] pub struct FlagComputation { diff --git a/src/librustc/ty/fold.rs b/src/librustc/ty/fold.rs index 28b6f010ce09c..306c69666e596 100644 --- a/src/librustc/ty/fold.rs +++ b/src/librustc/ty/fold.rs @@ -29,12 +29,12 @@ //! These methods return true to indicate that the visitor has found what it is looking for //! and does not need to visit anything else. -use hir::def_id::DefId; -use ty::{self, Binder, Ty, TyCtxt, TypeFlags}; +use crate::hir::def_id::DefId; +use crate::ty::{self, Binder, Ty, TyCtxt, TypeFlags}; use std::collections::BTreeMap; use std::fmt; -use util::nodemap::FxHashSet; +use crate::util::nodemap::FxHashSet; /// The TypeFoldable trait is implemented for every type that can be folded. /// Basically, every type that has a corresponding method in TypeFolder. diff --git a/src/librustc/ty/inhabitedness/def_id_forest.rs b/src/librustc/ty/inhabitedness/def_id_forest.rs index 41fd88607e893..73b7d74d9dafe 100644 --- a/src/librustc/ty/inhabitedness/def_id_forest.rs +++ b/src/librustc/ty/inhabitedness/def_id_forest.rs @@ -1,8 +1,8 @@ use std::mem; use smallvec::SmallVec; use syntax::ast::CRATE_NODE_ID; -use ty::context::TyCtxt; -use ty::{DefId, DefIdTree}; +use crate::ty::context::TyCtxt; +use crate::ty::{DefId, DefIdTree}; /// Represents a forest of DefIds closed under the ancestor relation. That is, /// if a DefId representing a module is contained in the forest then all diff --git a/src/librustc/ty/inhabitedness/mod.rs b/src/librustc/ty/inhabitedness/mod.rs index 6dfc9681cfd86..601ffe70eec18 100644 --- a/src/librustc/ty/inhabitedness/mod.rs +++ b/src/librustc/ty/inhabitedness/mod.rs @@ -1,8 +1,8 @@ -use ty::context::TyCtxt; -use ty::{AdtDef, VariantDef, FieldDef, Ty, TyS}; -use ty::{self, DefId, Substs}; -use ty::{AdtKind, Visibility}; -use ty::TyKind::*; +use crate::ty::context::TyCtxt; +use crate::ty::{AdtDef, VariantDef, FieldDef, Ty, TyS}; +use crate::ty::{self, DefId, Substs}; +use crate::ty::{AdtKind, Visibility}; +use crate::ty::TyKind::*; pub use self::def_id_forest::DefIdForest; diff --git a/src/librustc/ty/instance.rs b/src/librustc/ty/instance.rs index bc43fedef0f34..e4fe93d5deaea 100644 --- a/src/librustc/ty/instance.rs +++ b/src/librustc/ty/instance.rs @@ -1,9 +1,9 @@ -use hir::Unsafety; -use hir::def_id::DefId; -use ty::{self, Ty, PolyFnSig, TypeFoldable, Substs, TyCtxt}; -use traits; +use crate::hir::Unsafety; +use crate::hir::def_id::DefId; +use crate::ty::{self, Ty, PolyFnSig, TypeFoldable, Substs, TyCtxt}; +use crate::traits; use rustc_target::spec::abi::Abi; -use util::ppaux; +use crate::util::ppaux; use std::fmt; use std::iter; @@ -141,7 +141,7 @@ impl<'tcx> InstanceDef<'tcx> { &self, tcx: TyCtxt<'a, 'tcx, 'tcx> ) -> bool { - use hir::map::DefPathData; + use crate::hir::map::DefPathData; let def_id = match *self { ty::InstanceDef::Item(def_id) => def_id, ty::InstanceDef::DropGlue(_, Some(_)) => return false, diff --git a/src/librustc/ty/item_path.rs b/src/librustc/ty/item_path.rs index adb7e1fb3e322..f89e50d696945 100644 --- a/src/librustc/ty/item_path.rs +++ b/src/librustc/ty/item_path.rs @@ -1,8 +1,8 @@ -use hir; -use hir::map::DefPathData; -use hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; -use ty::{self, DefIdTree, Ty, TyCtxt}; -use middle::cstore::{ExternCrate, ExternCrateSource}; +use crate::hir; +use crate::hir::map::DefPathData; +use crate::hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX, LOCAL_CRATE}; +use crate::ty::{self, DefIdTree, Ty, TyCtxt}; +use crate::middle::cstore::{ExternCrate, ExternCrateSource}; use syntax::ast; use syntax::symbol::{keywords, LocalInternedString, Symbol}; diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 1162bff852cbb..8401d0861cad2 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -1,5 +1,5 @@ -use session::{self, DataTypeKind}; -use ty::{self, Ty, TyCtxt, TypeFoldable, ReprOptions}; +use crate::session::{self, DataTypeKind}; +use crate::ty::{self, Ty, TyCtxt, TypeFoldable, ReprOptions}; use syntax::ast::{self, Ident, IntTy, UintTy}; use syntax::attr; @@ -12,7 +12,7 @@ use std::iter; use std::mem; use std::ops::Bound; -use ich::StableHashingContext; +use crate::ich::StableHashingContext; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableHasherResult}; @@ -1872,7 +1872,7 @@ impl<'a> HashStable> for Variants { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - use ty::layout::Variants::*; + use crate::ty::layout::Variants::*; mem::discriminant(self).hash_stable(hcx, hasher); match *self { @@ -1908,7 +1908,7 @@ impl<'a> HashStable> for FieldPlacement { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - use ty::layout::FieldPlacement::*; + use crate::ty::layout::FieldPlacement::*; mem::discriminant(self).hash_stable(hcx, hasher); match *self { @@ -1941,7 +1941,7 @@ impl<'a> HashStable> for Abi { fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - use ty::layout::Abi::*; + use crate::ty::layout::Abi::*; mem::discriminant(self).hash_stable(hcx, hasher); match *self { @@ -1975,7 +1975,7 @@ impl<'a> HashStable> for Scalar { } } -impl_stable_hash_for!(struct ::ty::layout::LayoutDetails { +impl_stable_hash_for!(struct crate::ty::layout::LayoutDetails { variants, fields, abi, @@ -1983,7 +1983,7 @@ impl_stable_hash_for!(struct ::ty::layout::LayoutDetails { align }); -impl_stable_hash_for!(enum ::ty::layout::Integer { +impl_stable_hash_for!(enum crate::ty::layout::Integer { I8, I16, I32, @@ -1991,13 +1991,13 @@ impl_stable_hash_for!(enum ::ty::layout::Integer { I128 }); -impl_stable_hash_for!(enum ::ty::layout::Primitive { +impl_stable_hash_for!(enum crate::ty::layout::Primitive { Int(integer, signed), Float(fty), Pointer }); -impl_stable_hash_for!(struct ::ty::layout::AbiAndPrefAlign { +impl_stable_hash_for!(struct crate::ty::layout::AbiAndPrefAlign { abi, pref }); @@ -2023,7 +2023,7 @@ impl<'a, 'gcx> HashStable> for LayoutError<'gcx> fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { - use ty::layout::LayoutError::*; + use crate::ty::layout::LayoutError::*; mem::discriminant(self).hash_stable(hcx, hasher); match *self { diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index c9089428b2324..60e3ac673a0a0 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -4,31 +4,31 @@ pub use self::BorrowKind::*; pub use self::IntVarValue::*; pub use self::fold::TypeFoldable; -use hir::{map as hir_map, FreevarMap, GlobMap, TraitMap}; -use hir::Node; -use hir::def::{Def, CtorKind, ExportMap}; -use hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE}; -use hir::map::DefPathData; +use crate::hir::{map as hir_map, FreevarMap, GlobMap, TraitMap}; +use crate::hir::Node; +use crate::hir::def::{Def, CtorKind, ExportMap}; +use crate::hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE}; +use crate::hir::map::DefPathData; use rustc_data_structures::svh::Svh; -use ich::Fingerprint; -use ich::StableHashingContext; -use infer::canonical::Canonical; -use middle::lang_items::{FnTraitLangItem, FnMutTraitLangItem, FnOnceTraitLangItem}; -use middle::resolve_lifetime::ObjectLifetimeDefault; -use mir::Mir; -use mir::interpret::{GlobalId, ErrorHandled}; -use mir::GeneratorLayout; -use session::CrateDisambiguator; -use traits::{self, Reveal}; -use ty; -use ty::layout::VariantIdx; -use ty::subst::{Subst, Substs}; -use ty::util::{IntTypeExt, Discr}; -use ty::walk::TypeWalker; -use util::captures::Captures; -use util::nodemap::{NodeSet, DefIdMap, FxHashMap}; +use crate::ich::Fingerprint; +use crate::ich::StableHashingContext; +use crate::infer::canonical::Canonical; +use crate::middle::lang_items::{FnTraitLangItem, FnMutTraitLangItem, FnOnceTraitLangItem}; +use crate::middle::resolve_lifetime::ObjectLifetimeDefault; +use crate::mir::Mir; +use crate::mir::interpret::{GlobalId, ErrorHandled}; +use crate::mir::GeneratorLayout; +use crate::session::CrateDisambiguator; +use crate::traits::{self, Reveal}; +use crate::ty; +use crate::ty::layout::VariantIdx; +use crate::ty::subst::{Subst, Substs}; +use crate::ty::util::{IntTypeExt, Discr}; +use crate::ty::walk::TypeWalker; +use crate::util::captures::Captures; +use crate::util::nodemap::{NodeSet, DefIdMap, FxHashMap}; use arena::SyncDroplessArena; -use session::DataTypeKind; +use crate::session::DataTypeKind; use serialize::{self, Encodable, Encoder}; use std::cell::RefCell; @@ -50,7 +50,7 @@ use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc_data_structures::stable_hasher::{StableHasher, StableHasherResult, HashStable}; -use hir; +use crate::hir; pub use self::sty::{Binder, BoundTy, BoundTyKind, BoundVar, DebruijnIndex, INNERMOST}; pub use self::sty::{FnSig, GenSig, CanonicalPolyFnSig, PolyFnSig, PolyGenSig}; @@ -2277,7 +2277,7 @@ impl<'a, 'gcx, 'tcx> AdtDef { }) } else { info!("invalid enum discriminant: {:#?}", val); - ::mir::interpret::struct_error( + crate::mir::interpret::struct_error( tcx.at(tcx.def_span(expr_did)), "constant evaluation of enum discriminant resulted in non-integer", ).emit(); diff --git a/src/librustc/ty/outlives.rs b/src/librustc/ty/outlives.rs index ca2d5cd718c64..5b21ed5abd77b 100644 --- a/src/librustc/ty/outlives.rs +++ b/src/librustc/ty/outlives.rs @@ -3,7 +3,7 @@ // RFC for reference. use smallvec::SmallVec; -use ty::{self, Ty, TyCtxt, TypeFoldable}; +use crate::ty::{self, Ty, TyCtxt, TypeFoldable}; #[derive(Debug)] pub enum Component<'tcx> { diff --git a/src/librustc/ty/query/config.rs b/src/librustc/ty/query/config.rs index 495cce4d2feac..255e39eaccd6d 100644 --- a/src/librustc/ty/query/config.rs +++ b/src/librustc/ty/query/config.rs @@ -1,19 +1,19 @@ -use dep_graph::SerializedDepNodeIndex; -use dep_graph::DepNode; -use hir::def_id::{CrateNum, DefId, DefIndex}; -use mir::interpret::GlobalId; -use traits; -use traits::query::{ +use crate::dep_graph::SerializedDepNodeIndex; +use crate::dep_graph::DepNode; +use crate::hir::def_id::{CrateNum, DefId, DefIndex}; +use crate::mir::interpret::GlobalId; +use crate::traits; +use crate::traits::query::{ CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal, CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpNormalizeGoal, CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpSubtypeGoal, }; -use ty::{self, ParamEnvAnd, Ty, TyCtxt}; -use ty::subst::Substs; -use ty::query::queries; -use ty::query::Query; -use ty::query::QueryCache; -use util::profiling::ProfileCategory; +use crate::ty::{self, ParamEnvAnd, Ty, TyCtxt}; +use crate::ty::subst::Substs; +use crate::ty::query::queries; +use crate::ty::query::Query; +use crate::ty::query::QueryCache; +use crate::util::profiling::ProfileCategory; use std::borrow::Cow; use std::hash::Hash; @@ -21,7 +21,7 @@ use std::fmt::Debug; use syntax_pos::symbol::InternedString; use rustc_data_structures::sync::Lock; use rustc_data_structures::stable_hasher::HashStable; -use ich::StableHashingContext; +use crate::ich::StableHashingContext; // Query configuration and description traits. @@ -901,7 +901,7 @@ impl<'tcx> QueryDescription<'tcx> for queries::optimized_mir<'tcx> { fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, id: SerializedDepNodeIndex) -> Option { - let mir: Option<::mir::Mir<'tcx>> = tcx.queries.on_disk_cache + let mir: Option> = tcx.queries.on_disk_cache .try_load_query_result(tcx, id); mir.map(|x| tcx.alloc_mir(x)) } diff --git a/src/librustc/ty/query/job.rs b/src/librustc/ty/query/job.rs index abbf74a7761ef..0793366e6d479 100644 --- a/src/librustc/ty/query/job.rs +++ b/src/librustc/ty/query/job.rs @@ -1,25 +1,27 @@ #![allow(warnings)] use std::mem; +use std::process; +use std::{fmt, ptr}; + use rustc_data_structures::fx::FxHashSet; use rustc_data_structures::sync::{Lock, LockGuard, Lrc, Weak}; use rustc_data_structures::OnDrop; use syntax_pos::Span; -use ty::tls; -use ty::query::Query; -use ty::query::plumbing::CycleError; + +use crate::ty::tls; +use crate::ty::query::Query; +use crate::ty::query::plumbing::CycleError; #[cfg(not(parallel_compiler))] -use ty::query::{ +use crate::ty::query::{ plumbing::TryGetJob, config::QueryDescription, }; -use ty::context::TyCtxt; -use std::process; -use std::{fmt, ptr}; +use crate::ty::context::TyCtxt; #[cfg(parallel_compiler)] use { - rayon_core, + rustc_rayon_core as rayon_core, parking_lot::{Mutex, Condvar}, std::sync::atomic::Ordering, std::thread, @@ -89,7 +91,7 @@ impl<'tcx> QueryJob<'tcx> { /// For single threaded rustc there's no concurrent jobs running, so if we are waiting for any /// query that means that there is a query cycle, thus this always running a cycle error. #[cfg(parallel_compiler)] - pub(super) fn await<'lcx>( + pub(super) fn r#await<'lcx>( &self, tcx: TyCtxt<'_, 'tcx, 'lcx>, span: Span, @@ -101,7 +103,7 @@ impl<'tcx> QueryJob<'tcx> { cycle: Lock::new(None), condvar: Condvar::new(), }); - self.latch.await(&waiter); + self.latch.r#await(&waiter); // FIXME: Get rid of this lock. We have ownership of the QueryWaiter // although another thread may still have a Lrc reference so we cannot // use Lrc::get_mut @@ -200,7 +202,7 @@ impl<'tcx> QueryLatch<'tcx> { } /// Awaits the caller on this latch by blocking the current thread. - fn await(&self, waiter: &Lrc>) { + fn r#await(&self, waiter: &Lrc>) { let mut info = self.info.lock(); if !info.complete { // We push the waiter on to the `waiters` list. It can be accessed inside diff --git a/src/librustc/ty/query/keys.rs b/src/librustc/ty/query/keys.rs index af6f5a00dee5c..f5eb7374cc19b 100644 --- a/src/librustc/ty/query/keys.rs +++ b/src/librustc/ty/query/keys.rs @@ -1,12 +1,12 @@ //! Defines the set of legal keys that can be used in queries. -use infer::canonical::Canonical; -use hir::def_id::{CrateNum, DefId, LOCAL_CRATE, DefIndex}; -use traits; -use ty::{self, Ty, TyCtxt}; -use ty::subst::Substs; -use ty::fast_reject::SimplifiedType; -use mir; +use crate::infer::canonical::Canonical; +use crate::hir::def_id::{CrateNum, DefId, LOCAL_CRATE, DefIndex}; +use crate::traits; +use crate::ty::{self, Ty, TyCtxt}; +use crate::ty::subst::Substs; +use crate::ty::fast_reject::SimplifiedType; +use crate::mir; use std::fmt::Debug; use std::hash::Hash; diff --git a/src/librustc/ty/query/mod.rs b/src/librustc/ty/query/mod.rs index d4884e712b860..20a700bb58dd1 100644 --- a/src/librustc/ty/query/mod.rs +++ b/src/librustc/ty/query/mod.rs @@ -1,48 +1,48 @@ -use dep_graph::{DepConstructor, DepNode}; -use errors::DiagnosticBuilder; -use hir::def_id::{CrateNum, DefId, DefIndex}; -use hir::def::{Def, Export}; -use hir::{self, TraitCandidate, ItemLocalId, CodegenFnAttrs}; +use crate::dep_graph::{DepConstructor, DepNode}; +use crate::errors::DiagnosticBuilder; +use crate::hir::def_id::{CrateNum, DefId, DefIndex}; +use crate::hir::def::{Def, Export}; +use crate::hir::{self, TraitCandidate, ItemLocalId, CodegenFnAttrs}; use rustc_data_structures::svh::Svh; -use infer::canonical::{self, Canonical}; -use lint; -use middle::borrowck::BorrowCheckResult; -use middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary, ForeignModule}; -use middle::cstore::{NativeLibraryKind, DepKind, CrateSource}; -use middle::privacy::AccessLevels; -use middle::reachable::ReachableSet; -use middle::region; -use middle::resolve_lifetime::{ResolveLifetimes, Region, ObjectLifetimeDefault}; -use middle::stability::{self, DeprecationEntry}; -use middle::lib_features::LibFeatures; -use middle::lang_items::{LanguageItems, LangItem}; -use middle::exported_symbols::{SymbolExportLevel, ExportedSymbol}; -use mir::interpret::{ConstEvalRawResult, ConstEvalResult}; -use mir::mono::CodegenUnit; -use mir; -use mir::interpret::GlobalId; -use session::{CompileResult, CrateDisambiguator}; -use session::config::{EntryFnType, OutputFilenames, OptLevel}; -use traits::{self, Vtable}; -use traits::query::{ +use crate::infer::canonical::{self, Canonical}; +use crate::lint; +use crate::middle::borrowck::BorrowCheckResult; +use crate::middle::cstore::{ExternCrate, LinkagePreference, NativeLibrary, ForeignModule}; +use crate::middle::cstore::{NativeLibraryKind, DepKind, CrateSource}; +use crate::middle::privacy::AccessLevels; +use crate::middle::reachable::ReachableSet; +use crate::middle::region; +use crate::middle::resolve_lifetime::{ResolveLifetimes, Region, ObjectLifetimeDefault}; +use crate::middle::stability::{self, DeprecationEntry}; +use crate::middle::lib_features::LibFeatures; +use crate::middle::lang_items::{LanguageItems, LangItem}; +use crate::middle::exported_symbols::{SymbolExportLevel, ExportedSymbol}; +use crate::mir::interpret::{ConstEvalRawResult, ConstEvalResult}; +use crate::mir::mono::CodegenUnit; +use crate::mir; +use crate::mir::interpret::GlobalId; +use crate::session::{CompileResult, CrateDisambiguator}; +use crate::session::config::{EntryFnType, OutputFilenames, OptLevel}; +use crate::traits::{self, Vtable}; +use crate::traits::query::{ CanonicalPredicateGoal, CanonicalProjectionGoal, CanonicalTyGoal, CanonicalTypeOpAscribeUserTypeGoal, CanonicalTypeOpEqGoal, CanonicalTypeOpSubtypeGoal, CanonicalTypeOpProvePredicateGoal, CanonicalTypeOpNormalizeGoal, NoSolution, }; -use traits::query::method_autoderef::MethodAutoderefStepsResult; -use traits::query::dropck_outlives::{DtorckConstraint, DropckOutlivesResult}; -use traits::query::normalize::NormalizationResult; -use traits::query::outlives_bounds::OutlivesBound; -use traits::specialization_graph; -use traits::Clauses; -use ty::{self, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt}; -use ty::steal::Steal; -use ty::subst::Substs; -use util::nodemap::{DefIdSet, DefIdMap, ItemLocalSet}; -use util::common::{ErrorReported}; -use util::profiling::ProfileCategory::*; -use session::Session; +use crate::traits::query::method_autoderef::MethodAutoderefStepsResult; +use crate::traits::query::dropck_outlives::{DtorckConstraint, DropckOutlivesResult}; +use crate::traits::query::normalize::NormalizationResult; +use crate::traits::query::outlives_bounds::OutlivesBound; +use crate::traits::specialization_graph; +use crate::traits::Clauses; +use crate::ty::{self, CrateInherentImpls, ParamEnvAnd, Ty, TyCtxt}; +use crate::ty::steal::Steal; +use crate::ty::subst::Substs; +use crate::util::nodemap::{DefIdSet, DefIdMap, ItemLocalSet}; +use crate::util::common::{ErrorReported}; +use crate::util::profiling::ProfileCategory::*; +use crate::session::Session; use rustc_data_structures::bit_set::BitSet; use rustc_data_structures::indexed_vec::IndexVec; diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index a3f49de0d078b..9c9bc0f6aa11c 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -1,28 +1,28 @@ -use dep_graph::{DepNodeIndex, SerializedDepNodeIndex}; -use errors::Diagnostic; -use hir; -use hir::def_id::{CrateNum, DefIndex, DefId, LocalDefId, LOCAL_CRATE}; -use hir::map::definitions::DefPathHash; -use ich::{CachingSourceMapView, Fingerprint}; -use mir::{self, interpret}; -use mir::interpret::{AllocDecodingSession, AllocDecodingState}; +use crate::dep_graph::{DepNodeIndex, SerializedDepNodeIndex}; +use crate::errors::Diagnostic; +use crate::hir; +use crate::hir::def_id::{CrateNum, DefIndex, DefId, LocalDefId, LOCAL_CRATE}; +use crate::hir::map::definitions::DefPathHash; +use crate::ich::{CachingSourceMapView, Fingerprint}; +use crate::mir::{self, interpret}; +use crate::mir::interpret::{AllocDecodingSession, AllocDecodingState}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::thin_vec::ThinVec; use rustc_data_structures::sync::{Lrc, Lock, HashMapExt, Once}; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; -use rustc_serialize::{Decodable, Decoder, Encodable, Encoder, opaque, +use crate::rustc_serialize::{Decodable, Decoder, Encodable, Encoder, opaque, SpecializedDecoder, SpecializedEncoder, UseSpecializedDecodable, UseSpecializedEncodable}; -use session::{CrateDisambiguator, Session}; +use crate::session::{CrateDisambiguator, Session}; use std::mem; use syntax::ast::NodeId; use syntax::source_map::{SourceMap, StableSourceFileId}; use syntax_pos::{BytePos, Span, DUMMY_SP, SourceFile}; use syntax_pos::hygiene::{Mark, SyntaxContext, ExpnInfo}; -use ty; -use ty::codec::{self as ty_codec, TyDecoder, TyEncoder}; -use ty::context::TyCtxt; -use util::common::time; +use crate::ty; +use crate::ty::codec::{self as ty_codec, TyDecoder, TyEncoder}; +use crate::ty::context::TyCtxt; +use crate::util::common::time; const TAG_FILE_FOOTER: u128 = 0xC0FFEE_C0FFEE_C0FFEE_C0FFEE_C0FFEE; @@ -202,7 +202,7 @@ impl<'sess> OnDiskCache<'sess> { let mut query_result_index = EncodedQueryResultIndex::new(); time(tcx.sess, "encode query results", || { - use ty::query::queries::*; + use crate::ty::query::queries::*; let enc = &mut encoder; let qri = &mut query_result_index; @@ -225,11 +225,11 @@ impl<'sess> OnDiskCache<'sess> { encode_query_results::, _>(tcx, enc, qri)?; // const eval is special, it only encodes successfully evaluated constants - use ty::query::QueryAccessors; + use crate::ty::query::QueryAccessors; let cache = const_eval::query_cache(tcx).borrow(); assert!(cache.active.is_empty()); for (key, entry) in cache.results.iter() { - use ty::query::config::QueryDescription; + use crate::ty::query::config::QueryDescription; if const_eval::cache_on_disk(tcx, key.clone()) { if let Ok(ref value) = entry.value { let dep_node = SerializedDepNodeIndex::new(entry.index.index()); @@ -777,7 +777,7 @@ impl<'enc, 'a, 'tcx, E> CacheEncoder<'enc, 'a, 'tcx, E> value: &V) -> Result<(), E::Error> { - use ty::codec::TyEncoder; + use crate::ty::codec::TyEncoder; let start_pos = self.position(); tag.encode(self)?; diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index 69bff8d25b024..a26b21a1059fe 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -2,19 +2,19 @@ //! that generate the actual methods on tcx which find and execute the //! provider, manage the caches, and so forth. -use dep_graph::{DepNodeIndex, DepNode, DepKind, SerializedDepNodeIndex}; -use errors::DiagnosticBuilder; -use errors::Level; -use errors::Diagnostic; -use errors::FatalError; -use ty::tls; -use ty::{TyCtxt}; -use ty::query::Query; -use ty::query::config::{QueryConfig, QueryDescription}; -use ty::query::job::{QueryJob, QueryResult, QueryInfo}; -use ty::item_path; - -use util::common::{profq_msg, ProfileQueriesMsg, QueryMsg}; +use crate::dep_graph::{DepNodeIndex, DepNode, DepKind, SerializedDepNodeIndex}; +use crate::errors::DiagnosticBuilder; +use crate::errors::Level; +use crate::errors::Diagnostic; +use crate::errors::FatalError; +use crate::ty::tls; +use crate::ty::{TyCtxt}; +use crate::ty::query::Query; +use crate::ty::query::config::{QueryConfig, QueryDescription}; +use crate::ty::query::job::{QueryJob, QueryResult, QueryInfo}; +use crate::ty::item_path; + +use crate::util::common::{profq_msg, ProfileQueriesMsg, QueryMsg}; use rustc_data_structures::fx::{FxHashMap}; use rustc_data_structures::sync::{Lrc, Lock}; @@ -160,7 +160,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> { // thread #[cfg(parallel_compiler)] { - if let Err(cycle) = job.await(tcx, span) { + if let Err(cycle) = job.r#await(tcx, span) { return TryGetJob::JobCompleted(Err(cycle)); } } @@ -367,7 +367,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { // Fast path for when incr. comp. is off. `to_dep_node` is // expensive for some DepKinds. if !self.dep_graph.is_fully_enabled() { - let null_dep_node = DepNode::new_no_params(::dep_graph::DepKind::Null); + let null_dep_node = DepNode::new_no_params(crate::dep_graph::DepKind::Null); return Ok(self.force_query_with_job::(key, job, null_dep_node).0); } @@ -500,7 +500,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { dep_node_index: DepNodeIndex, ) { use rustc_data_structures::stable_hasher::{StableHasher, HashStable}; - use ich::Fingerprint; + use crate::ich::Fingerprint; assert!(Some(self.dep_graph.fingerprint_of(dep_node_index)) == self.dep_graph.prev_fingerprint_of(dep_node), @@ -566,7 +566,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { self.dep_graph.mark_loaded_from_cache(dep_node_index, false); } - if dep_node.kind != ::dep_graph::DepKind::Null { + if dep_node.kind != crate::dep_graph::DepKind::Null { if unlikely!(!diagnostics.is_empty()) { self.queries.on_disk_cache .store_diagnostics(dep_node_index, diagnostics); @@ -698,13 +698,13 @@ macro_rules! define_queries_inner { #[cfg(parallel_compiler)] use ty::query::job::QueryResult; use rustc_data_structures::sync::Lock; - use { + use crate::{ rustc_data_structures::stable_hasher::HashStable, rustc_data_structures::stable_hasher::StableHasherResult, rustc_data_structures::stable_hasher::StableHasher, ich::StableHashingContext }; - use util::profiling::ProfileCategory; + use crate::util::profiling::ProfileCategory; define_queries_struct! { tcx: $tcx, @@ -947,7 +947,7 @@ macro_rules! define_queries_inner { #[allow(unused)] #[inline(always)] fn to_dep_node(tcx: TyCtxt<'_, $tcx, '_>, key: &Self::Key) -> DepNode { - use dep_graph::DepConstructor::*; + use crate::dep_graph::DepConstructor::*; DepNode::new(tcx, $node(*key)) } @@ -1127,7 +1127,7 @@ macro_rules! define_provider_struct { pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, dep_node: &DepNode) -> bool { - use hir::def_id::LOCAL_CRATE; + use crate::hir::def_id::LOCAL_CRATE; // We must avoid ever having to call force_from_dep_node() for a // DepNode::CodegenUnit: @@ -1167,7 +1167,7 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, macro_rules! force { ($query:ident, $key:expr) => { { - tcx.force_query::<::ty::query::queries::$query<'_>>($key, DUMMY_SP, *dep_node); + tcx.force_query::>($key, DUMMY_SP, *dep_node); } } }; @@ -1437,8 +1437,8 @@ macro_rules! impl_load_from_cache { // Check whether the query invocation corresponding to the given // DepNode is eligible for on-disk-caching. pub fn cache_on_disk(&self, tcx: TyCtxt<'_, '_, '_>) -> bool { - use ty::query::queries; - use ty::query::QueryDescription; + use crate::ty::query::queries; + use crate::ty::query::QueryDescription; match self.kind { $(DepKind::$dep_kind => { diff --git a/src/librustc/ty/query/values.rs b/src/librustc/ty/query/values.rs index 3f84f1bc78972..11f55208d6e48 100644 --- a/src/librustc/ty/query/values.rs +++ b/src/librustc/ty/query/values.rs @@ -1,4 +1,4 @@ -use ty::{self, Ty, TyCtxt}; +use crate::ty::{self, Ty, TyCtxt}; use syntax::symbol::Symbol; diff --git a/src/librustc/ty/relate.rs b/src/librustc/ty/relate.rs index a16d6fea74c0b..3dbd0dc1d97f7 100644 --- a/src/librustc/ty/relate.rs +++ b/src/librustc/ty/relate.rs @@ -4,18 +4,18 @@ //! types or regions but can be other things. Examples of type relations are //! subtyping, type equality, etc. -use hir::def_id::DefId; -use ty::subst::{Kind, UnpackedKind, Substs}; -use ty::{self, Ty, TyCtxt, TypeFoldable}; -use ty::error::{ExpectedFound, TypeError}; -use mir::interpret::GlobalId; -use util::common::ErrorReported; +use crate::hir::def_id::DefId; +use crate::ty::subst::{Kind, UnpackedKind, Substs}; +use crate::ty::{self, Ty, TyCtxt, TypeFoldable}; +use crate::ty::error::{ExpectedFound, TypeError}; +use crate::mir::interpret::GlobalId; +use crate::util::common::ErrorReported; use syntax_pos::DUMMY_SP; use std::rc::Rc; use std::iter; use rustc_target::spec::abi; -use hir as ast; -use traits; +use crate::hir as ast; +use crate::traits; pub type RelateResult<'tcx, T> = Result>; @@ -588,7 +588,7 @@ impl<'tcx> Relate<'tcx> for &'tcx ty::List> { let tcx = relation.tcx(); let v = a.iter().zip(b.iter()).map(|(ep_a, ep_b)| { - use ty::ExistentialPredicate::*; + use crate::ty::ExistentialPredicate::*; match (*ep_a, *ep_b) { (Trait(ref a), Trait(ref b)) => Ok(Trait(relation.relate(a, b)?)), (Projection(ref a), Projection(ref b)) => Ok(Projection(relation.relate(a, b)?)), @@ -746,7 +746,7 @@ impl<'tcx> Relate<'tcx> for traits::WhereClause<'tcx> { ) -> RelateResult<'tcx, traits::WhereClause<'tcx>> where R: TypeRelation<'a, 'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a { - use traits::WhereClause::*; + use crate::traits::WhereClause::*; match (a, b) { (Implemented(a_pred), Implemented(b_pred)) => { Ok(Implemented(relation.relate(a_pred, b_pred)?)) @@ -783,7 +783,7 @@ impl<'tcx> Relate<'tcx> for traits::WellFormed<'tcx> { ) -> RelateResult<'tcx, traits::WellFormed<'tcx>> where R: TypeRelation<'a, 'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a { - use traits::WellFormed::*; + use crate::traits::WellFormed::*; match (a, b) { (Trait(a_pred), Trait(b_pred)) => Ok(Trait(relation.relate(a_pred, b_pred)?)), (Ty(a_ty), Ty(b_ty)) => Ok(Ty(relation.relate(a_ty, b_ty)?)), @@ -800,7 +800,7 @@ impl<'tcx> Relate<'tcx> for traits::FromEnv<'tcx> { ) -> RelateResult<'tcx, traits::FromEnv<'tcx>> where R: TypeRelation<'a, 'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a { - use traits::FromEnv::*; + use crate::traits::FromEnv::*; match (a, b) { (Trait(a_pred), Trait(b_pred)) => Ok(Trait(relation.relate(a_pred, b_pred)?)), (Ty(a_ty), Ty(b_ty)) => Ok(Ty(relation.relate(a_ty, b_ty)?)), @@ -817,7 +817,7 @@ impl<'tcx> Relate<'tcx> for traits::DomainGoal<'tcx> { ) -> RelateResult<'tcx, traits::DomainGoal<'tcx>> where R: TypeRelation<'a, 'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a { - use traits::DomainGoal::*; + use crate::traits::DomainGoal::*; match (a, b) { (Holds(a_wc), Holds(b_wc)) => Ok(Holds(relation.relate(a_wc, b_wc)?)), (WellFormed(a_wf), WellFormed(b_wf)) => Ok(WellFormed(relation.relate(a_wf, b_wf)?)), @@ -840,7 +840,7 @@ impl<'tcx> Relate<'tcx> for traits::Goal<'tcx> { ) -> RelateResult<'tcx, traits::Goal<'tcx>> where R: TypeRelation<'a, 'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a { - use traits::GoalKind::*; + use crate::traits::GoalKind::*; match (a, b) { (Implies(a_clauses, a_goal), Implies(b_clauses, b_goal)) => { let clauses = relation.relate(a_clauses, b_clauses)?; @@ -904,7 +904,7 @@ impl<'tcx> Relate<'tcx> for traits::Clause<'tcx> { ) -> RelateResult<'tcx, traits::Clause<'tcx>> where R: TypeRelation<'a, 'gcx, 'tcx>, 'gcx: 'tcx, 'tcx: 'a { - use traits::Clause::*; + use crate::traits::Clause::*; match (a, b) { (Implies(a_clause), Implies(b_clause)) => { let clause = relation.relate(a_clause, b_clause)?; diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs index 28f5a65374d98..62a49238ebf3d 100644 --- a/src/librustc/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -3,13 +3,13 @@ //! hand, though we've recently added some macros (e.g., //! `BraceStructLiftImpl!`) to help with the tedium. -use mir::ProjectionKind; -use mir::interpret::ConstValue; -use ty::{self, Lift, Ty, TyCtxt}; -use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; +use crate::mir::ProjectionKind; +use crate::mir::interpret::ConstValue; +use crate::ty::{self, Lift, Ty, TyCtxt}; +use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; use smallvec::SmallVec; -use mir::interpret; +use crate::mir::interpret; use std::rc::Rc; @@ -23,35 +23,35 @@ CloneTypeFoldableAndLiftImpls! { (), bool, usize, - ::ty::layout::VariantIdx, + crate::ty::layout::VariantIdx, u64, String, - ::middle::region::Scope, + crate::middle::region::Scope, ::syntax::ast::FloatTy, ::syntax::ast::NodeId, ::syntax_pos::symbol::Symbol, - ::hir::def::Def, - ::hir::def_id::DefId, - ::hir::InlineAsm, - ::hir::MatchSource, - ::hir::Mutability, - ::hir::Unsafety, + crate::hir::def::Def, + crate::hir::def_id::DefId, + crate::hir::InlineAsm, + crate::hir::MatchSource, + crate::hir::Mutability, + crate::hir::Unsafety, ::rustc_target::spec::abi::Abi, - ::mir::Local, - ::mir::Promoted, - ::traits::Reveal, - ::ty::adjustment::AutoBorrowMutability, - ::ty::AdtKind, + crate::mir::Local, + crate::mir::Promoted, + crate::traits::Reveal, + crate::ty::adjustment::AutoBorrowMutability, + crate::ty::AdtKind, // Including `BoundRegion` is a *bit* dubious, but direct // references to bound region appear in `ty::Error`, and aren't // really meant to be folded. In general, we can only fold a fully // general `Region`. - ::ty::BoundRegion, - ::ty::ClosureKind, - ::ty::IntVarValue, - ::ty::ParamTy, - ::ty::UniverseIndex, - ::ty::Variance, + crate::ty::BoundRegion, + crate::ty::ClosureKind, + crate::ty::IntVarValue, + crate::ty::ParamTy, + crate::ty::UniverseIndex, + crate::ty::Variance, ::syntax_pos::Span, } @@ -421,7 +421,7 @@ impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::error::ExpectedFound { impl<'a, 'tcx> Lift<'tcx> for ty::error::TypeError<'a> { type Lifted = ty::error::TypeError<'tcx>; fn lift_to_tcx<'b, 'gcx>(&self, tcx: TyCtxt<'b, 'gcx, 'tcx>) -> Option { - use ty::error::TypeError::*; + use crate::ty::error::TypeError::*; Some(match *self { Mismatch => Mismatch, @@ -651,7 +651,7 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::List> { impl<'tcx> TypeFoldable<'tcx> for ty::instance::Instance<'tcx> { fn super_fold_with<'gcx: 'tcx, F: TypeFolder<'gcx, 'tcx>>(&self, folder: &mut F) -> Self { - use ty::InstanceDef::*; + use crate::ty::InstanceDef::*; Self { substs: self.substs.fold_with(folder), def: match self.def { @@ -682,7 +682,7 @@ impl<'tcx> TypeFoldable<'tcx> for ty::instance::Instance<'tcx> { } fn super_visit_with>(&self, visitor: &mut V) -> bool { - use ty::InstanceDef::*; + use crate::ty::InstanceDef::*; self.substs.visit_with(visitor) || match self.def { Item(did) | VtableShim(did) | Intrinsic(did) | Virtual(did, _) => { diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 671a0fc2d5d7a..d4c18c64c9951 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -1,17 +1,17 @@ //! This module contains `TyKind` and its major components. -use hir; -use hir::def_id::DefId; -use infer::canonical::Canonical; -use mir::interpret::ConstValue; -use middle::region; +use crate::hir; +use crate::hir::def_id::DefId; +use crate::infer::canonical::Canonical; +use crate::mir::interpret::ConstValue; +use crate::middle::region; use polonius_engine::Atom; use rustc_data_structures::indexed_vec::Idx; -use ty::subst::{Substs, Subst, Kind, UnpackedKind}; -use ty::{self, AdtDef, TypeFlags, Ty, TyCtxt, TypeFoldable}; -use ty::{List, TyS, ParamEnvAnd, ParamEnv}; -use util::captures::Captures; -use mir::interpret::{Scalar, Pointer}; +use crate::ty::subst::{Substs, Subst, Kind, UnpackedKind}; +use crate::ty::{self, AdtDef, TypeFlags, Ty, TyCtxt, TypeFoldable}; +use crate::ty::{List, TyS, ParamEnvAnd, ParamEnv}; +use crate::util::captures::Captures; +use crate::mir::interpret::{Scalar, Pointer}; use smallvec::SmallVec; use std::iter; @@ -107,6 +107,7 @@ pub enum TyKind<'tcx> { /// definition and not a concrete use of it. Adt(&'tcx AdtDef, &'tcx Substs<'tcx>), + /// An unsized FFI type that is opaque to Rust. Written as `extern type T`. Foreign(DefId), /// The pointee of a string slice. Written as `str`. @@ -550,7 +551,7 @@ impl<'a, 'gcx, 'tcx> ExistentialPredicate<'tcx> { impl<'a, 'gcx, 'tcx> Binder> { pub fn with_self_ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, self_ty: Ty<'tcx>) -> ty::Predicate<'tcx> { - use ty::ToPredicate; + use crate::ty::ToPredicate; match *self.skip_binder() { ExistentialPredicate::Trait(tr) => Binder(tr).with_self_ty(tcx, self_ty).to_predicate(), ExistentialPredicate::Projection(p) => diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index 64e7af815b4bf..d7c322d0f8402 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -1,9 +1,9 @@ // Type substitutions. -use hir::def_id::DefId; -use infer::canonical::Canonical; -use ty::{self, Lift, List, Ty, TyCtxt}; -use ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; +use crate::hir::def_id::DefId; +use crate::infer::canonical::Canonical; +use crate::ty::{self, Lift, List, Ty, TyCtxt}; +use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; use serialize::{self, Encodable, Encoder, Decodable, Decoder}; use syntax_pos::{Span, DUMMY_SP}; diff --git a/src/librustc/ty/trait_def.rs b/src/librustc/ty/trait_def.rs index 37ec560d6c19f..5429a2504b97b 100644 --- a/src/librustc/ty/trait_def.rs +++ b/src/librustc/ty/trait_def.rs @@ -1,11 +1,11 @@ -use hir; -use hir::def_id::DefId; -use hir::map::DefPathHash; -use ich::{self, StableHashingContext}; -use traits::specialization_graph; -use ty::fast_reject; -use ty::fold::TypeFoldable; -use ty::{Ty, TyCtxt}; +use crate::hir; +use crate::hir::def_id::DefId; +use crate::hir::map::DefPathHash; +use crate::ich::{self, StableHashingContext}; +use crate::traits::specialization_graph; +use crate::ty::fast_reject; +use crate::ty::fold::TypeFoldable; +use crate::ty::{Ty, TyCtxt}; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::stable_hasher::{HashStable, StableHasher, diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index 2fe47b2f032f8..61544932b4329 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -1,18 +1,18 @@ //! misc. type-system utilities too small to deserve their own file -use hir::def::Def; -use hir::def_id::DefId; -use hir::map::DefPathData; -use hir::{self, Node}; -use ich::NodeIdHashingMode; -use traits::{self, ObligationCause}; -use ty::{self, Ty, TyCtxt, GenericParamDefKind, TypeFoldable}; -use ty::subst::{Subst, Substs, UnpackedKind}; -use ty::query::TyCtxtAt; -use ty::TyKind::*; -use ty::layout::{Integer, IntegerExt}; -use util::common::ErrorReported; -use middle::lang_items; +use crate::hir::def::Def; +use crate::hir::def_id::DefId; +use crate::hir::map::DefPathData; +use crate::hir::{self, Node}; +use crate::ich::NodeIdHashingMode; +use crate::traits::{self, ObligationCause}; +use crate::ty::{self, Ty, TyCtxt, GenericParamDefKind, TypeFoldable}; +use crate::ty::subst::{Subst, Substs, UnpackedKind}; +use crate::ty::query::TyCtxtAt; +use crate::ty::TyKind::*; +use crate::ty::layout::{Integer, IntegerExt}; +use crate::util::common::ErrorReported; +use crate::middle::lang_items; use rustc_data_structures::stable_hasher::{StableHasher, HashStable}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; diff --git a/src/librustc/ty/walk.rs b/src/librustc/ty/walk.rs index 6887d092fcd62..126f5290af513 100644 --- a/src/librustc/ty/walk.rs +++ b/src/librustc/ty/walk.rs @@ -1,7 +1,7 @@ //! An iterator over the type substructure. //! WARNING: this does not keep track of the region depth. -use ty::{self, Ty}; +use crate::ty::{self, Ty}; use smallvec::{self, SmallVec}; // The TypeWalker's stack is hot enough that it's worth going to some effort to diff --git a/src/librustc/ty/wf.rs b/src/librustc/ty/wf.rs index ef68394029680..2aae953c1c40a 100644 --- a/src/librustc/ty/wf.rs +++ b/src/librustc/ty/wf.rs @@ -1,12 +1,12 @@ -use hir::def_id::DefId; -use infer::InferCtxt; -use ty::subst::Substs; -use traits; -use ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable}; +use crate::hir::def_id::DefId; +use crate::infer::InferCtxt; +use crate::ty::subst::Substs; +use crate::traits; +use crate::ty::{self, ToPredicate, Ty, TyCtxt, TypeFoldable}; use std::iter::once; use syntax::ast; use syntax_pos::Span; -use middle::lang_items; +use crate::middle::lang_items; /// Returns the set of obligations needed to make `ty` well-formed. /// If `ty` contains unresolved inference variables, this may include diff --git a/src/librustc/util/bug.rs b/src/librustc/util/bug.rs index 7698f5ece98cc..02ddfab6d826e 100644 --- a/src/librustc/util/bug.rs +++ b/src/librustc/util/bug.rs @@ -1,6 +1,6 @@ // These functions are used by macro expansion for bug! and span_bug! -use ty::tls; +use crate::ty::tls; use std::fmt; use syntax_pos::{Span, MultiSpan}; diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index cc0ca165053d3..f6743ed75d92e 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -12,10 +12,10 @@ use std::time::{Duration, Instant}; use std::sync::mpsc::{Sender}; use syntax_pos::{SpanData}; -use ty::TyCtxt; -use dep_graph::{DepNode}; +use crate::ty::TyCtxt; +use crate::dep_graph::{DepNode}; use lazy_static; -use session::Session; +use crate::session::Session; // The name of the associated type for `Fn` return types pub const FN_OUTPUT_NAME: &str = "Output"; diff --git a/src/librustc/util/nodemap.rs b/src/librustc/util/nodemap.rs index fe6ab075a1a8a..6969b2f872ade 100644 --- a/src/librustc/util/nodemap.rs +++ b/src/librustc/util/nodemap.rs @@ -1,7 +1,7 @@ //! An efficient hash map for node IDs -use hir::def_id::DefId; -use hir::{HirId, ItemLocalId}; +use crate::hir::def_id::DefId; +use crate::hir::{HirId, ItemLocalId}; use syntax::ast; pub use rustc_data_structures::fx::FxHashMap; diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 51e9192cd290d..2cd82d44af3aa 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -1,15 +1,15 @@ -use hir::def_id::DefId; -use hir::map::definitions::DefPathData; -use middle::region; -use ty::subst::{self, Subst}; -use ty::{BrAnon, BrEnv, BrFresh, BrNamed}; -use ty::{Bool, Char, Adt}; -use ty::{Error, Str, Array, Slice, Float, FnDef, FnPtr}; -use ty::{Param, Bound, RawPtr, Ref, Never, Tuple}; -use ty::{Closure, Generator, GeneratorWitness, Foreign, Projection, Opaque}; -use ty::{Placeholder, UnnormalizedProjection, Dynamic, Int, Uint, Infer}; -use ty::{self, Ty, TyCtxt, TypeFoldable, GenericParamCount, GenericParamDefKind}; -use util::nodemap::FxHashSet; +use crate::hir::def_id::DefId; +use crate::hir::map::definitions::DefPathData; +use crate::middle::region; +use crate::ty::subst::{self, Subst}; +use crate::ty::{BrAnon, BrEnv, BrFresh, BrNamed}; +use crate::ty::{Bool, Char, Adt}; +use crate::ty::{Error, Str, Array, Slice, Float, FnDef, FnPtr}; +use crate::ty::{Param, Bound, RawPtr, Ref, Never, Tuple}; +use crate::ty::{Closure, Generator, GeneratorWitness, Foreign, Projection, Opaque}; +use crate::ty::{Placeholder, UnnormalizedProjection, Dynamic, Int, Uint, Infer}; +use crate::ty::{self, Ty, TyCtxt, TypeFoldable, GenericParamCount, GenericParamDefKind}; +use crate::util::nodemap::FxHashSet; use std::cell::Cell; use std::fmt; @@ -18,7 +18,7 @@ use std::usize; use rustc_target::spec::abi::Abi; use syntax::ast::CRATE_NODE_ID; use syntax::symbol::{Symbol, InternedString}; -use hir; +use crate::hir; /// The "region highlights" are used to control region printing during /// specific error messages. When a "region highlight" is enabled, it diff --git a/src/librustc/util/profiling.rs b/src/librustc/util/profiling.rs index d31a06d6cb82d..0e03946f82a5c 100644 --- a/src/librustc/util/profiling.rs +++ b/src/librustc/util/profiling.rs @@ -1,4 +1,4 @@ -use session::config::Options; +use crate::session::config::Options; use std::fs; use std::io::{self, StderrLock, Write}; diff --git a/src/librustc_apfloat/Cargo.toml b/src/librustc_apfloat/Cargo.toml index 248f2d71f41e5..c7496a9547ea6 100644 --- a/src/librustc_apfloat/Cargo.toml +++ b/src/librustc_apfloat/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc_apfloat" version = "0.0.0" +edition = "2018" [lib] name = "rustc_apfloat" diff --git a/src/librustc_apfloat/ieee.rs b/src/librustc_apfloat/ieee.rs index 7ad34bec899f4..58066a9cada47 100644 --- a/src/librustc_apfloat/ieee.rs +++ b/src/librustc_apfloat/ieee.rs @@ -1,5 +1,5 @@ -use {Category, ExpInt, IEK_INF, IEK_NAN, IEK_ZERO}; -use {Float, FloatConvert, ParseError, Round, Status, StatusAnd}; +use crate::{Category, ExpInt, IEK_INF, IEK_NAN, IEK_ZERO}; +use crate::{Float, FloatConvert, ParseError, Round, Status, StatusAnd}; use smallvec::{SmallVec, smallvec}; use std::cmp::{self, Ordering}; @@ -325,7 +325,7 @@ impl Neg for IeeeFloat { /// 1.01E-2 4 2 0.0101 /// 1.01E-2 4 1 1.01E-2 impl fmt::Display for IeeeFloat { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let width = f.width().unwrap_or(3); let alternate = f.alternate(); @@ -614,7 +614,7 @@ impl fmt::Display for IeeeFloat { } impl fmt::Debug for IeeeFloat { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}({:?} | {}{:?} * 2^{})", self, self.category, if self.sign { "-" } else { "+" }, diff --git a/src/librustc_apfloat/lib.rs b/src/librustc_apfloat/lib.rs index 6d2c54ca9ffe9..17311f0688fe6 100644 --- a/src/librustc_apfloat/lib.rs +++ b/src/librustc_apfloat/lib.rs @@ -34,24 +34,20 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] #![forbid(unsafe_code)] +#![deny(rust_2018_idioms)] -#![feature(nll)] #![feature(try_from)] // See librustc_cratesio_shim/Cargo.toml for a comment explaining this. #[allow(unused_extern_crates)] extern crate rustc_cratesio_shim; -#[macro_use] -extern crate bitflags; -extern crate smallvec; - use std::cmp::Ordering; use std::fmt; use std::ops::{Neg, Add, Sub, Mul, Div, Rem}; use std::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign}; use std::str::FromStr; -bitflags! { +bitflags::bitflags! { /// IEEE-754R 7: Default exception handling. /// /// UNDERFLOW or OVERFLOW are always returned or-ed with INEXACT. diff --git a/src/librustc_apfloat/ppc.rs b/src/librustc_apfloat/ppc.rs index 839e88cf34039..ddccfd6ca623b 100644 --- a/src/librustc_apfloat/ppc.rs +++ b/src/librustc_apfloat/ppc.rs @@ -1,5 +1,5 @@ -use {Category, ExpInt, Float, FloatConvert, Round, ParseError, Status, StatusAnd}; -use ieee; +use crate::{Category, ExpInt, Float, FloatConvert, Round, ParseError, Status, StatusAnd}; +use crate::ieee; use std::cmp::Ordering; use std::fmt; @@ -124,7 +124,7 @@ impl Neg for DoubleFloat { } impl>> fmt::Display for DoubleFloat { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&Fallback::from(*self), f) } } diff --git a/src/librustc_apfloat/tests/ieee.rs b/src/librustc_apfloat/tests/ieee.rs index 96249020c1a6f..108b2114439d4 100644 --- a/src/librustc_apfloat/tests/ieee.rs +++ b/src/librustc_apfloat/tests/ieee.rs @@ -1,9 +1,7 @@ -#[macro_use] -extern crate rustc_apfloat; - use rustc_apfloat::{Category, ExpInt, IEK_INF, IEK_NAN, IEK_ZERO}; use rustc_apfloat::{Float, FloatConvert, ParseError, Round, Status}; use rustc_apfloat::ieee::{Half, Single, Double, Quad, X87DoubleExtended}; +use rustc_apfloat::unpack; trait SingleExt { fn from_f32(input: f32) -> Self; diff --git a/src/librustc_apfloat/tests/ppc.rs b/src/librustc_apfloat/tests/ppc.rs index cfb453bd0617a..02cdeb90a12be 100644 --- a/src/librustc_apfloat/tests/ppc.rs +++ b/src/librustc_apfloat/tests/ppc.rs @@ -1,5 +1,3 @@ -extern crate rustc_apfloat; - use rustc_apfloat::{Category, Float, Round}; use rustc_apfloat::ppc::DoubleDouble; diff --git a/src/librustc_asan/Cargo.toml b/src/librustc_asan/Cargo.toml index 836caf22abfa5..7d9641c83ee7d 100644 --- a/src/librustc_asan/Cargo.toml +++ b/src/librustc_asan/Cargo.toml @@ -3,6 +3,7 @@ authors = ["The Rust Project Developers"] build = "build.rs" name = "rustc_asan" version = "0.0.0" +edition = "2018" [lib] name = "rustc_asan" diff --git a/src/librustc_asan/build.rs b/src/librustc_asan/build.rs index b42d775deb393..a2b4b090efb4f 100644 --- a/src/librustc_asan/build.rs +++ b/src/librustc_asan/build.rs @@ -1,6 +1,3 @@ -extern crate build_helper; -extern crate cmake; - use std::env; use build_helper::sanitizer_lib_boilerplate; diff --git a/src/librustc_asan/lib.rs b/src/librustc_asan/lib.rs index d6c8e54c18db7..568bb540c4719 100644 --- a/src/librustc_asan/lib.rs +++ b/src/librustc_asan/lib.rs @@ -1,8 +1,9 @@ #![sanitizer_runtime] -#![feature(nll)] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] #![unstable(feature = "sanitizer_runtime_lib", reason = "internal implementation detail of sanitizers", issue = "0")] + +#![deny(rust_2018_idioms)] diff --git a/src/librustc_codegen_ssa/mir/place.rs b/src/librustc_codegen_ssa/mir/place.rs index b10611e5ac797..596f97a038892 100644 --- a/src/librustc_codegen_ssa/mir/place.rs +++ b/src/librustc_codegen_ssa/mir/place.rs @@ -41,6 +41,21 @@ impl<'a, 'tcx: 'a, V: CodegenObject> PlaceRef<'tcx, V> { } } + fn new_thin_place>( + bx: &mut Bx, + llval: V, + layout: TyLayout<'tcx>, + align: Align, + ) -> PlaceRef<'tcx, V> { + assert!(!bx.cx().type_has_metadata(layout.ty)); + PlaceRef { + llval, + llextra: None, + layout, + align + } + } + pub fn alloca>( bx: &mut Bx, layout: TyLayout<'tcx>, @@ -421,8 +436,10 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } } mir::Place::Static(box mir::Static { def_id, ty }) => { + // NB: The layout of a static may be unsized as is the case when working + // with a static that is an extern_type. let layout = cx.layout_of(self.monomorphize(&ty)); - PlaceRef::new_sized(bx.get_static(def_id), layout, layout.align.abi) + PlaceRef::new_thin_place(bx, bx.get_static(def_id), layout, layout.align.abi) }, mir::Place::Projection(box mir::Projection { ref base, diff --git a/src/librustc_errors/Cargo.toml b/src/librustc_errors/Cargo.toml index b24f8ddf4d9f7..02c011857bd2a 100644 --- a/src/librustc_errors/Cargo.toml +++ b/src/librustc_errors/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc_errors" version = "0.0.0" +edition = "2018" [lib] name = "rustc_errors" diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index 06a1761a1e76f..aefe296ad0fa7 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -1,11 +1,11 @@ -use CodeSuggestion; -use SubstitutionPart; -use Substitution; -use Applicability; -use Level; +use crate::CodeSuggestion; +use crate::SubstitutionPart; +use crate::Substitution; +use crate::Applicability; +use crate::Level; +use crate::snippet::Style; use std::fmt; use syntax_pos::{MultiSpan, Span}; -use snippet::Style; #[must_use] #[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)] diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index f423a4cd1a7bf..fd4ea7f2d823f 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -1,14 +1,15 @@ -use Diagnostic; -use DiagnosticId; -use DiagnosticStyledString; -use Applicability; +use crate::Diagnostic; +use crate::DiagnosticId; +use crate::DiagnosticStyledString; +use crate::Applicability; -use Level; -use Handler; +use crate::Level; +use crate::Handler; use std::fmt::{self, Debug}; use std::ops::{Deref, DerefMut}; use std::thread::panicking; use syntax_pos::{MultiSpan, Span}; +use log::debug; /// Used for emitting structured error messages and other diagnostic information. /// @@ -111,8 +112,8 @@ impl<'a> DiagnosticBuilder<'a> { // implements `Drop`. let diagnostic; unsafe { - diagnostic = ::std::ptr::read(&self.diagnostic); - ::std::mem::forget(self); + diagnostic = std::ptr::read(&self.diagnostic); + std::mem::forget(self); }; // Logging here is useful to help track down where in logs an error was // actually emitted. @@ -298,7 +299,7 @@ impl<'a> DiagnosticBuilder<'a> { } impl<'a> Debug for DiagnosticBuilder<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.diagnostic.fmt(f) } } diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 25d09a33c154f..061d23697fa3a 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -1,28 +1,26 @@ -use self::Destination::*; +use Destination::*; use syntax_pos::{SourceFile, Span, MultiSpan}; -use {Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, SourceMapperDyn, DiagnosticId}; -use snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style}; -use styled_buffer::StyledBuffer; +use crate::{Level, CodeSuggestion, DiagnosticBuilder, SubDiagnostic, SourceMapperDyn, DiagnosticId}; +use crate::snippet::{Annotation, AnnotationType, Line, MultilineAnnotation, StyledString, Style}; +use crate::styled_buffer::StyledBuffer; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sync::Lrc; -use atty; use std::borrow::Cow; use std::io::prelude::*; use std::io; use std::cmp::{min, Reverse}; use termcolor::{StandardStream, ColorChoice, ColorSpec, BufferWriter}; use termcolor::{WriteColor, Color, Buffer}; -use unicode_width; const ANONYMIZED_LINE_NUM: &str = "LL"; /// Emitter trait for emitting errors. pub trait Emitter { /// Emit a structured diagnostic. - fn emit(&mut self, db: &DiagnosticBuilder); + fn emit(&mut self, db: &DiagnosticBuilder<'_>); /// Check if should show explanations about "rustc --explain" fn should_show_explain(&self) -> bool { @@ -31,7 +29,7 @@ pub trait Emitter { } impl Emitter for EmitterWriter { - fn emit(&mut self, db: &DiagnosticBuilder) { + fn emit(&mut self, db: &DiagnosticBuilder<'_>) { let mut primary_span = db.span.clone(); let mut children = db.children.clone(); let mut suggestions: &[_] = &[]; @@ -1431,7 +1429,7 @@ fn emit_to_destination(rendered_buffer: &[Vec], dst: &mut Destination, short_message: bool) -> io::Result<()> { - use lock; + use crate::lock; let mut dst = dst.writable(); diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 64d5ca0c2a742..831415ed0bb8c 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -6,23 +6,15 @@ #![allow(unused_attributes)] #![feature(range_contains)] #![cfg_attr(unix, feature(libc))] -#![feature(nll)] #![feature(optin_builtin_traits)] +#![deny(rust_2018_idioms)] -extern crate atty; -extern crate termcolor; -#[cfg(unix)] -extern crate libc; -#[macro_use] -extern crate log; -extern crate rustc_data_structures; -extern crate serialize as rustc_serialize; -extern crate syntax_pos; -extern crate unicode_width; +#[allow(unused_extern_crates)] +extern crate serialize as rustc_serialize; // used by deriving pub use emitter::ColorConfig; -use self::Level::*; +use Level::*; use emitter::{Emitter, EmitterWriter}; @@ -144,7 +136,7 @@ impl CodeSuggestion { use syntax_pos::{CharPos, Loc, Pos}; fn push_trailing(buf: &mut String, - line_opt: Option<&Cow>, + line_opt: Option<&Cow<'_, str>>, lo: &Loc, hi_opt: Option<&Loc>) { let (lo, hi_opt) = (lo.col.to_usize(), hi_opt.map(|hi| hi.col.to_usize())); @@ -247,7 +239,7 @@ impl FatalError { } impl fmt::Display for FatalError { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "parser fatal error") } } @@ -264,7 +256,7 @@ impl error::Error for FatalError { pub struct ExplicitBug; impl fmt::Display for ExplicitBug { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "parser internal bug") } } @@ -496,7 +488,7 @@ impl Handler { DiagnosticBuilder::new(self, Level::Fatal, msg) } - pub fn cancel(&self, err: &mut DiagnosticBuilder) { + pub fn cancel(&self, err: &mut DiagnosticBuilder<'_>) { err.cancel(); } @@ -698,12 +690,12 @@ impl Handler { self.taught_diagnostics.borrow_mut().insert(code.clone()) } - pub fn force_print_db(&self, mut db: DiagnosticBuilder) { + pub fn force_print_db(&self, mut db: DiagnosticBuilder<'_>) { self.emitter.borrow_mut().emit(&db); db.cancel(); } - fn emit_db(&self, db: &DiagnosticBuilder) { + fn emit_db(&self, db: &DiagnosticBuilder<'_>) { let diagnostic = &**db; TRACK_DIAGNOSTICS.with(|track_diagnostics| { @@ -749,7 +741,7 @@ pub enum Level { } impl fmt::Display for Level { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.to_str().fmt(f) } } diff --git a/src/librustc_errors/snippet.rs b/src/librustc_errors/snippet.rs index da1da77f398a9..0c62ff0ff89b2 100644 --- a/src/librustc_errors/snippet.rs +++ b/src/librustc_errors/snippet.rs @@ -1,6 +1,6 @@ // Code for annotating snippets. -use Level; +use crate::Level; #[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)] pub struct Line { diff --git a/src/librustc_errors/styled_buffer.rs b/src/librustc_errors/styled_buffer.rs index 880f09e75e32e..6e03618d2b0b5 100644 --- a/src/librustc_errors/styled_buffer.rs +++ b/src/librustc_errors/styled_buffer.rs @@ -1,6 +1,6 @@ // Code for creating styled buffers -use snippet::{Style, StyledString}; +use crate::snippet::{Style, StyledString}; #[derive(Debug)] pub struct StyledBuffer { diff --git a/src/librustc_fs_util/Cargo.toml b/src/librustc_fs_util/Cargo.toml index e40b44204b349..47918643f31fe 100644 --- a/src/librustc_fs_util/Cargo.toml +++ b/src/librustc_fs_util/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc_fs_util" version = "0.0.0" +edition = "2018" [lib] name = "rustc_fs_util" diff --git a/src/librustc_fs_util/lib.rs b/src/librustc_fs_util/lib.rs index 74ff121f80385..340681d65c383 100644 --- a/src/librustc_fs_util/lib.rs +++ b/src/librustc_fs_util/lib.rs @@ -1,3 +1,5 @@ +#![deny(rust_2018_idioms)] + use std::path::{Path, PathBuf}; use std::ffi::CString; use std::fs; diff --git a/src/librustc_llvm/Cargo.toml b/src/librustc_llvm/Cargo.toml index 013badb71cc5a..0fe327d5deeeb 100644 --- a/src/librustc_llvm/Cargo.toml +++ b/src/librustc_llvm/Cargo.toml @@ -3,6 +3,7 @@ authors = ["The Rust Project Developers"] name = "rustc_llvm" version = "0.0.0" build = "build.rs" +edition = "2018" [lib] name = "rustc_llvm" diff --git a/src/librustc_llvm/build.rs b/src/librustc_llvm/build.rs index cd91fcb2995ee..7fa83dd977950 100644 --- a/src/librustc_llvm/build.rs +++ b/src/librustc_llvm/build.rs @@ -1,6 +1,3 @@ -extern crate cc; -extern crate build_helper; - use std::process::Command; use std::env; use std::path::{PathBuf, Path}; diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index ca66540fa25f7..99c5e2493edec 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -1,4 +1,4 @@ -#![feature(nll)] +#![deny(rust_2018_idioms)] #![feature(static_nobundle)] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/librustc_lsan/Cargo.toml b/src/librustc_lsan/Cargo.toml index a8e11df7670cf..9ad53ee6d0958 100644 --- a/src/librustc_lsan/Cargo.toml +++ b/src/librustc_lsan/Cargo.toml @@ -3,6 +3,7 @@ authors = ["The Rust Project Developers"] build = "build.rs" name = "rustc_lsan" version = "0.0.0" +edition = "2018" [lib] name = "rustc_lsan" diff --git a/src/librustc_lsan/build.rs b/src/librustc_lsan/build.rs index ad528bb03902c..b8c7b7c2d5537 100644 --- a/src/librustc_lsan/build.rs +++ b/src/librustc_lsan/build.rs @@ -1,6 +1,3 @@ -extern crate build_helper; -extern crate cmake; - use std::env; use build_helper::sanitizer_lib_boilerplate; diff --git a/src/librustc_lsan/lib.rs b/src/librustc_lsan/lib.rs index d6c8e54c18db7..568bb540c4719 100644 --- a/src/librustc_lsan/lib.rs +++ b/src/librustc_lsan/lib.rs @@ -1,8 +1,9 @@ #![sanitizer_runtime] -#![feature(nll)] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] #![unstable(feature = "sanitizer_runtime_lib", reason = "internal implementation detail of sanitizers", issue = "0")] + +#![deny(rust_2018_idioms)] diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs index ec68ddaf3c852..550668a7ceece 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/mod.rs @@ -205,7 +205,7 @@ impl<'tcx> RegionInferenceContext<'tcx> { for constraint in self.constraint_graph .outgoing_edges(r, &self.constraints, fr_static) { - assert_eq!(constraint.sup, r); + debug_assert_eq!(constraint.sup, r); let sub_region = constraint.sub; if let Trace::NotVisited = context[sub_region] { context[sub_region] = Trace::FromOutlivesConstraint(constraint); diff --git a/src/librustc_msan/Cargo.toml b/src/librustc_msan/Cargo.toml index 78c39d03e45a9..7d88aa59b3adb 100644 --- a/src/librustc_msan/Cargo.toml +++ b/src/librustc_msan/Cargo.toml @@ -3,6 +3,7 @@ authors = ["The Rust Project Developers"] build = "build.rs" name = "rustc_msan" version = "0.0.0" +edition = "2018" [lib] name = "rustc_msan" diff --git a/src/librustc_msan/build.rs b/src/librustc_msan/build.rs index 085514b5a0108..1c66b0a9cd3cf 100644 --- a/src/librustc_msan/build.rs +++ b/src/librustc_msan/build.rs @@ -1,6 +1,3 @@ -extern crate build_helper; -extern crate cmake; - use std::env; use build_helper::sanitizer_lib_boilerplate; diff --git a/src/librustc_msan/lib.rs b/src/librustc_msan/lib.rs index d6c8e54c18db7..568bb540c4719 100644 --- a/src/librustc_msan/lib.rs +++ b/src/librustc_msan/lib.rs @@ -1,8 +1,9 @@ #![sanitizer_runtime] -#![feature(nll)] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] #![unstable(feature = "sanitizer_runtime_lib", reason = "internal implementation detail of sanitizers", issue = "0")] + +#![deny(rust_2018_idioms)] diff --git a/src/librustc_plugin/Cargo.toml b/src/librustc_plugin/Cargo.toml index d8fa1da1ce219..5e23aa0d7f74e 100644 --- a/src/librustc_plugin/Cargo.toml +++ b/src/librustc_plugin/Cargo.toml @@ -3,6 +3,7 @@ authors = ["The Rust Project Developers"] name = "rustc_plugin" version = "0.0.0" build = false +edition = "2018" [lib] name = "rustc_plugin" diff --git a/src/librustc_plugin/diagnostics.rs b/src/librustc_plugin/diagnostics.rs index 382a1edb43c4a..68462bd83ef60 100644 --- a/src/librustc_plugin/diagnostics.rs +++ b/src/librustc_plugin/diagnostics.rs @@ -1,5 +1,7 @@ #![allow(non_snake_case)] +use syntax::{register_diagnostic, register_diagnostics, register_long_diagnostics}; + register_long_diagnostics! { } diff --git a/src/librustc_plugin/lib.rs b/src/librustc_plugin/lib.rs index 7bdeae3e97854..9a31bddc1eded 100644 --- a/src/librustc_plugin/lib.rs +++ b/src/librustc_plugin/lib.rs @@ -54,19 +54,13 @@ html_favicon_url = "https://doc.rust-lang.org/favicon.ico", html_root_url = "https://doc.rust-lang.org/nightly/")] -#![feature(nll)] #![feature(rustc_diagnostic_macros)] #![recursion_limit="256"] -#[macro_use] extern crate syntax; +#![deny(rust_2018_idioms)] -extern crate rustc; -extern crate rustc_metadata; -extern crate syntax_pos; -extern crate rustc_errors as errors; - -pub use self::registry::Registry; +pub use registry::Registry; mod diagnostics; pub mod registry; diff --git a/src/librustc_plugin/load.rs b/src/librustc_plugin/load.rs index 39f580420cf03..1b88cf05f40d5 100644 --- a/src/librustc_plugin/load.rs +++ b/src/librustc_plugin/load.rs @@ -3,18 +3,19 @@ use rustc::session::Session; use rustc_metadata::creader::CrateLoader; use rustc_metadata::cstore::CStore; -use registry::Registry; +use crate::registry::Registry; use std::borrow::ToOwned; use std::env; use std::mem; use std::path::PathBuf; use syntax::ast; +use syntax::span_err; use syntax_pos::{Span, DUMMY_SP}; /// Pointer to a registrar function. pub type PluginRegistrarFun = - fn(&mut Registry); + fn(&mut Registry<'_>); pub struct PluginRegistrar { pub fun: PluginRegistrarFun, diff --git a/src/librustc_resolve/Cargo.toml b/src/librustc_resolve/Cargo.toml index 3a8e84a3280c6..0ce82f2ce521b 100644 --- a/src/librustc_resolve/Cargo.toml +++ b/src/librustc_resolve/Cargo.toml @@ -2,6 +2,7 @@ authors = ["The Rust Project Developers"] name = "rustc_resolve" version = "0.0.0" +edition = "2018" [lib] name = "rustc_resolve" diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index c5401ac3f5560..750eb35a98854 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -3,14 +3,15 @@ //! Here we build the "reduced graph": the graph of the module tree without //! any imports resolved. -use macros::{InvocationData, ParentScope, LegacyScope}; -use resolve_imports::ImportDirective; -use resolve_imports::ImportDirectiveSubclass::{self, GlobImport, SingleImport}; -use {Module, ModuleData, ModuleKind, NameBinding, NameBindingKind, Segment, ToNameBinding}; -use {ModuleOrUniformRoot, PerNS, Resolver, ResolverArenas, ExternPreludeEntry}; -use Namespace::{self, TypeNS, ValueNS, MacroNS}; -use {resolve_error, resolve_struct_error, ResolutionError}; - +use crate::macros::{InvocationData, ParentScope, LegacyScope}; +use crate::resolve_imports::ImportDirective; +use crate::resolve_imports::ImportDirectiveSubclass::{self, GlobImport, SingleImport}; +use crate::{Module, ModuleData, ModuleKind, NameBinding, NameBindingKind, Segment, ToNameBinding}; +use crate::{ModuleOrUniformRoot, PerNS, Resolver, ResolverArenas, ExternPreludeEntry}; +use crate::Namespace::{self, TypeNS, ValueNS, MacroNS}; +use crate::{resolve_error, resolve_struct_error, ResolutionError}; + +use rustc::bug; use rustc::hir::def::*; use rustc::hir::def_id::{CrateNum, CRATE_DEF_INDEX, LOCAL_CRATE, DefId}; use rustc::ty; @@ -21,7 +22,7 @@ use std::cell::Cell; use std::ptr; use rustc_data_structures::sync::Lrc; -use errors::Applicability; +use crate::errors::Applicability; use syntax::ast::{Name, Ident}; use syntax::attr; @@ -34,12 +35,15 @@ use syntax::ext::hygiene::Mark; use syntax::ext::tt::macro_rules; use syntax::feature_gate::is_builtin_attr; use syntax::parse::token::{self, Token}; +use syntax::span_err; use syntax::std_inject::injected_crate_name; use syntax::symbol::keywords; use syntax::visit::{self, Visitor}; use syntax_pos::{Span, DUMMY_SP}; +use log::debug; + impl<'a> ToNameBinding<'a> for (Module<'a>, ty::Visibility, Span, Mark) { fn to_name_binding(self, arenas: &'a ResolverArenas<'a>) -> &'a NameBinding<'a> { arenas.alloc_name_binding(NameBinding { diff --git a/src/librustc_resolve/check_unused.rs b/src/librustc_resolve/check_unused.rs index 16d8a95c003f7..639960827c996 100644 --- a/src/librustc_resolve/check_unused.rs +++ b/src/librustc_resolve/check_unused.rs @@ -10,8 +10,8 @@ use std::ops::{Deref, DerefMut}; -use Resolver; -use resolve_imports::ImportDirectiveSubclass; +use crate::Resolver; +use crate::resolve_imports::ImportDirectiveSubclass; use rustc::{lint, ty}; use rustc::util::nodemap::NodeMap; @@ -113,7 +113,7 @@ impl<'a, 'b> Visitor<'a> for UnusedImportCheckVisitor<'a, 'b> { } } -pub fn check_crate(resolver: &mut Resolver, krate: &ast::Crate) { +pub fn check_crate(resolver: &mut Resolver<'_>, krate: &ast::Crate) { for directive in resolver.potentially_unused_imports.iter() { match directive.subclass { _ if directive.used.get() || diff --git a/src/librustc_resolve/diagnostics.rs b/src/librustc_resolve/diagnostics.rs index 3f9c5f4fd273c..0db8689c0c17c 100644 --- a/src/librustc_resolve/diagnostics.rs +++ b/src/librustc_resolve/diagnostics.rs @@ -1,5 +1,7 @@ #![allow(non_snake_case)] +use syntax::{register_diagnostic, register_diagnostics, register_long_diagnostics}; + // Error messages for EXXXX errors. Each message should start and end with a // new line, and be wrapped to 80 characters. In vim you can `:set tw=80` and // use `gq` to wrap paragraphs. Use `:set tw=0` to disable. diff --git a/src/librustc_resolve/error_reporting.rs b/src/librustc_resolve/error_reporting.rs index 2a8e95536b8c7..b131a6b62f9bf 100644 --- a/src/librustc_resolve/error_reporting.rs +++ b/src/librustc_resolve/error_reporting.rs @@ -1,10 +1,12 @@ -use {CrateLint, PathResult, Segment}; -use macros::ParentScope; +use crate::{CrateLint, PathResult, Segment}; +use crate::macros::ParentScope; +use crate::resolve_imports::ImportResolver; use syntax::symbol::keywords; use syntax_pos::Span; -use resolve_imports::ImportResolver; +use log::debug; + use std::cmp::Reverse; impl<'a, 'b:'a> ImportResolver<'a, 'b> { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 3973bc2ad62de..b166b1be02f45 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -4,30 +4,19 @@ #![feature(crate_visibility_modifier)] #![feature(label_break_value)] -#![feature(nll)] #![feature(rustc_diagnostic_macros)] #![feature(slice_sort_by_cached_key)] #![recursion_limit="256"] -#[macro_use] -extern crate bitflags; -#[macro_use] -extern crate log; -#[macro_use] -extern crate syntax; -extern crate syntax_pos; -extern crate rustc_errors as errors; -extern crate arena; -#[macro_use] -extern crate rustc; -extern crate rustc_data_structures; -extern crate rustc_metadata; +#![deny(rust_2018_idioms)] + +use rustc_errors as errors; pub use rustc::hir::def::{Namespace, PerNS}; -use self::TypeParameters::*; -use self::RibKind::*; +use TypeParameters::*; +use RibKind::*; use rustc::hir::map::{Definitions, DefCollector}; use rustc::hir::{self, PrimTy, Bool, Char, Float, Int, Uint, Str}; @@ -41,6 +30,7 @@ use rustc::hir::{Freevar, FreevarMap, TraitCandidate, TraitMap, GlobMap}; use rustc::session::config::nightly_options; use rustc::ty; use rustc::util::nodemap::{NodeMap, NodeSet, FxHashMap, FxHashSet, DefIdMap}; +use rustc::{bug, span_bug}; use rustc_metadata::creader::CrateLoader; use rustc_metadata::cstore::CStore; @@ -62,10 +52,13 @@ use syntax::ast::{Item, ItemKind, ImplItem, ImplItemKind}; use syntax::ast::{Label, Local, Mutability, Pat, PatKind, Path}; use syntax::ast::{QSelf, TraitItemKind, TraitRef, Ty, TyKind}; use syntax::ptr::P; +use syntax::{span_err, struct_span_err, unwrap_or, walk_list}; use syntax_pos::{BytePos, Span, DUMMY_SP, MultiSpan}; use errors::{Applicability, DiagnosticBuilder, DiagnosticId}; +use log::debug; + use std::cell::{Cell, RefCell}; use std::{cmp, fmt, iter, mem, ptr}; use std::collections::BTreeSet; @@ -191,13 +184,13 @@ enum ResolutionError<'a> { /// /// This takes the error provided, combines it with the span and any additional spans inside the /// error and emits it. -fn resolve_error<'sess, 'a>(resolver: &'sess Resolver, +fn resolve_error<'sess, 'a>(resolver: &'sess Resolver<'_>, span: Span, resolution_error: ResolutionError<'a>) { resolve_struct_error(resolver, span, resolution_error).emit(); } -fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver, +fn resolve_struct_error<'sess, 'a>(resolver: &'sess Resolver<'_>, span: Span, resolution_error: ResolutionError<'a>) -> DiagnosticBuilder<'sess> { @@ -1192,7 +1185,7 @@ impl<'a> ModuleData<'a> { } impl<'a> fmt::Debug for ModuleData<'a> { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{:?}", self.def()) } } @@ -1416,7 +1409,7 @@ impl<'a> NameBinding<'a> { // in some later round and screw up our previously found resolution. // See more detailed explanation in // https://github.com/rust-lang/rust/pull/53778#issuecomment-419224049 - fn may_appear_after(&self, invoc_parent_expansion: Mark, binding: &NameBinding) -> bool { + fn may_appear_after(&self, invoc_parent_expansion: Mark, binding: &NameBinding<'_>) -> bool { // self > max(invoc, binding) => !(self <= invoc || self <= binding) // Expansions are partially ordered, so "may appear after" is an inversion of // "certainly appears before or simultaneously" and includes unordered cases. @@ -1630,14 +1623,14 @@ impl<'a> ResolverArenas<'a> { } module } - fn local_modules(&'a self) -> ::std::cell::Ref<'a, Vec>> { + fn local_modules(&'a self) -> std::cell::Ref<'a, Vec>> { self.local_modules.borrow() } fn alloc_name_binding(&'a self, name_binding: NameBinding<'a>) -> &'a NameBinding<'a> { self.name_bindings.alloc(name_binding) } fn alloc_import_directive(&'a self, import_directive: ImportDirective<'a>) - -> &'a ImportDirective { + -> &'a ImportDirective<'_> { self.import_directives.alloc(import_directive) } fn alloc_name_resolution(&'a self) -> &'a RefCell> { @@ -1754,7 +1747,7 @@ impl<'a> Resolver<'a> { is_value: bool, error_callback: F, ) -> hir::Path - where F: for<'c, 'b> FnOnce(&'c mut Resolver, Span, ResolutionError<'b>) + where F: for<'c, 'b> FnOnce(&'c mut Resolver<'_>, Span, ResolutionError<'b>) { let namespace = if is_value { ValueNS } else { TypeNS }; let span = path.span; @@ -1819,7 +1812,7 @@ impl<'a> Resolver<'a> { DefCollector::new(&mut definitions, Mark::root()) .collect_root(crate_name, session.local_crate_disambiguator()); - let mut extern_prelude: FxHashMap = + let mut extern_prelude: FxHashMap> = session.opts.externs.iter().map(|kv| (Ident::from_str(kv.0), Default::default())) .collect(); @@ -2315,7 +2308,7 @@ impl<'a> Resolver<'a> { // implementations thus found, for compatibility with old resolve pass. pub fn with_scope(&mut self, id: NodeId, f: F) -> T - where F: FnOnce(&mut Resolver) -> T + where F: FnOnce(&mut Resolver<'_>) -> T { let id = self.definitions.local_def_id(id); let module = self.module_map.get(&id).cloned(); // clones a reference @@ -2342,7 +2335,7 @@ impl<'a> Resolver<'a> { /// /// Stops after meeting a closure. fn search_label(&self, mut ident: Ident, pred: P) -> Option - where P: Fn(&Rib, Ident) -> Option + where P: Fn(&Rib<'_>, Ident) -> Option { for rib in self.label_ribs.iter().rev() { match rib.kind { @@ -2527,7 +2520,7 @@ impl<'a> Resolver<'a> { } fn with_type_parameter_rib<'b, F>(&'b mut self, type_parameters: TypeParameters<'a, 'b>, f: F) - where F: FnOnce(&mut Resolver) + where F: FnOnce(&mut Resolver<'_>) { match type_parameters { HasTypeParameters(generics, rib_kind) => { @@ -2573,7 +2566,7 @@ impl<'a> Resolver<'a> { } fn with_label_rib(&mut self, f: F) - where F: FnOnce(&mut Resolver) + where F: FnOnce(&mut Resolver<'_>) { self.label_ribs.push(Rib::new(NormalRibKind)); f(self); @@ -2581,7 +2574,7 @@ impl<'a> Resolver<'a> { } fn with_item_rib(&mut self, f: F) - where F: FnOnce(&mut Resolver) + where F: FnOnce(&mut Resolver<'_>) { self.ribs[ValueNS].push(Rib::new(ItemRibKind)); self.ribs[TypeNS].push(Rib::new(ItemRibKind)); @@ -2591,7 +2584,7 @@ impl<'a> Resolver<'a> { } fn with_constant_rib(&mut self, f: F) - where F: FnOnce(&mut Resolver) + where F: FnOnce(&mut Resolver<'_>) { self.ribs[ValueNS].push(Rib::new(ConstantItemRibKind)); self.label_ribs.push(Rib::new(ConstantItemRibKind)); @@ -2601,7 +2594,7 @@ impl<'a> Resolver<'a> { } fn with_current_self_type(&mut self, self_type: &Ty, f: F) -> T - where F: FnOnce(&mut Resolver) -> T + where F: FnOnce(&mut Resolver<'_>) -> T { // Handle nested impls (inside fn bodies) let previous_value = replace(&mut self.current_self_type, Some(self_type.clone())); @@ -2611,7 +2604,7 @@ impl<'a> Resolver<'a> { } fn with_current_self_item(&mut self, self_item: &Item, f: F) -> T - where F: FnOnce(&mut Resolver) -> T + where F: FnOnce(&mut Resolver<'_>) -> T { let previous_value = replace(&mut self.current_self_item, Some(self_item.id)); let result = f(self); @@ -2621,7 +2614,7 @@ impl<'a> Resolver<'a> { /// This is called to resolve a trait reference from an `impl` (i.e., `impl Trait for Foo`) fn with_optional_trait_ref(&mut self, opt_trait_ref: Option<&TraitRef>, f: F) -> T - where F: FnOnce(&mut Resolver, Option) -> T + where F: FnOnce(&mut Resolver<'_>, Option) -> T { let mut new_val = None; let mut new_id = None; @@ -2658,7 +2651,7 @@ impl<'a> Resolver<'a> { } fn with_self_rib(&mut self, self_def: Def, f: F) - where F: FnOnce(&mut Resolver) + where F: FnOnce(&mut Resolver<'_>) { let mut self_type_rib = Rib::new(NormalRibKind); @@ -2670,7 +2663,7 @@ impl<'a> Resolver<'a> { } fn with_self_struct_ctor_rib(&mut self, impl_id: DefId, f: F) - where F: FnOnce(&mut Resolver) + where F: FnOnce(&mut Resolver<'_>) { let self_def = Def::SelfCtor(impl_id); let mut self_type_rib = Rib::new(NormalRibKind); @@ -2771,7 +2764,7 @@ impl<'a> Resolver<'a> { } fn check_trait_item(&mut self, ident: Ident, ns: Namespace, span: Span, err: F) - where F: FnOnce(Name, &str) -> ResolutionError + where F: FnOnce(Name, &str) -> ResolutionError<'_> { // If there is a TraitRef in scope for an impl, then the method must be in the // trait. @@ -3102,7 +3095,7 @@ impl<'a> Resolver<'a> { id: NodeId, qself: Option<&QSelf>, path: &Path, - source: PathSource) + source: PathSource<'_>) -> PathResolution { self.smart_resolve_path_with_crate_lint(id, qself, path, source, CrateLint::SimplePath(id)) } @@ -3120,7 +3113,7 @@ impl<'a> Resolver<'a> { id: NodeId, qself: Option<&QSelf>, path: &Path, - source: PathSource, + source: PathSource<'_>, crate_lint: CrateLint ) -> PathResolution { self.smart_resolve_path_fragment( @@ -3138,7 +3131,7 @@ impl<'a> Resolver<'a> { qself: Option<&QSelf>, path: &[Segment], span: Span, - source: PathSource, + source: PathSource<'_>, crate_lint: CrateLint) -> PathResolution { let ident_span = path.last().map_or(span, |ident| ident.ident.span); @@ -3581,7 +3574,7 @@ impl<'a> Resolver<'a> { } fn type_ascription_suggestion(&self, - err: &mut DiagnosticBuilder, + err: &mut DiagnosticBuilder<'_>, base_span: Span) { debug!("type_ascription_suggetion {:?}", base_span); let cm = self.session.source_map(); @@ -4040,7 +4033,7 @@ impl<'a> Resolver<'a> { crate_lint: CrateLint, path: &[Segment], path_span: Span, - second_binding: Option<&NameBinding>, + second_binding: Option<&NameBinding<'_>>, ) { let (diag_id, diag_span) = match crate_lint { CrateLint::No => return, @@ -4266,7 +4259,7 @@ impl<'a> Resolver<'a> { where FilterFn: Fn(Def) -> bool, { - let add_module_candidates = |module: Module, names: &mut Vec| { + let add_module_candidates = |module: Module<'_>, names: &mut Vec| { for (&(ident, _), resolution) in module.resolutions.borrow().iter() { if let Some(binding) = resolution.borrow().binding { if filter_fn(binding.def()) { @@ -4361,7 +4354,7 @@ impl<'a> Resolver<'a> { } fn with_resolved_label(&mut self, label: Option