From 219ba511c824bc44149d55c570f723dcd0f0217d Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Tue, 21 Nov 2017 14:44:25 +0100 Subject: [PATCH 001/198] Document the size of bool --- src/libcore/mem.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index d57fbdf55f80e..486093f261c77 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -189,6 +189,7 @@ pub fn forget(t: T) { /// Type | size_of::\() /// ---- | --------------- /// () | 0 +/// bool | 1 /// u8 | 1 /// u16 | 2 /// u32 | 4 From ab7f02d0a8dcf5281fa55366f77a752dfe1a4796 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Tue, 16 Jan 2018 13:31:42 -0600 Subject: [PATCH 002/198] add documentation from doc(include) to analysis data --- src/librustc_save_analysis/lib.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 2e494fdfad8b8..8232a8efd541f 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -870,6 +870,17 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { result.push_str(&val.as_str()); } result.push('\n'); + } else if let Some(meta_list) = attr.meta_item_list() { + meta_list.into_iter() + .filter(|it| it.check_name("include")) + .filter_map(|it| it.meta_item_list().map(|l| l.to_owned())) + .flat_map(|it| it) + .filter(|meta| meta.check_name("contents")) + .filter_map(|meta| meta.value_str()) + .for_each(|val| { + result.push_str(&val.as_str()); + result.push('\n'); + }); } } } From fdfb964a821a2f61353146629977eecafc0aa947 Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 18 Jan 2018 15:28:10 +0000 Subject: [PATCH 003/198] Document the behaviour of infinite iterators on potentially-computable methods MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s not entirely clear from the current documentation what behaviour calling a method such as `min` on an infinite iterator like `RangeFrom` is. One might expect this to terminate, but in fact, for infinite iterators, `min` is always nonterminating (at least in the standard library). This adds a quick note about this behaviour for clarification. --- src/libcore/iter/iterator.rs | 4 ++++ src/libcore/iter/mod.rs | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index 35cd7441c66bc..209a22d534a2e 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -24,6 +24,10 @@ fn _assert_is_object_safe(_: &Iterator) {} /// This is the main iterator trait. For more about the concept of iterators /// generally, please see the [module-level documentation]. In particular, you /// may want to know how to [implement `Iterator`][impl]. +/// +/// Note: Methods on infinite iterators that generally require traversing every +/// element to produce a result may not terminate, even on traits for which a +/// result is determinable in finite time. /// /// [module-level documentation]: index.html /// [impl]: index.html#implementing-iterator diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 06c29b47bf921..3a5a72d1b87c1 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -297,8 +297,22 @@ //! ``` //! //! This will print the numbers `0` through `4`, each on their own line. +//! +//! Bear in mind that methods on infinite iterators, even those for which a +//! result can be computed in finite time, may not terminate. Specifically, +//! methods such as [`min`], which in the general case require traversing +//! every element in the iterator, are likely never to terminate for any +//! infinite iterators. +//! +//! ``` +//! let positives = 1..; +//! let least = positives.min().unwrap(); // Oh no! An infinite loop! +//! // `positives.min` causes an infinite loop, so we won't reach this point! +//! println!("The least positive number is {}.", least); +//! ``` //! //! [`take`]: trait.Iterator.html#method.take +//! [`min`]: trait.Iterator.html#method.min #![stable(feature = "rust1", since = "1.0.0")] From 91668fbf230b388330da9591ba310c7e35ef9611 Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 18 Jan 2018 17:49:32 +0000 Subject: [PATCH 004/198] Make example no_run --- src/libcore/iter/iterator.rs | 2 +- src/libcore/iter/mod.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index 209a22d534a2e..da9af214207b6 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -24,7 +24,7 @@ fn _assert_is_object_safe(_: &Iterator) {} /// This is the main iterator trait. For more about the concept of iterators /// generally, please see the [module-level documentation]. In particular, you /// may want to know how to [implement `Iterator`][impl]. -/// +/// /// Note: Methods on infinite iterators that generally require traversing every /// element to produce a result may not terminate, even on traits for which a /// result is determinable in finite time. diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 3a5a72d1b87c1..ae10ac385ab50 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -297,14 +297,14 @@ //! ``` //! //! This will print the numbers `0` through `4`, each on their own line. -//! +//! //! Bear in mind that methods on infinite iterators, even those for which a //! result can be computed in finite time, may not terminate. Specifically, //! methods such as [`min`], which in the general case require traversing //! every element in the iterator, are likely never to terminate for any //! infinite iterators. -//! -//! ``` +//! +//! ```no_run //! let positives = 1..; //! let least = positives.min().unwrap(); // Oh no! An infinite loop! //! // `positives.min` causes an infinite loop, so we won't reach this point! From 0be51730ee51c009cdd7cd5f77fcd1f2b898f5b7 Mon Sep 17 00:00:00 2001 From: varkor Date: Fri, 19 Jan 2018 21:16:34 +0000 Subject: [PATCH 005/198] Adjust language as per suggestions --- src/libcore/iter/iterator.rs | 8 ++++---- src/libcore/iter/mod.rs | 12 +++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index da9af214207b6..23fded0669a6f 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -25,10 +25,6 @@ fn _assert_is_object_safe(_: &Iterator) {} /// generally, please see the [module-level documentation]. In particular, you /// may want to know how to [implement `Iterator`][impl]. /// -/// Note: Methods on infinite iterators that generally require traversing every -/// element to produce a result may not terminate, even on traits for which a -/// result is determinable in finite time. -/// /// [module-level documentation]: index.html /// [impl]: index.html#implementing-iterator #[stable(feature = "rust1", since = "1.0.0")] @@ -1430,6 +1426,10 @@ pub trait Iterator { /// Folding is useful whenever you have a collection of something, and want /// to produce a single value from it. /// + /// Note: `fold()`, and similar methods that traverse the entire iterator, + /// may not terminate for infinite iterators, even on traits for which a + /// result is determinable in finite time. + /// /// # Examples /// /// Basic usage: diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index ae10ac385ab50..d1fdedd1b235f 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -299,15 +299,17 @@ //! This will print the numbers `0` through `4`, each on their own line. //! //! Bear in mind that methods on infinite iterators, even those for which a -//! result can be computed in finite time, may not terminate. Specifically, -//! methods such as [`min`], which in the general case require traversing -//! every element in the iterator, are likely never to terminate for any -//! infinite iterators. +//! result can be determined mathematically in finite time, may not terminate. +//! Specifically, methods such as [`min`], which in the general case require +//! traversing every element in the iterator, are likely not to return +//! successfully for any infinite iterators. //! //! ```no_run //! let positives = 1..; //! let least = positives.min().unwrap(); // Oh no! An infinite loop! -//! // `positives.min` causes an infinite loop, so we won't reach this point! +//! // `positives.min` will either overflow and panic (in debug mode), +//! // or cause an infinite loop (in release mode), so we won't reach +//! // this point! //! println!("The least positive number is {}.", least); //! ``` //! From 3f557947abf99b262aab994e896522c76329d315 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Sun, 21 Jan 2018 09:48:23 +0100 Subject: [PATCH 006/198] NonNull ended up landing in 1.25 --- src/libcore/ptr.rs | 36 ++++++++++++++++++------------------ src/libstd/panic.rs | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index fab5832d905df..607e4a1a9fa10 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2461,7 +2461,7 @@ impl<'a, T: ?Sized> From> for Unique { } /// Previous name of `NonNull`. -#[rustc_deprecated(since = "1.24", reason = "renamed to `NonNull`")] +#[rustc_deprecated(since = "1.25.0", reason = "renamed to `NonNull`")] #[unstable(feature = "shared", issue = "27730")] pub type Shared = NonNull; @@ -2482,12 +2482,12 @@ pub type Shared = NonNull; /// Usually this won't be necessary; covariance is correct for most safe abstractions, /// such as Box, Rc, Arc, Vec, and LinkedList. This is the case because they /// provide a public API that follows the normal shared XOR mutable rules of Rust. -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] pub struct NonNull { pointer: NonZero<*const T>, } -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl fmt::Debug for NonNull { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Pointer::fmt(&self.as_ptr(), f) @@ -2496,12 +2496,12 @@ impl fmt::Debug for NonNull { /// `NonNull` pointers are not `Send` because the data they reference may be aliased. // NB: This impl is unnecessary, but should provide better error messages. -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl !Send for NonNull { } /// `NonNull` pointers are not `Sync` because the data they reference may be aliased. // NB: This impl is unnecessary, but should provide better error messages. -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl !Sync for NonNull { } impl NonNull { @@ -2509,7 +2509,7 @@ impl NonNull { /// /// This is useful for initializing types which lazily allocate, like /// `Vec::new` does. - #[stable(feature = "nonnull", since = "1.24.0")] + #[stable(feature = "nonnull", since = "1.25.0")] pub fn dangling() -> Self { unsafe { let ptr = mem::align_of::() as *mut T; @@ -2524,19 +2524,19 @@ impl NonNull { /// # Safety /// /// `ptr` must be non-null. - #[stable(feature = "nonnull", since = "1.24.0")] + #[stable(feature = "nonnull", since = "1.25.0")] pub const unsafe fn new_unchecked(ptr: *mut T) -> Self { NonNull { pointer: NonZero::new_unchecked(ptr) } } /// Creates a new `NonNull` if `ptr` is non-null. - #[stable(feature = "nonnull", since = "1.24.0")] + #[stable(feature = "nonnull", since = "1.25.0")] pub fn new(ptr: *mut T) -> Option { NonZero::new(ptr as *const T).map(|nz| NonNull { pointer: nz }) } /// Acquires the underlying `*mut` pointer. - #[stable(feature = "nonnull", since = "1.24.0")] + #[stable(feature = "nonnull", since = "1.25.0")] pub fn as_ptr(self) -> *mut T { self.pointer.get() as *mut T } @@ -2546,7 +2546,7 @@ impl NonNull { /// The resulting lifetime is bound to self so this behaves "as if" /// it were actually an instance of T that is getting borrowed. If a longer /// (unbound) lifetime is needed, use `&*my_ptr.as_ptr()`. - #[stable(feature = "nonnull", since = "1.24.0")] + #[stable(feature = "nonnull", since = "1.25.0")] pub unsafe fn as_ref(&self) -> &T { &*self.as_ptr() } @@ -2556,47 +2556,47 @@ impl NonNull { /// The resulting lifetime is bound to self so this behaves "as if" /// it were actually an instance of T that is getting borrowed. If a longer /// (unbound) lifetime is needed, use `&mut *my_ptr.as_ptr()`. - #[stable(feature = "nonnull", since = "1.24.0")] + #[stable(feature = "nonnull", since = "1.25.0")] pub unsafe fn as_mut(&mut self) -> &mut T { &mut *self.as_ptr() } } -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl Clone for NonNull { fn clone(&self) -> Self { *self } } -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl Copy for NonNull { } -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl CoerceUnsized> for NonNull where T: Unsize { } -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl fmt::Pointer for NonNull { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Pointer::fmt(&self.as_ptr(), f) } } -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl From> for NonNull { fn from(unique: Unique) -> Self { NonNull { pointer: unique.pointer } } } -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl<'a, T: ?Sized> From<&'a mut T> for NonNull { fn from(reference: &'a mut T) -> Self { NonNull { pointer: NonZero::from(reference) } } } -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl<'a, T: ?Sized> From<&'a T> for NonNull { fn from(reference: &'a T) -> Self { NonNull { pointer: NonZero::from(reference) } diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 560876006d3f3..112e110609310 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -198,7 +198,7 @@ impl UnwindSafe for *const T {} impl UnwindSafe for *mut T {} #[unstable(feature = "ptr_internals", issue = "0")] impl UnwindSafe for Unique {} -#[stable(feature = "nonnull", since = "1.24.0")] +#[stable(feature = "nonnull", since = "1.25.0")] impl UnwindSafe for NonNull {} #[stable(feature = "catch_unwind", since = "1.9.0")] impl UnwindSafe for Mutex {} From ad37e3fc01b533994dfb30f703c28ecdbf66fe10 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Sun, 21 Jan 2018 09:48:58 +0100 Subject: [PATCH 007/198] =?UTF-8?q?Move=20Debug=20for=C2=A0NonNull=20impl?= =?UTF-8?q?=20closer=20to=20other=20trait=20impls?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libcore/ptr.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 607e4a1a9fa10..c3b7c4f5d2247 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2487,13 +2487,6 @@ pub struct NonNull { pointer: NonZero<*const T>, } -#[stable(feature = "nonnull", since = "1.25.0")] -impl fmt::Debug for NonNull { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Pointer::fmt(&self.as_ptr(), f) - } -} - /// `NonNull` pointers are not `Send` because the data they reference may be aliased. // NB: This impl is unnecessary, but should provide better error messages. #[stable(feature = "nonnull", since = "1.25.0")] @@ -2575,6 +2568,13 @@ impl Copy for NonNull { } #[stable(feature = "nonnull", since = "1.25.0")] impl CoerceUnsized> for NonNull where T: Unsize { } +#[stable(feature = "nonnull", since = "1.25.0")] +impl fmt::Debug for NonNull { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Pointer::fmt(&self.as_ptr(), f) + } +} + #[stable(feature = "nonnull", since = "1.25.0")] impl fmt::Pointer for NonNull { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { From 6461c9bdd35d6273b88f22fd5e8708eaf8949283 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Sun, 21 Jan 2018 09:51:19 +0100 Subject: [PATCH 008/198] Implement Eq, PartialEq, Ord, PartialOrd, and Hash for NonNull<_> --- src/libcore/ptr.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index c3b7c4f5d2247..a0d716fb57405 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2582,6 +2582,37 @@ impl fmt::Pointer for NonNull { } } +#[stable(feature = "nonnull", since = "1.25.0")] +impl Eq for NonNull {} + +#[stable(feature = "nonnull", since = "1.25.0")] +impl PartialEq for NonNull { + fn eq(&self, other: &Self) -> bool { + self.as_ptr() == other.as_ptr() + } +} + +#[stable(feature = "nonnull", since = "1.25.0")] +impl Ord for NonNull { + fn cmp(&self, other: &Self) -> Ordering { + self.as_ptr().cmp(&other.as_ptr()) + } +} + +#[stable(feature = "nonnull", since = "1.25.0")] +impl PartialOrd for NonNull { + fn partial_cmp(&self, other: &Self) -> Option { + self.as_ptr().partial_cmp(&other.as_ptr()) + } +} + +#[stable(feature = "nonnull", since = "1.25.0")] +impl hash::Hash for NonNull { + fn hash(&self, state: &mut H) { + self.as_ptr().hash(state) + } +} + #[stable(feature = "nonnull", since = "1.25.0")] impl From> for NonNull { fn from(unique: Unique) -> Self { From f129374d11d51ca23d85bc678fbc1ed4e7082ab1 Mon Sep 17 00:00:00 2001 From: varkor Date: Sun, 21 Jan 2018 19:45:27 +0000 Subject: [PATCH 009/198] Use repeat instead of RangeFrom --- src/libcore/iter/mod.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index d1fdedd1b235f..4490f15f446fe 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -305,12 +305,10 @@ //! successfully for any infinite iterators. //! //! ```no_run -//! let positives = 1..; -//! let least = positives.min().unwrap(); // Oh no! An infinite loop! -//! // `positives.min` will either overflow and panic (in debug mode), -//! // or cause an infinite loop (in release mode), so we won't reach -//! // this point! -//! println!("The least positive number is {}.", least); +//! let ones = std::iter::repeat(1); +//! let least = ones.min().unwrap(); // Oh no! An infinite loop! +//! // `ones.min()` causes an infinite loop, so we won't reach this point! +//! println!("The smallest number one is {}.", least); //! ``` //! //! [`take`]: trait.Iterator.html#method.take From b8ffc8a3d8c181e958d2ddf4f108f0cd3a108013 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Sun, 21 Jan 2018 09:56:33 +0100 Subject: [PATCH 010/198] Add an unstable `cast() -> NonNull` method to `NonNull`. This is less verbose than going through raw pointers to cast with `as`. --- src/libcore/ptr.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index a0d716fb57405..3d84e910fe662 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2553,6 +2553,14 @@ impl NonNull { pub unsafe fn as_mut(&mut self) -> &mut T { &mut *self.as_ptr() } + + /// Cast to a pointer of another type + #[unstable(feature = "nonnull_cast", issue = "47653")] + pub fn cast(self) -> NonNull { + unsafe { + NonNull::new_unchecked(self.as_ptr() as *mut U) + } + } } #[stable(feature = "nonnull", since = "1.25.0")] From 838ddbf908f63a0a3d8629d9dc16592a27a8ba30 Mon Sep 17 00:00:00 2001 From: tinaun Date: Fri, 26 Jan 2018 18:52:27 -0500 Subject: [PATCH 011/198] derive PartialEq and Eq for `ParseCharError` unlike the other Parse*Error types, ParseCharError didn't have these implemented for whatever reason --- src/libcore/char.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/char.rs b/src/libcore/char.rs index e8b81db07067c..7215bd2a47684 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -211,7 +211,7 @@ impl From for char { /// An error which can be returned when parsing a char. #[stable(feature = "char_from_str", since = "1.20.0")] -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq, Eq)] pub struct ParseCharError { kind: CharErrorKind, } From dd6b0059265c99de3bc9c9b083966b5e3a723517 Mon Sep 17 00:00:00 2001 From: David Wood Date: Mon, 15 Jan 2018 10:44:13 +0000 Subject: [PATCH 012/198] Added test for #45697 --- src/test/ui/issue-45697.rs | 35 ++++++++++++++++++++++++++++++++++ src/test/ui/issue-45697.stderr | 18 +++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 src/test/ui/issue-45697.rs create mode 100644 src/test/ui/issue-45697.stderr diff --git a/src/test/ui/issue-45697.rs b/src/test/ui/issue-45697.rs new file mode 100644 index 0000000000000..7f44209d717a1 --- /dev/null +++ b/src/test/ui/issue-45697.rs @@ -0,0 +1,35 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that assignments to an `&mut` pointer which is found in a +// borrowed (but otherwise non-aliasable) location is illegal. + +// compile-flags: -Z emit-end-regions -Z borrowck=compare + +struct S<'a> { + pointer: &'a mut isize +} + +fn copy_borrowed_ptr<'a>(p: &'a mut S<'a>) -> S<'a> { + S { pointer: &mut *p.pointer } +} + +fn main() { + let mut x = 1; + + { + let mut y = S { pointer: &mut x }; + let z = copy_borrowed_ptr(&mut y); + *y.pointer += 1; + //~^ ERROR cannot assign to `*y.pointer` because it is borrowed (Ast) [E0506] + //~| ERROR cannot assign to `*y.pointer` because it is borrowed (Mir) [E0506] + *z.pointer += 1; + } +} diff --git a/src/test/ui/issue-45697.stderr b/src/test/ui/issue-45697.stderr new file mode 100644 index 0000000000000..007bfbfc9b01e --- /dev/null +++ b/src/test/ui/issue-45697.stderr @@ -0,0 +1,18 @@ +error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast) + --> $DIR/issue-45697.rs:30:9 + | +29 | let z = copy_borrowed_ptr(&mut y); + | - borrow of `*y.pointer` occurs here +30 | *y.pointer += 1; + | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here + +error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Mir) + --> $DIR/issue-45697.rs:30:9 + | +29 | let z = copy_borrowed_ptr(&mut y); + | ------ borrow of `*y.pointer` occurs here +30 | *y.pointer += 1; + | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here + +error: aborting due to 2 previous errors + From f1c1db61e454a6be93a2706ad15a09aad161613f Mon Sep 17 00:00:00 2001 From: David Wood Date: Fri, 19 Jan 2018 22:04:01 +0000 Subject: [PATCH 013/198] Updated other affected tests. --- .../compile-fail/nll/reference-carried-through-struct-field.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/compile-fail/nll/reference-carried-through-struct-field.rs b/src/test/compile-fail/nll/reference-carried-through-struct-field.rs index 1c1fc4799c3d1..e64fecbe701e7 100644 --- a/src/test/compile-fail/nll/reference-carried-through-struct-field.rs +++ b/src/test/compile-fail/nll/reference-carried-through-struct-field.rs @@ -20,7 +20,6 @@ fn foo() { let wrapper = Wrap { w: &mut x }; x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506] //[mir]~^ ERROR cannot assign to `x` because it is borrowed [E0506] - //[mir]~^^ ERROR cannot use `x` because it was mutably borrowed [E0503] *wrapper.w += 1; } From 3daa4d255f1ecc9d0a28deb9ca3d6da79f1df438 Mon Sep 17 00:00:00 2001 From: David Wood Date: Fri, 19 Jan 2018 22:11:59 +0000 Subject: [PATCH 014/198] Introduced a new set to stop duplicate errors from MIR passes on one place/span. --- src/librustc_mir/borrow_check/mod.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index d6937c405f961..1d630b280a590 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -230,6 +230,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>( }, storage_dead_or_drop_error_reported_l: FxHashSet(), storage_dead_or_drop_error_reported_s: FxHashSet(), + read_or_write_error_reported: FxHashSet(), reservation_error_reported: FxHashSet(), nonlexical_regioncx: opt_regioncx.clone(), }; @@ -300,6 +301,9 @@ pub struct MirBorrowckCtxt<'cx, 'gcx: 'tcx, 'tcx: 'cx> { storage_dead_or_drop_error_reported_l: FxHashSet, /// Same as the above, but for statics (thread-locals) storage_dead_or_drop_error_reported_s: FxHashSet, + /// This field keeps track of when borrow errors are reported in read or write passes + /// so that an error is not reported in both. + read_or_write_error_reported: FxHashSet<(Place<'tcx>, Span)>, /// This field keeps track of when borrow conflict errors are reported /// for reservations, so that we don't report seemingly duplicate /// errors for corresponding activations @@ -739,11 +743,23 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } } + if self.read_or_write_error_reported.contains(&(place_span.0.clone(), place_span.1)) { + debug!("suppressing access_place write for {:?}", place_span); + return AccessErrorsReported { + mutability_error: false, + conflict_error: true, + }; + } + let mutability_error = self.check_access_permissions(place_span, rw, is_local_mutation_allowed); let conflict_error = self.check_access_for_conflict(context, place_span, sd, rw, flow_state); + if conflict_error { + self.read_or_write_error_reported.insert((place_span.0.clone(), place_span.1)); + } + AccessErrorsReported { mutability_error, conflict_error, From f92d679b78fc1e5db5d5fd6cbb9a5e076f8fee69 Mon Sep 17 00:00:00 2001 From: David Wood Date: Sat, 20 Jan 2018 02:15:57 +0000 Subject: [PATCH 015/198] Encompassed error deduplication of some existing sets in the ctxt. --- .../borrow_check/error_reporting.rs | 29 ++++--------- src/librustc_mir/borrow_check/mod.rs | 43 ++++++++----------- 2 files changed, 25 insertions(+), 47 deletions(-) diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index 7bd3b6e39f053..8ded245e13ff5 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -362,33 +362,20 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { let scope_tree = borrows.0.scope_tree(); let root_place = self.prefixes(&borrow.borrowed_place, PrefixSet::All).last().unwrap(); - match root_place { - &Place::Local(local) => { - if let Some(_) = self.storage_dead_or_drop_error_reported_l.replace(local) { - debug!("report_does_not_live_long_enough({:?}): ", - (borrow, drop_span)); - return - } - } - &Place::Static(ref statik) => { - if let Some(_) = self.storage_dead_or_drop_error_reported_s - .replace(statik.def_id) - { - debug!("report_does_not_live_long_enough({:?}): ", - (borrow, drop_span)); - return - } - }, - &Place::Projection(_) => - unreachable!("root_place is an unreachable???") - }; - let borrow_span = self.mir.source_info(borrow.location).span; let proper_span = match *root_place { Place::Local(local) => self.mir.local_decls[local].source_info.span, _ => drop_span, }; + if self.access_place_error_reported.contains(&(root_place.clone(), borrow_span)) { + debug!("suppressing access_place error when borrow doesn't live long enough for {:?}", + borrow_span); + return; + } + + self.access_place_error_reported.insert((root_place.clone(), borrow_span)); + match (borrow.region, &self.describe_place(&borrow.borrowed_place)) { (RegionKind::ReScope(_), Some(name)) => { self.report_scoped_local_value_does_not_live_long_enough( diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 1d630b280a590..6b84abbe266fa 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -17,7 +17,7 @@ use rustc::hir::map::definitions::DefPathData; use rustc::infer::InferCtxt; use rustc::ty::{self, ParamEnv, TyCtxt}; use rustc::ty::maps::Providers; -use rustc::mir::{AssertMessage, BasicBlock, BorrowKind, Local, Location, Place}; +use rustc::mir::{AssertMessage, BasicBlock, BorrowKind, Location, Place}; use rustc::mir::{Mir, Mutability, Operand, Projection, ProjectionElem, Rvalue}; use rustc::mir::{Field, Statement, StatementKind, Terminator, TerminatorKind}; use rustc::mir::ClosureRegionRequirements; @@ -228,9 +228,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>( hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(_) => false, hir::BodyOwnerKind::Fn => true, }, - storage_dead_or_drop_error_reported_l: FxHashSet(), - storage_dead_or_drop_error_reported_s: FxHashSet(), - read_or_write_error_reported: FxHashSet(), + access_place_error_reported: FxHashSet(), reservation_error_reported: FxHashSet(), nonlexical_regioncx: opt_regioncx.clone(), }; @@ -295,15 +293,12 @@ pub struct MirBorrowckCtxt<'cx, 'gcx: 'tcx, 'tcx: 'cx> { /// I'm not sure this is the right approach - @eddyb could you try and /// figure this out? locals_are_invalidated_at_exit: bool, - /// This field keeps track of when storage dead or drop errors are reported - /// in order to stop duplicate error reporting and identify the conditions required - /// for a "temporary value dropped here while still borrowed" error. See #45360. - storage_dead_or_drop_error_reported_l: FxHashSet, - /// Same as the above, but for statics (thread-locals) - storage_dead_or_drop_error_reported_s: FxHashSet, - /// This field keeps track of when borrow errors are reported in read or write passes - /// so that an error is not reported in both. - read_or_write_error_reported: FxHashSet<(Place<'tcx>, Span)>, + /// This field keeps track of when borrow errors are reported in the access_place function + /// so that there is no duplicate reporting. This field cannot also be used for the conflicting + /// borrow errors that is handled by the `reservation_error_reported` field as the inclusion + /// of the `Span` type (while required to mute some errors) stops the muting of the reservation + /// errors. + access_place_error_reported: FxHashSet<(Place<'tcx>, Span)>, /// This field keeps track of when borrow conflict errors are reported /// for reservations, so that we don't report seemingly duplicate /// errors for corresponding activations @@ -730,12 +725,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { if let Activation(_, borrow_index) = rw { if self.reservation_error_reported.contains(&place_span.0) { - debug!( - "skipping access_place for activation of invalid reservation \ - place: {:?} borrow_index: {:?}", - place_span.0, - borrow_index - ); + debug!("skipping access_place for activation of invalid reservation \ + place: {:?} borrow_index: {:?}", place_span.0, borrow_index); return AccessErrorsReported { mutability_error: false, conflict_error: true, @@ -743,8 +734,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } } - if self.read_or_write_error_reported.contains(&(place_span.0.clone(), place_span.1)) { - debug!("suppressing access_place write for {:?}", place_span); + if self.access_place_error_reported.contains(&(place_span.0.clone(), place_span.1)) { + debug!("suppressing access_place error for {:?}", place_span); return AccessErrorsReported { mutability_error: false, conflict_error: true, @@ -756,8 +747,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { let conflict_error = self.check_access_for_conflict(context, place_span, sd, rw, flow_state); - if conflict_error { - self.read_or_write_error_reported.insert((place_span.0.clone(), place_span.1)); + if conflict_error || mutability_error { + self.access_place_error_reported.insert((place_span.0.clone(), place_span.1)); } AccessErrorsReported { @@ -845,15 +836,15 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { place_span.0 ); this.reservation_error_reported.insert(place_span.0.clone()); - } + }, Activation(_, activating) => { debug!( "observing check_place for activation of \ borrow_index: {:?}", activating ); - } - Read(..) | Write(..) => {} + }, + Read(..) | Write(..) => {}, } match kind { From 6c86da288a6b658a2adb2c3de5dced871dc6826b Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Sat, 27 Jan 2018 17:54:01 +0100 Subject: [PATCH 016/198] Make wording around 0-cost casts more precise --- src/libstd/ffi/c_str.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index a19fe825f21fa..e91d3a32a50cd 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -1026,9 +1026,9 @@ impl CStr { /// The returned slice will **not** contain the trailing nul terminator that this C /// string has. /// - /// > **Note**: This method is currently implemented as a 0-cost cast, but - /// > it is planned to alter its definition in the future to perform the - /// > length calculation whenever this method is called. + /// > **Note**: This method is currently implemented as a constant-time + /// > cast, but it is planned to alter its definition in the future to + /// > perform the length calculation whenever this method is called. /// /// # Examples /// @@ -1077,9 +1077,9 @@ impl CStr { /// it will return an error with details of where UTF-8 validation failed. /// /// > **Note**: This method is currently implemented to check for validity - /// > after a 0-cost cast, but it is planned to alter its definition in the - /// > future to perform the length calculation in addition to the UTF-8 - /// > check whenever this method is called. + /// > after a constant-time cast, but it is planned to alter its definition + /// > in the future to perform the length calculation in addition to the + /// > UTF-8 check whenever this method is called. /// /// [`&str`]: ../primitive.str.html /// @@ -1110,9 +1110,9 @@ impl CStr { /// with the result. /// /// > **Note**: This method is currently implemented to check for validity - /// > after a 0-cost cast, but it is planned to alter its definition in the - /// > future to perform the length calculation in addition to the UTF-8 - /// > check whenever this method is called. + /// > after a constant-time cast, but it is planned to alter its definition + /// > in the future to perform the length calculation in addition to the + /// > UTF-8 check whenever this method is called. /// /// [`Cow`]: ../borrow/enum.Cow.html /// [`Borrowed`]: ../borrow/enum.Cow.html#variant.Borrowed From 970fb1a77f31e71e16871d22547243f1c98e6d66 Mon Sep 17 00:00:00 2001 From: David Wood Date: Sat, 27 Jan 2018 17:16:13 +0000 Subject: [PATCH 017/198] Added logging for error suppression. --- src/librustc_mir/borrow_check/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 6b84abbe266fa..95dd8dd48a0b1 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -735,7 +735,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } if self.access_place_error_reported.contains(&(place_span.0.clone(), place_span.1)) { - debug!("suppressing access_place error for {:?}", place_span); + debug!("access_place: suppressing error place_span=`{:?}` kind=`{:?}`", + place_span, kind); return AccessErrorsReported { mutability_error: false, conflict_error: true, @@ -748,6 +749,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { self.check_access_for_conflict(context, place_span, sd, rw, flow_state); if conflict_error || mutability_error { + debug!("access_place: logging error place_span=`{:?}` kind=`{:?}`", + place_span, kind); self.access_place_error_reported.insert((place_span.0.clone(), place_span.1)); } From 80b8c808baaba629e73440abf52ee4bbfdb5c0f8 Mon Sep 17 00:00:00 2001 From: Peter Hrvola Date: Sat, 27 Jan 2018 12:02:45 +0100 Subject: [PATCH 018/198] Optimized error reporting for recursive requirements #47720 --- src/librustc/traits/error_reporting.rs | 40 ++++++++++++++++++----- src/test/ui/recursive-requirements.rs | 27 +++++++++++++++ src/test/ui/recursive-requirements.stderr | 14 ++++++++ 3 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 src/test/ui/recursive-requirements.rs create mode 100644 src/test/ui/recursive-requirements.stderr diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 42200a3a44728..dc8fcbb597414 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -1194,13 +1194,15 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { { self.note_obligation_cause_code(err, &obligation.predicate, - &obligation.cause.code); + &obligation.cause.code, + &mut vec![]); } fn note_obligation_cause_code(&self, err: &mut DiagnosticBuilder, predicate: &T, - cause_code: &ObligationCauseCode<'tcx>) + cause_code: &ObligationCauseCode<'tcx>, + obligated_types: &mut Vec<&ty::TyS<'tcx>>) where T: fmt::Display { let tcx = self.tcx; @@ -1292,12 +1294,17 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } ObligationCauseCode::BuiltinDerivedObligation(ref data) => { let parent_trait_ref = self.resolve_type_vars_if_possible(&data.parent_trait_ref); - err.note(&format!("required because it appears within the type `{}`", - parent_trait_ref.0.self_ty())); + let ty = parent_trait_ref.0.self_ty(); + err.note(&format!("required because it appears within the type `{}`", ty)); + obligated_types.push(ty); + let parent_predicate = parent_trait_ref.to_predicate(); - self.note_obligation_cause_code(err, - &parent_predicate, - &data.parent_code); + if !self.is_recursive_obligation(obligated_types, &data.parent_code) { + self.note_obligation_cause_code(err, + &parent_predicate, + &data.parent_code, + obligated_types); + } } ObligationCauseCode::ImplDerivedObligation(ref data) => { let parent_trait_ref = self.resolve_type_vars_if_possible(&data.parent_trait_ref); @@ -1307,8 +1314,9 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { parent_trait_ref.0.self_ty())); let parent_predicate = parent_trait_ref.to_predicate(); self.note_obligation_cause_code(err, - &parent_predicate, - &data.parent_code); + &parent_predicate, + &data.parent_code, + obligated_types); } ObligationCauseCode::CompareImplMethodObligation { .. } => { err.note( @@ -1327,6 +1335,20 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { err.help(&format!("consider adding a `#![recursion_limit=\"{}\"]` attribute to your crate", suggested_limit)); } + + fn is_recursive_obligation(&self, + obligated_types: &mut Vec<&ty::TyS<'tcx>>, + cause_code: &ObligationCauseCode<'tcx>) -> bool { + if let ObligationCauseCode::BuiltinDerivedObligation(ref data) = cause_code { + let parent_trait_ref = self.resolve_type_vars_if_possible(&data.parent_trait_ref); + for obligated_type in obligated_types { + if obligated_type == &parent_trait_ref.0.self_ty() { + return true; + } + } + } + return false; + } } enum ArgKind { diff --git a/src/test/ui/recursive-requirements.rs b/src/test/ui/recursive-requirements.rs new file mode 100644 index 0000000000000..2c0f0338b2d15 --- /dev/null +++ b/src/test/ui/recursive-requirements.rs @@ -0,0 +1,27 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::marker::PhantomData; + +struct AssertSync(PhantomData); + +pub struct Foo { + bar: *const Bar, + phantom: PhantomData, +} + +pub struct Bar { + foo: *const Foo, + phantom: PhantomData, +} + +fn main() { + let _: AssertSync = unimplemented!(); //~ ERROR E0275 +} diff --git a/src/test/ui/recursive-requirements.stderr b/src/test/ui/recursive-requirements.stderr new file mode 100644 index 0000000000000..8cf2c65b1e25c --- /dev/null +++ b/src/test/ui/recursive-requirements.stderr @@ -0,0 +1,14 @@ +error[E0275]: overflow evaluating the requirement `Foo: std::marker::Sync` + --> $DIR/recursive-requirements.rs:26:12 + | +26 | let _: AssertSync = unimplemented!(); //~ ERROR E0275 + | ^^^^^^^^^^^^^^^ + | + = help: consider adding a `#![recursion_limit="128"]` attribute to your crate + = note: required because it appears within the type `std::marker::PhantomData` + = note: required because it appears within the type `Bar` + = note: required because it appears within the type `std::marker::PhantomData` + = note: required because it appears within the type `Foo` + +error: aborting due to previous error + From b7437c56f82cfb643a372a7b10c85b4ed183d886 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 28 Jan 2018 11:14:09 -0800 Subject: [PATCH 019/198] Suggest removing value from `break` when invalid --- src/librustc_passes/loops.rs | 5 +++++ src/test/ui/loop-break-value-no-repeat.stderr | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index c23f28fe2205f..008c71cc9ce3d 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -119,6 +119,11 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> { kind.name()) .span_label(e.span, "can only break with a value inside `loop`") + .span_suggestion(e.span, + &format!("instead, use `break` on its own \ + without a value inside this `{}` loop", + kind.name()), + "break".to_string()) .emit(); } } diff --git a/src/test/ui/loop-break-value-no-repeat.stderr b/src/test/ui/loop-break-value-no-repeat.stderr index 296b3b191e319..982de00b4fa7c 100644 --- a/src/test/ui/loop-break-value-no-repeat.stderr +++ b/src/test/ui/loop-break-value-no-repeat.stderr @@ -3,6 +3,10 @@ error[E0571]: `break` with value from a `for` loop | 22 | break 22 //~ ERROR `break` with value from a `for` loop | ^^^^^^^^ can only break with a value inside `loop` +help: instead, use `break` on its own without a value inside this `for` loop + | +22 | break //~ ERROR `break` with value from a `for` loop + | ^^^^^ error: aborting due to previous error From 505ef7bc069d9def137c3c469ee8bdd487882730 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Sun, 21 Jan 2018 19:18:57 -0700 Subject: [PATCH 020/198] Remove unused blake2b implementation --- src/librustc_data_structures/blake2b.rs | 363 ------------------------ src/librustc_data_structures/lib.rs | 1 - 2 files changed, 364 deletions(-) delete mode 100644 src/librustc_data_structures/blake2b.rs diff --git a/src/librustc_data_structures/blake2b.rs b/src/librustc_data_structures/blake2b.rs deleted file mode 100644 index 6b8bf8df0d33f..0000000000000 --- a/src/librustc_data_structures/blake2b.rs +++ /dev/null @@ -1,363 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -// An implementation of the Blake2b cryptographic hash function. -// The implementation closely follows: https://tools.ietf.org/html/rfc7693 -// -// "BLAKE2 is a cryptographic hash function faster than MD5, SHA-1, SHA-2, and -// SHA-3, yet is at least as secure as the latest standard SHA-3." -// according to their own website :) -// -// Indeed this implementation is two to three times as fast as our SHA-256 -// implementation. If you have the luxury of being able to use crates from -// crates.io, you can go there and find still faster implementations. - -use std::mem; -use std::slice; - -#[repr(C)] -struct Blake2bCtx { - b: [u8; 128], - h: [u64; 8], - t: [u64; 2], - c: usize, - outlen: u16, - finalized: bool, - - #[cfg(debug_assertions)] - fnv_hash: u64, -} - -#[cfg(debug_assertions)] -impl ::std::fmt::Debug for Blake2bCtx { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - write!(fmt, "{:x}", self.fnv_hash) - } -} - -#[cfg(not(debug_assertions))] -impl ::std::fmt::Debug for Blake2bCtx { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - write!(fmt, "Enable debug_assertions() for more info.") - } -} - -#[inline(always)] -fn b2b_g(v: &mut [u64; 16], - a: usize, - b: usize, - c: usize, - d: usize, - x: u64, - y: u64) -{ - v[a] = v[a].wrapping_add(v[b]).wrapping_add(x); - v[d] = (v[d] ^ v[a]).rotate_right(32); - v[c] = v[c].wrapping_add(v[d]); - v[b] = (v[b] ^ v[c]).rotate_right(24); - v[a] = v[a].wrapping_add(v[b]).wrapping_add(y); - v[d] = (v[d] ^ v[a]).rotate_right(16); - v[c] = v[c].wrapping_add(v[d]); - v[b] = (v[b] ^ v[c]).rotate_right(63); -} - -// Initialization vector -const BLAKE2B_IV: [u64; 8] = [ - 0x6A09E667F3BCC908, 0xBB67AE8584CAA73B, - 0x3C6EF372FE94F82B, 0xA54FF53A5F1D36F1, - 0x510E527FADE682D1, 0x9B05688C2B3E6C1F, - 0x1F83D9ABFB41BD6B, 0x5BE0CD19137E2179 -]; - -fn blake2b_compress(ctx: &mut Blake2bCtx, last: bool) { - - const SIGMA: [[usize; 16]; 12] = [ - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ], - [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 ], - [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 ], - [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 ], - [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 ], - [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 ], - [12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 ], - [13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 ], - [6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 ], - [10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 ], - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ], - [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 ] - ]; - - let mut v: [u64; 16] = [ - ctx.h[0], - ctx.h[1], - ctx.h[2], - ctx.h[3], - ctx.h[4], - ctx.h[5], - ctx.h[6], - ctx.h[7], - - BLAKE2B_IV[0], - BLAKE2B_IV[1], - BLAKE2B_IV[2], - BLAKE2B_IV[3], - BLAKE2B_IV[4], - BLAKE2B_IV[5], - BLAKE2B_IV[6], - BLAKE2B_IV[7], - ]; - - v[12] ^= ctx.t[0]; // low 64 bits of offset - v[13] ^= ctx.t[1]; // high 64 bits - if last { - v[14] = !v[14]; - } - - { - // Re-interpret the input buffer in the state as an array - // of little-endian u64s, converting them to machine - // endianness. It's OK to modify the buffer in place - // since this is the last time this data will be accessed - // before it's overwritten. - - let m: &mut [u64; 16] = unsafe { - let b: &mut [u8; 128] = &mut ctx.b; - ::std::mem::transmute(b) - }; - - if cfg!(target_endian = "big") { - for word in &mut m[..] { - *word = u64::from_le(*word); - } - } - - for i in 0 .. 12 { - b2b_g(&mut v, 0, 4, 8, 12, m[SIGMA[i][ 0]], m[SIGMA[i][ 1]]); - b2b_g(&mut v, 1, 5, 9, 13, m[SIGMA[i][ 2]], m[SIGMA[i][ 3]]); - b2b_g(&mut v, 2, 6, 10, 14, m[SIGMA[i][ 4]], m[SIGMA[i][ 5]]); - b2b_g(&mut v, 3, 7, 11, 15, m[SIGMA[i][ 6]], m[SIGMA[i][ 7]]); - b2b_g(&mut v, 0, 5, 10, 15, m[SIGMA[i][ 8]], m[SIGMA[i][ 9]]); - b2b_g(&mut v, 1, 6, 11, 12, m[SIGMA[i][10]], m[SIGMA[i][11]]); - b2b_g(&mut v, 2, 7, 8, 13, m[SIGMA[i][12]], m[SIGMA[i][13]]); - b2b_g(&mut v, 3, 4, 9, 14, m[SIGMA[i][14]], m[SIGMA[i][15]]); - } - } - - for i in 0 .. 8 { - ctx.h[i] ^= v[i] ^ v[i + 8]; - } -} - -fn blake2b_new(outlen: usize, key: &[u8]) -> Blake2bCtx { - assert!(outlen > 0 && outlen <= 64 && key.len() <= 64); - - let mut ctx = Blake2bCtx { - b: [0; 128], - h: BLAKE2B_IV, - t: [0; 2], - c: 0, - outlen: outlen as u16, - finalized: false, - - #[cfg(debug_assertions)] - fnv_hash: 0xcbf29ce484222325, - }; - - ctx.h[0] ^= 0x01010000 ^ ((key.len() << 8) as u64) ^ (outlen as u64); - - if key.len() > 0 { - blake2b_update(&mut ctx, key); - ctx.c = ctx.b.len(); - } - - ctx -} - -fn blake2b_update(ctx: &mut Blake2bCtx, mut data: &[u8]) { - assert!(!ctx.finalized, "Blake2bCtx already finalized"); - - let mut bytes_to_copy = data.len(); - let mut space_in_buffer = ctx.b.len() - ctx.c; - - while bytes_to_copy > space_in_buffer { - checked_mem_copy(data, &mut ctx.b[ctx.c .. ], space_in_buffer); - - ctx.t[0] = ctx.t[0].wrapping_add(ctx.b.len() as u64); - if ctx.t[0] < (ctx.b.len() as u64) { - ctx.t[1] += 1; - } - blake2b_compress(ctx, false); - ctx.c = 0; - - data = &data[space_in_buffer .. ]; - bytes_to_copy -= space_in_buffer; - space_in_buffer = ctx.b.len(); - } - - if bytes_to_copy > 0 { - checked_mem_copy(data, &mut ctx.b[ctx.c .. ], bytes_to_copy); - ctx.c += bytes_to_copy; - } - - #[cfg(debug_assertions)] - { - // compute additional FNV hash for simpler to read debug output - const MAGIC_PRIME: u64 = 0x00000100000001b3; - - for &byte in data { - ctx.fnv_hash = (ctx.fnv_hash ^ byte as u64).wrapping_mul(MAGIC_PRIME); - } - } -} - -fn blake2b_final(ctx: &mut Blake2bCtx) -{ - assert!(!ctx.finalized, "Blake2bCtx already finalized"); - - ctx.t[0] = ctx.t[0].wrapping_add(ctx.c as u64); - if ctx.t[0] < ctx.c as u64 { - ctx.t[1] += 1; - } - - while ctx.c < 128 { - ctx.b[ctx.c] = 0; - ctx.c += 1; - } - - blake2b_compress(ctx, true); - - // Modify our buffer to little-endian format as it will be read - // as a byte array. It's OK to modify the buffer in place since - // this is the last time this data will be accessed. - if cfg!(target_endian = "big") { - for word in &mut ctx.h { - *word = word.to_le(); - } - } - - ctx.finalized = true; -} - -#[inline(always)] -fn checked_mem_copy(from: &[T1], to: &mut [T2], byte_count: usize) { - let from_size = from.len() * mem::size_of::(); - let to_size = to.len() * mem::size_of::(); - assert!(from_size >= byte_count); - assert!(to_size >= byte_count); - let from_byte_ptr = from.as_ptr() as * const u8; - let to_byte_ptr = to.as_mut_ptr() as * mut u8; - unsafe { - ::std::ptr::copy_nonoverlapping(from_byte_ptr, to_byte_ptr, byte_count); - } -} - -pub fn blake2b(out: &mut [u8], key: &[u8], data: &[u8]) -{ - let mut ctx = blake2b_new(out.len(), key); - blake2b_update(&mut ctx, data); - blake2b_final(&mut ctx); - checked_mem_copy(&ctx.h, out, ctx.outlen as usize); -} - -pub struct Blake2bHasher(Blake2bCtx); - -impl ::std::hash::Hasher for Blake2bHasher { - fn write(&mut self, bytes: &[u8]) { - blake2b_update(&mut self.0, bytes); - } - - fn finish(&self) -> u64 { - assert!(self.0.outlen == 8, - "Hasher initialized with incompatible output length"); - u64::from_le(self.0.h[0]) - } -} - -impl Blake2bHasher { - pub fn new(outlen: usize, key: &[u8]) -> Blake2bHasher { - Blake2bHasher(blake2b_new(outlen, key)) - } - - pub fn finalize(&mut self) -> &[u8] { - if !self.0.finalized { - blake2b_final(&mut self.0); - } - debug_assert!(mem::size_of_val(&self.0.h) >= self.0.outlen as usize); - let raw_ptr = (&self.0.h[..]).as_ptr() as * const u8; - unsafe { - slice::from_raw_parts(raw_ptr, self.0.outlen as usize) - } - } -} - -impl ::std::fmt::Debug for Blake2bHasher { - fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> { - write!(fmt, "{:?}", self.0) - } -} - -#[cfg(test)] -fn selftest_seq(out: &mut [u8], seed: u32) -{ - let mut a: u32 = 0xDEAD4BADu32.wrapping_mul(seed); - let mut b: u32 = 1; - - for i in 0 .. out.len() { - let t: u32 = a.wrapping_add(b); - a = b; - b = t; - out[i] = ((t >> 24) & 0xFF) as u8; - } -} - -#[test] -fn blake2b_selftest() -{ - use std::hash::Hasher; - - // grand hash of hash results - const BLAKE2B_RES: [u8; 32] = [ - 0xC2, 0x3A, 0x78, 0x00, 0xD9, 0x81, 0x23, 0xBD, - 0x10, 0xF5, 0x06, 0xC6, 0x1E, 0x29, 0xDA, 0x56, - 0x03, 0xD7, 0x63, 0xB8, 0xBB, 0xAD, 0x2E, 0x73, - 0x7F, 0x5E, 0x76, 0x5A, 0x7B, 0xCC, 0xD4, 0x75 - ]; - - // parameter sets - const B2B_MD_LEN: [usize; 4] = [20, 32, 48, 64]; - const B2B_IN_LEN: [usize; 6] = [0, 3, 128, 129, 255, 1024]; - - let mut data = [0u8; 1024]; - let mut md = [0u8; 64]; - let mut key = [0u8; 64]; - - let mut hasher = Blake2bHasher::new(32, &[]); - - for i in 0 .. 4 { - let outlen = B2B_MD_LEN[i]; - for j in 0 .. 6 { - let inlen = B2B_IN_LEN[j]; - - selftest_seq(&mut data[.. inlen], inlen as u32); // unkeyed hash - blake2b(&mut md[.. outlen], &[], &data[.. inlen]); - hasher.write(&md[.. outlen]); // hash the hash - - selftest_seq(&mut key[0 .. outlen], outlen as u32); // keyed hash - blake2b(&mut md[.. outlen], &key[.. outlen], &data[.. inlen]); - hasher.write(&md[.. outlen]); // hash the hash - } - } - - // compute and compare the hash of hashes - let md = hasher.finalize(); - for i in 0 .. 32 { - assert_eq!(md[i], BLAKE2B_RES[i]); - } -} diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index a35ef2f7ce7ba..37afe1bb066af 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -57,7 +57,6 @@ pub mod small_vec; pub mod base_n; pub mod bitslice; pub mod bitvec; -pub mod blake2b; pub mod graph; pub mod indexed_set; pub mod indexed_vec; From caa42e11bb6b7aea210ced552a157fa7de100d68 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Sun, 21 Jan 2018 19:28:55 -0700 Subject: [PATCH 021/198] Remove VecCell --- src/librustc_data_structures/lib.rs | 1 - src/librustc_data_structures/veccell/mod.rs | 47 --------------------- 2 files changed, 48 deletions(-) delete mode 100644 src/librustc_data_structures/veccell/mod.rs diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index 37afe1bb066af..33d760d0a1482 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -69,7 +69,6 @@ pub mod transitive_relation; pub mod unify; pub mod fx; pub mod tuple_slice; -pub mod veccell; pub mod control_flow_graph; pub mod flock; pub mod sync; diff --git a/src/librustc_data_structures/veccell/mod.rs b/src/librustc_data_structures/veccell/mod.rs deleted file mode 100644 index 054eee8829a4a..0000000000000 --- a/src/librustc_data_structures/veccell/mod.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::cell::UnsafeCell; -use std::mem; - -pub struct VecCell { - data: UnsafeCell>, -} - -impl VecCell { - pub fn with_capacity(capacity: usize) -> VecCell { - VecCell { data: UnsafeCell::new(Vec::with_capacity(capacity)) } - } - - #[inline] - pub fn push(&self, data: T) -> usize { - // The logic here, and in `swap` below, is that the `push` - // method on the vector will not recursively access this - // `VecCell`. Therefore, we can temporarily obtain mutable - // access, secure in the knowledge that even if aliases exist - // -- indeed, even if aliases are reachable from within the - // vector -- they will not be used for the duration of this - // particular fn call. (Note that we also are relying on the - // fact that `VecCell` is not `Sync`.) - unsafe { - let v = self.data.get(); - (*v).push(data); - (*v).len() - } - } - - pub fn swap(&self, mut data: Vec) -> Vec { - unsafe { - let v = self.data.get(); - mem::swap(&mut *v, &mut data); - } - data - } -} From ad058cfafe584e1848276a05c2b7b5d3fcc965ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Sun, 28 Jan 2018 19:48:39 +0100 Subject: [PATCH 022/198] Make pattern visiting consistent --- src/librustc/middle/region.rs | 6 ++++-- src/librustc_typeck/check/generator_interior.rs | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 66b3adb83c160..9d6b29adb0496 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -467,9 +467,10 @@ impl<'tcx> Visitor<'tcx> for ExprLocatorVisitor { } fn visit_pat(&mut self, pat: &'tcx Pat) { + intravisit::walk_pat(self, pat); + self.expr_and_pat_count += 1; - intravisit::walk_pat(self, pat); } fn visit_expr(&mut self, expr: &'tcx Expr) { @@ -814,7 +815,8 @@ impl<'tcx> ScopeTree { /// Checks whether the given scope contains a `yield`. If so, /// returns `Some((span, expr_count))` with the span of a yield we found and - /// the number of expressions appearing before the `yield` in the body. + /// the number of expressions and patterns appearing before the `yield` in the body + 1. + /// If there a are multiple yields in a scope, the one with the highest number is returned. pub fn yield_in_scope(&self, scope: Scope) -> Option<(Span, usize)> { self.yield_in_scope.get(&scope).cloned() } diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index 781eeaef2482c..2e45e3b1f3521 100644 --- a/src/librustc_typeck/check/generator_interior.rs +++ b/src/librustc_typeck/check/generator_interior.rs @@ -150,15 +150,15 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'gcx, 'tcx> { } fn visit_pat(&mut self, pat: &'tcx Pat) { + intravisit::walk_pat(self, pat); + + self.expr_count += 1; + if let PatKind::Binding(..) = pat.node { let scope = self.region_scope_tree.var_scope(pat.hir_id.local_id); let ty = self.fcx.tables.borrow().pat_ty(pat); self.record(ty, Some(scope), None, pat.span); } - - self.expr_count += 1; - - intravisit::walk_pat(self, pat); } fn visit_expr(&mut self, expr: &'tcx Expr) { From dd3fa07a522cb4f059a96f5e8d82f8d82c33d238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Sun, 28 Jan 2018 19:49:48 +0100 Subject: [PATCH 023/198] Make `yield_in_scope_for_expr` work with patterns. Fixes #47758 --- src/librustc/middle/region.rs | 3 +++ src/test/ui/generator/pattern-borrow.rs | 23 +++++++++++++++++++++ src/test/ui/generator/pattern-borrow.stderr | 10 +++++++++ 3 files changed, 36 insertions(+) create mode 100644 src/test/ui/generator/pattern-borrow.rs create mode 100644 src/test/ui/generator/pattern-borrow.stderr diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index 9d6b29adb0496..cbc061478f853 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -471,6 +471,9 @@ impl<'tcx> Visitor<'tcx> for ExprLocatorVisitor { self.expr_and_pat_count += 1; + if pat.id == self.id { + self.result = Some(self.expr_and_pat_count); + } } fn visit_expr(&mut self, expr: &'tcx Expr) { diff --git a/src/test/ui/generator/pattern-borrow.rs b/src/test/ui/generator/pattern-borrow.rs new file mode 100644 index 0000000000000..557a5e62f7e46 --- /dev/null +++ b/src/test/ui/generator/pattern-borrow.rs @@ -0,0 +1,23 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(generators)] + +enum Test { A(i32), B, } + +fn main() { } + +fn fun(test: Test) { + move || { + if let Test::A(ref _a) = test { //~ ERROR borrow may still be in use when generator yields + yield (); + } + }; +} diff --git a/src/test/ui/generator/pattern-borrow.stderr b/src/test/ui/generator/pattern-borrow.stderr new file mode 100644 index 0000000000000..6b39b272d0e42 --- /dev/null +++ b/src/test/ui/generator/pattern-borrow.stderr @@ -0,0 +1,10 @@ +error[E0626]: borrow may still be in use when generator yields + --> $DIR/pattern-borrow.rs:19:24 + | +19 | if let Test::A(ref _a) = test { //~ ERROR borrow may still be in use when generator yields + | ^^^^^^ +20 | yield (); + | -------- possible yield occurs here + +error: aborting due to previous error + From 7a6f68c87275fc1be2b0c3aa1455bead5c9dce18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Sun, 28 Jan 2018 19:50:48 +0100 Subject: [PATCH 024/198] Make error reporting work on generator upvars. Fixes #47793, #47805 --- src/librustc_mir/borrow_check/error_reporting.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index 7bd3b6e39f053..7fadc4b36e44f 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -746,12 +746,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { self.describe_field_from_ty(&tnm.ty, field) } ty::TyArray(ty, _) | ty::TySlice(ty) => self.describe_field_from_ty(&ty, field), - ty::TyClosure(closure_def_id, _) => { + ty::TyClosure(def_id, _) | ty::TyGenerator(def_id, _, _) => { // Convert the def-id into a node-id. node-ids are only valid for // the local code in the current crate, so this returns an `Option` in case // the closure comes from another crate. But in that case we wouldn't // be borrowck'ing it, so we can just unwrap: - let node_id = self.tcx.hir.as_local_node_id(closure_def_id).unwrap(); + let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap(); let freevar = self.tcx.with_freevars(node_id, |fv| fv[field.index()]); self.tcx.hir.name(freevar.var_id()).to_string() From 77bc26f4f3cb5f053dbe72b363b55a53f626f0cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Sun, 28 Jan 2018 20:23:49 +0100 Subject: [PATCH 025/198] Require yield types to be sized --- src/librustc/traits/error_reporting.rs | 4 ++++ src/librustc/traits/mod.rs | 2 ++ src/librustc/traits/structural_impls.rs | 3 +++ src/librustc_typeck/check/mod.rs | 4 +++- src/test/ui/generator/sized-yield.rs | 21 +++++++++++++++++++++ src/test/ui/generator/sized-yield.stderr | 22 ++++++++++++++++++++++ 6 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/generator/sized-yield.rs create mode 100644 src/test/ui/generator/sized-yield.stderr diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 42200a3a44728..3cb9449901d0b 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -1261,6 +1261,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { err.note("the return type of a function must have a \ statically known size"); } + ObligationCauseCode::SizedYieldType => { + err.note("the yield type of a generator must have a \ + statically known size"); + } ObligationCauseCode::AssignmentLhsSized => { err.note("the left-hand-side of an assignment must have a statically known size"); } diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index fd47e09aad7f9..5bfa6f936db7d 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -138,6 +138,8 @@ pub enum ObligationCauseCode<'tcx> { VariableType(ast::NodeId), /// Return type must be Sized SizedReturnType, + /// Yield type must be Sized + SizedYieldType, /// [T,..n] --> T must be Copy RepeatVec, diff --git a/src/librustc/traits/structural_impls.rs b/src/librustc/traits/structural_impls.rs index e1e2798ecb51c..1eb14a222787d 100644 --- a/src/librustc/traits/structural_impls.rs +++ b/src/librustc/traits/structural_impls.rs @@ -209,6 +209,7 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> { super::VariableType(id) => Some(super::VariableType(id)), super::ReturnType(id) => Some(super::ReturnType(id)), super::SizedReturnType => Some(super::SizedReturnType), + super::SizedYieldType => Some(super::SizedYieldType), super::RepeatVec => Some(super::RepeatVec), super::FieldSized(item) => Some(super::FieldSized(item)), super::ConstSized => Some(super::ConstSized), @@ -526,6 +527,7 @@ impl<'tcx> TypeFoldable<'tcx> for traits::ObligationCauseCode<'tcx> { super::VariableType(_) | super::ReturnType(_) | super::SizedReturnType | + super::SizedYieldType | super::ReturnNoExpression | super::RepeatVec | super::FieldSized(_) | @@ -574,6 +576,7 @@ impl<'tcx> TypeFoldable<'tcx> for traits::ObligationCauseCode<'tcx> { super::VariableType(_) | super::ReturnType(_) | super::SizedReturnType | + super::SizedYieldType | super::ReturnNoExpression | super::RepeatVec | super::FieldSized(_) | diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 9b24c09036bce..098a98a8d92f3 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -1001,7 +1001,9 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, let span = body.value.span; if body.is_generator && can_be_generator.is_some() { - fcx.yield_ty = Some(fcx.next_ty_var(TypeVariableOrigin::TypeInference(span))); + let yield_ty = fcx.next_ty_var(TypeVariableOrigin::TypeInference(span)); + fcx.require_type_is_sized(yield_ty, span, traits::SizedYieldType); + fcx.yield_ty = Some(yield_ty); } GatherLocalsVisitor { fcx: &fcx, }.visit_body(body); diff --git a/src/test/ui/generator/sized-yield.rs b/src/test/ui/generator/sized-yield.rs new file mode 100644 index 0000000000000..f38ebf8b94636 --- /dev/null +++ b/src/test/ui/generator/sized-yield.rs @@ -0,0 +1,21 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(generators, generator_trait)] + +use std::ops::Generator; + +fn main() { + let s = String::from("foo"); + let mut gen = move || { //~ ERROR the trait bound `str: std::marker::Sized` is not satisfied + yield s[..]; + }; + gen.resume(); //~ ERROR the trait bound `str: std::marker::Sized` is not satisfied +} diff --git a/src/test/ui/generator/sized-yield.stderr b/src/test/ui/generator/sized-yield.stderr new file mode 100644 index 0000000000000..7adb2cc5598dc --- /dev/null +++ b/src/test/ui/generator/sized-yield.stderr @@ -0,0 +1,22 @@ +error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied + --> $DIR/sized-yield.rs:17:26 + | +17 | let mut gen = move || { //~ ERROR the trait bound `str: std::marker::Sized` is not satisfied + | __________________________^ +18 | | yield s[..]; +19 | | }; + | |____^ `str` does not have a constant size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `str` + = note: the yield type of a generator must have a statically known size + +error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied + --> $DIR/sized-yield.rs:20:8 + | +20 | gen.resume(); //~ ERROR the trait bound `str: std::marker::Sized` is not satisfied + | ^^^^^^ `str` does not have a constant size known at compile-time + | + = help: the trait `std::marker::Sized` is not implemented for `str` + +error: aborting due to 2 previous errors + From df1c61d303c6557434e3dc0dd8d32eb3599d8b40 Mon Sep 17 00:00:00 2001 From: varkor Date: Fri, 5 Jan 2018 00:31:40 +0000 Subject: [PATCH 026/198] Warn when rustc output conflicts with existing directories MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When the compiled executable would conflict with a directory, display a rustc error instead of a verbose and potentially-confusing linker error. This is a usability improvement, and doesn’t actually change behaviour with regards to compilation success. This addresses the concern in #35887. --- src/librustc/session/config.rs | 38 ++++++++++++++----- src/librustc_driver/driver.rs | 19 +++++++--- .../Makefile | 7 ++++ .../foo.rs | 11 ++++++ 4 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 src/test/run-make/output-filename-conflicts-with-directory/Makefile create mode 100644 src/test/run-make/output-filename-conflicts-with-directory/foo.rs diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index b9546143a054b..b04376000c0e2 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -549,24 +549,44 @@ impl OutputFilenames { format!("{}{}", self.out_filestem, self.extra) } - pub fn contains_path(&self, input_path: &PathBuf) -> bool { - let input_path = input_path.canonicalize().ok(); - if input_path.is_none() { - return false - } + fn check_output(&self, f: F) -> Option where F: Fn(PathBuf) -> Option { match self.single_output_file { - Some(ref output_path) => output_path.canonicalize().ok() == input_path, + Some(ref output_path) => { + f(output_path.clone()) + }, None => { for k in self.outputs.keys() { let output_path = self.path(k.to_owned()); - if output_path.canonicalize().ok() == input_path { - return true; + if let Some(result) = f(output_path) { + return Some(result); } } - false + None } } } + + pub fn contains_path(&self, input_path: &PathBuf) -> bool { + let input_path = input_path.canonicalize().ok(); + if input_path.is_none() { + return false + } + let check = |output_path: PathBuf| { + if output_path.canonicalize().ok() == input_path { + Some(()) + } else { None } + }; + self.check_output(check).is_some() + } + + pub fn conflicts_with_dir(&self) -> Option { + let check = |output_path: PathBuf| { + if output_path.is_dir() { + Some(output_path) + } else { None } + }; + self.check_output(check) + } } pub fn host_triple() -> &'static str { diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index e97d83ed1ee5a..5875ccbfd585d 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -125,11 +125,20 @@ pub fn compile_input(trans: Box, // Ensure the source file isn't accidentally overwritten during compilation. match *input_path { Some(ref input_path) => { - if outputs.contains_path(input_path) && sess.opts.will_create_output_file() { - sess.err(&format!( - "the input file \"{}\" would be overwritten by the generated executable", - input_path.display())); - return Err(CompileIncomplete::Stopped); + if sess.opts.will_create_output_file() { + if outputs.contains_path(input_path) { + sess.err(&format!( + "the input file \"{}\" would be overwritten by the generated executable", + input_path.display())); + return Err(CompileIncomplete::Stopped); + } + if let Some(dir_path) = outputs.conflicts_with_dir() { + sess.err(&format!( + "the generated executable for the input file \"{}\" conflicts with the \ + existing directory \"{}\'", + input_path.display(), dir_path.display())); + return Err(CompileIncomplete::Stopped); + } } }, None => {} diff --git a/src/test/run-make/output-filename-conflicts-with-directory/Makefile b/src/test/run-make/output-filename-conflicts-with-directory/Makefile new file mode 100644 index 0000000000000..68f72094ce65c --- /dev/null +++ b/src/test/run-make/output-filename-conflicts-with-directory/Makefile @@ -0,0 +1,7 @@ +-include ../tools.mk + +all: + cp foo.rs $(TMPDIR)/foo.rs + mkdir $(TMPDIR)/foo + $(RUSTC) $(TMPDIR)/foo.rs 2>&1 \ + | $(CGREP) -e "the generated executable for the input file \".*foo\.rs\" conflicts with the existing directory \".*foo\'" diff --git a/src/test/run-make/output-filename-conflicts-with-directory/foo.rs b/src/test/run-make/output-filename-conflicts-with-directory/foo.rs new file mode 100644 index 0000000000000..046d27a9f0fe5 --- /dev/null +++ b/src/test/run-make/output-filename-conflicts-with-directory/foo.rs @@ -0,0 +1,11 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() {} From dc274e68a7085491519cb4f3c5613c0321751c6f Mon Sep 17 00:00:00 2001 From: varkor Date: Fri, 5 Jan 2018 00:41:37 +0000 Subject: [PATCH 027/198] Fix tidy error --- src/librustc_driver/driver.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 5875ccbfd585d..c6b51f69406d8 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -128,7 +128,8 @@ pub fn compile_input(trans: Box, if sess.opts.will_create_output_file() { if outputs.contains_path(input_path) { sess.err(&format!( - "the input file \"{}\" would be overwritten by the generated executable", + "the input file \"{}\" would be overwritten by the generated \ + executable", input_path.display())); return Err(CompileIncomplete::Stopped); } From 3d55974be4142244d98007c9557ac93e9b9b7d0d Mon Sep 17 00:00:00 2001 From: varkor Date: Fri, 5 Jan 2018 10:15:52 +0000 Subject: [PATCH 028/198] Fix quotation mark --- src/librustc_driver/driver.rs | 2 +- .../run-make/output-filename-conflicts-with-directory/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index c6b51f69406d8..05bf5e5a7d94d 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -136,7 +136,7 @@ pub fn compile_input(trans: Box, if let Some(dir_path) = outputs.conflicts_with_dir() { sess.err(&format!( "the generated executable for the input file \"{}\" conflicts with the \ - existing directory \"{}\'", + existing directory \"{}\"", input_path.display(), dir_path.display())); return Err(CompileIncomplete::Stopped); } diff --git a/src/test/run-make/output-filename-conflicts-with-directory/Makefile b/src/test/run-make/output-filename-conflicts-with-directory/Makefile index 68f72094ce65c..74dea9ce72bfd 100644 --- a/src/test/run-make/output-filename-conflicts-with-directory/Makefile +++ b/src/test/run-make/output-filename-conflicts-with-directory/Makefile @@ -4,4 +4,4 @@ all: cp foo.rs $(TMPDIR)/foo.rs mkdir $(TMPDIR)/foo $(RUSTC) $(TMPDIR)/foo.rs 2>&1 \ - | $(CGREP) -e "the generated executable for the input file \".*foo\.rs\" conflicts with the existing directory \".*foo\'" + | $(CGREP) -e "the generated executable for the input file \".*foo\.rs\" conflicts with the existing directory \".*foo\"" From 45e962ecc023749fed2bb926c3386059c8e1407a Mon Sep 17 00:00:00 2001 From: varkor Date: Sun, 7 Jan 2018 01:11:23 +0000 Subject: [PATCH 029/198] Use correct output file paths for error checking --- src/librustc/session/config.rs | 39 -------------- src/librustc_driver/driver.rs | 96 ++++++++++++++++++++++++---------- 2 files changed, 69 insertions(+), 66 deletions(-) diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index b04376000c0e2..af91e294db6db 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -548,45 +548,6 @@ impl OutputFilenames { pub fn filestem(&self) -> String { format!("{}{}", self.out_filestem, self.extra) } - - fn check_output(&self, f: F) -> Option where F: Fn(PathBuf) -> Option { - match self.single_output_file { - Some(ref output_path) => { - f(output_path.clone()) - }, - None => { - for k in self.outputs.keys() { - let output_path = self.path(k.to_owned()); - if let Some(result) = f(output_path) { - return Some(result); - } - } - None - } - } - } - - pub fn contains_path(&self, input_path: &PathBuf) -> bool { - let input_path = input_path.canonicalize().ok(); - if input_path.is_none() { - return false - } - let check = |output_path: PathBuf| { - if output_path.canonicalize().ok() == input_path { - Some(()) - } else { None } - }; - self.check_output(check).is_some() - } - - pub fn conflicts_with_dir(&self) -> Option { - let check = |output_path: PathBuf| { - if output_path.is_dir() { - Some(output_path) - } else { None } - }; - self.check_output(check) - } } pub fn host_triple() -> &'static str { diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 05bf5e5a7d94d..a8ba795845fc9 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -121,19 +121,41 @@ pub fn compile_input(trans: Box, }; let outputs = build_output_filenames(input, outdir, output, &krate.attrs, sess); + let crate_name = + ::rustc_trans_utils::link::find_crate_name(Some(sess), &krate.attrs, input); + let ExpansionResult { expanded_crate, defs, analysis, resolutions, mut hir_forest } = { + phase_2_configure_and_expand( + sess, + &cstore, + krate, + registry, + &crate_name, + addl_plugins, + control.make_glob_map, + |expanded_crate| { + let mut state = CompileState::state_after_expand( + input, sess, outdir, output, &cstore, expanded_crate, &crate_name, + ); + controller_entry_point!(after_expand, sess, state, Ok(())); + Ok(()) + } + )? + }; + + let output_paths = generated_output_paths(sess, &outputs, &crate_name); // Ensure the source file isn't accidentally overwritten during compilation. match *input_path { Some(ref input_path) => { if sess.opts.will_create_output_file() { - if outputs.contains_path(input_path) { + if output_contains_path(&output_paths, input_path) { sess.err(&format!( "the input file \"{}\" would be overwritten by the generated \ executable", input_path.display())); return Err(CompileIncomplete::Stopped); } - if let Some(dir_path) = outputs.conflicts_with_dir() { + if let Some(dir_path) = output_conflicts_with_dir(&output_paths) { sess.err(&format!( "the generated executable for the input file \"{}\" conflicts with the \ existing directory \"{}\"", @@ -145,29 +167,7 @@ pub fn compile_input(trans: Box, None => {} } - let crate_name = - ::rustc_trans_utils::link::find_crate_name(Some(sess), &krate.attrs, input); - - let ExpansionResult { expanded_crate, defs, analysis, resolutions, mut hir_forest } = { - phase_2_configure_and_expand( - sess, - &cstore, - krate, - registry, - &crate_name, - addl_plugins, - control.make_glob_map, - |expanded_crate| { - let mut state = CompileState::state_after_expand( - input, sess, outdir, output, &cstore, expanded_crate, &crate_name, - ); - controller_entry_point!(after_expand, sess, state, Ok(())); - Ok(()) - } - )? - }; - - write_out_deps(sess, &outputs, &crate_name); + write_out_deps(sess, &outputs, &output_paths); if sess.opts.output_types.contains_key(&OutputType::DepInfo) && sess.opts.output_types.keys().count() == 1 { return Ok(()) @@ -1111,7 +1111,10 @@ fn escape_dep_filename(filename: &FileName) -> String { filename.to_string().replace(" ", "\\ ") } -fn write_out_deps(sess: &Session, outputs: &OutputFilenames, crate_name: &str) { +// Returns all the paths that correspond to generated files. +fn generated_output_paths(sess: &Session, + outputs: &OutputFilenames, + crate_name: &str) -> Vec { let mut out_filenames = Vec::new(); for output_type in sess.opts.output_types.keys() { let file = outputs.path(*output_type); @@ -1135,7 +1138,46 @@ fn write_out_deps(sess: &Session, outputs: &OutputFilenames, crate_name: &str) { } } } + out_filenames +} + +// Runs `f` on every output file path and returns the first non-None result, or None if `f` +// returns None for every file path. +fn check_output(output_paths: &Vec, f: F) -> Option + where F: Fn(&PathBuf) -> Option { + for output_path in output_paths { + if let Some(result) = f(output_path) { + return Some(result); + } + } + None +} + +pub fn output_contains_path(output_paths: &Vec, input_path: &PathBuf) -> bool { + let input_path = input_path.canonicalize().ok(); + if input_path.is_none() { + return false + } + let check = |output_path: &PathBuf| { + if output_path.canonicalize().ok() == input_path { + Some(()) + } else { None } + }; + check_output(output_paths, check).is_some() +} + +pub fn output_conflicts_with_dir(output_paths: &Vec) -> Option { + let check = |output_path: &PathBuf| { + if output_path.is_dir() { + Some(output_path.clone()) + } else { None } + }; + check_output(output_paths, check) +} +fn write_out_deps(sess: &Session, + outputs: &OutputFilenames, + out_filenames: &Vec) { // Write out dependency rules to the dep-info file if requested if !sess.opts.output_types.contains_key(&OutputType::DepInfo) { return; @@ -1154,7 +1196,7 @@ fn write_out_deps(sess: &Session, outputs: &OutputFilenames, crate_name: &str) { .map(|fmap| escape_dep_filename(&fmap.name)) .collect(); let mut file = fs::File::create(&deps_filename)?; - for path in &out_filenames { + for path in out_filenames { write!(file, "{}: {}\n\n", path.display(), files.join(" "))?; } From ba76092c2ef771f4b4463ec5e879f12194e59ec5 Mon Sep 17 00:00:00 2001 From: varkor Date: Sun, 7 Jan 2018 12:03:24 +0000 Subject: [PATCH 030/198] Fix tidy error --- src/librustc_driver/driver.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index a8ba795845fc9..4fe51138f9a51 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -141,7 +141,7 @@ pub fn compile_input(trans: Box, } )? }; - + let output_paths = generated_output_paths(sess, &outputs, &crate_name); // Ensure the source file isn't accidentally overwritten during compilation. From d97da7d536b85bda9ff9255b1cd27f1285143930 Mon Sep 17 00:00:00 2001 From: varkor Date: Tue, 9 Jan 2018 19:55:36 +0000 Subject: [PATCH 031/198] Minor refactoring --- src/librustc_driver/driver.rs | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 4fe51138f9a51..1ab5f19c2e2a3 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -145,26 +145,23 @@ pub fn compile_input(trans: Box, let output_paths = generated_output_paths(sess, &outputs, &crate_name); // Ensure the source file isn't accidentally overwritten during compilation. - match *input_path { - Some(ref input_path) => { - if sess.opts.will_create_output_file() { - if output_contains_path(&output_paths, input_path) { - sess.err(&format!( - "the input file \"{}\" would be overwritten by the generated \ - executable", - input_path.display())); - return Err(CompileIncomplete::Stopped); - } - if let Some(dir_path) = output_conflicts_with_dir(&output_paths) { - sess.err(&format!( - "the generated executable for the input file \"{}\" conflicts with the \ - existing directory \"{}\"", - input_path.display(), dir_path.display())); - return Err(CompileIncomplete::Stopped); - } + if let Some(ref input_path) = *input_path { + if sess.opts.will_create_output_file() { + if output_contains_path(&output_paths, input_path) { + sess.err(&format!( + "the input file \"{}\" would be overwritten by the generated \ + executable", + input_path.display())); + return Err(CompileIncomplete::Stopped); } - }, - None => {} + if let Some(dir_path) = output_conflicts_with_dir(&output_paths) { + sess.err(&format!( + "the generated executable for the input file \"{}\" conflicts with the \ + existing directory \"{}\"", + input_path.display(), dir_path.display())); + return Err(CompileIncomplete::Stopped); + } + } } write_out_deps(sess, &outputs, &output_paths); From 9a2f02df6655f65e5a7892e853cc2112e28b89e8 Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 29 Jan 2018 12:50:36 +0000 Subject: [PATCH 032/198] Warn when `-C extra-filename` flag is used with `-o` --- src/librustc_driver/driver.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 1ab5f19c2e2a3..df8860823add0 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -1378,6 +1378,9 @@ pub fn build_output_filenames(input: &Input, if *odir != None { sess.warn("ignoring --out-dir flag due to -o flag."); } + if !sess.opts.cg.extra_filename.is_empty() { + sess.warn("ignoring -C extra-filename flag due to -o flag."); + } let cur_dir = Path::new(""); From e92bdb9828ff19afc92c292b289be1790f2ee116 Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 29 Jan 2018 14:38:50 +0000 Subject: [PATCH 033/198] Specify output filenames for compatibility with Windows --- src/librustc_driver/driver.rs | 15 +++++++++------ .../Makefile | 2 +- .../foo.rs | 2 +- .../output-filename-overwrites-input/Makefile | 5 ++++- .../output-filename-overwrites-input/bar.rs | 11 +++++++++++ .../output-filename-overwrites-input/foo.rs | 2 +- 6 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 src/test/run-make/output-filename-overwrites-input/bar.rs diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index df8860823add0..50c19b5a99a54 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -142,7 +142,7 @@ pub fn compile_input(trans: Box, )? }; - let output_paths = generated_output_paths(sess, &outputs, &crate_name); + let output_paths = generated_output_paths(sess, &outputs, output.is_some(), &crate_name); // Ensure the source file isn't accidentally overwritten during compilation. if let Some(ref input_path) = *input_path { @@ -1111,16 +1111,19 @@ fn escape_dep_filename(filename: &FileName) -> String { // Returns all the paths that correspond to generated files. fn generated_output_paths(sess: &Session, outputs: &OutputFilenames, + exact_name: bool, crate_name: &str) -> Vec { let mut out_filenames = Vec::new(); for output_type in sess.opts.output_types.keys() { let file = outputs.path(*output_type); match *output_type { - OutputType::Exe => { - for output in sess.crate_types.borrow().iter() { + // If the filename has been overridden using `-o`, it will not be modified + // by appending `.rlib`, `.exe`, etc., so we can skip this transformation. + OutputType::Exe if !exact_name => { + for crate_type in sess.crate_types.borrow().iter() { let p = ::rustc_trans_utils::link::filename_for_input( sess, - *output, + *crate_type, crate_name, outputs ); @@ -1376,10 +1379,10 @@ pub fn build_output_filenames(input: &Input, Some(out_file.clone()) }; if *odir != None { - sess.warn("ignoring --out-dir flag due to -o flag."); + sess.warn("ignoring --out-dir flag due to -o flag"); } if !sess.opts.cg.extra_filename.is_empty() { - sess.warn("ignoring -C extra-filename flag due to -o flag."); + sess.warn("ignoring -C extra-filename flag due to -o flag"); } let cur_dir = Path::new(""); diff --git a/src/test/run-make/output-filename-conflicts-with-directory/Makefile b/src/test/run-make/output-filename-conflicts-with-directory/Makefile index 74dea9ce72bfd..74e5dcfcf36c2 100644 --- a/src/test/run-make/output-filename-conflicts-with-directory/Makefile +++ b/src/test/run-make/output-filename-conflicts-with-directory/Makefile @@ -3,5 +3,5 @@ all: cp foo.rs $(TMPDIR)/foo.rs mkdir $(TMPDIR)/foo - $(RUSTC) $(TMPDIR)/foo.rs 2>&1 \ + $(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo 2>&1 \ | $(CGREP) -e "the generated executable for the input file \".*foo\.rs\" conflicts with the existing directory \".*foo\"" diff --git a/src/test/run-make/output-filename-conflicts-with-directory/foo.rs b/src/test/run-make/output-filename-conflicts-with-directory/foo.rs index 046d27a9f0fe5..3f07b46791d22 100644 --- a/src/test/run-make/output-filename-conflicts-with-directory/foo.rs +++ b/src/test/run-make/output-filename-conflicts-with-directory/foo.rs @@ -1,4 +1,4 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/run-make/output-filename-overwrites-input/Makefile b/src/test/run-make/output-filename-overwrites-input/Makefile index 0554627d67753..6377038b7be74 100644 --- a/src/test/run-make/output-filename-overwrites-input/Makefile +++ b/src/test/run-make/output-filename-overwrites-input/Makefile @@ -2,8 +2,11 @@ all: cp foo.rs $(TMPDIR)/foo - $(RUSTC) $(TMPDIR)/foo 2>&1 \ + $(RUSTC) $(TMPDIR)/foo -o $(TMPDIR)/foo 2>&1 \ | $(CGREP) -e "the input file \".*foo\" would be overwritten by the generated executable" + cp bar.rs $(TMPDIR)/bar.rlib + $(RUSTC) $(TMPDIR)/bar.rlib -o $(TMPDIR)/bar.rlib 2>&1 \ + | $(CGREP) -e "the input file \".*bar.rlib\" would be overwritten by the generated executable" $(RUSTC) foo.rs 2>&1 && $(RUSTC) -Z ls $(TMPDIR)/foo 2>&1 cp foo.rs $(TMPDIR)/foo.rs $(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo.rs 2>&1 \ diff --git a/src/test/run-make/output-filename-overwrites-input/bar.rs b/src/test/run-make/output-filename-overwrites-input/bar.rs new file mode 100644 index 0000000000000..8e4e35fdee66e --- /dev/null +++ b/src/test/run-make/output-filename-overwrites-input/bar.rs @@ -0,0 +1,11 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] diff --git a/src/test/run-make/output-filename-overwrites-input/foo.rs b/src/test/run-make/output-filename-overwrites-input/foo.rs index 046d27a9f0fe5..3f07b46791d22 100644 --- a/src/test/run-make/output-filename-overwrites-input/foo.rs +++ b/src/test/run-make/output-filename-overwrites-input/foo.rs @@ -1,4 +1,4 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // From 79d85dab88536a66efdf550d687591b1bc53c022 Mon Sep 17 00:00:00 2001 From: varkor Date: Mon, 29 Jan 2018 16:31:14 +0000 Subject: [PATCH 034/198] Create a directory for --out-dir if it does not already exist MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently if `--out-dir` is set to a non-existent directory, the compiler will throw unfriendly messages like `error: could not write output to subdir/example.crate.allocator.rcgu.o: No such file or directory`, which, while not completely unreadable, isn’t very user-friendly either. This change creates the directory automatically if it does not yet exist. --- src/librustc_driver/driver.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index e97d83ed1ee5a..ed680feae0aa5 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -163,6 +163,13 @@ pub fn compile_input(trans: Box, return Ok(()) } + if let &Some(ref dir) = outdir { + if fs::create_dir_all(dir).is_err() { + sess.err("failed to find or create the directory specified by --out-dir"); + return Err(CompileIncomplete::Stopped); + } + } + let arenas = AllArenas::new(); // Construct the HIR map From 1a043533f504145fa51beeb6c94765e6865031ee Mon Sep 17 00:00:00 2001 From: Clar Charr Date: Fri, 22 Dec 2017 21:43:09 -0500 Subject: [PATCH 035/198] Document std::os::raw. --- src/libstd/lib.rs | 1 + src/libstd/os/raw/char.md | 11 +++++++++ src/libstd/os/raw/double.md | 6 +++++ src/libstd/os/raw/float.md | 5 ++++ src/libstd/os/raw/int.md | 6 +++++ src/libstd/os/raw/long.md | 8 +++++++ src/libstd/os/raw/longlong.md | 6 +++++ src/libstd/os/{raw.rs => raw/mod.rs} | 34 ++++++++++++++++++++++++---- src/libstd/os/raw/schar.md | 6 +++++ src/libstd/os/raw/short.md | 6 +++++ src/libstd/os/raw/uchar.md | 6 +++++ src/libstd/os/raw/uint.md | 6 +++++ src/libstd/os/raw/ulong.md | 8 +++++++ src/libstd/os/raw/ulonglong.md | 6 +++++ src/libstd/os/raw/ushort.md | 6 +++++ 15 files changed, 116 insertions(+), 5 deletions(-) create mode 100644 src/libstd/os/raw/char.md create mode 100644 src/libstd/os/raw/double.md create mode 100644 src/libstd/os/raw/float.md create mode 100644 src/libstd/os/raw/int.md create mode 100644 src/libstd/os/raw/long.md create mode 100644 src/libstd/os/raw/longlong.md rename src/libstd/os/{raw.rs => raw/mod.rs} (78%) create mode 100644 src/libstd/os/raw/schar.md create mode 100644 src/libstd/os/raw/short.md create mode 100644 src/libstd/os/raw/uchar.md create mode 100644 src/libstd/os/raw/uint.md create mode 100644 src/libstd/os/raw/ulong.md create mode 100644 src/libstd/os/raw/ulonglong.md create mode 100644 src/libstd/os/raw/ushort.md diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index a8049e676b3bb..642fa8775a479 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -260,6 +260,7 @@ #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] #![feature(exact_size_is_empty)] +#![feature(external_doc)] #![feature(fs_read_write)] #![feature(fixed_size_array)] #![feature(float_from_str_radix)] diff --git a/src/libstd/os/raw/char.md b/src/libstd/os/raw/char.md new file mode 100644 index 0000000000000..fb47dff187e5c --- /dev/null +++ b/src/libstd/os/raw/char.md @@ -0,0 +1,11 @@ +Equivalent to C's `char` type. + +[C's `char` type] is completely unlike [Rust's `char` type]; while Rust's type represents a unicode scalar value, C's `char` type is just an ordinary integer. In practice, this type will always be either [`i8`] or [`u8`], but you're technically not supposed to rely on this behaviour, as the standard only defines a char as being at least eight bits long. + +C chars are most commonly used to make C strings. Unlike Rust, where the length of a string is included alongside the string, C strings mark the end of a string with a zero. See [`CStr`] for more information. + +[C's `char` type]: https://en.wikipedia.org/wiki/C_data_types#Basic_types +[Rust's `char` type]: ../../primitive.char.html +[`CStr`]: ../../ffi/struct.CStr.html +[`i8`]: ../../primitive.i8.html +[`u8`]: ../../primitive.u8.html diff --git a/src/libstd/os/raw/double.md b/src/libstd/os/raw/double.md new file mode 100644 index 0000000000000..5ac09ee284c10 --- /dev/null +++ b/src/libstd/os/raw/double.md @@ -0,0 +1,6 @@ +Equivalent to C's `double` type. + +This type will almost always be [`f64`], however, the standard technically only guarantees that it be a floating-point number with at least the precision of a [`float`]. + +[`float`]: type.c_float.html +[`f64`]: ../../primitive.f64.html diff --git a/src/libstd/os/raw/float.md b/src/libstd/os/raw/float.md new file mode 100644 index 0000000000000..20ba8645055b1 --- /dev/null +++ b/src/libstd/os/raw/float.md @@ -0,0 +1,5 @@ +Equivalent to C's `float` type. + +This type will almost always be [`f32`], however, the standard technically only guarantees that it be a floating-point number. + +[`f32`]: ../../primitive.f32.html diff --git a/src/libstd/os/raw/int.md b/src/libstd/os/raw/int.md new file mode 100644 index 0000000000000..efe7786099ab1 --- /dev/null +++ b/src/libstd/os/raw/int.md @@ -0,0 +1,6 @@ +Equivalent to C's `signed int` (`int`) type. + +This type will almost always be [`i32`], however, the standard technically only requires that it be at least the size of a [`short`]. + +[`short`]: type.c_short.html +[`i32`]: ../../primitive.i32.html diff --git a/src/libstd/os/raw/long.md b/src/libstd/os/raw/long.md new file mode 100644 index 0000000000000..c281e01733674 --- /dev/null +++ b/src/libstd/os/raw/long.md @@ -0,0 +1,8 @@ +Equivalent to C's `signed long` (`long`) type. + +This type will usually be [`i64`], but is sometimes [`i32`] \(i.e. [`isize`]\) on 32-bit systems. Technically, the standard only requires that it be at least 32 bits, or at least the size of an [`int`]. + +[`int`]: type.c_int.html +[`i32`]: ../../primitive.i32.html +[`i64`]: ../../primitive.i64.html +[`isize`]: ../../primitive.isize.html diff --git a/src/libstd/os/raw/longlong.md b/src/libstd/os/raw/longlong.md new file mode 100644 index 0000000000000..6594fcd564c50 --- /dev/null +++ b/src/libstd/os/raw/longlong.md @@ -0,0 +1,6 @@ +Equivalent to C's `signed long long` (`long long`) type. + +This type will almost always be [`i64`], however, the standard technically only requires that it be at least 64 bits, or at least the size of an [`long`]. + +[`long`]: type.c_int.html +[`i64`]: ../../primitive.i64.html diff --git a/src/libstd/os/raw.rs b/src/libstd/os/raw/mod.rs similarity index 78% rename from src/libstd/os/raw.rs rename to src/libstd/os/raw/mod.rs index 279caf8053a85..e96ba045ce700 100644 --- a/src/libstd/os/raw.rs +++ b/src/libstd/os/raw/mod.rs @@ -8,12 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Raw OS-specific types for the current platform/architecture +//! Platform-specific types, as defined by C. +//! +//! Code that interacts via FFI will almost certainly be using the +//! base types provided by C, which aren't nearly as nicely defined +//! as Rust's primitive types. This module provides types which will +//! match those defined by C, so that code that interacts with C will +//! refer to the correct types. #![stable(feature = "raw_os", since = "1.1.0")] use fmt; +#[doc(include = "os/raw/char.md")] #[cfg(any(all(target_os = "linux", any(target_arch = "aarch64", target_arch = "arm", target_arch = "powerpc", @@ -25,6 +32,7 @@ use fmt; all(target_os = "openbsd", target_arch = "aarch64"), all(target_os = "fuchsia", target_arch = "aarch64")))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = u8; +#[doc(include = "os/raw/char.md")] #[cfg(not(any(all(target_os = "linux", any(target_arch = "aarch64", target_arch = "arm", target_arch = "powerpc", @@ -36,30 +44,46 @@ use fmt; all(target_os = "openbsd", target_arch = "aarch64"), all(target_os = "fuchsia", target_arch = "aarch64"))))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = i8; +#[doc(include = "os/raw/schar.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_schar = i8; +#[doc(include = "os/raw/uchar.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_uchar = u8; +#[doc(include = "os/raw/short.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_short = i16; +#[doc(include = "os/raw/ushort.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_ushort = u16; +#[doc(include = "os/raw/int.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_int = i32; +#[doc(include = "os/raw/uint.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_uint = u32; +#[doc(include = "os/raw/long.md")] #[cfg(any(target_pointer_width = "32", windows))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_long = i32; +#[doc(include = "os/raw/ulong.md")] #[cfg(any(target_pointer_width = "32", windows))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_ulong = u32; +#[doc(include = "os/raw/long.md")] #[cfg(all(target_pointer_width = "64", not(windows)))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_long = i64; +#[doc(include = "os/raw/ulong.md")] #[cfg(all(target_pointer_width = "64", not(windows)))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_ulong = u64; +#[doc(include = "os/raw/longlong.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_longlong = i64; +#[doc(include = "os/raw/ulonglong.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_ulonglong = u64; +#[doc(include = "os/raw/float.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_float = f32; +#[doc(include = "os/raw/double.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_double = f64; -/// Type used to construct void pointers for use with C. +/// Equivalent to C's `void` type when used as a [pointer]. /// -/// This type is only useful as a pointer target. Do not use it as a -/// return type for FFI functions which have the `void` return type in -/// C. Use the unit type `()` or omit the return type instead. +/// In essence, `*const c_void` is equivalent to C's `const void*` +/// and `*mut c_void` is equivalent to C's `void*`. That said, this is +/// *not* the same as C's `void` return type, which is Rust's `()` type. +/// +/// [pointer]: ../primitive.pointer.html // NB: For LLVM to recognize the void pointer type and by extension // functions like malloc(), we need to have it represented as i8* in // LLVM bitcode. The enum used here ensures this and prevents misuse diff --git a/src/libstd/os/raw/schar.md b/src/libstd/os/raw/schar.md new file mode 100644 index 0000000000000..42a403ef5d785 --- /dev/null +++ b/src/libstd/os/raw/schar.md @@ -0,0 +1,6 @@ +Equivalent to C's `signed char` type. + +This type will almost always be [`i8`], but its size is technically equal to the size of a C [`char`], which isn't very clear-cut. + +[`char`]: type.c_char.html +[`i8`]: ../../primitive.i8.html diff --git a/src/libstd/os/raw/short.md b/src/libstd/os/raw/short.md new file mode 100644 index 0000000000000..86a8495eae232 --- /dev/null +++ b/src/libstd/os/raw/short.md @@ -0,0 +1,6 @@ +Equivalent to C's `signed short` (`short`) type. + +This type will almost always be [`i16`], however, the standard technically only requires that it be at least 16 bits, or at least the size of a C [`char`]. + +[`char`]: type.c_char.html +[`i16`]: ../../primitive.i16.html diff --git a/src/libstd/os/raw/uchar.md b/src/libstd/os/raw/uchar.md new file mode 100644 index 0000000000000..a5b741702290d --- /dev/null +++ b/src/libstd/os/raw/uchar.md @@ -0,0 +1,6 @@ +Equivalent to C's `unsigned char` type. + +This type will almost always be [`u8`], but its size is technically equal to the size of a C [`char`], which isn't very clear-cut. + +[`char`]: type.c_char.html +[`u8`]: ../../primitive.u8.html diff --git a/src/libstd/os/raw/uint.md b/src/libstd/os/raw/uint.md new file mode 100644 index 0000000000000..ec4714a9ab44c --- /dev/null +++ b/src/libstd/os/raw/uint.md @@ -0,0 +1,6 @@ +Equivalent to C's `unsigned int` type. + +This type will almost always be [`u32`], however, the standard technically on requires that it be the same size as an [`int`], which isn't very clear-cut. + +[`int`]: type.c_int.html +[`u32`]: ../../primitive.u32.html diff --git a/src/libstd/os/raw/ulong.md b/src/libstd/os/raw/ulong.md new file mode 100644 index 0000000000000..3cdbc6f59bfca --- /dev/null +++ b/src/libstd/os/raw/ulong.md @@ -0,0 +1,8 @@ +Equivalent to C's `unsigned long` type. + +This type will usually be [`u64`], but is sometimes [`u32`] \(i.e. [`usize`]\) on 32-bit systems. Technically, the standard only requires that it be the same size as a [`long`], which isn't very clear-cut. + +[`long`]: type.c_long.html +[`u32`]: ../../primitive.u32.html +[`u64`]: ../../primitive.u64.html +[`usize`]: ../../primitive.usize.html diff --git a/src/libstd/os/raw/ulonglong.md b/src/libstd/os/raw/ulonglong.md new file mode 100644 index 0000000000000..9f5ff74f261c8 --- /dev/null +++ b/src/libstd/os/raw/ulonglong.md @@ -0,0 +1,6 @@ +Equivalent to C's `unsigned long long` type. + +This type will almost always be [`u64`], however, the standard technically only requires that it be the same size as a [`long long`], which isn't very clear-cut. + +[`long long`]: type.c_longlong.html +[`u64`]: ../../primitive.u64.html diff --git a/src/libstd/os/raw/ushort.md b/src/libstd/os/raw/ushort.md new file mode 100644 index 0000000000000..6dea582fda25e --- /dev/null +++ b/src/libstd/os/raw/ushort.md @@ -0,0 +1,6 @@ +Equivalent to C's `unsigned short` type. + +This type will almost always be [`u16`], however, the standard technically only requires that it be the same size as a [`short`], which isn't very clear-cut. + +[`short`]: type.c_short.html +[`u16`]: ../../primitive.u16.html From 853fa5873c91ad1d01e69e7cbdb758001a31e9c1 Mon Sep 17 00:00:00 2001 From: Clar Charr Date: Sat, 23 Dec 2017 17:29:51 -0500 Subject: [PATCH 036/198] Revisions suggested in comments --- src/libstd/os/raw/char.md | 2 +- src/libstd/os/raw/long.md | 3 +-- src/libstd/os/raw/mod.rs | 2 +- src/libstd/os/raw/ulong.md | 3 +-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/libstd/os/raw/char.md b/src/libstd/os/raw/char.md index fb47dff187e5c..6816e519d1a4d 100644 --- a/src/libstd/os/raw/char.md +++ b/src/libstd/os/raw/char.md @@ -2,7 +2,7 @@ Equivalent to C's `char` type. [C's `char` type] is completely unlike [Rust's `char` type]; while Rust's type represents a unicode scalar value, C's `char` type is just an ordinary integer. In practice, this type will always be either [`i8`] or [`u8`], but you're technically not supposed to rely on this behaviour, as the standard only defines a char as being at least eight bits long. -C chars are most commonly used to make C strings. Unlike Rust, where the length of a string is included alongside the string, C strings mark the end of a string with a zero. See [`CStr`] for more information. +C chars are most commonly used to make C strings. Unlike Rust, where the length of a string is included alongside the string, C strings mark the end of a string with the character `'\0'`. See [`CStr`] for more information. [C's `char` type]: https://en.wikipedia.org/wiki/C_data_types#Basic_types [Rust's `char` type]: ../../primitive.char.html diff --git a/src/libstd/os/raw/long.md b/src/libstd/os/raw/long.md index c281e01733674..5a2e2331c0a51 100644 --- a/src/libstd/os/raw/long.md +++ b/src/libstd/os/raw/long.md @@ -1,8 +1,7 @@ Equivalent to C's `signed long` (`long`) type. -This type will usually be [`i64`], but is sometimes [`i32`] \(i.e. [`isize`]\) on 32-bit systems. Technically, the standard only requires that it be at least 32 bits, or at least the size of an [`int`]. +This type will usually be [`i64`], but is sometimes [`i32`]. Technically, the standard only requires that it be at least 32 bits, or at least the size of an [`int`]. [`int`]: type.c_int.html [`i32`]: ../../primitive.i32.html [`i64`]: ../../primitive.i64.html -[`isize`]: ../../primitive.isize.html diff --git a/src/libstd/os/raw/mod.rs b/src/libstd/os/raw/mod.rs index e96ba045ce700..710976ed8e0a9 100644 --- a/src/libstd/os/raw/mod.rs +++ b/src/libstd/os/raw/mod.rs @@ -83,7 +83,7 @@ use fmt; /// and `*mut c_void` is equivalent to C's `void*`. That said, this is /// *not* the same as C's `void` return type, which is Rust's `()` type. /// -/// [pointer]: ../primitive.pointer.html +/// [pointer]: ../../primitive.pointer.html // NB: For LLVM to recognize the void pointer type and by extension // functions like malloc(), we need to have it represented as i8* in // LLVM bitcode. The enum used here ensures this and prevents misuse diff --git a/src/libstd/os/raw/ulong.md b/src/libstd/os/raw/ulong.md index 3cdbc6f59bfca..919de171a39ac 100644 --- a/src/libstd/os/raw/ulong.md +++ b/src/libstd/os/raw/ulong.md @@ -1,8 +1,7 @@ Equivalent to C's `unsigned long` type. -This type will usually be [`u64`], but is sometimes [`u32`] \(i.e. [`usize`]\) on 32-bit systems. Technically, the standard only requires that it be the same size as a [`long`], which isn't very clear-cut. +This type will usually be [`u64`], but is sometimes [`u32`]. Technically, the standard only requires that it be the same size as a [`long`], which isn't very clear-cut. [`long`]: type.c_long.html [`u32`]: ../../primitive.u32.html [`u64`]: ../../primitive.u64.html -[`usize`]: ../../primitive.usize.html From 2cab06855a9b325c527ab08be4660c4353816833 Mon Sep 17 00:00:00 2001 From: Clar Charr Date: Mon, 29 Jan 2018 18:13:18 -0500 Subject: [PATCH 037/198] Reworded to avoid fuzziness, mention ! in c_void docs. --- src/libstd/os/raw/char.md | 2 +- src/libstd/os/raw/double.md | 3 ++- src/libstd/os/raw/float.md | 3 ++- src/libstd/os/raw/int.md | 3 ++- src/libstd/os/raw/long.md | 2 +- src/libstd/os/raw/longlong.md | 3 ++- src/libstd/os/raw/mod.rs | 4 ++++ src/libstd/os/raw/schar.md | 2 +- src/libstd/os/raw/short.md | 2 +- src/libstd/os/raw/uchar.md | 2 +- src/libstd/os/raw/uint.md | 3 ++- src/libstd/os/raw/ulong.md | 2 +- src/libstd/os/raw/ulonglong.md | 3 ++- src/libstd/os/raw/ushort.md | 2 +- 14 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/libstd/os/raw/char.md b/src/libstd/os/raw/char.md index 6816e519d1a4d..9a55767d965a6 100644 --- a/src/libstd/os/raw/char.md +++ b/src/libstd/os/raw/char.md @@ -1,6 +1,6 @@ Equivalent to C's `char` type. -[C's `char` type] is completely unlike [Rust's `char` type]; while Rust's type represents a unicode scalar value, C's `char` type is just an ordinary integer. In practice, this type will always be either [`i8`] or [`u8`], but you're technically not supposed to rely on this behaviour, as the standard only defines a char as being at least eight bits long. +[C's `char` type] is completely unlike [Rust's `char` type]; while Rust's type represents a unicode scalar value, C's `char` type is just an ordinary integer. This type will always be either [`i8`] or [`u8`], as the type is defined as being one byte long. C chars are most commonly used to make C strings. Unlike Rust, where the length of a string is included alongside the string, C strings mark the end of a string with the character `'\0'`. See [`CStr`] for more information. diff --git a/src/libstd/os/raw/double.md b/src/libstd/os/raw/double.md index 5ac09ee284c10..6818dada31793 100644 --- a/src/libstd/os/raw/double.md +++ b/src/libstd/os/raw/double.md @@ -1,6 +1,7 @@ Equivalent to C's `double` type. -This type will almost always be [`f64`], however, the standard technically only guarantees that it be a floating-point number with at least the precision of a [`float`]. +This type will almost always be [`f64`], which is guaranteed to be an [IEEE-754 double-precision float] in Rust. That said, the standard technically only guarantees that it be a floating-point number with at least the precision of a [`float`], and it may be `f32` or something entirely different from the IEEE-754 standard. +[IEEE-754 double-precision float]: https://en.wikipedia.org/wiki/IEEE_754 [`float`]: type.c_float.html [`f64`]: ../../primitive.f64.html diff --git a/src/libstd/os/raw/float.md b/src/libstd/os/raw/float.md index 20ba8645055b1..57d1071d0da17 100644 --- a/src/libstd/os/raw/float.md +++ b/src/libstd/os/raw/float.md @@ -1,5 +1,6 @@ Equivalent to C's `float` type. -This type will almost always be [`f32`], however, the standard technically only guarantees that it be a floating-point number. +This type will almost always be [`f32`], which is guaranteed to be an [IEEE-754 single-precision float] in Rust. That said, the standard technically only guarantees that it be a floating-point number, and it may have less precision than `f32` or not follow the IEEE-754 standard at all. +[IEEE-754 single-precision float]: https://en.wikipedia.org/wiki/IEEE_754 [`f32`]: ../../primitive.f32.html diff --git a/src/libstd/os/raw/int.md b/src/libstd/os/raw/int.md index efe7786099ab1..a0d25fd21d89f 100644 --- a/src/libstd/os/raw/int.md +++ b/src/libstd/os/raw/int.md @@ -1,6 +1,7 @@ Equivalent to C's `signed int` (`int`) type. -This type will almost always be [`i32`], however, the standard technically only requires that it be at least the size of a [`short`]. +This type will almost always be [`i32`], but may differ on some esoteric systems. The C standard technically only requires that this type be a signed integer that is at least the size of a [`short`]; some systems define it as an [`i16`], for example. [`short`]: type.c_short.html [`i32`]: ../../primitive.i32.html +[`i16`]: ../../primitive.i16.html diff --git a/src/libstd/os/raw/long.md b/src/libstd/os/raw/long.md index 5a2e2331c0a51..c620b402819fd 100644 --- a/src/libstd/os/raw/long.md +++ b/src/libstd/os/raw/long.md @@ -1,6 +1,6 @@ Equivalent to C's `signed long` (`long`) type. -This type will usually be [`i64`], but is sometimes [`i32`]. Technically, the standard only requires that it be at least 32 bits, or at least the size of an [`int`]. +This type will always be [`i32`] or [`i64`]. Most notably, many Linux-based systems assume an `i64`, but Windows assumes `i32`. The C standard technically only requires that this type be a signed integer that is at least 32 bits and at least the size of an [`int`], although in practice, no system would have a `long` that is neither an `i32` nor `i64`. [`int`]: type.c_int.html [`i32`]: ../../primitive.i32.html diff --git a/src/libstd/os/raw/longlong.md b/src/libstd/os/raw/longlong.md index 6594fcd564c50..ab3d6436568df 100644 --- a/src/libstd/os/raw/longlong.md +++ b/src/libstd/os/raw/longlong.md @@ -1,6 +1,7 @@ Equivalent to C's `signed long long` (`long long`) type. -This type will almost always be [`i64`], however, the standard technically only requires that it be at least 64 bits, or at least the size of an [`long`]. +This type will almost always be [`i64`], but may differ on some systems. The C standard technically only requires that this type be a signed integer that is at least 64 bits and at least the size of a [`long`], although in practice, no system would have a `long long` that is not an `i64`, as most systems do not have a standardised [`i128`] type. [`long`]: type.c_int.html [`i64`]: ../../primitive.i64.html +[`i128`]: ../../primitive.i128.html diff --git a/src/libstd/os/raw/mod.rs b/src/libstd/os/raw/mod.rs index 710976ed8e0a9..d5eeb5252f0f1 100644 --- a/src/libstd/os/raw/mod.rs +++ b/src/libstd/os/raw/mod.rs @@ -83,6 +83,10 @@ use fmt; /// and `*mut c_void` is equivalent to C's `void*`. That said, this is /// *not* the same as C's `void` return type, which is Rust's `()` type. /// +/// Ideally, this type would be equivalent to [`!`], but currently it may +/// be more ideal to use `c_void` for FFI purposes. +/// +/// [`!`]: ../../primitive.never.html /// [pointer]: ../../primitive.pointer.html // NB: For LLVM to recognize the void pointer type and by extension // functions like malloc(), we need to have it represented as i8* in diff --git a/src/libstd/os/raw/schar.md b/src/libstd/os/raw/schar.md index 42a403ef5d785..6aa8b1211d808 100644 --- a/src/libstd/os/raw/schar.md +++ b/src/libstd/os/raw/schar.md @@ -1,6 +1,6 @@ Equivalent to C's `signed char` type. -This type will almost always be [`i8`], but its size is technically equal to the size of a C [`char`], which isn't very clear-cut. +This type will always be [`i8`], but is included for completeness. It is defined as being a signed integer the same size as a C [`char`]. [`char`]: type.c_char.html [`i8`]: ../../primitive.i8.html diff --git a/src/libstd/os/raw/short.md b/src/libstd/os/raw/short.md index 86a8495eae232..be92c6c106d59 100644 --- a/src/libstd/os/raw/short.md +++ b/src/libstd/os/raw/short.md @@ -1,6 +1,6 @@ Equivalent to C's `signed short` (`short`) type. -This type will almost always be [`i16`], however, the standard technically only requires that it be at least 16 bits, or at least the size of a C [`char`]. +This type will almost always be [`i16`], but may differ on some esoteric systems. The C standard technically only requires that this type be a signed integer with at least 16 bits; some systems may define it as `i32`, for example. [`char`]: type.c_char.html [`i16`]: ../../primitive.i16.html diff --git a/src/libstd/os/raw/uchar.md b/src/libstd/os/raw/uchar.md index a5b741702290d..b6ca711f86934 100644 --- a/src/libstd/os/raw/uchar.md +++ b/src/libstd/os/raw/uchar.md @@ -1,6 +1,6 @@ Equivalent to C's `unsigned char` type. -This type will almost always be [`u8`], but its size is technically equal to the size of a C [`char`], which isn't very clear-cut. +This type will always be [`u8`], but is included for completeness. It is defined as being an unsigned integer the same size as a C [`char`]. [`char`]: type.c_char.html [`u8`]: ../../primitive.u8.html diff --git a/src/libstd/os/raw/uint.md b/src/libstd/os/raw/uint.md index ec4714a9ab44c..1e710f804c445 100644 --- a/src/libstd/os/raw/uint.md +++ b/src/libstd/os/raw/uint.md @@ -1,6 +1,7 @@ Equivalent to C's `unsigned int` type. -This type will almost always be [`u32`], however, the standard technically on requires that it be the same size as an [`int`], which isn't very clear-cut. +This type will almost always be [`u16`], but may differ on some esoteric systems. The C standard technically only requires that this type be an unsigned integer with the same size as an [`int`]; some systems define it as a [`u16`], for example. [`int`]: type.c_int.html [`u32`]: ../../primitive.u32.html +[`u16`]: ../../primitive.u16.html diff --git a/src/libstd/os/raw/ulong.md b/src/libstd/os/raw/ulong.md index 919de171a39ac..c350395080e80 100644 --- a/src/libstd/os/raw/ulong.md +++ b/src/libstd/os/raw/ulong.md @@ -1,6 +1,6 @@ Equivalent to C's `unsigned long` type. -This type will usually be [`u64`], but is sometimes [`u32`]. Technically, the standard only requires that it be the same size as a [`long`], which isn't very clear-cut. +This type will always be [`u32`] or [`u64`]. Most notably, many Linux-based systems assume an `u64`, but Windows assumes `u32`. The C standard technically only requires that this type be an unsigned integer with the size of a [`long`], although in practice, no system would have a `ulong` that is neither a `u32` nor `u64`. [`long`]: type.c_long.html [`u32`]: ../../primitive.u32.html diff --git a/src/libstd/os/raw/ulonglong.md b/src/libstd/os/raw/ulonglong.md index 9f5ff74f261c8..c41faf74c5c68 100644 --- a/src/libstd/os/raw/ulonglong.md +++ b/src/libstd/os/raw/ulonglong.md @@ -1,6 +1,7 @@ Equivalent to C's `unsigned long long` type. -This type will almost always be [`u64`], however, the standard technically only requires that it be the same size as a [`long long`], which isn't very clear-cut. +This type will almost always be [`u64`], but may differ on some systems. The C standard technically only requires that this type be an unsigned integer with the size of a [`long long`], although in practice, no system would have a `long long` that is not a `u64`, as most systems do not have a standardised [`u128`] type. [`long long`]: type.c_longlong.html [`u64`]: ../../primitive.u64.html +[`u128`]: ../../primitive.u128.html diff --git a/src/libstd/os/raw/ushort.md b/src/libstd/os/raw/ushort.md index 6dea582fda25e..d364abb3c8e0c 100644 --- a/src/libstd/os/raw/ushort.md +++ b/src/libstd/os/raw/ushort.md @@ -1,6 +1,6 @@ Equivalent to C's `unsigned short` type. -This type will almost always be [`u16`], however, the standard technically only requires that it be the same size as a [`short`], which isn't very clear-cut. +This type will almost always be [`u16`], but may differ on some esoteric systems. The C standard technically only requires that this type be an unsigned integer with the same size as a [`short`]. [`short`]: type.c_short.html [`u16`]: ../../primitive.u16.html From b5f8cd5c20977119eb600b05edf699a1bde92a2c Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Mon, 29 Jan 2018 23:15:38 -0500 Subject: [PATCH 038/198] Fix ref-to-ptr coercions not working with NLL in certain cases Implicit coercions from references to pointers were lowered to slightly different Mir than explicit casts (e.g. 'foo as *mut T'). This resulted in certain uses of self-referential structs compiling correctly when an explicit cast was used, but not when the implicit coercion was used. To fix this, this commit adds an outer 'Use' expr when applying a raw-ptr-borrow adjustment. This makes the lowered Mir for coercions identical to that of explicit coercions, allowing the original code to compile regardless of how the raw ptr cast occurs. Fixes #47722 --- src/librustc_mir/hair/cx/expr.rs | 34 +++++++++++++++++++++++++++++++- src/test/mir-opt/validate_5.rs | 9 ++++++--- src/test/run-pass/issue-47722.rs | 26 ++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 src/test/run-pass/issue-47722.rs diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 848c2d3c811e9..317b038c48295 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -145,7 +145,39 @@ fn apply_adjustment<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, arg: expr.to_ref(), }, }; - ExprKind::Cast { source: expr.to_ref() } + let cast_expr = Expr { + temp_lifetime, + ty: adjustment.target, + span, + kind: ExprKind::Cast { source: expr.to_ref() } + }; + + // To ensure that both implicit and explicit coercions are + // handled the same way, we insert an extra layer of indirection here. + // For explicit casts (e.g. 'foo as *const T'), the source of the 'Use' + // will be an ExprKind::Hair with the appropriate cast expression. Here, + // we make our Use source the generated Cast from the original coercion. + // + // In both cases, this outer 'Use' ensures that the inner 'Cast' is handled by + // as_operand, not by as_rvalue - causing the cast result to be stored in a temporary. + // Ordinary, this is identical to using the cast directly as an rvalue. However, if the + // source of the cast was previously borrowed as mutable, storing the cast in a + // temporary gives the source a chance to expire before the cast is used. For + // structs with a self-referential *mut ptr, this allows assignment to work as + // expected. + // + // For example, consider the type 'struct Foo { field: *mut Foo }', + // The method 'fn bar(&mut self) { self.field = self }' + // triggers a coercion from '&mut self' to '*mut self'. In order + // for the assignment to be valid, the implicit borrow + // of 'self' involved in the coercion needs to end before the local + // containing the '*mut T' is assigned to 'self.field' - otherwise, + // we end up trying to assign to 'self.field' while we have another mutable borrow + // active. + // + // We only need to worry about this kind of thing for coercions from refs to ptrs, + // since they get rid of a borrow implicitly. + ExprKind::Use { source: cast_expr.to_ref() } } Adjust::Unsize => { ExprKind::Unsize { source: expr.to_ref() } diff --git a/src/test/mir-opt/validate_5.rs b/src/test/mir-opt/validate_5.rs index c9408c1f2f88b..d8d83fb5b4537 100644 --- a/src/test/mir-opt/validate_5.rs +++ b/src/test/mir-opt/validate_5.rs @@ -52,12 +52,15 @@ fn main() { // Validate(Acquire, [_1: &ReFree(DefId(0/1:9 ~ validate_5[317d]::main[0]::{{closure}}[0]), BrEnv) [closure@NodeId(46)], _2: &ReFree(DefId(0/1:9 ~ validate_5[317d]::main[0]::{{closure}}[0]), BrAnon(0)) mut i32]); // StorageLive(_3); // StorageLive(_4); +// StorageLive(_5); // Validate(Suspend(ReScope(Node(ItemLocalId(9)))), [(*_2): i32]); -// _4 = &ReErased mut (*_2); -// Validate(Acquire, [(*_4): i32/ReScope(Node(ItemLocalId(9)))]); -// _3 = move _4 as *mut i32 (Misc); +// _5 = &ReErased mut (*_2); +// Validate(Acquire, [(*_5): i32/ReScope(Node(ItemLocalId(9)))]); +// _4 = move _5 as *mut i32 (Misc); +// _3 = move _4; // EndRegion(ReScope(Node(ItemLocalId(9)))); // StorageDead(_4); +// StorageDead(_5); // Validate(Release, [_0: bool, _3: *mut i32]); // _0 = const write_42(move _3) -> bb1; // } diff --git a/src/test/run-pass/issue-47722.rs b/src/test/run-pass/issue-47722.rs new file mode 100644 index 0000000000000..3b5d808e1f546 --- /dev/null +++ b/src/test/run-pass/issue-47722.rs @@ -0,0 +1,26 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// Tests that automatic coercions from &mut T to *mut T +// allow borrows of T to expire immediately - essentially, that +// they work identically to 'foo as *mut T' +#![feature(nll)] + +struct SelfReference { + self_reference: *mut SelfReference, +} + +impl SelfReference { + fn set_self_ref(&mut self) { + self.self_reference = self; + } +} + +fn main() {} From 4325c6375ecf7beaa2aedea2f0d3219b856e5bd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Mon, 29 Jan 2018 08:29:58 +0100 Subject: [PATCH 039/198] Allow access of the state field before the generator transform. Fixes #47482, #46476 --- src/librustc/ty/sty.rs | 13 ++++++++++--- .../borrow_check/nll/type_check/mod.rs | 15 ++++++++++----- .../ui/generator/generator-with-nll.stderr | 18 +++++++++--------- .../yield-while-local-borrowed.stderr | 18 +++++++++--------- 4 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index db7e4fe45ef76..d20cf556b71c0 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -390,14 +390,21 @@ impl<'a, 'gcx, 'tcx> ClosureSubsts<'tcx> { state.map(move |d| d.ty.subst(tcx, self.substs)) } + /// This is the types of the fields of a generate which + /// is available before the generator transformation. + /// It includes the upvars and the state discriminant which is u32. + pub fn pre_transforms_tys(self, def_id: DefId, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> + impl Iterator> + 'a + { + self.upvar_tys(def_id, tcx).chain(iter::once(tcx.types.u32)) + } + /// This is the types of all the fields stored in a generator. /// It includes the upvars, state types and the state discriminant which is u32. pub fn field_tys(self, def_id: DefId, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> impl Iterator> + 'a { - let upvars = self.upvar_tys(def_id, tcx); - let state = self.state_tys(def_id, tcx); - upvars.chain(iter::once(tcx.types.u32)).chain(state) + self.pre_transforms_tys(def_id, tcx).chain(self.state_tys(def_id, tcx)) } } diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index 9dcd4435580ab..dc302b6cc354e 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -533,15 +533,17 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { } } ty::TyGenerator(def_id, substs, _) => { - // Try upvars first. `field_tys` requires final optimized MIR. - if let Some(ty) = substs.upvar_tys(def_id, tcx).nth(field.index()) { + // Try pre-transform fields first (upvars and current state) + if let Some(ty) = substs.pre_transforms_tys(def_id, tcx).nth(field.index()) { return Ok(ty); } + // Then try `field_tys` which contains all the fields, but it + // requires the final optimized MIR. return match substs.field_tys(def_id, tcx).nth(field.index()) { Some(ty) => Ok(ty), None => Err(FieldAccessError::OutOfRange { - field_count: substs.field_tys(def_id, tcx).count() + 1, + field_count: substs.field_tys(def_id, tcx).count(), }), }; } @@ -1233,13 +1235,16 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { } } AggregateKind::Generator(def_id, substs, _) => { - if let Some(ty) = substs.upvar_tys(def_id, tcx).nth(field_index) { + // Try pre-transform fields first (upvars and current state) + if let Some(ty) = substs.pre_transforms_tys(def_id, tcx).nth(field_index) { Ok(ty) } else { + // Then try `field_tys` which contains all the fields, but it + // requires the final optimized MIR. match substs.field_tys(def_id, tcx).nth(field_index) { Some(ty) => Ok(ty), None => Err(FieldAccessError::OutOfRange { - field_count: substs.field_tys(def_id, tcx).count() + 1, + field_count: substs.field_tys(def_id, tcx).count(), }), } } diff --git a/src/test/ui/generator/generator-with-nll.stderr b/src/test/ui/generator/generator-with-nll.stderr index 0a52a928f69d4..0f7d2e540d80a 100644 --- a/src/test/ui/generator/generator-with-nll.stderr +++ b/src/test/ui/generator/generator-with-nll.stderr @@ -1,12 +1,3 @@ -error[E0626]: borrow may still be in use when generator yields (Mir) - --> $DIR/generator-with-nll.rs:20:17 - | -20 | let b = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast) - | ^^^^^^^^^ -21 | //~^ borrow may still be in use when generator yields (Mir) -22 | yield (); - | -------- possible yield occurs here - error[E0626]: borrow may still be in use when generator yields (Ast) --> $DIR/generator-with-nll.rs:19:23 | @@ -25,5 +16,14 @@ error[E0626]: borrow may still be in use when generator yields (Ast) 22 | yield (); | -------- possible yield occurs here +error[E0626]: borrow may still be in use when generator yields (Mir) + --> $DIR/generator-with-nll.rs:20:17 + | +20 | let b = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast) + | ^^^^^^^^^ +21 | //~^ borrow may still be in use when generator yields (Mir) +22 | yield (); + | -------- possible yield occurs here + error: aborting due to 3 previous errors diff --git a/src/test/ui/generator/yield-while-local-borrowed.stderr b/src/test/ui/generator/yield-while-local-borrowed.stderr index 7961dd9744136..114fe8ffcab0e 100644 --- a/src/test/ui/generator/yield-while-local-borrowed.stderr +++ b/src/test/ui/generator/yield-while-local-borrowed.stderr @@ -1,12 +1,3 @@ -error[E0626]: borrow may still be in use when generator yields (Mir) - --> $DIR/yield-while-local-borrowed.rs:24:17 - | -24 | let a = &mut 3; - | ^^^^^^ -... -27 | yield(); - | ------- possible yield occurs here - error[E0626]: borrow may still be in use when generator yields (Ast) --> $DIR/yield-while-local-borrowed.rs:24:22 | @@ -25,6 +16,15 @@ error[E0626]: borrow may still be in use when generator yields (Ast) 55 | yield(); | ------- possible yield occurs here +error[E0626]: borrow may still be in use when generator yields (Mir) + --> $DIR/yield-while-local-borrowed.rs:24:17 + | +24 | let a = &mut 3; + | ^^^^^^ +... +27 | yield(); + | ------- possible yield occurs here + error[E0626]: borrow may still be in use when generator yields (Mir) --> $DIR/yield-while-local-borrowed.rs:52:21 | From 56473562c5ca1937ffd667c2d258f0028c734eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Mon, 29 Jan 2018 08:48:56 +0100 Subject: [PATCH 040/198] Force locals to be live after they are borrowed for immovable generators. Fixes #47736 --- .../dataflow/impls/borrowed_locals.rs | 118 ++++++++++++++++++ src/librustc_mir/dataflow/impls/mod.rs | 4 + src/librustc_mir/dataflow/mod.rs | 1 + src/librustc_mir/transform/generator.rs | 68 +++++++--- .../too-live-local-in-immovable-gen.rs | 28 +++++ 5 files changed, 202 insertions(+), 17 deletions(-) create mode 100644 src/librustc_mir/dataflow/impls/borrowed_locals.rs create mode 100644 src/test/run-pass/generator/too-live-local-in-immovable-gen.rs diff --git a/src/librustc_mir/dataflow/impls/borrowed_locals.rs b/src/librustc_mir/dataflow/impls/borrowed_locals.rs new file mode 100644 index 0000000000000..244e8b5ccd7e4 --- /dev/null +++ b/src/librustc_mir/dataflow/impls/borrowed_locals.rs @@ -0,0 +1,118 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub use super::*; + +use rustc::mir::*; +use rustc::mir::visit::Visitor; +use dataflow::BitDenotation; + +/// This calculates if any part of a MIR local could have previously been borrowed. +/// This means that once a local has been borrowed, its bit will always be set +/// from that point and onwards, even if the borrow ends. You could also think of this +/// as computing the lifetimes of infinite borrows. +/// This is used to compute which locals are live during a yield expression for +/// immovable generators. +#[derive(Copy, Clone)] +pub struct HaveBeenBorrowedLocals<'a, 'tcx: 'a> { + mir: &'a Mir<'tcx>, +} + +impl<'a, 'tcx: 'a> HaveBeenBorrowedLocals<'a, 'tcx> { + pub fn new(mir: &'a Mir<'tcx>) + -> Self { + HaveBeenBorrowedLocals { mir: mir } + } + + pub fn mir(&self) -> &Mir<'tcx> { + self.mir + } +} + +impl<'a, 'tcx> BitDenotation for HaveBeenBorrowedLocals<'a, 'tcx> { + type Idx = Local; + fn name() -> &'static str { "has_been_borrowed_locals" } + fn bits_per_block(&self) -> usize { + self.mir.local_decls.len() + } + + fn start_block_effect(&self, _sets: &mut IdxSet) { + // Nothing is borrowed on function entry + } + + fn statement_effect(&self, + sets: &mut BlockSets, + loc: Location) { + BorrowedLocalsVisitor { + sets, + }.visit_statement(loc.block, &self.mir[loc.block].statements[loc.statement_index], loc); + } + + fn terminator_effect(&self, + sets: &mut BlockSets, + loc: Location) { + BorrowedLocalsVisitor { + sets, + }.visit_terminator(loc.block, self.mir[loc.block].terminator(), loc); + } + + fn propagate_call_return(&self, + _in_out: &mut IdxSet, + _call_bb: mir::BasicBlock, + _dest_bb: mir::BasicBlock, + _dest_place: &mir::Place) { + // Nothing to do when a call returns successfully + } +} + +impl<'a, 'tcx> BitwiseOperator for HaveBeenBorrowedLocals<'a, 'tcx> { + #[inline] + fn join(&self, pred1: usize, pred2: usize) -> usize { + pred1 | pred2 // "maybe" means we union effects of both preds + } +} + +impl<'a, 'tcx> InitialFlow for HaveBeenBorrowedLocals<'a, 'tcx> { + #[inline] + fn bottom_value() -> bool { + false // bottom = unborrowed + } +} + +struct BorrowedLocalsVisitor<'b, 'c: 'b> { + sets: &'b mut BlockSets<'c, Local>, +} + +fn find_local<'tcx>(place: &Place<'tcx>) -> Option { + match *place { + Place::Local(l) => Some(l), + Place::Static(..) => None, + Place::Projection(ref proj) => { + match proj.elem { + ProjectionElem::Deref => None, + _ => find_local(&proj.base) + } + } + } +} + +impl<'tcx, 'b, 'c> Visitor<'tcx> for BorrowedLocalsVisitor<'b, 'c> { + fn visit_rvalue(&mut self, + rvalue: &Rvalue<'tcx>, + location: Location) { + if let Rvalue::Ref(_, _, ref place) = *rvalue { + if let Some(local) = find_local(place) { + self.sets.gen(&local); + } + } + + self.super_rvalue(rvalue, location) + } +} diff --git a/src/librustc_mir/dataflow/impls/mod.rs b/src/librustc_mir/dataflow/impls/mod.rs index 106a88e703c79..c4942adc81493 100644 --- a/src/librustc_mir/dataflow/impls/mod.rs +++ b/src/librustc_mir/dataflow/impls/mod.rs @@ -33,6 +33,10 @@ mod storage_liveness; pub use self::storage_liveness::*; +mod borrowed_locals; + +pub use self::borrowed_locals::*; + #[allow(dead_code)] pub(super) mod borrows; diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index b18fb7c7b9cce..8156ff11f9bbe 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -30,6 +30,7 @@ pub use self::impls::{MaybeInitializedLvals, MaybeUninitializedLvals}; pub use self::impls::{DefinitelyInitializedLvals, MovingOutStatements}; pub use self::impls::EverInitializedLvals; pub use self::impls::borrows::{Borrows, BorrowData}; +pub use self::impls::HaveBeenBorrowedLocals; pub(crate) use self::impls::borrows::{ActiveBorrows, Reservations, ReserveOrActivateIndex}; pub use self::at_location::{FlowAtLocation, FlowsAtLocation}; pub(crate) use self::drop_flag_effects::*; diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index ebd34f81deb29..812665f5fa498 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -78,7 +78,8 @@ use std::mem; use transform::{MirPass, MirSource}; use transform::simplify; use transform::no_landing_pads::no_landing_pads; -use dataflow::{do_dataflow, DebugFormatted, MaybeStorageLive, state_for_location}; +use dataflow::{do_dataflow, DebugFormatted, state_for_location}; +use dataflow::{MaybeStorageLive, HaveBeenBorrowedLocals}; pub struct StateTransform; @@ -369,17 +370,33 @@ fn locals_live_across_suspend_points<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, HashMap) { let dead_unwinds = IdxSetBuf::new_empty(mir.basic_blocks().len()); let node_id = tcx.hir.as_local_node_id(source.def_id).unwrap(); - let analysis = MaybeStorageLive::new(mir); + + // Calculate when MIR locals have live storage. This gives us an upper bound of their + // lifetimes. + let storage_live_analysis = MaybeStorageLive::new(mir); let storage_live = - do_dataflow(tcx, mir, node_id, &[], &dead_unwinds, analysis, + do_dataflow(tcx, mir, node_id, &[], &dead_unwinds, storage_live_analysis, |bd, p| DebugFormatted::new(&bd.mir().local_decls[p])); + // Find the MIR locals which do not use StorageLive/StorageDead statements. + // The storage of these locals are always live. let mut ignored = StorageIgnored(IdxSetBuf::new_filled(mir.local_decls.len())); ignored.visit_mir(mir); - let mut borrowed_locals = BorrowedLocals(IdxSetBuf::new_empty(mir.local_decls.len())); - borrowed_locals.visit_mir(mir); + // Calculate the MIR locals which have been previously + // borrowed (even if they are still active). + // This is only used for immovable generators. + let borrowed_locals = if !movable { + let analysis = HaveBeenBorrowedLocals::new(mir); + let result = + do_dataflow(tcx, mir, node_id, &[], &dead_unwinds, analysis, + |bd, p| DebugFormatted::new(&bd.mir().local_decls[p])); + Some((analysis, result)) + } else { + None + }; + // Calculate the liveness of MIR locals ignoring borrows. let mut set = liveness::LocalSet::new_empty(mir.local_decls.len()); let mut liveness = liveness::liveness_of_locals(mir, LivenessMode { include_regular_use: true, @@ -396,24 +413,41 @@ fn locals_live_across_suspend_points<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, statement_index: data.statements.len(), }; - let storage_liveness = state_for_location(loc, &analysis, &storage_live, mir); + if let Some((ref analysis, ref result)) = borrowed_locals { + let borrowed_locals = state_for_location(loc, + analysis, + result, + mir); + // The `liveness` variable contains the liveness of MIR locals ignoring borrows. + // This is correct for movable generators since borrows cannot live across + // suspension points. However for immovable generators we need to account for + // borrows, so we conseratively assume that all borrowed locals live forever. + // To do this we just union our `liveness` result with `borrowed_locals`, which + // contains all the locals which has been borrowed before this suspension point. + // If a borrow is converted to a raw reference, we must also assume that it lives + // forever. Note that the final liveness is still bounded by the storage liveness + // of the local, which happens using the `intersect` operation below. + liveness.outs[block].union(&borrowed_locals); + } + + let mut storage_liveness = state_for_location(loc, + &storage_live_analysis, + &storage_live, + mir); + // Store the storage liveness for later use so we can restore the state + // after a suspension point storage_liveness_map.insert(block, storage_liveness.clone()); - let mut live_locals = storage_liveness; - // Mark locals without storage statements as always having live storage - live_locals.union(&ignored.0); + storage_liveness.union(&ignored.0); - if !movable { - // For immovable generators we consider borrowed locals to always be live. - // This effectively makes those locals use just the storage liveness. - liveness.outs[block].union(&borrowed_locals.0); - } + // Locals live are live at this point only if they are used across + // suspension points (the `liveness` variable) + // and their storage is live (the `storage_liveness` variable) + storage_liveness.intersect(&liveness.outs[block]); - // Locals live are live at this point only if they are used across suspension points - // and their storage is live - live_locals.intersect(&liveness.outs[block]); + let live_locals = storage_liveness; // Add the locals life at this suspension point to the set of locals which live across // any suspension points diff --git a/src/test/run-pass/generator/too-live-local-in-immovable-gen.rs b/src/test/run-pass/generator/too-live-local-in-immovable-gen.rs new file mode 100644 index 0000000000000..2314533a68153 --- /dev/null +++ b/src/test/run-pass/generator/too-live-local-in-immovable-gen.rs @@ -0,0 +1,28 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(generators)] + +fn main() { + unsafe { + static move || { + // Tests that the generator transformation finds out that `a` is not live + // during the yield expression. Type checking will also compute liveness + // and it should also find out that `a` is not live. + // The compiler will panic if the generator transformation finds that + // `a` is live and type checking finds it dead. + let a = { + yield (); + 4i32 + }; + &a; + }; + } +} From 6c66e11ff8121034cbc4b299f2a78410b4bf0243 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Mon, 29 Jan 2018 10:53:20 +0100 Subject: [PATCH 041/198] The `static` keyword can now begin expressions --- src/libsyntax/parse/token.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 2be93c07d5ad7..7fbe781e9a1f6 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -112,6 +112,7 @@ fn ident_can_begin_expr(ident: ast::Ident) -> bool { keywords::Unsafe.name(), keywords::While.name(), keywords::Yield.name(), + keywords::Static.name(), ].contains(&ident.name) } From e07aecde4896c3752256eb8baded936b07fee4d0 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 30 Jan 2018 10:38:54 +0530 Subject: [PATCH 042/198] Make make_clone_call take a Place argument --- src/librustc_mir/shim.rs | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index c206d0ea9b5fd..26825eabb3e7d 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -407,8 +407,9 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { ty: Ty<'tcx>, rcvr_field: Place<'tcx>, next: BasicBlock, - cleanup: BasicBlock - ) -> Place<'tcx> { + cleanup: BasicBlock, + place: Place<'tcx> + ) { let tcx = self.tcx; let substs = Substs::for_item( @@ -439,8 +440,6 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { }) ); - let loc = self.make_place(Mutability::Not, ty); - // `let ref_loc: &ty = &rcvr_field;` let statement = self.make_statement( StatementKind::Assign( @@ -453,11 +452,9 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { self.block(vec![statement], TerminatorKind::Call { func, args: vec![Operand::Move(ref_loc)], - destination: Some((loc.clone(), next)), + destination: Some((place, next)), cleanup: Some(cleanup), }, false); - - loc } fn loop_header( @@ -540,7 +537,9 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { // `let cloned = Clone::clone(rcvr[beg])`; // Goto #3 if ok, #5 if unwinding happens. let rcvr_field = rcvr.clone().index(beg); - let cloned = self.make_clone_call(ty, rcvr_field, BasicBlock::new(3), BasicBlock::new(5)); + let cloned = self.make_place(Mutability::Not, ty); + self.make_clone_call(ty, rcvr_field, BasicBlock::new(3), + BasicBlock::new(5), cloned.clone()); // BB #3 // `ret[beg] = cloned;` @@ -638,16 +637,18 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { for (i, ity) in tys.iter().enumerate() { let rcvr_field = rcvr.clone().field(Field::new(i), *ity); + let place = self.make_place(Mutability::Not, ity); + returns.push(place.clone()); + // BB #(2i) // `returns[i] = Clone::clone(&rcvr.i);` // Goto #(2i + 2) if ok, #(2i + 1) if unwinding happens. - returns.push( - self.make_clone_call( - *ity, - rcvr_field, - BasicBlock::new(2 * i + 2), - BasicBlock::new(2 * i + 1), - ) + self.make_clone_call( + *ity, + rcvr_field, + BasicBlock::new(2 * i + 2), + BasicBlock::new(2 * i + 1), + place ); // BB #(2i + 1) (cleanup) From 7fd3c27345c69c5f0eac5372467427408293c045 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 30 Jan 2018 10:51:48 +0530 Subject: [PATCH 043/198] Write directly to the RETURN_PLACE in tuple_like_shim --- src/librustc_mir/shim.rs | 39 ++++++++++++++++----------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 26825eabb3e7d..cc351368233c5 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -408,7 +408,7 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { rcvr_field: Place<'tcx>, next: BasicBlock, cleanup: BasicBlock, - place: Place<'tcx> + dest: Place<'tcx> ) { let tcx = self.tcx; @@ -452,7 +452,7 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { self.block(vec![statement], TerminatorKind::Call { func, args: vec![Operand::Move(ref_loc)], - destination: Some((place, next)), + destination: Some((dest, next)), cleanup: Some(cleanup), }, false); } @@ -633,12 +633,13 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { let rcvr = Place::Local(Local::new(1+0)).deref(); - let mut returns = Vec::new(); + let mut previous_place = None; + let return_place = Place::Local(RETURN_PLACE); for (i, ity) in tys.iter().enumerate() { - let rcvr_field = rcvr.clone().field(Field::new(i), *ity); + let field = Field::new(i); + let rcvr_field = rcvr.clone().field(field, *ity); - let place = self.make_place(Mutability::Not, ity); - returns.push(place.clone()); + let place = return_place.clone().field(field, *ity); // BB #(2i) // `returns[i] = Clone::clone(&rcvr.i);` @@ -648,34 +649,26 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { rcvr_field, BasicBlock::new(2 * i + 2), BasicBlock::new(2 * i + 1), - place + place.clone() ); // BB #(2i + 1) (cleanup) - if i == 0 { - // Nothing to drop, just resume. - self.block(vec![], TerminatorKind::Resume, true); - } else { + if let Some(previous_place) = previous_place.take() { // Drop previous field and goto previous cleanup block. self.block(vec![], TerminatorKind::Drop { - location: returns[i - 1].clone(), + location: previous_place, target: BasicBlock::new(2 * i - 1), unwind: None, }, true); + } else { + // Nothing to drop, just resume. + self.block(vec![], TerminatorKind::Resume, true); } + + previous_place = Some(place); } - // `return kind(returns[0], returns[1], ..., returns[tys.len() - 1]);` - let ret_statement = self.make_statement( - StatementKind::Assign( - Place::Local(RETURN_PLACE), - Rvalue::Aggregate( - box kind, - returns.into_iter().map(Operand::Move).collect() - ) - ) - ); - self.block(vec![ret_statement], TerminatorKind::Return, false); + self.block(vec![], TerminatorKind::Return, false); } } From c6140970f5fcb161c5cd72d0a1b842783b053e55 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 30 Jan 2018 11:55:50 +0530 Subject: [PATCH 044/198] Remove AggregateKind argument from tuple_like_shim --- src/librustc_mir/shim.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index cc351368233c5..28bdaa41297b4 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -305,11 +305,10 @@ fn build_clone_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } ty::TyClosure(def_id, substs) => { builder.tuple_like_shim( - &substs.upvar_tys(def_id, tcx).collect::>(), - AggregateKind::Closure(def_id, substs) + &substs.upvar_tys(def_id, tcx).collect::>() ) } - ty::TyTuple(tys, _) => builder.tuple_like_shim(&**tys, AggregateKind::Tuple), + ty::TyTuple(tys, _) => builder.tuple_like_shim(&**tys), _ => { bug!("clone shim for `{:?}` which is not `Copy` and is not an aggregate", self_ty) } @@ -625,12 +624,7 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { self.block(vec![], TerminatorKind::Resume, true); } - fn tuple_like_shim(&mut self, tys: &[ty::Ty<'tcx>], kind: AggregateKind<'tcx>) { - match kind { - AggregateKind::Tuple | AggregateKind::Closure(..) => (), - _ => bug!("only tuples and closures are accepted"), - }; - + fn tuple_like_shim(&mut self, tys: &[ty::Ty<'tcx>]) { let rcvr = Place::Local(Local::new(1+0)).deref(); let mut previous_place = None; From 48a7a1f5e954c1fc6693e0fddc793bf6b3e2bb25 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 29 Jan 2018 14:11:32 +0530 Subject: [PATCH 045/198] Document the index used in AggregateKind::Adt --- src/librustc/mir/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 3b644aa13f321..e48d21a3e17d1 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -1515,8 +1515,8 @@ pub enum AggregateKind<'tcx> { Array(Ty<'tcx>), Tuple, - /// The second field is variant number (discriminant), it's equal - /// to 0 for struct and union expressions. The fourth field is + /// The second field is the variant index. It's equal to 0 for struct + /// and union expressions. The fourth field is /// active field number and is present only for union expressions /// -- e.g. for a union expression `SomeUnion { c: .. }`, the /// active field index would identity the field `c` From ef4f4864f166e4f148d5b903bc928a1bcb63ead5 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 30 Jan 2018 17:24:56 +0530 Subject: [PATCH 046/198] Use dest,src ordering for make_clone_call --- src/librustc_mir/shim.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 28bdaa41297b4..36dd359b20c86 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -403,11 +403,11 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { fn make_clone_call( &mut self, + dest: Place<'tcx>, + src: Place<'tcx>, ty: Ty<'tcx>, - rcvr_field: Place<'tcx>, next: BasicBlock, - cleanup: BasicBlock, - dest: Place<'tcx> + cleanup: BasicBlock ) { let tcx = self.tcx; @@ -439,11 +439,11 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { }) ); - // `let ref_loc: &ty = &rcvr_field;` + // `let ref_loc: &ty = &src;` let statement = self.make_statement( StatementKind::Assign( ref_loc.clone(), - Rvalue::Ref(tcx.types.re_erased, BorrowKind::Shared, rcvr_field) + Rvalue::Ref(tcx.types.re_erased, BorrowKind::Shared, src) ) ); @@ -537,8 +537,8 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { // Goto #3 if ok, #5 if unwinding happens. let rcvr_field = rcvr.clone().index(beg); let cloned = self.make_place(Mutability::Not, ty); - self.make_clone_call(ty, rcvr_field, BasicBlock::new(3), - BasicBlock::new(5), cloned.clone()); + self.make_clone_call(cloned.clone(), rcvr_field, ty, BasicBlock::new(3), + BasicBlock::new(5)); // BB #3 // `ret[beg] = cloned;` @@ -639,11 +639,11 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { // `returns[i] = Clone::clone(&rcvr.i);` // Goto #(2i + 2) if ok, #(2i + 1) if unwinding happens. self.make_clone_call( - *ity, + place.clone(), rcvr_field, + *ity, BasicBlock::new(2 * i + 2), BasicBlock::new(2 * i + 1), - place.clone() ); // BB #(2i + 1) (cleanup) From b9f756416a02fe3fd1c145fc081494b68f494f76 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 30 Jan 2018 11:20:57 -0300 Subject: [PATCH 047/198] Do not ignore lifetime bounds in Copy impls Closes #29149 --- .../borrow_check/nll/type_check/mod.rs | 21 +++++++++++------ .../do-not-ignore-lifetime-bounds-in-copy.rs | 23 +++++++++++++++++++ 2 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 src/test/compile-fail/nll/do-not-ignore-lifetime-bounds-in-copy.rs diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index 015eb8a3b6643..cebdd4d2826aa 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -374,13 +374,20 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { } }; if let PlaceContext::Copy = context { - let ty = place_ty.to_ty(self.tcx()); - if self.cx - .infcx - .type_moves_by_default(self.cx.param_env, ty, DUMMY_SP) - { - span_mirbug!(self, place, "attempted copy of non-Copy type ({:?})", ty); - } + let tcx = self.tcx(); + let trait_ref = ty::TraitRef { + def_id: tcx.lang_items().copy_trait().unwrap(), + substs: tcx.mk_substs_trait(place_ty.to_ty(tcx), &[]), + }; + + // In order to have a Copy operand, the type T of the value must be Copy. Note that we + // prove that T: Copy, rather than using the type_moves_by_default test. This is + // important because type_moves_by_default ignores the resulting region obligations and + // assumes they pass. This can result in bounds from Copy impls being unsoundly ignored + // (e.g., #29149). Note that we decide to use Copy before knowing whether the bounds + // fully apply: in effect, the rule is that if a value of some type could implement + // Copy, then it must. + self.cx.prove_trait_ref(trait_ref, location); } place_ty } diff --git a/src/test/compile-fail/nll/do-not-ignore-lifetime-bounds-in-copy.rs b/src/test/compile-fail/nll/do-not-ignore-lifetime-bounds-in-copy.rs new file mode 100644 index 0000000000000..2a4295fd90a26 --- /dev/null +++ b/src/test/compile-fail/nll/do-not-ignore-lifetime-bounds-in-copy.rs @@ -0,0 +1,23 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the 'static bound from the Copy impl is respected. Regression test for #29149. + +#![feature(nll)] + +#[derive(Clone)] struct Foo<'a>(&'a u32); +impl Copy for Foo<'static> {} + +fn main() { + let s = 2; + let a = Foo(&s); //~ ERROR `s` does not live long enough [E0597] + drop(a); + drop(a); +} From 760879bc88b2884275b59fc38e0c5b1a8632e4cd Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Thu, 18 Jan 2018 18:41:09 -0600 Subject: [PATCH 048/198] Allow `?` as a KleeneOp in the macro parser --- src/libsyntax/ext/tt/quoted.rs | 130 +++++++++++++++++++++------------ 1 file changed, 84 insertions(+), 46 deletions(-) diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index c55dfaba8f6b2..f8ae8726bc1e6 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -16,6 +16,7 @@ use symbol::keywords; use syntax_pos::{BytePos, Span, DUMMY_SP}; use tokenstream; +use std::iter::Peekable; use std::rc::Rc; /// Contains the sub-token-trees of a "delimited" token tree, such as the contents of `(`. Note @@ -78,6 +79,7 @@ pub enum KleeneOp { ZeroOrMore, /// Kleene plus (`+`) for one or more repetitions OneOrMore, + ZeroOrOne, } /// Similar to `tokenstream::TokenTree`, except that `$i`, `$i:ident`, and `$(...)` @@ -183,7 +185,7 @@ pub fn parse( // For each token tree in `input`, parse the token into a `self::TokenTree`, consuming // additional trees if need be. - let mut trees = input.trees(); + let mut trees = input.trees().peekable(); while let Some(tree) = trees.next() { let tree = parse_tree(tree, &mut trees, expect_matchers, sess); @@ -321,6 +323,34 @@ where } } +/// Takes a token and returns `Some(KleeneOp)` if the token is `+` `*` or `?`. Otherwise, return +/// `None`. +fn kleene_op(token: &token::Token) -> Option { + match *token { + token::BinOp(token::Star) => Some(KleeneOp::ZeroOrMore), + token::BinOp(token::Plus) => Some(KleeneOp::OneOrMore), + token::Question => Some(KleeneOp::ZeroOrOne), + _ => None, + } +} + +/// Parse the next token tree of the input looking for a KleeneOp. Returns +/// +/// - Ok(Ok(op)) if the next token tree is a KleeneOp +/// - Ok(Err(tok, span)) if the next token tree is a token but not a KleeneOp +/// - Err(span) if the next token tree is not a token +fn parse_kleene_op(input: &mut I, span: Span) -> Result, Span> + where I: Iterator, +{ + match input.next() { + Some(tokenstream::TokenTree::Token(span, tok)) => match kleene_op(&tok) { + Some(op) => Ok(Ok(op)), + None => Ok(Err((tok, span))), + } + tree => Err(tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(span)), + } +} + /// Attempt to parse a single Kleene star, possibly with a separator. /// /// For example, in a pattern such as `$(a),*`, `a` is the pattern to be repeated, `,` is the @@ -333,56 +363,64 @@ where /// session `sess`. If the next one (or possibly two) tokens in `input` correspond to a Kleene /// operator and separator, then a tuple with `(separator, KleeneOp)` is returned. Otherwise, an /// error with the appropriate span is emitted to `sess` and a dummy value is returned. -fn parse_sep_and_kleene_op( - input: &mut I, - span: Span, - sess: &ParseSess, -) -> (Option, KleeneOp) -where - I: Iterator, +fn parse_sep_and_kleene_op(input: &mut Peekable, span: Span, sess: &ParseSess) + -> (Option, KleeneOp) + where I: Iterator, { - fn kleene_op(token: &token::Token) -> Option { - match *token { - token::BinOp(token::Star) => Some(KleeneOp::ZeroOrMore), - token::BinOp(token::Plus) => Some(KleeneOp::OneOrMore), - _ => None, + // We basically look at two token trees here, denoted as #1 and #2 below + let span = match parse_kleene_op(input, span) { + // #1 is a `+` or `*` KleeneOp + // + // `?` is ambiguous: it could be a separator or a Kleene::ZeroOrOne, so we need to look + // ahead one more token to be sure. + Ok(Ok(op)) if op != KleeneOp::ZeroOrOne => return (None, op), + + // #1 is `?` token, but it could be a Kleene::ZeroOrOne without a separator or it could + // be a `?` separator followed by any Kleene operator. We need to look ahead 1 token to + // find out which. + Ok(Ok(op)) => { + // Lookahead at #2. If it is a KleenOp, then #1 is a separator. + let is_1_sep = if let Some(&tokenstream::TokenTree::Token(_, ref tok2)) = input.peek() { + kleene_op(tok2).is_some() + } else { + false + }; + + if is_1_sep { + // #1 is a separator and #2 should be a KleepeOp::* + // (N.B. We need to advance the input iterator.) + match parse_kleene_op(input, span) { + // #2 is a KleeneOp (this is the only valid option) :) + Ok(Ok(op)) => return (Some(token::Question), op), + + // #2 is a random token (this is an error) :( + Ok(Err((_, span))) => span, + + // #2 is not even a token at all :( + Err(span) => span, + } + } else { + // #2 is a random tree and #1 is KleeneOp::ZeroOrOne + return (None, op); + } } - } - // We attempt to look at the next two token trees in `input`. I will call the first #1 and the - // second #2. If #1 and #2 don't match a valid KleeneOp with/without separator, that is an - // error, and we should emit an error on the most specific span possible. - let span = match input.next() { - // #1 is a token - Some(tokenstream::TokenTree::Token(span, tok)) => match kleene_op(&tok) { - // #1 is a KleeneOp with no separator - Some(op) => return (None, op), - - // #1 is not a KleeneOp, but may be a separator... need to look at #2 - None => match input.next() { - // #2 is a token - Some(tokenstream::TokenTree::Token(span, tok2)) => match kleene_op(&tok2) { - // #2 is a KleeneOp, so #1 must be a separator - Some(op) => return (Some(tok), op), - - // #2 is not a KleeneOp... error - None => span, - }, - - // #2 is not a token at all... error - tree => tree.as_ref() - .map(tokenstream::TokenTree::span) - .unwrap_or(span), - }, - }, + // #1 is a separator followed by #2, a KleeneOp + Ok(Err((tok, span))) => match parse_kleene_op(input, span) { + // #2 is a KleeneOp :D + Ok(Ok(op)) => return (Some(tok), op), + + // #2 is a random token :( + Ok(Err((_, span))) => span, + + // #2 is not a token at all :( + Err(span) => span, + } - // #1 is not a token at all... error - tree => tree.as_ref() - .map(tokenstream::TokenTree::span) - .unwrap_or(span), + // #1 is not a token + Err(span) => span, }; - // Error... - sess.span_diagnostic.span_err(span, "expected `*` or `+`"); + sess.span_diagnostic.span_err(span, "expected one of: `*`, `+`, or `?`"); (None, KleeneOp::ZeroOrMore) } From bb8110c1fcc33117fbf8bed985c0f472b3816bc3 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Thu, 18 Jan 2018 19:30:15 -0600 Subject: [PATCH 049/198] Update the macro parser to allow at most once repetitions for `?` Kleene --- src/libsyntax/ext/tt/macro_parser.rs | 38 ++++++++++++++++------------ 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 1a9849ca5307d..88144b1960980 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -486,8 +486,8 @@ fn inner_parse_loop( match item.top_elts.get_tt(idx) { // Need to descend into a sequence TokenTree::Sequence(sp, seq) => { - if seq.op == quoted::KleeneOp::ZeroOrMore { - // Examine the case where there are 0 matches of this sequence + // Examine the case where there are 0 matches of this sequence + if seq.op == quoted::KleeneOp::ZeroOrMore || seq.op == quoted::KleeneOp::ZeroOrOne { let mut new_item = item.clone(); new_item.match_cur += seq.num_captures; new_item.idx += 1; @@ -497,20 +497,26 @@ fn inner_parse_loop( cur_items.push(new_item); } - // Examine the case where there is at least one match of this sequence - let matches = create_matches(item.matches.len()); - cur_items.push(Box::new(MatcherPos { - stack: vec![], - sep: seq.separator.clone(), - idx: 0, - matches, - match_lo: item.match_cur, - match_cur: item.match_cur, - match_hi: item.match_cur + seq.num_captures, - up: Some(item), - sp_lo: sp.lo(), - top_elts: Tt(TokenTree::Sequence(sp, seq)), - })); + // For ZeroOrMore and OneOrMore, we want to examine the case were there is at + // least one match. For ZeroOrOne, we only want the case where there is exactly + // one match. + if (seq.op == quoted::KleeneOp::ZeroOrOne && seq.num_captures == 1) || + seq.op != quoted::KleeneOp::ZeroOrOne { + + let matches = create_matches(item.matches.len()); + cur_items.push(Box::new(MatcherPos { + stack: vec![], + sep: seq.separator.clone(), + idx: 0, + matches, + match_lo: item.match_cur, + match_cur: item.match_cur, + match_hi: item.match_cur + seq.num_captures, + up: Some(item), + sp_lo: sp.lo(), + top_elts: Tt(TokenTree::Sequence(sp, seq)), + })); + } } // We need to match a metavar (but the identifier is invalid)... this is an error From c33649cd8effaf3e1301ad2d81b053bd90764e32 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Thu, 18 Jan 2018 21:17:01 -0600 Subject: [PATCH 050/198] Run rustfmt on quoted.rs --- src/libsyntax/ext/tt/quoted.rs | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index f8ae8726bc1e6..13764ebfca1e1 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -241,7 +241,7 @@ pub fn parse( /// - `sess`: the parsing session. Any errors will be emitted to this session. fn parse_tree( tree: tokenstream::TokenTree, - trees: &mut I, + trees: &mut Peekable, expect_matchers: bool, sess: &ParseSess, ) -> TokenTree @@ -339,15 +339,21 @@ fn kleene_op(token: &token::Token) -> Option { /// - Ok(Ok(op)) if the next token tree is a KleeneOp /// - Ok(Err(tok, span)) if the next token tree is a token but not a KleeneOp /// - Err(span) if the next token tree is not a token -fn parse_kleene_op(input: &mut I, span: Span) -> Result, Span> - where I: Iterator, +fn parse_kleene_op( + input: &mut I, + span: Span, +) -> Result, Span> +where + I: Iterator, { match input.next() { Some(tokenstream::TokenTree::Token(span, tok)) => match kleene_op(&tok) { Some(op) => Ok(Ok(op)), None => Ok(Err((tok, span))), - } - tree => Err(tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(span)), + }, + tree => Err(tree.as_ref() + .map(tokenstream::TokenTree::span) + .unwrap_or(span)), } } @@ -363,9 +369,13 @@ fn parse_kleene_op(input: &mut I, span: Span) -> Result(input: &mut Peekable, span: Span, sess: &ParseSess) - -> (Option, KleeneOp) - where I: Iterator, +fn parse_sep_and_kleene_op( + input: &mut Peekable, + span: Span, + sess: &ParseSess, +) -> (Option, KleeneOp) +where + I: Iterator, { // We basically look at two token trees here, denoted as #1 and #2 below let span = match parse_kleene_op(input, span) { @@ -415,12 +425,13 @@ fn parse_sep_and_kleene_op(input: &mut Peekable, span: Span, sess: &ParseS // #2 is not a token at all :( Err(span) => span, - } + }, // #1 is not a token Err(span) => span, }; - sess.span_diagnostic.span_err(span, "expected one of: `*`, `+`, or `?`"); + sess.span_diagnostic + .span_err(span, "expected one of: `*`, `+`, or `?`"); (None, KleeneOp::ZeroOrMore) } From 711f71cfa909808334d6b5d9024e8745ab62b19d Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Thu, 18 Jan 2018 21:17:27 -0600 Subject: [PATCH 051/198] Add a couple of tests --- .../macro-at-most-once-rep-ambig.rs | 26 +++++++++++++++++++ src/test/run-pass/macro-at-most-once-rep.rs | 25 ++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 src/test/compile-fail/macro-at-most-once-rep-ambig.rs create mode 100644 src/test/run-pass/macro-at-most-once-rep.rs diff --git a/src/test/compile-fail/macro-at-most-once-rep-ambig.rs b/src/test/compile-fail/macro-at-most-once-rep-ambig.rs new file mode 100644 index 0000000000000..b0a6ec145e16a --- /dev/null +++ b/src/test/compile-fail/macro-at-most-once-rep-ambig.rs @@ -0,0 +1,26 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! foo { + ($(a)?) => {} +} + +macro_rules! bar { + ($(a)?+) => {} +} + +pub fn main() { + foo!(a?a?a); //~ ERROR no rules expected the token `?` + foo!(a?a); //~ ERROR no rules expected the token `?` + foo!(a?); //~ ERROR no rules expected the token `?` + bar!(); //~ ERROR no rules expected the token `)` + bar!(a?); //~ ERROR no rules expected the token `?` +} + diff --git a/src/test/run-pass/macro-at-most-once-rep.rs b/src/test/run-pass/macro-at-most-once-rep.rs new file mode 100644 index 0000000000000..fa1f90bf6ef98 --- /dev/null +++ b/src/test/run-pass/macro-at-most-once-rep.rs @@ -0,0 +1,25 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! foo { + ($(a)?) => {} +} + +macro_rules! bar { + ($(a)?+) => {} +} + +pub fn main() { + foo!(); + foo!(a); + bar!(a); + bar!(a?a); + bar!(a?a?a); +} From 5ac48ec82623433bc6dbf62ce8c101eeec12648d Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Thu, 18 Jan 2018 21:18:04 -0600 Subject: [PATCH 052/198] Run rustfmt on macro_parser.rs --- src/libsyntax/ext/tt/macro_parser.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 88144b1960980..e067bbecce28f 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -487,7 +487,9 @@ fn inner_parse_loop( // Need to descend into a sequence TokenTree::Sequence(sp, seq) => { // Examine the case where there are 0 matches of this sequence - if seq.op == quoted::KleeneOp::ZeroOrMore || seq.op == quoted::KleeneOp::ZeroOrOne { + if seq.op == quoted::KleeneOp::ZeroOrMore + || seq.op == quoted::KleeneOp::ZeroOrOne + { let mut new_item = item.clone(); new_item.match_cur += seq.num_captures; new_item.idx += 1; @@ -500,9 +502,9 @@ fn inner_parse_loop( // For ZeroOrMore and OneOrMore, we want to examine the case were there is at // least one match. For ZeroOrOne, we only want the case where there is exactly // one match. - if (seq.op == quoted::KleeneOp::ZeroOrOne && seq.num_captures == 1) || - seq.op != quoted::KleeneOp::ZeroOrOne { - + if (seq.op == quoted::KleeneOp::ZeroOrOne && seq.num_captures == 1) + || seq.op != quoted::KleeneOp::ZeroOrOne + { let matches = create_matches(item.matches.len()); cur_items.push(Box::new(MatcherPos { stack: vec![], From f59b821944e52c1158ad921f8b2be1be54039942 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Thu, 25 Jan 2018 12:45:27 -0600 Subject: [PATCH 053/198] Attempted fix for `?` kleene op --- src/libsyntax/ext/tt/macro_parser.rs | 44 +++++++++++++--------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index e067bbecce28f..b35beedfff7d4 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -181,6 +181,8 @@ struct MatcherPos { match_hi: usize, // Specifically used if we are matching a repetition. If we aren't both should be `None`. + /// The KleeneOp of this sequence if we are in a repetition. + seq_op: Option, /// The separator if we are in a repetition sep: Option, /// The "parent" matcher position if we are in a repetition. That is, the matcher position just @@ -263,6 +265,7 @@ fn initial_matcher_pos(ms: Vec, lo: BytePos) -> Box { stack: vec![], // Haven't descended into any sequences, so both of these are `None`. + seq_op: None, sep: None, up: None, }) @@ -464,10 +467,11 @@ fn inner_parse_loop( item.idx += 1; next_items.push(item); } - } + } // We don't need a separator. Move the "dot" back to the beginning of the matcher - // and try to match again. - else { + // and try to match again UNLESS we are only allowed to have _one_ repetition. + else if item.seq_op != Some(quoted::KleeneOp::ZeroOrOne) { + // we don't need a separator item.match_cur = item.match_lo; item.idx = 0; cur_items.push(item); @@ -499,26 +503,20 @@ fn inner_parse_loop( cur_items.push(new_item); } - // For ZeroOrMore and OneOrMore, we want to examine the case were there is at - // least one match. For ZeroOrOne, we only want the case where there is exactly - // one match. - if (seq.op == quoted::KleeneOp::ZeroOrOne && seq.num_captures == 1) - || seq.op != quoted::KleeneOp::ZeroOrOne - { - let matches = create_matches(item.matches.len()); - cur_items.push(Box::new(MatcherPos { - stack: vec![], - sep: seq.separator.clone(), - idx: 0, - matches, - match_lo: item.match_cur, - match_cur: item.match_cur, - match_hi: item.match_cur + seq.num_captures, - up: Some(item), - sp_lo: sp.lo(), - top_elts: Tt(TokenTree::Sequence(sp, seq)), - })); - } + let matches = create_matches(item.matches.len()); + cur_items.push(Box::new(MatcherPos { + stack: vec![], + sep: seq.separator.clone(), + seq_op: Some(seq.op), + idx: 0, + matches, + match_lo: item.match_cur, + match_cur: item.match_cur, + match_hi: item.match_cur + seq.num_captures, + up: Some(item), + sp_lo: sp.lo(), + top_elts: Tt(TokenTree::Sequence(sp, seq)), + })); } // We need to match a metavar (but the identifier is invalid)... this is an error From 51ef7393ef3e55e22cd385bd89dfa2c1b95a659b Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Thu, 25 Jan 2018 15:23:43 -0600 Subject: [PATCH 054/198] Fix typo in error message + update tests --- src/libsyntax/ext/tt/quoted.rs | 2 +- src/test/compile-fail/issue-39388.rs | 2 +- .../compile-fail/macro-at-most-once-rep-ambig.rs | 14 ++++++++++++-- src/test/run-pass/macro-at-most-once-rep.rs | 6 ++++++ 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index 13764ebfca1e1..670d3614604b7 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -432,6 +432,6 @@ where }; sess.span_diagnostic - .span_err(span, "expected one of: `*`, `+`, or `?`"); + .span_err(span, "expected one of: `*`, `+`, or `?`"); (None, KleeneOp::ZeroOrMore) } diff --git a/src/test/compile-fail/issue-39388.rs b/src/test/compile-fail/issue-39388.rs index 15eef429eab97..3fbbab62d24cc 100644 --- a/src/test/compile-fail/issue-39388.rs +++ b/src/test/compile-fail/issue-39388.rs @@ -11,7 +11,7 @@ #![allow(unused_macros)] macro_rules! assign { - (($($a:tt)*) = ($($b:tt))*) => { //~ ERROR expected `*` or `+` + (($($a:tt)*) = ($($b:tt))*) => { //~ ERROR 14:22: 14:29: expected one of: `*`, `+`, or `?` $($a)* = $($b)* } } diff --git a/src/test/compile-fail/macro-at-most-once-rep-ambig.rs b/src/test/compile-fail/macro-at-most-once-rep-ambig.rs index b0a6ec145e16a..89ca30840a985 100644 --- a/src/test/compile-fail/macro-at-most-once-rep-ambig.rs +++ b/src/test/compile-fail/macro-at-most-once-rep-ambig.rs @@ -12,6 +12,10 @@ macro_rules! foo { ($(a)?) => {} } +macro_rules! baz { + ($(a),?) => {} // comma separator is meaningless for `?` +} + macro_rules! bar { ($(a)?+) => {} } @@ -20,7 +24,13 @@ pub fn main() { foo!(a?a?a); //~ ERROR no rules expected the token `?` foo!(a?a); //~ ERROR no rules expected the token `?` foo!(a?); //~ ERROR no rules expected the token `?` - bar!(); //~ ERROR no rules expected the token `)` + baz!(a?a?a); //~ ERROR no rules expected the token `?` + baz!(a?a); //~ ERROR no rules expected the token `?` + baz!(a?); //~ ERROR no rules expected the token `?` + baz!(a,); //~ ERROR no rules expected the token `,` + baz!(a?a?a,); //~ ERROR no rules expected the token `?` + baz!(a?a,); //~ ERROR no rules expected the token `?` + baz!(a?,); //~ ERROR no rules expected the token `?` + bar!(); //~ ERROR unexpected end of macro invocation bar!(a?); //~ ERROR no rules expected the token `?` } - diff --git a/src/test/run-pass/macro-at-most-once-rep.rs b/src/test/run-pass/macro-at-most-once-rep.rs index fa1f90bf6ef98..823f42c454427 100644 --- a/src/test/run-pass/macro-at-most-once-rep.rs +++ b/src/test/run-pass/macro-at-most-once-rep.rs @@ -12,6 +12,10 @@ macro_rules! foo { ($(a)?) => {} } +macro_rules! baz { + ($(a),?) => {} // comma separator is meaningless for `?` +} + macro_rules! bar { ($(a)?+) => {} } @@ -19,6 +23,8 @@ macro_rules! bar { pub fn main() { foo!(); foo!(a); + baz!(); + baz!(a); bar!(a); bar!(a?a); bar!(a?a?a); From 4897a05ebf862f694f8b276e6c540ba30af4326a Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Thu, 25 Jan 2018 15:31:40 -0600 Subject: [PATCH 055/198] Fix a couple of tests --- src/test/compile-fail/macro-at-most-once-rep-ambig.rs | 4 ++-- src/test/parse-fail/issue-33569.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/compile-fail/macro-at-most-once-rep-ambig.rs b/src/test/compile-fail/macro-at-most-once-rep-ambig.rs index 89ca30840a985..c745568f1caa2 100644 --- a/src/test/compile-fail/macro-at-most-once-rep-ambig.rs +++ b/src/test/compile-fail/macro-at-most-once-rep-ambig.rs @@ -27,10 +27,10 @@ pub fn main() { baz!(a?a?a); //~ ERROR no rules expected the token `?` baz!(a?a); //~ ERROR no rules expected the token `?` baz!(a?); //~ ERROR no rules expected the token `?` - baz!(a,); //~ ERROR no rules expected the token `,` + baz!(a,); //~ ERROR unexpected end of macro invocation baz!(a?a?a,); //~ ERROR no rules expected the token `?` baz!(a?a,); //~ ERROR no rules expected the token `?` baz!(a?,); //~ ERROR no rules expected the token `?` bar!(); //~ ERROR unexpected end of macro invocation - bar!(a?); //~ ERROR no rules expected the token `?` + bar!(a?); //~ ERROR unexpected end of macro invocation } diff --git a/src/test/parse-fail/issue-33569.rs b/src/test/parse-fail/issue-33569.rs index 15d491719a6d5..af90d0a83c926 100644 --- a/src/test/parse-fail/issue-33569.rs +++ b/src/test/parse-fail/issue-33569.rs @@ -13,7 +13,7 @@ macro_rules! foo { { $+ } => { //~ ERROR expected identifier, found `+` //~^ ERROR missing fragment specifier - $(x)(y) //~ ERROR expected `*` or `+` + $(x)(y) //~ ERROR expected one of: `*`, `+`, or `?` } } From 3c15405c2571e03226b98f2d6eddec51967f0a18 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Fri, 26 Jan 2018 16:16:43 -0600 Subject: [PATCH 056/198] Add feature gate + tests --- src/libsyntax/ext/tt/macro_rules.rs | 6 +- src/libsyntax/ext/tt/quoted.rs | 72 ++++++++++++++++--- src/libsyntax/feature_gate.rs | 8 +++ .../ui/feature-gate-macro_at_most_once_rep.rs | 19 +++++ ...feature-gate-macro_at_most_once_rep.stderr | 11 +++ 5 files changed, 106 insertions(+), 10 deletions(-) create mode 100644 src/test/ui/feature-gate-macro_at_most_once_rep.rs create mode 100644 src/test/ui/feature-gate-macro_at_most_once_rep.stderr diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 9efb4faa63535..5254c751e6b62 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -237,7 +237,8 @@ pub fn compile(sess: &ParseSess, features: &RefCell, def: &ast::Item) s.iter().map(|m| { if let MatchedNonterminal(ref nt) = *m { if let NtTT(ref tt) = **nt { - let tt = quoted::parse(tt.clone().into(), true, sess).pop().unwrap(); + let tt = quoted::parse(tt.clone().into(), true, sess, features, &def.attrs) + .pop().unwrap(); valid &= check_lhs_nt_follows(sess, features, &def.attrs, &tt); return tt; } @@ -253,7 +254,8 @@ pub fn compile(sess: &ParseSess, features: &RefCell, def: &ast::Item) s.iter().map(|m| { if let MatchedNonterminal(ref nt) = *m { if let NtTT(ref tt) = **nt { - return quoted::parse(tt.clone().into(), false, sess).pop().unwrap(); + return quoted::parse(tt.clone().into(), false, sess, features, &def.attrs) + .pop().unwrap(); } } sess.span_diagnostic.span_bug(def.span, "wrong-structured lhs") diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index 670d3614604b7..8e05a6ccc4704 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -8,14 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use ast; +use {ast, attr}; use ext::tt::macro_parser; +use feature_gate::{self, emit_feature_err, Features, GateIssue}; use parse::{token, ParseSess}; use print::pprust; use symbol::keywords; use syntax_pos::{BytePos, Span, DUMMY_SP}; use tokenstream; +use std::cell::RefCell; use std::iter::Peekable; use std::rc::Rc; @@ -179,6 +181,8 @@ pub fn parse( input: tokenstream::TokenStream, expect_matchers: bool, sess: &ParseSess, + features: &RefCell, + attrs: &[ast::Attribute], ) -> Vec { // Will contain the final collection of `self::TokenTree` let mut result = Vec::new(); @@ -187,10 +191,9 @@ pub fn parse( // additional trees if need be. let mut trees = input.trees().peekable(); while let Some(tree) = trees.next() { - let tree = parse_tree(tree, &mut trees, expect_matchers, sess); - // Given the parsed tree, if there is a metavar and we are expecting matchers, actually // parse out the matcher (i.e. in `$id:ident` this would parse the `:` and `ident`). + let tree = parse_tree(tree, &mut trees, expect_matchers, sess, features, attrs); match tree { TokenTree::MetaVar(start_sp, ident) if expect_matchers => { let span = match trees.next() { @@ -244,6 +247,8 @@ fn parse_tree( trees: &mut Peekable, expect_matchers: bool, sess: &ParseSess, + features: &RefCell, + attrs: &[ast::Attribute], ) -> TokenTree where I: Iterator, @@ -262,9 +267,9 @@ where sess.span_diagnostic.span_err(span, &msg); } // Parse the contents of the sequence itself - let sequence = parse(delimited.tts.into(), expect_matchers, sess); + let sequence = parse(delimited.tts.into(), expect_matchers, sess, features, attrs); // Get the Kleene operator and optional separator - let (separator, op) = parse_sep_and_kleene_op(trees, span, sess); + let (separator, op) = parse_sep_and_kleene_op(trees, span, sess, features, attrs); // Count the number of captured "names" (i.e. named metavars) let name_captures = macro_parser::count_names(&sequence); TokenTree::Sequence( @@ -317,7 +322,7 @@ where span, Rc::new(Delimited { delim: delimited.delim, - tts: parse(delimited.tts.into(), expect_matchers, sess), + tts: parse(delimited.tts.into(), expect_matchers, sess, features, attrs), }), ), } @@ -373,6 +378,8 @@ fn parse_sep_and_kleene_op( input: &mut Peekable, span: Span, sess: &ParseSess, + features: &RefCell, + attrs: &[ast::Attribute], ) -> (Option, KleeneOp) where I: Iterator, @@ -401,6 +408,21 @@ where // (N.B. We need to advance the input iterator.) match parse_kleene_op(input, span) { // #2 is a KleeneOp (this is the only valid option) :) + Ok(Ok(op)) if op == KleeneOp::ZeroOrOne => { + if !features.borrow().macro_at_most_once_rep + && !attr::contains_name(attrs, "allow_internal_unstable") + { + let explain = feature_gate::EXPLAIN_MACRO_AT_MOST_ONCE_REP; + emit_feature_err( + sess, + "macro_at_most_once_rep", + span, + GateIssue::Language, + explain, + ); + } + return (Some(token::Question), op); + } Ok(Ok(op)) => return (Some(token::Question), op), // #2 is a random token (this is an error) :( @@ -410,6 +432,19 @@ where Err(span) => span, } } else { + if !features.borrow().macro_at_most_once_rep + && !attr::contains_name(attrs, "allow_internal_unstable") + { + let explain = feature_gate::EXPLAIN_MACRO_AT_MOST_ONCE_REP; + emit_feature_err( + sess, + "macro_at_most_once_rep", + span, + GateIssue::Language, + explain, + ); + } + // #2 is a random tree and #1 is KleeneOp::ZeroOrOne return (None, op); } @@ -418,6 +453,21 @@ where // #1 is a separator followed by #2, a KleeneOp Ok(Err((tok, span))) => match parse_kleene_op(input, span) { // #2 is a KleeneOp :D + Ok(Ok(op)) if op == KleeneOp::ZeroOrOne => { + if !features.borrow().macro_at_most_once_rep + && !attr::contains_name(attrs, "allow_internal_unstable") + { + let explain = feature_gate::EXPLAIN_MACRO_AT_MOST_ONCE_REP; + emit_feature_err( + sess, + "macro_at_most_once_rep", + span, + GateIssue::Language, + explain, + ); + } + return (Some(tok), op); + } Ok(Ok(op)) => return (Some(tok), op), // #2 is a random token :( @@ -431,7 +481,13 @@ where Err(span) => span, }; - sess.span_diagnostic - .span_err(span, "expected one of: `*`, `+`, or `?`"); + if !features.borrow().macro_at_most_once_rep + && !attr::contains_name(attrs, "allow_internal_unstable") + { + sess.span_diagnostic + .span_err(span, "expected one of: `*`, `+`, or `?`"); + } else { + sess.span_diagnostic.span_err(span, "expected `*` or `+`"); + } (None, KleeneOp::ZeroOrMore) } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 9a2560b04583d..9358511018a93 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -452,6 +452,11 @@ declare_features! ( // Allows `#[repr(transparent)]` attribute on newtype structs (active, repr_transparent, "1.25.0", Some(43036)), + + // Use `?` as the Kleene "at most one" operator + // FIXME(mark-i-m): make sure we use the correct issue number when there is + // a tracking issue... + (active, macro_at_most_once_rep, "1.25.0", None), ); declare_features! ( @@ -1250,6 +1255,9 @@ pub const EXPLAIN_PLACEMENT_IN: &'static str = pub const EXPLAIN_UNSIZED_TUPLE_COERCION: &'static str = "Unsized tuple coercion is not stable enough for use and is subject to change"; +pub const EXPLAIN_MACRO_AT_MOST_ONCE_REP: &'static str = + "Using the `?` macro Kleene operator for \"at most one\" repetition is unstable"; + struct PostExpansionVisitor<'a> { context: &'a Context<'a>, } diff --git a/src/test/ui/feature-gate-macro_at_most_once_rep.rs b/src/test/ui/feature-gate-macro_at_most_once_rep.rs new file mode 100644 index 0000000000000..13b2a8e217a42 --- /dev/null +++ b/src/test/ui/feature-gate-macro_at_most_once_rep.rs @@ -0,0 +1,19 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that the MSP430 interrupt ABI cannot be used when msp430_interrupt +// feature gate is not used. + +macro_rules! m { ($(a)?) => {} } +//~^ ERROR Using the `?` macro Kleene operator for "at most one" repetition is unstable + +fn main() { + m!(); +} diff --git a/src/test/ui/feature-gate-macro_at_most_once_rep.stderr b/src/test/ui/feature-gate-macro_at_most_once_rep.stderr new file mode 100644 index 0000000000000..f470399ffefa5 --- /dev/null +++ b/src/test/ui/feature-gate-macro_at_most_once_rep.stderr @@ -0,0 +1,11 @@ +error[E0658]: Using the `?` macro Kleene operator for "at most one" repetition is unstable + --> $DIR/feature-gate-macro_at_most_once_rep.rs:14:19 + | +14 | macro_rules! m { ($(a)?) => {} } + | ^^^^^ + | + = help: add #![feature(macro_at_most_once_rep)] to the crate attributes to enable + +error: aborting due to previous error + + From 5c4b4fe4d6b528e1500fc75154b9c701645ac274 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Fri, 26 Jan 2018 16:34:26 -0600 Subject: [PATCH 057/198] Corrected ui feature gate test --- src/test/ui/feature-gate-macro_at_most_once_rep.stderr | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/test/ui/feature-gate-macro_at_most_once_rep.stderr b/src/test/ui/feature-gate-macro_at_most_once_rep.stderr index f470399ffefa5..515c6243e668b 100644 --- a/src/test/ui/feature-gate-macro_at_most_once_rep.stderr +++ b/src/test/ui/feature-gate-macro_at_most_once_rep.stderr @@ -1,11 +1,10 @@ error[E0658]: Using the `?` macro Kleene operator for "at most one" repetition is unstable - --> $DIR/feature-gate-macro_at_most_once_rep.rs:14:19 + --> $DIR/feature-gate-macro_at_most_once_rep.rs:14:20 | 14 | macro_rules! m { ($(a)?) => {} } - | ^^^^^ + | ^^^ | = help: add #![feature(macro_at_most_once_rep)] to the crate attributes to enable error: aborting due to previous error - From bd98a935587ad988b5780b75021b1a45d0f508d7 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Fri, 26 Jan 2018 17:08:50 -0600 Subject: [PATCH 058/198] Fix more tests --- src/test/compile-fail/macro-at-most-once-rep-ambig.rs | 2 ++ .../auxiliary/procedural_mbe_matching.rs | 9 ++++++++- src/test/run-pass/macro-at-most-once-rep.rs | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/test/compile-fail/macro-at-most-once-rep-ambig.rs b/src/test/compile-fail/macro-at-most-once-rep-ambig.rs index c745568f1caa2..6886a02cb9210 100644 --- a/src/test/compile-fail/macro-at-most-once-rep-ambig.rs +++ b/src/test/compile-fail/macro-at-most-once-rep-ambig.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(macro_at_most_once_rep)] + macro_rules! foo { ($(a)?) => {} } diff --git a/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs b/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs index b5d6ff595afd5..9ebc438ad5a00 100644 --- a/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs +++ b/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs @@ -18,6 +18,7 @@ extern crate syntax_pos; extern crate rustc; extern crate rustc_plugin; +use syntax::feature_gate::Features; use syntax::parse::token::{NtExpr, NtPat}; use syntax::ast::{Ident, Pat}; use syntax::tokenstream::{TokenTree}; @@ -31,11 +32,17 @@ use syntax::ptr::P; use syntax_pos::Span; use rustc_plugin::Registry; +use std::cell::RefCell; + fn expand_mbe_matches(cx: &mut ExtCtxt, _: Span, args: &[TokenTree]) -> Box { let mbe_matcher = quote_tokens!(cx, $$matched:expr, $$($$pat:pat)|+); - let mbe_matcher = quoted::parse(mbe_matcher.into_iter().collect(), true, cx.parse_sess); + let mbe_matcher = quoted::parse(mbe_matcher.into_iter().collect(), + true, + cx.parse_sess, + &RefCell::new(Features::new()), + &[]); let map = match TokenTree::parse(cx, &mbe_matcher, args.iter().cloned().collect()) { Success(map) => map, Failure(_, tok) => { diff --git a/src/test/run-pass/macro-at-most-once-rep.rs b/src/test/run-pass/macro-at-most-once-rep.rs index 823f42c454427..ecfa92d5a738b 100644 --- a/src/test/run-pass/macro-at-most-once-rep.rs +++ b/src/test/run-pass/macro-at-most-once-rep.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(macro_at_most_once_rep)] + macro_rules! foo { ($(a)?) => {} } From 6943430e6d0ff11db4d99544cef7d480b15385e5 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Fri, 26 Jan 2018 17:26:09 -0600 Subject: [PATCH 059/198] Add ? to unstable book --- .../language-features/macro-at-most-once-rep.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/doc/unstable-book/src/language-features/macro-at-most-once-rep.md diff --git a/src/doc/unstable-book/src/language-features/macro-at-most-once-rep.md b/src/doc/unstable-book/src/language-features/macro-at-most-once-rep.md new file mode 100644 index 0000000000000..dbaf91b6e78b2 --- /dev/null +++ b/src/doc/unstable-book/src/language-features/macro-at-most-once-rep.md @@ -0,0 +1,17 @@ +# `macro_at_most_once_rep` + +The tracking issue for this feature is: TODO(mark-i-m) + +With this feature gate enabled, one can use `?` as a Kleene operator meaning "0 +or 1 repetitions" in a macro definition. Previously only `+` and `*` were allowed. + +For example: +```rust +macro_rules! foo { + (something $(,)?) // `?` indicates `,` is "optional"... + => {} +} +``` + +------------------------ + From 3859eca85134d518278f172fb26483e098381047 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Mon, 29 Jan 2018 16:26:11 -0600 Subject: [PATCH 060/198] Improved tests + typo fixes + assert --- src/libsyntax/ext/tt/quoted.rs | 2 + src/test/compile-fail/issue-39388.rs | 2 +- .../macro-at-most-once-rep-ambig.rs | 21 ++++- src/test/run-pass/macro-at-most-once-rep.rs | 77 ++++++++++++++++--- .../ui/feature-gate-macro_at_most_once_rep.rs | 4 +- 5 files changed, 89 insertions(+), 17 deletions(-) diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index 8e05a6ccc4704..bde1010b523ab 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -396,6 +396,8 @@ where // be a `?` separator followed by any Kleene operator. We need to look ahead 1 token to // find out which. Ok(Ok(op)) => { + assert_eq!(op, KleeneOp::ZeroOrOne); + // Lookahead at #2. If it is a KleenOp, then #1 is a separator. let is_1_sep = if let Some(&tokenstream::TokenTree::Token(_, ref tok2)) = input.peek() { kleene_op(tok2).is_some() diff --git a/src/test/compile-fail/issue-39388.rs b/src/test/compile-fail/issue-39388.rs index 3fbbab62d24cc..6da049374086a 100644 --- a/src/test/compile-fail/issue-39388.rs +++ b/src/test/compile-fail/issue-39388.rs @@ -11,7 +11,7 @@ #![allow(unused_macros)] macro_rules! assign { - (($($a:tt)*) = ($($b:tt))*) => { //~ ERROR 14:22: 14:29: expected one of: `*`, `+`, or `?` + (($($a:tt)*) = ($($b:tt))*) => { //~ ERROR expected one of: `*`, `+`, or `?` $($a)* = $($b)* } } diff --git a/src/test/compile-fail/macro-at-most-once-rep-ambig.rs b/src/test/compile-fail/macro-at-most-once-rep-ambig.rs index 6886a02cb9210..a5660f8b41f8d 100644 --- a/src/test/compile-fail/macro-at-most-once-rep-ambig.rs +++ b/src/test/compile-fail/macro-at-most-once-rep-ambig.rs @@ -8,6 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// The logic for parsing Kleene operators in macros has a special case to disambiguate `?`. +// Specifically, `$(pat)?` is the ZeroOrOne operator whereas `$(pat)?+` or `$(pat)?*` are the +// ZeroOrMore and OneOrMore operators using `?` as a separator. These tests are intended to +// exercise that logic in the macro parser. +// +// Moreover, we also throw in some tests for using a separator with `?`, which is meaningless but +// included for consistency with `+` and `*`. +// +// This test focuses on error cases. + #![feature(macro_at_most_once_rep)] macro_rules! foo { @@ -18,10 +28,14 @@ macro_rules! baz { ($(a),?) => {} // comma separator is meaningless for `?` } -macro_rules! bar { +macro_rules! barplus { ($(a)?+) => {} } +macro_rules! barstar { + ($(a)?*) => {} +} + pub fn main() { foo!(a?a?a); //~ ERROR no rules expected the token `?` foo!(a?a); //~ ERROR no rules expected the token `?` @@ -33,6 +47,7 @@ pub fn main() { baz!(a?a?a,); //~ ERROR no rules expected the token `?` baz!(a?a,); //~ ERROR no rules expected the token `?` baz!(a?,); //~ ERROR no rules expected the token `?` - bar!(); //~ ERROR unexpected end of macro invocation - bar!(a?); //~ ERROR unexpected end of macro invocation + barplus!(); //~ ERROR unexpected end of macro invocation + barplus!(a?); //~ ERROR unexpected end of macro invocation + barstar!(a?); //~ ERROR unexpected end of macro invocation } diff --git a/src/test/run-pass/macro-at-most-once-rep.rs b/src/test/run-pass/macro-at-most-once-rep.rs index ecfa92d5a738b..b7e942f938321 100644 --- a/src/test/run-pass/macro-at-most-once-rep.rs +++ b/src/test/run-pass/macro-at-most-once-rep.rs @@ -8,26 +8,81 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// The logic for parsing Kleene operators in macros has a special case to disambiguate `?`. +// Specifically, `$(pat)?` is the ZeroOrOne operator whereas `$(pat)?+` or `$(pat)?*` are the +// ZeroOrMore and OneOrMore operators using `?` as a separator. These tests are intended to +// exercise that logic in the macro parser. +// +// Moreover, we also throw in some tests for using a separator with `?`, which is meaningless but +// included for consistency with `+` and `*`. +// +// This test focuses on non-error cases and making sure the correct number of repetitions happen. + #![feature(macro_at_most_once_rep)] macro_rules! foo { - ($(a)?) => {} + ($($a:ident)? ; $num:expr) => { { + let mut x = 0; + + $( + x += $a; + )? + + assert_eq!(x, $num); + } } } macro_rules! baz { - ($(a),?) => {} // comma separator is meaningless for `?` + ($($a:ident),? ; $num:expr) => { { // comma separator is meaningless for `?` + let mut x = 0; + + $( + x += $a; + )? + + assert_eq!(x, $num); + } } } -macro_rules! bar { - ($(a)?+) => {} +macro_rules! barplus { + ($($a:ident)?+ ; $num:expr) => { { + let mut x = 0; + + $( + x += $a; + )+ + + assert_eq!(x, $num); + } } +} + +macro_rules! barstar { + ($($a:ident)?* ; $num:expr) => { { + let mut x = 0; + + $( + x += $a; + )* + + assert_eq!(x, $num); + } } } pub fn main() { - foo!(); - foo!(a); - baz!(); - baz!(a); - bar!(a); - bar!(a?a); - bar!(a?a?a); + let a = 1; + + // accept 0 or 1 repetitions + foo!( ; 0); + foo!(a ; 1); + baz!( ; 0); + baz!(a ; 1); + + // Make sure using ? as a separator works as before + barplus!(a ; 1); + barplus!(a?a ; 2); + barplus!(a?a?a ; 3); + barstar!( ; 0); + barstar!(a ; 1); + barstar!(a?a ; 2); + barstar!(a?a?a ; 3); } diff --git a/src/test/ui/feature-gate-macro_at_most_once_rep.rs b/src/test/ui/feature-gate-macro_at_most_once_rep.rs index 13b2a8e217a42..19f5aca5730e1 100644 --- a/src/test/ui/feature-gate-macro_at_most_once_rep.rs +++ b/src/test/ui/feature-gate-macro_at_most_once_rep.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Test that the MSP430 interrupt ABI cannot be used when msp430_interrupt -// feature gate is not used. +// Test that `?` macro Kleene operator can not be used when the `macro_at_most_once_rep` feature +// gate is not used. macro_rules! m { ($(a)?) => {} } //~^ ERROR Using the `?` macro Kleene operator for "at most one" repetition is unstable From 786b2ca1556de6d589bfb7d07e4a98e8fdcc6498 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Tue, 30 Jan 2018 12:45:35 -0600 Subject: [PATCH 061/198] Fix trailing whitespace --- src/libsyntax/ext/tt/macro_parser.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index b35beedfff7d4..2a3b96ebcb52b 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -467,7 +467,7 @@ fn inner_parse_loop( item.idx += 1; next_items.push(item); } - } + } // We don't need a separator. Move the "dot" back to the beginning of the matcher // and try to match again UNLESS we are only allowed to have _one_ repetition. else if item.seq_op != Some(quoted::KleeneOp::ZeroOrOne) { From a99b5db56a36652185a91be630b3e2af8ea09360 Mon Sep 17 00:00:00 2001 From: Jonathan Goodman Date: Tue, 30 Jan 2018 14:56:02 -0600 Subject: [PATCH 062/198] stabilize match_beginning_vert --- .../language-features/match-beginning-vert.md | 23 ------------ src/libsyntax/ast.rs | 1 - src/libsyntax/ext/build.rs | 1 - src/libsyntax/feature_gate.rs | 10 ++---- src/libsyntax/fold.rs | 3 +- src/libsyntax/parse/parser.rs | 7 +--- src/test/run-pass/match-beginning-vert.rs | 28 +++++++++++++++ .../ui/feature-gate-match_beginning_vert.rs | 36 ------------------- .../feature-gate-match_beginning_vert.stderr | 26 -------------- 9 files changed, 32 insertions(+), 103 deletions(-) delete mode 100644 src/doc/unstable-book/src/language-features/match-beginning-vert.md create mode 100644 src/test/run-pass/match-beginning-vert.rs delete mode 100644 src/test/ui/feature-gate-match_beginning_vert.rs delete mode 100644 src/test/ui/feature-gate-match_beginning_vert.stderr diff --git a/src/doc/unstable-book/src/language-features/match-beginning-vert.md b/src/doc/unstable-book/src/language-features/match-beginning-vert.md deleted file mode 100644 index f0a51af7fd1c8..0000000000000 --- a/src/doc/unstable-book/src/language-features/match-beginning-vert.md +++ /dev/null @@ -1,23 +0,0 @@ -# `match_beginning_vert` - -The tracking issue for this feature is [#44101]. - -With this feature enabled, you are allowed to add a '|' to the beginning of a -match arm: - -```rust -#![feature(match_beginning_vert)] - -enum Foo { A, B, C } - -fn main() { - let x = Foo::A; - match x { - | Foo::A - | Foo::B => println!("AB"), - | Foo::C => println!("C"), - } -} -``` - -[#44101]: https://github.com/rust-lang/rust/issues/44101 \ No newline at end of file diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 73810b3fe81d7..c7ab6158256ba 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -883,7 +883,6 @@ pub struct Arm { pub pats: Vec>, pub guard: Option>, pub body: P, - pub beginning_vert: Option, // For RFC 1925 feature gate } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index cf63592c2ece2..2e6de96d65a6d 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -883,7 +883,6 @@ impl<'a> AstBuilder for ExtCtxt<'a> { pats, guard: None, body: expr, - beginning_vert: None, } } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 9a2560b04583d..6a4f338485b3e 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -386,9 +386,6 @@ declare_features! ( // allow `#[must_use]` on functions and comparison operators (RFC 1940) (active, fn_must_use, "1.21.0", Some(43302)), - // allow '|' at beginning of match arms (RFC 1925) - (active, match_beginning_vert, "1.21.0", Some(44101)), - // Future-proofing enums/structs with #[non_exhaustive] attribute (RFC 2008) (active, non_exhaustive, "1.22.0", Some(44109)), @@ -545,6 +542,8 @@ declare_features! ( (accepted, abi_sysv64, "1.24.0", Some(36167)), // Allows `repr(align(16))` struct attribute (RFC 1358) (accepted, repr_align, "1.24.0", Some(33626)), + // allow '|' at beginning of match arms (RFC 1925) + (accepted, match_beginning_vert, "1.25.0", Some(44101)), ); // If you change this, please modify src/doc/unstable-book as well. You must @@ -1678,11 +1677,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } fn visit_arm(&mut self, arm: &'a ast::Arm) { - if let Some(span) = arm.beginning_vert { - gate_feature_post!(&self, match_beginning_vert, - span, - "Use of a '|' at the beginning of a match arm is experimental") - } visit::walk_arm(self, arm) } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 0f8fe57e380e5..921ed3565a471 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -340,14 +340,13 @@ pub fn fold_thin_attrs(attrs: ThinVec, fld: &mut T) -> Thi fold_attrs(attrs.into(), fld).into() } -pub fn noop_fold_arm(Arm {attrs, pats, guard, body, beginning_vert}: Arm, +pub fn noop_fold_arm(Arm {attrs, pats, guard, body}: Arm, fld: &mut T) -> Arm { Arm { attrs: fold_attrs(attrs, fld), pats: pats.move_map(|x| fld.fold_pat(x)), guard: guard.map(|x| fld.fold_expr(x)), body: fld.fold_expr(body), - beginning_vert, } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b3c485a85c063..764b3d0a848ee 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -3398,11 +3398,7 @@ impl<'a> Parser<'a> { let attrs = self.parse_outer_attributes()?; // Allow a '|' before the pats (RFC 1925) - let beginning_vert = if self.eat(&token::BinOp(token::Or)) { - Some(self.prev_span) - } else { - None - }; + self.eat(&token::BinOp(token::Or)); let pats = self.parse_pats()?; let guard = if self.eat_keyword(keywords::If) { Some(self.parse_expr()?) @@ -3426,7 +3422,6 @@ impl<'a> Parser<'a> { pats, guard, body: expr, - beginning_vert, }) } diff --git a/src/test/run-pass/match-beginning-vert.rs b/src/test/run-pass/match-beginning-vert.rs new file mode 100644 index 0000000000000..cdacfb2f05729 --- /dev/null +++ b/src/test/run-pass/match-beginning-vert.rs @@ -0,0 +1,28 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +enum Foo { + A, + B, + C, + D, + E, +} +use Foo::*; + +fn main() { + for foo in &[A, B, C, D, E] { + match *foo { + | A => println!("A"), + | B | C if 1 < 2 => println!("BC!"), + | _ => {}, + } + } +} diff --git a/src/test/ui/feature-gate-match_beginning_vert.rs b/src/test/ui/feature-gate-match_beginning_vert.rs deleted file mode 100644 index 9085563c99d6d..0000000000000 --- a/src/test/ui/feature-gate-match_beginning_vert.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[allow(dead_code)] -enum Foo { - A, - B, - C, - D, - E, -} -use Foo::*; - -fn main() { - let x = Foo::A; - match x { - | A => println!("A"), - //~^ ERROR: Use of a '|' at the beginning of a match arm is experimental (see issue #44101) - | B | C => println!("BC!"), - //~^ ERROR: Use of a '|' at the beginning of a match arm is experimental (see issue #44101) - | _ => {}, - //~^ ERROR: Use of a '|' at the beginning of a match arm is experimental (see issue #44101) - }; - match x { - A | B | C => println!("ABC!"), - _ => {}, - }; -} - diff --git a/src/test/ui/feature-gate-match_beginning_vert.stderr b/src/test/ui/feature-gate-match_beginning_vert.stderr deleted file mode 100644 index 1d45dedb4971c..0000000000000 --- a/src/test/ui/feature-gate-match_beginning_vert.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0658]: Use of a '|' at the beginning of a match arm is experimental (see issue #44101) - --> $DIR/feature-gate-match_beginning_vert.rs:24:9 - | -24 | | A => println!("A"), - | ^ - | - = help: add #![feature(match_beginning_vert)] to the crate attributes to enable - -error[E0658]: Use of a '|' at the beginning of a match arm is experimental (see issue #44101) - --> $DIR/feature-gate-match_beginning_vert.rs:26:9 - | -26 | | B | C => println!("BC!"), - | ^ - | - = help: add #![feature(match_beginning_vert)] to the crate attributes to enable - -error[E0658]: Use of a '|' at the beginning of a match arm is experimental (see issue #44101) - --> $DIR/feature-gate-match_beginning_vert.rs:28:9 - | -28 | | _ => {}, - | ^ - | - = help: add #![feature(match_beginning_vert)] to the crate attributes to enable - -error: aborting due to 3 previous errors - From 549534e438e40439aa43e6580fe31509ea31376f Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Tue, 30 Jan 2018 16:20:46 -0600 Subject: [PATCH 063/198] Update a few comments --- src/libsyntax/ext/tt/macro_parser.rs | 1 - src/libsyntax/ext/tt/quoted.rs | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 2a3b96ebcb52b..0621f728e2a9d 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -471,7 +471,6 @@ fn inner_parse_loop( // We don't need a separator. Move the "dot" back to the beginning of the matcher // and try to match again UNLESS we are only allowed to have _one_ repetition. else if item.seq_op != Some(quoted::KleeneOp::ZeroOrOne) { - // we don't need a separator item.match_cur = item.match_lo; item.idx = 0; cur_items.push(item); diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index bde1010b523ab..982b60b81e47e 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -173,6 +173,8 @@ impl TokenTree { /// `ident` are "matchers". They are not present in the body of a macro rule -- just in the /// pattern, so we pass a parameter to indicate whether to expect them or not. /// - `sess`: the parsing session. Any errors will be emitted to this session. +/// - `features`, `attrs`: language feature flags and attributes so that we know whether to use +/// unstable features or not. /// /// # Returns /// @@ -242,6 +244,8 @@ pub fn parse( /// converting `tree` /// - `expect_matchers`: same as for `parse` (see above). /// - `sess`: the parsing session. Any errors will be emitted to this session. +/// - `features`, `attrs`: language feature flags and attributes so that we know whether to use +/// unstable features or not. fn parse_tree( tree: tokenstream::TokenTree, trees: &mut Peekable, From f641ac6ecbdf22b4fc1d3222f6e5920e00bd770e Mon Sep 17 00:00:00 2001 From: Daan Sprenkels Date: Wed, 24 Jan 2018 12:46:51 +0100 Subject: [PATCH 064/198] Add regression test for #44415 --- src/test/compile-fail/issue-44415.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/test/compile-fail/issue-44415.rs diff --git a/src/test/compile-fail/issue-44415.rs b/src/test/compile-fail/issue-44415.rs new file mode 100644 index 0000000000000..3b7089f497526 --- /dev/null +++ b/src/test/compile-fail/issue-44415.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(const_fn)] +#![feature(core_intrinsics)] + +use std::intrinsics; + +struct Foo { + bytes: [u8; unsafe { intrinsics::size_of::() }], + //~^ ERROR unsupported cyclic reference between types/traits detected + x: usize, +} + +fn main() {} From 5985b0b03523f9fead022d55e8ecaaf001731d0b Mon Sep 17 00:00:00 2001 From: "Zack M. Davis" Date: Tue, 30 Jan 2018 17:13:05 -0800 Subject: [PATCH 065/198] wherein the parens lint keeps its own counsel re args in nested macros MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In #46980 ("in which the unused-parens lint..." (14982db2d6)), the unused-parens lint was made to check function and method arguments, which it previously did not (seemingly due to oversight rather than willful design). However, in #47775 and discussion thereon, user–developers of Geal/nom and graphql-rust/juniper reported that the lint was seemingly erroneously triggering on certain complex macros in those projects. While this doesn't seem like a bug in the lint in the particular strict sense that the expanded code would, in fact, contain unncecessary parentheses, it also doesn't seem like the sort of thing macro authors should have to think about: the spirit of the unused-parens lint is to prevent needless clutter in code, not to give macro authors extra heartache in the handling of token trees. We propose the expediency of declining to lint unused parentheses in function or method args inside of nested expansions: we believe that this should eliminate the petty, troublesome lint warnings reported in the issue, without forgoing the benefits of the lint in simpler macros. It seemed like too much duplicated code for the `Call` and `MethodCall` match arms to duplicate the nested-macro check in addition to each having their own `for` loop, so this occasioned a slight refactor so that the function and method cases could share code—hopefully the overall intent is at least no less clear to the gentle reader. This is concerning #47775. --- src/librustc_lint/unused.rs | 37 ++++++++++++----- ...775-nested-macro-unnecessary-parens-arg.rs | 40 +++++++++++++++++++ ...nested-macro-unnecessary-parens-arg.stderr | 15 +++++++ 3 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.rs create mode 100644 src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.stderr diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index ef6475f9ee4c7..56f863ab3aa84 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -302,19 +302,38 @@ impl EarlyLintPass for UnusedParens { Assign(_, ref value) => (value, "assigned value", false), AssignOp(.., ref value) => (value, "assigned value", false), InPlace(_, ref value) => (value, "emplacement value", false), - Call(_, ref args) => { - for arg in args { - self.check_unused_parens_core(cx, arg, "function argument", false) + // either function/method call, or something this lint doesn't care about + ref call_or_other => { + let args_to_check; + let call_kind; + match *call_or_other { + Call(_, ref args) => { + call_kind = "function"; + args_to_check = &args[..]; + }, + MethodCall(_, ref args) => { + call_kind = "method"; + // first "argument" is self (which sometimes needs parens) + args_to_check = &args[1..]; + } + // actual catch-all arm + _ => { return; } } - return; - }, - MethodCall(_, ref args) => { - for arg in &args[1..] { // first "argument" is self (which sometimes needs parens) - self.check_unused_parens_core(cx, arg, "method argument", false) + // Don't lint if this is a nested macro expansion: otherwise, the lint could + // trigger in situations that macro authors shouldn't have to care about, e.g., + // when a parenthesized token tree matched in one macro expansion is matched as + // an expression in another and used as a fn/method argument (Issue #47775) + if e.span.ctxt().outer().expn_info() + .map_or(false, |info| info.call_site.ctxt().outer() + .expn_info().is_some()) { + return; + } + let msg = format!("{} argument", call_kind); + for arg in args_to_check { + self.check_unused_parens_core(cx, arg, &msg, false); } return; } - _ => return, }; self.check_unused_parens_core(cx, &value, msg, struct_lit_needs_parens); } diff --git a/src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.rs b/src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.rs new file mode 100644 index 0000000000000..b4e6c5074e3d3 --- /dev/null +++ b/src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.rs @@ -0,0 +1,40 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// must-compile-successfully + +#![warn(unused_parens)] + +macro_rules! the_worship_the_heart_lifts_above { + ( @as_expr, $e:expr) => { $e }; + ( @generate_fn, $name:tt) => { + #[allow(dead_code)] fn the_moth_for_the_star<'a>() -> Option<&'a str> { + Some(the_worship_the_heart_lifts_above!( @as_expr, $name )) + } + }; + ( $name:ident ) => { the_worship_the_heart_lifts_above!( @generate_fn, (stringify!($name))); } + // ↑ Notably, this does 𝘯𝘰𝘵 warn: we're declining to lint unused parens in + // function/method arguments inside of nested macros because of situations + // like those reported in Issue #47775 +} + +macro_rules! and_the_heavens_reject_not { + () => { + // ↓ But let's test that we still lint for unused parens around + // function args inside of simple, one-deep macros. + #[allow(dead_code)] fn the_night_for_the_morrow() -> Option { Some((2)) } + //~^ WARN unnecessary parentheses around function argument + } +} + +the_worship_the_heart_lifts_above!(rah); +and_the_heavens_reject_not!(); + +fn main() {} diff --git a/src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.stderr b/src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.stderr new file mode 100644 index 0000000000000..097ec1b1c8010 --- /dev/null +++ b/src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.stderr @@ -0,0 +1,15 @@ +warning: unnecessary parentheses around function argument + --> $DIR/issue-47775-nested-macro-unnecessary-parens-arg.rs:32:83 + | +32 | #[allow(dead_code)] fn the_night_for_the_morrow() -> Option { Some((2)) } + | ^^^ help: remove these parentheses +... +38 | and_the_heavens_reject_not!(); + | ------------------------------ in this macro invocation + | +note: lint level defined here + --> $DIR/issue-47775-nested-macro-unnecessary-parens-arg.rs:13:9 + | +13 | #![warn(unused_parens)] + | ^^^^^^^^^^^^^ + From cfe53c066646857a19046ebaf0cdc410c3d9f034 Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Mon, 29 Jan 2018 20:13:29 -0600 Subject: [PATCH 066/198] Export wasm source map when debug information is enabled We use binaryen's linker to produce a wasm file (via s2wasm). The wasm writer has capabilities to export source maps. The produced source map contains references to the original file, that might require additional source map file processing to include / package original files with it. --- src/librustc_binaryen/BinaryenWrapper.cpp | 34 +++++++++++++++++++++-- src/librustc_binaryen/lib.rs | 22 +++++++++++++++ src/librustc_trans/back/write.rs | 18 ++++++++++-- 3 files changed, 68 insertions(+), 6 deletions(-) diff --git a/src/librustc_binaryen/BinaryenWrapper.cpp b/src/librustc_binaryen/BinaryenWrapper.cpp index d1095a7819d4a..55f11665f6d0b 100644 --- a/src/librustc_binaryen/BinaryenWrapper.cpp +++ b/src/librustc_binaryen/BinaryenWrapper.cpp @@ -14,6 +14,7 @@ #include #include +#include #include #include "s2wasm.h" @@ -24,6 +25,7 @@ using namespace wasm; struct BinaryenRustModule { BufferWithRandomAccess buffer; + std::string sourceMapJSON; }; struct BinaryenRustModuleOptions { @@ -36,6 +38,7 @@ struct BinaryenRustModuleOptions { bool ignoreUnknownSymbols; bool debugInfo; std::string startFunction; + std::string sourceMapUrl; BinaryenRustModuleOptions() : globalBase(0), @@ -46,7 +49,8 @@ struct BinaryenRustModuleOptions { importMemory(false), ignoreUnknownSymbols(false), debugInfo(false), - startFunction("") + startFunction(""), + sourceMapUrl("") {} }; @@ -73,6 +77,12 @@ BinaryenRustModuleOptionsSetStart(BinaryenRustModuleOptions *options, options->startFunction = start; } +extern "C" void +BinaryenRustModuleOptionsSetSourceMapUrl(BinaryenRustModuleOptions *options, + char *sourceMapUrl) { + options->sourceMapUrl = sourceMapUrl; +} + extern "C" void BinaryenRustModuleOptionsSetStackAllocation(BinaryenRustModuleOptions *options, uint64_t stack) { @@ -106,12 +116,20 @@ BinaryenRustModuleCreate(const BinaryenRustModuleOptions *options, { WasmBinaryWriter writer(&linker.getOutput().wasm, ret->buffer, options->debug); writer.setNamesSection(options->debugInfo); - // FIXME: support source maps? - // writer.setSourceMap(sourceMapStream.get(), sourceMapUrl); + + std::unique_ptr sourceMapStream = nullptr; + { + sourceMapStream = make_unique(); + writer.setSourceMap(sourceMapStream.get(), options->sourceMapUrl); + } // FIXME: support symbol maps? // writer.setSymbolMap(symbolMap); writer.write(); + + if (sourceMapStream) { + ret->sourceMapJSON = sourceMapStream->str(); + } } return ret.release(); } @@ -126,6 +144,16 @@ BinaryenRustModuleLen(const BinaryenRustModule *M) { return M->buffer.size(); } +extern "C" const char* +BinaryenRustModuleSourceMapPtr(const BinaryenRustModule *M) { + return M->sourceMapJSON.data(); +} + +extern "C" size_t +BinaryenRustModuleSourceMapLen(const BinaryenRustModule *M) { + return M->sourceMapJSON.length(); +} + extern "C" void BinaryenRustModuleFree(BinaryenRustModule *M) { delete M; diff --git a/src/librustc_binaryen/lib.rs b/src/librustc_binaryen/lib.rs index 6c7feb6a7a9d3..36174e11ba04a 100644 --- a/src/librustc_binaryen/lib.rs +++ b/src/librustc_binaryen/lib.rs @@ -51,6 +51,15 @@ impl Module { slice::from_raw_parts(ptr, len) } } + + /// Returns the data of the source map JSON. + pub fn source_map(&self) -> &[u8] { + unsafe { + let ptr = BinaryenRustModuleSourceMapPtr(self.ptr); + let len = BinaryenRustModuleSourceMapLen(self.ptr); + slice::from_raw_parts(ptr, len) + } + } } impl Drop for Module { @@ -94,6 +103,15 @@ impl ModuleOptions { self } + /// Configures a `sourceMappingURL` custom section value for the module. + pub fn source_map_url(&mut self, url: &str) -> &mut Self { + let url = CString::new(url).unwrap(); + unsafe { + BinaryenRustModuleOptionsSetSourceMapUrl(self.ptr, url.as_ptr()); + } + self + } + /// Configures how much stack is initially allocated for the module. 1MB is /// probably good enough for now. pub fn stack(&mut self, amt: u64) -> &mut Self { @@ -130,6 +148,8 @@ extern { -> *mut BinaryenRustModule; fn BinaryenRustModulePtr(module: *const BinaryenRustModule) -> *const u8; fn BinaryenRustModuleLen(module: *const BinaryenRustModule) -> usize; + fn BinaryenRustModuleSourceMapPtr(module: *const BinaryenRustModule) -> *const u8; + fn BinaryenRustModuleSourceMapLen(module: *const BinaryenRustModule) -> usize; fn BinaryenRustModuleFree(module: *mut BinaryenRustModule); fn BinaryenRustModuleOptionsCreate() @@ -138,6 +158,8 @@ extern { debuginfo: bool); fn BinaryenRustModuleOptionsSetStart(module: *mut BinaryenRustModuleOptions, start: *const libc::c_char); + fn BinaryenRustModuleOptionsSetSourceMapUrl(module: *mut BinaryenRustModuleOptions, + sourceMapUrl: *const libc::c_char); fn BinaryenRustModuleOptionsSetStackAllocation( module: *mut BinaryenRustModuleOptions, stack: u64, diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index a013af7a4600e..7a194a37c9c55 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -748,7 +748,10 @@ unsafe fn codegen(cgcx: &CodegenContext, if asm2wasm && config.emit_obj { let assembly = cgcx.output_filenames.temp_path(OutputType::Assembly, module_name); - binaryen_assemble(cgcx, diag_handler, &assembly, &obj_out); + let suffix = ".wasm.map"; // FIXME use target suffix + let map = cgcx.output_filenames.path(OutputType::Exe) + .with_extension(&suffix[1..]); + binaryen_assemble(cgcx, diag_handler, &assembly, &obj_out, &map); timeline.record("binaryen"); if !config.emit_asm { @@ -795,7 +798,8 @@ unsafe fn codegen(cgcx: &CodegenContext, fn binaryen_assemble(cgcx: &CodegenContext, handler: &Handler, assembly: &Path, - object: &Path) { + object: &Path, + map: &Path) { use rustc_binaryen::{Module, ModuleOptions}; let input = fs::read(&assembly).and_then(|contents| { @@ -804,6 +808,8 @@ fn binaryen_assemble(cgcx: &CodegenContext, let mut options = ModuleOptions::new(); if cgcx.debuginfo != config::NoDebugInfo { options.debuginfo(true); + let map_file_name = map.file_name().unwrap(); + options.source_map_url(map_file_name.to_str().unwrap()); } if cgcx.crate_types.contains(&config::CrateTypeExecutable) { options.start("main"); @@ -815,7 +821,13 @@ fn binaryen_assemble(cgcx: &CodegenContext, .map_err(|e| io::Error::new(io::ErrorKind::Other, e)) }); let err = assembled.and_then(|binary| { - fs::write(&object, binary.data()) + fs::write(&object, binary.data()).and_then(|()| { + if cgcx.debuginfo != config::NoDebugInfo { + fs::write(map, binary.source_map()) + } else { + Ok(()) + } + }) }); if let Err(e) = err { handler.err(&format!("failed to run binaryen assembler: {}", e)); From bc8e11b975030c4282f4b76200a104788f8ac5c8 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Tue, 30 Jan 2018 21:44:35 -0500 Subject: [PATCH 067/198] Fix ICE when assigning references to a static mut with NLL is_unsafe_place only filters out statics in the rhs, not the lhs. Since it's possible to reach that 'Place::Static', we handle statics the same way as we do locals. Fixes #47789 --- src/librustc_mir/dataflow/impls/borrows.rs | 3 +-- src/test/run-pass/issue-47789.rs | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 src/test/run-pass/issue-47789.rs diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs index 632bb5b34284d..80990bcc08089 100644 --- a/src/librustc_mir/dataflow/impls/borrows.rs +++ b/src/librustc_mir/dataflow/impls/borrows.rs @@ -396,8 +396,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> { // Issue #46746: Two-phase borrows handles // stmts of form `Tmp = &mut Borrow` ... match lhs { - Place::Local(..) => {} // okay - Place::Static(..) => unreachable!(), // (filtered by is_unsafe_place) + Place::Local(..) | Place::Static(..) => {} // okay Place::Projection(..) => { // ... can assign into projections, // e.g. `box (&mut _)`. Current diff --git a/src/test/run-pass/issue-47789.rs b/src/test/run-pass/issue-47789.rs new file mode 100644 index 0000000000000..3148939992caf --- /dev/null +++ b/src/test/run-pass/issue-47789.rs @@ -0,0 +1,20 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +#![feature(nll)] + +static mut x: &'static u32 = &0; + +fn foo() { + unsafe { x = &1; } +} + +fn main() { } From 5a350c137196f0a192b632f0380a8e3e5ab71fb3 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Tue, 30 Jan 2018 20:54:34 -0600 Subject: [PATCH 068/198] add doc(include) to the save-analysis test --- src/test/run-make/save-analysis/extra-docs.md | 1 + src/test/run-make/save-analysis/foo.rs | 4 ++++ 2 files changed, 5 insertions(+) create mode 100644 src/test/run-make/save-analysis/extra-docs.md diff --git a/src/test/run-make/save-analysis/extra-docs.md b/src/test/run-make/save-analysis/extra-docs.md new file mode 100644 index 0000000000000..0605ca517ff3b --- /dev/null +++ b/src/test/run-make/save-analysis/extra-docs.md @@ -0,0 +1 @@ +Extra docs for this struct. diff --git a/src/test/run-make/save-analysis/foo.rs b/src/test/run-make/save-analysis/foo.rs index 834a7554a555d..5b4e4802957af 100644 --- a/src/test/run-make/save-analysis/foo.rs +++ b/src/test/run-make/save-analysis/foo.rs @@ -12,6 +12,7 @@ #![feature(box_syntax)] #![feature(rustc_private)] #![feature(associated_type_defaults)] +#![feature(external_doc)] extern crate graphviz; // A simple rust project @@ -461,3 +462,6 @@ impl Iterator for SilenceGenerator { trait Foo { type Bar = FrameBuffer; } + +#[doc(include="extra-docs.md")] +struct StructWithDocs; From e2de8deb0927eb68dbc5986e1fbbd0a1359f8a74 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 30 Jan 2018 16:47:30 -0800 Subject: [PATCH 069/198] Enable stack-probe tests with system LLVM >= 5.0 --- src/test/codegen/stack-probes.rs | 2 +- src/test/run-pass/stack-probes-lto.rs | 2 +- src/test/run-pass/stack-probes.rs | 2 +- src/tools/compiletest/src/header.rs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/codegen/stack-probes.rs b/src/test/codegen/stack-probes.rs index 5b26dade9aff0..4a489f1edb3b8 100644 --- a/src/test/codegen/stack-probes.rs +++ b/src/test/codegen/stack-probes.rs @@ -15,7 +15,7 @@ // ignore-wasm // ignore-emscripten // ignore-windows -// no-system-llvm +// min-system-llvm-version 5.0 // compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/src/test/run-pass/stack-probes-lto.rs b/src/test/run-pass/stack-probes-lto.rs index 22555c8d6a779..4deced1297bd1 100644 --- a/src/test/run-pass/stack-probes-lto.rs +++ b/src/test/run-pass/stack-probes-lto.rs @@ -15,7 +15,7 @@ // ignore-emscripten no processes // ignore-musl FIXME #31506 // ignore-pretty -// no-system-llvm +// min-system-llvm-version 5.0 // compile-flags: -C lto // no-prefer-dynamic diff --git a/src/test/run-pass/stack-probes.rs b/src/test/run-pass/stack-probes.rs index 248ad7019261d..4224a65ffd7c7 100644 --- a/src/test/run-pass/stack-probes.rs +++ b/src/test/run-pass/stack-probes.rs @@ -14,7 +14,7 @@ // ignore-cloudabi no processes // ignore-emscripten no processes // ignore-musl FIXME #31506 -// no-system-llvm +// min-system-llvm-version 5.0 use std::mem; use std::process::Command; diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index ff662736bdd1b..80750f9a3fee0 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -167,7 +167,7 @@ impl EarlyProps { .expect("Malformed llvm version directive"); // Ignore if using system LLVM and actual version // is smaller the minimum required version - !(config.system_llvm && &actual_version[..] < min_version) + config.system_llvm && &actual_version[..] < min_version } else { false } From 55b54a999bcdb0b1c1f42b6e1ae670beb0717086 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 31 Jan 2018 11:41:29 -0800 Subject: [PATCH 070/198] Use a range to identify SIGSEGV in stack guards MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, the `guard::init()` and `guard::current()` functions were returning a `usize` address representing the top of the stack guard, respectively for the main thread and for spawned threads. The `SIGSEGV` handler on `unix` targets checked if a fault was within one page below that address, if so reporting it as a stack overflow. Now `unix` targets report a `Range` representing the guard memory, so it can cover arbitrary guard sizes. Non-`unix` targets which always return `None` for guards now do so with `Option`, so they don't pay any overhead. For `linux-gnu` in particular, the previous guard upper-bound was `stackaddr + guardsize`, as the protected memory was *inside* the stack. This was a glibc bug, and starting from 2.27 they are moving the guard *past* the end of the stack. However, there's no simple way for us to know where the guard page actually lies, so now we declare it as the whole range of `stackaddr ± guardsize`, and any fault therein will be called a stack overflow. This fixes #47863. --- src/libstd/sys/cloudabi/thread.rs | 5 +- src/libstd/sys/redox/thread.rs | 5 +- src/libstd/sys/unix/stack_overflow.rs | 9 +- src/libstd/sys/unix/thread.rs | 115 ++++++++++++++++---------- src/libstd/sys/wasm/thread.rs | 5 +- src/libstd/sys/windows/thread.rs | 5 +- src/libstd/sys_common/thread_info.rs | 9 +- 7 files changed, 89 insertions(+), 64 deletions(-) diff --git a/src/libstd/sys/cloudabi/thread.rs b/src/libstd/sys/cloudabi/thread.rs index c980ae75261ca..78a3b82546e3a 100644 --- a/src/libstd/sys/cloudabi/thread.rs +++ b/src/libstd/sys/cloudabi/thread.rs @@ -111,10 +111,11 @@ impl Drop for Thread { #[cfg_attr(test, allow(dead_code))] pub mod guard { - pub unsafe fn current() -> Option { + pub type Guard = !; + pub unsafe fn current() -> Option { None } - pub unsafe fn init() -> Option { + pub unsafe fn init() -> Option { None } } diff --git a/src/libstd/sys/redox/thread.rs b/src/libstd/sys/redox/thread.rs index c4aad8d86f8b1..c4719a94c7e9d 100644 --- a/src/libstd/sys/redox/thread.rs +++ b/src/libstd/sys/redox/thread.rs @@ -88,6 +88,7 @@ impl Thread { } pub mod guard { - pub unsafe fn current() -> Option { None } - pub unsafe fn init() -> Option { None } + pub type Guard = !; + pub unsafe fn current() -> Option { None } + pub unsafe fn init() -> Option { None } } diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs index 51adbc24ae047..40453f9b8a15b 100644 --- a/src/libstd/sys/unix/stack_overflow.rs +++ b/src/libstd/sys/unix/stack_overflow.rs @@ -57,9 +57,6 @@ mod imp { use sys_common::thread_info; - // This is initialized in init() and only read from after - static mut PAGE_SIZE: usize = 0; - #[cfg(any(target_os = "linux", target_os = "android"))] unsafe fn siginfo_si_addr(info: *mut libc::siginfo_t) -> usize { #[repr(C)] @@ -102,12 +99,12 @@ mod imp { _data: *mut libc::c_void) { use sys_common::util::report_overflow; - let guard = thread_info::stack_guard().unwrap_or(0); + let guard = thread_info::stack_guard().unwrap_or(0..0); let addr = siginfo_si_addr(info); // If the faulting address is within the guard page, then we print a // message saying so and abort. - if guard != 0 && guard - PAGE_SIZE <= addr && addr < guard { + if guard.start <= addr && addr < guard.end { report_overflow(); rtabort!("stack overflow"); } else { @@ -123,8 +120,6 @@ mod imp { static mut MAIN_ALTSTACK: *mut libc::c_void = ptr::null_mut(); pub unsafe fn init() { - PAGE_SIZE = ::sys::os::page_size(); - let mut action: sigaction = mem::zeroed(); action.sa_flags = SA_SIGINFO | SA_ONSTACK; action.sa_sigaction = signal_handler as sighandler_t; diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index 525882c1e1ebb..72cdb9440b8e7 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -205,8 +205,10 @@ impl Drop for Thread { not(target_os = "solaris")))] #[cfg_attr(test, allow(dead_code))] pub mod guard { - pub unsafe fn current() -> Option { None } - pub unsafe fn init() -> Option { None } + use ops::Range; + pub type Guard = Range; + pub unsafe fn current() -> Option { None } + pub unsafe fn init() -> Option { None } } @@ -222,14 +224,43 @@ pub mod guard { use libc; use libc::mmap; use libc::{PROT_NONE, MAP_PRIVATE, MAP_ANON, MAP_FAILED, MAP_FIXED}; + use ops::Range; use sys::os; - #[cfg(any(target_os = "macos", - target_os = "bitrig", - target_os = "openbsd", - target_os = "solaris"))] + // This is initialized in init() and only read from after + static mut PAGE_SIZE: usize = 0; + + pub type Guard = Range; + + #[cfg(target_os = "solaris")] + unsafe fn get_stack_start() -> Option<*mut libc::c_void> { + let mut current_stack: libc::stack_t = ::mem::zeroed(); + assert_eq!(libc::stack_getbounds(&mut current_stack), 0); + Some(current_stack.ss_sp) + } + + #[cfg(target_os = "macos")] unsafe fn get_stack_start() -> Option<*mut libc::c_void> { - current().map(|s| s as *mut libc::c_void) + let stackaddr = libc::pthread_get_stackaddr_np(libc::pthread_self()) as usize - + libc::pthread_get_stacksize_np(libc::pthread_self()); + Some(stackaddr as *mut libc::c_void) + } + + #[cfg(any(target_os = "openbsd", target_os = "bitrig"))] + unsafe fn get_stack_start() -> Option<*mut libc::c_void> { + let mut current_stack: libc::stack_t = ::mem::zeroed(); + assert_eq!(libc::pthread_stackseg_np(libc::pthread_self(), + &mut current_stack), 0); + + let extra = if cfg!(target_os = "bitrig") {3} else {1} * PAGE_SIZE; + let stackaddr = if libc::pthread_main_np() == 1 { + // main thread + current_stack.ss_sp as usize - current_stack.ss_size + extra + } else { + // new thread + current_stack.ss_sp as usize - current_stack.ss_size + }; + Some(stackaddr as *mut libc::c_void) } #[cfg(any(target_os = "android", target_os = "freebsd", @@ -253,8 +284,9 @@ pub mod guard { ret } - pub unsafe fn init() -> Option { - let psize = os::page_size(); + pub unsafe fn init() -> Option { + PAGE_SIZE = os::page_size(); + let mut stackaddr = get_stack_start()?; // Ensure stackaddr is page aligned! A parent process might @@ -263,9 +295,9 @@ pub mod guard { // stackaddr < stackaddr + stacksize, so if stackaddr is not // page-aligned, calculate the fix such that stackaddr < // new_page_aligned_stackaddr < stackaddr + stacksize - let remainder = (stackaddr as usize) % psize; + let remainder = (stackaddr as usize) % PAGE_SIZE; if remainder != 0 { - stackaddr = ((stackaddr as usize) + psize - remainder) + stackaddr = ((stackaddr as usize) + PAGE_SIZE - remainder) as *mut libc::c_void; } @@ -280,60 +312,42 @@ pub mod guard { // Instead, we'll just note where we expect rlimit to start // faulting, so our handler can report "stack overflow", and // trust that the kernel's own stack guard will work. - Some(stackaddr as usize) + let stackaddr = stackaddr as usize; + Some(stackaddr - PAGE_SIZE..stackaddr) } else { // Reallocate the last page of the stack. // This ensures SIGBUS will be raised on // stack overflow. - let result = mmap(stackaddr, psize, PROT_NONE, + let result = mmap(stackaddr, PAGE_SIZE, PROT_NONE, MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0); if result != stackaddr || result == MAP_FAILED { panic!("failed to allocate a guard page"); } + let guardaddr = stackaddr as usize; let offset = if cfg!(target_os = "freebsd") { 2 } else { 1 }; - Some(stackaddr as usize + offset * psize) + Some(guardaddr..guardaddr + offset * PAGE_SIZE) } } - #[cfg(target_os = "solaris")] - pub unsafe fn current() -> Option { - let mut current_stack: libc::stack_t = ::mem::zeroed(); - assert_eq!(libc::stack_getbounds(&mut current_stack), 0); - Some(current_stack.ss_sp as usize) - } - - #[cfg(target_os = "macos")] - pub unsafe fn current() -> Option { - Some(libc::pthread_get_stackaddr_np(libc::pthread_self()) as usize - - libc::pthread_get_stacksize_np(libc::pthread_self())) - } - - #[cfg(any(target_os = "openbsd", target_os = "bitrig"))] - pub unsafe fn current() -> Option { - let mut current_stack: libc::stack_t = ::mem::zeroed(); - assert_eq!(libc::pthread_stackseg_np(libc::pthread_self(), - &mut current_stack), 0); - - let extra = if cfg!(target_os = "bitrig") {3} else {1} * os::page_size(); - Some(if libc::pthread_main_np() == 1 { - // main thread - current_stack.ss_sp as usize - current_stack.ss_size + extra - } else { - // new thread - current_stack.ss_sp as usize - current_stack.ss_size - }) + #[cfg(any(target_os = "macos", + target_os = "bitrig", + target_os = "openbsd", + target_os = "solaris"))] + pub unsafe fn current() -> Option { + let stackaddr = get_stack_start()? as usize; + Some(stackaddr - PAGE_SIZE..stackaddr) } #[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux", target_os = "netbsd", target_os = "l4re"))] - pub unsafe fn current() -> Option { + pub unsafe fn current() -> Option { let mut ret = None; let mut attr: libc::pthread_attr_t = ::mem::zeroed(); assert_eq!(libc::pthread_attr_init(&mut attr), 0); @@ -352,12 +366,23 @@ pub mod guard { assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr, &mut size), 0); + let stackaddr = stackaddr as usize; ret = if cfg!(target_os = "freebsd") { - Some(stackaddr as usize - guardsize) + // FIXME does freebsd really fault *below* the guard addr? + let guardaddr = stackaddr - guardsize; + Some(guardaddr - PAGE_SIZE..guardaddr) } else if cfg!(target_os = "netbsd") { - Some(stackaddr as usize) + Some(stackaddr - guardsize..stackaddr) + } else if cfg!(all(target_os = "linux", target_env = "gnu")) { + // glibc used to include the guard area within the stack, as noted in the BUGS + // section of `man pthread_attr_getguardsize`. This has been corrected starting + // with glibc 2.27, and in some distro backports, so the guard is now placed at the + // end (below) the stack. There's no easy way for us to know which we have at + // runtime, so we'll just match any fault in the range right above or below the + // stack base to call that fault a stack overflow. + Some(stackaddr - guardsize..stackaddr + guardsize) } else { - Some(stackaddr as usize + guardsize) + Some(stackaddr..stackaddr + guardsize) }; } assert_eq!(libc::pthread_attr_destroy(&mut attr), 0); diff --git a/src/libstd/sys/wasm/thread.rs b/src/libstd/sys/wasm/thread.rs index 13980e0cc19d1..6a066509b492a 100644 --- a/src/libstd/sys/wasm/thread.rs +++ b/src/libstd/sys/wasm/thread.rs @@ -43,6 +43,7 @@ impl Thread { } pub mod guard { - pub unsafe fn current() -> Option { None } - pub unsafe fn init() -> Option { None } + pub type Guard = !; + pub unsafe fn current() -> Option { None } + pub unsafe fn init() -> Option { None } } diff --git a/src/libstd/sys/windows/thread.rs b/src/libstd/sys/windows/thread.rs index 74786d092855f..43abfbb1f645e 100644 --- a/src/libstd/sys/windows/thread.rs +++ b/src/libstd/sys/windows/thread.rs @@ -93,6 +93,7 @@ impl Thread { #[cfg_attr(test, allow(dead_code))] pub mod guard { - pub unsafe fn current() -> Option { None } - pub unsafe fn init() -> Option { None } + pub type Guard = !; + pub unsafe fn current() -> Option { None } + pub unsafe fn init() -> Option { None } } diff --git a/src/libstd/sys_common/thread_info.rs b/src/libstd/sys_common/thread_info.rs index 7970042b1d67d..6a2b6742367a5 100644 --- a/src/libstd/sys_common/thread_info.rs +++ b/src/libstd/sys_common/thread_info.rs @@ -11,10 +11,11 @@ #![allow(dead_code)] // stack_guard isn't used right now on all platforms use cell::RefCell; +use sys::thread::guard::Guard; use thread::Thread; struct ThreadInfo { - stack_guard: Option, + stack_guard: Option, thread: Thread, } @@ -38,11 +39,11 @@ pub fn current_thread() -> Option { ThreadInfo::with(|info| info.thread.clone()) } -pub fn stack_guard() -> Option { - ThreadInfo::with(|info| info.stack_guard).and_then(|o| o) +pub fn stack_guard() -> Option { + ThreadInfo::with(|info| info.stack_guard.clone()).and_then(|o| o) } -pub fn set(stack_guard: Option, thread: Thread) { +pub fn set(stack_guard: Option, thread: Thread) { THREAD_INFO.with(|c| assert!(c.borrow().is_none())); THREAD_INFO.with(move |c| *c.borrow_mut() = Some(ThreadInfo{ stack_guard, From b9441f2428f501de15dcb00af8da255a70302a0d Mon Sep 17 00:00:00 2001 From: Ryan Cumming Date: Thu, 1 Feb 2018 08:15:38 +1100 Subject: [PATCH 071/198] Improve char escaping in lexer messages Currently ', " and \ are escaped as \', \" and \\ respectively. This leads to confusing messages such as `error: unknown start of token: \\` when encountering a single backslash. Fix by emitting printable ASCII characters directly. This will still escape \r, \n, \t and Unicode characters. Fixes #47902 --- src/libsyntax/parse/lexer/mod.rs | 31 +++++++++++++--------- src/test/parse-fail/bad-char-literals.rs | 2 +- src/test/parse-fail/lex-stray-backslash.rs | 13 +++++++++ 3 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 src/test/parse-fail/lex-stray-backslash.rs diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 0fd069b76aadc..11ab84a572916 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -246,14 +246,27 @@ impl<'a> StringReader<'a> { self.err_span(self.mk_sp(from_pos, to_pos), m) } + /// Pushes a character to a message string for error reporting + fn push_escaped_char_for_msg(m: &mut String, c: char) { + match c { + '\u{20}'...'\u{7e}' => { + // Don't escape \, ' or " for user-facing messages + m.push(c); + } + _ => { + for c in c.escape_default() { + m.push(c); + } + } + } + } + /// Report a lexical error spanning [`from_pos`, `to_pos`), appending an /// escaped character to the error message fn fatal_span_char(&self, from_pos: BytePos, to_pos: BytePos, m: &str, c: char) -> FatalError { let mut m = m.to_string(); m.push_str(": "); - for c in c.escape_default() { - m.push(c) - } + Self::push_escaped_char_for_msg(&mut m, c); self.fatal_span_(from_pos, to_pos, &m[..]) } fn struct_fatal_span_char(&self, @@ -264,9 +277,7 @@ impl<'a> StringReader<'a> { -> DiagnosticBuilder<'a> { let mut m = m.to_string(); m.push_str(": "); - for c in c.escape_default() { - m.push(c) - } + Self::push_escaped_char_for_msg(&mut m, c); self.sess.span_diagnostic.struct_span_fatal(self.mk_sp(from_pos, to_pos), &m[..]) } @@ -275,9 +286,7 @@ impl<'a> StringReader<'a> { fn err_span_char(&self, from_pos: BytePos, to_pos: BytePos, m: &str, c: char) { let mut m = m.to_string(); m.push_str(": "); - for c in c.escape_default() { - m.push(c) - } + Self::push_escaped_char_for_msg(&mut m, c); self.err_span_(from_pos, to_pos, &m[..]); } fn struct_err_span_char(&self, @@ -288,9 +297,7 @@ impl<'a> StringReader<'a> { -> DiagnosticBuilder<'a> { let mut m = m.to_string(); m.push_str(": "); - for c in c.escape_default() { - m.push(c) - } + Self::push_escaped_char_for_msg(&mut m, c); self.sess.span_diagnostic.struct_span_err(self.mk_sp(from_pos, to_pos), &m[..]) } diff --git a/src/test/parse-fail/bad-char-literals.rs b/src/test/parse-fail/bad-char-literals.rs index 96311d6de176c..821015ece7712 100644 --- a/src/test/parse-fail/bad-char-literals.rs +++ b/src/test/parse-fail/bad-char-literals.rs @@ -15,7 +15,7 @@ fn main() { // these literals are just silly. '''; - //~^ ERROR: character constant must be escaped: \' + //~^ ERROR: character constant must be escaped: ' // note that this is a literal "\n" byte ' diff --git a/src/test/parse-fail/lex-stray-backslash.rs b/src/test/parse-fail/lex-stray-backslash.rs new file mode 100644 index 0000000000000..b6042bbdc1a26 --- /dev/null +++ b/src/test/parse-fail/lex-stray-backslash.rs @@ -0,0 +1,13 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z parse-only + +\ //~ ERROR: unknown start of token: \ From 9c3dc7e8721c03e1e033895f327ff71f8fd400b4 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Thu, 1 Feb 2018 00:00:38 +0200 Subject: [PATCH 072/198] rustc: prefer ParamEnvAnd and LayoutCx over tuples for LayoutOf. --- src/librustc/lint/context.rs | 2 +- src/librustc/ty/layout.rs | 171 ++++++++++++--------- src/librustc_const_eval/eval.rs | 3 +- src/librustc_lint/types.rs | 4 +- src/librustc_mir/interpret/eval_context.rs | 2 +- src/librustc_mir/transform/inline.rs | 3 +- src/librustc_trans/context.rs | 3 +- src/librustc_typeck/check/mod.rs | 3 +- 8 files changed, 107 insertions(+), 84 deletions(-) diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 5336c1944e8c4..929d5e7ec62bb 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -631,7 +631,7 @@ impl<'a, 'tcx> LayoutOf> for &'a LateContext<'a, 'tcx> { type TyLayout = Result, LayoutError<'tcx>>; fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout { - (self.tcx, self.param_env.reveal_all()).layout_of(ty) + self.tcx.layout_of(self.param_env.and(ty)) } } diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 69d07eafdca7a..63b91ff110161 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -895,7 +895,8 @@ fn layout_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } tcx.layout_depth.set(depth+1); - let layout = LayoutDetails::compute_uncached(tcx, param_env, ty); + let cx = LayoutCx { tcx, param_env }; + let layout = cx.layout_raw_uncached(ty); tcx.layout_depth.set(depth); layout @@ -908,13 +909,18 @@ pub fn provide(providers: &mut ty::maps::Providers) { }; } -impl<'a, 'tcx> LayoutDetails { - fn compute_uncached(tcx: TyCtxt<'a, 'tcx, 'tcx>, - param_env: ty::ParamEnv<'tcx>, - ty: Ty<'tcx>) - -> Result<&'tcx Self, LayoutError<'tcx>> { - let cx = (tcx, param_env); - let dl = cx.data_layout(); +#[derive(Copy, Clone)] +pub struct LayoutCx<'tcx, C> { + pub tcx: C, + pub param_env: ty::ParamEnv<'tcx> +} + +impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { + fn layout_raw_uncached(self, ty: Ty<'tcx>) + -> Result<&'tcx LayoutDetails, LayoutError<'tcx>> { + let tcx = self.tcx; + let param_env = self.param_env; + let dl = self.data_layout(); let scalar_unit = |value: Primitive| { let bits = value.size(dl).bits(); assert!(bits <= 128); @@ -924,7 +930,7 @@ impl<'a, 'tcx> LayoutDetails { } }; let scalar = |value: Primitive| { - tcx.intern_layout(LayoutDetails::scalar(cx, scalar_unit(value))) + tcx.intern_layout(LayoutDetails::scalar(self, scalar_unit(value))) }; let scalar_pair = |a: Scalar, b: Scalar| { let align = a.value.align(dl).max(b.value.align(dl)).max(dl.aggregate_align); @@ -1158,13 +1164,13 @@ impl<'a, 'tcx> LayoutDetails { Ok(match ty.sty { // Basic scalars. ty::TyBool => { - tcx.intern_layout(LayoutDetails::scalar(cx, Scalar { + tcx.intern_layout(LayoutDetails::scalar(self, Scalar { value: Int(I8, false), valid_range: 0..=1 })) } ty::TyChar => { - tcx.intern_layout(LayoutDetails::scalar(cx, Scalar { + tcx.intern_layout(LayoutDetails::scalar(self, Scalar { value: Int(I32, false), valid_range: 0..=0x10FFFF })) @@ -1180,7 +1186,7 @@ impl<'a, 'tcx> LayoutDetails { ty::TyFnPtr(_) => { let mut ptr = scalar_unit(Pointer); ptr.valid_range.start = 1; - tcx.intern_layout(LayoutDetails::scalar(cx, ptr)) + tcx.intern_layout(LayoutDetails::scalar(self, ptr)) } // The never type. @@ -1198,13 +1204,13 @@ impl<'a, 'tcx> LayoutDetails { let pointee = tcx.normalize_associated_type_in_env(&pointee, param_env); if pointee.is_sized(tcx, param_env, DUMMY_SP) { - return Ok(tcx.intern_layout(LayoutDetails::scalar(cx, data_ptr))); + return Ok(tcx.intern_layout(LayoutDetails::scalar(self, data_ptr))); } let unsized_part = tcx.struct_tail(pointee); let metadata = match unsized_part.sty { ty::TyForeign(..) => { - return Ok(tcx.intern_layout(LayoutDetails::scalar(cx, data_ptr))); + return Ok(tcx.intern_layout(LayoutDetails::scalar(self, data_ptr))); } ty::TySlice(_) | ty::TyStr => { scalar_unit(Int(dl.ptr_sized_integer(), false)) @@ -1230,7 +1236,7 @@ impl<'a, 'tcx> LayoutDetails { } } - let element = cx.layout_of(element)?; + let element = self.layout_of(element)?; let count = count.val.to_const_int().unwrap().to_u64().unwrap(); let size = element.size.checked_mul(count, dl) .ok_or(LayoutError::SizeOverflow(ty))?; @@ -1247,7 +1253,7 @@ impl<'a, 'tcx> LayoutDetails { }) } ty::TySlice(element) => { - let element = cx.layout_of(element)?; + let element = self.layout_of(element)?; tcx.intern_layout(LayoutDetails { variants: Variants::Single { index: 0 }, fields: FieldPlacement::Array { @@ -1289,14 +1295,14 @@ impl<'a, 'tcx> LayoutDetails { // Tuples, generators and closures. ty::TyGenerator(def_id, ref substs, _) => { let tys = substs.field_tys(def_id, tcx); - univariant(&tys.map(|ty| cx.layout_of(ty)).collect::, _>>()?, + univariant(&tys.map(|ty| self.layout_of(ty)).collect::, _>>()?, &ReprOptions::default(), StructKind::AlwaysSized)? } ty::TyClosure(def_id, ref substs) => { let tys = substs.upvar_tys(def_id, tcx); - univariant(&tys.map(|ty| cx.layout_of(ty)).collect::, _>>()?, + univariant(&tys.map(|ty| self.layout_of(ty)).collect::, _>>()?, &ReprOptions::default(), StructKind::AlwaysSized)? } @@ -1308,13 +1314,13 @@ impl<'a, 'tcx> LayoutDetails { StructKind::MaybeUnsized }; - univariant(&tys.iter().map(|ty| cx.layout_of(ty)).collect::, _>>()?, + univariant(&tys.iter().map(|ty| self.layout_of(ty)).collect::, _>>()?, &ReprOptions::default(), kind)? } // SIMD vector types. ty::TyAdt(def, ..) if def.repr.simd() => { - let element = cx.layout_of(ty.simd_type(tcx))?; + let element = self.layout_of(ty.simd_type(tcx))?; let count = ty.simd_size(tcx) as u64; assert!(count > 0); let scalar = match element.abi { @@ -1350,7 +1356,7 @@ impl<'a, 'tcx> LayoutDetails { // Cache the field layouts. let variants = def.variants.iter().map(|v| { v.fields.iter().map(|field| { - cx.layout_of(field.ty(tcx, substs)) + self.layout_of(field.ty(tcx, substs)) }).collect::, _>>() }).collect::, _>>()?; @@ -1430,7 +1436,7 @@ impl<'a, 'tcx> LayoutDetails { let mut st = univariant_uninterned(&variants[v], &def.repr, kind)?; st.variants = Variants::Single { index: v }; // Exclude 0 from the range of a newtype ABI NonZero. - if Some(def.did) == cx.tcx().lang_items().non_zero() { + if Some(def.did) == self.tcx.lang_items().non_zero() { match st.abi { Abi::Scalar(ref mut scalar) | Abi::ScalarPair(ref mut scalar, _) => { @@ -1482,7 +1488,7 @@ impl<'a, 'tcx> LayoutDetails { let count = (niche_variants.end - niche_variants.start + 1) as u128; for (field_index, field) in variants[i].iter().enumerate() { let (offset, niche, niche_start) = - match field.find_niche(cx, count)? { + match field.find_niche(self, count)? { Some(niche) => niche, None => continue }; @@ -1687,56 +1693,49 @@ impl<'a, 'tcx> LayoutDetails { /// This is invoked by the `layout_raw` query to record the final /// layout of each type. #[inline] - fn record_layout_for_printing(tcx: TyCtxt<'a, 'tcx, 'tcx>, - ty: Ty<'tcx>, - param_env: ty::ParamEnv<'tcx>, - layout: TyLayout<'tcx>) { + fn record_layout_for_printing(self, layout: TyLayout<'tcx>) { // If we are running with `-Zprint-type-sizes`, record layouts for // dumping later. Ignore layouts that are done with non-empty // environments or non-monomorphic layouts, as the user only wants // to see the stuff resulting from the final trans session. if - !tcx.sess.opts.debugging_opts.print_type_sizes || - ty.has_param_types() || - ty.has_self_ty() || - !param_env.caller_bounds.is_empty() + !self.tcx.sess.opts.debugging_opts.print_type_sizes || + layout.ty.has_param_types() || + layout.ty.has_self_ty() || + !self.param_env.caller_bounds.is_empty() { return; } - Self::record_layout_for_printing_outlined(tcx, ty, param_env, layout) + self.record_layout_for_printing_outlined(layout) } - fn record_layout_for_printing_outlined(tcx: TyCtxt<'a, 'tcx, 'tcx>, - ty: Ty<'tcx>, - param_env: ty::ParamEnv<'tcx>, - layout: TyLayout<'tcx>) { - let cx = (tcx, param_env); + fn record_layout_for_printing_outlined(self, layout: TyLayout<'tcx>) { // (delay format until we actually need it) let record = |kind, opt_discr_size, variants| { - let type_desc = format!("{:?}", ty); - tcx.sess.code_stats.borrow_mut().record_type_size(kind, - type_desc, - layout.align, - layout.size, - opt_discr_size, - variants); + let type_desc = format!("{:?}", layout.ty); + self.tcx.sess.code_stats.borrow_mut().record_type_size(kind, + type_desc, + layout.align, + layout.size, + opt_discr_size, + variants); }; - let adt_def = match ty.sty { + let adt_def = match layout.ty.sty { ty::TyAdt(ref adt_def, _) => { - debug!("print-type-size t: `{:?}` process adt", ty); + debug!("print-type-size t: `{:?}` process adt", layout.ty); adt_def } ty::TyClosure(..) => { - debug!("print-type-size t: `{:?}` record closure", ty); + debug!("print-type-size t: `{:?}` record closure", layout.ty); record(DataTypeKind::Closure, None, vec![]); return; } _ => { - debug!("print-type-size t: `{:?}` skip non-nominal", ty); + debug!("print-type-size t: `{:?}` skip non-nominal", layout.ty); return; } }; @@ -1748,7 +1747,7 @@ impl<'a, 'tcx> LayoutDetails { layout: TyLayout<'tcx>| { let mut min_size = Size::from_bytes(0); let field_info: Vec<_> = flds.iter().enumerate().map(|(i, &name)| { - match layout.field(cx, i) { + match layout.field(self, i) { Err(err) => { bug!("no layout found for field {}: `{:?}`", name, err); } @@ -1808,18 +1807,18 @@ impl<'a, 'tcx> LayoutDetails { Variants::NicheFilling { .. } | Variants::Tagged { .. } => { debug!("print-type-size `{:#?}` adt general variants def {}", - ty, adt_def.variants.len()); + layout.ty, adt_def.variants.len()); let variant_infos: Vec<_> = adt_def.variants.iter().enumerate().map(|(i, variant_def)| { let fields: Vec<_> = variant_def.fields.iter().map(|f| f.name).collect(); build_variant_info(Some(variant_def.name), &fields, - layout.for_variant(cx, i)) + layout.for_variant(self, i)) }) .collect(); record(adt_kind.into(), match layout.variants { - Variants::Tagged { ref discr, .. } => Some(discr.value.size(tcx)), + Variants::Tagged { ref discr, .. } => Some(discr.value.size(self)), _ => None }, variant_infos); } @@ -1855,7 +1854,7 @@ impl<'a, 'tcx> SizeSkeleton<'tcx> { assert!(!ty.has_infer_types()); // First try computing a static layout. - let err = match (tcx, param_env).layout_of(ty) { + let err = match tcx.layout_of(param_env.and(ty)) { Ok(layout) => { return Ok(SizeSkeleton::Known(layout.size)); } @@ -2001,15 +2000,15 @@ impl<'a, 'gcx, 'tcx> HasTyCtxt<'gcx> for TyCtxt<'a, 'gcx, 'tcx> { } } -impl<'a, 'gcx, 'tcx, T: Copy> HasDataLayout for (TyCtxt<'a, 'gcx, 'tcx>, T) { +impl<'tcx, T: HasDataLayout> HasDataLayout for LayoutCx<'tcx, T> { fn data_layout(&self) -> &TargetDataLayout { - self.0.data_layout() + self.tcx.data_layout() } } -impl<'a, 'gcx, 'tcx, T: Copy> HasTyCtxt<'gcx> for (TyCtxt<'a, 'gcx, 'tcx>, T) { +impl<'gcx, 'tcx, T: HasTyCtxt<'gcx>> HasTyCtxt<'gcx> for LayoutCx<'tcx, T> { fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'gcx> { - self.0.tcx() + self.tcx.tcx() } } @@ -2042,17 +2041,15 @@ pub trait LayoutOf { fn layout_of(self, ty: T) -> Self::TyLayout; } -impl<'a, 'tcx> LayoutOf> for (TyCtxt<'a, 'tcx, 'tcx>, ty::ParamEnv<'tcx>) { +impl<'a, 'tcx> LayoutOf> for LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { type TyLayout = Result, LayoutError<'tcx>>; /// Computes the layout of a type. Note that this implicitly /// executes in "reveal all" mode. - #[inline] fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout { - let (tcx, param_env) = self; - - let ty = tcx.normalize_associated_type_in_env(&ty, param_env.reveal_all()); - let details = tcx.layout_raw(param_env.reveal_all().and(ty))?; + let param_env = self.param_env.reveal_all(); + let ty = self.tcx.normalize_associated_type_in_env(&ty, param_env); + let details = self.tcx.layout_raw(param_env.and(ty))?; let layout = TyLayout { ty, details @@ -2064,24 +2061,21 @@ impl<'a, 'tcx> LayoutOf> for (TyCtxt<'a, 'tcx, 'tcx>, ty::ParamEnv<'tcx // completed, to avoid problems around recursive structures // and the like. (Admitedly, I wasn't able to reproduce a problem // here, but it seems like the right thing to do. -nmatsakis) - LayoutDetails::record_layout_for_printing(tcx, ty, param_env, layout); + self.record_layout_for_printing(layout); Ok(layout) } } -impl<'a, 'tcx> LayoutOf> for (ty::maps::TyCtxtAt<'a, 'tcx, 'tcx>, - ty::ParamEnv<'tcx>) { +impl<'a, 'tcx> LayoutOf> for LayoutCx<'tcx, ty::maps::TyCtxtAt<'a, 'tcx, 'tcx>> { type TyLayout = Result, LayoutError<'tcx>>; /// Computes the layout of a type. Note that this implicitly /// executes in "reveal all" mode. - #[inline] fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout { - let (tcx_at, param_env) = self; - - let ty = tcx_at.tcx.normalize_associated_type_in_env(&ty, param_env.reveal_all()); - let details = tcx_at.layout_raw(param_env.reveal_all().and(ty))?; + let param_env = self.param_env.reveal_all(); + let ty = self.tcx.normalize_associated_type_in_env(&ty, param_env.reveal_all()); + let details = self.tcx.layout_raw(param_env.reveal_all().and(ty))?; let layout = TyLayout { ty, details @@ -2093,12 +2087,45 @@ impl<'a, 'tcx> LayoutOf> for (ty::maps::TyCtxtAt<'a, 'tcx, 'tcx>, // completed, to avoid problems around recursive structures // and the like. (Admitedly, I wasn't able to reproduce a problem // here, but it seems like the right thing to do. -nmatsakis) - LayoutDetails::record_layout_for_printing(tcx_at.tcx, ty, param_env, layout); + let cx = LayoutCx { + tcx: *self.tcx, + param_env: self.param_env + }; + cx.record_layout_for_printing(layout); Ok(layout) } } +// Helper (inherent) `layout_of` methods to avoid pushing `LayoutCx` to users. +impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { + /// Computes the layout of a type. Note that this implicitly + /// executes in "reveal all" mode. + #[inline] + pub fn layout_of(self, param_env_and_ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) + -> Result, LayoutError<'tcx>> { + let cx = LayoutCx { + tcx: self, + param_env: param_env_and_ty.param_env + }; + cx.layout_of(param_env_and_ty.value) + } +} + +impl<'a, 'tcx> ty::maps::TyCtxtAt<'a, 'tcx, 'tcx> { + /// Computes the layout of a type. Note that this implicitly + /// executes in "reveal all" mode. + #[inline] + pub fn layout_of(self, param_env_and_ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) + -> Result, LayoutError<'tcx>> { + let cx = LayoutCx { + tcx: self, + param_env: param_env_and_ty.param_env + }; + cx.layout_of(param_env_and_ty.value) + } +} + impl<'a, 'tcx> TyLayout<'tcx> { pub fn for_variant(&self, cx: C, variant_index: usize) -> Self where C: LayoutOf> + HasTyCtxt<'tcx>, diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index 418bd4b5effc6..1d2813e4f6704 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -17,7 +17,6 @@ use rustc::hir::map::blocks::FnLikeNode; use rustc::hir::def::{Def, CtorKind}; use rustc::hir::def_id::DefId; use rustc::ty::{self, Ty, TyCtxt}; -use rustc::ty::layout::LayoutOf; use rustc::ty::util::IntTypeExt; use rustc::ty::subst::{Substs, Subst}; use rustc::util::common::ErrorReported; @@ -313,7 +312,7 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>, if tcx.fn_sig(def_id).abi() == Abi::RustIntrinsic { let layout_of = |ty: Ty<'tcx>| { let ty = tcx.erase_regions(&ty); - (tcx.at(e.span), cx.param_env).layout_of(ty).map_err(|err| { + tcx.at(e.span).layout_of(cx.param_env.and(ty)).map_err(|err| { ConstEvalErr { span: e.span, kind: LayoutError(err) } }) }; diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index e0999db6e3e66..e7e4119b9999b 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -437,8 +437,8 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { // repr(transparent) types are allowed to have arbitrary ZSTs, not just // PhantomData -- skip checking all ZST fields if def.repr.transparent() { - let is_zst = (cx, cx.param_env(field.did)) - .layout_of(field_ty) + let is_zst = cx + .layout_of(cx.param_env(field.did).and(field_ty)) .map(|layout| layout.is_zst()) .unwrap_or(false); if is_zst { diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index baec0fea50f1e..02fcb69fef5ac 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -172,7 +172,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> LayoutOf> for &'a EvalContext<'a, 'tcx type TyLayout = EvalResult<'tcx, TyLayout<'tcx>>; fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout { - (self.tcx, self.param_env).layout_of(ty) + self.tcx.layout_of(self.param_env.and(ty)) .map_err(|layout| EvalErrorKind::Layout(layout).into()) } } diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index 43ee75d1e2ba2..ceea97e3ed3b0 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -19,7 +19,6 @@ use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc::mir::*; use rustc::mir::visit::*; use rustc::ty::{self, Instance, Ty, TyCtxt, TypeFoldable}; -use rustc::ty::layout::LayoutOf; use rustc::ty::subst::{Subst,Substs}; use std::collections::VecDeque; @@ -655,7 +654,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { fn type_size_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>) -> Option { - (tcx, param_env).layout_of(ty).ok().map(|layout| layout.size.bytes()) + tcx.layout_of(param_env.and(ty)).ok().map(|layout| layout.size.bytes()) } fn subst_and_normalize<'a, 'tcx: 'a>( diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index 06b8d9ff7b306..a285e5f263ab7 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -464,8 +464,7 @@ impl<'a, 'tcx> LayoutOf> for &'a CodegenCx<'a, 'tcx> { type TyLayout = TyLayout<'tcx>; fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout { - (self.tcx, ty::ParamEnv::empty(traits::Reveal::All)) - .layout_of(ty) + self.tcx.layout_of(ty::ParamEnv::empty(traits::Reveal::All).and(ty)) .unwrap_or_else(|e| match e { LayoutError::SizeOverflow(_) => self.sess().fatal(&e.to_string()), _ => bug!("failed to get layout for `{}`: {}", ty, e) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 483dd345286d4..e4023b4d9590b 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -100,7 +100,6 @@ use rustc::ty::adjustment::{Adjust, Adjustment, AutoBorrow}; use rustc::ty::fold::TypeFoldable; use rustc::ty::maps::Providers; use rustc::ty::util::{Representability, IntTypeExt}; -use rustc::ty::layout::LayoutOf; use errors::{DiagnosticBuilder, DiagnosticId}; use require_c_abi_if_variadic; @@ -1551,7 +1550,7 @@ fn check_transparent<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span, def_id: De let field_infos: Vec<_> = adt.non_enum_variant().fields.iter().map(|field| { let ty = field.ty(tcx, Substs::identity_for_item(tcx, field.did)); let param_env = tcx.param_env(field.did); - let layout = (tcx, param_env).layout_of(ty); + let layout = tcx.layout_of(param_env.and(ty)); // We are currently checking the type this field came from, so it must be local let span = tcx.hir.span_if_local(field.did).unwrap(); let zst = layout.map(|layout| layout.is_zst()).unwrap_or(false); From cf78ff3913f3efeefb2c90dcae18682f460b0d84 Mon Sep 17 00:00:00 2001 From: Volker Mische Date: Thu, 1 Feb 2018 00:21:43 +0100 Subject: [PATCH 073/198] Fix lang items box example code The `exchange_free` lang item is gone in favour of `box_free` [1]. Some warnings are also fixed by this commit. [1]: https://github.com/rust-lang/rust/commit/ca115dd083a1fe1d2b4892c5e50e49eb83ff1f3 --- .../src/language-features/lang-items.md | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/doc/unstable-book/src/language-features/lang-items.md b/src/doc/unstable-book/src/language-features/lang-items.md index 0137a052a62d8..c51674186146b 100644 --- a/src/doc/unstable-book/src/language-features/lang-items.md +++ b/src/doc/unstable-book/src/language-features/lang-items.md @@ -37,28 +37,23 @@ unsafe fn allocate(size: usize, _align: usize) -> *mut u8 { p } -#[lang = "exchange_free"] -unsafe fn deallocate(ptr: *mut u8, _size: usize, _align: usize) { - libc::free(ptr as *mut libc::c_void) -} - #[lang = "box_free"] unsafe fn box_free(ptr: *mut T) { - deallocate(ptr as *mut u8, ::core::mem::size_of_val(&*ptr), ::core::mem::align_of_val(&*ptr)); + libc::free(ptr as *mut libc::c_void) } #[start] -fn main(argc: isize, argv: *const *const u8) -> isize { - let x = box 1; +fn main(_argc: isize, _argv: *const *const u8) -> isize { + let _x = box 1; 0 } #[lang = "eh_personality"] extern fn rust_eh_personality() {} #[lang = "panic_fmt"] extern fn rust_begin_panic() -> ! { unsafe { intrinsics::abort() } } -# #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {} -# #[no_mangle] pub extern fn rust_eh_register_frames () {} -# #[no_mangle] pub extern fn rust_eh_unregister_frames () {} +#[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {} +#[no_mangle] pub extern fn rust_eh_register_frames () {} +#[no_mangle] pub extern fn rust_eh_unregister_frames () {} ``` Note the use of `abort`: the `exchange_malloc` lang item is assumed to @@ -80,7 +75,7 @@ Other features provided by lang items include: Lang items are loaded lazily by the compiler; e.g. if one never uses `Box` then there is no need to define functions for `exchange_malloc` -and `exchange_free`. `rustc` will emit an error when an item is needed +and `box_free`. `rustc` will emit an error when an item is needed but not found in the current crate or any that it depends on. Most lang items are defined by `libcore`, but if you're trying to build @@ -318,4 +313,4 @@ the source code. - `phantom_data`: `libcore/marker.rs` - `freeze`: `libcore/marker.rs` - `debug_trait`: `libcore/fmt/mod.rs` - - `non_zero`: `libcore/nonzero.rs` \ No newline at end of file + - `non_zero`: `libcore/nonzero.rs` From f97629160fe944cd9185ba180221d19f66126e2f Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 30 Jan 2018 14:47:25 +0530 Subject: [PATCH 074/198] Correctly subst the fn_sig so that we get the correct types Otherwise we get random TySelfs there, which means operations on RETURN_PLACE end up breaking down badly. --- src/librustc_mir/shim.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 36dd359b20c86..54aed69a315d2 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -294,7 +294,7 @@ fn build_clone_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, { debug!("build_clone_shim(def_id={:?})", def_id); - let mut builder = CloneShimBuilder::new(tcx, def_id); + let mut builder = CloneShimBuilder::new(tcx, def_id, self_ty); let is_copy = !self_ty.moves_by_default(tcx, tcx.param_env(def_id), builder.span); match self_ty.sty { @@ -327,8 +327,14 @@ struct CloneShimBuilder<'a, 'tcx: 'a> { } impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { - fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Self { - let sig = tcx.fn_sig(def_id); + fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, + def_id: DefId, + self_ty: Ty<'tcx>) -> Self { + // we must subst the self_ty because it's + // otherwise going to be TySelf and we can't index + // or access fields of a Place of type TySelf. + let substs = tcx.mk_substs_trait(self_ty, &[]); + let sig = tcx.fn_sig(def_id).subst(tcx, substs); let sig = tcx.erase_late_bound_regions(&sig); let span = tcx.def_span(def_id); From dfd244d952676009e807dca6a9bfdb378b7db72f Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 30 Jan 2018 17:30:15 +0530 Subject: [PATCH 075/198] Eliminate ret_field and ret intermediates in array clone shim --- src/librustc_mir/shim.rs | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 54aed69a315d2..58914097b43fb 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -505,11 +505,11 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { fn array_shim(&mut self, ty: Ty<'tcx>, len: u64) { let tcx = self.tcx; let span = self.span; - let rcvr = Place::Local(Local::new(1+0)).deref(); + let src = Place::Local(Local::new(1+0)).deref(); + let dest = Place::Local(RETURN_PLACE); let beg = self.local_decls.push(temp_decl(Mutability::Mut, tcx.types.usize, span)); let end = self.make_place(Mutability::Not, tcx.types.usize); - let ret = self.make_place(Mutability::Mut, tcx.mk_array(ty, len)); // BB #0 // `let mut beg = 0;` @@ -539,25 +539,17 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { self.loop_header(Place::Local(beg), end, BasicBlock::new(2), BasicBlock::new(4), false); // BB #2 - // `let cloned = Clone::clone(rcvr[beg])`; + // `dest[i] = Clone::clone(src[beg])`; // Goto #3 if ok, #5 if unwinding happens. - let rcvr_field = rcvr.clone().index(beg); - let cloned = self.make_place(Mutability::Not, ty); - self.make_clone_call(cloned.clone(), rcvr_field, ty, BasicBlock::new(3), + let dest_field = dest.clone().index(beg); + let src_field = src.clone().index(beg); + self.make_clone_call(dest_field, src_field, ty, BasicBlock::new(3), BasicBlock::new(5)); // BB #3 - // `ret[beg] = cloned;` // `beg = beg + 1;` // `goto #1`; - let ret_field = ret.clone().index(beg); let statements = vec![ - self.make_statement( - StatementKind::Assign( - ret_field, - Rvalue::Use(Operand::Move(cloned)) - ) - ), self.make_statement( StatementKind::Assign( Place::Local(beg), @@ -572,14 +564,8 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { self.block(statements, TerminatorKind::Goto { target: BasicBlock::new(1) }, false); // BB #4 - // `return ret;` - let ret_statement = self.make_statement( - StatementKind::Assign( - Place::Local(RETURN_PLACE), - Rvalue::Use(Operand::Move(ret.clone())), - ) - ); - self.block(vec![ret_statement], TerminatorKind::Return, false); + // `return dest;` + self.block(vec![], TerminatorKind::Return, false); // BB #5 (cleanup) // `let end = beg;` @@ -604,9 +590,9 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { BasicBlock::new(7), BasicBlock::new(9), true); // BB #7 (cleanup) - // `drop(ret[beg])`; + // `drop(dest[beg])`; self.block(vec![], TerminatorKind::Drop { - location: ret.index(beg), + location: dest.index(beg), target: BasicBlock::new(8), unwind: None, }, true); From 8a8f91b89effd9005c0ee536bcd8767304ac1363 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 30 Jan 2018 17:36:19 +0530 Subject: [PATCH 076/198] Generalize tuple_like_shim's code to be useful for enums --- src/librustc_mir/shim.rs | 63 +++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 24 deletions(-) diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 58914097b43fb..42ffcc194ca8c 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -297,18 +297,22 @@ fn build_clone_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let mut builder = CloneShimBuilder::new(tcx, def_id, self_ty); let is_copy = !self_ty.moves_by_default(tcx, tcx.param_env(def_id), builder.span); + let dest = Place::Local(RETURN_PLACE); + let src = Place::Local(Local::new(1+0)).deref(); + match self_ty.sty { _ if is_copy => builder.copy_shim(), ty::TyArray(ty, len) => { let len = len.val.to_const_int().unwrap().to_u64().unwrap(); - builder.array_shim(ty, len) + builder.array_shim(dest, src, ty, len) } ty::TyClosure(def_id, substs) => { builder.tuple_like_shim( - &substs.upvar_tys(def_id, tcx).collect::>() + dest, src, + substs.upvar_tys(def_id, tcx) ) } - ty::TyTuple(tys, _) => builder.tuple_like_shim(&**tys), + ty::TyTuple(tys, _) => builder.tuple_like_shim(dest, src, tys.iter().cloned()), _ => { bug!("clone shim for `{:?}` which is not `Copy` and is not an aggregate", self_ty) } @@ -382,6 +386,14 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { }) } + /// Gives the index of an upcoming BasicBlock, with an offset. + /// offset=0 will give you the index of the next BasicBlock, + /// offset=1 will give the index of the next-to-next block, + /// offset=-1 will give you the index of the last-created block + fn block_index_offset(&mut self, offset: usize) -> BasicBlock { + BasicBlock::new(self.blocks.len() + offset) + } + fn make_statement(&self, kind: StatementKind<'tcx>) -> Statement<'tcx> { Statement { source_info: self.source_info(), @@ -502,11 +514,9 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { } } - fn array_shim(&mut self, ty: Ty<'tcx>, len: u64) { + fn array_shim(&mut self, dest: Place<'tcx>, src: Place<'tcx>, ty: Ty<'tcx>, len: u64) { let tcx = self.tcx; let span = self.span; - let src = Place::Local(Local::new(1+0)).deref(); - let dest = Place::Local(RETURN_PLACE); let beg = self.local_decls.push(temp_decl(Mutability::Mut, tcx.types.usize, span)); let end = self.make_place(Mutability::Not, tcx.types.usize); @@ -616,34 +626,39 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { self.block(vec![], TerminatorKind::Resume, true); } - fn tuple_like_shim(&mut self, tys: &[ty::Ty<'tcx>]) { - let rcvr = Place::Local(Local::new(1+0)).deref(); - - let mut previous_place = None; - let return_place = Place::Local(RETURN_PLACE); - for (i, ity) in tys.iter().enumerate() { + fn tuple_like_shim(&mut self, dest: Place<'tcx>, + src: Place<'tcx>, tys: I) + where I: Iterator> { + let mut previous_field = None; + for (i, ity) in tys.enumerate() { let field = Field::new(i); - let rcvr_field = rcvr.clone().field(field, *ity); + let src_field = src.clone().field(field, ity); + + let dest_field = dest.clone().field(field, ity); - let place = return_place.clone().field(field, *ity); + // #(2i + 1) is the cleanup block for the previous clone operation + let cleanup_block = self.block_index_offset(1); + // #(2i + 2) is the next cloning block + // (or the Return terminator if this is the last block) + let next_block = self.block_index_offset(2); // BB #(2i) - // `returns[i] = Clone::clone(&rcvr.i);` + // `dest.i = Clone::clone(&src.i);` // Goto #(2i + 2) if ok, #(2i + 1) if unwinding happens. self.make_clone_call( - place.clone(), - rcvr_field, - *ity, - BasicBlock::new(2 * i + 2), - BasicBlock::new(2 * i + 1), + dest_field.clone(), + src_field, + ity, + next_block, + cleanup_block, ); // BB #(2i + 1) (cleanup) - if let Some(previous_place) = previous_place.take() { + if let Some((previous_field, previous_cleanup)) = previous_field.take() { // Drop previous field and goto previous cleanup block. self.block(vec![], TerminatorKind::Drop { - location: previous_place, - target: BasicBlock::new(2 * i - 1), + location: previous_field, + target: previous_cleanup, unwind: None, }, true); } else { @@ -651,7 +666,7 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { self.block(vec![], TerminatorKind::Resume, true); } - previous_place = Some(place); + previous_field = Some((dest_field, cleanup_block)); } self.block(vec![], TerminatorKind::Return, false); From 0fd4f3794495d7348ccb8d5d7dc1404d380ecbc4 Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Wed, 31 Jan 2018 22:11:50 -0500 Subject: [PATCH 077/198] Fix overflow when performing drop check calculations in NLL Clearing out the infcx's region constraints after processing each type ends up interacting badly with normalizing associated types. This commit keeps all region constraints intact until the end of TypeLivenessGenerator.add_drop_live_constraint, ensuring that normalized types are able to re-use existing inference variables. Fixes #47589 --- .../borrow_check/nll/type_check/liveness.rs | 117 ++++++++++++------ src/test/run-pass/nll/issue-47589.rs | 33 +++++ 2 files changed, 113 insertions(+), 37 deletions(-) create mode 100644 src/test/run-pass/nll/issue-47589.rs diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness.rs index 6c2037810d326..93bb3cb6647a9 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness.rs @@ -15,7 +15,11 @@ use dataflow::move_paths::{HasMoveData, MoveData}; use rustc::mir::{BasicBlock, Location, Mir}; use rustc::mir::Local; use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; +//use rustc::ty::subst::Kind; +use rustc::traits; +use rustc::infer::InferOk; use rustc::util::common::ErrorReported; +use borrow_check::nll::type_check::AtLocation; use rustc_data_structures::fx::FxHashSet; use syntax::codemap::DUMMY_SP; use util::liveness::LivenessResults; @@ -184,48 +188,87 @@ impl<'gen, 'typeck, 'flow, 'gcx, 'tcx> TypeLivenessGenerator<'gen, 'typeck, 'flo location ); - let tcx = self.cx.infcx.tcx; - let mut types = vec![(dropped_ty, 0)]; - let mut known = FxHashSet(); - while let Some((ty, depth)) = types.pop() { - let span = DUMMY_SP; // FIXME - let result = match tcx.dtorck_constraint_for_ty(span, dropped_ty, depth, ty) { - Ok(result) => result, - Err(ErrorReported) => { - continue; - } - }; - - let ty::DtorckConstraint { - outlives, - dtorck_types, - } = result; - - // All things in the `outlives` array may be touched by - // the destructor and must be live at this point. - for outlive in outlives { - let cause = Cause::DropVar(dropped_local, location); - self.push_type_live_constraint(outlive, location, cause); - } + // If we end visiting the same type twice (usually due to a cycle involving + // associated types), we need to ensure that its region types match up with the type + // we added to the 'known' map the first time around. For this reason, we need + // our infcx to hold onto its calculated region constraints after each call + // to dtorck_constraint_for_ty. Otherwise, normalizing the corresponding associated + // type will end up instantiating the type with a new set of inference variables + // Since this new type will never be in 'known', we end up looping forever. + // + // For this reason, we avoid calling TypeChecker.normalize, instead doing all normalization + // ourselves in one large 'fully_perform_op' callback. + let (type_constraints, kind_constraints) = self.cx.fully_perform_op(location.at_self(), + |cx| { + + let tcx = cx.infcx.tcx; + let mut selcx = traits::SelectionContext::new(cx.infcx); + let cause = cx.misc(cx.last_span); + + let mut types = vec![(dropped_ty, 0)]; + let mut final_obligations = Vec::new(); + let mut type_constraints = Vec::new(); + let mut kind_constraints = Vec::new(); - // However, there may also be some types that - // `dtorck_constraint_for_ty` could not resolve (e.g., - // associated types and parameters). We need to normalize - // associated types here and possibly recursively process. - for ty in dtorck_types { - let ty = self.cx.normalize(&ty, location); - let ty = self.cx.infcx.resolve_type_and_region_vars_if_possible(&ty); - match ty.sty { - ty::TyParam(..) | ty::TyProjection(..) | ty::TyAnon(..) => { - let cause = Cause::DropVar(dropped_local, location); - self.push_type_live_constraint(ty, location, cause); + let mut known = FxHashSet(); + + while let Some((ty, depth)) = types.pop() { + let span = DUMMY_SP; // FIXME + let result = match tcx.dtorck_constraint_for_ty(span, dropped_ty, depth, ty) { + Ok(result) => result, + Err(ErrorReported) => { + continue; } + }; + + let ty::DtorckConstraint { + outlives, + dtorck_types, + } = result; + + // All things in the `outlives` array may be touched by + // the destructor and must be live at this point. + for outlive in outlives { + let cause = Cause::DropVar(dropped_local, location); + kind_constraints.push((outlive, location, cause)); + } - _ => if known.insert(ty) { - types.push((ty, depth + 1)); - }, + // However, there may also be some types that + // `dtorck_constraint_for_ty` could not resolve (e.g., + // associated types and parameters). We need to normalize + // associated types here and possibly recursively process. + for ty in dtorck_types { + let traits::Normalized { value: ty, obligations } = + traits::normalize(&mut selcx, cx.param_env, cause.clone(), &ty); + + final_obligations.extend(obligations); + + //let ty = self.cx.normalize(&ty, location); + let ty = cx.infcx.resolve_type_and_region_vars_if_possible(&ty); + match ty.sty { + ty::TyParam(..) | ty::TyProjection(..) | ty::TyAnon(..) => { + let cause = Cause::DropVar(dropped_local, location); + type_constraints.push((ty, location, cause)); + } + + _ => if known.insert(ty) { + types.push((ty, depth + 1)); + }, + } } } + + Ok(InferOk { + value: (type_constraints, kind_constraints), obligations: final_obligations + }) + }).unwrap(); + + for (ty, location, cause) in type_constraints { + self.push_type_live_constraint(ty, location, cause); + } + + for (kind, location, cause) in kind_constraints { + self.push_type_live_constraint(kind, location, cause); } } } diff --git a/src/test/run-pass/nll/issue-47589.rs b/src/test/run-pass/nll/issue-47589.rs new file mode 100644 index 0000000000000..393c18efad0ad --- /dev/null +++ b/src/test/run-pass/nll/issue-47589.rs @@ -0,0 +1,33 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(nll)] + +pub struct DescriptorSet<'a> { + pub slots: Vec> +} + +pub trait ResourcesTrait<'r>: Sized { + type DescriptorSet: 'r; +} + +pub struct Resources; + +impl<'a> ResourcesTrait<'a> for Resources { + type DescriptorSet = DescriptorSet<'a>; +} + +pub enum AttachInfo<'a, R: ResourcesTrait<'a>> { + NextDescriptorSet(Box) +} + +fn main() { + let _x = DescriptorSet {slots: Vec::new()}; +} From 8f9d91587fa1d2595405f8a1cc1c43e7b044be1a Mon Sep 17 00:00:00 2001 From: "Zack M. Davis" Date: Wed, 31 Jan 2018 20:40:03 -0800 Subject: [PATCH 078/198] in which HirIdMap is introduced as an affordance for using HirIds more The glossaries in the draft rustc-guide book and librustc/README.md state that `NodeId` is being gradually phased out in favor of `HirId`; as such, the present author claims that we ought to have a typedef for efficient `HirId` maps and sets in the module for such, even if no use for them has been made as yet (compatibility constraints preventing the use of it in the author's present unit of work): it is important to create the psychological "affordance" (in James J. Gibson's sense) that `HirId`s are a thing that compiler developers can work with. --- src/librustc/util/nodemap.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/librustc/util/nodemap.rs b/src/librustc/util/nodemap.rs index 674f67d5cd2f1..f98a8f834df8a 100644 --- a/src/librustc/util/nodemap.rs +++ b/src/librustc/util/nodemap.rs @@ -13,7 +13,7 @@ #![allow(non_snake_case)] use hir::def_id::DefId; -use hir::ItemLocalId; +use hir::{HirId, ItemLocalId}; use syntax::ast; pub use rustc_data_structures::fx::FxHashMap; @@ -21,10 +21,12 @@ pub use rustc_data_structures::fx::FxHashSet; pub type NodeMap = FxHashMap; pub type DefIdMap = FxHashMap; +pub type HirIdMap = FxHashMap; pub type ItemLocalMap = FxHashMap; pub type NodeSet = FxHashSet; pub type DefIdSet = FxHashSet; +pub type HirIdSet = FxHashSet; pub type ItemLocalSet = FxHashSet; pub fn NodeMap() -> NodeMap { FxHashMap() } From e4b1a7971d7b4ed61d27af44e3169cb26595ae13 Mon Sep 17 00:00:00 2001 From: "Zack M. Davis" Date: Wed, 31 Jan 2018 20:56:01 -0800 Subject: [PATCH 079/198] concerning well-formed suggestions for unused shorthand field patterns Previously, unused variables would get a note that the warning could be silenced by prefixing the variable with an underscore, but that doesn't work for field shorthand patterns, which the liveness analysis didn't know about. The "to avoid this warning" verbiage seemed unnecessary. Resolves #47390. --- src/librustc/middle/liveness.rs | 63 ++++++++++++++----- ...47390-unused-variable-in-struct-pattern.rs | 34 ++++++++++ ...0-unused-variable-in-struct-pattern.stderr | 40 ++++++++++++ src/test/ui/span/issue-24690.stderr | 3 +- 4 files changed, 124 insertions(+), 16 deletions(-) create mode 100644 src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs create mode 100644 src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.stderr diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 297586f140e34..10497c95e27d0 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -109,7 +109,7 @@ use self::VarKind::*; use hir::def::*; use ty::{self, TyCtxt}; use lint; -use util::nodemap::NodeMap; +use util::nodemap::{NodeMap, NodeSet}; use std::{fmt, usize}; use std::io::prelude::*; @@ -244,7 +244,8 @@ struct CaptureInfo { #[derive(Copy, Clone, Debug)] struct LocalInfo { id: NodeId, - name: ast::Name + name: ast::Name, + is_shorthand: bool, } #[derive(Copy, Clone, Debug)] @@ -333,6 +334,13 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> { } } + fn variable_is_shorthand(&self, var: Variable) -> bool { + match self.var_kinds[var.get()] { + Local(LocalInfo { is_shorthand, .. }) => is_shorthand, + Arg(..) | CleanExit => false + } + } + fn set_captures(&mut self, node_id: NodeId, cs: Vec) { self.capture_info_map.insert(node_id, Rc::new(cs)); } @@ -384,8 +392,9 @@ fn visit_local<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, local: &'tcx hir::Local) { let name = path1.node; ir.add_live_node_for_node(p_id, VarDefNode(sp)); ir.add_variable(Local(LocalInfo { - id: p_id, - name, + id: p_id, + name, + is_shorthand: false, })); }); intravisit::walk_local(ir, local); @@ -393,6 +402,22 @@ fn visit_local<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, local: &'tcx hir::Local) { fn visit_arm<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, arm: &'tcx hir::Arm) { for pat in &arm.pats { + // for struct patterns, take note of which fields used shorthand (`x` + // rather than `x: x`) + // + // FIXME: according to the rust-lang-nursery/rustc-guide book and + // librustc/README.md, `NodeId`s are to be phased out in favor of + // `HirId`s; however, we need to match the signature of `each_binding`, + // which uses `NodeIds`. + let mut shorthand_field_ids = NodeSet(); + if let hir::PatKind::Struct(_, ref fields, _) = pat.node { + for field in fields { + if field.node.is_shorthand { + shorthand_field_ids.insert(field.node.pat.id); + } + } + } + pat.each_binding(|bm, p_id, sp, path1| { debug!("adding local variable {} from match with bm {:?}", p_id, bm); @@ -400,7 +425,8 @@ fn visit_arm<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, arm: &'tcx hir::Arm) { ir.add_live_node_for_node(p_id, VarDefNode(sp)); ir.add_variable(Local(LocalInfo { id: p_id, - name, + name: name, + is_shorthand: shorthand_field_ids.contains(&p_id) })); }) } @@ -1483,17 +1509,26 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.assigned_on_exit(ln, var).is_some() }; + let suggest_underscore_msg = format!("consider using `_{}` instead", + name); if is_assigned { - self.ir.tcx.lint_node_note(lint::builtin::UNUSED_VARIABLES, id, sp, - &format!("variable `{}` is assigned to, but never used", - name), - &format!("to avoid this warning, consider using `_{}` instead", - name)); + self.ir.tcx + .lint_node_note(lint::builtin::UNUSED_VARIABLES, id, sp, + &format!("variable `{}` is assigned to, but never used", + name), + &suggest_underscore_msg); } else if name != "self" { - self.ir.tcx.lint_node_note(lint::builtin::UNUSED_VARIABLES, id, sp, - &format!("unused variable: `{}`", name), - &format!("to avoid this warning, consider using `_{}` instead", - name)); + let msg = format!("unused variable: `{}`", name); + let mut err = self.ir.tcx + .struct_span_lint_node(lint::builtin::UNUSED_VARIABLES, id, sp, &msg); + if self.ir.variable_is_shorthand(var) { + err.span_suggestion(sp, "try ignoring the field", + format!("{}: _", name)); + } else { + err.span_suggestion_short(sp, &suggest_underscore_msg, + format!("_{}", name)); + } + err.emit() } } true diff --git a/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs b/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs new file mode 100644 index 0000000000000..a68b4f7635292 --- /dev/null +++ b/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs @@ -0,0 +1,34 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// must-compile-successfully + +#![warn(unused)] // UI tests pass `-A unused` (#43896) + +struct SoulHistory { + corridors_of_light: usize, + hours_are_suns: bool, + endless_and_singing: bool +} + +fn main() { + let i_think_continually = 2; + let who_from_the_womb_remembered = SoulHistory { + corridors_of_light: 5, + hours_are_suns: true, + endless_and_singing: true + }; + + if let SoulHistory { corridors_of_light, + mut hours_are_suns, + endless_and_singing: true } = who_from_the_womb_remembered { + hours_are_suns = false; + } +} diff --git a/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.stderr b/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.stderr new file mode 100644 index 0000000000000..694fe69e01648 --- /dev/null +++ b/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.stderr @@ -0,0 +1,40 @@ +warning: unused variable: `i_think_continually` + --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:22:9 + | +22 | let i_think_continually = 2; + | ^^^^^^^^^^^^^^^^^^^ help: consider using `_i_think_continually` instead + | +note: lint level defined here + --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:13:9 + | +13 | #![warn(unused)] // UI tests pass `-A unused` (#43896) + | ^^^^^^ + = note: #[warn(unused_variables)] implied by #[warn(unused)] + +warning: unused variable: `corridors_of_light` + --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:29:26 + | +29 | if let SoulHistory { corridors_of_light, + | ^^^^^^^^^^^^^^^^^^ help: try ignoring the field: `corridors_of_light: _` + +warning: variable `hours_are_suns` is assigned to, but never used + --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:30:26 + | +30 | mut hours_are_suns, + | ^^^^^^^^^^^^^^^^^^ + | + = note: consider using `_hours_are_suns` instead + +warning: value assigned to `hours_are_suns` is never read + --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:32:9 + | +32 | hours_are_suns = false; + | ^^^^^^^^^^^^^^ + | +note: lint level defined here + --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:13:9 + | +13 | #![warn(unused)] // UI tests pass `-A unused` (#43896) + | ^^^^^^ + = note: #[warn(unused_assignments)] implied by #[warn(unused)] + diff --git a/src/test/ui/span/issue-24690.stderr b/src/test/ui/span/issue-24690.stderr index 7e19c7492ce0b..31728dbf08db2 100644 --- a/src/test/ui/span/issue-24690.stderr +++ b/src/test/ui/span/issue-24690.stderr @@ -2,7 +2,7 @@ warning: unused variable: `theOtherTwo` --> $DIR/issue-24690.rs:23:9 | 23 | let theOtherTwo = 2; //~ WARN should have a snake case name - | ^^^^^^^^^^^ + | ^^^^^^^^^^^ help: consider using `_theOtherTwo` instead | note: lint level defined here --> $DIR/issue-24690.rs:18:9 @@ -10,7 +10,6 @@ note: lint level defined here 18 | #![warn(unused)] | ^^^^^^ = note: #[warn(unused_variables)] implied by #[warn(unused)] - = note: to avoid this warning, consider using `_theOtherTwo` instead warning: variable `theTwo` should have a snake case name such as `the_two` --> $DIR/issue-24690.rs:22:9 From e34c31bf02eb0f0ff4dd43ae72e0eae53f2ac519 Mon Sep 17 00:00:00 2001 From: varkor Date: Thu, 1 Feb 2018 18:35:51 +0000 Subject: [PATCH 080/198] =?UTF-8?q?Use=20constant=20for=20180/=CF=80=20in?= =?UTF-8?q?=20to=5Fdegrees?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current `f32|f64.to_degrees` implementation uses a division to calculate 180/π, which causes a loss of precision. Using a constant is still not perfect (implementing a maximally-precise algorithm would come with a high performance cost), but improves precision with a minimal change. --- src/libcore/num/f32.rs | 4 +++- src/libcore/num/f64.rs | 3 +++ src/libstd/f32.rs | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 207df84d080f2..3586fa5442fb4 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -239,7 +239,9 @@ impl Float for f32 { /// Converts to degrees, assuming the number is in radians. #[inline] fn to_degrees(self) -> f32 { - self * (180.0f32 / consts::PI) + // Use a constant for better precision. + const PIS_IN_180: f32 = 57.2957795130823208767981548141051703_f32; + self * PIS_IN_180 } /// Converts to radians, assuming the number is in degrees. diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 9206132e8b46f..64c0d508b388c 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -237,6 +237,9 @@ impl Float for f64 { /// Converts to degrees, assuming the number is in radians. #[inline] fn to_degrees(self) -> f64 { + // The division here is correctly rounded with respect to the true + // value of 180/π. (This differs from f32, where a constant must be + // used to ensure a correctly rounded result.) self * (180.0f64 / consts::PI) } diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index 9810dede61821..ecf68f29d6f1f 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -1531,6 +1531,7 @@ mod tests { assert!(nan.to_degrees().is_nan()); assert_eq!(inf.to_degrees(), inf); assert_eq!(neg_inf.to_degrees(), neg_inf); + assert_eq!(1_f32.to_degrees(), 57.2957795130823208767981548141051703); } #[test] From aaec60836761da35a8d0cf6179769eb9bc9f63c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 1 Feb 2018 11:51:49 -0800 Subject: [PATCH 081/198] Minimize weird spans involving macro context Sometimes the parser attempts to synthesize spans from within a macro context with the span for the captured argument, leading to non-sensical spans with very bad output. Given that an incorrect span is worse than a partially incomplete span, when detecting this situation return only one of the spans without mergin them. --- src/libsyntax_pos/lib.rs | 23 ++++++++++++++----- .../ui/macros/span-covering-argument-1.rs | 23 +++++++++++++++++++ .../ui/macros/span-covering-argument-1.stderr | 13 +++++++++++ .../ui/span/macro-span-replacement.stderr | 4 ++-- 4 files changed, 55 insertions(+), 8 deletions(-) create mode 100644 src/test/ui/macros/span-covering-argument-1.rs create mode 100644 src/test/ui/macros/span-covering-argument-1.stderr diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 85f0925b98210..09e2677eed618 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -361,13 +361,24 @@ impl Span { /// Return a `Span` that would enclose both `self` and `end`. pub fn to(self, end: Span) -> Span { - let span = self.data(); - let end = end.data(); + let span_data = self.data(); + let end_data = end.data(); + // FIXME(jseyfried): self.ctxt should always equal end.ctxt here (c.f. issue #23480) + // Return the macro span on its own to avoid weird diagnostic output. It is preferable to + // have an incomplete span than a completely nonsensical one. + if span_data.ctxt != end_data.ctxt { + if span_data.ctxt == SyntaxContext::empty() { + return end; + } else if end_data.ctxt == SyntaxContext::empty() { + return self; + } + // both span fall within a macro + // FIXME(estebank) check if it is the *same* macro + } Span::new( - cmp::min(span.lo, end.lo), - cmp::max(span.hi, end.hi), - // FIXME(jseyfried): self.ctxt should always equal end.ctxt here (c.f. issue #23480) - if span.ctxt == SyntaxContext::empty() { end.ctxt } else { span.ctxt }, + cmp::min(span_data.lo, end_data.lo), + cmp::max(span_data.hi, end_data.hi), + if span_data.ctxt == SyntaxContext::empty() { end_data.ctxt } else { span_data.ctxt }, ) } diff --git a/src/test/ui/macros/span-covering-argument-1.rs b/src/test/ui/macros/span-covering-argument-1.rs new file mode 100644 index 0000000000000..bfc137fc7b26d --- /dev/null +++ b/src/test/ui/macros/span-covering-argument-1.rs @@ -0,0 +1,23 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +macro_rules! bad { + ($s:ident whatever) => { + { + let $s = 0; + *&mut $s = 0; + //~^ ERROR cannot borrow immutable local variable `foo` as mutable [E0596] + } + } +} + +fn main() { + bad!(foo whatever); +} diff --git a/src/test/ui/macros/span-covering-argument-1.stderr b/src/test/ui/macros/span-covering-argument-1.stderr new file mode 100644 index 0000000000000..677d2f10fd6c9 --- /dev/null +++ b/src/test/ui/macros/span-covering-argument-1.stderr @@ -0,0 +1,13 @@ +error[E0596]: cannot borrow immutable local variable `foo` as mutable + --> $DIR/span-covering-argument-1.rs:15:19 + | +14 | let $s = 0; + | -- consider changing this to `mut $s` +15 | *&mut $s = 0; + | ^^ cannot borrow mutably +... +22 | bad!(foo whatever); + | ------------------- in this macro invocation + +error: aborting due to previous error + diff --git a/src/test/ui/span/macro-span-replacement.stderr b/src/test/ui/span/macro-span-replacement.stderr index 2a0e71e192c62..728cd12e2c685 100644 --- a/src/test/ui/span/macro-span-replacement.stderr +++ b/src/test/ui/span/macro-span-replacement.stderr @@ -1,8 +1,8 @@ warning: struct is never used: `S` - --> $DIR/macro-span-replacement.rs:17:9 + --> $DIR/macro-span-replacement.rs:17:14 | 17 | $b $a; //~ WARN struct is never used - | ^^^^^^ + | ^ ... 22 | m!(S struct); | ------------- in this macro invocation From accd997b546d73ce6f59070bc4277556f27cd539 Mon Sep 17 00:00:00 2001 From: dpc Date: Fri, 2 Feb 2018 02:10:10 +0530 Subject: [PATCH 082/198] add ellided lifetime --- src/librustc/lint/builtin.rs | 10 +++++++++- src/librustc/middle/resolve_lifetime.rs | 16 +++++++++++++--- .../ui/in-band-lifetimes/ellided-lifetimes.rs | 19 +++++++++++++++++++ .../ellided-lifetimes.stderr | 14 ++++++++++++++ 4 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 src/test/ui/in-band-lifetimes/ellided-lifetimes.rs create mode 100644 src/test/ui/in-band-lifetimes/ellided-lifetimes.stderr diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 143d2c2ea28bb..0577800f3f411 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -246,6 +246,12 @@ declare_lint! { "raw pointer to an inference variable" } +declare_lint! { + pub ELIDED_LIFETIME_IN_PATH, + Allow, + "hidden lifetime parameters are deprecated, try `Foo<'_>`" +} + /// Does nothing as a lint pass, but registers some `Lint`s /// which are used by other parts of the compiler. #[derive(Copy, Clone)] @@ -291,7 +297,9 @@ impl LintPass for HardwiredLints { UNUSED_MUT, COERCE_NEVER, SINGLE_USE_LIFETIME, - TYVAR_BEHIND_RAW_POINTER + TYVAR_BEHIND_RAW_POINTER, + ELIDED_LIFETIME_IN_PATH + ) } } diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 944d770516375..59460141166b1 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -737,7 +737,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { fn visit_lifetime(&mut self, lifetime_ref: &'tcx hir::Lifetime) { if lifetime_ref.is_elided() { - self.resolve_elided_lifetimes(slice::from_ref(lifetime_ref)); + self.resolve_elided_lifetimes(slice::from_ref(lifetime_ref), false); return; } if lifetime_ref.is_static() { @@ -1444,7 +1444,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } if params.lifetimes.iter().all(|l| l.is_elided()) { - self.resolve_elided_lifetimes(¶ms.lifetimes); + self.resolve_elided_lifetimes(¶ms.lifetimes, true); } else { for l in ¶ms.lifetimes { self.visit_lifetime(l); @@ -1803,14 +1803,24 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } } - fn resolve_elided_lifetimes(&mut self, lifetime_refs: &'tcx [hir::Lifetime]) { + fn resolve_elided_lifetimes(&mut self, lifetime_refs: &'tcx [hir::Lifetime], deprecated: bool) { if lifetime_refs.is_empty() { return; } let span = lifetime_refs[0].span; + let id = lifetime_refs[0].id; let mut late_depth = 0; let mut scope = self.scope; + if deprecated { + self.tcx + .struct_span_lint_node( + lint::builtin::ELIDED_LIFETIME_IN_PATH, + id, + span, + &format!("hidden lifetime parameters are deprecated, try `Foo<'_>`")) + .emit(); + } let error = loop { match *scope { // Do not assign any resolution, it will be inferred. diff --git a/src/test/ui/in-band-lifetimes/ellided-lifetimes.rs b/src/test/ui/in-band-lifetimes/ellided-lifetimes.rs new file mode 100644 index 0000000000000..5151abd68232c --- /dev/null +++ b/src/test/ui/in-band-lifetimes/ellided-lifetimes.rs @@ -0,0 +1,19 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +#![allow(warnings)] +#![allow(unused_variables, dead_code, unused, bad_style)] +#![deny(elided_lifetime_in_path)] + +struct Foo<'a> { x: &'a u32 } +fn foo(x: &Foo) { + //~^ ERROR: hidden lifetime parameters are deprecated, try `Foo<'_>` +} + +fn main() {} diff --git a/src/test/ui/in-band-lifetimes/ellided-lifetimes.stderr b/src/test/ui/in-band-lifetimes/ellided-lifetimes.stderr new file mode 100644 index 0000000000000..613a7be6ed2c1 --- /dev/null +++ b/src/test/ui/in-band-lifetimes/ellided-lifetimes.stderr @@ -0,0 +1,14 @@ +error: hidden lifetime parameters are deprecated, try `Foo<'_>` + --> $DIR/ellided-lifetimes.rs:15:12 + | +15 | fn foo(x: &Foo) { + | ^^^ + | +note: lint level defined here + --> $DIR/ellided-lifetimes.rs:12:9 + | +12 | #![deny(elided_lifetime_in_path)] + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + From 196fad0d00bddd11074b5da32af2393abaac9a26 Mon Sep 17 00:00:00 2001 From: Badel2 <2badel2@gmail.com> Date: Tue, 30 Jan 2018 21:33:33 +0100 Subject: [PATCH 083/198] Turn `type_id` into a constant intrinsic Add rustc_const_unstable attribute for `any::TypeId::of` Add test for `const fn TypeId::of` --- src/libcore/any.rs | 27 ++++++++++++ src/libcore/lib.rs | 1 + src/librustc_const_eval/eval.rs | 4 ++ src/librustc_mir/interpret/const_eval.rs | 6 +++ src/librustc_mir/transform/qualify_consts.rs | 2 +- src/librustc_trans/mir/constant.rs | 5 +++ src/test/compile-fail/const-typeid-of.rs | 18 ++++++++ src/test/run-pass/const-typeid-of.rs | 43 ++++++++++++++++++++ 8 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 src/test/compile-fail/const-typeid-of.rs create mode 100644 src/test/run-pass/const-typeid-of.rs diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 338e5c7fd95b4..566bfe2a3fb5e 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -367,9 +367,36 @@ impl TypeId { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] + #[cfg(stage0)] pub fn of() -> TypeId { TypeId { t: unsafe { intrinsics::type_id::() }, } } + + /// Returns the `TypeId` of the type this generic function has been + /// instantiated with. + /// + /// # Examples + /// + /// ``` + /// use std::any::{Any, TypeId}; + /// + /// fn is_string(_s: &T) -> bool { + /// TypeId::of::() == TypeId::of::() + /// } + /// + /// fn main() { + /// assert_eq!(is_string(&0), false); + /// assert_eq!(is_string(&"cookie monster".to_string()), true); + /// } + /// ``` + #[stable(feature = "rust1", since = "1.0.0")] + #[rustc_const_unstable(feature="const_type_id")] + #[cfg(not(stage0))] + pub const fn of() -> TypeId { + TypeId { + t: unsafe { intrinsics::type_id::() }, + } + } } diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index d5190b65863cb..7f094e580ab5c 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -91,6 +91,7 @@ #![feature(untagged_unions)] #![feature(unwind_attributes)] #![feature(doc_spotlight)] +#![feature(rustc_const_unstable)] #[prelude_import] #[allow(unused)] diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index 418bd4b5effc6..17a9454e9d456 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -328,6 +328,10 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>, return Ok(mk_const(Integral(Usize(ConstUsize::new(align, tcx.sess.target.usize_ty).unwrap())))); } + "type_id" => { + let type_id = tcx.type_id_hash(substs.type_at(0)); + return Ok(mk_const(Integral(U64(type_id)))); + } _ => signal!(e, TypeckError) } } diff --git a/src/librustc_mir/interpret/const_eval.rs b/src/librustc_mir/interpret/const_eval.rs index 2913f72460e3e..d3b084fde6ab8 100644 --- a/src/librustc_mir/interpret/const_eval.rs +++ b/src/librustc_mir/interpret/const_eval.rs @@ -243,6 +243,12 @@ impl<'tcx> super::Machine<'tcx> for CompileTimeEvaluator { ecx.write_primval(dest, PrimVal::from_u128(size), dest_layout.ty)?; } + "type_id" => { + let ty = substs.type_at(0); + let type_id = ecx.tcx.type_id_hash(ty) as u128; + ecx.write_primval(dest, PrimVal::from_u128(type_id), dest_layout.ty)?; + } + name => return Err(ConstEvalError::NeedsRfc(format!("calling intrinsic `{}`", name)).into()), } diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index b896e6ca85343..da76adfd48f3f 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -737,7 +737,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { Abi::PlatformIntrinsic => { assert!(!self.tcx.is_const_fn(def_id)); match &self.tcx.item_name(def_id)[..] { - "size_of" | "min_align_of" => is_const_fn = Some(def_id), + "size_of" | "min_align_of" | "type_id" => is_const_fn = Some(def_id), name if name.starts_with("simd_shuffle") => { is_shuffle = true; diff --git a/src/librustc_trans/mir/constant.rs b/src/librustc_trans/mir/constant.rs index a3e55205dd875..cd1975488a24a 100644 --- a/src/librustc_trans/mir/constant.rs +++ b/src/librustc_trans/mir/constant.rs @@ -411,6 +411,11 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> { self.cx.align_of(substs.type_at(0)).abi()); Ok(Const::new(llval, tcx.types.usize)) } + "type_id" => { + let llval = C_u64(self.cx, + self.cx.tcx.type_id_hash(substs.type_at(0))); + Ok(Const::new(llval, tcx.types.u64)) + } _ => span_bug!(span, "{:?} in constant", terminator.kind) } } else if let Some((op, is_checked)) = self.is_binop_lang_item(def_id) { diff --git a/src/test/compile-fail/const-typeid-of.rs b/src/test/compile-fail/const-typeid-of.rs new file mode 100644 index 0000000000000..401125cef09d8 --- /dev/null +++ b/src/test/compile-fail/const-typeid-of.rs @@ -0,0 +1,18 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::any::TypeId; + +struct A; + +fn main() { + const A_ID: TypeId = TypeId::of::(); + //~^ ERROR `std::any::TypeId::of` is not yet stable as a const fn +} diff --git a/src/test/run-pass/const-typeid-of.rs b/src/test/run-pass/const-typeid-of.rs new file mode 100644 index 0000000000000..ce29e55c6d720 --- /dev/null +++ b/src/test/run-pass/const-typeid-of.rs @@ -0,0 +1,43 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(core_intrinsics)] +#![feature(const_type_id)] + +use std::any::TypeId; + +struct A; + +static ID_ISIZE: TypeId = TypeId::of::(); + +pub fn main() { + assert_eq!(ID_ISIZE, TypeId::of::()); + + // sanity test of TypeId + const T: (TypeId, TypeId, TypeId) = (TypeId::of::(), + TypeId::of::<&'static str>(), + TypeId::of::()); + let (d, e, f) = (TypeId::of::(), TypeId::of::<&'static str>(), + TypeId::of::()); + + assert!(T.0 != T.1); + assert!(T.0 != T.2); + assert!(T.1 != T.2); + + assert_eq!(T.0, d); + assert_eq!(T.1, e); + assert_eq!(T.2, f); + + // Check fn pointer against collisions + const F: (TypeId, TypeId) = (TypeId::of:: A) -> A>(), + TypeId::of:: A, A) -> A>()); + + assert!(F.0 != F.1); +} From 8b8d044026945fd1dd678c9e33c48bf59b35ad6d Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 1 Feb 2018 23:40:23 +0100 Subject: [PATCH 084/198] Fix ugly hover in sidebar --- src/librustdoc/html/static/rustdoc.css | 30 +++++++++++++++++++------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index d2eeb2e15b3dd..2b1f920bba0b3 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -181,15 +181,19 @@ nav.sub { overflow: auto; } -.sidebar .current { +.sidebar .block > ul > li { margin-right: -20px; } -.content, nav { max-width: 960px; } +.content, nav { + max-width: 960px; +} /* Everything else */ -.js-only, .hidden { display: none !important; } +.js-only, .hidden { + display: none !important; +} .sidebar img { margin: 20px auto; @@ -218,7 +222,9 @@ nav.sub { border: none; } -.location a:first-child { font-weight: 500; } +.location a:first-child { + font-weight: 500; +} .block { padding: 0; @@ -299,7 +305,9 @@ nav.sub { -ms-user-select: none; user-select: none; } -.line-numbers span { cursor: pointer; } +.line-numbers span { + cursor: pointer; +} .docblock-short p { display: inline; @@ -317,7 +325,9 @@ nav.sub { text-overflow: ellipsis; margin: 0; } -.docblock-short code { white-space: nowrap; } +.docblock-short code { + white-space: nowrap; +} .docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 { border-bottom: 1px solid; @@ -384,7 +394,9 @@ h4 > code, h3 > code, .invisible > code { display: inline-block; } -#main { position: relative; } +#main { + position: relative; +} #main > .since { top: inherit; font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; @@ -428,7 +440,9 @@ h4 > code, h3 > code, .invisible > code { padding: 0; } -.content .item-list li { margin-bottom: 1em; } +.content .item-list li { + margin-bottom: 1em; +} .content .multi-column { -moz-column-count: 5; From c1383e4dc4bd6598f5d73d2d6b1054f61b2b99d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 19 Jan 2018 19:57:10 -0800 Subject: [PATCH 085/198] Add filtering options to `rustc_on_unimplemented` - filter error on the evaluated value of `Self` - filter error on the evaluated value of the type arguments - add argument to include custom note in diagnostic - allow the parser to parse `Self` when processing attributes - add custom message to binops --- src/libcore/ops/arith.rs | 115 ++++++++++++++++-- src/libcore/ops/bit.rs | 30 +++-- src/librustc/traits/error_reporting.rs | 32 +++-- src/librustc/traits/on_unimplemented.rs | 34 ++++-- src/libsyntax/parse/attr.rs | 2 +- src/libsyntax/parse/parser.rs | 16 ++- .../anonymous-higher-ranked-lifetime.stderr | 66 ++-------- .../issue-39802-show-5-trait-impls.stderr | 18 +-- .../ui/did_you_mean/recursion_limit.stderr | 6 +- .../ui/feature-gate-abi_unadjusted.stderr | 2 +- src/test/ui/feature-gate-catch_expr.stderr | 2 +- src/test/ui/feature-gate-i128_type2.stderr | 10 +- src/test/ui/feature-gate-intrinsics.stderr | 4 +- .../ui/feature-gate-non_ascii_idents.stderr | 26 ++-- src/test/ui/feature-gate-repr128.stderr | 2 +- .../ui/feature-gate-unboxed-closures.stderr | 2 +- .../ui/feature-gate-untagged_unions.stderr | 6 +- src/test/ui/fmt/send-sync.stderr | 12 +- src/test/ui/generator/not-send-sync.stderr | 6 +- src/test/ui/impl-trait/auto-trait-leak.stderr | 12 +- src/test/ui/impl-trait/equality.stderr | 2 +- src/test/ui/issue-24424.stderr | 6 +- src/test/ui/lint/suggestions.stderr | 32 ++--- src/test/ui/lint/use_suggestion_json.stderr | 67 +--------- src/test/ui/macros/format-foreign.stderr | 10 +- .../ui/macros/format-unused-lables.stderr | 52 ++++---- src/test/ui/mismatched_types/E0631.stderr | 24 +--- src/test/ui/mismatched_types/binops.stderr | 8 +- .../mismatched_types/closure-arg-count.stderr | 6 +- .../closure-arg-type-mismatch.stderr | 12 +- .../mismatched_types/closure-mismatch.stderr | 12 +- .../ui/mismatched_types/fn-variance-1.stderr | 12 +- .../unboxed-closures-vtable-mismatch.stderr | 13 +- .../ui/on-unimplemented/multiple-impls.stderr | 18 +-- src/test/ui/on-unimplemented/on-impl.stderr | 6 +- src/test/ui/on-unimplemented/on-trait.stderr | 12 +- src/test/ui/span/issue-29595.stderr | 6 +- src/test/ui/span/multiline-span-simple.stderr | 2 +- .../suggestions/try-operator-on-main.stderr | 6 +- src/test/ui/type-check/issue-40294.stderr | 6 +- 40 files changed, 312 insertions(+), 403 deletions(-) diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs index 8b3d662a6db77..59a18d6cb75ed 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs @@ -75,7 +75,93 @@ /// ``` #[lang = "add"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} + {RHS}`"] +#[rustc_on_unimplemented( + on( + any( + all(_Self="i128", RHS="i64"), + all(_Self="i128", RHS="i32"), + all(_Self="i128", RHS="i16"), + all(_Self="i128", RHS="i8"), + all(_Self="i64", RHS="i32"), + all(_Self="i64", RHS="i16"), + all(_Self="i64", RHS="i8"), + all(_Self="i32", RHS="i16"), + all(_Self="i32", RHS="i8"), + all(_Self="i16", RHS="i8"), + all(_Self="u128", RHS="u64"), + all(_Self="u128", RHS="u32"), + all(_Self="u128", RHS="u16"), + all(_Self="u128", RHS="u8"), + all(_Self="u64", RHS="u32"), + all(_Self="u64", RHS="u16"), + all(_Self="u64", RHS="u8"), + all(_Self="u32", RHS="u16"), + all(_Self="u32", RHS="u8"), + all(_Self="u16", RHS="u8"), + all(_Self="f64", RHS="i32"), + all(_Self="f64", RHS="i16"), + all(_Self="f64", RHS="i8"), + all(_Self="f64", RHS="u32"), + all(_Self="f64", RHS="u16"), + all(_Self="f64", RHS="u8"), + all(_Self="f32", RHS="i16"), + all(_Self="f32", RHS="i8"), + all(_Self="f32", RHS="u16"), + all(_Self="f32", RHS="u8"), + ), + message="cannot add `{RHS}` to `{Self}`", + label="no implementation for `{Self} + {RHS}`, but you can safely cast \ + `{RHS}` into `{Self}` using `as {Self}`", + ), + on( + any( + all(RHS="i128", _Self="i64"), + all(RHS="i128", _Self="i32"), + all(RHS="i128", _Self="i16"), + all(RHS="i128", _Self="i8"), + all(RHS="i64", _Self="i32"), + all(RHS="i64", _Self="i16"), + all(RHS="i64", _Self="i8"), + all(RHS="i32", _Self="i16"), + all(RHS="i32", _Self="i8"), + all(RHS="i16", _Self="i8"), + all(RHS="u128", _Self="u64"), + all(RHS="u128", _Self="u32"), + all(RHS="u128", _Self="u16"), + all(RHS="u128", _Self="u8"), + all(RHS="u64", _Self="u32"), + all(RHS="u64", _Self="u16"), + all(RHS="u64", _Self="u8"), + all(RHS="u32", _Self="u16"), + all(RHS="u32", _Self="u8"), + all(RHS="u16", _Self="u8"), + all(RHS="f64", _Self="i32"), + all(RHS="f64", _Self="i16"), + all(RHS="f64", _Self="i8"), + all(RHS="f64", _Self="u32"), + all(RHS="f64", _Self="u16"), + all(RHS="f64", _Self="u8"), + all(RHS="f32", _Self="i16"), + all(RHS="f32", _Self="i8"), + all(RHS="f32", _Self="u16"), + all(RHS="f32", _Self="u8"), + ), + message="cannot add `{RHS}` to `{Self}`", + label="no implementation for `{Self} + {RHS}`, but you can safely turn \ + `{Self}` into `{RHS}` using `as {RHS}`", + ), + on( + all(_Self="{integer}", RHS="{float}"), + message="cannot add a float to an integer", + label="no implementation for `{Self} + {RHS}`", + ), + on( + all(_Self="{float}", RHS="{integer}"), + message="cannot add an integer to a float", + label="no implementation for `{Self} + {RHS}`", + ), + message="cannot add `{RHS}` to `{Self}`", + label="no implementation for `{Self} + {RHS}`")] pub trait Add { /// The resulting type after applying the `+` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -170,7 +256,8 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "sub"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} - {RHS}`"] +#[rustc_on_unimplemented(message="cannot substract `{RHS}` from `{Self}`", + label="no implementation for `{Self} - {RHS}`")] pub trait Sub { /// The resulting type after applying the `-` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -287,7 +374,8 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "mul"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} * {RHS}`"] +#[rustc_on_unimplemented(message="cannot multiply `{RHS}` to `{Self}`", + label="no implementation for `{Self} * {RHS}`")] pub trait Mul { /// The resulting type after applying the `*` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -408,7 +496,8 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "div"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} / {RHS}`"] +#[rustc_on_unimplemented(message="cannot divide `{Self}` by `{RHS}`", + label="no implementation for `{Self} / {RHS}`")] pub trait Div { /// The resulting type after applying the `/` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -490,7 +579,8 @@ div_impl_float! { f32 f64 } /// ``` #[lang = "rem"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} % {RHS}`"] +#[rustc_on_unimplemented(message="cannot mod `{Self}` by `{RHS}`", + label="no implementation for `{Self} % {RHS}`")] pub trait Rem { /// The resulting type after applying the `%` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -647,7 +737,8 @@ neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "add_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} += {Rhs}`"] +#[rustc_on_unimplemented(message="cannot add-assign `{Rhs}` to `{Self}`", + label="no implementation for `{Self} += {Rhs}`")] pub trait AddAssign { /// Performs the `+=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -700,7 +791,8 @@ add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "sub_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} -= {Rhs}`"] +#[rustc_on_unimplemented(message="cannot substract-assign `{Rhs}` from `{Self}`", + label="no implementation for `{Self} -= {Rhs}`")] pub trait SubAssign { /// Performs the `-=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -744,7 +836,8 @@ sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "mul_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} *= {Rhs}`"] +#[rustc_on_unimplemented(message="cannot multiply-assign `{Rhs}` to `{Self}`", + label="no implementation for `{Self} *= {Rhs}`")] pub trait MulAssign { /// Performs the `*=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -788,7 +881,8 @@ mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "div_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} /= {Rhs}`"] +#[rustc_on_unimplemented(message="cannot divide-assign `{Self}` by `{Rhs}`", + label="no implementation for `{Self} /= {Rhs}`")] pub trait DivAssign { /// Performs the `/=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -835,7 +929,8 @@ div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "rem_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} %= {Rhs}`"] +#[rustc_on_unimplemented(message="cannot mod-assign `{Self}` by `{Rhs}``", + label="no implementation for `{Self} %= {Rhs}`")] pub trait RemAssign { /// Performs the `%=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] diff --git a/src/libcore/ops/bit.rs b/src/libcore/ops/bit.rs index 7ac5fc4debf14..a0ecd6cf75ce9 100644 --- a/src/libcore/ops/bit.rs +++ b/src/libcore/ops/bit.rs @@ -120,7 +120,8 @@ not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "bitand"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} & {RHS}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} & {RHS}`", + label="no implementation for `{Self} & {RHS}`")] pub trait BitAnd { /// The resulting type after applying the `&` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -201,7 +202,8 @@ bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "bitor"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} | {RHS}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} | {RHS}`", + label="no implementation for `{Self} | {RHS}`")] pub trait BitOr { /// The resulting type after applying the `|` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -285,7 +287,8 @@ bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "bitxor"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} ^ {RHS}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} ^ {RHS}`", + label="no implementation for `{Self} ^ {RHS}`")] pub trait BitXor { /// The resulting type after applying the `^` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -365,7 +368,8 @@ bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "shl"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} << {RHS}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} << {RHS}`", + label="no implementation for `{Self} << {RHS}`")] pub trait Shl { /// The resulting type after applying the `<<` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -466,7 +470,8 @@ shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 } /// ``` #[lang = "shr"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} >> {RHS}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} >> {RHS}`", + label="no implementation for `{Self} >> {RHS}`")] pub trait Shr { /// The resulting type after applying the `>>` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -579,7 +584,8 @@ shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } /// ``` #[lang = "bitand_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} &= {Rhs}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} &= {Rhs}`", + label="no implementation for `{Self} &= {Rhs}`")] pub trait BitAndAssign { /// Performs the `&=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -626,7 +632,8 @@ bitand_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "bitor_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} |= {Rhs}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} |= {Rhs}`", + label="no implementation for `{Self} |= {Rhs}`")] pub trait BitOrAssign { /// Performs the `|=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -673,7 +680,8 @@ bitor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "bitxor_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} ^= {Rhs}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} ^= {Rhs}`", + label="no implementation for `{Self} ^= {Rhs}`")] pub trait BitXorAssign { /// Performs the `^=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -718,7 +726,8 @@ bitxor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "shl_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} <<= {Rhs}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} <<= {Rhs}`", + label="no implementation for `{Self} <<= {Rhs}`")] pub trait ShlAssign { /// Performs the `<<=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -784,7 +793,8 @@ shl_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } /// ``` #[lang = "shr_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented = "no implementation for `{Self} >>= {Rhs}`"] +#[rustc_on_unimplemented(message="no implementation for `{Self} >>= {Rhs}`", + label="no implementation for `{Self} >>= {Rhs}`")] pub trait ShrAssign { /// Performs the `>>=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index d65becb912a3c..f5ff122668558 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -348,7 +348,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { if direct { // this is a "direct", user-specified, rather than derived, // obligation. - flags.push(("direct", None)); + flags.push(("direct".to_string(), None)); } if let ObligationCauseCode::ItemObligation(item) = obligation.cause.code { @@ -359,21 +359,35 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // Currently I'm leaving it for what I need for `try`. if self.tcx.trait_of_item(item) == Some(trait_ref.def_id) { method = self.tcx.item_name(item); - flags.push(("from_method", None)); - flags.push(("from_method", Some(&*method))); + flags.push(("from_method".to_string(), None)); + flags.push(("from_method".to_string(), Some(method.to_string()))); } } if let Some(k) = obligation.cause.span.compiler_desugaring_kind() { desugaring = k.as_symbol().as_str(); - flags.push(("from_desugaring", None)); - flags.push(("from_desugaring", Some(&*desugaring))); + flags.push(("from_desugaring".to_string(), None)); + flags.push(("from_desugaring".to_string(), Some(desugaring.to_string()))); + } + let generics = self.tcx.generics_of(def_id); + let self_ty = trait_ref.self_ty(); + let self_ty_str = self_ty.to_string(); + // FIXME: remove once `Self` is accepted by the compiler + flags.push(("_Self".to_string(), Some(self_ty_str.clone()))); + flags.push(("Self".to_string(), Some(self_ty_str.clone()))); + + for param in generics.types.iter() { + let name = param.name.as_str().to_string(); + let ty = trait_ref.substs.type_for_def(param); + let ty_str = ty.to_string(); + flags.push((name.clone(), + Some(ty_str.clone()))); } if let Ok(Some(command)) = OnUnimplementedDirective::of_item( self.tcx, trait_ref.def_id, def_id ) { - command.evaluate(self.tcx, trait_ref, &flags) + command.evaluate(self.tcx, trait_ref, &flags[..]) } else { OnUnimplementedNote::empty() } @@ -549,7 +563,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { .map(|t| (format!(" in `{}`", t), format!("within `{}`, ", t))) .unwrap_or((String::new(), String::new())); - let OnUnimplementedNote { message, label } + let OnUnimplementedNote { message, label, note } = self.on_unimplemented_note(trait_ref, obligation); let have_alt_message = message.is_some() || label.is_some(); @@ -578,6 +592,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { trait_ref, trait_ref.self_ty())); } + if let Some(ref s) = note { + // If it has a custom "#[rustc_on_unimplemented]" note, let's display it + err.note(s.as_str()); + } self.suggest_borrow_on_unsized_slice(&obligation.cause.code, &mut err); diff --git a/src/librustc/traits/on_unimplemented.rs b/src/librustc/traits/on_unimplemented.rs index 757b078086d9c..a493b7f0bb603 100644 --- a/src/librustc/traits/on_unimplemented.rs +++ b/src/librustc/traits/on_unimplemented.rs @@ -29,16 +29,18 @@ pub struct OnUnimplementedDirective { pub subcommands: Vec, pub message: Option, pub label: Option, + pub note: Option, } pub struct OnUnimplementedNote { pub message: Option, pub label: Option, + pub note: Option, } impl OnUnimplementedNote { pub fn empty() -> Self { - OnUnimplementedNote { message: None, label: None } + OnUnimplementedNote { message: None, label: None, note: None } } } @@ -89,6 +91,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { let mut message = None; let mut label = None; + let mut note = None; let mut subcommands = vec![]; for item in item_iter { if item.check_name("message") && message.is_none() { @@ -103,8 +106,14 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { tcx, trait_def_id, label_.as_str(), span)?); continue; } + } else if item.check_name("note") && note.is_none() { + if let Some(note_) = item.value_str() { + note = Some(OnUnimplementedFormatString::try_parse( + tcx, trait_def_id, note_.as_str(), span)?); + continue; + } } else if item.check_name("on") && is_root && - message.is_none() && label.is_none() + message.is_none() && label.is_none() && note.is_none() { if let Some(items) = item.meta_item_list() { if let Ok(subcommand) = @@ -128,7 +137,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { if errored { Err(ErrorReported) } else { - Ok(OnUnimplementedDirective { condition, message, label, subcommands }) + Ok(OnUnimplementedDirective { condition, message, label, subcommands, note }) } } @@ -154,7 +163,8 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { message: None, subcommands: vec![], label: Some(OnUnimplementedFormatString::try_parse( - tcx, trait_def_id, value.as_str(), attr.span)?) + tcx, trait_def_id, value.as_str(), attr.span)?), + note: None, })) } else { return Err(parse_error(tcx, attr.span, @@ -169,20 +179,21 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { pub fn evaluate(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, trait_ref: ty::TraitRef<'tcx>, - options: &[(&str, Option<&str>)]) + options: &[(String, Option)]) -> OnUnimplementedNote { let mut message = None; let mut label = None; + let mut note = None; info!("evaluate({:?}, trait_ref={:?}, options={:?})", self, trait_ref, options); for command in self.subcommands.iter().chain(Some(self)).rev() { if let Some(ref condition) = command.condition { if !attr::eval_condition(condition, &tcx.sess.parse_sess, &mut |c| { - options.contains(&(&c.name().as_str(), - match c.value_str().map(|s| s.as_str()) { - Some(ref s) => Some(s), + options.contains(&(c.name().as_str().to_string(), + match c.value_str().map(|s| s.as_str().to_string()) { + Some(s) => Some(s), None => None })) }) { @@ -198,11 +209,16 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { if let Some(ref label_) = command.label { label = Some(label_.clone()); } + + if let Some(ref note_) = command.note { + note = Some(note_.clone()); + } } OnUnimplementedNote { label: label.map(|l| l.format(tcx, trait_ref)), - message: message.map(|m| m.format(tcx, trait_ref)) + message: message.map(|m| m.format(tcx, trait_ref)), + note: note.map(|n| n.format(tcx, trait_ref)), } } } diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index 053746b579dcb..b01f479895b10 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -235,7 +235,7 @@ impl<'a> Parser<'a> { } let lo = self.span; - let ident = self.parse_ident()?; + let ident = self.parse_ident_attr()?; let node = self.parse_meta_item_kind()?; Ok(ast::MetaItem { name: ident.name, node: node, span: lo.to(self.prev_span) }) } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index b3c485a85c063..9e8c4d3de2220 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -762,13 +762,19 @@ impl<'a> Parser<'a> { } pub fn parse_ident(&mut self) -> PResult<'a, ast::Ident> { - self.parse_ident_common(true) + self.parse_ident_common(true, false) } - fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, ast::Ident> { + pub fn parse_ident_attr(&mut self) -> PResult<'a, ast::Ident> { + self.parse_ident_common(true, true) + } + + fn parse_ident_common(&mut self, recover: bool, accept_self: bool) -> PResult<'a, ast::Ident> { match self.token { token::Ident(i) => { - if self.token.is_reserved_ident() { + if self.token.is_reserved_ident() + && !(accept_self && i.name == keywords::SelfType.name()) + { let mut err = self.struct_span_err(self.span, &format!("expected identifier, found {}", self.this_token_descr())); @@ -2111,7 +2117,7 @@ impl<'a> Parser<'a> { self.bump(); Ok(Ident::with_empty_ctxt(name)) } else { - self.parse_ident_common(false) + self.parse_ident_common(false, false) } } @@ -2128,7 +2134,7 @@ impl<'a> Parser<'a> { hi = self.prev_span; (fieldname, self.parse_expr()?, false) } else { - let fieldname = self.parse_ident_common(false)?; + let fieldname = self.parse_ident_common(false, false)?; hi = self.prev_span; // Mimic `x: x` for the `x` field shorthand. diff --git a/src/test/ui/anonymous-higher-ranked-lifetime.stderr b/src/test/ui/anonymous-higher-ranked-lifetime.stderr index 4bd3b684b7ba3..e364a4d8b1441 100644 --- a/src/test/ui/anonymous-higher-ranked-lifetime.stderr +++ b/src/test/ui/anonymous-higher-ranked-lifetime.stderr @@ -6,11 +6,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r, 's> fn(&'r (), &'s ()) -> _` | -note: required by `f1` - --> $DIR/anonymous-higher-ranked-lifetime.rs:26:1 - | -26 | fn f1(_: F) where F: Fn(&(), &()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `f1` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:13:5 @@ -20,11 +16,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'a, 'r> fn(&'a (), &'r ()) -> _` | -note: required by `f2` - --> $DIR/anonymous-higher-ranked-lifetime.rs:27:1 - | -27 | fn f2(_: F) where F: for<'a> Fn(&'a (), &()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `f2` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:14:5 @@ -34,11 +26,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&(), &'r ()) -> _` | -note: required by `f3` - --> $DIR/anonymous-higher-ranked-lifetime.rs:28:1 - | -28 | fn f3<'a, F>(_: F) where F: Fn(&'a (), &()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `f3` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:15:5 @@ -48,11 +36,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'s, 'r> fn(&'s (), &'r ()) -> _` | -note: required by `f4` - --> $DIR/anonymous-higher-ranked-lifetime.rs:29:1 - | -29 | fn f4(_: F) where F: for<'r> Fn(&(), &'r ()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `f4` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:16:5 @@ -62,11 +46,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&'r (), &'r ()) -> _` | -note: required by `f5` - --> $DIR/anonymous-higher-ranked-lifetime.rs:30:1 - | -30 | fn f5(_: F) where F: for<'r> Fn(&'r (), &'r ()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `f5` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:17:5 @@ -76,11 +56,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&'r (), std::boxed::Box std::ops::Fn(&'s ()) + 'static>) -> _` | -note: required by `g1` - --> $DIR/anonymous-higher-ranked-lifetime.rs:33:1 - | -33 | fn g1(_: F) where F: Fn(&(), Box) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `g1` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:18:5 @@ -90,11 +66,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&'r (), for<'s> fn(&'s ())) -> _` | -note: required by `g2` - --> $DIR/anonymous-higher-ranked-lifetime.rs:34:1 - | -34 | fn g2(_: F) where F: Fn(&(), fn(&())) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `g2` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:19:5 @@ -104,11 +76,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'s> fn(&'s (), std::boxed::Box std::ops::Fn(&'r ()) + 'static>) -> _` | -note: required by `g3` - --> $DIR/anonymous-higher-ranked-lifetime.rs:35:1 - | -35 | fn g3(_: F) where F: for<'s> Fn(&'s (), Box) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `g3` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:20:5 @@ -118,11 +86,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'s> fn(&'s (), for<'r> fn(&'r ())) -> _` | -note: required by `g4` - --> $DIR/anonymous-higher-ranked-lifetime.rs:36:1 - | -36 | fn g4(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `g4` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:21:5 @@ -132,11 +96,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r, 's> fn(&'r (), std::boxed::Box std::ops::Fn(&'t0 ()) + 'static>, &'s (), for<'t0, 't1> fn(&'t0 (), &'t1 ())) -> _` | -note: required by `h1` - --> $DIR/anonymous-higher-ranked-lifetime.rs:39:1 - | -39 | fn h1(_: F) where F: Fn(&(), Box, &(), fn(&(), &())) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `h1` error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:22:5 @@ -146,11 +106,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r, 't0> fn(&'r (), std::boxed::Box std::ops::Fn(&'s ()) + 'static>, &'t0 (), for<'s, 't1> fn(&'s (), &'t1 ())) -> _` | -note: required by `h2` - --> $DIR/anonymous-higher-ranked-lifetime.rs:40:1 - | -40 | fn h2(_: F) where F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), &())) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `h2` error: aborting due to 11 previous errors diff --git a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr index 7ca3e8728fd9c..d5c4add34b526 100644 --- a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr +++ b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr @@ -10,11 +10,7 @@ error[E0277]: the trait bound `i8: Foo` is not satisfied > > > -note: required by `Foo::bar` - --> $DIR/issue-39802-show-5-trait-impls.rs:12:5 - | -12 | fn bar(&self){} - | ^^^^^^^^^^^^^ + = note: required by `Foo::bar` error[E0277]: the trait bound `u8: Foo` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:35:5 @@ -27,11 +23,7 @@ error[E0277]: the trait bound `u8: Foo` is not satisfied > > > -note: required by `Foo::bar` - --> $DIR/issue-39802-show-5-trait-impls.rs:12:5 - | -12 | fn bar(&self){} - | ^^^^^^^^^^^^^ + = note: required by `Foo::bar` error[E0277]: the trait bound `bool: Foo` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:36:5 @@ -45,11 +37,7 @@ error[E0277]: the trait bound `bool: Foo` is not satisfied > > and 2 others -note: required by `Foo::bar` - --> $DIR/issue-39802-show-5-trait-impls.rs:12:5 - | -12 | fn bar(&self){} - | ^^^^^^^^^^^^^ + = note: required by `Foo::bar` error: aborting due to 3 previous errors diff --git a/src/test/ui/did_you_mean/recursion_limit.stderr b/src/test/ui/did_you_mean/recursion_limit.stderr index 2bc7e9e46e7c5..7fac604ba49d7 100644 --- a/src/test/ui/did_you_mean/recursion_limit.stderr +++ b/src/test/ui/did_you_mean/recursion_limit.stderr @@ -15,11 +15,7 @@ error[E0275]: overflow evaluating the requirement `K: std::marker::Send` = note: required because it appears within the type `C` = note: required because it appears within the type `B` = note: required because it appears within the type `A` -note: required by `is_send` - --> $DIR/recursion_limit.rs:41:1 - | -41 | fn is_send() { } - | ^^^^^^^^^^^^^^^^^^^^ + = note: required by `is_send` error: aborting due to previous error diff --git a/src/test/ui/feature-gate-abi_unadjusted.stderr b/src/test/ui/feature-gate-abi_unadjusted.stderr index b3f7cd218d3e9..3cc43847156a1 100644 --- a/src/test/ui/feature-gate-abi_unadjusted.stderr +++ b/src/test/ui/feature-gate-abi_unadjusted.stderr @@ -1,4 +1,4 @@ -error[E0658]: unadjusted ABI is an implementation detail and perma-unstable +error: unadjusted ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-abi_unadjusted.rs:11:1 | 11 | / extern "unadjusted" fn foo() { diff --git a/src/test/ui/feature-gate-catch_expr.stderr b/src/test/ui/feature-gate-catch_expr.stderr index 4b3bfbbe27ac8..f486373d225c3 100644 --- a/src/test/ui/feature-gate-catch_expr.stderr +++ b/src/test/ui/feature-gate-catch_expr.stderr @@ -1,4 +1,4 @@ -error[E0658]: `catch` expression is experimental (see issue #31436) +error: `catch` expression is experimental (see issue #31436) --> $DIR/feature-gate-catch_expr.rs:12:24 | 12 | let catch_result = do catch { //~ ERROR `catch` expression is experimental diff --git a/src/test/ui/feature-gate-i128_type2.stderr b/src/test/ui/feature-gate-i128_type2.stderr index ee81a26921498..26653a5739b2c 100644 --- a/src/test/ui/feature-gate-i128_type2.stderr +++ b/src/test/ui/feature-gate-i128_type2.stderr @@ -1,4 +1,4 @@ -error[E0658]: 128-bit type is unstable (see issue #35118) +error: 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:13:15 | 13 | fn test1() -> i128 { //~ ERROR 128-bit type is unstable @@ -6,7 +6,7 @@ error[E0658]: 128-bit type is unstable (see issue #35118) | = help: add #![feature(i128_type)] to the crate attributes to enable -error[E0658]: 128-bit type is unstable (see issue #35118) +error: 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:17:17 | 17 | fn test1_2() -> u128 { //~ ERROR 128-bit type is unstable @@ -14,7 +14,7 @@ error[E0658]: 128-bit type is unstable (see issue #35118) | = help: add #![feature(i128_type)] to the crate attributes to enable -error[E0658]: 128-bit type is unstable (see issue #35118) +error: 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:22:12 | 22 | let x: i128 = 0; //~ ERROR 128-bit type is unstable @@ -22,7 +22,7 @@ error[E0658]: 128-bit type is unstable (see issue #35118) | = help: add #![feature(i128_type)] to the crate attributes to enable -error[E0658]: 128-bit type is unstable (see issue #35118) +error: 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:26:12 | 26 | let x: u128 = 0; //~ ERROR 128-bit type is unstable @@ -32,7 +32,7 @@ error[E0658]: 128-bit type is unstable (see issue #35118) error[E0601]: main function not found -error[E0658]: repr with 128-bit type is unstable (see issue #35118) +error: repr with 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:30:1 | 30 | / enum A { //~ ERROR 128-bit type is unstable diff --git a/src/test/ui/feature-gate-intrinsics.stderr b/src/test/ui/feature-gate-intrinsics.stderr index 918c749504aea..5382122e30edd 100644 --- a/src/test/ui/feature-gate-intrinsics.stderr +++ b/src/test/ui/feature-gate-intrinsics.stderr @@ -1,4 +1,4 @@ -error[E0658]: intrinsics are subject to change +error: intrinsics are subject to change --> $DIR/feature-gate-intrinsics.rs:11:1 | 11 | / extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change @@ -8,7 +8,7 @@ error[E0658]: intrinsics are subject to change | = help: add #![feature(intrinsics)] to the crate attributes to enable -error[E0658]: intrinsics are subject to change +error: intrinsics are subject to change --> $DIR/feature-gate-intrinsics.rs:15:1 | 15 | / extern "rust-intrinsic" fn baz() { //~ ERROR intrinsics are subject to change diff --git a/src/test/ui/feature-gate-non_ascii_idents.stderr b/src/test/ui/feature-gate-non_ascii_idents.stderr index deb707752b066..90d0b8daee71c 100644 --- a/src/test/ui/feature-gate-non_ascii_idents.stderr +++ b/src/test/ui/feature-gate-non_ascii_idents.stderr @@ -1,4 +1,4 @@ -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:11:1 | 11 | extern crate core as bäz; //~ ERROR non-ascii idents @@ -6,7 +6,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:13:5 | 13 | use föö::bar; //~ ERROR non-ascii idents @@ -14,7 +14,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:15:1 | 15 | mod föö { //~ ERROR non-ascii idents @@ -22,7 +22,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:19:1 | 19 | / fn bär( //~ ERROR non-ascii idents @@ -36,7 +36,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:20:5 | 20 | bäz: isize //~ ERROR non-ascii idents @@ -44,7 +44,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:22:9 | 22 | let _ö: isize; //~ ERROR non-ascii idents @@ -52,7 +52,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:25:10 | 25 | (_ä, _) => {} //~ ERROR non-ascii idents @@ -60,7 +60,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:29:1 | 29 | struct Föö { //~ ERROR non-ascii idents @@ -68,7 +68,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:30:5 | 30 | föö: isize //~ ERROR non-ascii idents @@ -76,7 +76,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:33:1 | 33 | enum Bär { //~ ERROR non-ascii idents @@ -84,7 +84,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:34:5 | 34 | Bäz { //~ ERROR non-ascii idents @@ -92,7 +92,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:35:9 | 35 | qüx: isize //~ ERROR non-ascii idents @@ -100,7 +100,7 @@ error[E0658]: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error[E0658]: non-ascii idents are not fully supported. (see issue #28979) +error: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:40:5 | 40 | fn qüx(); //~ ERROR non-ascii idents diff --git a/src/test/ui/feature-gate-repr128.stderr b/src/test/ui/feature-gate-repr128.stderr index 982ebb0101662..c59964887b58f 100644 --- a/src/test/ui/feature-gate-repr128.stderr +++ b/src/test/ui/feature-gate-repr128.stderr @@ -1,4 +1,4 @@ -error[E0658]: repr with 128-bit type is unstable (see issue #35118) +error: repr with 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-repr128.rs:12:1 | 12 | / enum A { //~ ERROR repr with 128-bit type is unstable diff --git a/src/test/ui/feature-gate-unboxed-closures.stderr b/src/test/ui/feature-gate-unboxed-closures.stderr index ca8a59249463d..b79165147e590 100644 --- a/src/test/ui/feature-gate-unboxed-closures.stderr +++ b/src/test/ui/feature-gate-unboxed-closures.stderr @@ -1,4 +1,4 @@ -error[E0658]: rust-call ABI is subject to change (see issue #29625) +error: rust-call ABI is subject to change (see issue #29625) --> $DIR/feature-gate-unboxed-closures.rs:16:5 | 16 | / extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { diff --git a/src/test/ui/feature-gate-untagged_unions.stderr b/src/test/ui/feature-gate-untagged_unions.stderr index 14b66cb5c815a..26b698912bc95 100644 --- a/src/test/ui/feature-gate-untagged_unions.stderr +++ b/src/test/ui/feature-gate-untagged_unions.stderr @@ -1,4 +1,4 @@ -error[E0658]: unions with non-`Copy` fields are unstable (see issue #32836) +error: unions with non-`Copy` fields are unstable (see issue #32836) --> $DIR/feature-gate-untagged_unions.rs:19:1 | 19 | / union U3 { //~ ERROR unions with non-`Copy` fields are unstable @@ -8,7 +8,7 @@ error[E0658]: unions with non-`Copy` fields are unstable (see issue #32836) | = help: add #![feature(untagged_unions)] to the crate attributes to enable -error[E0658]: unions with non-`Copy` fields are unstable (see issue #32836) +error: unions with non-`Copy` fields are unstable (see issue #32836) --> $DIR/feature-gate-untagged_unions.rs:23:1 | 23 | / union U4 { //~ ERROR unions with non-`Copy` fields are unstable @@ -18,7 +18,7 @@ error[E0658]: unions with non-`Copy` fields are unstable (see issue #32836) | = help: add #![feature(untagged_unions)] to the crate attributes to enable -error[E0658]: unions with `Drop` implementations are unstable (see issue #32836) +error: unions with `Drop` implementations are unstable (see issue #32836) --> $DIR/feature-gate-untagged_unions.rs:27:1 | 27 | / union U5 { //~ ERROR unions with `Drop` implementations are unstable diff --git a/src/test/ui/fmt/send-sync.stderr b/src/test/ui/fmt/send-sync.stderr index 4ec5c9ebd2712..9e0e563c35f65 100644 --- a/src/test/ui/fmt/send-sync.stderr +++ b/src/test/ui/fmt/send-sync.stderr @@ -12,11 +12,7 @@ error[E0277]: the trait bound `*mut std::ops::Fn() + 'static: std::marker::Sync` = note: required because it appears within the type `[std::fmt::ArgumentV1<'_>]` = note: required because of the requirements on the impl of `std::marker::Send` for `&[std::fmt::ArgumentV1<'_>]` = note: required because it appears within the type `std::fmt::Arguments<'_>` -note: required by `send` - --> $DIR/send-sync.rs:11:1 - | -11 | fn send(_: T) {} - | ^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `send` error[E0277]: the trait bound `*mut std::ops::Fn() + 'static: std::marker::Sync` is not satisfied in `std::fmt::Arguments<'_>` --> $DIR/send-sync.rs:19:5 @@ -32,11 +28,7 @@ error[E0277]: the trait bound `*mut std::ops::Fn() + 'static: std::marker::Sync` = note: required because it appears within the type `[std::fmt::ArgumentV1<'_>]` = note: required because it appears within the type `&[std::fmt::ArgumentV1<'_>]` = note: required because it appears within the type `std::fmt::Arguments<'_>` -note: required by `sync` - --> $DIR/send-sync.rs:12:1 - | -12 | fn sync(_: T) {} - | ^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `sync` error: aborting due to 2 previous errors diff --git a/src/test/ui/generator/not-send-sync.stderr b/src/test/ui/generator/not-send-sync.stderr index e65c8f1546e82..fd8f3b8e6463d 100644 --- a/src/test/ui/generator/not-send-sync.stderr +++ b/src/test/ui/generator/not-send-sync.stderr @@ -7,11 +7,7 @@ error[E0277]: the trait bound `std::cell::Cell: std::marker::Sync` is not s = help: the trait `std::marker::Sync` is not implemented for `std::cell::Cell` = note: required because of the requirements on the impl of `std::marker::Send` for `&std::cell::Cell` = note: required because it appears within the type `[generator@$DIR/not-send-sync.rs:26:17: 30:6 a:&std::cell::Cell _]` -note: required by `main::assert_send` - --> $DIR/not-send-sync.rs:17:5 - | -17 | fn assert_send(_: T) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `main::assert_send` error[E0277]: the trait bound `std::cell::Cell: std::marker::Sync` is not satisfied in `[generator@$DIR/not-send-sync.rs:19:17: 23:6 {std::cell::Cell, ()}]` --> $DIR/not-send-sync.rs:19:5 diff --git a/src/test/ui/impl-trait/auto-trait-leak.stderr b/src/test/ui/impl-trait/auto-trait-leak.stderr index 838a3002e3aa7..ffd6a3fe4ffb1 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak.stderr @@ -7,11 +7,7 @@ error[E0277]: the trait bound `std::rc::Rc>: std::marker::S = help: within `impl std::ops::Fn<(i32,)>`, the trait `std::marker::Send` is not implemented for `std::rc::Rc>` = note: required because it appears within the type `[closure@$DIR/auto-trait-leak.rs:21:5: 21:22 p:std::rc::Rc>]` = note: required because it appears within the type `impl std::ops::Fn<(i32,)>` -note: required by `send` - --> $DIR/auto-trait-leak.rs:24:1 - | -24 | fn send(_: T) {} - | ^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `send` error[E0277]: the trait bound `std::rc::Rc>: std::marker::Send` is not satisfied in `impl std::ops::Fn<(i32,)>` --> $DIR/auto-trait-leak.rs:30:5 @@ -22,11 +18,7 @@ error[E0277]: the trait bound `std::rc::Rc>: std::marker::S = help: within `impl std::ops::Fn<(i32,)>`, the trait `std::marker::Send` is not implemented for `std::rc::Rc>` = note: required because it appears within the type `[closure@$DIR/auto-trait-leak.rs:38:5: 38:22 p:std::rc::Rc>]` = note: required because it appears within the type `impl std::ops::Fn<(i32,)>` -note: required by `send` - --> $DIR/auto-trait-leak.rs:24:1 - | -24 | fn send(_: T) {} - | ^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `send` error[E0391]: unsupported cyclic reference between types/traits detected --> $DIR/auto-trait-leak.rs:44:1 diff --git a/src/test/ui/impl-trait/equality.stderr b/src/test/ui/impl-trait/equality.stderr index 3fc08a0900fb9..8ec819038031b 100644 --- a/src/test/ui/impl-trait/equality.stderr +++ b/src/test/ui/impl-trait/equality.stderr @@ -7,7 +7,7 @@ error[E0308]: mismatched types = note: expected type `i32` found type `u32` -error[E0277]: the trait bound `u32: std::ops::Add` is not satisfied +error[E0277]: cannot add `impl Foo` to `u32` --> $DIR/equality.rs:34:11 | 34 | n + sum_to(n - 1) diff --git a/src/test/ui/issue-24424.stderr b/src/test/ui/issue-24424.stderr index 55af26dd91ea3..acdf348791b20 100644 --- a/src/test/ui/issue-24424.stderr +++ b/src/test/ui/issue-24424.stderr @@ -4,11 +4,7 @@ error[E0283]: type annotations required: cannot resolve `T0: Trait0<'l0>` 14 | impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -note: required by `Trait0` - --> $DIR/issue-24424.rs:12:1 - | -12 | trait Trait0<'l0> {} - | ^^^^^^^^^^^^^^^^^ + = note: required by `Trait0` error: aborting due to previous error diff --git a/src/test/ui/lint/suggestions.stderr b/src/test/ui/lint/suggestions.stderr index 8b30f552d3771..701a95222183a 100644 --- a/src/test/ui/lint/suggestions.stderr +++ b/src/test/ui/lint/suggestions.stderr @@ -1,7 +1,7 @@ warning: unnecessary parentheses around assigned value - --> $DIR/suggestions.rs:46:21 + --> $DIR/suggestions.rs:36:21 | -46 | let mut a = (1); // should suggest no `mut`, no parens +36 | let mut a = (1); // should suggest no `mut`, no parens | ^^^ help: remove these parentheses | note: lint level defined here @@ -11,17 +11,17 @@ note: lint level defined here | ^^^^^^^^^^^^^ warning: use of deprecated attribute `no_debug`: the `#[no_debug]` attribute was an experimental feature that has been deprecated due to lack of demand. See https://github.com/rust-lang/rust/issues/29721 - --> $DIR/suggestions.rs:41:1 + --> $DIR/suggestions.rs:31:1 | -41 | #[no_debug] // should suggest removal of deprecated attribute +31 | #[no_debug] // should suggest removal of deprecated attribute | ^^^^^^^^^^^ help: remove this attribute | = note: #[warn(deprecated)] on by default warning: variable does not need to be mutable - --> $DIR/suggestions.rs:46:13 + --> $DIR/suggestions.rs:36:13 | -46 | let mut a = (1); // should suggest no `mut`, no parens +36 | let mut a = (1); // should suggest no `mut`, no parens | ---^^ | | | help: remove this `mut` @@ -72,30 +72,18 @@ warning: function is marked #[no_mangle], but not exported | = note: #[warn(private_no_mangle_fns)] on by default -warning: static is marked #[no_mangle], but not exported - --> $DIR/suggestions.rs:31:18 - | -31 | #[no_mangle] pub static DAUNTLESS: bool = true; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: function is marked #[no_mangle], but not exported - --> $DIR/suggestions.rs:33:18 - | -33 | #[no_mangle] pub fn val_jean() {} - | ^^^^^^^^^^^^^^^^^^^^ - warning: denote infinite loops with `loop { ... }` - --> $DIR/suggestions.rs:44:5 + --> $DIR/suggestions.rs:34:5 | -44 | while true { // should suggest `loop` +34 | while true { // should suggest `loop` | ^^^^^^^^^^ help: use `loop` | = note: #[warn(while_true)] on by default warning: the `warp_factor:` in this pattern is redundant - --> $DIR/suggestions.rs:51:23 + --> $DIR/suggestions.rs:41:23 | -51 | Equinox { warp_factor: warp_factor } => {} // should suggest shorthand +41 | Equinox { warp_factor: warp_factor } => {} // should suggest shorthand | ------------^^^^^^^^^^^^ | | | help: remove this diff --git a/src/test/ui/lint/use_suggestion_json.stderr b/src/test/ui/lint/use_suggestion_json.stderr index 86c2ad4c0e7a4..abbf3da513a6f 100644 --- a/src/test/ui/lint/use_suggestion_json.stderr +++ b/src/test/ui/lint/use_suggestion_json.stderr @@ -2,72 +2,7 @@ "message": "cannot find type `Iter` in this scope", "code": { "code": "E0412", - "explanation": " -The type name used is not in scope. - -Erroneous code examples: - -```compile_fail,E0412 -impl Something {} // error: type name `Something` is not in scope - -// or: - -trait Foo { - fn bar(N); // error: type name `N` is not in scope -} - -// or: - -fn foo(x: T) {} // type name `T` is not in scope -``` - -To fix this error, please verify you didn't misspell the type name, you did -declare it or imported it into the scope. Examples: - -``` -struct Something; - -impl Something {} // ok! - -// or: - -trait Foo { - type N; - - fn bar(_: Self::N); // ok! -} - -// or: - -fn foo(x: T) {} // ok! -``` - -Another case that causes this error is when a type is imported into a parent -module. To fix this, you can follow the suggestion and use File directly or -`use super::File;` which will import the types from the parent namespace. An -example that causes this error is below: - -```compile_fail,E0412 -use std::fs::File; - -mod foo { - fn some_function(f: File) {} -} -``` - -``` -use std::fs::File; - -mod foo { - // either - use super::File; - // or - // use std::fs::File; - fn foo(f: File) {} -} -# fn main() {} // don't insert it for us; that'll break imports -``` -" + "explanation": null }, "level": "error", "spans": [ diff --git a/src/test/ui/macros/format-foreign.stderr b/src/test/ui/macros/format-foreign.stderr index f9852c5477332..d0229957b682e 100644 --- a/src/test/ui/macros/format-foreign.stderr +++ b/src/test/ui/macros/format-foreign.stderr @@ -1,8 +1,12 @@ error: multiple unused formatting arguments - --> $DIR/format-foreign.rs:12:30 + --> $DIR/format-foreign.rs:12:5 | -12 | println!("%.*3$s %s!/n", "Hello,", "World", 4); //~ ERROR multiple unused formatting arguments - | -------------------------^^^^^^^^--^^^^^^^--^-- multiple unused arguments in this statement +12 | println!("%.*3$s %s!/n", "Hello,", "World", 4); + | ^^^^^^^^^^^^^^^^^^^^^^^^^--------^^-------^^-^^ + | | | | + | | | unused + | | unused + | unused | = help: `%.*3$s` should be written as `{:.2$}` = help: `%s` should be written as `{}` diff --git a/src/test/ui/macros/format-unused-lables.stderr b/src/test/ui/macros/format-unused-lables.stderr index 64ea5626c1d62..9efdca12dea03 100644 --- a/src/test/ui/macros/format-unused-lables.stderr +++ b/src/test/ui/macros/format-unused-lables.stderr @@ -1,43 +1,49 @@ error: multiple unused formatting arguments - --> $DIR/format-unused-lables.rs:12:22 + --> $DIR/format-unused-lables.rs:12:5 | 12 | println!("Test", 123, 456, 789); - | -----------------^^^--^^^--^^^-- multiple unused arguments in this statement + | ^^^^^^^^^^^^^^^^^---^^---^^---^^ + | | | | + | | | unused + | | unused + | unused | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: multiple unused formatting arguments - --> $DIR/format-unused-lables.rs:16:9 + --> $DIR/format-unused-lables.rs:14:5 | -15 | / println!("Test2", -16 | | 123, //~ ERROR multiple unused formatting arguments - | | ^^^ -17 | | 456, - | | ^^^ -18 | | 789 - | | ^^^ -19 | | ); - | |______- multiple unused arguments in this statement +14 | / println!("Test2", +15 | | 123, + | | --- unused +16 | | 456, + | | --- unused +17 | | 789 + | | --- unused +18 | | ); + | |______^ | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: named argument never used - --> $DIR/format-unused-lables.rs:21:35 + --> $DIR/format-unused-lables.rs:20:35 | -21 | println!("Some stuff", UNUSED="args"); //~ ERROR named argument never used +20 | println!("Some stuff", UNUSED="args"); //~ ERROR named argument never used | ^^^^^^ error: multiple unused formatting arguments - --> $DIR/format-unused-lables.rs:24:9 + --> $DIR/format-unused-lables.rs:22:5 | -23 | / println!("Some more $STUFF", -24 | | "woo!", //~ ERROR multiple unused formatting arguments - | | ^^^^^^ -25 | | STUFF= -26 | | "things" - | | ^^^^^^^^ -27 | | , UNUSED="args"); - | |_______________________^^^^^^_- multiple unused arguments in this statement +22 | / println!("Some more $STUFF", +23 | | "woo!", + | | ------ unused +24 | | STUFF= +25 | | "things" + | | -------- unused +26 | | , UNUSED="args"); + | |_______________________------_^ + | | + | unused | = help: `$STUFF` should be written as `{STUFF}` = note: shell formatting not supported; see the documentation for `std::fmt` diff --git a/src/test/ui/mismatched_types/E0631.stderr b/src/test/ui/mismatched_types/E0631.stderr index 53f2f54325d57..442900e0a836a 100644 --- a/src/test/ui/mismatched_types/E0631.stderr +++ b/src/test/ui/mismatched_types/E0631.stderr @@ -6,11 +6,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `fn(usize) -> _` | -note: required by `foo` - --> $DIR/E0631.rs:13:1 - | -13 | fn foo(_: F) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `foo` error[E0631]: type mismatch in closure arguments --> $DIR/E0631.rs:18:5 @@ -20,11 +16,7 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `fn(usize) -> _` | -note: required by `bar` - --> $DIR/E0631.rs:14:1 - | -14 | fn bar>(_: F) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `bar` error[E0631]: type mismatch in function arguments --> $DIR/E0631.rs:19:5 @@ -35,11 +27,7 @@ error[E0631]: type mismatch in function arguments 19 | foo(f); //~ ERROR type mismatch | ^^^ expected signature of `fn(usize) -> _` | -note: required by `foo` - --> $DIR/E0631.rs:13:1 - | -13 | fn foo(_: F) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `foo` error[E0631]: type mismatch in function arguments --> $DIR/E0631.rs:20:5 @@ -50,11 +38,7 @@ error[E0631]: type mismatch in function arguments 20 | bar(f); //~ ERROR type mismatch | ^^^ expected signature of `fn(usize) -> _` | -note: required by `bar` - --> $DIR/E0631.rs:14:1 - | -14 | fn bar>(_: F) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `bar` error: aborting due to 4 previous errors diff --git a/src/test/ui/mismatched_types/binops.stderr b/src/test/ui/mismatched_types/binops.stderr index 8541ad52e0177..57e66794a58a9 100644 --- a/src/test/ui/mismatched_types/binops.stderr +++ b/src/test/ui/mismatched_types/binops.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `{integer}: std::ops::Add>` is not satisfied +error[E0277]: cannot add `std::option::Option<{integer}>` to `{integer}` --> $DIR/binops.rs:12:7 | 12 | 1 + Some(1); //~ ERROR is not satisfied @@ -6,7 +6,7 @@ error[E0277]: the trait bound `{integer}: std::ops::Add>` is not implemented for `{integer}` -error[E0277]: the trait bound `usize: std::ops::Sub>` is not satisfied +error[E0277]: cannot substract `std::option::Option<{integer}>` from `usize` --> $DIR/binops.rs:13:16 | 13 | 2 as usize - Some(1); //~ ERROR is not satisfied @@ -14,7 +14,7 @@ error[E0277]: the trait bound `usize: std::ops::Sub>` is not implemented for `usize` -error[E0277]: the trait bound `{integer}: std::ops::Mul<()>` is not satisfied +error[E0277]: cannot multiply `()` to `{integer}` --> $DIR/binops.rs:14:7 | 14 | 3 * (); //~ ERROR is not satisfied @@ -22,7 +22,7 @@ error[E0277]: the trait bound `{integer}: std::ops::Mul<()>` is not satisfied | = help: the trait `std::ops::Mul<()>` is not implemented for `{integer}` -error[E0277]: the trait bound `{integer}: std::ops::Div<&str>` is not satisfied +error[E0277]: cannot divide `{integer}` by `&str` --> $DIR/binops.rs:15:7 | 15 | 4 / ""; //~ ERROR is not satisfied diff --git a/src/test/ui/mismatched_types/closure-arg-count.stderr b/src/test/ui/mismatched_types/closure-arg-count.stderr index be00ee4d74e7e..d904831ba4e32 100644 --- a/src/test/ui/mismatched_types/closure-arg-count.stderr +++ b/src/test/ui/mismatched_types/closure-arg-count.stderr @@ -46,11 +46,7 @@ error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments | | | expected closure that takes 1 argument | -note: required by `f` - --> $DIR/closure-arg-count.rs:13:1 - | -13 | fn f>(_: F) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `f` error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments --> $DIR/closure-arg-count.rs:26:53 diff --git a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr index dfd02fe23b686..77d3a33276737 100644 --- a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr @@ -31,11 +31,7 @@ error[E0631]: type mismatch in function arguments | expected signature of `for<'r> fn(*mut &'r u32) -> _` | found signature of `fn(*mut &'a u32) -> _` | -note: required by `baz` - --> $DIR/closure-arg-type-mismatch.rs:18:1 - | -18 | fn baz(_: F) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `baz` error[E0271]: type mismatch resolving `for<'r> >::Output == ()` --> $DIR/closure-arg-type-mismatch.rs:20:5 @@ -43,11 +39,7 @@ error[E0271]: type mismatch resolving `for<'r> $DIR/closure-arg-type-mismatch.rs:18:1 - | -18 | fn baz(_: F) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `baz` error: aborting due to 5 previous errors diff --git a/src/test/ui/mismatched_types/closure-mismatch.stderr b/src/test/ui/mismatched_types/closure-mismatch.stderr index 01de7e0749500..99767ba1afaef 100644 --- a/src/test/ui/mismatched_types/closure-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-mismatch.stderr @@ -5,11 +5,7 @@ error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/closure-mismatch.r | ^^^ expected bound lifetime parameter, found concrete lifetime | = note: required because of the requirements on the impl of `Foo` for `[closure@$DIR/closure-mismatch.rs:18:9: 18:15]` -note: required by `baz` - --> $DIR/closure-mismatch.rs:15:1 - | -15 | fn baz(_: T) {} - | ^^^^^^^^^^^^^^^^^^^^ + = note: required by `baz` error[E0631]: type mismatch in closure arguments --> $DIR/closure-mismatch.rs:18:5 @@ -20,11 +16,7 @@ error[E0631]: type mismatch in closure arguments | expected signature of `for<'r> fn(&'r ()) -> _` | = note: required because of the requirements on the impl of `Foo` for `[closure@$DIR/closure-mismatch.rs:18:9: 18:15]` -note: required by `baz` - --> $DIR/closure-mismatch.rs:15:1 - | -15 | fn baz(_: T) {} - | ^^^^^^^^^^^^^^^^^^^^ + = note: required by `baz` error: aborting due to 2 previous errors diff --git a/src/test/ui/mismatched_types/fn-variance-1.stderr b/src/test/ui/mismatched_types/fn-variance-1.stderr index 64c260c30ed49..2a27ffd106247 100644 --- a/src/test/ui/mismatched_types/fn-variance-1.stderr +++ b/src/test/ui/mismatched_types/fn-variance-1.stderr @@ -7,11 +7,7 @@ error[E0631]: type mismatch in function arguments 21 | apply(&3, takes_mut); | ^^^^^ expected signature of `fn(&{integer}) -> _` | -note: required by `apply` - --> $DIR/fn-variance-1.rs:15:1 - | -15 | fn apply(t: T, f: F) where F: FnOnce(T) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `apply` error[E0631]: type mismatch in function arguments --> $DIR/fn-variance-1.rs:25:5 @@ -22,11 +18,7 @@ error[E0631]: type mismatch in function arguments 25 | apply(&mut 3, takes_imm); | ^^^^^ expected signature of `fn(&mut {integer}) -> _` | -note: required by `apply` - --> $DIR/fn-variance-1.rs:15:1 - | -15 | fn apply(t: T, f: F) where F: FnOnce(T) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `apply` error: aborting due to 2 previous errors diff --git a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr index 9c9bbd19c7552..8539c8818c025 100644 --- a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr +++ b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr @@ -1,17 +1,12 @@ error[E0631]: type mismatch in closure arguments - --> $DIR/unboxed-closures-vtable-mismatch.rs:25:13 + --> $DIR/unboxed-closures-vtable-mismatch.rs:23:13 | -23 | let f = to_fn_mut(|x: usize, y: isize| -> isize { (x as isize) + y }); +22 | let f = to_fn_mut(|x: usize, y: isize| -> isize { (x as isize) + y }); | ----------------------------- found signature of `fn(usize, isize) -> _` -24 | //~^ NOTE found signature of `fn(usize, isize) -> _` -25 | let z = call_it(3, f); +23 | let z = call_it(3, f); | ^^^^^^^ expected signature of `fn(isize, isize) -> _` | -note: required by `call_it` - --> $DIR/unboxed-closures-vtable-mismatch.rs:17:1 - | -17 | fn call_itisize>(y: isize, mut f: F) -> isize { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `call_it` error: aborting due to previous error diff --git a/src/test/ui/on-unimplemented/multiple-impls.stderr b/src/test/ui/on-unimplemented/multiple-impls.stderr index cfac3981be284..1f71be446efb5 100644 --- a/src/test/ui/on-unimplemented/multiple-impls.stderr +++ b/src/test/ui/on-unimplemented/multiple-impls.stderr @@ -5,11 +5,7 @@ error[E0277]: the trait bound `[i32]: Index` is not satisfied | ^^^^^^^^^^^^ trait message | = help: the trait `Index` is not implemented for `[i32]` -note: required by `Index::index` - --> $DIR/multiple-impls.rs:22:5 - | -22 | fn index(&self, index: Idx) -> &Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `Index::index` error[E0277]: the trait bound `[i32]: Index` is not satisfied --> $DIR/multiple-impls.rs:43:5 @@ -26,11 +22,7 @@ error[E0277]: the trait bound `[i32]: Index>` is not satisfied | ^^^^^^^^^^^^ on impl for Foo | = help: the trait `Index>` is not implemented for `[i32]` -note: required by `Index::index` - --> $DIR/multiple-impls.rs:22:5 - | -22 | fn index(&self, index: Idx) -> &Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `Index::index` error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:46:5 @@ -47,11 +39,7 @@ error[E0277]: the trait bound `[i32]: Index>` is not satisfied | ^^^^^^^^^^^^ on impl for Bar | = help: the trait `Index>` is not implemented for `[i32]` -note: required by `Index::index` - --> $DIR/multiple-impls.rs:22:5 - | -22 | fn index(&self, index: Idx) -> &Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `Index::index` error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:49:5 diff --git a/src/test/ui/on-unimplemented/on-impl.stderr b/src/test/ui/on-unimplemented/on-impl.stderr index ed2da68f08167..c8c06bf44fd6f 100644 --- a/src/test/ui/on-unimplemented/on-impl.stderr +++ b/src/test/ui/on-unimplemented/on-impl.stderr @@ -5,11 +5,7 @@ error[E0277]: the trait bound `[i32]: Index` is not satisfied | ^^^^^^^^^^^^^^^^^^^ a usize is required to index into a slice | = help: the trait `Index` is not implemented for `[i32]` -note: required by `Index::index` - --> $DIR/on-impl.rs:19:5 - | -19 | fn index(&self, index: Idx) -> &Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `Index::index` error[E0277]: the trait bound `[i32]: Index` is not satisfied --> $DIR/on-impl.rs:32:5 diff --git a/src/test/ui/on-unimplemented/on-trait.stderr b/src/test/ui/on-unimplemented/on-trait.stderr index 028200a5558c8..cde56022faea2 100644 --- a/src/test/ui/on-unimplemented/on-trait.stderr +++ b/src/test/ui/on-unimplemented/on-trait.stderr @@ -5,11 +5,7 @@ error[E0277]: the trait bound `std::option::Option>: MyFromIte | ^^^^^^^ a collection of type `std::option::Option>` cannot be built from an iterator over elements of type `&u8` | = help: the trait `MyFromIterator<&u8>` is not implemented for `std::option::Option>` -note: required by `collect` - --> $DIR/on-trait.rs:31:1 - | -31 | fn collect, B: MyFromIterator>(it: I) -> B { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `collect` error[E0277]: the trait bound `std::string::String: Bar::Foo` is not satisfied --> $DIR/on-trait.rs:40:21 @@ -18,11 +14,7 @@ error[E0277]: the trait bound `std::string::String: Bar::Foo` is not | ^^^^^^ test error `std::string::String` with `u8` `_` `u32` in `Bar::Foo` | = help: the trait `Bar::Foo` is not implemented for `std::string::String` -note: required by `foobar` - --> $DIR/on-trait.rs:21:1 - | -21 | fn foobar>() -> T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `foobar` error: aborting due to 2 previous errors diff --git a/src/test/ui/span/issue-29595.stderr b/src/test/ui/span/issue-29595.stderr index 9046b90f0e9c3..81ba0057d7173 100644 --- a/src/test/ui/span/issue-29595.stderr +++ b/src/test/ui/span/issue-29595.stderr @@ -4,11 +4,7 @@ error[E0277]: the trait bound `u8: Tr` is not satisfied 17 | let a: u8 = Tr::C; //~ ERROR the trait bound `u8: Tr` is not satisfied | ^^^^^ the trait `Tr` is not implemented for `u8` | -note: required by `Tr::C` - --> $DIR/issue-29595.rs:13:5 - | -13 | const C: Self; - | ^^^^^^^^^^^^^^ + = note: required by `Tr::C` error: aborting due to previous error diff --git a/src/test/ui/span/multiline-span-simple.stderr b/src/test/ui/span/multiline-span-simple.stderr index b068798630ed8..b6182825fc278 100644 --- a/src/test/ui/span/multiline-span-simple.stderr +++ b/src/test/ui/span/multiline-span-simple.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `u32: std::ops::Add<()>` is not satisfied +error[E0277]: cannot add `()` to `u32` --> $DIR/multiline-span-simple.rs:23:18 | 23 | foo(1 as u32 + //~ ERROR not satisfied diff --git a/src/test/ui/suggestions/try-operator-on-main.stderr b/src/test/ui/suggestions/try-operator-on-main.stderr index e97823a3d5d5b..36cdd558b0faf 100644 --- a/src/test/ui/suggestions/try-operator-on-main.stderr +++ b/src/test/ui/suggestions/try-operator-on-main.stderr @@ -22,11 +22,7 @@ error[E0277]: the trait bound `(): std::ops::Try` is not satisfied 25 | try_trait_generic::<()>(); //~ ERROR the trait bound | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::Try` is not implemented for `()` | -note: required by `try_trait_generic` - --> $DIR/try-operator-on-main.rs:30:1 - | -30 | fn try_trait_generic() -> T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: required by `try_trait_generic` error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try` --> $DIR/try-operator-on-main.rs:32:5 diff --git a/src/test/ui/type-check/issue-40294.stderr b/src/test/ui/type-check/issue-40294.stderr index cf270afdeb173..2ca97aa3ef067 100644 --- a/src/test/ui/type-check/issue-40294.stderr +++ b/src/test/ui/type-check/issue-40294.stderr @@ -10,11 +10,7 @@ error[E0283]: type annotations required: cannot resolve `&'a T: Foo` 21 | | } | |_^ | -note: required by `Foo` - --> $DIR/issue-40294.rs:11:1 - | -11 | trait Foo: Sized { - | ^^^^^^^^^^^^^^^^ + = note: required by `Foo` error: aborting due to previous error From 4c92a02b64e5cb8cfb9b885638e1dfa2067cacd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Fri, 19 Jan 2018 20:28:09 -0800 Subject: [PATCH 086/198] Change rustc_on_unimplemented for Iterator and binops --- src/libcore/ops/arith.rs | 9 +-- .../anonymous-higher-ranked-lifetime.stderr | 66 +++++++++++++++---- .../issue-39802-show-5-trait-impls.stderr | 18 ++++- .../ui/did_you_mean/recursion_limit.stderr | 6 +- .../ui/feature-gate-abi_unadjusted.stderr | 2 +- src/test/ui/feature-gate-catch_expr.stderr | 2 +- src/test/ui/feature-gate-i128_type2.stderr | 10 +-- src/test/ui/feature-gate-intrinsics.stderr | 4 +- .../ui/feature-gate-non_ascii_idents.stderr | 26 ++++---- src/test/ui/feature-gate-repr128.stderr | 2 +- .../ui/feature-gate-unboxed-closures.stderr | 2 +- .../ui/feature-gate-untagged_unions.stderr | 6 +- src/test/ui/fmt/send-sync.stderr | 12 +++- src/test/ui/generator/not-send-sync.stderr | 6 +- src/test/ui/impl-trait/auto-trait-leak.stderr | 12 +++- src/test/ui/issue-24424.stderr | 6 +- src/test/ui/lint/suggestions.stderr | 32 ++++++--- src/test/ui/macros/format-foreign.stderr | 10 +-- .../ui/macros/format-unused-lables.stderr | 52 +++++++-------- src/test/ui/mismatched_types/E0631.stderr | 24 +++++-- .../mismatched_types/closure-arg-count.stderr | 56 ++++++++-------- .../closure-arg-type-mismatch.stderr | 12 +++- .../mismatched_types/closure-mismatch.stderr | 12 +++- .../ui/mismatched_types/fn-variance-1.stderr | 12 +++- .../unboxed-closures-vtable-mismatch.stderr | 13 ++-- .../multiple-impls-complex-filtering.rs | 61 +++++++++++++++++ .../multiple-impls-complex-filtering.stderr | 44 +++++++++++++ .../ui/on-unimplemented/multiple-impls.stderr | 18 ++++- src/test/ui/on-unimplemented/on-impl.stderr | 6 +- src/test/ui/on-unimplemented/on-trait.stderr | 12 +++- src/test/ui/span/issue-29595.stderr | 6 +- .../suggestions/try-operator-on-main.stderr | 6 +- src/test/ui/type-check/issue-40294.stderr | 6 +- 33 files changed, 418 insertions(+), 153 deletions(-) create mode 100644 src/test/ui/on-unimplemented/multiple-impls-complex-filtering.rs create mode 100644 src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs index 59a18d6cb75ed..47617b22dd34d 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs @@ -109,7 +109,6 @@ all(_Self="f32", RHS="u16"), all(_Self="f32", RHS="u8"), ), - message="cannot add `{RHS}` to `{Self}`", label="no implementation for `{Self} + {RHS}`, but you can safely cast \ `{RHS}` into `{Self}` using `as {Self}`", ), @@ -146,22 +145,20 @@ all(RHS="f32", _Self="u16"), all(RHS="f32", _Self="u8"), ), - message="cannot add `{RHS}` to `{Self}`", - label="no implementation for `{Self} + {RHS}`, but you can safely turn \ + label="no implementation for `{Self} + {RHS}`, but you can safely cast \ `{Self}` into `{RHS}` using `as {RHS}`", ), on( all(_Self="{integer}", RHS="{float}"), message="cannot add a float to an integer", - label="no implementation for `{Self} + {RHS}`", ), on( all(_Self="{float}", RHS="{integer}"), message="cannot add an integer to a float", - label="no implementation for `{Self} + {RHS}`", ), message="cannot add `{RHS}` to `{Self}`", - label="no implementation for `{Self} + {RHS}`")] + label="no implementation for `{Self} + {RHS}`", +)] pub trait Add { /// The resulting type after applying the `+` operator. #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/test/ui/anonymous-higher-ranked-lifetime.stderr b/src/test/ui/anonymous-higher-ranked-lifetime.stderr index e364a4d8b1441..4bd3b684b7ba3 100644 --- a/src/test/ui/anonymous-higher-ranked-lifetime.stderr +++ b/src/test/ui/anonymous-higher-ranked-lifetime.stderr @@ -6,7 +6,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r, 's> fn(&'r (), &'s ()) -> _` | - = note: required by `f1` +note: required by `f1` + --> $DIR/anonymous-higher-ranked-lifetime.rs:26:1 + | +26 | fn f1(_: F) where F: Fn(&(), &()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:13:5 @@ -16,7 +20,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'a, 'r> fn(&'a (), &'r ()) -> _` | - = note: required by `f2` +note: required by `f2` + --> $DIR/anonymous-higher-ranked-lifetime.rs:27:1 + | +27 | fn f2(_: F) where F: for<'a> Fn(&'a (), &()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:14:5 @@ -26,7 +34,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&(), &'r ()) -> _` | - = note: required by `f3` +note: required by `f3` + --> $DIR/anonymous-higher-ranked-lifetime.rs:28:1 + | +28 | fn f3<'a, F>(_: F) where F: Fn(&'a (), &()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:15:5 @@ -36,7 +48,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'s, 'r> fn(&'s (), &'r ()) -> _` | - = note: required by `f4` +note: required by `f4` + --> $DIR/anonymous-higher-ranked-lifetime.rs:29:1 + | +29 | fn f4(_: F) where F: for<'r> Fn(&(), &'r ()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:16:5 @@ -46,7 +62,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&'r (), &'r ()) -> _` | - = note: required by `f5` +note: required by `f5` + --> $DIR/anonymous-higher-ranked-lifetime.rs:30:1 + | +30 | fn f5(_: F) where F: for<'r> Fn(&'r (), &'r ()) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:17:5 @@ -56,7 +76,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&'r (), std::boxed::Box std::ops::Fn(&'s ()) + 'static>) -> _` | - = note: required by `g1` +note: required by `g1` + --> $DIR/anonymous-higher-ranked-lifetime.rs:33:1 + | +33 | fn g1(_: F) where F: Fn(&(), Box) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:18:5 @@ -66,7 +90,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r> fn(&'r (), for<'s> fn(&'s ())) -> _` | - = note: required by `g2` +note: required by `g2` + --> $DIR/anonymous-higher-ranked-lifetime.rs:34:1 + | +34 | fn g2(_: F) where F: Fn(&(), fn(&())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:19:5 @@ -76,7 +104,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'s> fn(&'s (), std::boxed::Box std::ops::Fn(&'r ()) + 'static>) -> _` | - = note: required by `g3` +note: required by `g3` + --> $DIR/anonymous-higher-ranked-lifetime.rs:35:1 + | +35 | fn g3(_: F) where F: for<'s> Fn(&'s (), Box) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:20:5 @@ -86,7 +118,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'s> fn(&'s (), for<'r> fn(&'r ())) -> _` | - = note: required by `g4` +note: required by `g4` + --> $DIR/anonymous-higher-ranked-lifetime.rs:36:1 + | +36 | fn g4(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:21:5 @@ -96,7 +132,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r, 's> fn(&'r (), std::boxed::Box std::ops::Fn(&'t0 ()) + 'static>, &'s (), for<'t0, 't1> fn(&'t0 (), &'t1 ())) -> _` | - = note: required by `h1` +note: required by `h1` + --> $DIR/anonymous-higher-ranked-lifetime.rs:39:1 + | +39 | fn h1(_: F) where F: Fn(&(), Box, &(), fn(&(), &())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/anonymous-higher-ranked-lifetime.rs:22:5 @@ -106,7 +146,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `for<'r, 't0> fn(&'r (), std::boxed::Box std::ops::Fn(&'s ()) + 'static>, &'t0 (), for<'s, 't1> fn(&'s (), &'t1 ())) -> _` | - = note: required by `h2` +note: required by `h2` + --> $DIR/anonymous-higher-ranked-lifetime.rs:40:1 + | +40 | fn h2(_: F) where F: for<'t0> Fn(&(), Box, &'t0 (), fn(&(), &())) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 11 previous errors diff --git a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr index d5c4add34b526..7ca3e8728fd9c 100644 --- a/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr +++ b/src/test/ui/did_you_mean/issue-39802-show-5-trait-impls.stderr @@ -10,7 +10,11 @@ error[E0277]: the trait bound `i8: Foo` is not satisfied > > > - = note: required by `Foo::bar` +note: required by `Foo::bar` + --> $DIR/issue-39802-show-5-trait-impls.rs:12:5 + | +12 | fn bar(&self){} + | ^^^^^^^^^^^^^ error[E0277]: the trait bound `u8: Foo` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:35:5 @@ -23,7 +27,11 @@ error[E0277]: the trait bound `u8: Foo` is not satisfied > > > - = note: required by `Foo::bar` +note: required by `Foo::bar` + --> $DIR/issue-39802-show-5-trait-impls.rs:12:5 + | +12 | fn bar(&self){} + | ^^^^^^^^^^^^^ error[E0277]: the trait bound `bool: Foo` is not satisfied --> $DIR/issue-39802-show-5-trait-impls.rs:36:5 @@ -37,7 +45,11 @@ error[E0277]: the trait bound `bool: Foo` is not satisfied > > and 2 others - = note: required by `Foo::bar` +note: required by `Foo::bar` + --> $DIR/issue-39802-show-5-trait-impls.rs:12:5 + | +12 | fn bar(&self){} + | ^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/src/test/ui/did_you_mean/recursion_limit.stderr b/src/test/ui/did_you_mean/recursion_limit.stderr index 7fac604ba49d7..2bc7e9e46e7c5 100644 --- a/src/test/ui/did_you_mean/recursion_limit.stderr +++ b/src/test/ui/did_you_mean/recursion_limit.stderr @@ -15,7 +15,11 @@ error[E0275]: overflow evaluating the requirement `K: std::marker::Send` = note: required because it appears within the type `C` = note: required because it appears within the type `B` = note: required because it appears within the type `A` - = note: required by `is_send` +note: required by `is_send` + --> $DIR/recursion_limit.rs:41:1 + | +41 | fn is_send() { } + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/feature-gate-abi_unadjusted.stderr b/src/test/ui/feature-gate-abi_unadjusted.stderr index 3cc43847156a1..b3f7cd218d3e9 100644 --- a/src/test/ui/feature-gate-abi_unadjusted.stderr +++ b/src/test/ui/feature-gate-abi_unadjusted.stderr @@ -1,4 +1,4 @@ -error: unadjusted ABI is an implementation detail and perma-unstable +error[E0658]: unadjusted ABI is an implementation detail and perma-unstable --> $DIR/feature-gate-abi_unadjusted.rs:11:1 | 11 | / extern "unadjusted" fn foo() { diff --git a/src/test/ui/feature-gate-catch_expr.stderr b/src/test/ui/feature-gate-catch_expr.stderr index f486373d225c3..4b3bfbbe27ac8 100644 --- a/src/test/ui/feature-gate-catch_expr.stderr +++ b/src/test/ui/feature-gate-catch_expr.stderr @@ -1,4 +1,4 @@ -error: `catch` expression is experimental (see issue #31436) +error[E0658]: `catch` expression is experimental (see issue #31436) --> $DIR/feature-gate-catch_expr.rs:12:24 | 12 | let catch_result = do catch { //~ ERROR `catch` expression is experimental diff --git a/src/test/ui/feature-gate-i128_type2.stderr b/src/test/ui/feature-gate-i128_type2.stderr index 26653a5739b2c..ee81a26921498 100644 --- a/src/test/ui/feature-gate-i128_type2.stderr +++ b/src/test/ui/feature-gate-i128_type2.stderr @@ -1,4 +1,4 @@ -error: 128-bit type is unstable (see issue #35118) +error[E0658]: 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:13:15 | 13 | fn test1() -> i128 { //~ ERROR 128-bit type is unstable @@ -6,7 +6,7 @@ error: 128-bit type is unstable (see issue #35118) | = help: add #![feature(i128_type)] to the crate attributes to enable -error: 128-bit type is unstable (see issue #35118) +error[E0658]: 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:17:17 | 17 | fn test1_2() -> u128 { //~ ERROR 128-bit type is unstable @@ -14,7 +14,7 @@ error: 128-bit type is unstable (see issue #35118) | = help: add #![feature(i128_type)] to the crate attributes to enable -error: 128-bit type is unstable (see issue #35118) +error[E0658]: 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:22:12 | 22 | let x: i128 = 0; //~ ERROR 128-bit type is unstable @@ -22,7 +22,7 @@ error: 128-bit type is unstable (see issue #35118) | = help: add #![feature(i128_type)] to the crate attributes to enable -error: 128-bit type is unstable (see issue #35118) +error[E0658]: 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:26:12 | 26 | let x: u128 = 0; //~ ERROR 128-bit type is unstable @@ -32,7 +32,7 @@ error: 128-bit type is unstable (see issue #35118) error[E0601]: main function not found -error: repr with 128-bit type is unstable (see issue #35118) +error[E0658]: repr with 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-i128_type2.rs:30:1 | 30 | / enum A { //~ ERROR 128-bit type is unstable diff --git a/src/test/ui/feature-gate-intrinsics.stderr b/src/test/ui/feature-gate-intrinsics.stderr index 5382122e30edd..918c749504aea 100644 --- a/src/test/ui/feature-gate-intrinsics.stderr +++ b/src/test/ui/feature-gate-intrinsics.stderr @@ -1,4 +1,4 @@ -error: intrinsics are subject to change +error[E0658]: intrinsics are subject to change --> $DIR/feature-gate-intrinsics.rs:11:1 | 11 | / extern "rust-intrinsic" { //~ ERROR intrinsics are subject to change @@ -8,7 +8,7 @@ error: intrinsics are subject to change | = help: add #![feature(intrinsics)] to the crate attributes to enable -error: intrinsics are subject to change +error[E0658]: intrinsics are subject to change --> $DIR/feature-gate-intrinsics.rs:15:1 | 15 | / extern "rust-intrinsic" fn baz() { //~ ERROR intrinsics are subject to change diff --git a/src/test/ui/feature-gate-non_ascii_idents.stderr b/src/test/ui/feature-gate-non_ascii_idents.stderr index 90d0b8daee71c..deb707752b066 100644 --- a/src/test/ui/feature-gate-non_ascii_idents.stderr +++ b/src/test/ui/feature-gate-non_ascii_idents.stderr @@ -1,4 +1,4 @@ -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:11:1 | 11 | extern crate core as bäz; //~ ERROR non-ascii idents @@ -6,7 +6,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:13:5 | 13 | use föö::bar; //~ ERROR non-ascii idents @@ -14,7 +14,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:15:1 | 15 | mod föö { //~ ERROR non-ascii idents @@ -22,7 +22,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:19:1 | 19 | / fn bär( //~ ERROR non-ascii idents @@ -36,7 +36,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:20:5 | 20 | bäz: isize //~ ERROR non-ascii idents @@ -44,7 +44,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:22:9 | 22 | let _ö: isize; //~ ERROR non-ascii idents @@ -52,7 +52,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:25:10 | 25 | (_ä, _) => {} //~ ERROR non-ascii idents @@ -60,7 +60,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:29:1 | 29 | struct Föö { //~ ERROR non-ascii idents @@ -68,7 +68,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:30:5 | 30 | föö: isize //~ ERROR non-ascii idents @@ -76,7 +76,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:33:1 | 33 | enum Bär { //~ ERROR non-ascii idents @@ -84,7 +84,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:34:5 | 34 | Bäz { //~ ERROR non-ascii idents @@ -92,7 +92,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:35:9 | 35 | qüx: isize //~ ERROR non-ascii idents @@ -100,7 +100,7 @@ error: non-ascii idents are not fully supported. (see issue #28979) | = help: add #![feature(non_ascii_idents)] to the crate attributes to enable -error: non-ascii idents are not fully supported. (see issue #28979) +error[E0658]: non-ascii idents are not fully supported. (see issue #28979) --> $DIR/feature-gate-non_ascii_idents.rs:40:5 | 40 | fn qüx(); //~ ERROR non-ascii idents diff --git a/src/test/ui/feature-gate-repr128.stderr b/src/test/ui/feature-gate-repr128.stderr index c59964887b58f..982ebb0101662 100644 --- a/src/test/ui/feature-gate-repr128.stderr +++ b/src/test/ui/feature-gate-repr128.stderr @@ -1,4 +1,4 @@ -error: repr with 128-bit type is unstable (see issue #35118) +error[E0658]: repr with 128-bit type is unstable (see issue #35118) --> $DIR/feature-gate-repr128.rs:12:1 | 12 | / enum A { //~ ERROR repr with 128-bit type is unstable diff --git a/src/test/ui/feature-gate-unboxed-closures.stderr b/src/test/ui/feature-gate-unboxed-closures.stderr index b79165147e590..ca8a59249463d 100644 --- a/src/test/ui/feature-gate-unboxed-closures.stderr +++ b/src/test/ui/feature-gate-unboxed-closures.stderr @@ -1,4 +1,4 @@ -error: rust-call ABI is subject to change (see issue #29625) +error[E0658]: rust-call ABI is subject to change (see issue #29625) --> $DIR/feature-gate-unboxed-closures.rs:16:5 | 16 | / extern "rust-call" fn call_once(self, (a, b): (u32, u32)) -> u32 { diff --git a/src/test/ui/feature-gate-untagged_unions.stderr b/src/test/ui/feature-gate-untagged_unions.stderr index 26b698912bc95..14b66cb5c815a 100644 --- a/src/test/ui/feature-gate-untagged_unions.stderr +++ b/src/test/ui/feature-gate-untagged_unions.stderr @@ -1,4 +1,4 @@ -error: unions with non-`Copy` fields are unstable (see issue #32836) +error[E0658]: unions with non-`Copy` fields are unstable (see issue #32836) --> $DIR/feature-gate-untagged_unions.rs:19:1 | 19 | / union U3 { //~ ERROR unions with non-`Copy` fields are unstable @@ -8,7 +8,7 @@ error: unions with non-`Copy` fields are unstable (see issue #32836) | = help: add #![feature(untagged_unions)] to the crate attributes to enable -error: unions with non-`Copy` fields are unstable (see issue #32836) +error[E0658]: unions with non-`Copy` fields are unstable (see issue #32836) --> $DIR/feature-gate-untagged_unions.rs:23:1 | 23 | / union U4 { //~ ERROR unions with non-`Copy` fields are unstable @@ -18,7 +18,7 @@ error: unions with non-`Copy` fields are unstable (see issue #32836) | = help: add #![feature(untagged_unions)] to the crate attributes to enable -error: unions with `Drop` implementations are unstable (see issue #32836) +error[E0658]: unions with `Drop` implementations are unstable (see issue #32836) --> $DIR/feature-gate-untagged_unions.rs:27:1 | 27 | / union U5 { //~ ERROR unions with `Drop` implementations are unstable diff --git a/src/test/ui/fmt/send-sync.stderr b/src/test/ui/fmt/send-sync.stderr index 9e0e563c35f65..4ec5c9ebd2712 100644 --- a/src/test/ui/fmt/send-sync.stderr +++ b/src/test/ui/fmt/send-sync.stderr @@ -12,7 +12,11 @@ error[E0277]: the trait bound `*mut std::ops::Fn() + 'static: std::marker::Sync` = note: required because it appears within the type `[std::fmt::ArgumentV1<'_>]` = note: required because of the requirements on the impl of `std::marker::Send` for `&[std::fmt::ArgumentV1<'_>]` = note: required because it appears within the type `std::fmt::Arguments<'_>` - = note: required by `send` +note: required by `send` + --> $DIR/send-sync.rs:11:1 + | +11 | fn send(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `*mut std::ops::Fn() + 'static: std::marker::Sync` is not satisfied in `std::fmt::Arguments<'_>` --> $DIR/send-sync.rs:19:5 @@ -28,7 +32,11 @@ error[E0277]: the trait bound `*mut std::ops::Fn() + 'static: std::marker::Sync` = note: required because it appears within the type `[std::fmt::ArgumentV1<'_>]` = note: required because it appears within the type `&[std::fmt::ArgumentV1<'_>]` = note: required because it appears within the type `std::fmt::Arguments<'_>` - = note: required by `sync` +note: required by `sync` + --> $DIR/send-sync.rs:12:1 + | +12 | fn sync(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/generator/not-send-sync.stderr b/src/test/ui/generator/not-send-sync.stderr index fd8f3b8e6463d..e65c8f1546e82 100644 --- a/src/test/ui/generator/not-send-sync.stderr +++ b/src/test/ui/generator/not-send-sync.stderr @@ -7,7 +7,11 @@ error[E0277]: the trait bound `std::cell::Cell: std::marker::Sync` is not s = help: the trait `std::marker::Sync` is not implemented for `std::cell::Cell` = note: required because of the requirements on the impl of `std::marker::Send` for `&std::cell::Cell` = note: required because it appears within the type `[generator@$DIR/not-send-sync.rs:26:17: 30:6 a:&std::cell::Cell _]` - = note: required by `main::assert_send` +note: required by `main::assert_send` + --> $DIR/not-send-sync.rs:17:5 + | +17 | fn assert_send(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `std::cell::Cell: std::marker::Sync` is not satisfied in `[generator@$DIR/not-send-sync.rs:19:17: 23:6 {std::cell::Cell, ()}]` --> $DIR/not-send-sync.rs:19:5 diff --git a/src/test/ui/impl-trait/auto-trait-leak.stderr b/src/test/ui/impl-trait/auto-trait-leak.stderr index ffd6a3fe4ffb1..838a3002e3aa7 100644 --- a/src/test/ui/impl-trait/auto-trait-leak.stderr +++ b/src/test/ui/impl-trait/auto-trait-leak.stderr @@ -7,7 +7,11 @@ error[E0277]: the trait bound `std::rc::Rc>: std::marker::S = help: within `impl std::ops::Fn<(i32,)>`, the trait `std::marker::Send` is not implemented for `std::rc::Rc>` = note: required because it appears within the type `[closure@$DIR/auto-trait-leak.rs:21:5: 21:22 p:std::rc::Rc>]` = note: required because it appears within the type `impl std::ops::Fn<(i32,)>` - = note: required by `send` +note: required by `send` + --> $DIR/auto-trait-leak.rs:24:1 + | +24 | fn send(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `std::rc::Rc>: std::marker::Send` is not satisfied in `impl std::ops::Fn<(i32,)>` --> $DIR/auto-trait-leak.rs:30:5 @@ -18,7 +22,11 @@ error[E0277]: the trait bound `std::rc::Rc>: std::marker::S = help: within `impl std::ops::Fn<(i32,)>`, the trait `std::marker::Send` is not implemented for `std::rc::Rc>` = note: required because it appears within the type `[closure@$DIR/auto-trait-leak.rs:38:5: 38:22 p:std::rc::Rc>]` = note: required because it appears within the type `impl std::ops::Fn<(i32,)>` - = note: required by `send` +note: required by `send` + --> $DIR/auto-trait-leak.rs:24:1 + | +24 | fn send(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0391]: unsupported cyclic reference between types/traits detected --> $DIR/auto-trait-leak.rs:44:1 diff --git a/src/test/ui/issue-24424.stderr b/src/test/ui/issue-24424.stderr index acdf348791b20..55af26dd91ea3 100644 --- a/src/test/ui/issue-24424.stderr +++ b/src/test/ui/issue-24424.stderr @@ -4,7 +4,11 @@ error[E0283]: type annotations required: cannot resolve `T0: Trait0<'l0>` 14 | impl <'l0, 'l1, T0> Trait1<'l0, T0> for bool where T0 : Trait0<'l0>, T0 : Trait0<'l1> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: required by `Trait0` +note: required by `Trait0` + --> $DIR/issue-24424.rs:12:1 + | +12 | trait Trait0<'l0> {} + | ^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/lint/suggestions.stderr b/src/test/ui/lint/suggestions.stderr index 701a95222183a..8b30f552d3771 100644 --- a/src/test/ui/lint/suggestions.stderr +++ b/src/test/ui/lint/suggestions.stderr @@ -1,7 +1,7 @@ warning: unnecessary parentheses around assigned value - --> $DIR/suggestions.rs:36:21 + --> $DIR/suggestions.rs:46:21 | -36 | let mut a = (1); // should suggest no `mut`, no parens +46 | let mut a = (1); // should suggest no `mut`, no parens | ^^^ help: remove these parentheses | note: lint level defined here @@ -11,17 +11,17 @@ note: lint level defined here | ^^^^^^^^^^^^^ warning: use of deprecated attribute `no_debug`: the `#[no_debug]` attribute was an experimental feature that has been deprecated due to lack of demand. See https://github.com/rust-lang/rust/issues/29721 - --> $DIR/suggestions.rs:31:1 + --> $DIR/suggestions.rs:41:1 | -31 | #[no_debug] // should suggest removal of deprecated attribute +41 | #[no_debug] // should suggest removal of deprecated attribute | ^^^^^^^^^^^ help: remove this attribute | = note: #[warn(deprecated)] on by default warning: variable does not need to be mutable - --> $DIR/suggestions.rs:36:13 + --> $DIR/suggestions.rs:46:13 | -36 | let mut a = (1); // should suggest no `mut`, no parens +46 | let mut a = (1); // should suggest no `mut`, no parens | ---^^ | | | help: remove this `mut` @@ -72,18 +72,30 @@ warning: function is marked #[no_mangle], but not exported | = note: #[warn(private_no_mangle_fns)] on by default +warning: static is marked #[no_mangle], but not exported + --> $DIR/suggestions.rs:31:18 + | +31 | #[no_mangle] pub static DAUNTLESS: bool = true; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: function is marked #[no_mangle], but not exported + --> $DIR/suggestions.rs:33:18 + | +33 | #[no_mangle] pub fn val_jean() {} + | ^^^^^^^^^^^^^^^^^^^^ + warning: denote infinite loops with `loop { ... }` - --> $DIR/suggestions.rs:34:5 + --> $DIR/suggestions.rs:44:5 | -34 | while true { // should suggest `loop` +44 | while true { // should suggest `loop` | ^^^^^^^^^^ help: use `loop` | = note: #[warn(while_true)] on by default warning: the `warp_factor:` in this pattern is redundant - --> $DIR/suggestions.rs:41:23 + --> $DIR/suggestions.rs:51:23 | -41 | Equinox { warp_factor: warp_factor } => {} // should suggest shorthand +51 | Equinox { warp_factor: warp_factor } => {} // should suggest shorthand | ------------^^^^^^^^^^^^ | | | help: remove this diff --git a/src/test/ui/macros/format-foreign.stderr b/src/test/ui/macros/format-foreign.stderr index d0229957b682e..f9852c5477332 100644 --- a/src/test/ui/macros/format-foreign.stderr +++ b/src/test/ui/macros/format-foreign.stderr @@ -1,12 +1,8 @@ error: multiple unused formatting arguments - --> $DIR/format-foreign.rs:12:5 + --> $DIR/format-foreign.rs:12:30 | -12 | println!("%.*3$s %s!/n", "Hello,", "World", 4); - | ^^^^^^^^^^^^^^^^^^^^^^^^^--------^^-------^^-^^ - | | | | - | | | unused - | | unused - | unused +12 | println!("%.*3$s %s!/n", "Hello,", "World", 4); //~ ERROR multiple unused formatting arguments + | -------------------------^^^^^^^^--^^^^^^^--^-- multiple unused arguments in this statement | = help: `%.*3$s` should be written as `{:.2$}` = help: `%s` should be written as `{}` diff --git a/src/test/ui/macros/format-unused-lables.stderr b/src/test/ui/macros/format-unused-lables.stderr index 9efdca12dea03..64ea5626c1d62 100644 --- a/src/test/ui/macros/format-unused-lables.stderr +++ b/src/test/ui/macros/format-unused-lables.stderr @@ -1,49 +1,43 @@ error: multiple unused formatting arguments - --> $DIR/format-unused-lables.rs:12:5 + --> $DIR/format-unused-lables.rs:12:22 | 12 | println!("Test", 123, 456, 789); - | ^^^^^^^^^^^^^^^^^---^^---^^---^^ - | | | | - | | | unused - | | unused - | unused + | -----------------^^^--^^^--^^^-- multiple unused arguments in this statement | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: multiple unused formatting arguments - --> $DIR/format-unused-lables.rs:14:5 + --> $DIR/format-unused-lables.rs:16:9 | -14 | / println!("Test2", -15 | | 123, - | | --- unused -16 | | 456, - | | --- unused -17 | | 789 - | | --- unused -18 | | ); - | |______^ +15 | / println!("Test2", +16 | | 123, //~ ERROR multiple unused formatting arguments + | | ^^^ +17 | | 456, + | | ^^^ +18 | | 789 + | | ^^^ +19 | | ); + | |______- multiple unused arguments in this statement | = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info) error: named argument never used - --> $DIR/format-unused-lables.rs:20:35 + --> $DIR/format-unused-lables.rs:21:35 | -20 | println!("Some stuff", UNUSED="args"); //~ ERROR named argument never used +21 | println!("Some stuff", UNUSED="args"); //~ ERROR named argument never used | ^^^^^^ error: multiple unused formatting arguments - --> $DIR/format-unused-lables.rs:22:5 + --> $DIR/format-unused-lables.rs:24:9 | -22 | / println!("Some more $STUFF", -23 | | "woo!", - | | ------ unused -24 | | STUFF= -25 | | "things" - | | -------- unused -26 | | , UNUSED="args"); - | |_______________________------_^ - | | - | unused +23 | / println!("Some more $STUFF", +24 | | "woo!", //~ ERROR multiple unused formatting arguments + | | ^^^^^^ +25 | | STUFF= +26 | | "things" + | | ^^^^^^^^ +27 | | , UNUSED="args"); + | |_______________________^^^^^^_- multiple unused arguments in this statement | = help: `$STUFF` should be written as `{STUFF}` = note: shell formatting not supported; see the documentation for `std::fmt` diff --git a/src/test/ui/mismatched_types/E0631.stderr b/src/test/ui/mismatched_types/E0631.stderr index 442900e0a836a..53f2f54325d57 100644 --- a/src/test/ui/mismatched_types/E0631.stderr +++ b/src/test/ui/mismatched_types/E0631.stderr @@ -6,7 +6,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `fn(usize) -> _` | - = note: required by `foo` +note: required by `foo` + --> $DIR/E0631.rs:13:1 + | +13 | fn foo(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/E0631.rs:18:5 @@ -16,7 +20,11 @@ error[E0631]: type mismatch in closure arguments | | | expected signature of `fn(usize) -> _` | - = note: required by `bar` +note: required by `bar` + --> $DIR/E0631.rs:14:1 + | +14 | fn bar>(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in function arguments --> $DIR/E0631.rs:19:5 @@ -27,7 +35,11 @@ error[E0631]: type mismatch in function arguments 19 | foo(f); //~ ERROR type mismatch | ^^^ expected signature of `fn(usize) -> _` | - = note: required by `foo` +note: required by `foo` + --> $DIR/E0631.rs:13:1 + | +13 | fn foo(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in function arguments --> $DIR/E0631.rs:20:5 @@ -38,7 +50,11 @@ error[E0631]: type mismatch in function arguments 20 | bar(f); //~ ERROR type mismatch | ^^^ expected signature of `fn(usize) -> _` | - = note: required by `bar` +note: required by `bar` + --> $DIR/E0631.rs:14:1 + | +14 | fn bar>(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors diff --git a/src/test/ui/mismatched_types/closure-arg-count.stderr b/src/test/ui/mismatched_types/closure-arg-count.stderr index d904831ba4e32..4e1523c79d2d4 100644 --- a/src/test/ui/mismatched_types/closure-arg-count.stderr +++ b/src/test/ui/mismatched_types/closure-arg-count.stderr @@ -14,7 +14,7 @@ error[E0593]: closure is expected to take 2 arguments, but it takes 1 argument | | | expected closure that takes 2 arguments -error[E0593]: closure is expected to take 2 distinct arguments, but it takes a single 2-tuple as argument +error[E0593]: closure is expected to take 2 arguments, but it takes 1 argument --> $DIR/closure-arg-count.rs:19:15 | 19 | [1, 2, 3].sort_by(|(tuple, tuple2)| panic!()); @@ -39,62 +39,58 @@ help: change the closure to take multiple arguments instead of a single tuple | ^^^^^^^^^^^^^^^ error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments - --> $DIR/closure-arg-count.rs:23:5 + --> $DIR/closure-arg-count.rs:21:5 | -23 | f(|| panic!()); +21 | f(|| panic!()); | ^ -- takes 0 arguments | | | expected closure that takes 1 argument | - = note: required by `f` +note: required by `f` + --> $DIR/closure-arg-count.rs:13:1 + | +13 | fn f>(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments - --> $DIR/closure-arg-count.rs:26:53 +error[E0593]: closure is expected to take a single tuple as argument, but it takes 2 distinct arguments + --> $DIR/closure-arg-count.rs:24:53 | -26 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x| i); - | ^^^ ------ takes 2 distinct arguments +24 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x| i); + | ^^^ ------ help: consider changing the closure to accept a tuple: `|(i, x)|` | | - | expected closure that takes a single 2-tuple as argument -help: change the closure to accept a tuple instead of individual arguments - | -26 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|(i, x)| i); - | ^^^^^^^^ + | expected closure that takes a single tuple as argument -error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments - --> $DIR/closure-arg-count.rs:28:53 +error[E0593]: closure is expected to take a single tuple as argument, but it takes 2 distinct arguments + --> $DIR/closure-arg-count.rs:26:53 | -28 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i: usize, x| i); - | ^^^ ------------- takes 2 distinct arguments +26 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i: usize, x| i); + | ^^^ ------------- help: consider changing the closure to accept a tuple: `|(i, x): (usize, _)|` | | - | expected closure that takes a single 2-tuple as argument -help: change the closure to accept a tuple instead of individual arguments - | -28 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|(i, x)| i); - | ^^^^^^^^ + | expected closure that takes a single tuple as argument error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 3 distinct arguments - --> $DIR/closure-arg-count.rs:30:53 + --> $DIR/closure-arg-count.rs:28:53 | -30 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x, y| i); +28 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x, y| i); | ^^^ --------- takes 3 distinct arguments | | | expected closure that takes a single 2-tuple as argument error[E0593]: function is expected to take a single 2-tuple as argument, but it takes 0 arguments - --> $DIR/closure-arg-count.rs:32:53 + --> $DIR/closure-arg-count.rs:30:53 | -32 | let _it = vec![1, 2, 3].into_iter().enumerate().map(foo); +30 | let _it = vec![1, 2, 3].into_iter().enumerate().map(foo); | ^^^ expected function that takes a single 2-tuple as argument ... -41 | fn foo() {} +37 | fn foo() {} | -------- takes 0 arguments error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 3 distinct arguments - --> $DIR/closure-arg-count.rs:35:53 + --> $DIR/closure-arg-count.rs:33:53 | -34 | let bar = |i, x, y| i; +32 | let bar = |i, x, y| i; | --------- takes 3 distinct arguments -35 | let _it = vec![1, 2, 3].into_iter().enumerate().map(bar); +33 | let _it = vec![1, 2, 3].into_iter().enumerate().map(bar); | ^^^ expected closure that takes a single 2-tuple as argument error[E0593]: function is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments diff --git a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr index 77d3a33276737..dfd02fe23b686 100644 --- a/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-arg-type-mismatch.stderr @@ -31,7 +31,11 @@ error[E0631]: type mismatch in function arguments | expected signature of `for<'r> fn(*mut &'r u32) -> _` | found signature of `fn(*mut &'a u32) -> _` | - = note: required by `baz` +note: required by `baz` + --> $DIR/closure-arg-type-mismatch.rs:18:1 + | +18 | fn baz(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0271]: type mismatch resolving `for<'r> >::Output == ()` --> $DIR/closure-arg-type-mismatch.rs:20:5 @@ -39,7 +43,11 @@ error[E0271]: type mismatch resolving `for<'r> $DIR/closure-arg-type-mismatch.rs:18:1 + | +18 | fn baz(_: F) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 5 previous errors diff --git a/src/test/ui/mismatched_types/closure-mismatch.stderr b/src/test/ui/mismatched_types/closure-mismatch.stderr index 99767ba1afaef..01de7e0749500 100644 --- a/src/test/ui/mismatched_types/closure-mismatch.stderr +++ b/src/test/ui/mismatched_types/closure-mismatch.stderr @@ -5,7 +5,11 @@ error[E0271]: type mismatch resolving `for<'r> <[closure@$DIR/closure-mismatch.r | ^^^ expected bound lifetime parameter, found concrete lifetime | = note: required because of the requirements on the impl of `Foo` for `[closure@$DIR/closure-mismatch.rs:18:9: 18:15]` - = note: required by `baz` +note: required by `baz` + --> $DIR/closure-mismatch.rs:15:1 + | +15 | fn baz(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in closure arguments --> $DIR/closure-mismatch.rs:18:5 @@ -16,7 +20,11 @@ error[E0631]: type mismatch in closure arguments | expected signature of `for<'r> fn(&'r ()) -> _` | = note: required because of the requirements on the impl of `Foo` for `[closure@$DIR/closure-mismatch.rs:18:9: 18:15]` - = note: required by `baz` +note: required by `baz` + --> $DIR/closure-mismatch.rs:15:1 + | +15 | fn baz(_: T) {} + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/mismatched_types/fn-variance-1.stderr b/src/test/ui/mismatched_types/fn-variance-1.stderr index 2a27ffd106247..64c260c30ed49 100644 --- a/src/test/ui/mismatched_types/fn-variance-1.stderr +++ b/src/test/ui/mismatched_types/fn-variance-1.stderr @@ -7,7 +7,11 @@ error[E0631]: type mismatch in function arguments 21 | apply(&3, takes_mut); | ^^^^^ expected signature of `fn(&{integer}) -> _` | - = note: required by `apply` +note: required by `apply` + --> $DIR/fn-variance-1.rs:15:1 + | +15 | fn apply(t: T, f: F) where F: FnOnce(T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0631]: type mismatch in function arguments --> $DIR/fn-variance-1.rs:25:5 @@ -18,7 +22,11 @@ error[E0631]: type mismatch in function arguments 25 | apply(&mut 3, takes_imm); | ^^^^^ expected signature of `fn(&mut {integer}) -> _` | - = note: required by `apply` +note: required by `apply` + --> $DIR/fn-variance-1.rs:15:1 + | +15 | fn apply(t: T, f: F) where F: FnOnce(T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr index 8539c8818c025..9c9bbd19c7552 100644 --- a/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr +++ b/src/test/ui/mismatched_types/unboxed-closures-vtable-mismatch.stderr @@ -1,12 +1,17 @@ error[E0631]: type mismatch in closure arguments - --> $DIR/unboxed-closures-vtable-mismatch.rs:23:13 + --> $DIR/unboxed-closures-vtable-mismatch.rs:25:13 | -22 | let f = to_fn_mut(|x: usize, y: isize| -> isize { (x as isize) + y }); +23 | let f = to_fn_mut(|x: usize, y: isize| -> isize { (x as isize) + y }); | ----------------------------- found signature of `fn(usize, isize) -> _` -23 | let z = call_it(3, f); +24 | //~^ NOTE found signature of `fn(usize, isize) -> _` +25 | let z = call_it(3, f); | ^^^^^^^ expected signature of `fn(isize, isize) -> _` | - = note: required by `call_it` +note: required by `call_it` + --> $DIR/unboxed-closures-vtable-mismatch.rs:17:1 + | +17 | fn call_itisize>(y: isize, mut f: F) -> isize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.rs b/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.rs new file mode 100644 index 0000000000000..b48b08daa1963 --- /dev/null +++ b/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.rs @@ -0,0 +1,61 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test if the on_unimplemented message override works + +#![feature(on_unimplemented)] +#![feature(rustc_attrs)] + +struct Foo(T); +struct Bar(T); + +#[rustc_on_unimplemented( + on(_Self="[i32]", label="trait label if i32"), + label="trait label", + message="trait message", +)] +trait Index { + type Output: ?Sized; + fn index(&self, index: Idx) -> &Self::Output; +} + +#[rustc_on_unimplemented( + label="impl foo {Self} {Idx} {Index}", +)] +impl Index> for [i32] { + type Output = i32; + fn index(&self, _index: Foo) -> &i32 { + loop {} + } +} + +#[rustc_on_unimplemented = "on impl for Bar"] +impl Index> for [i32] { + type Output = i32; + fn index(&self, _index: Bar) -> &i32 { + loop {} + } +} + +#[rustc_error] +fn main() { + Index::index(&[] as &[i32], 2usize); + Index::index(&[] as &[i32], 2u32); + Index::index(&[] as &[u32], 2u32); + //~^ ERROR E0277 + //~| ERROR E0277 + Index::index(&[] as &[i32], Foo(2usize)); + Index::index(&[] as &[i32], Foo(2u32)); + //~^ ERROR E0277 + //~| ERROR E0277 + Index::index(&[] as &[i32], Bar(2u32)); + //~^ ERROR E0277 + //~| ERROR E0277 +} diff --git a/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr b/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr new file mode 100644 index 0000000000000..2ea9b67f26025 --- /dev/null +++ b/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr @@ -0,0 +1,44 @@ +error[E0277]: trait message `[i32]` + --> $DIR/multiple-impls-complex-filtering.rs:46:5 + | +46 | Index::index(&[] as &[i32], 2usize); + | ^^^^^^^^^^^^ u32 message + | + = help: the trait `Index<_>` is not implemented for `[i32]` +note: required by `Index::index` + --> $DIR/multiple-impls-complex-filtering.rs:25:5 + | +25 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: trait message `[i32]` + --> $DIR/multiple-impls-complex-filtering.rs:46:5 + | +46 | Index::index(&[] as &[i32], 2usize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u32 message + | + = help: the trait `Index<_>` is not implemented for `[i32]` + +error[E0277]: trait message `[i32]` + --> $DIR/multiple-impls-complex-filtering.rs:47:5 + | +47 | Index::index(&[] as &[i32], 2u32); + | ^^^^^^^^^^^^ u32 message + | + = help: the trait `Index<_>` is not implemented for `[i32]` +note: required by `Index::index` + --> $DIR/multiple-impls-complex-filtering.rs:25:5 + | +25 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: trait message `[i32]` + --> $DIR/multiple-impls-complex-filtering.rs:47:5 + | +47 | Index::index(&[] as &[i32], 2u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u32 message + | + = help: the trait `Index<_>` is not implemented for `[i32]` + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/on-unimplemented/multiple-impls.stderr b/src/test/ui/on-unimplemented/multiple-impls.stderr index 1f71be446efb5..cfac3981be284 100644 --- a/src/test/ui/on-unimplemented/multiple-impls.stderr +++ b/src/test/ui/on-unimplemented/multiple-impls.stderr @@ -5,7 +5,11 @@ error[E0277]: the trait bound `[i32]: Index` is not satisfied | ^^^^^^^^^^^^ trait message | = help: the trait `Index` is not implemented for `[i32]` - = note: required by `Index::index` +note: required by `Index::index` + --> $DIR/multiple-impls.rs:22:5 + | +22 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `[i32]: Index` is not satisfied --> $DIR/multiple-impls.rs:43:5 @@ -22,7 +26,11 @@ error[E0277]: the trait bound `[i32]: Index>` is not satisfied | ^^^^^^^^^^^^ on impl for Foo | = help: the trait `Index>` is not implemented for `[i32]` - = note: required by `Index::index` +note: required by `Index::index` + --> $DIR/multiple-impls.rs:22:5 + | +22 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:46:5 @@ -39,7 +47,11 @@ error[E0277]: the trait bound `[i32]: Index>` is not satisfied | ^^^^^^^^^^^^ on impl for Bar | = help: the trait `Index>` is not implemented for `[i32]` - = note: required by `Index::index` +note: required by `Index::index` + --> $DIR/multiple-impls.rs:22:5 + | +22 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `[i32]: Index>` is not satisfied --> $DIR/multiple-impls.rs:49:5 diff --git a/src/test/ui/on-unimplemented/on-impl.stderr b/src/test/ui/on-unimplemented/on-impl.stderr index c8c06bf44fd6f..ed2da68f08167 100644 --- a/src/test/ui/on-unimplemented/on-impl.stderr +++ b/src/test/ui/on-unimplemented/on-impl.stderr @@ -5,7 +5,11 @@ error[E0277]: the trait bound `[i32]: Index` is not satisfied | ^^^^^^^^^^^^^^^^^^^ a usize is required to index into a slice | = help: the trait `Index` is not implemented for `[i32]` - = note: required by `Index::index` +note: required by `Index::index` + --> $DIR/on-impl.rs:19:5 + | +19 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `[i32]: Index` is not satisfied --> $DIR/on-impl.rs:32:5 diff --git a/src/test/ui/on-unimplemented/on-trait.stderr b/src/test/ui/on-unimplemented/on-trait.stderr index cde56022faea2..028200a5558c8 100644 --- a/src/test/ui/on-unimplemented/on-trait.stderr +++ b/src/test/ui/on-unimplemented/on-trait.stderr @@ -5,7 +5,11 @@ error[E0277]: the trait bound `std::option::Option>: MyFromIte | ^^^^^^^ a collection of type `std::option::Option>` cannot be built from an iterator over elements of type `&u8` | = help: the trait `MyFromIterator<&u8>` is not implemented for `std::option::Option>` - = note: required by `collect` +note: required by `collect` + --> $DIR/on-trait.rs:31:1 + | +31 | fn collect, B: MyFromIterator>(it: I) -> B { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `std::string::String: Bar::Foo` is not satisfied --> $DIR/on-trait.rs:40:21 @@ -14,7 +18,11 @@ error[E0277]: the trait bound `std::string::String: Bar::Foo` is not | ^^^^^^ test error `std::string::String` with `u8` `_` `u32` in `Bar::Foo` | = help: the trait `Bar::Foo` is not implemented for `std::string::String` - = note: required by `foobar` +note: required by `foobar` + --> $DIR/on-trait.rs:21:1 + | +21 | fn foobar>() -> T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/span/issue-29595.stderr b/src/test/ui/span/issue-29595.stderr index 81ba0057d7173..9046b90f0e9c3 100644 --- a/src/test/ui/span/issue-29595.stderr +++ b/src/test/ui/span/issue-29595.stderr @@ -4,7 +4,11 @@ error[E0277]: the trait bound `u8: Tr` is not satisfied 17 | let a: u8 = Tr::C; //~ ERROR the trait bound `u8: Tr` is not satisfied | ^^^^^ the trait `Tr` is not implemented for `u8` | - = note: required by `Tr::C` +note: required by `Tr::C` + --> $DIR/issue-29595.rs:13:5 + | +13 | const C: Self; + | ^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/suggestions/try-operator-on-main.stderr b/src/test/ui/suggestions/try-operator-on-main.stderr index 36cdd558b0faf..e97823a3d5d5b 100644 --- a/src/test/ui/suggestions/try-operator-on-main.stderr +++ b/src/test/ui/suggestions/try-operator-on-main.stderr @@ -22,7 +22,11 @@ error[E0277]: the trait bound `(): std::ops::Try` is not satisfied 25 | try_trait_generic::<()>(); //~ ERROR the trait bound | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::ops::Try` is not implemented for `()` | - = note: required by `try_trait_generic` +note: required by `try_trait_generic` + --> $DIR/try-operator-on-main.rs:30:1 + | +30 | fn try_trait_generic() -> T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: the `?` operator can only be applied to values that implement `std::ops::Try` --> $DIR/try-operator-on-main.rs:32:5 diff --git a/src/test/ui/type-check/issue-40294.stderr b/src/test/ui/type-check/issue-40294.stderr index 2ca97aa3ef067..cf270afdeb173 100644 --- a/src/test/ui/type-check/issue-40294.stderr +++ b/src/test/ui/type-check/issue-40294.stderr @@ -10,7 +10,11 @@ error[E0283]: type annotations required: cannot resolve `&'a T: Foo` 21 | | } | |_^ | - = note: required by `Foo` +note: required by `Foo` + --> $DIR/issue-40294.rs:11:1 + | +11 | trait Foo: Sized { + | ^^^^^^^^^^^^^^^^ error: aborting due to previous error From 621e61bff92554d784aab13a507afcc0acdde53b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 20 Jan 2018 01:33:39 -0800 Subject: [PATCH 087/198] Add filter to detect local crates for rustc_on_unimplemented --- src/libcore/fmt/mod.rs | 17 ++- src/libcore/iter/iterator.rs | 9 +- src/librustc/traits/error_reporting.rs | 4 + src/librustc/traits/on_unimplemented.rs | 3 +- src/test/ui/impl-trait/equality.rs | 2 +- src/test/ui/lint/use_suggestion_json.stderr | 67 ++++++++++- src/test/ui/mismatched_types/binops.rs | 8 +- src/test/ui/mismatched_types/binops.stderr | 8 +- .../ui/on-unimplemented/auxiliary/no_debug.rs | 14 +++ .../multiple-impls-complex-filtering.stderr | 113 ++++++++++++++---- src/test/ui/on-unimplemented/no-debug.rs | 27 +++++ src/test/ui/on-unimplemented/no-debug.stderr | 38 ++++++ src/test/ui/span/multiline-span-simple.rs | 2 +- src/test/ui/span/multiline-span-simple.stderr | 2 +- src/test/ui/suggestions/iterate-str.rs | 19 +++ src/test/ui/suggestions/iterate-str.stderr | 13 ++ 16 files changed, 299 insertions(+), 47 deletions(-) create mode 100644 src/test/ui/on-unimplemented/auxiliary/no_debug.rs create mode 100644 src/test/ui/on-unimplemented/no-debug.rs create mode 100644 src/test/ui/on-unimplemented/no-debug.stderr create mode 100644 src/test/ui/suggestions/iterate-str.rs create mode 100644 src/test/ui/suggestions/iterate-str.stderr diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 6c8a1c3062b00..8ad5a9861a02f 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -530,9 +530,12 @@ impl<'a> Display for Arguments<'a> { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "`{Self}` cannot be formatted using `:?`; if it is \ - defined in your crate, add `#[derive(Debug)]` or \ - manually implement it"] +#[rustc_on_unimplemented( + on(crate_local, label="`{Self}` cannot be formatted using `:?`; \ + add `#[derive(Debug)]` or manually implement `{Debug}`"), + message="`{Self}` doesn't implement `{Debug}`", + label="`{Self}` cannot be formatted using `:?` because it doesn't implement `{Debug}`", +)] #[lang = "debug_trait"] pub trait Debug { /// Formats the value using the given formatter. @@ -593,9 +596,11 @@ pub trait Debug { /// /// println!("The origin is: {}", origin); /// ``` -#[rustc_on_unimplemented = "`{Self}` cannot be formatted with the default \ - formatter; try using `:?` instead if you are using \ - a format string"] +#[rustc_on_unimplemented( + message="`{Self}` doesn't implement `{Display}`", + label="`{Self}` cannot be formatted with the default formatter; \ + try using `:?` instead if you are using a format string", +)] #[stable(feature = "rust1", since = "1.0.0")] pub trait Display { /// Formats the value using the given formatter. diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index 35cd7441c66bc..296fb8733ba6c 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -28,8 +28,13 @@ fn _assert_is_object_safe(_: &Iterator) {} /// [module-level documentation]: index.html /// [impl]: index.html#implementing-iterator #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented = "`{Self}` is not an iterator; maybe try calling \ - `.iter()` or a similar method"] +#[rustc_on_unimplemented( + on( + _Self="&str", + label="`{Self}` is not an iterator; try calling `.chars()` or `.bytes()`" + ), + label="`{Self}` is not an iterator; maybe try calling `.iter()` or a similar method" +)] #[doc(spotlight)] pub trait Iterator { /// The type of the elements being iterated over. diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index f5ff122668558..be7ecbce8af73 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -384,6 +384,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { Some(ty_str.clone()))); } + if let Some(true) = self_ty.ty_to_def_id().map(|def_id| def_id.is_local()) { + flags.push(("crate_local".to_string(), None)); + } + if let Ok(Some(command)) = OnUnimplementedDirective::of_item( self.tcx, trait_ref.def_id, def_id ) { diff --git a/src/librustc/traits/on_unimplemented.rs b/src/librustc/traits/on_unimplemented.rs index a493b7f0bb603..8c2c1cfa45472 100644 --- a/src/librustc/traits/on_unimplemented.rs +++ b/src/librustc/traits/on_unimplemented.rs @@ -185,8 +185,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { let mut message = None; let mut label = None; let mut note = None; - info!("evaluate({:?}, trait_ref={:?}, options={:?})", - self, trait_ref, options); + info!("evaluate({:?}, trait_ref={:?}, options={:?})", self, trait_ref, options); for command in self.subcommands.iter().chain(Some(self)).rev() { if let Some(ref condition) = command.condition { diff --git a/src/test/ui/impl-trait/equality.rs b/src/test/ui/impl-trait/equality.rs index 36df4f0eb4d46..9d9d4cef3119a 100644 --- a/src/test/ui/impl-trait/equality.rs +++ b/src/test/ui/impl-trait/equality.rs @@ -32,7 +32,7 @@ fn sum_to(n: u32) -> impl Foo { 0 } else { n + sum_to(n - 1) - //~^ ERROR the trait bound `u32: std::ops::Add` is not satisfied + //~^ ERROR cannot add `impl Foo` to `u32` } } diff --git a/src/test/ui/lint/use_suggestion_json.stderr b/src/test/ui/lint/use_suggestion_json.stderr index abbf3da513a6f..86c2ad4c0e7a4 100644 --- a/src/test/ui/lint/use_suggestion_json.stderr +++ b/src/test/ui/lint/use_suggestion_json.stderr @@ -2,7 +2,72 @@ "message": "cannot find type `Iter` in this scope", "code": { "code": "E0412", - "explanation": null + "explanation": " +The type name used is not in scope. + +Erroneous code examples: + +```compile_fail,E0412 +impl Something {} // error: type name `Something` is not in scope + +// or: + +trait Foo { + fn bar(N); // error: type name `N` is not in scope +} + +// or: + +fn foo(x: T) {} // type name `T` is not in scope +``` + +To fix this error, please verify you didn't misspell the type name, you did +declare it or imported it into the scope. Examples: + +``` +struct Something; + +impl Something {} // ok! + +// or: + +trait Foo { + type N; + + fn bar(_: Self::N); // ok! +} + +// or: + +fn foo(x: T) {} // ok! +``` + +Another case that causes this error is when a type is imported into a parent +module. To fix this, you can follow the suggestion and use File directly or +`use super::File;` which will import the types from the parent namespace. An +example that causes this error is below: + +```compile_fail,E0412 +use std::fs::File; + +mod foo { + fn some_function(f: File) {} +} +``` + +``` +use std::fs::File; + +mod foo { + // either + use super::File; + // or + // use std::fs::File; + fn foo(f: File) {} +} +# fn main() {} // don't insert it for us; that'll break imports +``` +" }, "level": "error", "spans": [ diff --git a/src/test/ui/mismatched_types/binops.rs b/src/test/ui/mismatched_types/binops.rs index e45616cd67a81..5144b59955cc9 100644 --- a/src/test/ui/mismatched_types/binops.rs +++ b/src/test/ui/mismatched_types/binops.rs @@ -9,10 +9,10 @@ // except according to those terms. fn main() { - 1 + Some(1); //~ ERROR is not satisfied - 2 as usize - Some(1); //~ ERROR is not satisfied - 3 * (); //~ ERROR is not satisfied - 4 / ""; //~ ERROR is not satisfied + 1 + Some(1); //~ ERROR cannot add `std::option::Option<{integer}>` to `{integer}` + 2 as usize - Some(1); //~ ERROR cannot substract `std::option::Option<{integer}>` from `usize` + 3 * (); //~ ERROR cannot multiply `()` to `{integer}` + 4 / ""; //~ ERROR cannot divide `{integer}` by `&str` 5 < String::new(); //~ ERROR is not satisfied 6 == Ok(1); //~ ERROR is not satisfied } diff --git a/src/test/ui/mismatched_types/binops.stderr b/src/test/ui/mismatched_types/binops.stderr index 57e66794a58a9..1b7fba050636f 100644 --- a/src/test/ui/mismatched_types/binops.stderr +++ b/src/test/ui/mismatched_types/binops.stderr @@ -1,7 +1,7 @@ error[E0277]: cannot add `std::option::Option<{integer}>` to `{integer}` --> $DIR/binops.rs:12:7 | -12 | 1 + Some(1); //~ ERROR is not satisfied +12 | 1 + Some(1); //~ ERROR cannot add `std::option::Option<{integer}>` to `{integer}` | ^ no implementation for `{integer} + std::option::Option<{integer}>` | = help: the trait `std::ops::Add>` is not implemented for `{integer}` @@ -9,7 +9,7 @@ error[E0277]: cannot add `std::option::Option<{integer}>` to `{integer}` error[E0277]: cannot substract `std::option::Option<{integer}>` from `usize` --> $DIR/binops.rs:13:16 | -13 | 2 as usize - Some(1); //~ ERROR is not satisfied +13 | 2 as usize - Some(1); //~ ERROR cannot substract `std::option::Option<{integer}>` from `usize` | ^ no implementation for `usize - std::option::Option<{integer}>` | = help: the trait `std::ops::Sub>` is not implemented for `usize` @@ -17,7 +17,7 @@ error[E0277]: cannot substract `std::option::Option<{integer}>` from `usize` error[E0277]: cannot multiply `()` to `{integer}` --> $DIR/binops.rs:14:7 | -14 | 3 * (); //~ ERROR is not satisfied +14 | 3 * (); //~ ERROR cannot multiply `()` to `{integer}` | ^ no implementation for `{integer} * ()` | = help: the trait `std::ops::Mul<()>` is not implemented for `{integer}` @@ -25,7 +25,7 @@ error[E0277]: cannot multiply `()` to `{integer}` error[E0277]: cannot divide `{integer}` by `&str` --> $DIR/binops.rs:15:7 | -15 | 4 / ""; //~ ERROR is not satisfied +15 | 4 / ""; //~ ERROR cannot divide `{integer}` by `&str` | ^ no implementation for `{integer} / &str` | = help: the trait `std::ops::Div<&str>` is not implemented for `{integer}` diff --git a/src/test/ui/on-unimplemented/auxiliary/no_debug.rs b/src/test/ui/on-unimplemented/auxiliary/no_debug.rs new file mode 100644 index 0000000000000..0f833c6263722 --- /dev/null +++ b/src/test/ui/on-unimplemented/auxiliary/no_debug.rs @@ -0,0 +1,14 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// ignore-tidy-linelength + +#![crate_type = "lib"] + +pub struct Bar; diff --git a/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr b/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr index 2ea9b67f26025..c4bac12eebdbe 100644 --- a/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr +++ b/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr @@ -1,44 +1,107 @@ -error[E0277]: trait message `[i32]` - --> $DIR/multiple-impls-complex-filtering.rs:46:5 +error[E0277]: trait message + --> $DIR/multiple-impls-complex-filtering.rs:49:5 | -46 | Index::index(&[] as &[i32], 2usize); - | ^^^^^^^^^^^^ u32 message +49 | Index::index(&[] as &[i32], 2usize); + | ^^^^^^^^^^^^ trait label if i32 | - = help: the trait `Index<_>` is not implemented for `[i32]` + = help: the trait `Index` is not implemented for `[i32]` note: required by `Index::index` - --> $DIR/multiple-impls-complex-filtering.rs:25:5 + --> $DIR/multiple-impls-complex-filtering.rs:26:5 | -25 | fn index(&self, index: Idx) -> &Self::Output; +26 | fn index(&self, index: Idx) -> &Self::Output; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: trait message `[i32]` - --> $DIR/multiple-impls-complex-filtering.rs:46:5 +error[E0277]: trait message + --> $DIR/multiple-impls-complex-filtering.rs:49:5 | -46 | Index::index(&[] as &[i32], 2usize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u32 message +49 | Index::index(&[] as &[i32], 2usize); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait label if i32 | - = help: the trait `Index<_>` is not implemented for `[i32]` + = help: the trait `Index` is not implemented for `[i32]` -error[E0277]: trait message `[i32]` - --> $DIR/multiple-impls-complex-filtering.rs:47:5 +error[E0277]: trait message + --> $DIR/multiple-impls-complex-filtering.rs:50:5 | -47 | Index::index(&[] as &[i32], 2u32); - | ^^^^^^^^^^^^ u32 message +50 | Index::index(&[] as &[i32], 2u32); + | ^^^^^^^^^^^^ trait label if i32 | - = help: the trait `Index<_>` is not implemented for `[i32]` + = help: the trait `Index` is not implemented for `[i32]` note: required by `Index::index` - --> $DIR/multiple-impls-complex-filtering.rs:25:5 + --> $DIR/multiple-impls-complex-filtering.rs:26:5 | -25 | fn index(&self, index: Idx) -> &Self::Output; +26 | fn index(&self, index: Idx) -> &Self::Output; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: trait message `[i32]` - --> $DIR/multiple-impls-complex-filtering.rs:47:5 +error[E0277]: trait message + --> $DIR/multiple-impls-complex-filtering.rs:50:5 | -47 | Index::index(&[] as &[i32], 2u32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ u32 message +50 | Index::index(&[] as &[i32], 2u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait label if i32 | - = help: the trait `Index<_>` is not implemented for `[i32]` + = help: the trait `Index` is not implemented for `[i32]` -error: aborting due to 4 previous errors +error[E0277]: trait message + --> $DIR/multiple-impls-complex-filtering.rs:51:5 + | +51 | Index::index(&[] as &[u32], 2u32); + | ^^^^^^^^^^^^ trait label + | + = help: the trait `Index<_>` is not implemented for `[u32]` +note: required by `Index::index` + --> $DIR/multiple-impls-complex-filtering.rs:26:5 + | +26 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: trait message + --> $DIR/multiple-impls-complex-filtering.rs:51:5 + | +51 | Index::index(&[] as &[u32], 2u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait label + | + = help: the trait `Index<_>` is not implemented for `[u32]` + +error[E0277]: the trait bound `[i32]: Index>` is not satisfied + --> $DIR/multiple-impls-complex-filtering.rs:55:5 + | +55 | Index::index(&[] as &[i32], Foo(2u32)); + | ^^^^^^^^^^^^ impl foo [i32] Foo Index + | + = help: the trait `Index>` is not implemented for `[i32]` +note: required by `Index::index` + --> $DIR/multiple-impls-complex-filtering.rs:26:5 + | +26 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `[i32]: Index>` is not satisfied + --> $DIR/multiple-impls-complex-filtering.rs:55:5 + | +55 | Index::index(&[] as &[i32], Foo(2u32)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl foo [i32] Foo Index + | + = help: the trait `Index>` is not implemented for `[i32]` + +error[E0277]: the trait bound `[i32]: Index>` is not satisfied + --> $DIR/multiple-impls-complex-filtering.rs:58:5 + | +58 | Index::index(&[] as &[i32], Bar(2u32)); + | ^^^^^^^^^^^^ on impl for Bar + | + = help: the trait `Index>` is not implemented for `[i32]` +note: required by `Index::index` + --> $DIR/multiple-impls-complex-filtering.rs:26:5 + | +26 | fn index(&self, index: Idx) -> &Self::Output; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0277]: the trait bound `[i32]: Index>` is not satisfied + --> $DIR/multiple-impls-complex-filtering.rs:58:5 + | +58 | Index::index(&[] as &[i32], Bar(2u32)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ on impl for Bar + | + = help: the trait `Index>` is not implemented for `[i32]` + +error: aborting due to 10 previous errors diff --git a/src/test/ui/on-unimplemented/no-debug.rs b/src/test/ui/on-unimplemented/no-debug.rs new file mode 100644 index 0000000000000..fff6122c6b34b --- /dev/null +++ b/src/test/ui/on-unimplemented/no-debug.rs @@ -0,0 +1,27 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:no_debug.rs + +extern crate no_debug; + +use no_debug::Bar; + +struct Foo; + +fn main() { + println!("{:?} {:?}", Foo, Bar); + println!("{} {}", Foo, Bar); +} +//~^^^ ERROR `Foo` doesn't implement `std::fmt::Debug` +//~| ERROR `no_debug::Bar` doesn't implement `std::fmt::Debug` +//~^^^^ ERROR `Foo` doesn't implement `std::fmt::Display` +//~| ERROR `no_debug::Bar` doesn't implement `std::fmt::Display` + diff --git a/src/test/ui/on-unimplemented/no-debug.stderr b/src/test/ui/on-unimplemented/no-debug.stderr new file mode 100644 index 0000000000000..af5b1e91211fb --- /dev/null +++ b/src/test/ui/on-unimplemented/no-debug.stderr @@ -0,0 +1,38 @@ +error[E0277]: `Foo` doesn't implement `std::fmt::Debug` + --> $DIR/no-debug.rs:20:27 + | +20 | println!("{:?} {:?}", Foo, Bar); + | ^^^ `Foo` cannot be formatted using `:?`; add `#[derive(Debug)]` or manually implement `std::fmt::Debug` + | + = help: the trait `std::fmt::Debug` is not implemented for `Foo` + = note: required by `std::fmt::Debug::fmt` + +error[E0277]: `no_debug::Bar` doesn't implement `std::fmt::Debug` + --> $DIR/no-debug.rs:20:32 + | +20 | println!("{:?} {:?}", Foo, Bar); + | ^^^ `no_debug::Bar` cannot be formatted using `:?` because it doesn't implement `std::fmt::Debug` + | + = help: the trait `std::fmt::Debug` is not implemented for `no_debug::Bar` + = note: required by `std::fmt::Debug::fmt` + +error[E0277]: `Foo` doesn't implement `std::fmt::Display` + --> $DIR/no-debug.rs:21:23 + | +21 | println!("{} {}", Foo, Bar); + | ^^^ `Foo` cannot be formatted with the default formatter; try using `:?` instead if you are using a format string + | + = help: the trait `std::fmt::Display` is not implemented for `Foo` + = note: required by `std::fmt::Display::fmt` + +error[E0277]: `no_debug::Bar` doesn't implement `std::fmt::Display` + --> $DIR/no-debug.rs:21:28 + | +21 | println!("{} {}", Foo, Bar); + | ^^^ `no_debug::Bar` cannot be formatted with the default formatter; try using `:?` instead if you are using a format string + | + = help: the trait `std::fmt::Display` is not implemented for `no_debug::Bar` + = note: required by `std::fmt::Display::fmt` + +error: aborting due to 4 previous errors + diff --git a/src/test/ui/span/multiline-span-simple.rs b/src/test/ui/span/multiline-span-simple.rs index f8e4cbcbf191f..dd09534480e10 100644 --- a/src/test/ui/span/multiline-span-simple.rs +++ b/src/test/ui/span/multiline-span-simple.rs @@ -20,7 +20,7 @@ fn main() { let x = 1; let y = 2; let z = 3; - foo(1 as u32 + //~ ERROR not satisfied + foo(1 as u32 + //~ ERROR cannot add `()` to `u32` bar(x, diff --git a/src/test/ui/span/multiline-span-simple.stderr b/src/test/ui/span/multiline-span-simple.stderr index b6182825fc278..a18dfeb31d9ef 100644 --- a/src/test/ui/span/multiline-span-simple.stderr +++ b/src/test/ui/span/multiline-span-simple.stderr @@ -1,7 +1,7 @@ error[E0277]: cannot add `()` to `u32` --> $DIR/multiline-span-simple.rs:23:18 | -23 | foo(1 as u32 + //~ ERROR not satisfied +23 | foo(1 as u32 + //~ ERROR cannot add `()` to `u32` | ^ no implementation for `u32 + ()` | = help: the trait `std::ops::Add<()>` is not implemented for `u32` diff --git a/src/test/ui/suggestions/iterate-str.rs b/src/test/ui/suggestions/iterate-str.rs new file mode 100644 index 0000000000000..1022491b84a36 --- /dev/null +++ b/src/test/ui/suggestions/iterate-str.rs @@ -0,0 +1,19 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +fn main() { + for c in "foobarbaz" { + println!("{}", c); + } + //~^^^ ERROR the trait bound `&str: std::iter::Iterator` is not satisfied + //~| NOTE `&str` is not an iterator; try calling `.chars()` or `.bytes()` + //~| HELP the trait `std::iter::Iterator` is not implemented for `&str` + //~| NOTE required by `std::iter::IntoIterator::into_iter` +} diff --git a/src/test/ui/suggestions/iterate-str.stderr b/src/test/ui/suggestions/iterate-str.stderr new file mode 100644 index 0000000000000..59da6d70c0236 --- /dev/null +++ b/src/test/ui/suggestions/iterate-str.stderr @@ -0,0 +1,13 @@ +error[E0277]: the trait bound `&str: std::iter::Iterator` is not satisfied + --> $DIR/iterate-str.rs:12:5 + | +12 | / for c in "foobarbaz" { +13 | | println!("{}", c); +14 | | } + | |_____^ `&str` is not an iterator; try calling `.chars()` or `.bytes()` + | + = help: the trait `std::iter::Iterator` is not implemented for `&str` + = note: required by `std::iter::IntoIterator::into_iter` + +error: aborting due to previous error + From 2dee07b12a2dd08a281a84146dc7085299389add Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sat, 20 Jan 2018 02:36:39 -0800 Subject: [PATCH 088/198] Remove cast suggestions --- src/libcore/ops/arith.rs | 72 ------------ .../multiple-impls-complex-filtering.rs | 61 ---------- .../multiple-impls-complex-filtering.stderr | 107 ------------------ 3 files changed, 240 deletions(-) delete mode 100644 src/test/ui/on-unimplemented/multiple-impls-complex-filtering.rs delete mode 100644 src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs index 47617b22dd34d..d0d0c09869e9d 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs @@ -76,78 +76,6 @@ #[lang = "add"] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_on_unimplemented( - on( - any( - all(_Self="i128", RHS="i64"), - all(_Self="i128", RHS="i32"), - all(_Self="i128", RHS="i16"), - all(_Self="i128", RHS="i8"), - all(_Self="i64", RHS="i32"), - all(_Self="i64", RHS="i16"), - all(_Self="i64", RHS="i8"), - all(_Self="i32", RHS="i16"), - all(_Self="i32", RHS="i8"), - all(_Self="i16", RHS="i8"), - all(_Self="u128", RHS="u64"), - all(_Self="u128", RHS="u32"), - all(_Self="u128", RHS="u16"), - all(_Self="u128", RHS="u8"), - all(_Self="u64", RHS="u32"), - all(_Self="u64", RHS="u16"), - all(_Self="u64", RHS="u8"), - all(_Self="u32", RHS="u16"), - all(_Self="u32", RHS="u8"), - all(_Self="u16", RHS="u8"), - all(_Self="f64", RHS="i32"), - all(_Self="f64", RHS="i16"), - all(_Self="f64", RHS="i8"), - all(_Self="f64", RHS="u32"), - all(_Self="f64", RHS="u16"), - all(_Self="f64", RHS="u8"), - all(_Self="f32", RHS="i16"), - all(_Self="f32", RHS="i8"), - all(_Self="f32", RHS="u16"), - all(_Self="f32", RHS="u8"), - ), - label="no implementation for `{Self} + {RHS}`, but you can safely cast \ - `{RHS}` into `{Self}` using `as {Self}`", - ), - on( - any( - all(RHS="i128", _Self="i64"), - all(RHS="i128", _Self="i32"), - all(RHS="i128", _Self="i16"), - all(RHS="i128", _Self="i8"), - all(RHS="i64", _Self="i32"), - all(RHS="i64", _Self="i16"), - all(RHS="i64", _Self="i8"), - all(RHS="i32", _Self="i16"), - all(RHS="i32", _Self="i8"), - all(RHS="i16", _Self="i8"), - all(RHS="u128", _Self="u64"), - all(RHS="u128", _Self="u32"), - all(RHS="u128", _Self="u16"), - all(RHS="u128", _Self="u8"), - all(RHS="u64", _Self="u32"), - all(RHS="u64", _Self="u16"), - all(RHS="u64", _Self="u8"), - all(RHS="u32", _Self="u16"), - all(RHS="u32", _Self="u8"), - all(RHS="u16", _Self="u8"), - all(RHS="f64", _Self="i32"), - all(RHS="f64", _Self="i16"), - all(RHS="f64", _Self="i8"), - all(RHS="f64", _Self="u32"), - all(RHS="f64", _Self="u16"), - all(RHS="f64", _Self="u8"), - all(RHS="f32", _Self="i16"), - all(RHS="f32", _Self="i8"), - all(RHS="f32", _Self="u16"), - all(RHS="f32", _Self="u8"), - ), - label="no implementation for `{Self} + {RHS}`, but you can safely cast \ - `{Self}` into `{RHS}` using `as {RHS}`", - ), on( all(_Self="{integer}", RHS="{float}"), message="cannot add a float to an integer", diff --git a/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.rs b/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.rs deleted file mode 100644 index b48b08daa1963..0000000000000 --- a/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.rs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test if the on_unimplemented message override works - -#![feature(on_unimplemented)] -#![feature(rustc_attrs)] - -struct Foo(T); -struct Bar(T); - -#[rustc_on_unimplemented( - on(_Self="[i32]", label="trait label if i32"), - label="trait label", - message="trait message", -)] -trait Index { - type Output: ?Sized; - fn index(&self, index: Idx) -> &Self::Output; -} - -#[rustc_on_unimplemented( - label="impl foo {Self} {Idx} {Index}", -)] -impl Index> for [i32] { - type Output = i32; - fn index(&self, _index: Foo) -> &i32 { - loop {} - } -} - -#[rustc_on_unimplemented = "on impl for Bar"] -impl Index> for [i32] { - type Output = i32; - fn index(&self, _index: Bar) -> &i32 { - loop {} - } -} - -#[rustc_error] -fn main() { - Index::index(&[] as &[i32], 2usize); - Index::index(&[] as &[i32], 2u32); - Index::index(&[] as &[u32], 2u32); - //~^ ERROR E0277 - //~| ERROR E0277 - Index::index(&[] as &[i32], Foo(2usize)); - Index::index(&[] as &[i32], Foo(2u32)); - //~^ ERROR E0277 - //~| ERROR E0277 - Index::index(&[] as &[i32], Bar(2u32)); - //~^ ERROR E0277 - //~| ERROR E0277 -} diff --git a/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr b/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr deleted file mode 100644 index c4bac12eebdbe..0000000000000 --- a/src/test/ui/on-unimplemented/multiple-impls-complex-filtering.stderr +++ /dev/null @@ -1,107 +0,0 @@ -error[E0277]: trait message - --> $DIR/multiple-impls-complex-filtering.rs:49:5 - | -49 | Index::index(&[] as &[i32], 2usize); - | ^^^^^^^^^^^^ trait label if i32 - | - = help: the trait `Index` is not implemented for `[i32]` -note: required by `Index::index` - --> $DIR/multiple-impls-complex-filtering.rs:26:5 - | -26 | fn index(&self, index: Idx) -> &Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: trait message - --> $DIR/multiple-impls-complex-filtering.rs:49:5 - | -49 | Index::index(&[] as &[i32], 2usize); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait label if i32 - | - = help: the trait `Index` is not implemented for `[i32]` - -error[E0277]: trait message - --> $DIR/multiple-impls-complex-filtering.rs:50:5 - | -50 | Index::index(&[] as &[i32], 2u32); - | ^^^^^^^^^^^^ trait label if i32 - | - = help: the trait `Index` is not implemented for `[i32]` -note: required by `Index::index` - --> $DIR/multiple-impls-complex-filtering.rs:26:5 - | -26 | fn index(&self, index: Idx) -> &Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: trait message - --> $DIR/multiple-impls-complex-filtering.rs:50:5 - | -50 | Index::index(&[] as &[i32], 2u32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait label if i32 - | - = help: the trait `Index` is not implemented for `[i32]` - -error[E0277]: trait message - --> $DIR/multiple-impls-complex-filtering.rs:51:5 - | -51 | Index::index(&[] as &[u32], 2u32); - | ^^^^^^^^^^^^ trait label - | - = help: the trait `Index<_>` is not implemented for `[u32]` -note: required by `Index::index` - --> $DIR/multiple-impls-complex-filtering.rs:26:5 - | -26 | fn index(&self, index: Idx) -> &Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: trait message - --> $DIR/multiple-impls-complex-filtering.rs:51:5 - | -51 | Index::index(&[] as &[u32], 2u32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ trait label - | - = help: the trait `Index<_>` is not implemented for `[u32]` - -error[E0277]: the trait bound `[i32]: Index>` is not satisfied - --> $DIR/multiple-impls-complex-filtering.rs:55:5 - | -55 | Index::index(&[] as &[i32], Foo(2u32)); - | ^^^^^^^^^^^^ impl foo [i32] Foo Index - | - = help: the trait `Index>` is not implemented for `[i32]` -note: required by `Index::index` - --> $DIR/multiple-impls-complex-filtering.rs:26:5 - | -26 | fn index(&self, index: Idx) -> &Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: the trait bound `[i32]: Index>` is not satisfied - --> $DIR/multiple-impls-complex-filtering.rs:55:5 - | -55 | Index::index(&[] as &[i32], Foo(2u32)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl foo [i32] Foo Index - | - = help: the trait `Index>` is not implemented for `[i32]` - -error[E0277]: the trait bound `[i32]: Index>` is not satisfied - --> $DIR/multiple-impls-complex-filtering.rs:58:5 - | -58 | Index::index(&[] as &[i32], Bar(2u32)); - | ^^^^^^^^^^^^ on impl for Bar - | - = help: the trait `Index>` is not implemented for `[i32]` -note: required by `Index::index` - --> $DIR/multiple-impls-complex-filtering.rs:26:5 - | -26 | fn index(&self, index: Idx) -> &Self::Output; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0277]: the trait bound `[i32]: Index>` is not satisfied - --> $DIR/multiple-impls-complex-filtering.rs:58:5 - | -58 | Index::index(&[] as &[i32], Bar(2u32)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ on impl for Bar - | - = help: the trait `Index>` is not implemented for `[i32]` - -error: aborting due to 10 previous errors - From 27a23db66032be9be96e697fdda50e73b0b90cc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 22 Jan 2018 19:03:51 -0800 Subject: [PATCH 089/198] Rework `parse_ident_attr` --- src/libsyntax/parse/parser.rs | 51 ++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9e8c4d3de2220..5b55f0f232877 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -761,29 +761,37 @@ impl<'a> Parser<'a> { }) } + fn expected_ident_found(&self) -> DiagnosticBuilder<'a> { + let mut err = self.struct_span_err(self.span, + &format!("expected identifier, found {}", + self.this_token_descr())); + if let Some(token_descr) = self.token_descr() { + err.span_label(self.span, format!("expected identifier, found {}", token_descr)); + } else { + err.span_label(self.span, "expected identifier"); + } + err + } + pub fn parse_ident(&mut self) -> PResult<'a, ast::Ident> { - self.parse_ident_common(true, false) + self.parse_ident_common(true) } pub fn parse_ident_attr(&mut self) -> PResult<'a, ast::Ident> { - self.parse_ident_common(true, true) + match self.token { + token::Ident(i) if i.name == keywords::SelfType.name() { + self.bump(); + Ok(i) + } + _ => self.parse_ident(), + } } - fn parse_ident_common(&mut self, recover: bool, accept_self: bool) -> PResult<'a, ast::Ident> { + fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, ast::Ident> { match self.token { token::Ident(i) => { - if self.token.is_reserved_ident() - && !(accept_self && i.name == keywords::SelfType.name()) - { - let mut err = self.struct_span_err(self.span, - &format!("expected identifier, found {}", - self.this_token_descr())); - if let Some(token_descr) = self.token_descr() { - err.span_label(self.span, format!("expected identifier, found {}", - token_descr)); - } else { - err.span_label(self.span, "expected identifier"); - } + if self.token.is_reserved_ident() { + let mut err = self.expected_ident_found(); if recover { err.emit(); } else { @@ -797,14 +805,7 @@ impl<'a> Parser<'a> { Err(if self.prev_token_kind == PrevTokenKind::DocComment { self.span_fatal_err(self.prev_span, Error::UselessDocComment) } else { - let mut err = self.fatal(&format!("expected identifier, found `{}`", - self.this_token_to_string())); - if let Some(token_descr) = self.token_descr() { - err.span_label(self.span, format!("expected identifier, found {}", - token_descr)); - } else { - err.span_label(self.span, "expected identifier"); - } + let mut err = self.expected_ident_found(); if self.token == token::Underscore { err.note("`_` is a wildcard pattern, not an identifier"); } @@ -2117,7 +2118,7 @@ impl<'a> Parser<'a> { self.bump(); Ok(Ident::with_empty_ctxt(name)) } else { - self.parse_ident_common(false, false) + self.parse_ident_common(false) } } @@ -2134,7 +2135,7 @@ impl<'a> Parser<'a> { hi = self.prev_span; (fieldname, self.parse_expr()?, false) } else { - let fieldname = self.parse_ident_common(false, false)?; + let fieldname = self.parse_ident_common(false)?; hi = self.prev_span; // Mimic `x: x` for the `x` field shorthand. From f7c61783e4cbc169955c7e633ecf629ed901a54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Mon, 22 Jan 2018 19:13:06 -0800 Subject: [PATCH 090/198] Fix tests --- src/libsyntax/parse/parser.rs | 2 +- src/test/compile-fail/const-eval-overflow-4b.rs | 2 +- src/test/compile-fail/ufcs-qpath-self-mismatch.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 5b55f0f232877..380170207301a 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -779,7 +779,7 @@ impl<'a> Parser<'a> { pub fn parse_ident_attr(&mut self) -> PResult<'a, ast::Ident> { match self.token { - token::Ident(i) if i.name == keywords::SelfType.name() { + token::Ident(i) if i.name == keywords::SelfType.name() => { self.bump(); Ok(i) } diff --git a/src/test/compile-fail/const-eval-overflow-4b.rs b/src/test/compile-fail/const-eval-overflow-4b.rs index 02072e9a1a1f6..6028df1883967 100644 --- a/src/test/compile-fail/const-eval-overflow-4b.rs +++ b/src/test/compile-fail/const-eval-overflow-4b.rs @@ -22,7 +22,7 @@ const A_I8_T : [u32; (i8::MAX as i8 + 1u8) as usize] //~^ ERROR mismatched types //~| expected i8, found u8 - //~| ERROR the trait bound `i8: std::ops::Add` is not satisfied + //~| ERROR cannot add `u8` to `i8` = [0; (i8::MAX as usize) + 1]; diff --git a/src/test/compile-fail/ufcs-qpath-self-mismatch.rs b/src/test/compile-fail/ufcs-qpath-self-mismatch.rs index 94a98b1582af1..caf510071bd68 100644 --- a/src/test/compile-fail/ufcs-qpath-self-mismatch.rs +++ b/src/test/compile-fail/ufcs-qpath-self-mismatch.rs @@ -12,7 +12,7 @@ use std::ops::Add; fn main() { >::add(1, 2); - //~^ ERROR `i32: std::ops::Add` is not satisfied + //~^ ERROR cannot add `u32` to `i32` >::add(1u32, 2); //~^ ERROR mismatched types >::add(1, 2u32); From 378e73e6db0b4d47586f4e3ec975e43ef530ac99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 1 Feb 2018 12:12:55 -0800 Subject: [PATCH 091/198] Remove support for `Self` in attributes --- src/librustc/traits/error_reporting.rs | 2 -- src/libsyntax/parse/parser.rs | 8 +------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index be7ecbce8af73..d5ac63431445e 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -372,9 +372,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { let generics = self.tcx.generics_of(def_id); let self_ty = trait_ref.self_ty(); let self_ty_str = self_ty.to_string(); - // FIXME: remove once `Self` is accepted by the compiler flags.push(("_Self".to_string(), Some(self_ty_str.clone()))); - flags.push(("Self".to_string(), Some(self_ty_str.clone()))); for param in generics.types.iter() { let name = param.name.as_str().to_string(); diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 380170207301a..9d573ea0e7c03 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -778,13 +778,7 @@ impl<'a> Parser<'a> { } pub fn parse_ident_attr(&mut self) -> PResult<'a, ast::Ident> { - match self.token { - token::Ident(i) if i.name == keywords::SelfType.name() => { - self.bump(); - Ok(i) - } - _ => self.parse_ident(), - } + self.parse_ident() } fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, ast::Ident> { From fd3f2312a75bcc4c8121ad324a012c3b8befb61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Thu, 1 Feb 2018 14:16:53 -0800 Subject: [PATCH 092/198] Fix test after rebase --- src/libsyntax/parse/attr.rs | 2 +- src/libsyntax/parse/parser.rs | 4 -- .../mismatched_types/closure-arg-count.stderr | 50 +++++++++++-------- src/test/ui/suggestions/for-c-in-str.stderr | 2 +- src/test/ui/suggestions/iterate-str.rs | 19 ------- src/test/ui/suggestions/iterate-str.stderr | 13 ----- 6 files changed, 31 insertions(+), 59 deletions(-) delete mode 100644 src/test/ui/suggestions/iterate-str.rs delete mode 100644 src/test/ui/suggestions/iterate-str.stderr diff --git a/src/libsyntax/parse/attr.rs b/src/libsyntax/parse/attr.rs index b01f479895b10..053746b579dcb 100644 --- a/src/libsyntax/parse/attr.rs +++ b/src/libsyntax/parse/attr.rs @@ -235,7 +235,7 @@ impl<'a> Parser<'a> { } let lo = self.span; - let ident = self.parse_ident_attr()?; + let ident = self.parse_ident()?; let node = self.parse_meta_item_kind()?; Ok(ast::MetaItem { name: ident.name, node: node, span: lo.to(self.prev_span) }) } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9d573ea0e7c03..4c61ab6bd7810 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -777,10 +777,6 @@ impl<'a> Parser<'a> { self.parse_ident_common(true) } - pub fn parse_ident_attr(&mut self) -> PResult<'a, ast::Ident> { - self.parse_ident() - } - fn parse_ident_common(&mut self, recover: bool) -> PResult<'a, ast::Ident> { match self.token { token::Ident(i) => { diff --git a/src/test/ui/mismatched_types/closure-arg-count.stderr b/src/test/ui/mismatched_types/closure-arg-count.stderr index 4e1523c79d2d4..be00ee4d74e7e 100644 --- a/src/test/ui/mismatched_types/closure-arg-count.stderr +++ b/src/test/ui/mismatched_types/closure-arg-count.stderr @@ -14,7 +14,7 @@ error[E0593]: closure is expected to take 2 arguments, but it takes 1 argument | | | expected closure that takes 2 arguments -error[E0593]: closure is expected to take 2 arguments, but it takes 1 argument +error[E0593]: closure is expected to take 2 distinct arguments, but it takes a single 2-tuple as argument --> $DIR/closure-arg-count.rs:19:15 | 19 | [1, 2, 3].sort_by(|(tuple, tuple2)| panic!()); @@ -39,9 +39,9 @@ help: change the closure to take multiple arguments instead of a single tuple | ^^^^^^^^^^^^^^^ error[E0593]: closure is expected to take 1 argument, but it takes 0 arguments - --> $DIR/closure-arg-count.rs:21:5 + --> $DIR/closure-arg-count.rs:23:5 | -21 | f(|| panic!()); +23 | f(|| panic!()); | ^ -- takes 0 arguments | | | expected closure that takes 1 argument @@ -52,45 +52,53 @@ note: required by `f` 13 | fn f>(_: F) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0593]: closure is expected to take a single tuple as argument, but it takes 2 distinct arguments - --> $DIR/closure-arg-count.rs:24:53 +error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments + --> $DIR/closure-arg-count.rs:26:53 | -24 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x| i); - | ^^^ ------ help: consider changing the closure to accept a tuple: `|(i, x)|` +26 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x| i); + | ^^^ ------ takes 2 distinct arguments | | - | expected closure that takes a single tuple as argument + | expected closure that takes a single 2-tuple as argument +help: change the closure to accept a tuple instead of individual arguments + | +26 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|(i, x)| i); + | ^^^^^^^^ -error[E0593]: closure is expected to take a single tuple as argument, but it takes 2 distinct arguments - --> $DIR/closure-arg-count.rs:26:53 +error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments + --> $DIR/closure-arg-count.rs:28:53 | -26 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i: usize, x| i); - | ^^^ ------------- help: consider changing the closure to accept a tuple: `|(i, x): (usize, _)|` +28 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i: usize, x| i); + | ^^^ ------------- takes 2 distinct arguments | | - | expected closure that takes a single tuple as argument + | expected closure that takes a single 2-tuple as argument +help: change the closure to accept a tuple instead of individual arguments + | +28 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|(i, x)| i); + | ^^^^^^^^ error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 3 distinct arguments - --> $DIR/closure-arg-count.rs:28:53 + --> $DIR/closure-arg-count.rs:30:53 | -28 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x, y| i); +30 | let _it = vec![1, 2, 3].into_iter().enumerate().map(|i, x, y| i); | ^^^ --------- takes 3 distinct arguments | | | expected closure that takes a single 2-tuple as argument error[E0593]: function is expected to take a single 2-tuple as argument, but it takes 0 arguments - --> $DIR/closure-arg-count.rs:30:53 + --> $DIR/closure-arg-count.rs:32:53 | -30 | let _it = vec![1, 2, 3].into_iter().enumerate().map(foo); +32 | let _it = vec![1, 2, 3].into_iter().enumerate().map(foo); | ^^^ expected function that takes a single 2-tuple as argument ... -37 | fn foo() {} +41 | fn foo() {} | -------- takes 0 arguments error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 3 distinct arguments - --> $DIR/closure-arg-count.rs:33:53 + --> $DIR/closure-arg-count.rs:35:53 | -32 | let bar = |i, x, y| i; +34 | let bar = |i, x, y| i; | --------- takes 3 distinct arguments -33 | let _it = vec![1, 2, 3].into_iter().enumerate().map(bar); +35 | let _it = vec![1, 2, 3].into_iter().enumerate().map(bar); | ^^^ expected closure that takes a single 2-tuple as argument error[E0593]: function is expected to take a single 2-tuple as argument, but it takes 2 distinct arguments diff --git a/src/test/ui/suggestions/for-c-in-str.stderr b/src/test/ui/suggestions/for-c-in-str.stderr index 7a6dc9a504029..88a7b1b49d62d 100644 --- a/src/test/ui/suggestions/for-c-in-str.stderr +++ b/src/test/ui/suggestions/for-c-in-str.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `&str: std::iter::Iterator` is not satisfied --> $DIR/for-c-in-str.rs:14:14 | 14 | for c in "asdf" { - | ^^^^^^ `&str` is not an iterator; maybe try calling `.iter()` or a similar method + | ^^^^^^ `&str` is not an iterator; try calling `.chars()` or `.bytes()` | = help: the trait `std::iter::Iterator` is not implemented for `&str` = note: required by `std::iter::IntoIterator::into_iter` diff --git a/src/test/ui/suggestions/iterate-str.rs b/src/test/ui/suggestions/iterate-str.rs deleted file mode 100644 index 1022491b84a36..0000000000000 --- a/src/test/ui/suggestions/iterate-str.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - for c in "foobarbaz" { - println!("{}", c); - } - //~^^^ ERROR the trait bound `&str: std::iter::Iterator` is not satisfied - //~| NOTE `&str` is not an iterator; try calling `.chars()` or `.bytes()` - //~| HELP the trait `std::iter::Iterator` is not implemented for `&str` - //~| NOTE required by `std::iter::IntoIterator::into_iter` -} diff --git a/src/test/ui/suggestions/iterate-str.stderr b/src/test/ui/suggestions/iterate-str.stderr deleted file mode 100644 index 59da6d70c0236..0000000000000 --- a/src/test/ui/suggestions/iterate-str.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0277]: the trait bound `&str: std::iter::Iterator` is not satisfied - --> $DIR/iterate-str.rs:12:5 - | -12 | / for c in "foobarbaz" { -13 | | println!("{}", c); -14 | | } - | |_____^ `&str` is not an iterator; try calling `.chars()` or `.bytes()` - | - = help: the trait `std::iter::Iterator` is not implemented for `&str` - = note: required by `std::iter::IntoIterator::into_iter` - -error: aborting due to previous error - From c7850139517d209ec9f2879e12cd7bb69cc78a9c Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 29 Jan 2018 11:14:55 +0530 Subject: [PATCH 093/198] Remove dead code --- src/librustc_errors/snippet.rs | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/src/librustc_errors/snippet.rs b/src/librustc_errors/snippet.rs index 6035f33c822ce..7d416f13ffc8a 100644 --- a/src/librustc_errors/snippet.rs +++ b/src/librustc_errors/snippet.rs @@ -10,32 +10,8 @@ // Code for annotating snippets. -use syntax_pos::{Span, FileMap}; -use CodeMapper; -use std::rc::Rc; use Level; -#[derive(Clone)] -pub struct SnippetData { - codemap: Rc, - files: Vec, -} - -#[derive(Clone)] -pub struct FileInfo { - file: Rc, - - /// The "primary file", if any, gets a `-->` marker instead of - /// `>>>`, and has a line-number/column printed and not just a - /// filename (other files are not guaranteed to have line numbers - /// or columns). It appears first in the listing. It is known to - /// contain at least one primary span, though primary spans (which - /// are designated with `^^^`) may also occur in other files. - primary_span: Option, - - lines: Vec, -} - #[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)] pub struct Line { pub line_index: usize, From c22d6e2fda06841dd77e9f92247fe9de575845a6 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 2 Feb 2018 12:09:25 +0530 Subject: [PATCH 094/198] Fix rustdoc ICE on macros defined within functions fixes #47639 --- src/librustc/lint/context.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 5336c1944e8c4..2efb9f2dc9cae 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -1042,11 +1042,20 @@ pub fn check_ast_crate(sess: &Session, krate: &ast::Crate) { // Put the lint store levels and passes back in the session. cx.lint_sess.restore(&sess.lint_store); - // Emit all buffered lints from early on in the session now that we've - // calculated the lint levels for all AST nodes. - for (_id, lints) in cx.buffered.map { - for early_lint in lints { - span_bug!(early_lint.span, "failed to process buffered lint here"); + // All of the buffered lints should have been emitted at this point. + // If not, that means that we somehow buffered a lint for a node id + // that was not lint-checked (perhaps it doesn't exist?). This is a bug. + // + // Rustdoc runs everybody-loops before the early lints and removes + // function bodies, so it's totally possible for linted + // node ids to not exist (e.g. macros defined within functions for the + // unused_macro lint) anymore. So we only run this check + // when we're not in rustdoc mode. (see issue #47639) + if !sess.opts.actually_rustdoc { + for (_id, lints) in cx.buffered.map { + for early_lint in lints { + span_bug!(early_lint.span, "failed to process buffered lint here"); + } } } } From ee737c73a2ac2d02420df812ad36cf16856da67a Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Fri, 2 Feb 2018 12:11:16 +0530 Subject: [PATCH 095/198] Add regression test --- src/test/rustdoc/issue-47639.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 src/test/rustdoc/issue-47639.rs diff --git a/src/test/rustdoc/issue-47639.rs b/src/test/rustdoc/issue-47639.rs new file mode 100644 index 0000000000000..167c3aaec4ab6 --- /dev/null +++ b/src/test/rustdoc/issue-47639.rs @@ -0,0 +1,16 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This should not ICE +pub fn test() { + macro_rules! foo { + () => () + } +} From a7646df923c62343959c0955a955ee19562da1ff Mon Sep 17 00:00:00 2001 From: Aaron Hill Date: Fri, 2 Feb 2018 14:59:27 -0500 Subject: [PATCH 096/198] Remove commented-out code --- src/librustc_mir/borrow_check/nll/type_check/liveness.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness.rs index 93bb3cb6647a9..a50b99937475e 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness.rs @@ -15,7 +15,6 @@ use dataflow::move_paths::{HasMoveData, MoveData}; use rustc::mir::{BasicBlock, Location, Mir}; use rustc::mir::Local; use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; -//use rustc::ty::subst::Kind; use rustc::traits; use rustc::infer::InferOk; use rustc::util::common::ErrorReported; @@ -243,7 +242,6 @@ impl<'gen, 'typeck, 'flow, 'gcx, 'tcx> TypeLivenessGenerator<'gen, 'typeck, 'flo final_obligations.extend(obligations); - //let ty = self.cx.normalize(&ty, location); let ty = cx.infcx.resolve_type_and_region_vars_if_possible(&ty); match ty.sty { ty::TyParam(..) | ty::TyProjection(..) | ty::TyAnon(..) => { From 321e429b9f9318dccd93f0bb637be3a6c926daef Mon Sep 17 00:00:00 2001 From: Per Lundberg Date: Fri, 2 Feb 2018 22:44:14 +0200 Subject: [PATCH 097/198] copy_nonoverlapping example: Fixed typo The comment referred to a variable using an incorrect name. (it has probably been renamed since the comment was written, or the comment was copied elsewhere - I noted the example in libcore has the `tmp` name for the temporary variable.) --- src/libcore/intrinsics.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index a611dc02469e8..a05d67a304fa0 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -992,7 +992,7 @@ extern "rust-intrinsic" { /// ptr::copy_nonoverlapping(y, x, 1); /// ptr::copy_nonoverlapping(&t, y, 1); /// - /// // y and t now point to the same thing, but we need to completely forget `tmp` + /// // y and t now point to the same thing, but we need to completely forget `t` /// // because it's no longer relevant. /// mem::forget(t); /// } From cc68afb38476c6ebf53b3dab302a2760cb9374b9 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Sat, 3 Feb 2018 02:51:16 +0200 Subject: [PATCH 098/198] ui tests: diff from old (expected) to new (actual) instead of backwards. --- src/tools/compiletest/src/runtest.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index abf62a060b83b..46df211cbaf65 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -79,7 +79,7 @@ pub fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec { if lines_since_mismatch >= context_size && lines_since_mismatch > 0 { @@ -91,7 +91,8 @@ pub fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec { @@ -104,8 +105,7 @@ pub fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec { From 6b35d813826a8011e3b3f19206c22f6978173134 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 29 Jan 2018 23:04:43 +0100 Subject: [PATCH 099/198] Fix const evaluation ICE in rustdoc --- src/librustdoc/clean/mod.rs | 11 +++++++++-- src/test/rustdoc/const-evalutation-ice.rs | 22 ++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/test/rustdoc/const-evalutation-ice.rs diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 0929b833c1965..7c9a49c82a939 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2447,7 +2447,12 @@ impl Clean for hir::Ty { let def_id = cx.tcx.hir.body_owner_def_id(n); let param_env = cx.tcx.param_env(def_id); let substs = Substs::identity_for_item(cx.tcx, def_id); - let n = cx.tcx.const_eval(param_env.and((def_id, substs))).unwrap(); + let n = cx.tcx.const_eval(param_env.and((def_id, substs))).unwrap_or_else(|_| { + cx.tcx.mk_const(ty::Const { + val: ConstVal::Unevaluated(def_id, substs), + ty: cx.tcx.types.usize + }) + }); let n = if let ConstVal::Integral(ConstInt::Usize(n)) = n.val { n.to_string() } else if let ConstVal::Unevaluated(def_id, _) = n.val { @@ -2577,7 +2582,9 @@ impl<'tcx> Clean for Ty<'tcx> { let mut n = cx.tcx.lift(&n).unwrap(); if let ConstVal::Unevaluated(def_id, substs) = n.val { let param_env = cx.tcx.param_env(def_id); - n = cx.tcx.const_eval(param_env.and((def_id, substs))).unwrap() + if let Ok(new_n) = cx.tcx.const_eval(param_env.and((def_id, substs))) { + n = new_n; + } }; let n = if let ConstVal::Integral(ConstInt::Usize(n)) = n.val { n.to_string() diff --git a/src/test/rustdoc/const-evalutation-ice.rs b/src/test/rustdoc/const-evalutation-ice.rs new file mode 100644 index 0000000000000..9fed67ee583d2 --- /dev/null +++ b/src/test/rustdoc/const-evalutation-ice.rs @@ -0,0 +1,22 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Just check if we don't get an ICE for the _S type. + +#![feature(const_size_of)] + +use std::cell::Cell; +use std::mem; + +pub struct S { + s: Cell +} + +pub type _S = [usize; 0 - (mem::size_of::() != 4) as usize]; From dde361128157a0845fb51d11dcd121c3491dd4a7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 27 Jan 2018 18:58:59 +0100 Subject: [PATCH 100/198] Fix rendering issues on mobile --- src/librustdoc/html/static/main.js | 26 ++++++++++++++++++++++ src/librustdoc/html/static/rustdoc.css | 8 ++++--- src/librustdoc/html/static/themes/dark.css | 2 +- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 0f9e7001c159b..ba9bcb7af7ae0 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -47,6 +47,8 @@ // 2 for "In Return Types" var currentTab = 0; + var themesWidth = null; + function hasClass(elem, className) { if (elem && className && elem.className) { var elemClass = elem.className; @@ -121,10 +123,25 @@ sidebar.appendChild(div); } } + var themeChoices = document.getElementById("theme-choices"); + if (themeChoices) { + if (!themesWidth) { + var savedState = themeChoices.style.display; + themeChoices.style.display = 'block'; + themesWidth = themeChoices.offsetWidth + 'px'; + themeChoices.style.display = savedState; + } + themeChoices.style.position = "fixed"; + themeChoices.style.width = themesWidth; + themeChoices.style.top = '78px'; + themeChoices.style.left = '250px'; + } document.getElementsByTagName("body")[0].style.marginTop = '45px'; var themePicker = document.getElementById("theme-picker"); if (themePicker) { themePicker.style.position = "fixed"; + themePicker.style.top = "50px"; + themePicker.style.left = "250px"; } } @@ -143,6 +160,15 @@ var themePicker = document.getElementById("theme-picker"); if (themePicker) { themePicker.style.position = "absolute"; + themePicker.style.top = null; + themePicker.style.left = null; + } + var themeChoices = document.getElementById("theme-choices"); + if (themeChoices) { + themeChoices.style.position = 'absolute'; + themeChoices.style.width = null; + themeChoices.style.top = null; + themeChoices.style.left = null; } } diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index d2eeb2e15b3dd..cb6f5d836b8a7 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -856,6 +856,7 @@ span.since { display: block; border-bottom: 1px solid; border-right: 1px solid; + height: 45px; } .sidebar-elems { @@ -875,7 +876,8 @@ span.since { } nav.sub { - margin: 0 auto; + width: calc(100% - 32px); + float: right; } .content { @@ -1184,8 +1186,8 @@ kbd { @media (max-width: 700px) { .theme-picker { - left: 109px; - top: 7px; + left: 10px; + top: 54px; z-index: 1; } } diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index 4c6bcab72b7c9..907a6e4fcb4a0 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -383,6 +383,6 @@ kbd { @media (max-width: 700px) { #theme-picker { - background: #353535; + background: #f0f0f0; } } From 9b4b2d79692f89a3c12e80a51eb874078affdf76 Mon Sep 17 00:00:00 2001 From: csmoe <35686186+csmoe@users.noreply.github.com> Date: Sat, 3 Feb 2018 20:22:33 +0800 Subject: [PATCH 101/198] inform user where to give a type annotation after a call to collect --- src/librustc_typeck/check/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 483dd345286d4..9a3dba440eae1 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -5033,9 +5033,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // If not, error. if alternative.is_ty_var() || alternative.references_error() { if !self.is_tainted_by_errors() { - type_error_struct!(self.tcx.sess, sp, ty, E0619, - "the type of this value must be known in this context") - .emit(); + self.need_type_info((**self).body_id, sp, ty); } self.demand_suptype(sp, self.tcx.types.err, ty); ty = self.tcx.types.err; From d597da32672805644b6dc76cfffeca6b8c4d8e62 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Thu, 1 Feb 2018 23:36:33 -0500 Subject: [PATCH 102/198] Clarify shared file handler behavior of File::try_clone. Fixes https://github.com/rust-lang/rust/issues/46578. --- src/libstd/fs.rs | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index d1f3ccbd2c6e0..594c9d0ff5aed 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -482,20 +482,42 @@ impl File { self.inner.file_attr().map(Metadata) } - /// Creates a new independently owned handle to the underlying file. - /// - /// The returned `File` is a reference to the same state that this object - /// references. Both handles will read and write with the same cursor - /// position. + /// Create a new `File` instance that shares the same underlying file handle + /// as the existing `File` instance. Reads, writes, and seeks will affect + /// both `File` instances simultaneously. /// /// # Examples /// + /// Create two handles for a file named `foo.txt`: + /// /// ```no_run /// use std::fs::File; /// /// # fn foo() -> std::io::Result<()> { - /// let mut f = File::open("foo.txt")?; - /// let file_copy = f.try_clone()?; + /// let mut file = File::open("foo.txt")?; + /// let file_copy = file.try_clone()?; + /// # Ok(()) + /// # } + /// ``` + /// + /// Assuming there’s a file named `foo.txt` with contents `abcdef\n`, create + /// two handles, seek one of them, and read the remaining bytes from the + /// other handle: + /// + /// ```no_run + /// use std::fs::File; + /// use std::io::SeekFrom; + /// use std::io::prelude::*; + /// + /// # fn foo() -> std::io::Result<()> { + /// let mut file = File::open("foo.txt")?; + /// let mut file_copy = file.try_clone()?; + /// + /// file.seek(SeekFrom::Start(3))?; + /// + /// let mut contents = vec![]; + /// file_copy.read_to_end(&mut contents)?; + /// assert_eq!(contents, b"def\n"); /// # Ok(()) /// # } /// ``` From e1f04c04dffc1615fde9dd1e51d27bcc5275cdb2 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Sun, 28 Jan 2018 15:50:03 -0700 Subject: [PATCH 103/198] Disable ThinLTO for dist builds. Dist builds should always be as fast as we can make them, and since those run on CI we don't care quite as much for the build being somewhat slower. As such, we don't automatically enable ThinLTO on builds for the dist builders. --- config.toml.example | 5 +++++ src/bootstrap/builder.rs | 21 +++++++++++++++------ src/bootstrap/config.rs | 5 +++++ src/bootstrap/configure.py | 1 + src/ci/run.sh | 1 + 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/config.toml.example b/config.toml.example index 9ca0f563d0af1..75cab74258b6b 100644 --- a/config.toml.example +++ b/config.toml.example @@ -235,6 +235,11 @@ # compiler. #codegen-units = 1 +# Whether to enable ThinLTO (and increase the codegen units to either a default +# or the configured value). On by default. If we want the fastest possible +# compiler, we should disable this. +#thinlto = true + # Whether or not debug assertions are enabled for the compiler and standard # library. Also enables compilation of debug! and trace! logging macros. #debug-assertions = false diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 780513dd94394..bf7b1015a4921 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -509,10 +509,6 @@ impl<'a> Builder<'a> { }) .env("TEST_MIRI", self.config.test_miri.to_string()) .env("RUSTC_ERROR_METADATA_DST", self.extended_error_dir()); - if let Some(n) = self.config.rust_codegen_units { - cargo.env("RUSTC_CODEGEN_UNITS", n.to_string()); - } - if let Some(host_linker) = self.build.linker(compiler.host) { cargo.env("RUSTC_HOST_LINKER", host_linker); @@ -679,6 +675,13 @@ impl<'a> Builder<'a> { if self.is_very_verbose() { cargo.arg("-v"); } + + // This must be kept before the thinlto check, as we set codegen units + // to 1 forcibly there. + if let Some(n) = self.config.rust_codegen_units { + cargo.env("RUSTC_CODEGEN_UNITS", n.to_string()); + } + if self.config.rust_optimize { // FIXME: cargo bench does not accept `--release` if cmd != "bench" { @@ -686,11 +689,17 @@ impl<'a> Builder<'a> { } if self.config.rust_codegen_units.is_none() && - self.build.is_rust_llvm(compiler.host) - { + self.build.is_rust_llvm(compiler.host) && + self.config.rust_thinlto { cargo.env("RUSTC_THINLTO", "1"); + } else if self.config.rust_codegen_units.is_none() { + // Generally, if ThinLTO has been disabled for some reason, we + // want to set the codegen units to 1. However, we shouldn't do + // this if the option was specifically set by the user. + cargo.env("RUSTC_CODEGEN_UNITS", "1"); } } + if self.config.locked_deps { cargo.arg("--locked"); } diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 0da04bebac513..be8910120ee19 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -81,6 +81,7 @@ pub struct Config { // rust codegen options pub rust_optimize: bool, pub rust_codegen_units: Option, + pub rust_thinlto: bool, pub rust_debug_assertions: bool, pub rust_debuginfo: bool, pub rust_debuginfo_lines: bool, @@ -261,6 +262,7 @@ impl Default for StringOrBool { struct Rust { optimize: Option, codegen_units: Option, + thinlto: Option, debug_assertions: Option, debuginfo: Option, debuginfo_lines: Option, @@ -412,6 +414,7 @@ impl Config { // Store off these values as options because if they're not provided // we'll infer default values for them later + let mut thinlto = None; let mut llvm_assertions = None; let mut debuginfo_lines = None; let mut debuginfo_only_std = None; @@ -455,6 +458,7 @@ impl Config { optimize = rust.optimize; ignore_git = rust.ignore_git; debug_jemalloc = rust.debug_jemalloc; + thinlto = rust.thinlto; set(&mut config.rust_optimize_tests, rust.optimize_tests); set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests); set(&mut config.codegen_tests, rust.codegen_tests); @@ -539,6 +543,7 @@ impl Config { "stable" | "beta" | "nightly" => true, _ => false, }; + config.rust_thinlto = thinlto.unwrap_or(true); config.rust_debuginfo_lines = debuginfo_lines.unwrap_or(default); config.rust_debuginfo_only_std = debuginfo_only_std.unwrap_or(default); diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index bc6f666d0012f..d51752a12d9e5 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -70,6 +70,7 @@ def v(*args): # Optimization and debugging options. These may be overridden by the release # channel, etc. o("optimize", "rust.optimize", "build optimized rust code") +o("thinlto", "rust.thinlto", "build Rust with ThinLTO enabled") o("optimize-llvm", "llvm.optimize", "build optimized LLVM") o("llvm-assertions", "llvm.assertions", "build LLVM with assertions") o("debug-assertions", "rust.debug-assertions", "build with debugging assertions") diff --git a/src/ci/run.sh b/src/ci/run.sh index dab385c09649c..02480c6937de1 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -46,6 +46,7 @@ export RUST_RELEASE_CHANNEL=nightly if [ "$DEPLOY$DEPLOY_ALT" != "" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp" + RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-thinlto" if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions" From cec82c1bfe373785e0bad93c557ce7db17a4048d Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Thu, 1 Feb 2018 18:56:48 +1300 Subject: [PATCH 104/198] Update RLS and Rustfmt --- src/Cargo.lock | 56 +++++++++++++++++++++++------------------------ src/tools/rls | 2 +- src/tools/rustfmt | 2 +- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index d26098903eec5..fc89cc4ea9ee3 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -1618,7 +1618,7 @@ version = "0.1.0" [[package]] name = "rls" -version = "0.124.0" +version = "0.125.0" dependencies = [ "cargo 0.26.0", "env_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1635,7 +1635,7 @@ dependencies = [ "rls-rustc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rustfmt-nightly 0.3.6", + "rustfmt-nightly 0.3.8", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1723,7 +1723,7 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_cratesio_shim" -version = "12.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1732,57 +1732,57 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_data_structures" -version = "12.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot_core 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-rustc_errors" -version = "12.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-ap-rustc_data_structures 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax_pos 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax_pos 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-serialize" -version = "12.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rustc-ap-syntax" -version = "12.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_cratesio_shim 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_data_structures 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_errors 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax_pos 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_cratesio_shim 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_errors 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax_pos 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-syntax_pos" -version = "12.0.0" +version = "29.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-ap-rustc_data_structures 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2207,7 +2207,7 @@ dependencies = [ [[package]] name = "rustfmt-nightly" -version = "0.3.6" +version = "0.3.8" dependencies = [ "cargo_metadata 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "derive-new 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2219,8 +2219,8 @@ dependencies = [ "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_errors 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_errors 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3068,12 +3068,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rls-rustc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "85cfb9dde19e313da3e47738008f8a472e470cc42d910b71595a9238494701f2" "checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a" "checksum rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ffd34691a510938bb67fe0444fb363103c73ffb31c121d1e16bc92d8945ea8ff" -"checksum rustc-ap-rustc_cratesio_shim 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f1a51c10af5abd5d698b7e3487e869e6d15f6feb04cbedb5c792e2824f9d845e" -"checksum rustc-ap-rustc_data_structures 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1aa227490501072780d57f74b1164d361833ff8e172f817da0da2cdf2e4280cc" -"checksum rustc-ap-rustc_errors 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "21ff6c6e13ac4fc04b7d4d398828b024c4b6577045cb3175b33d35fea35ff6d0" -"checksum rustc-ap-serialize 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b4e7f51e298675c2bf830f7265621a8936fb09e63b825b58144cbaac969e604" -"checksum rustc-ap-syntax 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8bf5639869ba2f7fa581939cd217cb71a85506b82ad0ea520614fb0dceb2386c" -"checksum rustc-ap-syntax_pos 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1c020cdb7379e1c733ae0a311ae47c748337ba584d2dd7b7f53baaae78de6f8b" +"checksum rustc-ap-rustc_cratesio_shim 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ad5e562044ea78a6764dd75ae8afe4b21fde49f4548024b5fdf6345c21fb524" +"checksum rustc-ap-rustc_data_structures 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c0d65325492aba7db72899e3edbab34d39af98c42ab7c7e450c9a288ffe4ad" +"checksum rustc-ap-rustc_errors 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "87d4ab2e06a671b5b5c5b0359dac346f164c99d059dce6a22feb08f2f56bd182" +"checksum rustc-ap-serialize 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e0745fa445ff41c4b6699936cf35ce3ca49502377dd7b3929c829594772c3a7b" +"checksum rustc-ap-syntax 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "82efedabe30f393161e11214a9130edfa01ad476372d1c6f3fec1f8d30488c9d" +"checksum rustc-ap-syntax_pos 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db9de2e927e280c75b8efab9c5f591ad31082d5d2c4c562c68fdba2ee77286b0" "checksum rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aee45432acc62f7b9a108cc054142dac51f979e69e71ddce7d6fc7adf29e817e" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7" diff --git a/src/tools/rls b/src/tools/rls index 511321ae1c2fa..dee42bda8156a 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit 511321ae1c2fa3f0e334885fecf406dd6c882836 +Subproject commit dee42bda8156a28ead609080e27b02173bb9c29e diff --git a/src/tools/rustfmt b/src/tools/rustfmt index e0e3e22248cd1..346238f49740d 160000 --- a/src/tools/rustfmt +++ b/src/tools/rustfmt @@ -1 +1 @@ -Subproject commit e0e3e22248cd14ebbe0253e9720261a0328bfc59 +Subproject commit 346238f49740d6c98102a6a59811b1625c73a9d7 From 61ff3ba5364ae7bbf93be5b892fa7c122d3cfab2 Mon Sep 17 00:00:00 2001 From: Gilad Naaman Date: Sat, 27 Jan 2018 22:34:05 +0200 Subject: [PATCH 105/198] libtest: Replace panics with error messages --- src/libtest/lib.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index ffa27688cf1a7..9ea5f39b71fee 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -72,6 +72,7 @@ use std::sync::{Arc, Mutex}; use std::thread; use std::time::{Instant, Duration}; use std::borrow::Cow; +use std::process; const TEST_WARN_TIMEOUT_S: u64 = 60; const QUIET_MODE_MAX_COLUMN: usize = 100; // insert a '\n' after 100 tests in quiet mode @@ -266,19 +267,27 @@ impl Options { pub fn test_main(args: &[String], tests: Vec, options: Options) { let mut opts = match parse_opts(args) { Some(Ok(o)) => o, - Some(Err(msg)) => panic!("{:?}", msg), + Some(Err(msg)) => { + eprintln!("error: {}", msg); + process::exit(101); + }, None => return, }; + opts.options = options; if opts.list { if let Err(e) = list_tests_console(&opts, tests) { - panic!("io error when listing tests: {:?}", e); + eprintln!("error: io error when listing tests: {:?}", e); + process::exit(101); } } else { match run_tests_console(&opts, tests) { Ok(true) => {} - Ok(false) => std::process::exit(101), - Err(e) => panic!("io error when running tests: {:?}", e), + Ok(false) => process::exit(101), + Err(e) => { + eprintln!("error: io error when listing tests: {:?}", e); + process::exit(101); + }, } } } From 3d114c7f61c5994633196a378e5eed4ee3e58841 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Sun, 4 Feb 2018 17:31:00 +0900 Subject: [PATCH 106/198] Remove delay_span_bug() in check_aliasability This path was considered to be unreachable. However, `&mut` could potentially live inside `static`. For example, `static TAB: [&mut [u8]; 0] = [];`. --- src/librustc_borrowck/borrowck/mod.rs | 12 +----------- src/test/compile-fail/issue-42344.rs | 17 +++++++++++++++++ src/test/compile-fail/issue-46604.rs | 3 ++- 3 files changed, 20 insertions(+), 12 deletions(-) create mode 100644 src/test/compile-fail/issue-42344.rs diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 4529e4bab752c..04c16b1d69496 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -1113,22 +1113,12 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { }; match cause { - mc::AliasableStatic => { - // This happens when we have an `&mut` or assignment to a - // static. We should have already reported a mutability - // violation first, but may have continued compiling. - self.tcx.sess.delay_span_bug( - span, - &format!("aliasability violation for static `{}`", prefix) - ); - return; - } mc::AliasableStaticMut => { // This path cannot occur. `static mut X` is not checked // for aliasability violations. span_bug!(span, "aliasability violation for static mut `{}`", prefix) } - mc::AliasableBorrowed => {} + mc::AliasableStatic | mc::AliasableBorrowed => {} }; let blame = cmt.immutability_blame(); let mut err = match blame { diff --git a/src/test/compile-fail/issue-42344.rs b/src/test/compile-fail/issue-42344.rs new file mode 100644 index 0000000000000..2f11ff402beed --- /dev/null +++ b/src/test/compile-fail/issue-42344.rs @@ -0,0 +1,17 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +static TAB: [&mut [u8]; 0] = []; + +pub unsafe fn test() { + TAB[0].iter_mut(); //~ ERROR cannot borrow data mutably in a `&` reference [E0389] +} + +pub fn main() {} diff --git a/src/test/compile-fail/issue-46604.rs b/src/test/compile-fail/issue-46604.rs index 06aa4c343fea3..dc14eca1e6734 100644 --- a/src/test/compile-fail/issue-46604.rs +++ b/src/test/compile-fail/issue-46604.rs @@ -17,5 +17,6 @@ fn write>(buffer: T) { } fn main() { write(&buf); - buf[0]=2; //[mir]~ ERROR E0594 + buf[0]=2; //[ast]~ ERROR E0389 + //[mir]~^ ERROR E0594 } From c26abe75bcc4201c8f94d278f9da8645c4a8f718 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 4 Feb 2018 13:38:39 +0100 Subject: [PATCH 107/198] Fix not selectable search input --- src/librustdoc/html/static/rustdoc.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index cb6f5d836b8a7..fc5444b6b788d 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -884,6 +884,11 @@ span.since { margin-left: 0px; } + #main { + margin-top: 50px; + padding: 0; + } + .content .in-band { width: 100%; } From 8a587e67afcd99e800eb0783a090f8b163cdfb10 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sun, 4 Feb 2018 13:47:35 +0100 Subject: [PATCH 108/198] Improve big sidebar elements display --- src/librustdoc/html/static/rustdoc.css | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index fc5444b6b788d..6d95123e63c65 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -1035,6 +1035,24 @@ h4 > .important-traits { .show-it { display: block; + width: 246px; + } + + .show-it > .block.items { + margin: 8px 0; + } + + .show-it > .block.items > ul { + margin: 0; + } + + .show-it > .block.items > ul > li { + text-align: center; + margin: 2px 0; + } + + .show-it > .block.items > ul > li > a { + font-size: 21px; } /* Because of ios, we need to actually have a full height sidebar title so the From 32d5fbe8b204a0fb9c58c5344f95917a713e53a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Sun, 4 Feb 2018 14:52:31 +0100 Subject: [PATCH 109/198] Run the `run-make` tests last, so more tests run on Windows when `make` is unavailable --- src/bootstrap/test.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 5fdc6e0092064..e4c1cdb79fd24 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -610,7 +610,6 @@ static HOST_COMPILETESTS: &[Test] = &[ mode: "incremental", suite: "incremental-fulldeps", }, - Test { path: "src/test/run-make", mode: "run-make", suite: "run-make" }, Test { path: "src/test/rustdoc", mode: "rustdoc", suite: "rustdoc" }, Test { path: "src/test/pretty", mode: "pretty", suite: "pretty" }, @@ -619,6 +618,7 @@ static HOST_COMPILETESTS: &[Test] = &[ Test { path: "src/test/run-pass-valgrind/pretty", mode: "pretty", suite: "run-pass-valgrind" }, Test { path: "src/test/run-pass-fulldeps/pretty", mode: "pretty", suite: "run-pass-fulldeps" }, Test { path: "src/test/run-fail-fulldeps/pretty", mode: "pretty", suite: "run-fail-fulldeps" }, + Test { path: "src/test/run-make", mode: "run-make", suite: "run-make" }, ]; #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] From a1809d57840a19e28e93b437a7d029be3656acb8 Mon Sep 17 00:00:00 2001 From: oberien Date: Thu, 18 Jan 2018 18:40:08 +0100 Subject: [PATCH 110/198] Implement TrustedLen for Take and Take --- src/libcore/iter/mod.rs | 3 +++ src/libcore/iter/range.rs | 3 +++ src/libcore/iter/sources.rs | 3 +++ 3 files changed, 9 insertions(+) diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 7314fac282b66..bf8367d85fd10 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -2322,6 +2322,9 @@ impl ExactSizeIterator for Take where I: ExactSizeIterator {} #[unstable(feature = "fused", issue = "35602")] impl FusedIterator for Take where I: FusedIterator {} +#[unstable(feature = "trusted_len", issue = "37572")] +unsafe impl TrustedLen for Take {} + /// An iterator to maintain state while iterating another iterator. /// /// This `struct` is created by the [`scan`] method on [`Iterator`]. See its diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs index 66a76a24df45a..5af6df3e1cb47 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -325,6 +325,9 @@ impl Iterator for ops::RangeFrom { #[unstable(feature = "fused", issue = "35602")] impl FusedIterator for ops::RangeFrom {} +#[unstable(feature = "trusted_len", issue = "37572")] +unsafe impl TrustedLen for ops::RangeFrom {} + #[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")] impl Iterator for ops::RangeInclusive { type Item = A; diff --git a/src/libcore/iter/sources.rs b/src/libcore/iter/sources.rs index b405f35d5e4db..b05a893e66104 100644 --- a/src/libcore/iter/sources.rs +++ b/src/libcore/iter/sources.rs @@ -44,6 +44,9 @@ impl DoubleEndedIterator for Repeat { #[unstable(feature = "fused", issue = "35602")] impl FusedIterator for Repeat {} +#[unstable(feature = "trusted_len", issue = "37572")] +unsafe impl TrustedLen for Repeat {} + /// Creates a new iterator that endlessly repeats a single element. /// /// The `repeat()` function repeats a single value over and over and over and From 75474ff1323c2968bb2dafc8b8f0af4817a89d01 Mon Sep 17 00:00:00 2001 From: oberien Date: Fri, 2 Feb 2018 09:31:56 +0100 Subject: [PATCH 111/198] TrustedLen for Repeat / RangeFrom test cases --- src/libcore/tests/iter.rs | 43 ++++++++++++++++++++++++++ src/test/codegen/repeat-trusted-len.rs | 23 ++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/test/codegen/repeat-trusted-len.rs diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index e52e119ff59b9..f6b12fbb2dd11 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -1371,6 +1371,29 @@ fn test_range_from_nth() { assert_eq!(r, 16..); assert_eq!(r.nth(10), Some(26)); assert_eq!(r, 27..); + + assert_eq!((0..).size_hint(), (usize::MAX, None)); +} + +fn is_trusted_len(_: I) {} + +#[test] +fn test_range_from_take() { + let mut it = (0..).take(3); + assert_eq!(it.next(), Some(0)); + assert_eq!(it.next(), Some(1)); + assert_eq!(it.next(), Some(2)); + assert_eq!(it.next(), None); + is_trusted_len((0..).take(3)); + assert_eq!((0..).take(3).size_hint(), (3, Some(3))); + assert_eq!((0..).take(0).size_hint(), (0, Some(0))); + assert_eq!((0..).take(usize::MAX).size_hint(), (usize::MAX, Some(usize::MAX))); +} + +#[test] +fn test_range_from_take_collect() { + let v: Vec<_> = (0..).take(3).collect(); + assert_eq!(v, vec![0, 1, 2]); } #[test] @@ -1465,6 +1488,26 @@ fn test_repeat() { assert_eq!(it.next(), Some(42)); assert_eq!(it.next(), Some(42)); assert_eq!(it.next(), Some(42)); + assert_eq!(repeat(42).size_hint(), (usize::MAX, None)); +} + +#[test] +fn test_repeat_take() { + let mut it = repeat(42).take(3); + assert_eq!(it.next(), Some(42)); + assert_eq!(it.next(), Some(42)); + assert_eq!(it.next(), Some(42)); + assert_eq!(it.next(), None); + is_trusted_len(repeat(42).take(3)); + assert_eq!(repeat(42).take(3).size_hint(), (3, Some(3))); + assert_eq!(repeat(42).take(0).size_hint(), (0, Some(0))); + assert_eq!(repeat(42).take(usize::MAX).size_hint(), (usize::MAX, Some(usize::MAX))); +} + +#[test] +fn test_repeat_take_collect() { + let v: Vec<_> = repeat(42).take(3).collect(); + assert_eq!(v, vec![42, 42, 42]); } #[test] diff --git a/src/test/codegen/repeat-trusted-len.rs b/src/test/codegen/repeat-trusted-len.rs new file mode 100644 index 0000000000000..43872f15d51e2 --- /dev/null +++ b/src/test/codegen/repeat-trusted-len.rs @@ -0,0 +1,23 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -O +// ignore-tidy-linelength + +#![crate_type = "lib"] + +use std::iter; + +// CHECK-LABEL: @repeat_take_collect +#[no_mangle] +pub fn repeat_take_collect() -> Vec { +// CHECK: call void @llvm.memset.p0i8 + iter::repeat(42).take(100000).collect() +} From 6caec2c0494a173f696e5a63583ff35d1bd106aa Mon Sep 17 00:00:00 2001 From: oberien Date: Sun, 4 Feb 2018 16:04:06 +0100 Subject: [PATCH 112/198] Document TrustedLen guarantees more explicitly --- src/libcore/iter/traits.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs index 11e668d228c48..be4889f24877c 100644 --- a/src/libcore/iter/traits.rs +++ b/src/libcore/iter/traits.rs @@ -970,9 +970,11 @@ impl<'a, I: FusedIterator + ?Sized> FusedIterator for &'a mut I {} /// The iterator reports a size hint where it is either exact /// (lower bound is equal to upper bound), or the upper bound is [`None`]. /// The upper bound must only be [`None`] if the actual iterator length is -/// larger than [`usize::MAX`]. +/// larger than [`usize::MAX`]. In that case, the lower bound must be +/// [`usize::MAX`], resulting in a [`.size_hint`] of `(usize::MAX, None)`. /// -/// The iterator must produce exactly the number of elements it reported. +/// The iterator must produce exactly the number of elements it reported +/// or diverge before reaching the end. /// /// # Safety /// From f168700ba6257979dd90b20e0149e1ccf53590f0 Mon Sep 17 00:00:00 2001 From: Jay Strict Date: Sun, 4 Feb 2018 16:24:18 +0100 Subject: [PATCH 113/198] Remove 'the this' in doc comments. --- src/librustc/mir/mod.rs | 2 +- src/libstd/fs.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 3b644aa13f321..c0feb8ad02078 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -1825,7 +1825,7 @@ pub struct Location { /// the location is within this block pub block: BasicBlock, - /// the location is the start of the this statement; or, if `statement_index` + /// the location is the start of the statement; or, if `statement_index` /// == num-statements, then the start of the terminator. pub statement_index: usize, } diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index d1f3ccbd2c6e0..9bf90d402564f 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -1001,7 +1001,7 @@ impl Metadata { self.0.accessed().map(FromInner::from_inner) } - /// Returns the creation time listed in the this metadata. + /// Returns the creation time listed in this metadata. /// /// The returned value corresponds to the `birthtime` field of `stat` on /// Unix platforms and the `ftCreationTime` field on Windows platforms. From f243f9239d2e2e5c0d21aa45f4d8bfd3cdcd3367 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Sun, 4 Feb 2018 11:57:36 -0800 Subject: [PATCH 114/198] Fix info about generic impls in AsMut docs This text was copy-pasted from the `AsRef` docs to `AsMut`, but needed some additional adjustments for correctness. --- src/libcore/convert.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index e815d72d36646..d3a83dc795c85 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -141,9 +141,9 @@ pub trait AsRef { /// /// # Generic Implementations /// -/// - `AsMut` auto-dereferences if the inner type is a reference or a mutable -/// reference (e.g.: `foo.as_ref()` will work the same if `foo` has type -/// `&mut Foo` or `&&mut Foo`) +/// - `AsMut` auto-dereferences if the inner type is a mutable reference +/// (e.g.: `foo.as_mut()` will work the same if `foo` has type `&mut Foo` +/// or `&mut &mut Foo`) /// /// # Examples /// From dcb3e21b06f38f693fa99dda1f612028b4aa4584 Mon Sep 17 00:00:00 2001 From: steveklabnik Date: Thu, 25 Jan 2018 12:24:27 -0500 Subject: [PATCH 115/198] update trpl Includes https://github.com/rust-lang/book/pull/1088 and https://github.com/rust-lang/book/commit/62210e326c27697e94ce429c1683dcea4e4887e4 --- src/doc/book | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/book b/src/doc/book index 194eb8d5f1753..a645960fe4894 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit 194eb8d5f1753fb5f4501011cebdc1b585712474 +Subproject commit a645960fe48946153936dd5628df4a90bd837981 From b320829da41d6f93e0f2f9f4218502f1073626a4 Mon Sep 17 00:00:00 2001 From: steveklabnik Date: Fri, 26 Jan 2018 12:32:33 -0500 Subject: [PATCH 116/198] update reference --- src/doc/reference | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/reference b/src/doc/reference index 1d791b55b23ec..e6a5d5d10aa2f 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 1d791b55b23ec5389fbd5b3cee80db3f8bbdd162 +Subproject commit e6a5d5d10aa2fde0baed7b29bf672bd9f3af8962 From 5437188e100d704516dd5803378ee5ccd29edfe1 Mon Sep 17 00:00:00 2001 From: steveklabnik Date: Thu, 25 Jan 2018 12:32:25 -0500 Subject: [PATCH 117/198] update mdbook to 0.1.2 and improve printing of errors --- src/Cargo.lock | 51 ++++++++++++++++++++++++++++++---- src/tools/rustbook/Cargo.toml | 2 +- src/tools/rustbook/src/main.rs | 10 +++++-- 3 files changed, 53 insertions(+), 10 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index fc89cc4ea9ee3..a5dafbb0a3019 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -928,6 +928,11 @@ dependencies = [ "xz2 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "is-match" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "itertools" version = "0.6.5" @@ -936,6 +941,14 @@ dependencies = [ "either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "itertools" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "itoa" version = "0.3.4" @@ -1129,23 +1142,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "mdbook" -version = "0.0.28" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "handlebars 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "open 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "toml-query 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1695,7 +1713,7 @@ name = "rustbook" version = "0.1.0" dependencies = [ "clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)", - "mdbook 0.0.28 (registry+https://github.com/rust-lang/crates.io-index)", + "mdbook 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2379,6 +2397,11 @@ name = "shell-escape" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "shlex" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "siphasher" version = "0.2.2" @@ -2702,6 +2725,18 @@ dependencies = [ "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "toml-query" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "is-match 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", + "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "unicode-bidi" version = "0.3.4" @@ -2992,7 +3027,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" "checksum if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "61bb90bdd39e3af69b0172dfc6130f6cd6332bf040fbb9bdd4401d37adbd48b8" "checksum ignore 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bb2f0238094bd1b41800fb6eb9b16fdd5e9832ed6053ed91409f0cd5bf28dcfd" +"checksum is-match 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7e5b386aef33a1c677be65237cb9d32c3f3ef56bd035949710c4bb13083eb053" "checksum itertools 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d3f2be4da1690a039e9ae5fd575f706a63ad5a2120f161b1d653c9da3930dd21" +"checksum itertools 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b07332223953b5051bceb67e8c4700aa65291535568e1f12408c43c4a42c0394" "checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c" "checksum jobserver 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "565f6106bd87b394398f813bea4e5ecad6d6b0f6aa077592d088f882a506481d" "checksum json 0.11.12 (registry+https://github.com/rust-lang/crates.io-index)" = "39ebf0fac977ee3a4a3242b6446004ff64514889e3e2730bbd4f764a67a2e483" @@ -3014,7 +3051,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum mac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" "checksum markup5ever 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "047150a0e03b57e638fc45af33a0b63a0362305d5b9f92ecef81df472a4cceb0" "checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376" -"checksum mdbook 0.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "1ee8ba20c002000546681dc78d7f7e91fd35832058b1e2fdd492ca842bb6e9be" +"checksum mdbook 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fef236caad7ba3b5b3944df946f19ab3e190bca53c111dd00fe05fa8d879f2fd" "checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" "checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" "checksum miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "609ce024854aeb19a0ef7567d348aaa5a746b32fb72e336df7fcc16869d7e2b4" @@ -3094,6 +3131,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c9db7266c7d63a4c4b7fe8719656ccdd51acf1bed6124b174f933b009fb10bcb" "checksum shared_child 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "099b38928dbe4a0a01fcd8c233183072f14a7d126a34bed05880869be66e14cc" "checksum shell-escape 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "dd5cc96481d54583947bfe88bf30c23d53f883c6cd0145368b69989d97b84ef8" +"checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" "checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537" "checksum smallvec 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4f8266519bc1d17d0b5b16f6c21295625d562841c708f6376f49028a43e9c11e" "checksum smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44db0ecb22921ef790d17ae13a3f6d15784183ff5f2a01aa32098c7498d2b4b9" @@ -3122,6 +3160,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "a15375f1df02096fb3317256ce2cee6a1f42fc84ea5ad5fc8c421cfe40c73098" "checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4" "checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e" +"checksum toml-query 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6854664bfc6df0360c695480836ee90e2d0c965f06db291d10be9344792d43e8" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "51ccda9ef9efa3f7ef5d91e8f9b83bbe6955f9bf86aec89d5cce2c874625920f" "checksum unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8083c594e02b8ae1654ae26f0ade5158b119bd88ad0e8227a5d8fcd72407946" diff --git a/src/tools/rustbook/Cargo.toml b/src/tools/rustbook/Cargo.toml index bc35cbe9fbba6..539b434e9eca5 100644 --- a/src/tools/rustbook/Cargo.toml +++ b/src/tools/rustbook/Cargo.toml @@ -8,5 +8,5 @@ license = "MIT/Apache-2.0" clap = "2.25.0" [dependencies.mdbook] -version = "0.0.28" +version = "0.1.2" default-features = false diff --git a/src/tools/rustbook/src/main.rs b/src/tools/rustbook/src/main.rs index 50f4364e448f7..87a63a34cb642 100644 --- a/src/tools/rustbook/src/main.rs +++ b/src/tools/rustbook/src/main.rs @@ -13,7 +13,6 @@ extern crate mdbook; extern crate clap; use std::env; -use std::io::{self, Write}; use std::path::{Path, PathBuf}; use clap::{App, ArgMatches, SubCommand, AppSettings}; @@ -45,14 +44,19 @@ fn main() { }; if let Err(e) = res { - writeln!(&mut io::stderr(), "An error occured:\n{}", e).ok(); + eprintln!("Error: {}", e); + + for cause in e.iter().skip(1) { + eprintln!("\tCaused By: {}", cause); + } + ::std::process::exit(101); } } // Build command implementation pub fn build(args: &ArgMatches) -> Result<()> { let book_dir = get_book_dir(args); - let mut book = MDBook::new(&book_dir).read_config()?; + let mut book = MDBook::load(&book_dir)?; // Set this to allow us to catch bugs in advance. book.config.build.create_missing = false; From 983cc00b80d0d6a37ef8ae171febfd45cd4313fe Mon Sep 17 00:00:00 2001 From: steveklabnik Date: Sat, 3 Feb 2018 11:00:39 -0500 Subject: [PATCH 118/198] add exceptions for new deps --- src/tools/tidy/src/deps.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index bc2767c7bcc5d..159c9e035b7a2 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -33,6 +33,8 @@ static EXCEPTIONS: &'static [&'static str] = &[ "openssl", // BSD+advertising clause, cargo, mdbook "pest", // MPL2, mdbook via handlebars "thread-id", // Apache-2.0, mdbook + "toml-query", // MPL-2.0, mdbook + "is-match", // MPL-2.0, mdbook "cssparser", // MPL-2.0, rustdoc "smallvec", // MPL-2.0, rustdoc "fuchsia-zircon-sys", // BSD-3-Clause, rustdoc, rustc, cargo From 3c72a848e9d4470d49969fa0ef0a0a8a0c24d681 Mon Sep 17 00:00:00 2001 From: Nick Cameron Date: Mon, 5 Feb 2018 11:00:56 +1300 Subject: [PATCH 119/198] save-analysis: avoid implicit unwrap When looking up a field defintion, since the name might be incorrect in the field init shorthand case. cc https://github.com/rust-lang-nursery/rls/issues/699 --- src/librustc_save_analysis/lib.rs | 2 +- src/test/run-make/save-analysis-fail/foo.rs | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 2e494fdfad8b8..7bd7d5cb15d8e 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -791,7 +791,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { field_ref: &ast::Field, variant: &ty::VariantDef, ) -> Option { - let f = variant.field_named(field_ref.ident.node.name); + let f = variant.find_field_named(field_ref.ident.node.name)?; // We don't really need a sub-span here, but no harm done let sub_span = self.span_utils.span_for_last_ident(field_ref.ident.span); filter!(self.span_utils, sub_span, field_ref.ident.span, None); diff --git a/src/test/run-make/save-analysis-fail/foo.rs b/src/test/run-make/save-analysis-fail/foo.rs index 8a1b579398946..07322d8bbc325 100644 --- a/src/test/run-make/save-analysis-fail/foo.rs +++ b/src/test/run-make/save-analysis-fail/foo.rs @@ -451,3 +451,11 @@ extern { static EXTERN_FOO: u8; fn extern_foo(a: u8, b: i32) -> String; } + +struct Rls699 { + f: u32, +} + +fn new(f: u32) -> Rls699 { + Rls699 { fs } +} From 1b1e887f4d40e5800a8d5ae81f8574806e7ba21a Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Sun, 4 Feb 2018 23:48:40 -0800 Subject: [PATCH 120/198] Override try_[r]fold for RangeInclusive Because the last item needs special handling, it seems that LLVM has trouble canonicalizing the loops in external iteration. With the override, it becomes obvious that the start==end case exits the loop (as opposed to the one *after* that exiting the loop in external iteration). --- src/libcore/iter/range.rs | 46 ++++++++++++++++++++++++++++++++++++++- src/libcore/tests/iter.rs | 20 +++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs index 66a76a24df45a..3b034efcce14c 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -10,7 +10,7 @@ use convert::TryFrom; use mem; -use ops::{self, Add, Sub}; +use ops::{self, Add, Sub, Try}; use usize; use super::{FusedIterator, TrustedLen}; @@ -397,6 +397,28 @@ impl Iterator for ops::RangeInclusive { fn max(mut self) -> Option { self.next_back() } + + #[inline] + fn try_fold(&mut self, init: B, mut f: F) -> R where + Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try + { + let mut accum = init; + if self.start <= self.end { + loop { + let (x, done) = + if self.start < self.end { + let n = self.start.add_one(); + (mem::replace(&mut self.start, n), false) + } else { + self.end.replace_zero(); + (self.start.replace_one(), true) + }; + accum = f(accum, x)?; + if done { break } + } + } + Try::from_ok(accum) + } } #[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")] @@ -418,6 +440,28 @@ impl DoubleEndedIterator for ops::RangeInclusive { _ => None, } } + + #[inline] + fn try_rfold(&mut self, init: B, mut f: F) -> R where + Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try + { + let mut accum = init; + if self.start <= self.end { + loop { + let (x, done) = + if self.start < self.end { + let n = self.end.sub_one(); + (mem::replace(&mut self.end, n), false) + } else { + self.start.replace_one(); + (self.end.replace_zero(), true) + }; + accum = f(accum, x)?; + if done { break } + } + } + Try::from_ok(accum) + } } #[unstable(feature = "fused", issue = "35602")] diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index 8997cf9c6bff9..e33a0b6224e54 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -1397,6 +1397,26 @@ fn test_range_inclusive_min() { assert_eq!(r.min(), None); } +#[test] +fn test_range_inclusive_folds() { + assert_eq!((1..=10).sum::(), 55); + assert_eq!((1..=10).rev().sum::(), 55); + + let mut it = 40..=50; + assert_eq!(it.try_fold(0, i8::checked_add), None); + assert_eq!(it, 44..=50); + assert_eq!(it.try_rfold(0, i8::checked_add), None); + assert_eq!(it, 44..=47); + + let mut it = 10..=20; + assert_eq!(it.try_fold(0, |a,b| Some(a+b)), Some(165)); + assert_eq!(it, 1..=0); + + let mut it = 10..=20; + assert_eq!(it.try_rfold(0, |a,b| Some(a+b)), Some(165)); + assert_eq!(it, 1..=0); +} + #[test] fn test_repeat() { let mut it = repeat(42); From 1461d12b3c9778a51c443b804f2db5e235554151 Mon Sep 17 00:00:00 2001 From: Onur Aslan Date: Mon, 5 Feb 2018 11:39:54 +0300 Subject: [PATCH 121/198] Use time crate in bootstrap dist instead of date --- src/Cargo.lock | 1 + src/bootstrap/Cargo.toml | 1 + src/bootstrap/dist.rs | 6 +++--- src/bootstrap/lib.rs | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index fc89cc4ea9ee3..aa6d1eb324952 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -133,6 +133,7 @@ dependencies = [ "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index bbbbf0e191555..2d47834131784 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -41,3 +41,4 @@ serde_derive = "1.0.8" serde_json = "1.0.2" toml = "0.4" lazy_static = "0.2" +time = "0.1" diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index dbb7d19e43285..6717b1cb09883 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -33,6 +33,7 @@ use builder::{Builder, RunConfig, ShouldRun, Step}; use compile; use tool::{self, Tool}; use cache::{INTERNER, Interned}; +use time; pub fn pkgname(build: &Build, component: &str) -> String { if component == "cargo" { @@ -445,8 +446,7 @@ impl Step for Rustc { t!(fs::create_dir_all(image.join("share/man/man1"))); let man_src = build.src.join("src/doc/man"); let man_dst = image.join("share/man/man1"); - let date_output = output(Command::new("date").arg("+%B %Y")); - let month_year = date_output.trim(); + let month_year = t!(time::strftime("%B %Y", &time::now())); // don't use our `bootstrap::util::{copy, cp_r}`, because those try // to hardlink, and we don't want to edit the source templates for entry_result in t!(fs::read_dir(man_src)) { @@ -456,7 +456,7 @@ impl Step for Rustc { t!(fs::copy(&page_src, &page_dst)); // template in month/year and version number replace_in_file(&page_dst, - &[("", month_year), + &[("", &month_year), ("", channel::CFG_RELEASE_NUM)]); } diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index f2a7ce30c8ac7..a84a6a8990bbd 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -130,6 +130,7 @@ extern crate cc; extern crate getopts; extern crate num_cpus; extern crate toml; +extern crate time; #[cfg(unix)] extern crate libc; From 01f0814a2a7db7d93b4cb90b74242b082861e674 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Thu, 1 Feb 2018 22:55:20 +0100 Subject: [PATCH 122/198] Stabilize use_nested_groups --- .../language-features/use-nested-groups.md | 90 ------------------- src/libsyntax/feature_gate.rs | 28 +----- .../absolute-paths-in-nested-use-groups.rs | 1 - src/test/run-pass/issue-47673.rs | 1 - src/test/run-pass/use-nested-groups.rs | 2 - src/test/ui/feature-gate-use_nested_groups.rs | 31 ------- .../ui/feature-gate-use_nested_groups.stderr | 26 ------ src/test/ui/use-nested-groups-error.rs | 2 - src/test/ui/use-nested-groups-error.stderr | 4 +- 9 files changed, 4 insertions(+), 181 deletions(-) delete mode 100644 src/doc/unstable-book/src/language-features/use-nested-groups.md delete mode 100644 src/test/ui/feature-gate-use_nested_groups.rs delete mode 100644 src/test/ui/feature-gate-use_nested_groups.stderr diff --git a/src/doc/unstable-book/src/language-features/use-nested-groups.md b/src/doc/unstable-book/src/language-features/use-nested-groups.md deleted file mode 100644 index 47b635bad736f..0000000000000 --- a/src/doc/unstable-book/src/language-features/use-nested-groups.md +++ /dev/null @@ -1,90 +0,0 @@ -# `use_nested_groups` - -The tracking issue for this feature is: [#44494] - -[#44494]: https://github.com/rust-lang/rust/issues/44494 - ------------------------- - -The `use_nested_groups` feature allows you to import multiple items from a -complex module tree easily, by nesting different imports in the same -declaration. For example: - -```rust -#![feature(use_nested_groups)] -# #![allow(unused_imports, dead_code)] -# -# mod foo { -# pub mod bar { -# pub type Foo = (); -# } -# pub mod baz { -# pub mod quux { -# pub type Bar = (); -# } -# } -# } - -use foo::{ - bar::{self, Foo}, - baz::{*, quux::Bar}, -}; -# -# fn main() {} -``` - -## Snippet for the book's new features appendix - -When stabilizing, add this to -`src/doc/book/second-edition/src/appendix-07-newest-features.md`: - -### Nested groups in `use` declarations - -If you have a complex module tree with many different submodules and you need -to import a few items from each one, it might be useful to group all the -imports in the same declaration to keep your code clean and avoid repeating the -base modules' name. - -The `use` declaration supports nesting to help you in those cases, both with -simple imports and glob ones. For example this snippets imports `bar`, `Foo`, -all the items in `baz` and `Bar`: - -```rust -# #![feature(use_nested_groups)] -# #![allow(unused_imports, dead_code)] -# -# mod foo { -# pub mod bar { -# pub type Foo = (); -# } -# pub mod baz { -# pub mod quux { -# pub type Bar = (); -# } -# } -# } -# -use foo::{ - bar::{self, Foo}, - baz::{*, quux::Bar}, -}; -# -# fn main() {} -``` - -## Updated reference - -When stabilizing, replace the shortcut list in -`src/doc/reference/src/items/use-declarations.md` with this updated one: - -* Simultaneously binding a list of paths with a common prefix, using the - glob-like brace syntax `use a::b::{c, d, e::f, g::h::i};` -* Simultaneously binding a list of paths with a common prefix and their common - parent module, using the `self` keyword, such as `use a::b::{self, c, d::e};` -* Rebinding the target name as a new local name, using the syntax `use p::q::r - as x;`. This can also be used with the last two features: - `use a::b::{self as ab, c as abc}`. -* Binding all paths matching a given prefix, using the asterisk wildcard syntax - `use a::b::*;`. -* Nesting groups of the previous features multiple times, such as - `use a::b::{self as ab, c d::{*, e::f}};` diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 3e858c3b923a1..9c6520cd874a8 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -423,9 +423,6 @@ declare_features! ( // In-band lifetime bindings (e.g. `fn foo(x: &'a u8) -> &'a u8`) (active, in_band_lifetimes, "1.23.0", Some(44524)), - // Nested groups in `use` (RFC 2128) - (active, use_nested_groups, "1.23.0", Some(44494)), - // generic associated types (RFC 1598) (active, generic_associated_types, "1.23.0", Some(44265)), @@ -544,6 +541,8 @@ declare_features! ( (accepted, repr_align, "1.24.0", Some(33626)), // allow '|' at beginning of match arms (RFC 1925) (accepted, match_beginning_vert, "1.25.0", Some(44101)), + // Nested groups in `use` (RFC 2128) + (accepted, use_nested_groups, "1.25.0", Some(44494)), ); // If you change this, please modify src/doc/unstable-book as well. You must @@ -1805,29 +1804,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { visit::walk_path(self, path); } - fn visit_use_tree(&mut self, use_tree: &'a ast::UseTree, id: NodeId, nested: bool) { - if nested { - match use_tree.kind { - ast::UseTreeKind::Simple(_) => { - if use_tree.prefix.segments.len() != 1 { - gate_feature_post!(&self, use_nested_groups, use_tree.span, - "paths in `use` groups are experimental"); - } - } - ast::UseTreeKind::Glob => { - gate_feature_post!(&self, use_nested_groups, use_tree.span, - "glob imports in `use` groups are experimental"); - } - ast::UseTreeKind::Nested(_) => { - gate_feature_post!(&self, use_nested_groups, use_tree.span, - "nested groups in `use` are experimental"); - } - } - } - - visit::walk_use_tree(self, use_tree, id); - } - fn visit_vis(&mut self, vis: &'a ast::Visibility) { if let ast::Visibility::Crate(span, ast::CrateSugar::JustCrate) = *vis { gate_feature_post!(&self, crate_visibility_modifier, span, diff --git a/src/test/compile-fail/absolute-paths-in-nested-use-groups.rs b/src/test/compile-fail/absolute-paths-in-nested-use-groups.rs index 8e5ba489c565e..fe052f2f47ffd 100644 --- a/src/test/compile-fail/absolute-paths-in-nested-use-groups.rs +++ b/src/test/compile-fail/absolute-paths-in-nested-use-groups.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(use_nested_groups)] #![allow(unused_imports)] mod foo {} diff --git a/src/test/run-pass/issue-47673.rs b/src/test/run-pass/issue-47673.rs index 92f54a44f63c9..22f7f169e2988 100644 --- a/src/test/run-pass/issue-47673.rs +++ b/src/test/run-pass/issue-47673.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(use_nested_groups)] #![allow(unused_import)] use {{}, {}}; diff --git a/src/test/run-pass/use-nested-groups.rs b/src/test/run-pass/use-nested-groups.rs index a28f8da9ff882..be06e463e3b37 100644 --- a/src/test/run-pass/use-nested-groups.rs +++ b/src/test/run-pass/use-nested-groups.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(use_nested_groups)] - mod a { pub enum B {} diff --git a/src/test/ui/feature-gate-use_nested_groups.rs b/src/test/ui/feature-gate-use_nested_groups.rs deleted file mode 100644 index 56413a999d7f7..0000000000000 --- a/src/test/ui/feature-gate-use_nested_groups.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![allow(unused_imports, dead_code)] - -mod a { - pub enum B {} - pub enum C {} - - pub mod d { - pub enum E {} - pub enum F {} - - pub mod g { - pub enum H {} - } - } -} - -use a::{B, d::{*, g::H}}; //~ ERROR glob imports in `use` groups are experimental - //~^ ERROR nested groups in `use` are experimental - //~^^ ERROR paths in `use` groups are experimental - -fn main() {} diff --git a/src/test/ui/feature-gate-use_nested_groups.stderr b/src/test/ui/feature-gate-use_nested_groups.stderr deleted file mode 100644 index 6ae691c384be8..0000000000000 --- a/src/test/ui/feature-gate-use_nested_groups.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0658]: nested groups in `use` are experimental (see issue #44494) - --> $DIR/feature-gate-use_nested_groups.rs:27:12 - | -27 | use a::{B, d::{*, g::H}}; //~ ERROR glob imports in `use` groups are experimental - | ^^^^^^^^^^^^ - | - = help: add #![feature(use_nested_groups)] to the crate attributes to enable - -error[E0658]: glob imports in `use` groups are experimental (see issue #44494) - --> $DIR/feature-gate-use_nested_groups.rs:27:16 - | -27 | use a::{B, d::{*, g::H}}; //~ ERROR glob imports in `use` groups are experimental - | ^ - | - = help: add #![feature(use_nested_groups)] to the crate attributes to enable - -error[E0658]: paths in `use` groups are experimental (see issue #44494) - --> $DIR/feature-gate-use_nested_groups.rs:27:19 - | -27 | use a::{B, d::{*, g::H}}; //~ ERROR glob imports in `use` groups are experimental - | ^^^^ - | - = help: add #![feature(use_nested_groups)] to the crate attributes to enable - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/use-nested-groups-error.rs b/src/test/ui/use-nested-groups-error.rs index a9b6b3ee70d57..0a68d34ade9fa 100644 --- a/src/test/ui/use-nested-groups-error.rs +++ b/src/test/ui/use-nested-groups-error.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(use_nested_groups)] - mod a { pub mod b1 { pub enum C2 {} diff --git a/src/test/ui/use-nested-groups-error.stderr b/src/test/ui/use-nested-groups-error.stderr index cae34684c8e38..c4edb626be0bb 100644 --- a/src/test/ui/use-nested-groups-error.stderr +++ b/src/test/ui/use-nested-groups-error.stderr @@ -1,7 +1,7 @@ error[E0432]: unresolved import `a::b1::C1` - --> $DIR/use-nested-groups-error.rs:21:14 + --> $DIR/use-nested-groups-error.rs:19:14 | -21 | use a::{b1::{C1, C2}, B2}; +19 | use a::{b1::{C1, C2}, B2}; | ^^ no `C1` in `a::b1`. Did you mean to use `C2`? error: aborting due to previous error From 70717f20f5b94db65747d860319b484bc7191758 Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Tue, 30 Jan 2018 15:12:12 +0100 Subject: [PATCH 123/198] Update clippy and miri submodule --- src/Cargo.lock | 22 ++++++++++---------- src/ci/docker/x86_64-gnu-tools/checktools.sh | 2 +- src/tools/clippy | 2 +- src/tools/miri | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index fc89cc4ea9ee3..23ec918a8657d 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -291,14 +291,14 @@ dependencies = [ [[package]] name = "clippy" -version = "0.0.174" +version = "0.0.186" dependencies = [ "cargo_metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy-mini-macro-test 0.1.0", - "clippy_lints 0.0.174", - "compiletest_rs 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy-mini-macro-test 0.2.0", + "clippy_lints 0.0.186", + "compiletest_rs 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "duct 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -306,15 +306,15 @@ dependencies = [ [[package]] name = "clippy-mini-macro-test" -version = "0.1.0" +version = "0.2.0" [[package]] name = "clippy_lints" -version = "0.0.174" +version = "0.0.186" dependencies = [ "if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -386,7 +386,7 @@ dependencies = [ [[package]] name = "compiletest_rs" -version = "0.3.3" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1190,7 +1190,7 @@ version = "0.1.0" dependencies = [ "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "cargo_metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "compiletest_rs 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "compiletest_rs 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2941,7 +2941,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c06169f5beb7e31c7c67ebf5540b8b472d23e3eade3b2ec7d1f5b504a85f91bd" "checksum commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007" "checksum commoncrypto-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2" -"checksum compiletest_rs 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "562bafeec9aef1e3e08f1c5b0c542220bb80ff2894e5373a1f9d17c346412c66" +"checksum compiletest_rs 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6c5aafb5d4a77c6b5fa384fe93c7a9a3561bd88c4b8b8e45187cf5e779b1badc" "checksum core-foundation 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8047f547cd6856d45b1cdd75ef8d2f21f3d0e4bf1dab0a0041b0ae9a5dda9c0e" "checksum core-foundation-sys 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "152195421a2e6497a8179195672e9d4ee8e45ed8c465b626f1606d27a08ebcd5" "checksum crossbeam 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "bd66663db5a988098a89599d4857919b3acf7f61402e61365acfd3919857b9be" diff --git a/src/ci/docker/x86_64-gnu-tools/checktools.sh b/src/ci/docker/x86_64-gnu-tools/checktools.sh index b9268fe62ed06..61bb5a84d21ac 100755 --- a/src/ci/docker/x86_64-gnu-tools/checktools.sh +++ b/src/ci/docker/x86_64-gnu-tools/checktools.sh @@ -32,7 +32,7 @@ cat "$TOOLSTATE_FILE" # If this PR is intended to update one of these tools, do not let the build pass # when they do not test-pass. -for TOOL in rls rustfmt miri clippy; do +for TOOL in rls rustfmt clippy; do echo "Verifying status of $TOOL..." if echo "$CHANGED_FILES" | grep -q "^M[[:blank:]]src/tools/$TOOL$"; then echo "This PR updated 'src/tools/$TOOL', verifying if status is 'test-pass'..." diff --git a/src/tools/clippy b/src/tools/clippy index 7d7fef1690218..ce47e529d29f0 160000 --- a/src/tools/clippy +++ b/src/tools/clippy @@ -1 +1 @@ -Subproject commit 7d7fef1690218bbb406cf3bcadf7bb29dbb40cc5 +Subproject commit ce47e529d29f0bf19b31ae80b37b467e42fb97e2 diff --git a/src/tools/miri b/src/tools/miri index 919604e1ead82..61833b9aeab8b 160000 --- a/src/tools/miri +++ b/src/tools/miri @@ -1 +1 @@ -Subproject commit 919604e1ead8294c8ca14f101be4380ea1ea370c +Subproject commit 61833b9aeab8bf8f0c0c0e42b7c96b6eceb37d0d From a29d8545b573d008e364571a83fcd865748a8ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Thu, 16 Nov 2017 10:08:19 +0100 Subject: [PATCH 124/198] Make inline assembly volatile if it has no outputs. Fixes #46026 --- src/libsyntax_ext/asm.rs | 6 +++++ src/test/codegen/no-output-asm-is-volatile.rs | 26 +++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/test/codegen/no-output-asm-is-volatile.rs diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs index 3742fb8c804d7..d1de4dccd0043 100644 --- a/src/libsyntax_ext/asm.rs +++ b/src/libsyntax_ext/asm.rs @@ -239,6 +239,12 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, } } + // If there are no outputs, the inline assembly is executed just for its side effects, + // so ensure that it is volatile + if outputs.is_empty() { + volatile = true; + } + MacEager::expr(P(ast::Expr { id: ast::DUMMY_NODE_ID, node: ast::ExprKind::InlineAsm(P(ast::InlineAsm { diff --git a/src/test/codegen/no-output-asm-is-volatile.rs b/src/test/codegen/no-output-asm-is-volatile.rs new file mode 100644 index 0000000000000..457d706a8ffef --- /dev/null +++ b/src/test/codegen/no-output-asm-is-volatile.rs @@ -0,0 +1,26 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -O + +// ignore-asmjs + +#![feature(asm)] +#![crate_type = "lib"] + +// Check that inline assembly expressions without any outputs +// are marked as having side effects / being volatile + +// CHECK-LABEL: @assembly +#[no_mangle] +pub fn assembly() { + unsafe { asm!("") } +// CHECK: tail call void asm sideeffect "", {{.*}} +} From c83dd0306215e21ce5f8dab92edcc3ac9795f3da Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 5 Feb 2018 17:31:46 +0100 Subject: [PATCH 125/198] Clarify 'trait bounds ignored' wording --- src/librustc_typeck/collect.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 7a91827faef83..8b0d4248bbf28 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -388,8 +388,7 @@ fn ensure_no_ty_param_bounds(tcx: TyCtxt, // part of this PR. Still, convert to warning to // make bootstrapping easier. span_warn!(tcx.sess, span, E0122, - "trait bounds are not (yet) enforced \ - in {} definitions", + "trait bounds are ignored in {} definitions", thing); } } From 7be8e2fbb3745602ac864fc079a040dd3a80d91d Mon Sep 17 00:00:00 2001 From: O01eg Date: Mon, 5 Feb 2018 20:10:05 +0300 Subject: [PATCH 126/198] Add build.tools option to manage installation of extended rust tools. --- config.toml.example | 4 ++++ src/bootstrap/config.rs | 5 ++++- src/bootstrap/configure.py | 1 + src/bootstrap/install.rs | 21 ++++++++++++++------- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/config.toml.example b/config.toml.example index 75cab74258b6b..e69443f835d77 100644 --- a/config.toml.example +++ b/config.toml.example @@ -151,6 +151,10 @@ # default. #extended = false +# Installs choosen set of extended tools if enables. By default builds all. +# If choosen tool failed to build the installation fails. +#tools = ["cargo", "rls", "rustfmt", "analysis", "src"] + # Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose #verbose = 0 diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index be8910120ee19..4f4fd14ae8cab 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -13,7 +13,7 @@ //! This module implements parsing `config.toml` configuration files to tweak //! how the build runs. -use std::collections::HashMap; +use std::collections::{HashMap, HashSet}; use std::env; use std::fs::File; use std::io::prelude::*; @@ -52,6 +52,7 @@ pub struct Config { pub target_config: HashMap, Target>, pub full_bootstrap: bool, pub extended: bool, + pub tools: Option>, pub sanitizers: bool, pub profiler: bool, pub ignore_git: bool, @@ -191,6 +192,7 @@ struct Build { python: Option, full_bootstrap: Option, extended: Option, + tools: Option>, verbose: Option, sanitizers: Option, profiler: Option, @@ -395,6 +397,7 @@ impl Config { set(&mut config.vendor, build.vendor); set(&mut config.full_bootstrap, build.full_bootstrap); set(&mut config.extended, build.extended); + config.tools = build.tools; set(&mut config.verbose, build.verbose); set(&mut config.sanitizers, build.sanitizers); set(&mut config.profiler, build.profiler); diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index d51752a12d9e5..99a3ee4e4c369 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -144,6 +144,7 @@ def v(*args): o("full-bootstrap", "build.full-bootstrap", "build three compilers instead of two") o("extended", "build.extended", "build an extended rust tool set") +v("tools", "build.tools", "List of extended tools will be installed") v("build", "build.build", "GNUs ./configure syntax LLVM build triple") v("host", None, "GNUs ./configure syntax LLVM host triples") v("target", None, "GNUs ./configure syntax LLVM target triples") diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index 743f32ece99c6..86df36f209e6b 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -185,32 +185,39 @@ install!((self, builder, _config), install_std(builder, self.stage, *target); } }; - Cargo, "cargo", _config.extended, only_hosts: true, { + Cargo, "cargo", _config.extended && + _config.tools.as_ref().map_or(true, |t| t.contains("cargo")), only_hosts: true, { builder.ensure(dist::Cargo { stage: self.stage, target: self.target }); install_cargo(builder, self.stage, self.target); }; - Rls, "rls", _config.extended, only_hosts: true, { - if builder.ensure(dist::Rls { stage: self.stage, target: self.target }).is_some() { + Rls, "rls", _config.extended && + _config.tools.as_ref().map_or(true, |t| t.contains("rls")), only_hosts: true, { + if builder.ensure(dist::Rls { stage: self.stage, target: self.target }).is_some() || + builder.config.tools.as_ref().map_or(false, |t| t.contains("rls")) { install_rls(builder, self.stage, self.target); } else { println!("skipping Install RLS stage{} ({})", self.stage, self.target); } }; - Rustfmt, "rustfmt", _config.extended, only_hosts: true, { - if builder.ensure(dist::Rustfmt { stage: self.stage, target: self.target }).is_some() { + Rustfmt, "rustfmt", _config.extended && + _config.tools.as_ref().map_or(true, |t| t.contains("rustfmt")), only_hosts: true, { + if builder.ensure(dist::Rustfmt { stage: self.stage, target: self.target }).is_some() || + builder.config.tools.as_ref().map_or(false, |t| t.contains("rustfmt")) { install_rustfmt(builder, self.stage, self.target); } else { println!("skipping Install Rustfmt stage{} ({})", self.stage, self.target); } }; - Analysis, "analysis", _config.extended, only_hosts: false, { + Analysis, "analysis", _config.extended && + _config.tools.as_ref().map_or(true, |t| t.contains("analysis")), only_hosts: false, { builder.ensure(dist::Analysis { compiler: builder.compiler(self.stage, self.host), target: self.target }); install_analysis(builder, self.stage, self.target); }; - Src, "src", _config.extended, only_hosts: true, { + Src, "src", _config.extended && + _config.tools.as_ref().map_or(true, |t| t.contains("src")), only_hosts: true, { builder.ensure(dist::Src); install_src(builder, self.stage); }, ONLY_BUILD; From 27a4e73ca54f454d16cab7942ef9b27d5c942a32 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 5 Feb 2018 10:48:22 -0800 Subject: [PATCH 127/198] rustc: Add `#[rustc_args_required_const]` This commit adds a new unstable attribute to the compiler which requires that arguments to a function are always provided as constants. The primary use case for this is SIMD intrinsics where arguments are defined by vendors to be constant and in LLVM they indeed must be constant as well. For now this is mostly just a semantic guarantee in rustc that an argument is a constant when invoked, phases like trans don't actually take advantage of it yet. This means that we'll be able to use this in stdsimd but we won't be able to remove the `constify_*` macros just yet. Hopefully soon though! --- src/librustc_mir/transform/promote_consts.rs | 19 ++++---- src/librustc_mir/transform/qualify_consts.rs | 45 +++++++++++++++++-- .../compile-fail/rustc-args-required-const.rs | 36 +++++++++++++++ 3 files changed, 89 insertions(+), 11 deletions(-) create mode 100644 src/test/compile-fail/rustc-args-required-const.rs diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index 1545040f2da79..b732eeb624c6d 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -71,9 +71,12 @@ pub enum Candidate { /// Borrow of a constant temporary. Ref(Location), - /// Array of indices found in the third argument of - /// a call to one of the simd_shuffleN intrinsics. - ShuffleIndices(BasicBlock) + /// Currently applied to function calls where the callee has the unstable + /// `#[rustc_args_required_const]` attribute as well as the SIMD shuffle + /// intrinsic. The intrinsic requires the arguments are indeed constant and + /// the attribute currently provides the semantic requirement that arguments + /// must be constant. + Argument { bb: BasicBlock, index: usize }, } struct TempCollector<'tcx> { @@ -303,10 +306,10 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> { _ => bug!() } } - Candidate::ShuffleIndices(bb) => { + Candidate::Argument { bb, index } => { match self.source[bb].terminator_mut().kind { TerminatorKind::Call { ref mut args, .. } => { - Rvalue::Use(mem::replace(&mut args[2], new_operand)) + Rvalue::Use(mem::replace(&mut args[index], new_operand)) } _ => bug!() } @@ -359,15 +362,15 @@ pub fn promote_candidates<'a, 'tcx>(mir: &mut Mir<'tcx>, } (statement.source_info.span, dest.ty(mir, tcx).to_ty(tcx)) } - Candidate::ShuffleIndices(bb) => { + Candidate::Argument { bb, index } => { let terminator = mir[bb].terminator(); let ty = match terminator.kind { TerminatorKind::Call { ref args, .. } => { - args[2].ty(mir, tcx) + args[index].ty(mir, tcx) } _ => { span_bug!(terminator.source_info.span, - "expected simd_shuffleN call to promote"); + "expected call argument to promote"); } }; (terminator.source_info.span, ty) diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index da76adfd48f3f..297e0e491f694 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -17,6 +17,7 @@ use rustc_data_structures::bitvec::BitVector; use rustc_data_structures::indexed_set::IdxSetBuf; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; +use rustc_data_structures::fx::FxHashSet; use rustc::hir; use rustc::hir::def_id::DefId; use rustc::middle::const_val::ConstVal; @@ -30,6 +31,7 @@ use rustc::mir::visit::{PlaceContext, Visitor}; use rustc::middle::lang_items; use syntax::abi::Abi; use syntax::attr; +use syntax::ast::LitKind; use syntax::feature_gate::UnstableFeatures; use syntax_pos::{Span, DUMMY_SP}; @@ -407,7 +409,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { _ => {} } } - Candidate::ShuffleIndices(_) => {} + Candidate::Argument { .. } => {} } } @@ -730,8 +732,10 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { self.visit_operand(func, location); let fn_ty = func.ty(self.mir, self.tcx); + let mut callee_def_id = None; let (mut is_shuffle, mut is_const_fn) = (false, None); if let ty::TyFnDef(def_id, _) = fn_ty.sty { + callee_def_id = Some(def_id); match self.tcx.fn_sig(def_id).abi() { Abi::RustIntrinsic | Abi::PlatformIntrinsic => { @@ -754,17 +758,39 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } } + let constant_arguments = callee_def_id.and_then(|id| { + args_required_const(self.tcx, id) + }); for (i, arg) in args.iter().enumerate() { self.nest(|this| { this.visit_operand(arg, location); - if is_shuffle && i == 2 && this.mode == Mode::Fn { - let candidate = Candidate::ShuffleIndices(bb); + if this.mode != Mode::Fn { + return + } + let candidate = Candidate::Argument { bb, index: i }; + if is_shuffle && i == 2 { if this.can_promote() { this.promotion_candidates.push(candidate); } else { span_err!(this.tcx.sess, this.span, E0526, "shuffle indices are not constant"); } + return + } + + let constant_arguments = match constant_arguments.as_ref() { + Some(s) => s, + None => return, + }; + if !constant_arguments.contains(&i) { + return + } + if this.can_promote() { + this.promotion_candidates.push(candidate); + } else { + this.tcx.sess.span_err(this.span, + &format!("argument {} is required to be a constant", + i + 1)); } }); } @@ -1085,3 +1111,16 @@ impl MirPass for QualifyAndPromoteConstants { } } } + +fn args_required_const(tcx: TyCtxt, def_id: DefId) -> Option> { + let attrs = tcx.get_attrs(def_id); + let attr = attrs.iter().find(|a| a.check_name("rustc_args_required_const"))?; + let mut ret = FxHashSet(); + for meta in attr.meta_item_list()? { + match meta.literal()?.node { + LitKind::Int(a, _) => { ret.insert(a as usize); } + _ => return None, + } + } + Some(ret) +} diff --git a/src/test/compile-fail/rustc-args-required-const.rs b/src/test/compile-fail/rustc-args-required-const.rs new file mode 100644 index 0000000000000..aac9299eaafb9 --- /dev/null +++ b/src/test/compile-fail/rustc-args-required-const.rs @@ -0,0 +1,36 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(attr_literals, rustc_attrs, const_fn)] + +#[rustc_args_required_const(0)] +fn foo(_a: i32) { +} + +#[rustc_args_required_const(1)] +fn bar(_a: i32, _b: i32) { +} + +const A: i32 = 3; + +const fn baz() -> i32 { + 3 +} + +fn main() { + foo(2); + foo(2 + 3); + foo(baz()); + let a = 4; + foo(A); + foo(a); //~ ERROR: argument 1 is required to be a constant + bar(a, 3); + bar(a, a); //~ ERROR: argument 2 is required to be a constant +} From 5ca88ae6ae2f864dcdd924f099cdf6a345476196 Mon Sep 17 00:00:00 2001 From: bobtwinkles Date: Mon, 22 Jan 2018 17:15:06 -0500 Subject: [PATCH 128/198] Fix comment in ExprKind::LogicalOp The comment previously implied that the true branch would result in the false block. Fortunately the implementation is correct. --- src/librustc_mir/build/expr/into.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_mir/build/expr/into.rs b/src/librustc_mir/build/expr/into.rs index 68b23d1ae17e8..fa98dc8b110ad 100644 --- a/src/librustc_mir/build/expr/into.rs +++ b/src/librustc_mir/build/expr/into.rs @@ -104,8 +104,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // Or: // // [block: If(lhs)] -false-> [else_block: If(rhs)] -true-> [true_block] - // | | (false) - // +----------true------------+-------------------> [false_block] + // | (true) | (false) + // [true_block] [false_block] let (true_block, false_block, mut else_block, join_block) = (this.cfg.start_new_block(), this.cfg.start_new_block(), From bdc37aa05722818e8edb5d93825a62921f351913 Mon Sep 17 00:00:00 2001 From: bobtwinkles Date: Thu, 25 Jan 2018 01:45:45 -0500 Subject: [PATCH 129/198] mir: Add TerminatorKind::FalseUnwind Sometimes a simple goto misses the cleanup/unwind edges. Specifically, in the case of infinite loops such as those introduced by a loop statement without any other out edges. Analogous to TerminatorKind::FalseEdges; this new terminator kind is used when we want borrowck to consider an unwind path, but real control flow should never actually take it. --- src/librustc/ich/impls_mir.rs | 4 ++ src/librustc/mir/mod.rs | 39 ++++++++++++++++--- src/librustc/mir/visit.rs | 10 ++++- src/librustc_mir/borrow_check/mod.rs | 3 +- .../borrow_check/nll/type_check/mod.rs | 15 ++++++- src/librustc_mir/build/matches/mod.rs | 6 ++- src/librustc_mir/dataflow/impls/borrows.rs | 1 + src/librustc_mir/dataflow/mod.rs | 8 ++++ .../dataflow/move_paths/builder.rs | 1 + src/librustc_mir/interpret/terminator/mod.rs | 1 + src/librustc_mir/monomorphize/collector.rs | 3 +- src/librustc_mir/transform/check_unsafety.rs | 3 +- src/librustc_mir/transform/inline.rs | 3 ++ src/librustc_mir/transform/qualify_consts.rs | 3 +- .../transform/remove_noop_landing_pads.rs | 3 +- .../transform/simplify_branches.rs | 3 ++ src/librustc_passes/mir_stats.rs | 1 + src/librustc_trans/mir/analyze.rs | 3 +- src/librustc_trans/mir/block.rs | 5 ++- 19 files changed, 97 insertions(+), 18 deletions(-) diff --git a/src/librustc/ich/impls_mir.rs b/src/librustc/ich/impls_mir.rs index f46b590d2dc59..e78c2ad7c88b7 100644 --- a/src/librustc/ich/impls_mir.rs +++ b/src/librustc/ich/impls_mir.rs @@ -201,6 +201,10 @@ for mir::TerminatorKind<'gcx> { target.hash_stable(hcx, hasher); } } + mir::TerminatorKind::FalseUnwind { ref real_target, ref unwind } => { + real_target.hash_stable(hcx, hasher); + unwind.hash_stable(hcx, hasher); + } } } } diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index d82691f882c73..e7284a2716fd1 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -803,9 +803,28 @@ pub enum TerminatorKind<'tcx> { /// Indicates the end of the dropping of a generator GeneratorDrop, + /// A block where control flow only ever takes one real path, but borrowck + /// needs to be more conservative. FalseEdges { + /// The target normal control flow will take real_target: BasicBlock, - imaginary_targets: Vec + /// The list of blocks control flow could conceptually take, but won't + /// in practice + imaginary_targets: Vec, + }, + /// A terminator for blocks that only take one path in reality, but where we + /// reserve the right to unwind in borrowck, even if it won't happen in practice. + /// This can arise in infinite loops with no function calls for example. + FalseUnwind { + /// The target normal control flow will take + real_target: BasicBlock, + /// The imaginary cleanup block link. This particular path will never be taken + /// in practice, but in order to avoid fragility we want to always + /// consider it in borrowck. We don't want to accept programs which + /// pass borrowck only when panic=abort or some assertions are disabled + /// due to release vs. debug mode builds. This needs to be an Option because + /// of the remove_noop_landing_pads and no_landing_pads passes + unwind: Option, }, } @@ -865,6 +884,8 @@ impl<'tcx> TerminatorKind<'tcx> { s.extend_from_slice(imaginary_targets); s.into_cow() } + FalseUnwind { real_target: t, unwind: Some(u) } => vec![t, u].into_cow(), + FalseUnwind { real_target: ref t, unwind: None } => slice::from_ref(t).into_cow(), } } @@ -897,6 +918,8 @@ impl<'tcx> TerminatorKind<'tcx> { s.extend(imaginary_targets.iter_mut()); s } + FalseUnwind { real_target: ref mut t, unwind: Some(ref mut u) } => vec![t, u], + FalseUnwind { ref mut real_target, unwind: None } => vec![real_target], } } @@ -916,7 +939,8 @@ impl<'tcx> TerminatorKind<'tcx> { TerminatorKind::Call { cleanup: ref mut unwind, .. } | TerminatorKind::Assert { cleanup: ref mut unwind, .. } | TerminatorKind::DropAndReplace { ref mut unwind, .. } | - TerminatorKind::Drop { ref mut unwind, .. } => { + TerminatorKind::Drop { ref mut unwind, .. } | + TerminatorKind::FalseUnwind { ref mut unwind, .. } => { Some(unwind) } } @@ -1045,7 +1069,8 @@ impl<'tcx> TerminatorKind<'tcx> { write!(fmt, ")") }, - FalseEdges { .. } => write!(fmt, "falseEdges") + FalseEdges { .. } => write!(fmt, "falseEdges"), + FalseUnwind { .. } => write!(fmt, "falseUnwind"), } } @@ -1087,6 +1112,8 @@ impl<'tcx> TerminatorKind<'tcx> { l.resize(imaginary_targets.len() + 1, "imaginary".into()); l } + FalseUnwind { unwind: Some(_), .. } => vec!["real".into(), "cleanup".into()], + FalseUnwind { unwind: None, .. } => vec!["real".into()], } } } @@ -2189,7 +2216,8 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> { Return => Return, Unreachable => Unreachable, FalseEdges { real_target, ref imaginary_targets } => - FalseEdges { real_target, imaginary_targets: imaginary_targets.clone() } + FalseEdges { real_target, imaginary_targets: imaginary_targets.clone() }, + FalseUnwind { real_target, unwind } => FalseUnwind { real_target, unwind }, }; Terminator { source_info: self.source_info, @@ -2231,7 +2259,8 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> { Return | GeneratorDrop | Unreachable | - FalseEdges { .. } => false + FalseEdges { .. } | + FalseUnwind { .. } => false } } } diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index 57ed41f2f06e6..b26e1854d97fd 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -495,15 +495,21 @@ macro_rules! make_mir_visitor { self.visit_operand(value, source_location); self.visit_branch(block, resume); drop.map(|t| self.visit_branch(block, t)); - } - TerminatorKind::FalseEdges { real_target, ref imaginary_targets } => { + TerminatorKind::FalseEdges { real_target, ref imaginary_targets} => { self.visit_branch(block, real_target); for target in imaginary_targets { self.visit_branch(block, *target); } } + + TerminatorKind::FalseUnwind { real_target, unwind } => { + self.visit_branch(block, real_target); + if let Some(unwind) = unwind { + self.visit_branch(block, unwind); + } + } } } diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 9a6d83b8eb759..6a19392a6e88b 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -576,7 +576,8 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx TerminatorKind::Goto { target: _ } | TerminatorKind::Abort | TerminatorKind::Unreachable - | TerminatorKind::FalseEdges { .. } => { + | TerminatorKind::FalseEdges { real_target: _, imaginary_targets: _ } + | TerminatorKind::FalseUnwind { real_target: _, unwind: _ } => { // no data used, thus irrelevant to borrowck } } diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index c0c680a4ddcbc..7ca8d0bdd500b 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -796,7 +796,8 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { | TerminatorKind::GeneratorDrop | TerminatorKind::Unreachable | TerminatorKind::Drop { .. } - | TerminatorKind::FalseEdges { .. } => { + | TerminatorKind::FalseEdges { .. } + | TerminatorKind::FalseUnwind { .. } => { // no checks needed for these } @@ -1152,6 +1153,18 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { self.assert_iscleanup(mir, block_data, *target, is_cleanup); } } + TerminatorKind::FalseUnwind { + real_target, + unwind + } => { + self.assert_iscleanup(mir, block_data, real_target, is_cleanup); + if let Some(unwind) = unwind { + if is_cleanup { + span_mirbug!(self, block_data, "cleanup in cleanup block via false unwind"); + } + self.assert_iscleanup(mir, block_data, unwind, true); + } + } } } diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index 6cb9217776648..e2096bf5356c1 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -728,7 +728,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { TerminatorKind::FalseEdges { real_target: block, imaginary_targets: - vec![candidate.next_candidate_pre_binding_block]}); + vec![candidate.next_candidate_pre_binding_block], + }); self.bind_matched_candidate(block, candidate.bindings); @@ -749,7 +750,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { TerminatorKind::FalseEdges { real_target: otherwise, imaginary_targets: - vec![candidate.next_candidate_pre_binding_block] }); + vec![candidate.next_candidate_pre_binding_block], + }); Some(otherwise) } else { self.cfg.terminate(block, candidate_source_info, diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs index 80990bcc08089..ad6ac6876ce66 100644 --- a/src/librustc_mir/dataflow/impls/borrows.rs +++ b/src/librustc_mir/dataflow/impls/borrows.rs @@ -517,6 +517,7 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> { mir::TerminatorKind::Yield {..} | mir::TerminatorKind::Goto {..} | mir::TerminatorKind::FalseEdges {..} | + mir::TerminatorKind::FalseUnwind {..} | mir::TerminatorKind::Unreachable => {} } } diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index 291c22b5e1ed0..9c7d9b398cc56 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -864,6 +864,14 @@ impl<'a, 'tcx: 'a, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation self.propagate_bits_into_entry_set_for(in_out, changed, target); } } + mir::TerminatorKind::FalseUnwind { ref real_target, unwind } => { + self.propagate_bits_into_entry_set_for(in_out, changed, real_target); + if let Some(ref unwind) = unwind { + if !self.dead_unwinds.contains(&bb) { + self.propagate_bits_into_entry_set_for(in_out, changed, unwind); + } + } + } } } diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index cd36282eca0a6..635d99e7737a9 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -346,6 +346,7 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> { TerminatorKind::Abort | TerminatorKind::GeneratorDrop | TerminatorKind::FalseEdges { .. } | + TerminatorKind::FalseUnwind { .. } | TerminatorKind::Unreachable => { } TerminatorKind::Return => { diff --git a/src/librustc_mir/interpret/terminator/mod.rs b/src/librustc_mir/interpret/terminator/mod.rs index c8a0dbdd90308..606bda51edb1f 100644 --- a/src/librustc_mir/interpret/terminator/mod.rs +++ b/src/librustc_mir/interpret/terminator/mod.rs @@ -165,6 +165,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { Resume => unimplemented!(), Abort => unimplemented!(), FalseEdges { .. } => bug!("should have been eliminated by `simplify_branches` mir pass"), + FalseUnwind { .. } => bug!("should have been eliminated by `simplify_branches` mir pass"), Unreachable => return err!(Unreachable), } diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index f16187797d4e5..a80dfaef0dab1 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -636,7 +636,8 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { mir::TerminatorKind::Assert { .. } => {} mir::TerminatorKind::GeneratorDrop | mir::TerminatorKind::Yield { .. } | - mir::TerminatorKind::FalseEdges { .. } => bug!(), + mir::TerminatorKind::FalseEdges { .. } | + mir::TerminatorKind::FalseUnwind { .. } => bug!(), } self.super_terminator_kind(block, kind, location); diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index ae27f54e618a1..bbc7803b84d8e 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -76,7 +76,8 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> { TerminatorKind::Abort | TerminatorKind::Return | TerminatorKind::Unreachable | - TerminatorKind::FalseEdges { .. } => { + TerminatorKind::FalseEdges { .. } | + TerminatorKind::FalseUnwind { .. } => { // safe (at least as emitted during MIR construction) } diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index ceea97e3ed3b0..2d861921c9c8d 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -813,6 +813,9 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> { *target = self.update_target(*target); } } + TerminatorKind::FalseUnwind { real_target: _ , unwind: _ } => + // see the ordering of passes in the optimized_mir query. + bug!("False unwinds should have been removed before inlining") } } diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index da76adfd48f3f..741e39fe06880 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -327,7 +327,8 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } | TerminatorKind::Unreachable | - TerminatorKind::FalseEdges { .. } => None, + TerminatorKind::FalseEdges { .. } | + TerminatorKind::FalseUnwind { .. } => None, TerminatorKind::Return => { // Check for unused values. This usually means diff --git a/src/librustc_mir/transform/remove_noop_landing_pads.rs b/src/librustc_mir/transform/remove_noop_landing_pads.rs index e7cab469bc222..cd80d25c410f1 100644 --- a/src/librustc_mir/transform/remove_noop_landing_pads.rs +++ b/src/librustc_mir/transform/remove_noop_landing_pads.rs @@ -75,7 +75,8 @@ impl RemoveNoopLandingPads { TerminatorKind::Goto { .. } | TerminatorKind::Resume | TerminatorKind::SwitchInt { .. } | - TerminatorKind::FalseEdges { .. } => { + TerminatorKind::FalseEdges { .. } | + TerminatorKind::FalseUnwind { .. } => { terminator.successors().iter().all(|succ| { nop_landing_pads.contains(succ.index()) }) diff --git a/src/librustc_mir/transform/simplify_branches.rs b/src/librustc_mir/transform/simplify_branches.rs index 20c33bab1aacb..41089f567bd71 100644 --- a/src/librustc_mir/transform/simplify_branches.rs +++ b/src/librustc_mir/transform/simplify_branches.rs @@ -64,6 +64,9 @@ impl MirPass for SimplifyBranches { TerminatorKind::FalseEdges { real_target, .. } => { TerminatorKind::Goto { target: real_target } }, + TerminatorKind::FalseUnwind { real_target, .. } => { + TerminatorKind::Goto { target: real_target } + }, _ => continue }; } diff --git a/src/librustc_passes/mir_stats.rs b/src/librustc_passes/mir_stats.rs index b379a174b23f6..e4705674e2292 100644 --- a/src/librustc_passes/mir_stats.rs +++ b/src/librustc_passes/mir_stats.rs @@ -123,6 +123,7 @@ impl<'a, 'tcx> mir_visit::Visitor<'tcx> for StatCollector<'a, 'tcx> { TerminatorKind::GeneratorDrop => "TerminatorKind::GeneratorDrop", TerminatorKind::Yield { .. } => "TerminatorKind::Yield", TerminatorKind::FalseEdges { .. } => "TerminatorKind::FalseEdges", + TerminatorKind::FalseUnwind { .. } => "TerminatorKind::FalseUnwind", }, kind); self.super_terminator_kind(block, kind, location); } diff --git a/src/librustc_trans/mir/analyze.rs b/src/librustc_trans/mir/analyze.rs index bf82e1d50c473..f683703ce6d53 100644 --- a/src/librustc_trans/mir/analyze.rs +++ b/src/librustc_trans/mir/analyze.rs @@ -242,7 +242,8 @@ pub fn cleanup_kinds<'a, 'tcx>(mir: &mir::Mir<'tcx>) -> IndexVec { + TerminatorKind::FalseEdges { .. } | + TerminatorKind::FalseUnwind { .. } => { /* nothing to do */ } TerminatorKind::Call { cleanup: unwind, .. } | diff --git a/src/librustc_trans/mir/block.rs b/src/librustc_trans/mir/block.rs index af1e30a4b19a6..bb2a7840faee7 100644 --- a/src/librustc_trans/mir/block.rs +++ b/src/librustc_trans/mir/block.rs @@ -608,8 +608,9 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> { cleanup); } mir::TerminatorKind::GeneratorDrop | - mir::TerminatorKind::Yield { .. } | - mir::TerminatorKind::FalseEdges { .. } => bug!("generator ops in trans"), + mir::TerminatorKind::Yield { .. } => bug!("generator ops in trans"), + mir::TerminatorKind::FalseEdges { .. } | + mir::TerminatorKind::FalseUnwind { .. } => bug!("borrowck false edges in trans"), } } From ed6a2ebcd6d36f2e0760d419094a653bda984bc2 Mon Sep 17 00:00:00 2001 From: bobtwinkles Date: Fri, 26 Jan 2018 18:25:25 -0500 Subject: [PATCH 130/198] mir: Add false edge cleanup out of infinite loops Fixes #46036 --- src/librustc_mir/build/expr/into.rs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/librustc_mir/build/expr/into.rs b/src/librustc_mir/build/expr/into.rs index fa98dc8b110ad..089ce3f71a5ba 100644 --- a/src/librustc_mir/build/expr/into.rs +++ b/src/librustc_mir/build/expr/into.rs @@ -156,11 +156,15 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // // If `opt_cond_expr` is `None`, then the graph is somewhat simplified: // - // [block] --> [loop_block / body_block ] ~~> [body_block_end] [exit_block] - // ^ | - // | | - // +--------------------------+ + // [block] --> [loop_block] ~~> [loop_block_end] + // | ^ | + // false link | | + // | +-------------------+ + // v + // [cleanup_block] // + // The false link is required in case something results in + // unwinding through the body. let loop_block = this.cfg.start_new_block(); let exit_block = this.cfg.start_new_block(); @@ -174,6 +178,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { move |this| { // conduct the test, if necessary let body_block; + let out_terminator; if let Some(cond_expr) = opt_cond_expr { let loop_block_end; let cond = unpack!( @@ -187,8 +192,15 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // we have to do it; this overwrites any `break`-assigned value but it's // always `()` anyway this.cfg.push_assign_unit(exit_block, source_info, destination); + + out_terminator = TerminatorKind::Goto { target: loop_block }; } else { body_block = loop_block; + let diverge_cleanup = this.diverge_cleanup(); + out_terminator = TerminatorKind::FalseUnwind { + real_target: loop_block, + unwind: Some(diverge_cleanup) + } } // The “return” value of the loop body must always be an unit. We therefore @@ -197,7 +209,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // Execute the body, branching back to the test. let body_block_end = unpack!(this.into(&tmp, body_block, body)); this.cfg.terminate(body_block_end, source_info, - TerminatorKind::Goto { target: loop_block }); + out_terminator); } ); exit_block.unit() From eae1a35f554aa8149a71181354481b8b7a9b71bb Mon Sep 17 00:00:00 2001 From: bobtwinkles Date: Sat, 27 Jan 2018 05:18:12 -0500 Subject: [PATCH 131/198] mir: Add and fix tests for FalseUnwinds Fix instructions on existing mir-opt tests after introducing false edges from loops. Also, add a test for issue 46036: infinite loops. --- src/test/compile-fail/issue-46036.rs | 23 +++++++++++++++++++++++ src/test/mir-opt/end_region_2.rs | 9 ++++++--- src/test/mir-opt/end_region_3.rs | 9 ++++++--- src/test/mir-opt/end_region_9.rs | 14 ++++++++------ src/test/mir-opt/end_region_cyclic.rs | 2 +- src/test/mir-opt/issue-38669.rs | 14 ++++++++------ 6 files changed, 52 insertions(+), 19 deletions(-) create mode 100644 src/test/compile-fail/issue-46036.rs diff --git a/src/test/compile-fail/issue-46036.rs b/src/test/compile-fail/issue-46036.rs new file mode 100644 index 0000000000000..b5cdded4d304a --- /dev/null +++ b/src/test/compile-fail/issue-46036.rs @@ -0,0 +1,23 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Issue 46036: [NLL] false edges on infinite loops +// Infinite loops should create false edges to the cleanup block. +#![feature(nll)] + +struct Foo { x: &'static u32 } + +fn foo() { + let a = 3; + let foo = Foo { x: &a }; //~ ERROR E0597 + loop { } +} + +fn main() { } diff --git a/src/test/mir-opt/end_region_2.rs b/src/test/mir-opt/end_region_2.rs index 56c3e2a38a0ed..958e9364c8fa8 100644 --- a/src/test/mir-opt/end_region_2.rs +++ b/src/test/mir-opt/end_region_2.rs @@ -46,9 +46,12 @@ fn main() { // _3 = &'23_1rs _2; // StorageLive(_5); // _5 = _2; -// switchInt(move _5) -> [0u8: bb3, otherwise: bb2]; +// switchInt(move _5) -> [0u8: bb4, otherwise: bb3]; // } // bb2: { +// ... +// } +// bb3: { // _0 = (); // StorageDead(_5); // EndRegion('23_1rs); @@ -56,7 +59,7 @@ fn main() { // StorageDead(_2); // return; // } -// bb3: { +// bb4: { // _4 = (); // StorageDead(_5); // StorageLive(_7); @@ -67,6 +70,6 @@ fn main() { // EndRegion('23_1rs); // StorageDead(_3); // StorageDead(_2); -// goto -> bb1; +// falseUnwind -> [real: bb1, cleanup: bb2]; // } // END rustc.main.SimplifyCfg-qualify-consts.after.mir diff --git a/src/test/mir-opt/end_region_3.rs b/src/test/mir-opt/end_region_3.rs index 8c0d56eba7828..c1ebc525e88ed 100644 --- a/src/test/mir-opt/end_region_3.rs +++ b/src/test/mir-opt/end_region_3.rs @@ -48,9 +48,12 @@ fn main() { // _3 = &'26_1rs _1; // StorageLive(_5); // _5 = _1; -// switchInt(move _5) -> [0u8: bb3, otherwise: bb2]; +// switchInt(move _5) -> [0u8: bb4, otherwise: bb3]; // } // bb2: { +// ... +// } +// bb3: { // _0 = (); // StorageDead(_5); // EndRegion('26_1rs); @@ -58,7 +61,7 @@ fn main() { // StorageDead(_1); // return; // } -// bb3: { +// bb4: { // _4 = (); // StorageDead(_5); // StorageLive(_7); @@ -68,6 +71,6 @@ fn main() { // StorageDead(_7); // EndRegion('26_1rs); // StorageDead(_3); -// goto -> bb1; +// falseUnwind -> [real: bb1, cleanup: bb2]; // } // END rustc.main.SimplifyCfg-qualify-consts.after.mir diff --git a/src/test/mir-opt/end_region_9.rs b/src/test/mir-opt/end_region_9.rs index b313e296ac99c..70611306fd328 100644 --- a/src/test/mir-opt/end_region_9.rs +++ b/src/test/mir-opt/end_region_9.rs @@ -58,15 +58,17 @@ fn main() { // StorageLive(_2); // _2 = const 3i32; // StorageLive(_4); -// goto -> bb1; +// goto -> bb2; // } -// // bb1: { +// ... +// } +// bb2: { // StorageLive(_7); // _7 = _1; -// switchInt(move _7) -> [0u8: bb3, otherwise: bb2]; +// switchInt(move _7) -> [0u8: bb4, otherwise: bb3]; // } -// bb2: { +// bb3: { // _0 = (); // StorageDead(_7); // EndRegion('33_0rs); @@ -75,13 +77,13 @@ fn main() { // StorageDead(_1); // return; // } -// bb3: { +// bb4: { // _4 = &'33_0rs _2; // _6 = (); // StorageDead(_7); // _1 = const true; // _3 = (); -// goto -> bb1; +// falseUnwind -> [real: bb2, cleanup: bb1]; // } // } // END rustc.main.SimplifyCfg-qualify-consts.after.mir diff --git a/src/test/mir-opt/end_region_cyclic.rs b/src/test/mir-opt/end_region_cyclic.rs index 37a6229febabb..801c4eed4d20b 100644 --- a/src/test/mir-opt/end_region_cyclic.rs +++ b/src/test/mir-opt/end_region_cyclic.rs @@ -131,7 +131,7 @@ fn query() -> bool { true } // _1 = (); // EndRegion('35_0rs); // StorageDead(_2); -// goto -> bb1; +// falseUnwind -> [real: bb1, cleanup: bb2]; // } // } // END rustc.main.SimplifyCfg-qualify-consts.after.mir diff --git a/src/test/mir-opt/issue-38669.rs b/src/test/mir-opt/issue-38669.rs index b5c188cf834a9..4444d96798fcf 100644 --- a/src/test/mir-opt/issue-38669.rs +++ b/src/test/mir-opt/issue-38669.rs @@ -25,27 +25,29 @@ fn main() { // bb0: { // StorageLive(_1); // _1 = const false; -// goto -> bb1; +// goto -> bb2; // } // // bb1: { +// resume; +// } +// bb2: { // StorageLive(_4); // _4 = _1; -// switchInt(move _4) -> [0u8: bb3, otherwise: bb2]; +// switchInt(move _4) -> [0u8: bb4, otherwise: bb3]; // } -// -// bb2: { +// bb3: { // _0 = (); // StorageDead(_4); // StorageDead(_1); // return; // } // -// bb3: { +// bb4: { // _3 = (); // StorageDead(_4); // _1 = const true; // _2 = (); -// goto -> bb1; +// falseUnwind -> [real: bb2, cleanup: bb1]; // } // END rustc.main.SimplifyCfg-initial.after.mir From 2aae22746e70eea96b0959f6e7b603576e14f3bb Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 5 Feb 2018 21:20:57 +0100 Subject: [PATCH 132/198] Warn about more ignored bounds on type aliases --- src/librustc_typeck/collect.rs | 35 ++++++++----------- src/test/compile-fail/dst-bad-assign-3.rs | 2 +- .../compile-fail/private-in-public-warn.rs | 2 +- src/test/ui/param-bounds-ignored.rs | 33 +++++++++++++++++ src/test/ui/param-bounds-ignored.stderr | 18 ++++++++++ 5 files changed, 68 insertions(+), 22 deletions(-) create mode 100644 src/test/ui/param-bounds-ignored.rs create mode 100644 src/test/ui/param-bounds-ignored.stderr diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 8b0d4248bbf28..ecef168dcadd2 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -355,40 +355,35 @@ fn is_param<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } } -fn ensure_no_ty_param_bounds(tcx: TyCtxt, - span: Span, - generics: &hir::Generics, - thing: &'static str) { +fn ensure_no_param_bounds(tcx: TyCtxt, + span: Span, + generics: &hir::Generics, + thing: &'static str) { let mut warn = false; for ty_param in generics.ty_params() { - for bound in ty_param.bounds.iter() { - match *bound { - hir::TraitTyParamBound(..) => { - warn = true; - } - hir::RegionTyParamBound(..) => { } - } + if !ty_param.bounds.is_empty() { + warn = true; } } - for predicate in generics.where_clause.predicates.iter() { - match *predicate { - hir::WherePredicate::BoundPredicate(..) => { - warn = true; - } - hir::WherePredicate::RegionPredicate(..) => { } - hir::WherePredicate::EqPredicate(..) => { } + for lft_param in generics.lifetimes() { + if !lft_param.bounds.is_empty() { + warn = true; } } + if !generics.where_clause.predicates.is_empty() { + warn = true; + } + if warn { // According to accepted RFC #XXX, we should // eventually accept these, but it will not be // part of this PR. Still, convert to warning to // make bootstrapping easier. span_warn!(tcx.sess, span, E0122, - "trait bounds are ignored in {} definitions", + "bounds are ignored in {}", thing); } } @@ -454,7 +449,7 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) { } }, hir::ItemTy(_, ref generics) => { - ensure_no_ty_param_bounds(tcx, it.span, generics, "type"); + ensure_no_param_bounds(tcx, it.span, generics, "type aliases"); tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); diff --git a/src/test/compile-fail/dst-bad-assign-3.rs b/src/test/compile-fail/dst-bad-assign-3.rs index 1c3bad5ba5643..759da7b2bde21 100644 --- a/src/test/compile-fail/dst-bad-assign-3.rs +++ b/src/test/compile-fail/dst-bad-assign-3.rs @@ -13,7 +13,7 @@ #![feature(unsized_tuple_coercion)] type Fat = (isize, &'static str, T); -//~^ WARNING trait bounds are not (yet) enforced +//~^ WARNING bounds are ignored #[derive(PartialEq,Eq)] struct Bar; diff --git a/src/test/compile-fail/private-in-public-warn.rs b/src/test/compile-fail/private-in-public-warn.rs index dfcf4dc01b8ab..aa91ce27c379a 100644 --- a/src/test/compile-fail/private-in-public-warn.rs +++ b/src/test/compile-fail/private-in-public-warn.rs @@ -58,7 +58,7 @@ mod traits { pub trait PubTr {} pub type Alias = T; //~ ERROR private trait `traits::PrivTr` in public interface - //~^ WARN trait bounds are not (yet) enforced in type definitions + //~^ WARN bounds are ignored in type aliases //~| WARNING hard error pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in public interface //~^ WARNING hard error diff --git a/src/test/ui/param-bounds-ignored.rs b/src/test/ui/param-bounds-ignored.rs new file mode 100644 index 0000000000000..9e09102f2d439 --- /dev/null +++ b/src/test/ui/param-bounds-ignored.rs @@ -0,0 +1,33 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// must-compile-successfully + +use std::rc::Rc; + +type SVec = Vec; +type VVec<'b, 'a: 'b> = Vec<&'a i32>; +type WVec<'b, T: 'b> = Vec; + +fn foo<'a>(y: &'a i32) { + // If the bounds above would matter, the code below would be rejected. + let mut x : SVec<_> = Vec::new(); + x.push(Rc::new(42)); + + let mut x : VVec<'static, 'a> = Vec::new(); + x.push(y); + + let mut x : WVec<'static, & 'a i32> = Vec::new(); + x.push(y); +} + +fn main() { + foo(&42); +} diff --git a/src/test/ui/param-bounds-ignored.stderr b/src/test/ui/param-bounds-ignored.stderr new file mode 100644 index 0000000000000..a14d416aaa733 --- /dev/null +++ b/src/test/ui/param-bounds-ignored.stderr @@ -0,0 +1,18 @@ +warning[E0122]: bounds are ignored in type aliases + --> $DIR/param-bounds-ignored.rs:15:1 + | +15 | type SVec = Vec; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning[E0122]: bounds are ignored in type aliases + --> $DIR/param-bounds-ignored.rs:16:1 + | +16 | type VVec<'b, 'a: 'b> = Vec<&'a i32>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning[E0122]: bounds are ignored in type aliases + --> $DIR/param-bounds-ignored.rs:17:1 + | +17 | type WVec<'b, T: 'b> = Vec; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + From 5cd4b4fd955ac57f64f45e175844c0e7e165989f Mon Sep 17 00:00:00 2001 From: David Wood Date: Mon, 5 Feb 2018 22:31:56 +0000 Subject: [PATCH 133/198] Swapped order of left/right visits to ensure consistency in read/write pass ordering when -O is passed. --- src/librustc_mir/borrow_check/mod.rs | 14 +++++++------- .../nll/reference-carried-through-struct-field.rs | 2 +- src/test/ui/issue-45697.rs | 2 +- src/test/ui/issue-45697.stderr | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 95dd8dd48a0b1..07d6ce20821ed 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -347,6 +347,13 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx match stmt.kind { StatementKind::Assign(ref lhs, ref rhs) => { + self.consume_rvalue( + ContextKind::AssignRhs.new(location), + (rhs, span), + location, + flow_state, + ); + self.mutate_place( ContextKind::AssignLhs.new(location), (lhs, span), @@ -354,13 +361,6 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx JustWrite, flow_state, ); - - self.consume_rvalue( - ContextKind::AssignRhs.new(location), - (rhs, span), - location, - flow_state, - ); } StatementKind::SetDiscriminant { ref place, diff --git a/src/test/compile-fail/nll/reference-carried-through-struct-field.rs b/src/test/compile-fail/nll/reference-carried-through-struct-field.rs index e64fecbe701e7..efa6cc273b6f4 100644 --- a/src/test/compile-fail/nll/reference-carried-through-struct-field.rs +++ b/src/test/compile-fail/nll/reference-carried-through-struct-field.rs @@ -19,7 +19,7 @@ fn foo() { let mut x = 22; let wrapper = Wrap { w: &mut x }; x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506] - //[mir]~^ ERROR cannot assign to `x` because it is borrowed [E0506] + //[mir]~^ ERROR cannot use `x` because it was mutably borrowed [E0503] *wrapper.w += 1; } diff --git a/src/test/ui/issue-45697.rs b/src/test/ui/issue-45697.rs index 7f44209d717a1..b69ba97cc9b4d 100644 --- a/src/test/ui/issue-45697.rs +++ b/src/test/ui/issue-45697.rs @@ -29,7 +29,7 @@ fn main() { let z = copy_borrowed_ptr(&mut y); *y.pointer += 1; //~^ ERROR cannot assign to `*y.pointer` because it is borrowed (Ast) [E0506] - //~| ERROR cannot assign to `*y.pointer` because it is borrowed (Mir) [E0506] + //~| ERROR cannot use `*y.pointer` because it was mutably borrowed (Mir) [E0503] *z.pointer += 1; } } diff --git a/src/test/ui/issue-45697.stderr b/src/test/ui/issue-45697.stderr index 007bfbfc9b01e..e9b723d57b507 100644 --- a/src/test/ui/issue-45697.stderr +++ b/src/test/ui/issue-45697.stderr @@ -6,13 +6,13 @@ error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast) 30 | *y.pointer += 1; | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here -error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Mir) +error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir) --> $DIR/issue-45697.rs:30:9 | 29 | let z = copy_borrowed_ptr(&mut y); - | ------ borrow of `*y.pointer` occurs here + | ------ borrow of `y` occurs here 30 | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here + | ^^^^^^^^^^^^^^^ use of borrowed `y` error: aborting due to 2 previous errors From b55e07ee50c9e4d00b6fc13dc27d45bd03a7965d Mon Sep 17 00:00:00 2001 From: "Zack M. Davis" Date: Mon, 5 Feb 2018 18:09:51 -0800 Subject: [PATCH 134/198] correct E0619 span re method call receivers whose type must be known Previously, when the type of a method receiver could not be determined, the error message would, potentially confusingly, highlight the span of the entire method call. Resolves #36598, resolves #42234. --- src/librustc_typeck/check/mod.rs | 2 +- .../span/issue-42234-unknown-receiver-type.rs | 27 +++++++++++++++++++ .../issue-42234-unknown-receiver-type.stderr | 15 +++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/span/issue-42234-unknown-receiver-type.rs create mode 100644 src/test/ui/span/issue-42234-unknown-receiver-type.stderr diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 363d4a9dc0cd3..f044b2c711e20 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -2925,7 +2925,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let rcvr = &args[0]; let rcvr_t = self.check_expr_with_needs(&rcvr, needs); // no need to check for bot/err -- callee does that - let rcvr_t = self.structurally_resolved_type(expr.span, rcvr_t); + let rcvr_t = self.structurally_resolved_type(args[0].span, rcvr_t); let method = match self.lookup_method(rcvr_t, segment, diff --git a/src/test/ui/span/issue-42234-unknown-receiver-type.rs b/src/test/ui/span/issue-42234-unknown-receiver-type.rs new file mode 100644 index 0000000000000..d9cdd99c245e6 --- /dev/null +++ b/src/test/ui/span/issue-42234-unknown-receiver-type.rs @@ -0,0 +1,27 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// When the type of a method call's receiver is unknown, the span should point +// to the receiver (and not the entire call, as was previously the case before +// the fix of which this tests). + +fn shines_a_beacon_through_the_darkness() { + let x: Option<_> = None; + x.unwrap().method_that_could_exist_on_some_type(); + //~^ ERROR 17:5: 17:15: the type of this value must be known in this context +} + +fn courier_to_des_moines_and_points_west(data: &[u32]) -> String { + data.iter() //~ ERROR 22:5: 23:20: the type of this value must be known in this context + .sum::<_>() + .to_string() +} + +fn main() {} diff --git a/src/test/ui/span/issue-42234-unknown-receiver-type.stderr b/src/test/ui/span/issue-42234-unknown-receiver-type.stderr new file mode 100644 index 0000000000000..ed756cdc553ce --- /dev/null +++ b/src/test/ui/span/issue-42234-unknown-receiver-type.stderr @@ -0,0 +1,15 @@ +error[E0619]: the type of this value must be known in this context + --> $DIR/issue-42234-unknown-receiver-type.rs:17:5 + | +17 | x.unwrap().method_that_could_exist_on_some_type(); + | ^^^^^^^^^^ + +error[E0619]: the type of this value must be known in this context + --> $DIR/issue-42234-unknown-receiver-type.rs:22:5 + | +22 | / data.iter() //~ ERROR 22:5: 23:20: the type of this value must be known in this context +23 | | .sum::<_>() + | |___________________^ + +error: aborting due to 2 previous errors + From 2cff123416cf62648ddbe7aab387aabe1a01314f Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sun, 4 Feb 2018 22:22:26 +0530 Subject: [PATCH 135/198] Add -Zepoch --- src/librustc/lib.rs | 1 + src/librustc/session/config.rs | 45 ++++++++++++++++++++++++++++++++-- src/librustc/session/mod.rs | 7 +++++- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index db6863d6dadc2..a7a2619505931 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -58,6 +58,7 @@ #![feature(macro_vis_matcher)] #![feature(match_default_bindings)] #![feature(never_type)] +#![feature(non_exhaustive)] #![feature(nonzero)] #![feature(quote)] #![feature(refcell_replace_swap)] diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 9543d01597d04..f1590f4aced45 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -112,6 +112,31 @@ pub enum OutputType { DepInfo, } +/// The epoch of the compiler (RFC 2052) +#[derive(Clone, Copy, Hash, PartialOrd, Ord, Eq, PartialEq)] +#[non_exhaustive] +pub enum Epoch { + // epochs must be kept in order, newest to oldest + + /// The 2015 epoch + Epoch2015, + /// The 2018 epoch + Epoch2018, + + // when adding new epochs, be sure to update: + // + // - the list in the `parse_epoch` static + // - the match in the `parse_epoch` function + // - add a `rust_####()` function to the session + // - update the enum in Cargo's sources as well + // + // When -Zepoch becomes --epoch, there will + // also be a check for the epoch being nightly-only + // somewhere. That will need to be updated + // whenever we're stabilizing/introducing a new epoch + // as well as changing the default Cargo template. +} + impl_stable_hash_for!(enum self::OutputType { Bitcode, Assembly, @@ -802,11 +827,13 @@ macro_rules! options { Some("`string` or `string=string`"); pub const parse_lto: Option<&'static str> = Some("one of `thin`, `fat`, or omitted"); + pub const parse_epoch: Option<&'static str> = + Some("one of: `2015`, `2018`"); } #[allow(dead_code)] mod $mod_set { - use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer, Lto}; + use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer, Lto, Epoch}; use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel}; use std::path::PathBuf; @@ -1010,6 +1037,15 @@ macro_rules! options { }; true } + + fn parse_epoch(slot: &mut Epoch, v: Option<&str>) -> bool { + match v { + Some("2015") => *slot = Epoch::Epoch2015, + Some("2018") => *slot = Epoch::Epoch2018, + _ => return false, + } + true + } } ) } @@ -1297,6 +1333,10 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, `everybody_loops` (all function bodies replaced with `loop {}`), `hir` (the HIR), `hir,identified`, or `hir,typed` (HIR with types for each node)."), + epoch: Epoch = (Epoch::Epoch2015, parse_epoch, [TRACKED], + "The epoch to build Rust with. Newer epochs may include features + that require breaking changes. The default epoch is 2015 (the first + epoch). Crates compiled with different epochs can be linked together."), } pub fn default_lib_output() -> CrateType { @@ -2088,7 +2128,7 @@ mod dep_tracking { use std::path::PathBuf; use std::collections::hash_map::DefaultHasher; use super::{Passes, CrateType, OptLevel, DebugInfoLevel, Lto, - OutputTypes, Externs, ErrorOutputType, Sanitizer}; + OutputTypes, Externs, ErrorOutputType, Sanitizer, Epoch}; use syntax::feature_gate::UnstableFeatures; use rustc_back::{PanicStrategy, RelroLevel}; @@ -2150,6 +2190,7 @@ mod dep_tracking { impl_dep_tracking_hash_via_hash!(cstore::NativeLibraryKind); impl_dep_tracking_hash_via_hash!(Sanitizer); impl_dep_tracking_hash_via_hash!(Option); + impl_dep_tracking_hash_via_hash!(Epoch); impl_dep_tracking_hash_for_sortable_vec_of!(String); impl_dep_tracking_hash_for_sortable_vec_of!(PathBuf); diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index f4a00a43d8d92..9d7a9acc3d533 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -19,7 +19,7 @@ use lint; use middle::allocator::AllocatorKind; use middle::dependency_format; use session::search_paths::PathKind; -use session::config::{BorrowckMode, DebugInfoLevel, OutputType}; +use session::config::{BorrowckMode, DebugInfoLevel, OutputType, Epoch}; use ty::tls; use util::nodemap::{FxHashMap, FxHashSet}; use util::common::{duration_to_secs_str, ErrorReported}; @@ -864,6 +864,11 @@ impl Session { pub fn teach(&self, code: &DiagnosticId) -> bool { self.opts.debugging_opts.teach && !self.parse_sess.span_diagnostic.code_emitted(code) } + + /// Are we allowed to use features from the Rust 2018 epoch? + pub fn rust_2018(&self) -> bool { + self.opts.debugging_opts.epoch >= Epoch::Epoch2018 + } } pub fn build_session(sopts: config::Options, From d0ab8f03bbc0e0694b6b8c411c5b39b89c2fe821 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 5 Feb 2018 01:45:43 +0530 Subject: [PATCH 136/198] Convert tyvar_behind_raw_pointer to hard error for the 2018 epoch --- src/librustc_typeck/check/method/probe.rs | 18 ++++++++++++------ src/librustc_typeck/diagnostics.rs | 1 + 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index c88bbd03af82b..e8c3966f23f08 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -326,13 +326,19 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if reached_raw_pointer && !self.tcx.sess.features.borrow().arbitrary_self_types { // this case used to be allowed by the compiler, - // so we do a future-compat lint here + // so we do a future-compat lint here for the 2015 epoch // (see https://github.com/rust-lang/rust/issues/46906) - self.tcx.lint_node( - lint::builtin::TYVAR_BEHIND_RAW_POINTER, - scope_expr_id, - span, - &format!("the type of this value must be known in this context")); + if self.tcx.sess.rust_2018() { + span_err!(self.tcx.sess, span, E0908, + "the type of this value must be known \ + to call a method on a raw pointer on it"); + } else { + self.tcx.lint_node( + lint::builtin::TYVAR_BEHIND_RAW_POINTER, + scope_expr_id, + span, + &format!("the type of this value must be known in this context")); + } } else { let t = self.structurally_resolved_type(span, final_ty); assert_eq!(t, self.tcx.types.err); diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index ac7f54250d32b..ea9b5473ed103 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -4777,4 +4777,5 @@ register_diagnostics! { E0641, // cannot cast to/from a pointer with an unknown kind E0645, // trait aliases not finished E0907, // type inside generator must be known in this context + E0908, // methods on raw pointers can only be called if the pointer type is fully known } From 8d8ba812d01d1284c8bdaa728df4deae865fd1d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Tue, 6 Feb 2018 12:59:06 +0100 Subject: [PATCH 137/198] config.toml.example: fix typos. Most of them were found by codespell: https://github.com/lucasdemarchi/codespell --- config.toml.example | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config.toml.example b/config.toml.example index 75cab74258b6b..c2ec731eeb8a2 100644 --- a/config.toml.example +++ b/config.toml.example @@ -295,7 +295,7 @@ # Flag indicating whether git info will be retrieved from .git automatically. # Having the git information can cause a lot of rebuilds during development. -# Note: If this attribute is not explicity set (e.g. if left commented out) it +# Note: If this attribute is not explicitly set (e.g. if left commented out) it # will default to true if channel = "dev", but will default to false otherwise. #ignore-git = true @@ -317,8 +317,8 @@ # bootstrap) #codegen-backends = ["llvm"] -# Flag indicating whether `libstd` calls an imported function to hande basic IO -# when targetting WebAssembly. Enable this to debug tests for the `wasm32-unknown-unknown` +# Flag indicating whether `libstd` calls an imported function to handle basic IO +# when targeting WebAssembly. Enable this to debug tests for the `wasm32-unknown-unknown` # target, as without this option the test output will not be captured. #wasm-syscall = false @@ -349,7 +349,7 @@ #linker = "cc" # Path to the `llvm-config` binary of the installation of a custom LLVM to link -# against. Note that if this is specifed we don't compile LLVM at all for this +# against. Note that if this is specified we don't compile LLVM at all for this # target. #llvm-config = "../path/to/llvm/root/bin/llvm-config" From 3cf73f40fb7217471dfe7394b73e67f53cfefc49 Mon Sep 17 00:00:00 2001 From: Alex Burka Date: Tue, 6 Feb 2018 14:43:01 +0000 Subject: [PATCH 138/198] proc_macro: don't panic parsing ..= (fix #47950) --- src/libproc_macro/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index b9e816baac0dc..6768e0ade4304 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -685,7 +685,7 @@ impl TokenTree { }) } - DotEq => unreachable!(), + DotEq => joint!('.', Eq), OpenDelim(..) | CloseDelim(..) => unreachable!(), Whitespace | Comment | Shebang(..) | Eof => unreachable!(), }; From fefd5e9bbc150273faf2ac0c4dff8e0e8a098393 Mon Sep 17 00:00:00 2001 From: QuietMisdreavus Date: Tue, 6 Feb 2018 09:26:15 -0600 Subject: [PATCH 139/198] fix docs link --- src/libstd/os/raw/uint.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/os/raw/uint.md b/src/libstd/os/raw/uint.md index 1e710f804c445..6f7013a8ac18d 100644 --- a/src/libstd/os/raw/uint.md +++ b/src/libstd/os/raw/uint.md @@ -1,6 +1,6 @@ Equivalent to C's `unsigned int` type. -This type will almost always be [`u16`], but may differ on some esoteric systems. The C standard technically only requires that this type be an unsigned integer with the same size as an [`int`]; some systems define it as a [`u16`], for example. +This type will almost always be [`u32`], but may differ on some esoteric systems. The C standard technically only requires that this type be an unsigned integer with the same size as an [`int`]; some systems define it as a [`u16`], for example. [`int`]: type.c_int.html [`u32`]: ../../primitive.u32.html From ac183f83df4bf43bc5d8c5e5f2c5d4297a0b3755 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 6 Feb 2018 16:28:25 +0100 Subject: [PATCH 140/198] improve wording: bounds -> generic bounds --- src/librustc_typeck/collect.rs | 2 +- src/test/ui/param-bounds-ignored.stderr | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index ecef168dcadd2..d5328a18c2240 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -383,7 +383,7 @@ fn ensure_no_param_bounds(tcx: TyCtxt, // part of this PR. Still, convert to warning to // make bootstrapping easier. span_warn!(tcx.sess, span, E0122, - "bounds are ignored in {}", + "generic bounds are ignored in {}", thing); } } diff --git a/src/test/ui/param-bounds-ignored.stderr b/src/test/ui/param-bounds-ignored.stderr index a14d416aaa733..19aa9c5d6e562 100644 --- a/src/test/ui/param-bounds-ignored.stderr +++ b/src/test/ui/param-bounds-ignored.stderr @@ -1,16 +1,16 @@ -warning[E0122]: bounds are ignored in type aliases +warning[E0122]: generic bounds are ignored in type aliases --> $DIR/param-bounds-ignored.rs:15:1 | 15 | type SVec = Vec; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning[E0122]: bounds are ignored in type aliases +warning[E0122]: generic bounds are ignored in type aliases --> $DIR/param-bounds-ignored.rs:16:1 | 16 | type VVec<'b, 'a: 'b> = Vec<&'a i32>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning[E0122]: bounds are ignored in type aliases +warning[E0122]: generic bounds are ignored in type aliases --> $DIR/param-bounds-ignored.rs:17:1 | 17 | type WVec<'b, T: 'b> = Vec; From bb6e54d4bc7d4ce4c2372fecb84222867374b135 Mon Sep 17 00:00:00 2001 From: David Wood Date: Tue, 6 Feb 2018 17:37:49 +0000 Subject: [PATCH 141/198] Added and updated tests to enable/disable overflow checks. --- src/test/ui/issue-45697-1.rs | 35 ++++++++++++++++++++++++++++++++ src/test/ui/issue-45697-1.stderr | 18 ++++++++++++++++ src/test/ui/issue-45697.rs | 2 +- 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/issue-45697-1.rs create mode 100644 src/test/ui/issue-45697-1.stderr diff --git a/src/test/ui/issue-45697-1.rs b/src/test/ui/issue-45697-1.rs new file mode 100644 index 0000000000000..7734b14b2ab7b --- /dev/null +++ b/src/test/ui/issue-45697-1.rs @@ -0,0 +1,35 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that assignments to an `&mut` pointer which is found in a +// borrowed (but otherwise non-aliasable) location is illegal. + +// compile-flags: -Z emit-end-regions -Z borrowck=compare -C overflow-checks=on + +struct S<'a> { + pointer: &'a mut isize +} + +fn copy_borrowed_ptr<'a>(p: &'a mut S<'a>) -> S<'a> { + S { pointer: &mut *p.pointer } +} + +fn main() { + let mut x = 1; + + { + let mut y = S { pointer: &mut x }; + let z = copy_borrowed_ptr(&mut y); + *y.pointer += 1; + //~^ ERROR cannot assign to `*y.pointer` because it is borrowed (Ast) [E0506] + //~| ERROR cannot use `*y.pointer` because it was mutably borrowed (Mir) [E0503] + *z.pointer += 1; + } +} diff --git a/src/test/ui/issue-45697-1.stderr b/src/test/ui/issue-45697-1.stderr new file mode 100644 index 0000000000000..09f32b93acc1c --- /dev/null +++ b/src/test/ui/issue-45697-1.stderr @@ -0,0 +1,18 @@ +error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast) + --> $DIR/issue-45697-1.rs:30:9 + | +29 | let z = copy_borrowed_ptr(&mut y); + | - borrow of `*y.pointer` occurs here +30 | *y.pointer += 1; + | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here + +error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir) + --> $DIR/issue-45697-1.rs:30:9 + | +29 | let z = copy_borrowed_ptr(&mut y); + | ------ borrow of `y` occurs here +30 | *y.pointer += 1; + | ^^^^^^^^^^^^^^^ use of borrowed `y` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/issue-45697.rs b/src/test/ui/issue-45697.rs index b69ba97cc9b4d..4e93eccd6f649 100644 --- a/src/test/ui/issue-45697.rs +++ b/src/test/ui/issue-45697.rs @@ -11,7 +11,7 @@ // Test that assignments to an `&mut` pointer which is found in a // borrowed (but otherwise non-aliasable) location is illegal. -// compile-flags: -Z emit-end-regions -Z borrowck=compare +// compile-flags: -Z emit-end-regions -Z borrowck=compare -C overflow-checks=off struct S<'a> { pointer: &'a mut isize From 498ef20a2a2ce5da889440fb8708406b6f17e8d0 Mon Sep 17 00:00:00 2001 From: Badel2 <2badel2@gmail.com> Date: Tue, 6 Feb 2018 02:13:39 +0100 Subject: [PATCH 142/198] Trait objects cannot contain associated constants --- src/librustc/diagnostics.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 8bd89b834d6b6..4c256556191fa 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -256,6 +256,28 @@ trait Foo { } ``` +### The trait cannot contain associated constants + +Just like static functions, associated constants aren't stored on the method +table. If the trait or any subtrait contain an associated constant, they cannot +be made into an object. + +```compile_fail,E0038 +trait Foo { + const X: i32; +} + +impl Foo {} +``` + +A simple workaround is to use a helper method instead: + +``` +trait Foo { + fn x(&self) -> i32; +} +``` + ### The trait cannot use `Self` as a type parameter in the supertrait listing This is similar to the second sub-error, but subtler. It happens in situations From 83a9f4980ec8e9a97fffdc262c88b8ad47549014 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 5 Feb 2018 02:00:37 +0530 Subject: [PATCH 143/198] Fill in long diagnostic --- src/librustc_typeck/diagnostics.rs | 50 +++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index ea9b5473ed103..f59948e9fc42f 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -4698,6 +4698,55 @@ element type `T`. Also note that the error is conservatively reported even when the alignment of the zero-sized type is less than or equal to the data field's alignment. "##, + + +E0908: r##" +A method was called on a raw pointer whose inner type wasn't completely known. + +For example, you may have done something like: + +```compile_fail +# #![deny(warnings)] +let foo = &1; +let bar = foo as *const _; +if bar.is_null() { + // ... +} +``` + +Here, the type of `bar` isn't known; it could be a pointer to anything. Instead, +specify a type for the pointer (preferably something that makes sense for the +thing you're pointing to): + +``` +let foo = &1; +let bar = foo as *const i32; +if bar.is_null() { + // ... +} +``` + +Even though `is_null()` exists as a method on any raw pointer, Rust shows this +error because Rust allows for `self` to have arbitrary types (behind the +arbitrary_self_types feature flag). + +This means that someone can specify such a function: + +```ignore (cannot-doctest-feature-doesnt-exist-yet) +impl Foo { + fn is_null(self: *const Self) -> bool { + // do something else + } +} +``` + +and now when you call `.is_null()` on a raw pointer to `Foo`, there's ambiguity. + +Given that we don't know what type the pointer is, and there's potential +ambiguity for some types, we disallow calling methods on raw pointers when +the type is unknown. +"##, + } register_diagnostics! { @@ -4777,5 +4826,4 @@ register_diagnostics! { E0641, // cannot cast to/from a pointer with an unknown kind E0645, // trait aliases not finished E0907, // type inside generator must be known in this context - E0908, // methods on raw pointers can only be called if the pointer type is fully known } From b8aa8cadd6e868e74becaffaae17b64aeb66d004 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Mon, 5 Feb 2018 17:04:50 -0500 Subject: [PATCH 144/198] Add tests for -Zepoch using tyvar_raw_pointer --- .../epoch-raw-pointer-method-2015.rs | 23 +++++++++++++++++++ .../epoch-raw-pointer-method-2018.rs | 22 ++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/test/compile-fail/epoch-raw-pointer-method-2015.rs create mode 100644 src/test/compile-fail/epoch-raw-pointer-method-2018.rs diff --git a/src/test/compile-fail/epoch-raw-pointer-method-2015.rs b/src/test/compile-fail/epoch-raw-pointer-method-2015.rs new file mode 100644 index 0000000000000..a71db040b50e7 --- /dev/null +++ b/src/test/compile-fail/epoch-raw-pointer-method-2015.rs @@ -0,0 +1,23 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength +// compile-flags: -Zepoch=2015 -Zunstable-options + +// tests that epochs work with the tyvar warning-turned-error + +#[deny(warnings)] +fn main() { + let x = 0; + let y = &x as *const _; + let _ = y.is_null(); + //~^ error: the type of this value must be known in this context [tyvar_behind_raw_pointer] + //~^^ warning: this was previously accepted +} diff --git a/src/test/compile-fail/epoch-raw-pointer-method-2018.rs b/src/test/compile-fail/epoch-raw-pointer-method-2018.rs new file mode 100644 index 0000000000000..c4815de2306e9 --- /dev/null +++ b/src/test/compile-fail/epoch-raw-pointer-method-2018.rs @@ -0,0 +1,22 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength +// compile-flags: -Zepoch=2018 -Zunstable-options + +// tests that epochs work with the tyvar warning-turned-error + +#[deny(warnings)] +fn main() { + let x = 0; + let y = &x as *const _; + let _ = y.is_null(); + //~^ error: the type of this value must be known to call a method on a raw pointer on it [E0908] +} From 5de094e579f8fa6c32df0690fd3e47a33c1cb6ef Mon Sep 17 00:00:00 2001 From: bobtwinkles Date: Thu, 1 Feb 2018 22:26:48 -0500 Subject: [PATCH 145/198] mir: Fix DefiningTy::Const Fixes #47590 by fixing the way DefiningTy represents constants. Previously, constants were represented using just the type of the variable. However, this will fail to capture early-bound regions as NLL inference vars, resulting in an ICE when we try to compute region VIDs a little bit later in the universal region resolution process. --- .../nll/region_infer/annotation.rs | 7 +- .../borrow_check/nll/universal_regions.rs | 77 ++++++++++--------- src/test/ui/nll/trait-associated-constant.rs | 42 ++++++++++ .../ui/nll/trait-associated-constant.stderr | 52 +++++++++++++ 4 files changed, 140 insertions(+), 38 deletions(-) create mode 100644 src/test/ui/nll/trait-associated-constant.rs create mode 100644 src/test/ui/nll/trait-associated-constant.stderr diff --git a/src/librustc_mir/borrow_check/nll/region_infer/annotation.rs b/src/librustc_mir/borrow_check/nll/region_infer/annotation.rs index e8a23acd798de..d213f376d2bca 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/annotation.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/annotation.rs @@ -45,10 +45,11 @@ impl<'gcx, 'tcx> RegionInferenceContext<'tcx> { &substs[..] )); } - DefiningTy::Const(ty) => { + DefiningTy::Const(def_id, substs) => { err.note(&format!( - "defining type: {:?}", - ty + "defining constant type: {:?} with substs {:#?}", + def_id, + &substs[..] )); } } diff --git a/src/librustc_mir/borrow_check/nll/universal_regions.rs b/src/librustc_mir/borrow_check/nll/universal_regions.rs index e47e3c728dff2..668172749fecb 100644 --- a/src/librustc_mir/borrow_check/nll/universal_regions.rs +++ b/src/librustc_mir/borrow_check/nll/universal_regions.rs @@ -125,7 +125,7 @@ pub enum DefiningTy<'tcx> { /// The MIR represents some form of constant. The signature then /// is that it has no inputs and a single return value, which is /// the value of the constant. - Const(Ty<'tcx>), + Const(DefId, &'tcx Substs<'tcx>), } #[derive(Debug)] @@ -534,34 +534,42 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> { /// see `DefiningTy` for details. fn defining_ty(&self) -> DefiningTy<'tcx> { let tcx = self.infcx.tcx; - let closure_base_def_id = tcx.closure_base_def_id(self.mir_def_id); - let defining_ty = if self.mir_def_id == closure_base_def_id { - tcx.type_of(closure_base_def_id) - } else { - let tables = tcx.typeck_tables_of(self.mir_def_id); - tables.node_id_to_type(self.mir_hir_id) - }; - - let defining_ty = self.infcx - .replace_free_regions_with_nll_infer_vars(FR, &defining_ty); - match tcx.hir.body_owner_kind(self.mir_node_id) { - BodyOwnerKind::Fn => match defining_ty.sty { - ty::TyClosure(def_id, substs) => DefiningTy::Closure(def_id, substs), - ty::TyGenerator(def_id, substs, interior) => { - DefiningTy::Generator(def_id, substs, interior) + BodyOwnerKind::Fn => { + let defining_ty = if self.mir_def_id == closure_base_def_id { + tcx.type_of(closure_base_def_id) + } else { + let tables = tcx.typeck_tables_of(self.mir_def_id); + tables.node_id_to_type(self.mir_hir_id) + }; + + let defining_ty = self.infcx + .replace_free_regions_with_nll_infer_vars(FR, &defining_ty); + + match defining_ty.sty { + ty::TyClosure(def_id, substs) => DefiningTy::Closure(def_id, substs), + ty::TyGenerator(def_id, substs, interior) => { + DefiningTy::Generator(def_id, substs, interior) + } + ty::TyFnDef(def_id, substs) => DefiningTy::FnDef(def_id, substs), + _ => span_bug!( + tcx.def_span(self.mir_def_id), + "expected defining type for `{:?}`: `{:?}`", + self.mir_def_id, + defining_ty + ), } - ty::TyFnDef(def_id, substs) => DefiningTy::FnDef(def_id, substs), - _ => span_bug!( - tcx.def_span(self.mir_def_id), - "expected defining type for `{:?}`: `{:?}`", - self.mir_def_id, - defining_ty - ), - }, - BodyOwnerKind::Const | BodyOwnerKind::Static(..) => DefiningTy::Const(defining_ty), + } + + BodyOwnerKind::Const | BodyOwnerKind::Static(..) => { + assert_eq!(closure_base_def_id, self.mir_def_id); + let identity_substs = Substs::identity_for_item(tcx, closure_base_def_id); + let substs = self.infcx + .replace_free_regions_with_nll_infer_vars(FR, &identity_substs); + DefiningTy::Const(self.mir_def_id, substs) + } } } @@ -592,13 +600,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> { substs.substs } - DefiningTy::FnDef(_, substs) => substs, - - // When we encounter a constant body, just return whatever - // substitutions are in scope for that constant. - DefiningTy::Const(_) => { - identity_substs - } + DefiningTy::FnDef(_, substs) | DefiningTy::Const(_, substs) => substs, }; let global_mapping = iter::once((gcx.types.re_static, fr_static)); @@ -660,9 +662,14 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> { sig.inputs_and_output() } - // For a constant body, there are no inputs, and one - // "output" (the type of the constant). - DefiningTy::Const(ty) => ty::Binder::dummy(tcx.mk_type_list(iter::once(ty))), + DefiningTy::Const(def_id, _) => { + // For a constant body, there are no inputs, and one + // "output" (the type of the constant). + assert_eq!(self.mir_def_id, def_id); + let ty = tcx.type_of(def_id); + let ty = indices.fold_to_region_vids(tcx, &ty); + ty::Binder::dummy(tcx.mk_type_list(iter::once(ty))) + } } } diff --git a/src/test/ui/nll/trait-associated-constant.rs b/src/test/ui/nll/trait-associated-constant.rs new file mode 100644 index 0000000000000..b0f5fbf7160d1 --- /dev/null +++ b/src/test/ui/nll/trait-associated-constant.rs @@ -0,0 +1,42 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test cases where we put various lifetime constraints on trait +// associated constants. + +#![feature(rustc_attrs)] + +use std::option::Option; + +trait Anything<'a: 'b, 'b> { + const AC: Option<&'b str>; +} + +struct OKStruct { } + +impl<'a: 'b, 'b> Anything<'a, 'b> for OKStruct { + const AC: Option<&'b str> = None; +} + +struct FailStruct1 { } + +impl<'a: 'b, 'b, 'c> Anything<'a, 'b> for FailStruct1 { + const AC: Option<&'c str> = None; + //~^ ERROR: mismatched types +} + +struct FailStruct2 { } + +impl<'a: 'b, 'b> Anything<'a, 'b> for FailStruct2 { + const AC: Option<&'a str> = None; + //~^ ERROR: mismatched types +} + +fn main() {} diff --git a/src/test/ui/nll/trait-associated-constant.stderr b/src/test/ui/nll/trait-associated-constant.stderr new file mode 100644 index 0000000000000..100e3362886b3 --- /dev/null +++ b/src/test/ui/nll/trait-associated-constant.stderr @@ -0,0 +1,52 @@ +error[E0308]: mismatched types + --> $DIR/trait-associated-constant.rs:31:5 + | +31 | const AC: Option<&'c str> = None; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `std::option::Option<&'b str>` + found type `std::option::Option<&'c str>` +note: the lifetime 'c as defined on the impl at 30:1... + --> $DIR/trait-associated-constant.rs:30:1 + | +30 | / impl<'a: 'b, 'b, 'c> Anything<'a, 'b> for FailStruct1 { +31 | | const AC: Option<&'c str> = None; +32 | | //~^ ERROR: mismatched types +33 | | } + | |_^ +note: ...does not necessarily outlive the lifetime 'b as defined on the impl at 30:1 + --> $DIR/trait-associated-constant.rs:30:1 + | +30 | / impl<'a: 'b, 'b, 'c> Anything<'a, 'b> for FailStruct1 { +31 | | const AC: Option<&'c str> = None; +32 | | //~^ ERROR: mismatched types +33 | | } + | |_^ + +error[E0308]: mismatched types + --> $DIR/trait-associated-constant.rs:38:5 + | +38 | const AC: Option<&'a str> = None; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch + | + = note: expected type `std::option::Option<&'b str>` + found type `std::option::Option<&'a str>` +note: the lifetime 'a as defined on the impl at 37:1... + --> $DIR/trait-associated-constant.rs:37:1 + | +37 | / impl<'a: 'b, 'b> Anything<'a, 'b> for FailStruct2 { +38 | | const AC: Option<&'a str> = None; +39 | | //~^ ERROR: mismatched types +40 | | } + | |_^ +note: ...does not necessarily outlive the lifetime 'b as defined on the impl at 37:1 + --> $DIR/trait-associated-constant.rs:37:1 + | +37 | / impl<'a: 'b, 'b> Anything<'a, 'b> for FailStruct2 { +38 | | const AC: Option<&'a str> = None; +39 | | //~^ ERROR: mismatched types +40 | | } + | |_^ + +error: aborting due to 2 previous errors + From e99f8fcbc5ea4cf839575bc7ca56151147346a54 Mon Sep 17 00:00:00 2001 From: bobtwinkles Date: Wed, 7 Feb 2018 00:46:36 -0500 Subject: [PATCH 146/198] Update trait-associated-const test to new format --- .../ui/nll/trait-associated-constant.stderr | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/src/test/ui/nll/trait-associated-constant.stderr b/src/test/ui/nll/trait-associated-constant.stderr index 100e3362886b3..21c1a6ded93c2 100644 --- a/src/test/ui/nll/trait-associated-constant.stderr +++ b/src/test/ui/nll/trait-associated-constant.stderr @@ -9,19 +9,13 @@ error[E0308]: mismatched types note: the lifetime 'c as defined on the impl at 30:1... --> $DIR/trait-associated-constant.rs:30:1 | -30 | / impl<'a: 'b, 'b, 'c> Anything<'a, 'b> for FailStruct1 { -31 | | const AC: Option<&'c str> = None; -32 | | //~^ ERROR: mismatched types -33 | | } - | |_^ +30 | impl<'a: 'b, 'b, 'c> Anything<'a, 'b> for FailStruct1 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...does not necessarily outlive the lifetime 'b as defined on the impl at 30:1 --> $DIR/trait-associated-constant.rs:30:1 | -30 | / impl<'a: 'b, 'b, 'c> Anything<'a, 'b> for FailStruct1 { -31 | | const AC: Option<&'c str> = None; -32 | | //~^ ERROR: mismatched types -33 | | } - | |_^ +30 | impl<'a: 'b, 'b, 'c> Anything<'a, 'b> for FailStruct1 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0308]: mismatched types --> $DIR/trait-associated-constant.rs:38:5 @@ -34,19 +28,13 @@ error[E0308]: mismatched types note: the lifetime 'a as defined on the impl at 37:1... --> $DIR/trait-associated-constant.rs:37:1 | -37 | / impl<'a: 'b, 'b> Anything<'a, 'b> for FailStruct2 { -38 | | const AC: Option<&'a str> = None; -39 | | //~^ ERROR: mismatched types -40 | | } - | |_^ +37 | impl<'a: 'b, 'b> Anything<'a, 'b> for FailStruct2 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...does not necessarily outlive the lifetime 'b as defined on the impl at 37:1 --> $DIR/trait-associated-constant.rs:37:1 | -37 | / impl<'a: 'b, 'b> Anything<'a, 'b> for FailStruct2 { -38 | | const AC: Option<&'a str> = None; -39 | | //~^ ERROR: mismatched types -40 | | } - | |_^ +37 | impl<'a: 'b, 'b> Anything<'a, 'b> for FailStruct2 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors From daaa9a440ccbdcf12165165ca38eb80bdb9a6eff Mon Sep 17 00:00:00 2001 From: Ryan Cumming Date: Wed, 7 Feb 2018 18:34:45 +1100 Subject: [PATCH 147/198] Fix ICE for mismatched args on target without span Commit 7ed00caacc improved our error reporting by including the target function in our error messages when there is an argument count mismatch. A simple example from the UI tests is: ``` error[E0593]: function is expected to take a single 2-tuple as argument, but it takes 0 arguments --> $DIR/closure-arg-count.rs:32:53 | 32 | let _it = vec![1, 2, 3].into_iter().enumerate().map(foo); | ^^^ expected function that takes a single 2-tuple as argument ... 44 | fn foo() {} | -------- takes 0 arguments ``` However, this assumed the target span was always available. This does not hold true if the target function is in `std` or another crate. A simple example from #48046 is assigning `str::split` to a function type with a different number of arguments. Fix by removing all of the labels and suggestions related to the target span when it's not found. Fixes #48046 --- src/librustc/traits/error_reporting.rs | 93 ++++++++++--------- .../ui/mismatched_types/closure-arg-count.rs | 3 + .../mismatched_types/closure-arg-count.stderr | 12 ++- 3 files changed, 61 insertions(+), 47 deletions(-) diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 7b86791026b41..f58ac9f00e4cc 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -744,8 +744,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } else { let (closure_span, found) = found_did .and_then(|did| self.tcx.hir.get_if_local(did)) - .map(|node| self.get_fn_like_arguments(node)) - .unwrap_or((found_span.unwrap(), found)); + .map(|node| { + let (found_span, found) = self.get_fn_like_arguments(node); + (Some(found_span), found) + }).unwrap_or((found_span, found)); self.report_arg_count_mismatch(span, closure_span, @@ -855,7 +857,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { fn report_arg_count_mismatch( &self, span: Span, - found_span: Span, + found_span: Option, expected_args: Vec, found_args: Vec, is_closure: bool, @@ -893,48 +895,51 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { ); err.span_label(span, format!( "expected {} that takes {}", kind, expected_str)); - err.span_label(found_span, format!("takes {}", found_str)); - - if let &[ArgKind::Tuple(_, ref fields)] = &found_args[..] { - if fields.len() == expected_args.len() { - let sugg = fields.iter() - .map(|(name, _)| name.to_owned()) - .collect::>().join(", "); - err.span_suggestion(found_span, - "change the closure to take multiple arguments instead of \ - a single tuple", - format!("|{}|", sugg)); + + if let Some(found_span) = found_span { + err.span_label(found_span, format!("takes {}", found_str)); + + if let &[ArgKind::Tuple(_, ref fields)] = &found_args[..] { + if fields.len() == expected_args.len() { + let sugg = fields.iter() + .map(|(name, _)| name.to_owned()) + .collect::>().join(", "); + err.span_suggestion(found_span, + "change the closure to take multiple arguments instead of \ + a single tuple", + format!("|{}|", sugg)); + } } - } - if let &[ArgKind::Tuple(_, ref fields)] = &expected_args[..] { - if fields.len() == found_args.len() && is_closure { - let sugg = format!( - "|({}){}|", - found_args.iter() - .map(|arg| match arg { - ArgKind::Arg(name, _) => name.to_owned(), - _ => "_".to_owned(), - }) - .collect::>() - .join(", "), - // add type annotations if available - if found_args.iter().any(|arg| match arg { - ArgKind::Arg(_, ty) => ty != "_", - _ => false, - }) { - format!(": ({})", - fields.iter() - .map(|(_, ty)| ty.to_owned()) - .collect::>() - .join(", ")) - } else { - "".to_owned() - }, - ); - err.span_suggestion(found_span, - "change the closure to accept a tuple instead of individual \ - arguments", - sugg); + if let &[ArgKind::Tuple(_, ref fields)] = &expected_args[..] { + if fields.len() == found_args.len() && is_closure { + let sugg = format!( + "|({}){}|", + found_args.iter() + .map(|arg| match arg { + ArgKind::Arg(name, _) => name.to_owned(), + _ => "_".to_owned(), + }) + .collect::>() + .join(", "), + // add type annotations if available + if found_args.iter().any(|arg| match arg { + ArgKind::Arg(_, ty) => ty != "_", + _ => false, + }) { + format!(": ({})", + fields.iter() + .map(|(_, ty)| ty.to_owned()) + .collect::>() + .join(", ")) + } else { + "".to_owned() + }, + ); + err.span_suggestion(found_span, + "change the closure to accept a tuple instead of \ + individual arguments", + sugg); + } } } diff --git a/src/test/ui/mismatched_types/closure-arg-count.rs b/src/test/ui/mismatched_types/closure-arg-count.rs index 96e5201716c71..34232e81cbdee 100644 --- a/src/test/ui/mismatched_types/closure-arg-count.rs +++ b/src/test/ui/mismatched_types/closure-arg-count.rs @@ -36,6 +36,9 @@ fn main() { //~^ ERROR closure is expected to take let _it = vec![1, 2, 3].into_iter().enumerate().map(qux); //~^ ERROR function is expected to take + + let _it = vec![1, 2, 3].into_iter().map(usize::checked_add); + //~^ ERROR function is expected to take } fn foo() {} diff --git a/src/test/ui/mismatched_types/closure-arg-count.stderr b/src/test/ui/mismatched_types/closure-arg-count.stderr index be00ee4d74e7e..d2a6d6da814ca 100644 --- a/src/test/ui/mismatched_types/closure-arg-count.stderr +++ b/src/test/ui/mismatched_types/closure-arg-count.stderr @@ -90,7 +90,7 @@ error[E0593]: function is expected to take a single 2-tuple as argument, but it 32 | let _it = vec![1, 2, 3].into_iter().enumerate().map(foo); | ^^^ expected function that takes a single 2-tuple as argument ... -41 | fn foo() {} +44 | fn foo() {} | -------- takes 0 arguments error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 3 distinct arguments @@ -107,8 +107,14 @@ error[E0593]: function is expected to take a single 2-tuple as argument, but it 37 | let _it = vec![1, 2, 3].into_iter().enumerate().map(qux); | ^^^ expected function that takes a single 2-tuple as argument ... -42 | fn qux(x: usize, y: usize) {} +45 | fn qux(x: usize, y: usize) {} | -------------------------- takes 2 distinct arguments -error: aborting due to 11 previous errors +error[E0593]: function is expected to take 1 argument, but it takes 2 arguments + --> $DIR/closure-arg-count.rs:40:41 + | +40 | let _it = vec![1, 2, 3].into_iter().map(usize::checked_add); + | ^^^ expected function that takes 1 argument + +error: aborting due to 12 previous errors From 528d6b65b69a163fd34450d3d8806f1a4f37412d Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Wed, 7 Feb 2018 13:14:37 +0000 Subject: [PATCH 148/198] rustdoc: Hide `-> ()` in cross crate inlined Fn* bounds --- src/librustdoc/clean/simplify.rs | 4 +++- src/test/rustdoc/auxiliary/unit-return.rs | 13 +++++++++++ src/test/rustdoc/unit-return.rs | 27 +++++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/test/rustdoc/auxiliary/unit-return.rs create mode 100644 src/test/rustdoc/unit-return.rs diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs index 63ebb16e5e009..0eb4f9ba7e581 100644 --- a/src/librustdoc/clean/simplify.rs +++ b/src/librustdoc/clean/simplify.rs @@ -106,7 +106,9 @@ pub fn where_clauses(cx: &DocContext, clauses: Vec) -> Vec { } PP::Parenthesized { ref mut output, .. } => { assert!(output.is_none()); - *output = Some(rhs.clone()); + if *rhs != clean::Type::Tuple(Vec::new()) { + *output = Some(rhs.clone()); + } } }; true diff --git a/src/test/rustdoc/auxiliary/unit-return.rs b/src/test/rustdoc/auxiliary/unit-return.rs new file mode 100644 index 0000000000000..1b30a6a43282f --- /dev/null +++ b/src/test/rustdoc/auxiliary/unit-return.rs @@ -0,0 +1,13 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +pub fn f2(f: F) {} + +pub fn f3 () + Clone>(f: F) {} diff --git a/src/test/rustdoc/unit-return.rs b/src/test/rustdoc/unit-return.rs new file mode 100644 index 0000000000000..757e8979edd4f --- /dev/null +++ b/src/test/rustdoc/unit-return.rs @@ -0,0 +1,27 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:unit-return.rs + +#![crate_name = "foo"] + +extern crate unit_return; + +// @has 'foo/fn.f0.html' '//*[@class="rust fn"]' 'F: FnMut(u8) + Clone' +pub fn f0(f: F) {} + +// @has 'foo/fn.f1.html' '//*[@class="rust fn"]' 'F: FnMut(u16) + Clone' +pub fn f1 () + Clone>(f: F) {} + +// @has 'foo/fn.f2.html' '//*[@class="rust fn"]' 'F: FnMut(u32) + Clone' +pub use unit_return::f2; + +// @has 'foo/fn.f3.html' '//*[@class="rust fn"]' 'F: FnMut(u64) + Clone' +pub use unit_return::f3; From 78a0b7fd466093003841cec6fd20d65270cf2175 Mon Sep 17 00:00:00 2001 From: O01eg Date: Wed, 7 Feb 2018 20:57:02 +0300 Subject: [PATCH 149/198] Refactor checks on list of extended tools. --- src/bootstrap/install.rs | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index 86df36f209e6b..20f7d379a6967 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -22,6 +22,7 @@ use dist::{self, pkgname, sanitize_sh, tmpdir}; use builder::{Builder, RunConfig, ShouldRun, Step}; use cache::Interned; +use config::Config; pub fn install_docs(builder: &Builder, stage: u32, host: Interned) { install_sh(builder, "docs", "rust-docs", stage, Some(host)); @@ -144,6 +145,19 @@ macro_rules! install { pub host: Interned, } + impl $name { + #[allow(dead_code)] + fn should_build(config: &Config) -> bool { + config.extended && config.tools.as_ref() + .map_or(true, |t| t.contains($path)) + } + + #[allow(dead_code)] + fn should_install(builder: &Builder) -> bool { + builder.config.tools.as_ref().map_or(false, |t| t.contains($path)) + } + } + impl Step for $name { type Output = (); const DEFAULT: bool = true; @@ -185,39 +199,34 @@ install!((self, builder, _config), install_std(builder, self.stage, *target); } }; - Cargo, "cargo", _config.extended && - _config.tools.as_ref().map_or(true, |t| t.contains("cargo")), only_hosts: true, { + Cargo, "cargo", Self::should_build(_config), only_hosts: true, { builder.ensure(dist::Cargo { stage: self.stage, target: self.target }); install_cargo(builder, self.stage, self.target); }; - Rls, "rls", _config.extended && - _config.tools.as_ref().map_or(true, |t| t.contains("rls")), only_hosts: true, { + Rls, "rls", Self::should_build(_config), only_hosts: true, { if builder.ensure(dist::Rls { stage: self.stage, target: self.target }).is_some() || - builder.config.tools.as_ref().map_or(false, |t| t.contains("rls")) { + Self::should_install(builder) { install_rls(builder, self.stage, self.target); } else { println!("skipping Install RLS stage{} ({})", self.stage, self.target); } }; - Rustfmt, "rustfmt", _config.extended && - _config.tools.as_ref().map_or(true, |t| t.contains("rustfmt")), only_hosts: true, { + Rustfmt, "rustfmt", Self::should_build(_config), only_hosts: true, { if builder.ensure(dist::Rustfmt { stage: self.stage, target: self.target }).is_some() || - builder.config.tools.as_ref().map_or(false, |t| t.contains("rustfmt")) { + Self::should_install(builder) { install_rustfmt(builder, self.stage, self.target); } else { println!("skipping Install Rustfmt stage{} ({})", self.stage, self.target); } }; - Analysis, "analysis", _config.extended && - _config.tools.as_ref().map_or(true, |t| t.contains("analysis")), only_hosts: false, { + Analysis, "analysis", Self::should_build(_config), only_hosts: false, { builder.ensure(dist::Analysis { compiler: builder.compiler(self.stage, self.host), target: self.target }); install_analysis(builder, self.stage, self.target); }; - Src, "src", _config.extended && - _config.tools.as_ref().map_or(true, |t| t.contains("src")), only_hosts: true, { + Src, "src", Self::should_build(_config) , only_hosts: true, { builder.ensure(dist::Src); install_src(builder, self.stage); }, ONLY_BUILD; From 27d4d51670710aa44a73baf04130bc262b8de244 Mon Sep 17 00:00:00 2001 From: Scott McMurray Date: Wed, 7 Feb 2018 11:11:54 -0800 Subject: [PATCH 150/198] Simplify RangeInclusive::next[_back] `match`ing on an `Option` seems cause some confusion for LLVM; switching to just using comparison operators removes a few jumps from the simple `for` loops I was trying. --- src/libcore/iter/range.rs | 28 ++++++++++++---------------- src/libcore/tests/iter.rs | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+), 16 deletions(-) diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs index 3b034efcce14c..6d582b9a721fe 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -331,19 +331,17 @@ impl Iterator for ops::RangeInclusive { #[inline] fn next(&mut self) -> Option { - use cmp::Ordering::*; - - match self.start.partial_cmp(&self.end) { - Some(Less) => { + if self.start <= self.end { + if self.start < self.end { let n = self.start.add_one(); Some(mem::replace(&mut self.start, n)) - }, - Some(Equal) => { + } else { let last = self.start.replace_one(); self.end.replace_zero(); Some(last) - }, - _ => None, + } + } else { + None } } @@ -425,19 +423,17 @@ impl Iterator for ops::RangeInclusive { impl DoubleEndedIterator for ops::RangeInclusive { #[inline] fn next_back(&mut self) -> Option { - use cmp::Ordering::*; - - match self.start.partial_cmp(&self.end) { - Some(Less) => { + if self.start <= self.end { + if self.start < self.end { let n = self.end.sub_one(); Some(mem::replace(&mut self.end, n)) - }, - Some(Equal) => { + } else { let last = self.end.replace_zero(); self.start.replace_one(); Some(last) - }, - _ => None, + } + } else { + None } } diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index dc866d180bfa0..c742a1d8048fc 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -1332,6 +1332,18 @@ fn test_range_inclusive_exhaustion() { assert_eq!(r.next_back(), Some(10)); assert_eq!(r, 1..=0); + let mut r = 10..=12; + assert_eq!(r.next(), Some(10)); + assert_eq!(r.next(), Some(11)); + assert_eq!(r.next(), Some(12)); + assert_eq!(r, 1..=0); + + let mut r = 10..=12; + assert_eq!(r.next_back(), Some(12)); + assert_eq!(r.next_back(), Some(11)); + assert_eq!(r.next_back(), Some(10)); + assert_eq!(r, 1..=0); + let mut r = 10..=12; assert_eq!(r.nth(2), Some(12)); assert_eq!(r, 1..=0); @@ -1340,6 +1352,13 @@ fn test_range_inclusive_exhaustion() { assert_eq!(r.nth(5), None); assert_eq!(r, 1..=0); + let mut r = 100..=10; + assert_eq!(r.next(), None); + assert_eq!(r, 100..=10); + + let mut r = 100..=10; + assert_eq!(r.next_back(), None); + assert_eq!(r, 100..=10); } #[test] From 8e0c3f5c462acc7da61c59e81510765da1919e80 Mon Sep 17 00:00:00 2001 From: bobtwinkles Date: Wed, 7 Feb 2018 14:25:08 -0500 Subject: [PATCH 151/198] [ci skip] Generate false edges from loop_block As opposed to using weirdness involving pretending the body block is the loop block. This does not pass tests This commit is [ci skip] because I know it doesn't pass tests yet. Somehow this commit introduces nondeterminism into the handling of loops. --- src/librustc_mir/build/expr/into.rs | 46 +++++++++---------- src/test/mir-opt/end_region_2.rs | 13 ++++-- src/test/mir-opt/end_region_3.rs | 13 ++++-- src/test/mir-opt/end_region_9.rs | 18 +++++--- src/test/mir-opt/end_region_cyclic.rs | 29 ++++++------ src/test/mir-opt/issue-38669.rs | 13 +++--- .../mir-opt/nll/liveness-drop-intra-block.rs | 16 +++---- 7 files changed, 81 insertions(+), 67 deletions(-) diff --git a/src/librustc_mir/build/expr/into.rs b/src/librustc_mir/build/expr/into.rs index 089ce3f71a5ba..28dc329e4fe7c 100644 --- a/src/librustc_mir/build/expr/into.rs +++ b/src/librustc_mir/build/expr/into.rs @@ -147,24 +147,24 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { join_block.unit() } ExprKind::Loop { condition: opt_cond_expr, body } => { - // [block] --> [loop_block] ~~> [loop_block_end] -1-> [exit_block] - // ^ | - // | 0 - // | | - // | v - // [body_block_end] <~~~ [body_block] + // [block] --> [loop_block] -/eval. cond./-> [loop_block_end] -1-> [exit_block] + // ^ | + // | 0 + // | | + // | v + // [body_block_end] <-/eval. body/-- [body_block] // // If `opt_cond_expr` is `None`, then the graph is somewhat simplified: // - // [block] --> [loop_block] ~~> [loop_block_end] - // | ^ | - // false link | | - // | +-------------------+ - // v - // [cleanup_block] - // - // The false link is required in case something results in - // unwinding through the body. + // [block] + // | + // [loop_block] -> [body_block] -/eval. body/-> [body_block_end] + // | ^ | + // false link | | + // | +-----------------------------------------+ + // +-> [diverge_cleanup] + // The false link is required to make sure borrowck considers unwinds through the + // body, even when the exact code in the body cannot unwind let loop_block = this.cfg.start_new_block(); let exit_block = this.cfg.start_new_block(); @@ -178,7 +178,6 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { move |this| { // conduct the test, if necessary let body_block; - let out_terminator; if let Some(cond_expr) = opt_cond_expr { let loop_block_end; let cond = unpack!( @@ -192,15 +191,14 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // we have to do it; this overwrites any `break`-assigned value but it's // always `()` anyway this.cfg.push_assign_unit(exit_block, source_info, destination); - - out_terminator = TerminatorKind::Goto { target: loop_block }; } else { - body_block = loop_block; + body_block = this.cfg.start_new_block(); let diverge_cleanup = this.diverge_cleanup(); - out_terminator = TerminatorKind::FalseUnwind { - real_target: loop_block, - unwind: Some(diverge_cleanup) - } + this.cfg.terminate(loop_block, source_info, + TerminatorKind::FalseUnwind { + real_target: body_block, + unwind: Some(diverge_cleanup) + }) } // The “return” value of the loop body must always be an unit. We therefore @@ -209,7 +207,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // Execute the body, branching back to the test. let body_block_end = unpack!(this.into(&tmp, body_block, body)); this.cfg.terminate(body_block_end, source_info, - out_terminator); + TerminatorKind::Goto { target: loop_block }); } ); exit_block.unit() diff --git a/src/test/mir-opt/end_region_2.rs b/src/test/mir-opt/end_region_2.rs index 958e9364c8fa8..d6084d5a6da92 100644 --- a/src/test/mir-opt/end_region_2.rs +++ b/src/test/mir-opt/end_region_2.rs @@ -40,18 +40,21 @@ fn main() { // goto -> bb1; // } // bb1: { +// falseUnwind -> [real: bb2, cleanup: bb3]; +// } +// bb2: { // StorageLive(_2); // _2 = const true; // StorageLive(_3); // _3 = &'23_1rs _2; // StorageLive(_5); // _5 = _2; -// switchInt(move _5) -> [0u8: bb4, otherwise: bb3]; +// switchInt(move _5) -> [0u8: bb5, otherwise: bb4]; // } -// bb2: { +// bb3: { // ... // } -// bb3: { +// bb4: { // _0 = (); // StorageDead(_5); // EndRegion('23_1rs); @@ -59,7 +62,7 @@ fn main() { // StorageDead(_2); // return; // } -// bb4: { +// bb5: { // _4 = (); // StorageDead(_5); // StorageLive(_7); @@ -70,6 +73,6 @@ fn main() { // EndRegion('23_1rs); // StorageDead(_3); // StorageDead(_2); -// falseUnwind -> [real: bb1, cleanup: bb2]; +// goto -> bb1; // } // END rustc.main.SimplifyCfg-qualify-consts.after.mir diff --git a/src/test/mir-opt/end_region_3.rs b/src/test/mir-opt/end_region_3.rs index c1ebc525e88ed..46548f1cce978 100644 --- a/src/test/mir-opt/end_region_3.rs +++ b/src/test/mir-opt/end_region_3.rs @@ -43,17 +43,20 @@ fn main() { // goto -> bb1; // } // bb1: { +// falseUnwind -> [real: bb2, cleanup: bb3]; +// } +// bb2: { // _1 = const true; // StorageLive(_3); // _3 = &'26_1rs _1; // StorageLive(_5); // _5 = _1; -// switchInt(move _5) -> [0u8: bb4, otherwise: bb3]; +// switchInt(move _5) -> [0u8: bb5, otherwise: bb4]; // } -// bb2: { +// bb3: { // ... // } -// bb3: { +// bb4: { // _0 = (); // StorageDead(_5); // EndRegion('26_1rs); @@ -61,7 +64,7 @@ fn main() { // StorageDead(_1); // return; // } -// bb4: { +// bb5: { // _4 = (); // StorageDead(_5); // StorageLive(_7); @@ -71,6 +74,6 @@ fn main() { // StorageDead(_7); // EndRegion('26_1rs); // StorageDead(_3); -// falseUnwind -> [real: bb1, cleanup: bb2]; +// goto -> bb1; // } // END rustc.main.SimplifyCfg-qualify-consts.after.mir diff --git a/src/test/mir-opt/end_region_9.rs b/src/test/mir-opt/end_region_9.rs index 70611306fd328..0f1d714cc6fd2 100644 --- a/src/test/mir-opt/end_region_9.rs +++ b/src/test/mir-opt/end_region_9.rs @@ -57,18 +57,24 @@ fn main() { // _1 = const false; // StorageLive(_2); // _2 = const 3i32; -// StorageLive(_4); -// goto -> bb2; +// falseUnwind -> [real: bb2, cleanup: bb1]; // } // bb1: { // ... // } // bb2: { +// StorageLive(_4); +// goto -> bb3; +// } +// bb3: { +// falseUnwind -> [real: bb4, cleanup: bb1]; +// } +// bb4: { // StorageLive(_7); // _7 = _1; -// switchInt(move _7) -> [0u8: bb4, otherwise: bb3]; +// switchInt(move _7) -> [0u8: bb6, otherwise: bb5]; // } -// bb3: { +// bb5: { // _0 = (); // StorageDead(_7); // EndRegion('33_0rs); @@ -77,13 +83,13 @@ fn main() { // StorageDead(_1); // return; // } -// bb4: { +// bb6: { // _4 = &'33_0rs _2; // _6 = (); // StorageDead(_7); // _1 = const true; // _3 = (); -// falseUnwind -> [real: bb2, cleanup: bb1]; +// goto -> bb3; // } // } // END rustc.main.SimplifyCfg-qualify-consts.after.mir diff --git a/src/test/mir-opt/end_region_cyclic.rs b/src/test/mir-opt/end_region_cyclic.rs index 801c4eed4d20b..2a82e2675b67d 100644 --- a/src/test/mir-opt/end_region_cyclic.rs +++ b/src/test/mir-opt/end_region_cyclic.rs @@ -67,16 +67,19 @@ fn query() -> bool { true } // goto -> bb1; // } // bb1: { +// falseUnwind -> [real: bb2, cleanup: bb3]; +// } +// bb2: { // StorageLive(_2); // StorageLive(_3); // StorageLive(_4); // _4 = std::option::Option<&'35_0rs S<'35_0rs>>::None; -// _3 = const >::new(move _4) -> [return: bb3, unwind: bb2]; +// _3 = const >::new(move _4) -> [return: bb4, unwind: bb3]; // } -// bb2: { +// bb3: { // resume; // } -// bb3: { +// bb4: { // StorageDead(_4); // _2 = S<'35_0rs> { r: move _3 }; // StorageDead(_3); @@ -89,27 +92,27 @@ fn query() -> bool { true } // _8 = &'35_0rs (*_9); // _7 = std::option::Option<&'35_0rs S<'35_0rs>>::Some(move _8,); // StorageDead(_8); -// _5 = const >::set(move _6, move _7) -> [return: bb4, unwind: bb2]; +// _5 = const >::set(move _6, move _7) -> [return: bb5, unwind: bb3]; // } -// bb4: { +// bb5: { // EndRegion('16s); // StorageDead(_7); // StorageDead(_6); // StorageDead(_9); // StorageLive(_11); -// _11 = const query() -> [return: bb5, unwind: bb2]; -// } -// bb5: { -// switchInt(move _11) -> [0u8: bb7, otherwise: bb6]; +// _11 = const query() -> [return: bb6, unwind: bb3]; // } // bb6: { +// switchInt(move _11) -> [0u8: bb8, otherwise: bb7]; +// } +// bb7: { // _0 = (); // StorageDead(_11); // EndRegion('35_0rs); // StorageDead(_2); // return; // } -// bb7: { +// bb8: { // _10 = (); // StorageDead(_11); // StorageLive(_14); @@ -121,9 +124,9 @@ fn query() -> bool { true } // _16 = &'35_0rs (*_17); // _15 = std::option::Option<&'35_0rs S<'35_0rs>>::Some(move _16,); // StorageDead(_16); -// _13 = const >::set(move _14, move _15) -> [return: bb8, unwind: bb2]; +// _13 = const >::set(move _14, move _15) -> [return: bb9, unwind: bb3]; // } -// bb8: { +// bb9: { // EndRegion('33s); // StorageDead(_15); // StorageDead(_14); @@ -131,7 +134,7 @@ fn query() -> bool { true } // _1 = (); // EndRegion('35_0rs); // StorageDead(_2); -// falseUnwind -> [real: bb1, cleanup: bb2]; +// goto -> bb1; // } // } // END rustc.main.SimplifyCfg-qualify-consts.after.mir diff --git a/src/test/mir-opt/issue-38669.rs b/src/test/mir-opt/issue-38669.rs index 4444d96798fcf..3151c0643079c 100644 --- a/src/test/mir-opt/issue-38669.rs +++ b/src/test/mir-opt/issue-38669.rs @@ -27,27 +27,28 @@ fn main() { // _1 = const false; // goto -> bb2; // } -// // bb1: { // resume; // } // bb2: { +// falseUnwind -> [real: bb3, cleanup: bb1]; +// } +// bb3: { // StorageLive(_4); // _4 = _1; -// switchInt(move _4) -> [0u8: bb4, otherwise: bb3]; +// switchInt(move _4) -> [0u8: bb5, otherwise: bb4]; // } -// bb3: { +// bb4: { // _0 = (); // StorageDead(_4); // StorageDead(_1); // return; // } -// -// bb4: { +// bb5: { // _3 = (); // StorageDead(_4); // _1 = const true; // _2 = (); -// falseUnwind -> [real: bb2, cleanup: bb1]; +// goto -> bb2; // } // END rustc.main.SimplifyCfg-initial.after.mir diff --git a/src/test/mir-opt/nll/liveness-drop-intra-block.rs b/src/test/mir-opt/nll/liveness-drop-intra-block.rs index b060222a95f17..64ffc7446062c 100644 --- a/src/test/mir-opt/nll/liveness-drop-intra-block.rs +++ b/src/test/mir-opt/nll/liveness-drop-intra-block.rs @@ -25,17 +25,17 @@ fn main() { // END RUST SOURCE // START rustc.main.nll.0.mir -// | Live variables on entry to bb2: [] -// bb2: { -// | Live variables on entry to bb2[0]: [] +// | Live variables on entry to bb3: [] +// bb3: { +// | Live variables on entry to bb3[0]: [] // _1 = const 55usize; -// | Live variables on entry to bb2[1]: [_1] +// | Live variables on entry to bb3[1]: [_1] // StorageLive(_3); -// | Live variables on entry to bb2[2]: [_1] +// | Live variables on entry to bb3[2]: [_1] // StorageLive(_4); -// | Live variables on entry to bb2[3]: [_1] +// | Live variables on entry to bb3[3]: [_1] // _4 = _1; -// | Live variables on entry to bb2[4]: [_4] -// _3 = const use_x(move _4) -> [return: bb3, unwind: bb1]; +// | Live variables on entry to bb3[4]: [_4] +// _3 = const use_x(move _4) -> [return: bb4, unwind: bb1]; // } // END rustc.main.nll.0.mir From 37b5af2600501ea1461f1361f2f690e24734e6df Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 7 Feb 2018 12:20:25 -0800 Subject: [PATCH 152/198] Update binaryen to fix -Werror with GCC 8 --- src/binaryen | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/binaryen b/src/binaryen index 1c9bf65aa0e37..17841e155edf8 160000 --- a/src/binaryen +++ b/src/binaryen @@ -1 +1 @@ -Subproject commit 1c9bf65aa0e371b84755a8ddd6e79497fac57171 +Subproject commit 17841e155edf858c8ea7802dd5f5ecbef54b989f From 04fde1c42f92491886272f50308bf1f095307629 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 7 Feb 2018 16:35:40 -0800 Subject: [PATCH 153/198] intra-doc-links: bail early for linky things --- src/librustdoc/clean/mod.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 7c9a49c82a939..66b5f3b5ea366 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1051,6 +1051,10 @@ impl Clean for [ast::Attribute] { if UnstableFeatures::from_environment().is_nightly_build() { let dox = attrs.collapsed_doc_value().unwrap_or_else(String::new); for link in markdown_links(&dox, cx.render_type) { + // bail early for real links + if link.contains('/') { + continue; + } let (def, fragment) = { let mut kind = PathKind::Unknown; let path_str = if let Some(prefix) = From 85dfa9d1a33be7a4e7276e03660fb9966057cb6e Mon Sep 17 00:00:00 2001 From: bobtwinkles Date: Wed, 7 Feb 2018 20:00:54 -0500 Subject: [PATCH 154/198] Fix tests for MIR loop lowering Fixes the hash test to recognize that MirValidated can change when changing around labels, and add a new test that makes sure we're lowering loop statements correctly. --- .../incremental/hashes/loop_expressions.rs | 2 +- src/test/mir-opt/loop_test.rs | 49 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/test/mir-opt/loop_test.rs diff --git a/src/test/incremental/hashes/loop_expressions.rs b/src/test/incremental/hashes/loop_expressions.rs index dcb937fd867ab..8599f8d7f9a00 100644 --- a/src/test/incremental/hashes/loop_expressions.rs +++ b/src/test/incremental/hashes/loop_expressions.rs @@ -179,7 +179,7 @@ pub fn change_continue_label() { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="HirBody, TypeckTables")] +#[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, TypeckTables")] #[rustc_clean(cfg="cfail3")] pub fn change_continue_label() { let mut _x = 0; diff --git a/src/test/mir-opt/loop_test.rs b/src/test/mir-opt/loop_test.rs new file mode 100644 index 0000000000000..d36d890809497 --- /dev/null +++ b/src/test/mir-opt/loop_test.rs @@ -0,0 +1,49 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z identify_regions -Z emit-end-regions + +// Tests to make sure we correctly generate falseUnwind edges in loops + +fn main() { + // Exit early at runtime. Since only care about the generated MIR + // and not the runtime behavior (which is exercised by other tests) + // we just bail early. Without this the test just loops infinitely. + if true { + return; + } + loop { + let x = 1; + continue; + } +} + +// END RUST SOURCE +// START rustc.main.SimplifyCfg-qualify-consts.after.mir +// ... +// bb1: { // The cleanup block +// resume; +// } +// ... +// bb3: { // Entry into the loop +// _1 = (); +// goto -> bb4; +// } +// bb4: { // The loop_block +// falseUnwind -> [real: bb5, cleanup: bb1]; +// } +// bb5: { // The loop body (body_block) +// StorageLive(_5); +// _5 = const 1i32; +// StorageDead(_5); +// goto -> bb4; +// } +// ... +// END rustc.main.SimplifyCfg-qualify-consts.after.mir From e87e0bcc0e82a9936eac11077a25af31a612f127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 28 Jan 2018 21:44:04 -0800 Subject: [PATCH 155/198] Add `-Zteach` documentation Add extra inline documentation to E0019, E0016, E0013, E0396, E0017, E0018, E0010, E0022, E0030, E0029, E0033, E0026 and E0027. --- src/librustc/middle/entry.rs | 4 + src/librustc_mir/transform/qualify_consts.rs | 168 +++++++++++++++---- src/librustc_passes/consts.rs | 18 +- src/librustc_typeck/check/_match.rs | 94 ++++++++--- 4 files changed, 229 insertions(+), 55 deletions(-) diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 31e054ec1cb93..8b4b9aaeac848 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -175,6 +175,10 @@ fn configure_main(this: &mut EntryContext) { err.emit(); this.session.abort_if_errors(); } else { + if this.session.teach(&err.get_code().unwrap()) { + err.note("If you don't know the basics of Rust, you can go look to the Rust Book \ + to get started: https://doc.rust-lang.org/book/"); + } err.emit(); } } diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 297e0e491f694..ed1e1ebfc9f0a 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -170,8 +170,20 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { fn not_const(&mut self) { self.add(Qualif::NOT_CONST); if self.mode != Mode::Fn { - span_err!(self.tcx.sess, self.span, E0019, - "{} contains unimplemented expression type", self.mode); + let mut err = struct_span_err!( + self.tcx.sess, + self.span, + E0019, + "{} contains unimplemented expression type", + self.mode + ); + if self.tcx.sess.teach(&err.get_code().unwrap()) { + err.note("A function call isn't allowed in the const's initialization expression \ + because the expression's value must be known at compile-time."); + err.note("Remember: you can't use a function call inside a const's initialization \ + expression! However, you can use it anywhere else."); + } + err.emit(); } } @@ -179,9 +191,19 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { fn statement_like(&mut self) { self.add(Qualif::NOT_CONST); if self.mode != Mode::Fn { - span_err!(self.tcx.sess, self.span, E0016, - "blocks in {}s are limited to items and tail expressions", - self.mode); + let mut err = struct_span_err!( + self.tcx.sess, + self.span, + E0016, + "blocks in {}s are limited to items and tail expressions", + self.mode + ); + if self.tcx.sess.teach(&err.get_code().unwrap()) { + err.note("Blocks in constants may only contain items (such as constant, function \ + definition, etc...) and a tail expression."); + err.help("To avoid it, you have to replace the non-item object."); + } + err.emit(); } } @@ -474,9 +496,19 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } if self.mode == Mode::Const || self.mode == Mode::ConstFn { - span_err!(self.tcx.sess, self.span, E0013, - "{}s cannot refer to statics, use \ - a constant instead", self.mode); + let mut err = struct_span_err!(self.tcx.sess, self.span, E0013, + "{}s cannot refer to statics, use \ + a constant instead", self.mode); + if self.tcx.sess.teach(&err.get_code().unwrap()) { + err.note( + "Static and const variables can refer to other const variables. But a \ + const variable cannot refer to a static variable." + ); + err.help( + "To fix this, the value can be extracted as a const and then used." + ); + } + err.emit() } } Place::Projection(ref proj) => { @@ -497,13 +529,25 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { if let ty::TyRawPtr(_) = base_ty.sty { this.add(Qualif::NOT_CONST); if this.mode != Mode::Fn { - struct_span_err!(this.tcx.sess, - this.span, E0396, + let mut err = struct_span_err!( + this.tcx.sess, + this.span, + E0396, "raw pointers cannot be dereferenced in {}s", - this.mode) - .span_label(this.span, - "dereference of raw pointer in constant") - .emit(); + this.mode + ); + err.span_label(this.span, + "dereference of raw pointer in constant"); + if this.tcx.sess.teach(&err.get_code().unwrap()) { + err.note( + "The value behind a raw pointer can't be determined \ + at compile-time (or even link-time), which means it \ + can't be used in a constant expression." + ); + err.help("A possible fix is to dereference your pointer \ + at some point in run-time."); + } + err.emit(); } } } @@ -622,12 +666,22 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { if !allow { self.add(Qualif::NOT_CONST); if self.mode != Mode::Fn { - struct_span_err!(self.tcx.sess, self.span, E0017, - "references in {}s may only refer \ - to immutable values", self.mode) - .span_label(self.span, format!("{}s require immutable values", - self.mode)) - .emit(); + let mut err = struct_span_err!(self.tcx.sess, self.span, E0017, + "references in {}s may only refer \ + to immutable values", self.mode); + err.span_label(self.span, format!("{}s require immutable values", + self.mode)); + if self.tcx.sess.teach(&err.get_code().unwrap()) { + err.note("References in statics and constants may only refer to \ + immutable values.\n\n\ + Statics are shared everywhere, and if they refer to \ + mutable data one might violate memory safety since \ + holding multiple mutable references to shared data is \ + not allowed.\n\n\ + If you really want global mutable state, try using \ + static mut or a global UnsafeCell."); + } + err.emit(); } } } else { @@ -668,9 +722,42 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { (CastTy::FnPtr, CastTy::Int(_)) => { self.add(Qualif::NOT_CONST); if self.mode != Mode::Fn { - span_err!(self.tcx.sess, self.span, E0018, - "raw pointers cannot be cast to integers in {}s", - self.mode); + let mut err = struct_span_err!( + self.tcx.sess, + self.span, + E0018, + "raw pointers cannot be cast to integers in {}s", + self.mode + ); + if self.tcx.sess.teach(&err.get_code().unwrap()) { + err.note("\ +The value of static and constant integers must be known at compile time. You can't cast a pointer \ +to an integer because the address of a pointer can vary. + +For example, if you write: + +``` +static MY_STATIC: u32 = 42; +static MY_STATIC_ADDR: usize = &MY_STATIC as *const _ as usize; +static WHAT: usize = (MY_STATIC_ADDR^17) + MY_STATIC_ADDR; +``` + +Then `MY_STATIC_ADDR` would contain the address of `MY_STATIC`. However, the address can change \ +when the program is linked, as well as change between different executions due to ASLR, and many \ +linkers would not be able to calculate the value of `WHAT`. + +On the other hand, static and constant pointers can point either to a known numeric address or to \ +the address of a symbol. + +``` +static MY_STATIC: u32 = 42; +static MY_STATIC_ADDR: &'static u32 = &MY_STATIC; +const CONST_ADDR: *const u8 = 0x5f3759df as *const u8; +``` + +This does not pose a problem by itself because they can't be accessed directly."); + } + err.emit(); } } _ => {} @@ -701,10 +788,18 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { Rvalue::NullaryOp(NullOp::Box, _) => { self.add(Qualif::NOT_CONST); if self.mode != Mode::Fn { - struct_span_err!(self.tcx.sess, self.span, E0010, - "allocations are not allowed in {}s", self.mode) - .span_label(self.span, format!("allocation not allowed in {}s", self.mode)) - .emit(); + let mut err = struct_span_err!(self.tcx.sess, self.span, E0010, + "allocations are not allowed in {}s", self.mode); + err.span_label(self.span, format!("allocation not allowed in {}s", self.mode)); + if self.tcx.sess.teach(&err.get_code().unwrap()) { + err.note( + "The value of statics and constants must be known at compile time, \ + and they live for the entire lifetime of a program. Creating a boxed \ + value allocates memory on the heap at runtime, and therefore cannot \ + be done at compile time." + ); + } + err.emit(); } } @@ -930,9 +1025,22 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { // Avoid a generic error for other uses of arguments. if self.qualif.intersects(Qualif::FN_ARGUMENT) { let decl = &self.mir.local_decls[index]; - span_err!(self.tcx.sess, decl.source_info.span, E0022, - "arguments of constant functions can only \ - be immutable by-value bindings"); + let mut err = struct_span_err!( + self.tcx.sess, + decl.source_info.span, + E0022, + "arguments of constant functions can only be immutable by-value bindings" + ); + if self.tcx.sess.teach(&err.get_code().unwrap()) { + err.note("Constant functions are not allowed to mutate anything. Thus, \ + binding to an argument with a mutable pattern is not allowed."); + err.note("Remove any mutable bindings from the argument list to fix this \ + error. In case you need to mutate the argument, try lazily \ + initializing a global variable instead of using a const fn, or \ + refactoring the code to a functional style to avoid mutation if \ + possible."); + } + err.emit(); return; } } diff --git a/src/librustc_passes/consts.rs b/src/librustc_passes/consts.rs index 6df860492f05a..59864182a7e40 100644 --- a/src/librustc_passes/consts.rs +++ b/src/librustc_passes/consts.rs @@ -237,10 +237,20 @@ impl<'a, 'tcx> Visitor<'tcx> for CheckCrateVisitor<'a, 'tcx> { Ok(Ordering::Less) | Ok(Ordering::Equal) => {} Ok(Ordering::Greater) => { - struct_span_err!(self.tcx.sess, start.span, E0030, - "lower range bound must be less than or equal to upper") - .span_label(start.span, "lower bound larger than upper bound") - .emit(); + let mut err = struct_span_err!( + self.tcx.sess, + start.span, + E0030, + "lower range bound must be less than or equal to upper" + ); + err.span_label(start.span, "lower bound larger than upper bound"); + if self.tcx.sess.teach(&err.get_code().unwrap()) { + err.note("When matching against a range, the compiler verifies that \ + the range is non-empty. Range patterns include both \ + end-points, so this is equivalent to requiring the start of \ + the range to be less than or equal to the end of the range."); + } + err.emit(); } Err(ErrorReported) => {} } diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index 1a285cd869aec..bf253a88d27c2 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -214,12 +214,25 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { end.span }; - struct_span_err!(tcx.sess, span, E0029, - "only char and numeric types are allowed in range patterns") - .span_label(span, "ranges require char or numeric types") - .note(&format!("start type: {}", self.ty_to_string(lhs_ty))) - .note(&format!("end type: {}", self.ty_to_string(rhs_ty))) - .emit(); + let mut err = struct_span_err!( + tcx.sess, + span, + E0029, + "only char and numeric types are allowed in range patterns" + ); + err.span_label(span, "ranges require char or numeric types"); + err.note(&format!("start type: {}", self.ty_to_string(lhs_ty))); + err.note(&format!("end type: {}", self.ty_to_string(rhs_ty))); + if tcx.sess.teach(&err.get_code().unwrap()) { + err.note( + "In a match expression, only numbers and characters can be matched \ + against a range. This is because the compiler checks that the range \ + is non-empty at compile-time, and is unable to evaluate arbitrary \ + comparison functions. If you want to capture values of an orderable \ + type between two end-points, you can use a guard." + ); + } + err.emit(); return; } @@ -505,10 +518,25 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // This is "x = SomeTrait" being reduced from // "let &x = &SomeTrait" or "let box x = Box", an error. let type_str = self.ty_to_string(expected); - struct_span_err!(self.tcx.sess, span, E0033, - "type `{}` cannot be dereferenced", type_str) - .span_label(span, format!("type `{}` cannot be dereferenced", type_str)) - .emit(); + let mut err = struct_span_err!( + self.tcx.sess, + span, + E0033, + "type `{}` cannot be dereferenced", + type_str + ); + err.span_label(span, format!("type `{}` cannot be dereferenced", type_str)); + if self.tcx.sess.teach(&err.get_code().unwrap()) { + err.note("\ +This error indicates that a pointer to a trait type cannot be implicitly dereferenced by a \ +pattern. Every trait defines a type, but because the size of trait implementors isn't fixed, \ +this type has no compile-time size. Therefore, all accesses to trait types must be through \ +pointers. If you encounter this error you should try to avoid dereferencing the pointer. + +You can read more about trait objects in the Trait Objects section of the Reference: \ +https://doc.rust-lang.org/reference/types.html#trait-objects"); + } + err.emit(); return false } } @@ -881,17 +909,33 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.field_ty(span, f, substs) }) .unwrap_or_else(|| { - struct_span_err!(tcx.sess, span, E0026, - "{} `{}` does not have a field named `{}`", - kind_name, - tcx.item_path_str(variant.did), - field.name) - .span_label(span, - format!("{} `{}` does not have field `{}`", - kind_name, - tcx.item_path_str(variant.did), - field.name)) - .emit(); + let mut err = struct_span_err!( + tcx.sess, + span, + E0026, + "{} `{}` does not have a field named `{}`", + kind_name, + tcx.item_path_str(variant.did), + field.name + ); + err.span_label(span, + format!("{} `{}` does not have field `{}`", + kind_name, + tcx.item_path_str(variant.did), + field.name)); + if tcx.sess.teach(&err.get_code().unwrap()) { + err.note( + "This error indicates that a struct pattern attempted to \ + extract a non-existent field from a struct. Struct fields \ + are identified by the name used before the colon : so struct \ + patterns should resemble the declaration of the struct type \ + being matched.\n\n\ + If you are using shorthand field patterns but want to refer \ + to the struct field by a different name, you should rename \ + it explicitly." + ); + } + err.emit(); tcx.types.err }) @@ -927,6 +971,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if variant.ctor_kind == CtorKind::Fn { diag.note("trying to match a tuple variant with a struct variant pattern"); } + if tcx.sess.teach(&diag.get_code().unwrap()) { + diag.note( + "This error indicates that a pattern for a struct fails to specify a \ + sub-pattern for every one of the struct's fields. Ensure that each field \ + from the struct's definition is mentioned in the pattern, or use `..` to \ + ignore unwanted fields." + ); + } diag.emit(); } } From 94ad4e1d38d4f3ac0f3e532b5cd07f0e15025c87 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 24 Jan 2018 00:38:41 +0100 Subject: [PATCH 156/198] Add theme tests --- src/librustdoc/lib.rs | 27 +++++ src/librustdoc/theme.rs | 258 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 285 insertions(+) create mode 100644 src/librustdoc/theme.rs diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index e39fe20310c28..efdfcafb40a2f 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -91,6 +91,7 @@ pub mod plugins; pub mod visit_ast; pub mod visit_lib; pub mod test; +pub mod theme; use clean::AttributesExt; @@ -267,6 +268,11 @@ pub fn opts() -> Vec { "additional themes which will be added to the generated docs", "FILES") }), + unstable("theme-checker", |o| { + o.optmulti("", "theme-checker", + "check if given theme is valid", + "FILES") + }), ] } @@ -316,6 +322,27 @@ pub fn main_args(args: &[String]) -> isize { return 0; } + let to_check = matches.opt_strs("theme-checker"); + if !to_check.is_empty() { + let pathes = theme::load_css_pathes(include_bytes!("html/static/themes/main.css")); + let mut errors = 0; + + println!("rustdoc: [theme-checker] Starting tests!"); + for theme_file in to_check.iter() { + print!(" - Checking \"{}\"...", theme_file); + if !theme::test_theme_against(theme_file, &pathes) { + eprintln!(" FAILED"); + errors += 1; + } else { + println!(" OK"); + } + } + if errors != 0 { + return 1; + } + return 0; + } + if matches.free.is_empty() { print_error("missing file operand"); return 1; diff --git a/src/librustdoc/theme.rs b/src/librustdoc/theme.rs new file mode 100644 index 0000000000000..ff1adc3e4c4f7 --- /dev/null +++ b/src/librustdoc/theme.rs @@ -0,0 +1,258 @@ +// Copyright 2012-2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::collections::HashSet; +use std::fs::File; +use std::hash::{Hash, Hasher}; +use std::io::Read; +use std::path::Path; + +macro_rules! try_false { + ($e:expr) => ({ + match $e { + Ok(c) => c, + Err(e) => { + eprintln!("rustdoc: got an error: {}", e); + return false; + } + } + }) +} + +#[derive(Debug, Clone, Eq)] +pub struct CssPath { + pub name: String, + pub children: HashSet, +} + +// This PartialEq implementation IS NOT COMMUTATIVE!!! +// +// The order is very important: the second object must have all first's rules. +// However, the first doesn't require to have all second's rules. +impl PartialEq for CssPath { + fn eq(&self, other: &CssPath) -> bool { + if self.name != other.name { + false + } else { + for child in &self.children { + if !other.children.iter().any(|c| child == c) { + return false; + } + } + true + } + } +} + +impl Hash for CssPath { + fn hash(&self, state: &mut H) { + self.name.hash(state); + for x in &self.children { + x.hash(state); + } + } +} + +impl CssPath { + fn new(name: String) -> CssPath { + CssPath { + name, + children: HashSet::new(), + } + } +} + +/// All variants contain the position they occur. +#[derive(Debug, Clone, Copy)] +enum Events { + StartLineComment(usize), + StartComment(usize), + EndComment(usize), + InBlock(usize), + OutBlock(usize), +} + +impl Events { + fn get_pos(&self) -> usize { + match *self { + Events::StartLineComment(p) | + Events::StartComment(p) | + Events::EndComment(p) | + Events::InBlock(p) | + Events::OutBlock(p) => p, + } + } + + fn is_comment(&self) -> bool { + match *self { + Events::StartLineComment(_) | + Events::StartComment(_) | + Events::EndComment(_) => true, + _ => false, + } + } +} + +fn previous_is_line_comment(events: &[Events]) -> bool { + if let Some(&Events::StartLineComment(_)) = events.last() { + true + } else { + false + } +} + +fn is_line_comment(pos: usize, v: &[u8], events: &[Events]) -> bool { + if let Some(&Events::StartComment(_)) = events.last() { + return false; + } + pos + 1 < v.len() && v[pos + 1] == b'/' +} + +fn load_css_events(v: &[u8]) -> Vec { + let mut pos = 0; + let mut events = Vec::with_capacity(100); + + while pos < v.len() - 1 { + match v[pos] { + b'/' if pos + 1 < v.len() && v[pos + 1] == b'*' => { + events.push(Events::StartComment(pos)); + pos += 1; + } + b'/' if is_line_comment(pos, v, &events) => { + events.push(Events::StartLineComment(pos)); + pos += 1; + } + b'\n' if previous_is_line_comment(&events) => { + events.push(Events::EndComment(pos)); + } + b'*' if pos + 1 < v.len() && v[pos + 1] == b'/' => { + events.push(Events::EndComment(pos + 2)); + pos += 1; + } + b'{' if !previous_is_line_comment(&events) => { + if let Some(&Events::StartComment(_)) = events.last() { + pos += 1; + continue + } + events.push(Events::InBlock(pos + 1)); + } + b'}' if !previous_is_line_comment(&events) => { + if let Some(&Events::StartComment(_)) = events.last() { + pos += 1; + continue + } + events.push(Events::OutBlock(pos + 1)); + } + _ => {} + } + pos += 1; + } + events +} + +fn get_useful_next(events: &[Events], pos: &mut usize) -> Option { + while *pos < events.len() { + if !events[*pos].is_comment() { + return Some(events[*pos]); + } + *pos += 1; + } + None +} + +fn inner(v: &[u8], events: &[Events], pos: &mut usize) -> HashSet { + let mut pathes = Vec::with_capacity(50); + + while *pos < events.len() { + if let Some(Events::OutBlock(_)) = get_useful_next(events, pos) { + println!("00 => {:?}", events[*pos]); + *pos += 1; + break + } + println!("a => {:?}", events[*pos]); + if let Some(Events::InBlock(start_pos)) = get_useful_next(events, pos) { + println!("aa => {:?}", events[*pos]); + pathes.push(CssPath::new(::std::str::from_utf8(if *pos > 0 { + &v[events[*pos - 1].get_pos()..start_pos - 1] + } else { + &v[..start_pos] + }).unwrap_or("").trim().to_owned())); + *pos += 1; + } + println!("b => {:?}", events[*pos]); + while let Some(Events::InBlock(_)) = get_useful_next(events, pos) { + println!("bb => {:?}", events[*pos]); + if let Some(ref mut path) = pathes.last_mut() { + for entry in inner(v, events, pos).iter() { + path.children.insert(entry.clone()); + } + } + } + if *pos < events.len() { + println!("c => {:?}", events[*pos]); + } + if let Some(Events::OutBlock(_)) = get_useful_next(events, pos) { + *pos += 1; + } + } + pathes.iter().cloned().collect() +} + +pub fn load_css_pathes(v: &[u8]) -> CssPath { + let events = load_css_events(v); + let mut pos = 0; + + println!("\n======> {:?}", events); + let mut parent = CssPath::new("parent".to_owned()); + parent.children = inner(v, &events, &mut pos); + parent +} + +pub fn test_theme_against>(f: &P, against: &CssPath) -> bool { + let mut file = try_false!(File::open(f)); + let mut data = Vec::with_capacity(1000); + + try_false!(file.read_to_end(&mut data)); + let pathes = load_css_pathes(&data); + println!("========= {:?}", pathes); + println!("========= {:?}", against); + pathes == *against +} + +#[test] +fn test_comments_in_rules() { + let text = r#" +rule a {} + +rule b, c +// a line comment +{} + +rule d +// another line comment +e {} + +rule f/* a multine + +comment*/{} + +rule g/* another multine + +comment*/h + +i {} + +rule j/*commeeeeent + +you like things like "{}" in there? :) +*/ +end {} +"#; +} \ No newline at end of file From b44b033bf1a8f74f190854048616ca90db21319e Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 25 Jan 2018 21:58:10 +0100 Subject: [PATCH 157/198] get differences --- src/librustdoc/lib.rs | 4 +++- src/librustdoc/theme.rs | 49 +++++++++++++++++++++++++++++++++-------- 2 files changed, 43 insertions(+), 10 deletions(-) diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index efdfcafb40a2f..613ac67f03bf5 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -330,9 +330,11 @@ pub fn main_args(args: &[String]) -> isize { println!("rustdoc: [theme-checker] Starting tests!"); for theme_file in to_check.iter() { print!(" - Checking \"{}\"...", theme_file); - if !theme::test_theme_against(theme_file, &pathes) { + let differences = theme::test_theme_against(theme_file, &pathes); + if !differences.is_empty() { eprintln!(" FAILED"); errors += 1; + eprintln!("{}", differences.join("\n")); } else { println!(" OK"); } diff --git a/src/librustdoc/theme.rs b/src/librustdoc/theme.rs index ff1adc3e4c4f7..933749cfcf9ba 100644 --- a/src/librustdoc/theme.rs +++ b/src/librustdoc/theme.rs @@ -14,13 +14,13 @@ use std::hash::{Hash, Hasher}; use std::io::Read; use std::path::Path; -macro_rules! try_false { - ($e:expr) => ({ +macro_rules! try_something { + ($e:expr, $out:expr) => ({ match $e { Ok(c) => c, Err(e) => { eprintln!("rustdoc: got an error: {}", e); - return false; + return $out; } } }) @@ -215,18 +215,49 @@ pub fn load_css_pathes(v: &[u8]) -> CssPath { parent } -pub fn test_theme_against>(f: &P, against: &CssPath) -> bool { - let mut file = try_false!(File::open(f)); +fn get_differences(against: &CssPath, other: &CssPath, v: &mut Vec) { + if against.name != other.name { + return + } else { + for child in &against.children { + let mut found = false; + let mut found_working = false; + let mut tmp = Vec::new(); + + for other_child in &other.children { + if child.name == other_child.name { + if child != other_child { + get_differences(child, other_child, &mut tmp); + } else { + found_working = true; + } + found = true; + break + } + } + if found == false { + v.push(format!(" Missing \"{}\" rule", child.name)); + } else if found_working == false { + v.extend(tmp.iter().cloned()); + } + } + } +} + +pub fn test_theme_against>(f: &P, against: &CssPath) -> Vec { + let mut file = try_something!(File::open(f), Vec::new()); let mut data = Vec::with_capacity(1000); - try_false!(file.read_to_end(&mut data)); + try_something!(file.read_to_end(&mut data), Vec::new()); let pathes = load_css_pathes(&data); println!("========= {:?}", pathes); println!("========= {:?}", against); - pathes == *against + let mut ret = Vec::new(); + get_differences(against, &pathes, &mut ret); + ret } -#[test] +/*#[test] fn test_comments_in_rules() { let text = r#" rule a {} @@ -255,4 +286,4 @@ you like things like "{}" in there? :) */ end {} "#; -} \ No newline at end of file +}*/ From 649715d09b29c76f71eb5d213d34b4108b8dcf65 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 25 Jan 2018 21:59:54 +0100 Subject: [PATCH 158/198] Fix missing rules for dark.css --- src/librustdoc/html/static/themes/dark.css | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index 907a6e4fcb4a0..b45c3bf8e5f4e 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -112,10 +112,13 @@ pre { } .content .highlighted a, .content .highlighted span { color: #eee !important; } .content .highlighted.trait { background-color: #013191; } +.content .highlighted.mod, +.content .highlighted.externcrate { background-color: #afc6e4; } .content .highlighted.mod { background-color: #803a1b; } .content .highlighted.externcrate { background-color: #396bac; } .content .highlighted.enum { background-color: #5b4e68; } .content .highlighted.struct { background-color: #194e9f; } +.content .highlighted.union { background-color: #b7bd49; } .content .highlighted.fn, .content .highlighted.method, .content .highlighted.tymethod { background-color: #4950ed; } From 583b29f85c3f478e633eba38c59505e1a31694e6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 25 Jan 2018 23:23:09 +0100 Subject: [PATCH 159/198] Handle comments in css selector and add tests --- src/librustdoc/theme.rs | 103 +++++++++++++++++++++++++++++++--------- 1 file changed, 80 insertions(+), 23 deletions(-) diff --git a/src/librustdoc/theme.rs b/src/librustdoc/theme.rs index 933749cfcf9ba..b64d61184e0dd 100644 --- a/src/librustdoc/theme.rs +++ b/src/librustdoc/theme.rs @@ -167,37 +167,53 @@ fn get_useful_next(events: &[Events], pos: &mut usize) -> Option { None } +fn get_previous_positions(events: &[Events], mut pos: usize) -> Vec { + let mut ret = Vec::with_capacity(3); + + ret.push(events[pos].get_pos() - 1); + if pos > 0 { + pos -= 1; + } + loop { + ret.push(events[pos].get_pos()); + if pos < 1 || !events[pos].is_comment() { + break + } + pos -= 1; + } + if events[pos].is_comment() { + ret.push(0); + } + ret.iter().rev().cloned().collect() +} + +fn build_rule(v: &[u8], positions: &[usize]) -> String { + positions.chunks(2) + .map(|x| ::std::str::from_utf8(&v[x[0]..x[1]]).unwrap_or("").to_owned()) + .collect::() + .trim() + .replace("\n", " ") +} + fn inner(v: &[u8], events: &[Events], pos: &mut usize) -> HashSet { let mut pathes = Vec::with_capacity(50); while *pos < events.len() { if let Some(Events::OutBlock(_)) = get_useful_next(events, pos) { - println!("00 => {:?}", events[*pos]); *pos += 1; break } - println!("a => {:?}", events[*pos]); - if let Some(Events::InBlock(start_pos)) = get_useful_next(events, pos) { - println!("aa => {:?}", events[*pos]); - pathes.push(CssPath::new(::std::str::from_utf8(if *pos > 0 { - &v[events[*pos - 1].get_pos()..start_pos - 1] - } else { - &v[..start_pos] - }).unwrap_or("").trim().to_owned())); + if let Some(Events::InBlock(_)) = get_useful_next(events, pos) { + pathes.push(CssPath::new(build_rule(v, &get_previous_positions(events, *pos)))); *pos += 1; } - println!("b => {:?}", events[*pos]); while let Some(Events::InBlock(_)) = get_useful_next(events, pos) { - println!("bb => {:?}", events[*pos]); if let Some(ref mut path) = pathes.last_mut() { for entry in inner(v, events, pos).iter() { path.children.insert(entry.clone()); } } } - if *pos < events.len() { - println!("c => {:?}", events[*pos]); - } if let Some(Events::OutBlock(_)) = get_useful_next(events, pos) { *pos += 1; } @@ -209,13 +225,12 @@ pub fn load_css_pathes(v: &[u8]) -> CssPath { let events = load_css_events(v); let mut pos = 0; - println!("\n======> {:?}", events); let mut parent = CssPath::new("parent".to_owned()); parent.children = inner(v, &events, &mut pos); parent } -fn get_differences(against: &CssPath, other: &CssPath, v: &mut Vec) { +pub fn get_differences(against: &CssPath, other: &CssPath, v: &mut Vec) { if against.name != other.name { return } else { @@ -250,16 +265,18 @@ pub fn test_theme_against>(f: &P, against: &CssPath) -> Vec Date: Thu, 25 Jan 2018 23:31:48 +0100 Subject: [PATCH 160/198] Add test when trying to add new theme --- src/librustdoc/lib.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 613ac67f03bf5..1bdcebcee98cb 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -398,12 +398,23 @@ pub fn main_args(args: &[String]) -> isize { } let mut themes = Vec::new(); - for theme in matches.opt_strs("themes").iter().map(|s| PathBuf::from(&s)) { - if !theme.is_file() { - eprintln!("rustdoc: option --themes arguments must all be files"); - return 1; + if matches.opt_present("themes") { + let pathes = theme::load_css_pathes(include_bytes!("html/static/themes/main.css")); + + for (theme_file, theme_s) in matches.opt_strs("themes") + .iter() + .map(|s| (PathBuf::from(&s), s.to_owned())) { + if !theme_file.is_file() { + eprintln!("rustdoc: option --themes arguments must all be files"); + return 1; + } + if !theme::test_theme_against(&theme_file, &pathes).is_empty() { + eprintln!("rustdoc: invalid theme: \"{}\"", theme_s); + eprintln!(" Check what's wrong with the \"theme-checker\" option"); + return 1; + } + themes.push(theme_file); } - themes.push(theme); } let external_html = match ExternalHtml::load( From 63ee1cd846b92eb3a124ec345d4889bdb5bca8e3 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 26 Jan 2018 00:43:57 +0100 Subject: [PATCH 161/198] Improve output a bit in case of error --- src/librustdoc/lib.rs | 11 +++++++---- src/librustdoc/theme.rs | 21 +++++++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 1bdcebcee98cb..c08cff988924d 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -330,11 +330,13 @@ pub fn main_args(args: &[String]) -> isize { println!("rustdoc: [theme-checker] Starting tests!"); for theme_file in to_check.iter() { print!(" - Checking \"{}\"...", theme_file); - let differences = theme::test_theme_against(theme_file, &pathes); - if !differences.is_empty() { + let (success, differences) = theme::test_theme_against(theme_file, &pathes); + if !differences.is_empty() || !success { eprintln!(" FAILED"); errors += 1; - eprintln!("{}", differences.join("\n")); + if !differences.is_empty() { + eprintln!("{}", differences.join("\n")); + } } else { println!(" OK"); } @@ -408,7 +410,8 @@ pub fn main_args(args: &[String]) -> isize { eprintln!("rustdoc: option --themes arguments must all be files"); return 1; } - if !theme::test_theme_against(&theme_file, &pathes).is_empty() { + let (success, ret) = theme::test_theme_against(&theme_file, &pathes); + if !success || !ret.is_empty() { eprintln!("rustdoc: invalid theme: \"{}\"", theme_s); eprintln!(" Check what's wrong with the \"theme-checker\" option"); return 1; diff --git a/src/librustdoc/theme.rs b/src/librustdoc/theme.rs index b64d61184e0dd..fe7538780412d 100644 --- a/src/librustdoc/theme.rs +++ b/src/librustdoc/theme.rs @@ -259,15 +259,15 @@ pub fn get_differences(against: &CssPath, other: &CssPath, v: &mut Vec) } } -pub fn test_theme_against>(f: &P, against: &CssPath) -> Vec { - let mut file = try_something!(File::open(f), Vec::new()); +pub fn test_theme_against>(f: &P, against: &CssPath) -> (bool, Vec) { + let mut file = try_something!(File::open(f), (false, Vec::new())); let mut data = Vec::with_capacity(1000); - try_something!(file.read_to_end(&mut data), Vec::new()); + try_something!(file.read_to_end(&mut data), (false, Vec::new())); let pathes = load_css_pathes(&data); let mut ret = Vec::new(); get_differences(against, &pathes, &mut ret); - ret + (true, ret) } #[cfg(test)] @@ -321,6 +321,19 @@ rule j end {} &load_css_pathes(text.as_bytes())).is_empty()); } + #[test] + fn test_text() { + let text = r#" +a +/* sdfs +*/ b +c // sdf +d {} +"#; + let pathes = load_css_pathes(text.as_bytes()); + assert!(pathes.children.get("a b c d").is_some()); + } + #[test] fn test_comparison() { let x = r#" From 51580d46f919c1f97d82aeca1ea1086c545c7484 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Fri, 26 Jan 2018 00:44:52 +0100 Subject: [PATCH 162/198] Add tests for themes --- src/bootstrap/builder.rs | 2 +- src/bootstrap/check.rs | 1 - src/bootstrap/test.rs | 42 ++++++++++++++++++ src/librustdoc/lib.rs | 8 ++-- src/librustdoc/theme.rs | 58 +++++++++++++++++-------- src/tools/rustdoc-themes/test-themes.py | 52 ++++++++++++++++++++++ 6 files changed, 138 insertions(+), 25 deletions(-) create mode 100644 src/tools/rustdoc-themes/test-themes.py diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index bf7b1015a4921..6c68ee18506bb 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -258,7 +258,7 @@ impl<'a> Builder<'a> { test::HostCompiletest, test::Crate, test::CrateLibrustc, test::Rustdoc, test::Linkcheck, test::Cargotest, test::Cargo, test::Rls, test::Docs, test::ErrorIndex, test::Distcheck, test::Rustfmt, test::Miri, test::Clippy, - test::RustdocJS), + test::RustdocJS, test::RustdocTheme), Kind::Bench => describe!(test::Crate, test::CrateLibrustc), Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook, doc::Standalone, doc::Std, doc::Test, doc::Rustc, doc::ErrorIndex, doc::Nomicon, diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index e6871764b2c78..ede403491d7fc 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -160,4 +160,3 @@ pub fn libtest_stamp(build: &Build, compiler: Compiler, target: Interned pub fn librustc_stamp(build: &Build, compiler: Compiler, target: Interned) -> PathBuf { build.cargo_out(compiler, Mode::Librustc, target).join(".librustc-check.stamp") } - diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index e4c1cdb79fd24..1c6cd066ad99e 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -424,6 +424,48 @@ fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString { env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("") } +#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] +pub struct RustdocTheme { + pub compiler: Compiler, + pub host: Interned, +} + +impl Step for RustdocTheme { + type Output = (); + const DEFAULT: bool = true; + const ONLY_HOSTS: bool = true; + + fn should_run(run: ShouldRun) -> ShouldRun { + run.path("src/tools/rustdoc-themes") + } + + fn make_run(run: RunConfig) { + let compiler = run.builder.compiler(run.builder.top_stage, run.host); + + run.builder.ensure(RustdocTheme { + compiler: compiler, + host: run.builder.build.build, + }); + } + + fn run(self, builder: &Builder) { + let rustdoc = builder.rustdoc(self.compiler.host); + let mut cmd = Command::new(builder.config.python.clone().expect("python not defined")); + cmd.args(&["src/tools/rustdoc-themes/test-themes.py", rustdoc.to_str().unwrap()]); + cmd.env("RUSTC_STAGE", self.compiler.stage.to_string()) + .env("RUSTC_SYSROOT", builder.sysroot(self.compiler)) + .env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host)) + .env("CFG_RELEASE_CHANNEL", &builder.build.config.channel) + .env("RUSTDOC_REAL", builder.rustdoc(self.host)) + .env("RUSTDOC_CRATE_VERSION", builder.build.rust_version()) + .env("RUSTC_BOOTSTRAP", "1"); + if let Some(linker) = builder.build.linker(self.host) { + cmd.env("RUSTC_TARGET_LINKER", linker); + } + builder.run(&mut cmd); + } +} + #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct RustdocJS { pub host: Interned, diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index c08cff988924d..17cf2b7349b28 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -324,13 +324,13 @@ pub fn main_args(args: &[String]) -> isize { let to_check = matches.opt_strs("theme-checker"); if !to_check.is_empty() { - let pathes = theme::load_css_pathes(include_bytes!("html/static/themes/main.css")); + let paths = theme::load_css_paths(include_bytes!("html/static/themes/main.css")); let mut errors = 0; println!("rustdoc: [theme-checker] Starting tests!"); for theme_file in to_check.iter() { print!(" - Checking \"{}\"...", theme_file); - let (success, differences) = theme::test_theme_against(theme_file, &pathes); + let (success, differences) = theme::test_theme_against(theme_file, &paths); if !differences.is_empty() || !success { eprintln!(" FAILED"); errors += 1; @@ -401,7 +401,7 @@ pub fn main_args(args: &[String]) -> isize { let mut themes = Vec::new(); if matches.opt_present("themes") { - let pathes = theme::load_css_pathes(include_bytes!("html/static/themes/main.css")); + let paths = theme::load_css_paths(include_bytes!("html/static/themes/main.css")); for (theme_file, theme_s) in matches.opt_strs("themes") .iter() @@ -410,7 +410,7 @@ pub fn main_args(args: &[String]) -> isize { eprintln!("rustdoc: option --themes arguments must all be files"); return 1; } - let (success, ret) = theme::test_theme_against(&theme_file, &pathes); + let (success, ret) = theme::test_theme_against(&theme_file, &paths); if !success || !ret.is_empty() { eprintln!("rustdoc: invalid theme: \"{}\"", theme_s); eprintln!(" Check what's wrong with the \"theme-checker\" option"); diff --git a/src/librustdoc/theme.rs b/src/librustdoc/theme.rs index fe7538780412d..39c9a6e2aa400 100644 --- a/src/librustdoc/theme.rs +++ b/src/librustdoc/theme.rs @@ -170,18 +170,24 @@ fn get_useful_next(events: &[Events], pos: &mut usize) -> Option { fn get_previous_positions(events: &[Events], mut pos: usize) -> Vec { let mut ret = Vec::with_capacity(3); - ret.push(events[pos].get_pos() - 1); + ret.push(events[pos].get_pos()); if pos > 0 { pos -= 1; } loop { - ret.push(events[pos].get_pos()); if pos < 1 || !events[pos].is_comment() { + let x = events[pos].get_pos(); + if *ret.last().unwrap() != x { + ret.push(x); + } else { + ret.push(0); + } break } + ret.push(events[pos].get_pos()); pos -= 1; } - if events[pos].is_comment() { + if ret.len() & 1 != 0 && events[pos].is_comment() { ret.push(0); } ret.iter().rev().cloned().collect() @@ -189,14 +195,22 @@ fn get_previous_positions(events: &[Events], mut pos: usize) -> Vec { fn build_rule(v: &[u8], positions: &[usize]) -> String { positions.chunks(2) - .map(|x| ::std::str::from_utf8(&v[x[0]..x[1]]).unwrap_or("").to_owned()) + .map(|x| ::std::str::from_utf8(&v[x[0]..x[1]]).unwrap_or("")) .collect::() .trim() .replace("\n", " ") + .replace("/", "") + .replace("\t", " ") + .replace("{", "") + .replace("}", "") + .split(" ") + .filter(|s| s.len() > 0) + .collect::>() + .join(" ") } fn inner(v: &[u8], events: &[Events], pos: &mut usize) -> HashSet { - let mut pathes = Vec::with_capacity(50); + let mut paths = Vec::with_capacity(50); while *pos < events.len() { if let Some(Events::OutBlock(_)) = get_useful_next(events, pos) { @@ -204,11 +218,11 @@ fn inner(v: &[u8], events: &[Events], pos: &mut usize) -> HashSet { break } if let Some(Events::InBlock(_)) = get_useful_next(events, pos) { - pathes.push(CssPath::new(build_rule(v, &get_previous_positions(events, *pos)))); + paths.push(CssPath::new(build_rule(v, &get_previous_positions(events, *pos)))); *pos += 1; } while let Some(Events::InBlock(_)) = get_useful_next(events, pos) { - if let Some(ref mut path) = pathes.last_mut() { + if let Some(ref mut path) = paths.last_mut() { for entry in inner(v, events, pos).iter() { path.children.insert(entry.clone()); } @@ -218,10 +232,10 @@ fn inner(v: &[u8], events: &[Events], pos: &mut usize) -> HashSet { *pos += 1; } } - pathes.iter().cloned().collect() + paths.iter().cloned().collect() } -pub fn load_css_pathes(v: &[u8]) -> CssPath { +pub fn load_css_paths(v: &[u8]) -> CssPath { let events = load_css_events(v); let mut pos = 0; @@ -264,9 +278,9 @@ pub fn test_theme_against>(f: &P, against: &CssPath) -> (bool, Ve let mut data = Vec::with_capacity(1000); try_something!(file.read_to_end(&mut data), (false, Vec::new())); - let pathes = load_css_pathes(&data); + let paths = load_css_paths(&data); let mut ret = Vec::new(); - get_differences(against, &pathes, &mut ret); + get_differences(against, &paths, &mut ret); (true, ret) } @@ -317,8 +331,11 @@ rule gh i {} rule j end {} "#; - assert!(get_differences(&load_css_pathes(against.as_bytes()), - &load_css_pathes(text.as_bytes())).is_empty()); + let mut ret = Vec::new(); + get_differences(&load_css_paths(against.as_bytes()), + &load_css_paths(text.as_bytes()), + &mut ret); + assert!(ret.is_empty()); } #[test] @@ -330,8 +347,8 @@ a c // sdf d {} "#; - let pathes = load_css_pathes(text.as_bytes()); - assert!(pathes.children.get("a b c d").is_some()); + let paths = load_css_paths(text.as_bytes()); + assert!(paths.children.get(&CssPath::new("a b c d".to_owned())).is_some()); } #[test] @@ -350,10 +367,13 @@ a { } "#; - let against = load_css_pathes(y.as_bytes()); - let other = load_css_pathes(x.as_bytes()); + let against = load_css_paths(y.as_bytes()); + let other = load_css_paths(x.as_bytes()); - assert!(get_differences(&against, &other).is_empty()); - assert_eq!(get_differences(&other, &against), vec![" Missing \"c\" rule".to_owned()]) + let mut ret = Vec::new(); + get_differences(&against, &other, &mut ret); + assert!(ret.is_empty()); + get_differences(&other, &against, &mut ret); + assert_eq!(ret, vec![" Missing \"c\" rule".to_owned()]); } } diff --git a/src/tools/rustdoc-themes/test-themes.py b/src/tools/rustdoc-themes/test-themes.py new file mode 100644 index 0000000000000..27756e3bef6b3 --- /dev/null +++ b/src/tools/rustdoc-themes/test-themes.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# Copyright 2018 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +from os import listdir +from os.path import isfile, join +import subprocess +import sys + +FILES_TO_IGNORE = ['main.css'] +THEME_DIR_PATH = "src/librustdoc/html/static/themes" + + +def print_err(msg): + sys.stderr.write('{}\n'.format(msg)) + + +def exec_command(command): + child = subprocess.Popen(command) + stdout, stderr = child.communicate() + return child.returncode + + +def main(argv): + if len(argv) < 1: + print_err("Needs rustdoc binary path") + return 1 + rustdoc_bin = argv[0] + themes = [join(THEME_DIR_PATH, f) for f in listdir(THEME_DIR_PATH) + if isfile(join(THEME_DIR_PATH, f)) and f not in FILES_TO_IGNORE] + if len(themes) < 1: + print_err('No theme found in "{}"...'.format(THEME_DIR_PATH)) + return 1 + args = [rustdoc_bin, '-Z', 'unstable-options', '--theme-checker'] + args.extend(themes) + return exec_command(args) + + +if __name__ != '__main__': + print_err("Needs to be run as main") + sys.exit(1) +else: + sys.exit(main(sys.argv[1:])) From b1b11d4589e8f7486bfc181286b954c498bba4c9 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Sat, 27 Jan 2018 22:12:28 +0100 Subject: [PATCH 163/198] Pass themes folder as parameter --- src/bootstrap/test.rs | 4 +++- src/librustdoc/lib.rs | 10 +++++----- src/librustdoc/theme.rs | 2 +- src/tools/rustdoc-themes/test-themes.py | 10 +++++----- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 1c6cd066ad99e..351d10df28d2c 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -451,7 +451,9 @@ impl Step for RustdocTheme { fn run(self, builder: &Builder) { let rustdoc = builder.rustdoc(self.compiler.host); let mut cmd = Command::new(builder.config.python.clone().expect("python not defined")); - cmd.args(&["src/tools/rustdoc-themes/test-themes.py", rustdoc.to_str().unwrap()]); + cmd.args(&[builder.src.join("src/tools/rustdoc-themes/test-themes.py").to_str().unwrap(), + rustdoc.to_str().unwrap(), + builder.src.join("src/librustdoc/html/static/themes").to_str().unwrap()]); cmd.env("RUSTC_STAGE", self.compiler.stage.to_string()) .env("RUSTC_SYSROOT", builder.sysroot(self.compiler)) .env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host)) diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 17cf2b7349b28..a72026c7d6b27 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -332,10 +332,10 @@ pub fn main_args(args: &[String]) -> isize { print!(" - Checking \"{}\"...", theme_file); let (success, differences) = theme::test_theme_against(theme_file, &paths); if !differences.is_empty() || !success { - eprintln!(" FAILED"); + println!(" FAILED"); errors += 1; if !differences.is_empty() { - eprintln!("{}", differences.join("\n")); + println!("{}", differences.join("\n")); } } else { println!(" OK"); @@ -407,13 +407,13 @@ pub fn main_args(args: &[String]) -> isize { .iter() .map(|s| (PathBuf::from(&s), s.to_owned())) { if !theme_file.is_file() { - eprintln!("rustdoc: option --themes arguments must all be files"); + println!("rustdoc: option --themes arguments must all be files"); return 1; } let (success, ret) = theme::test_theme_against(&theme_file, &paths); if !success || !ret.is_empty() { - eprintln!("rustdoc: invalid theme: \"{}\"", theme_s); - eprintln!(" Check what's wrong with the \"theme-checker\" option"); + println!("rustdoc: invalid theme: \"{}\"", theme_s); + println!(" Check what's wrong with the \"theme-checker\" option"); return 1; } themes.push(theme_file); diff --git a/src/librustdoc/theme.rs b/src/librustdoc/theme.rs index 39c9a6e2aa400..1e4f64f5c52c9 100644 --- a/src/librustdoc/theme.rs +++ b/src/librustdoc/theme.rs @@ -348,7 +348,7 @@ c // sdf d {} "#; let paths = load_css_paths(text.as_bytes()); - assert!(paths.children.get(&CssPath::new("a b c d".to_owned())).is_some()); + assert!(paths.children.contains(&CssPath::new("a b c d".to_owned()))); } #[test] diff --git a/src/tools/rustdoc-themes/test-themes.py b/src/tools/rustdoc-themes/test-themes.py index 27756e3bef6b3..31591277ce356 100644 --- a/src/tools/rustdoc-themes/test-themes.py +++ b/src/tools/rustdoc-themes/test-themes.py @@ -17,7 +17,6 @@ import sys FILES_TO_IGNORE = ['main.css'] -THEME_DIR_PATH = "src/librustdoc/html/static/themes" def print_err(msg): @@ -31,14 +30,15 @@ def exec_command(command): def main(argv): - if len(argv) < 1: + if len(argv) < 2: print_err("Needs rustdoc binary path") return 1 rustdoc_bin = argv[0] - themes = [join(THEME_DIR_PATH, f) for f in listdir(THEME_DIR_PATH) - if isfile(join(THEME_DIR_PATH, f)) and f not in FILES_TO_IGNORE] + themes_folder = argv[1] + themes = [join(themes_folder, f) for f in listdir(themes_folder) + if isfile(join(themes_folder, f)) and f not in FILES_TO_IGNORE] if len(themes) < 1: - print_err('No theme found in "{}"...'.format(THEME_DIR_PATH)) + print_err('No theme found in "{}"...'.format(themes_folder)) return 1 args = [rustdoc_bin, '-Z', 'unstable-options', '--theme-checker'] args.extend(themes) From dec9fab768e43a5c75456bb61c21701502db6de6 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 5 Feb 2018 23:43:53 +0100 Subject: [PATCH 164/198] Convert python script to rust --- src/Cargo.lock | 4 ++ src/Cargo.toml | 1 + src/bootstrap/test.rs | 19 ++++---- src/bootstrap/tool.rs | 1 + src/tools/rustdoc-themes/Cargo.toml | 8 ++++ src/tools/rustdoc-themes/main.rs | 59 +++++++++++++++++++++++++ src/tools/rustdoc-themes/test-themes.py | 52 ---------------------- 7 files changed, 81 insertions(+), 63 deletions(-) create mode 100644 src/tools/rustdoc-themes/Cargo.toml create mode 100644 src/tools/rustdoc-themes/main.rs delete mode 100644 src/tools/rustdoc-themes/test-themes.py diff --git a/src/Cargo.lock b/src/Cargo.lock index 52ed134c01ecd..afe7f841f2571 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -2217,6 +2217,10 @@ dependencies = [ "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rustdoc-themes" +version = "0.1.0" + [[package]] name = "rustdoc-tool" version = "0.0.0" diff --git a/src/Cargo.toml b/src/Cargo.toml index c22ba7a37c8b0..c03301852cd3b 100644 --- a/src/Cargo.toml +++ b/src/Cargo.toml @@ -22,6 +22,7 @@ members = [ "tools/rls", "tools/rustfmt", "tools/miri", + "tools/rustdoc-themes", # FIXME(https://github.com/rust-lang/cargo/issues/4089): move these to exclude "tools/rls/test_data/bin_lib", "tools/rls/test_data/borrow_error", diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 351d10df28d2c..eae8ec1311df7 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -113,7 +113,7 @@ impl Step for Linkcheck { let _time = util::timeit(); try_run(build, builder.tool_cmd(Tool::Linkchecker) - .arg(build.out.join(host).join("doc"))); + .arg(build.out.join(host).join("doc"))); } fn should_run(run: ShouldRun) -> ShouldRun { @@ -427,7 +427,6 @@ fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString { #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct RustdocTheme { pub compiler: Compiler, - pub host: Interned, } impl Step for RustdocTheme { @@ -444,27 +443,25 @@ impl Step for RustdocTheme { run.builder.ensure(RustdocTheme { compiler: compiler, - host: run.builder.build.build, }); } fn run(self, builder: &Builder) { let rustdoc = builder.rustdoc(self.compiler.host); - let mut cmd = Command::new(builder.config.python.clone().expect("python not defined")); - cmd.args(&[builder.src.join("src/tools/rustdoc-themes/test-themes.py").to_str().unwrap(), - rustdoc.to_str().unwrap(), - builder.src.join("src/librustdoc/html/static/themes").to_str().unwrap()]); - cmd.env("RUSTC_STAGE", self.compiler.stage.to_string()) + let mut cmd = builder.tool_cmd(Tool::RustdocTheme); + cmd.arg(rustdoc.to_str().unwrap()) + .arg(builder.src.join("src/librustdoc/html/static/themes").to_str().unwrap()) + .env("RUSTC_STAGE", self.compiler.stage.to_string()) .env("RUSTC_SYSROOT", builder.sysroot(self.compiler)) .env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host)) .env("CFG_RELEASE_CHANNEL", &builder.build.config.channel) - .env("RUSTDOC_REAL", builder.rustdoc(self.host)) + .env("RUSTDOC_REAL", builder.rustdoc(self.compiler.host)) .env("RUSTDOC_CRATE_VERSION", builder.build.rust_version()) .env("RUSTC_BOOTSTRAP", "1"); - if let Some(linker) = builder.build.linker(self.host) { + if let Some(linker) = builder.build.linker(self.compiler.host) { cmd.env("RUSTC_TARGET_LINKER", linker); } - builder.run(&mut cmd); + try_run(builder.build, &mut cmd); } } diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index ea055cb5d1b99..9036eb044b5a5 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -260,6 +260,7 @@ tool!( BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::Libstd; RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::Libstd; RustInstaller, "src/tools/rust-installer", "fabricate", Mode::Libstd; + RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes", Mode::Libstd; ); #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] diff --git a/src/tools/rustdoc-themes/Cargo.toml b/src/tools/rustdoc-themes/Cargo.toml new file mode 100644 index 0000000000000..c0e2f527301be --- /dev/null +++ b/src/tools/rustdoc-themes/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "rustdoc-themes" +version = "0.1.0" +authors = ["Guillaume Gomez "] + +[[bin]] +name = "rustdoc-themes" +path = "main.rs" diff --git a/src/tools/rustdoc-themes/main.rs b/src/tools/rustdoc-themes/main.rs new file mode 100644 index 0000000000000..4028cb4e8b6ed --- /dev/null +++ b/src/tools/rustdoc-themes/main.rs @@ -0,0 +1,59 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::env::args; +use std::fs::read_dir; +use std::path::Path; +use std::process::{Command, exit}; + +const FILES_TO_IGNORE: &[&str] = &["main.css"]; + +fn get_folders>(folder_path: P) -> Vec { + let mut ret = Vec::with_capacity(10); + + for entry in read_dir(folder_path.as_ref()).expect("read_dir failed") { + let entry = entry.expect("Couldn't unwrap entry"); + let path = entry.path(); + + if !path.is_file() { + continue + } + let filename = path.file_name().expect("file_name failed"); + if FILES_TO_IGNORE.iter().any(|x| x == &filename) { + continue + } + ret.push(format!("{}", path.display())); + } + ret +} + +fn main() { + let argv: Vec = args().collect(); + + if argv.len() < 3 { + eprintln!("Needs rustdoc binary path"); + exit(1); + } + let rustdoc_bin = &argv[1]; + let themes_folder = &argv[2]; + let themes = get_folders(&themes_folder); + if themes.is_empty() { + eprintln!("No theme found in \"{}\"...", themes_folder); + exit(1); + } + let status = Command::new(rustdoc_bin) + .args(&["-Z", "unstable-options", "--theme-checker"]) + .args(&themes) + .status() + .expect("failed to execute child"); + if !status.success() { + exit(1); + } +} diff --git a/src/tools/rustdoc-themes/test-themes.py b/src/tools/rustdoc-themes/test-themes.py deleted file mode 100644 index 31591277ce356..0000000000000 --- a/src/tools/rustdoc-themes/test-themes.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Copyright 2018 The Rust Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution and at -# http://rust-lang.org/COPYRIGHT. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - -from os import listdir -from os.path import isfile, join -import subprocess -import sys - -FILES_TO_IGNORE = ['main.css'] - - -def print_err(msg): - sys.stderr.write('{}\n'.format(msg)) - - -def exec_command(command): - child = subprocess.Popen(command) - stdout, stderr = child.communicate() - return child.returncode - - -def main(argv): - if len(argv) < 2: - print_err("Needs rustdoc binary path") - return 1 - rustdoc_bin = argv[0] - themes_folder = argv[1] - themes = [join(themes_folder, f) for f in listdir(themes_folder) - if isfile(join(themes_folder, f)) and f not in FILES_TO_IGNORE] - if len(themes) < 1: - print_err('No theme found in "{}"...'.format(themes_folder)) - return 1 - args = [rustdoc_bin, '-Z', 'unstable-options', '--theme-checker'] - args.extend(themes) - return exec_command(args) - - -if __name__ != '__main__': - print_err("Needs to be run as main") - sys.exit(1) -else: - sys.exit(main(sys.argv[1:])) From c00266b7ac97a8c04136e14f10eb70fb64ec2c94 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 15 Jan 2018 12:47:26 +0100 Subject: [PATCH 165/198] Encode (in MIR) whether borrows are explicit in source or arise due to autoref. This is foundation for issue 46747 (limit two-phase borrows to method-call autorefs). --- src/librustc/ich/impls_mir.rs | 20 ++++++++++++++++++- src/librustc/mir/mod.rs | 8 ++++++-- src/librustc/mir/tcx.rs | 2 +- src/librustc/mir/visit.rs | 6 ++++-- src/librustc_const_eval/pattern.rs | 4 ++-- .../borrow_check/error_reporting.rs | 8 ++++---- src/librustc_mir/borrow_check/mod.rs | 14 ++++++------- src/librustc_mir/dataflow/impls/borrows.rs | 2 +- src/librustc_mir/hair/cx/expr.rs | 15 +++++++------- src/librustc_mir/shim.rs | 5 ++++- src/librustc_mir/transform/inline.rs | 4 ++-- src/librustc_mir/transform/qualify_consts.rs | 2 +- src/librustc_mir/util/elaborate_drops.rs | 10 +++++++--- src/librustc_trans/mir/constant.rs | 2 +- 14 files changed, 67 insertions(+), 35 deletions(-) diff --git a/src/librustc/ich/impls_mir.rs b/src/librustc/ich/impls_mir.rs index f46b590d2dc59..03a369577a31e 100644 --- a/src/librustc/ich/impls_mir.rs +++ b/src/librustc/ich/impls_mir.rs @@ -20,7 +20,6 @@ use std::mem; impl_stable_hash_for!(struct mir::GeneratorLayout<'tcx> { fields }); impl_stable_hash_for!(struct mir::SourceInfo { span, scope }); impl_stable_hash_for!(enum mir::Mutability { Mut, Not }); -impl_stable_hash_for!(enum mir::BorrowKind { Shared, Unique, Mut }); impl_stable_hash_for!(enum mir::LocalKind { Var, Temp, Arg, ReturnPointer }); impl_stable_hash_for!(struct mir::LocalDecl<'tcx> { mutability, @@ -36,6 +35,25 @@ impl_stable_hash_for!(struct mir::BasicBlockData<'tcx> { statements, terminator, impl_stable_hash_for!(struct mir::UnsafetyViolation { source_info, description, kind }); impl_stable_hash_for!(struct mir::UnsafetyCheckResult { violations, unsafe_blocks }); +impl<'gcx> HashStable> +for mir::BorrowKind { + #[inline] + fn hash_stable(&self, + hcx: &mut StableHashingContext<'gcx>, + hasher: &mut StableHasher) { + mem::discriminant(self).hash_stable(hcx, hasher); + + match *self { + mir::BorrowKind::Shared | + mir::BorrowKind::Unique => {} + mir::BorrowKind::Mut { allow_two_phase_borrow } => { + allow_two_phase_borrow.hash_stable(hcx, hasher); + } + } + } +} + + impl<'gcx> HashStable> for mir::UnsafetyViolationKind { #[inline] diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index d82691f882c73..70bfc1e2d327f 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -413,7 +413,11 @@ pub enum BorrowKind { Unique, /// Data is mutable and not aliasable. - Mut, + Mut { + /// True if this borrow arose from method-call auto-ref + /// (i.e. `adjustment::Adjust::Borrow`) + allow_two_phase_borrow: bool + } } /////////////////////////////////////////////////////////////////////////// @@ -1611,7 +1615,7 @@ impl<'tcx> Debug for Rvalue<'tcx> { Ref(region, borrow_kind, ref place) => { let kind_str = match borrow_kind { BorrowKind::Shared => "", - BorrowKind::Mut | BorrowKind::Unique => "mut ", + BorrowKind::Mut { .. } | BorrowKind::Unique => "mut ", }; // When printing regions, add trailing space if necessary. diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index 53607764b3984..5433c54fb949c 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -264,7 +264,7 @@ impl<'tcx> BinOp { impl BorrowKind { pub fn to_mutbl_lossy(self) -> hir::Mutability { match self { - BorrowKind::Mut => hir::MutMutable, + BorrowKind::Mut { .. } => hir::MutMutable, BorrowKind::Shared => hir::MutImmutable, // We have no type corresponding to a unique imm borrow, so diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index 57ed41f2f06e6..afaf7d41e92ff 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -951,9 +951,10 @@ impl<'tcx> PlaceContext<'tcx> { pub fn is_mutating_use(&self) -> bool { match *self { PlaceContext::Store | PlaceContext::AsmOutput | PlaceContext::Call | - PlaceContext::Borrow { kind: BorrowKind::Mut, .. } | + PlaceContext::Borrow { kind: BorrowKind::Mut { .. }, .. } | PlaceContext::Projection(Mutability::Mut) | PlaceContext::Drop => true, + PlaceContext::Inspect | PlaceContext::Borrow { kind: BorrowKind::Shared, .. } | PlaceContext::Borrow { kind: BorrowKind::Unique, .. } | @@ -971,7 +972,8 @@ impl<'tcx> PlaceContext<'tcx> { PlaceContext::Borrow { kind: BorrowKind::Unique, .. } | PlaceContext::Projection(Mutability::Not) | PlaceContext::Copy | PlaceContext::Move => true, - PlaceContext::Borrow { kind: BorrowKind::Mut, .. } | PlaceContext::Store | + + PlaceContext::Borrow { kind: BorrowKind::Mut { .. }, .. } | PlaceContext::Store | PlaceContext::AsmOutput | PlaceContext::Call | PlaceContext::Projection(Mutability::Mut) | PlaceContext::Drop | PlaceContext::StorageLive | PlaceContext::StorageDead | diff --git a/src/librustc_const_eval/pattern.rs b/src/librustc_const_eval/pattern.rs index e0b3929e32a8d..bdb1001124de6 100644 --- a/src/librustc_const_eval/pattern.rs +++ b/src/librustc_const_eval/pattern.rs @@ -134,7 +134,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> { BindingMode::ByValue => mutability == Mutability::Mut, BindingMode::ByRef(_, bk) => { write!(f, "ref ")?; - bk == BorrowKind::Mut + match bk { BorrowKind::Mut { .. } => true, _ => false } } }; if is_mut { @@ -429,7 +429,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { (Mutability::Not, BindingMode::ByValue), ty::BindByReference(hir::MutMutable) => (Mutability::Not, BindingMode::ByRef( - region.unwrap(), BorrowKind::Mut)), + region.unwrap(), BorrowKind::Mut { allow_two_phase_borrow: false })), ty::BindByReference(hir::MutImmutable) => (Mutability::Not, BindingMode::ByRef( region.unwrap(), BorrowKind::Shared)), diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index 1ea897bf27ca5..34551e8e76f59 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -256,8 +256,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { "immutable", "mutable", ) { - (BorrowKind::Shared, lft, _, BorrowKind::Mut, _, rgt) | - (BorrowKind::Mut, _, lft, BorrowKind::Shared, rgt, _) => self.tcx + (BorrowKind::Shared, lft, _, BorrowKind::Mut { .. }, _, rgt) | + (BorrowKind::Mut { .. }, _, lft, BorrowKind::Shared, rgt, _) => self.tcx .cannot_reborrow_already_borrowed( span, &desc_place, @@ -271,7 +271,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { Origin::Mir, ), - (BorrowKind::Mut, _, _, BorrowKind::Mut, _, _) => self.tcx + (BorrowKind::Mut { .. }, _, _, BorrowKind::Mut { .. }, _, _) => self.tcx .cannot_mutably_borrow_multiply( span, &desc_place, @@ -314,7 +314,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { Origin::Mir, ), - (BorrowKind::Mut, _, lft, BorrowKind::Unique, _, _) => self.tcx + (BorrowKind::Mut { .. }, _, lft, BorrowKind::Unique, _, _) => self.tcx .cannot_reborrow_already_uniquely_borrowed( span, &desc_place, diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index d90209993aa48..647cf178310ad 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -797,7 +797,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { Control::Continue } - (Read(kind), BorrowKind::Unique) | (Read(kind), BorrowKind::Mut) => { + (Read(kind), BorrowKind::Unique) | (Read(kind), BorrowKind::Mut { .. }) => { // Reading from mere reservations of mutable-borrows is OK. if this.tcx.sess.two_phase_borrows() && index.is_reservation() { @@ -828,7 +828,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } (Reservation(kind), BorrowKind::Unique) - | (Reservation(kind), BorrowKind::Mut) + | (Reservation(kind), BorrowKind::Mut { .. }) | (Activation(kind, _), _) | (Write(kind), _) => { match rw { @@ -945,7 +945,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { Rvalue::Ref(_ /*rgn*/, bk, ref place) => { let access_kind = match bk { BorrowKind::Shared => (Deep, Read(ReadKind::Borrow(bk))), - BorrowKind::Unique | BorrowKind::Mut => { + BorrowKind::Unique | BorrowKind::Mut { .. } => { let wk = WriteKind::MutableBorrow(bk); if self.tcx.sess.two_phase_borrows() { (Deep, Reservation(wk)) @@ -1196,7 +1196,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // mutable borrow before we check it. match borrow.kind { BorrowKind::Shared => return, - BorrowKind::Unique | BorrowKind::Mut => {} + BorrowKind::Unique | BorrowKind::Mut { .. } => {} } self.access_place( @@ -1467,8 +1467,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { span_bug!(span, "&unique borrow for {:?} should not fail", place); } } - Reservation(WriteKind::MutableBorrow(BorrowKind::Mut)) - | Write(WriteKind::MutableBorrow(BorrowKind::Mut)) => if let Err(place_err) = + Reservation(WriteKind::MutableBorrow(BorrowKind::Mut { .. })) + | Write(WriteKind::MutableBorrow(BorrowKind::Mut { .. })) => if let Err(place_err) = self.is_mutable(place, is_local_mutation_allowed) { error_reported = true; @@ -1532,7 +1532,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { Activation(..) => {} // permission checks are done at Reservation point. Read(ReadKind::Borrow(BorrowKind::Unique)) - | Read(ReadKind::Borrow(BorrowKind::Mut)) + | Read(ReadKind::Borrow(BorrowKind::Mut { .. })) | Read(ReadKind::Borrow(BorrowKind::Shared)) | Read(ReadKind::Copy) => {} // Access authorized } diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs index 80990bcc08089..fe9b0b86befc3 100644 --- a/src/librustc_mir/dataflow/impls/borrows.rs +++ b/src/librustc_mir/dataflow/impls/borrows.rs @@ -122,7 +122,7 @@ impl<'tcx> fmt::Display for BorrowData<'tcx> { let kind = match self.kind { mir::BorrowKind::Shared => "", mir::BorrowKind::Unique => "uniq ", - mir::BorrowKind::Mut => "mut ", + mir::BorrowKind::Mut { .. } => "mut ", }; let region = format!("{}", self.region); let region = if region.len() > 0 { format!("{} ", region) } else { region }; diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 317b038c48295..e33147a915b5f 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -21,6 +21,7 @@ use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow}; use rustc::ty::cast::CastKind as TyCastKind; use rustc::hir; use rustc::hir::def_id::LocalDefId; +use rustc::mir::{BorrowKind}; impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr { type Output = Expr<'tcx>; @@ -111,7 +112,7 @@ fn apply_adjustment<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, span, kind: ExprKind::Borrow { region: deref.region, - borrow_kind: to_borrow_kind(deref.mutbl), + borrow_kind: to_borrow_kind(deref.mutbl, true), arg: expr.to_ref(), }, }; @@ -121,7 +122,7 @@ fn apply_adjustment<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, Adjust::Borrow(AutoBorrow::Ref(r, m)) => { ExprKind::Borrow { region: r, - borrow_kind: to_borrow_kind(m), + borrow_kind: to_borrow_kind(m, true), arg: expr.to_ref(), } } @@ -141,7 +142,7 @@ fn apply_adjustment<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, span, kind: ExprKind::Borrow { region, - borrow_kind: to_borrow_kind(m), + borrow_kind: to_borrow_kind(m, true), arg: expr.to_ref(), }, }; @@ -287,7 +288,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, }; ExprKind::Borrow { region, - borrow_kind: to_borrow_kind(mutbl), + borrow_kind: to_borrow_kind(mutbl, false), arg: expr.to_ref(), } } @@ -642,9 +643,9 @@ fn method_callee<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } } -fn to_borrow_kind(m: hir::Mutability) -> BorrowKind { +fn to_borrow_kind(m: hir::Mutability, allow_two_phase_borrow: bool) -> BorrowKind { match m { - hir::MutMutable => BorrowKind::Mut, + hir::MutMutable => BorrowKind::Mut { allow_two_phase_borrow }, hir::MutImmutable => BorrowKind::Shared, } } @@ -947,7 +948,7 @@ fn capture_freevar<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, let borrow_kind = match upvar_borrow.kind { ty::BorrowKind::ImmBorrow => BorrowKind::Shared, ty::BorrowKind::UniqueImmBorrow => BorrowKind::Unique, - ty::BorrowKind::MutBorrow => BorrowKind::Mut, + ty::BorrowKind::MutBorrow => BorrowKind::Mut { allow_two_phase_borrow: false } }; Expr { temp_lifetime, diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index 42ffcc194ca8c..e6ebdd3d6c167 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -716,11 +716,14 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }), span )); + let borrow_kind = BorrowKind::Mut { + allow_two_phase_borrow: false, + }; statements.push(Statement { source_info, kind: StatementKind::Assign( Place::Local(ref_rcvr), - Rvalue::Ref(tcx.types.re_erased, BorrowKind::Mut, rcvr_l) + Rvalue::Ref(tcx.types.re_erased, borrow_kind, rcvr_l) ) }); Operand::Move(Place::Local(ref_rcvr)) diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index ceea97e3ed3b0..15bbcad7325be 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -426,7 +426,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { debug!("Creating temp for return destination"); let dest = Rvalue::Ref( self.tcx.types.re_erased, - BorrowKind::Mut, + BorrowKind::Mut { allow_two_phase_borrow: false }, destination.0); let ty = dest.ty(caller_mir, self.tcx); @@ -511,7 +511,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { callsite: &CallSite<'tcx>, caller_mir: &mut Mir<'tcx>) -> Local { let arg = Rvalue::Ref( self.tcx.types.re_erased, - BorrowKind::Mut, + BorrowKind::Mut { allow_two_phase_borrow: false }, arg.deref()); let ty = arg.ty(caller_mir, self.tcx); diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index da76adfd48f3f..d4ef90a7d7cf2 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -600,7 +600,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } let ty = place.ty(self.mir, self.tcx).to_ty(self.tcx); - if kind == BorrowKind::Mut { + if let BorrowKind::Mut { .. } = kind { // In theory, any zero-sized value could be borrowed // mutably without consequences. However, only &mut [] // is allowed right now, and only in functions. diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index 6577106801499..e2feb0ed39054 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -531,7 +531,9 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> let result = BasicBlockData { statements: vec![self.assign( &Place::Local(ref_place), - Rvalue::Ref(tcx.types.re_erased, BorrowKind::Mut, self.place.clone()) + Rvalue::Ref(tcx.types.re_erased, + BorrowKind::Mut { allow_two_phase_borrow: false }, + self.place.clone()) )], terminator: Some(Terminator { kind: TerminatorKind::Call { @@ -591,7 +593,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> } else { (Rvalue::Ref( tcx.types.re_erased, - BorrowKind::Mut, + BorrowKind::Mut { allow_two_phase_borrow: false }, self.place.clone().index(cur)), Rvalue::BinaryOp(BinOp::Add, copy(&Place::Local(cur)), one)) }; @@ -735,7 +737,9 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> // cur = tmp as *mut T; // end = Offset(cur, len); drop_block_stmts.push(self.assign(&tmp, Rvalue::Ref( - tcx.types.re_erased, BorrowKind::Mut, self.place.clone() + tcx.types.re_erased, + BorrowKind::Mut { allow_two_phase_borrow: false }, + self.place.clone() ))); drop_block_stmts.push(self.assign(&cur, Rvalue::Cast( CastKind::Misc, Operand::Move(tmp.clone()), iter_ty diff --git a/src/librustc_trans/mir/constant.rs b/src/librustc_trans/mir/constant.rs index cd1975488a24a..49b4ef0d38549 100644 --- a/src/librustc_trans/mir/constant.rs +++ b/src/librustc_trans/mir/constant.rs @@ -870,7 +870,7 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> { } else { self.cx.tcx.data_layout.pointer_align }; - if bk == mir::BorrowKind::Mut { + if let mir::BorrowKind::Mut { .. } = bk { consts::addr_of_mut(self.cx, llval, align, "ref_mut") } else { consts::addr_of(self.cx, llval, align, "ref") From 1855ab742458cc4359e27deadbdf3d8747ce361d Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Tue, 16 Jan 2018 10:52:52 +0100 Subject: [PATCH 166/198] Restrict two-phase borrows to solely borrows introduced via autoref. Added `-Z two-phase-beyond-autoref` to bring back old behavior (mainly to allow demonstration of desugared examples). Updated tests to use aforementioned flag when necessary. (But in each case where I added the flag, I made sure to also include a revision without the flag so that one can readily see what the actual behavior we expect is for the initial deployment of NLL.) --- src/librustc/mir/mod.rs | 9 +++++ src/librustc/session/config.rs | 2 ++ src/librustc_mir/borrow_check/mod.rs | 13 +++++-- ...o-phase-activation-sharing-interference.rs | 34 ++++++++++++++----- ...o-phase-allow-access-during-reservation.rs | 23 ++++++++++--- ...-phase-reservation-sharing-interference.rs | 28 ++++++++++++--- 6 files changed, 89 insertions(+), 20 deletions(-) diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 70bfc1e2d327f..c035d02a61232 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -420,6 +420,15 @@ pub enum BorrowKind { } } +impl BorrowKind { + pub fn allows_two_phase_borrow(&self) -> bool { + match *self { + BorrowKind::Shared | BorrowKind::Unique => false, + BorrowKind::Mut { allow_two_phase_borrow } => allow_two_phase_borrow, + } + } +} + /////////////////////////////////////////////////////////////////////////// // Variables and temps diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index c56575f432d1e..76564b9b7d2ac 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -1085,6 +1085,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "select which borrowck is used (`ast`, `mir`, or `compare`)"), two_phase_borrows: bool = (false, parse_bool, [UNTRACKED], "use two-phase reserved/active distinction for `&mut` borrows in MIR borrowck"), + two_phase_beyond_autoref: bool = (false, parse_bool, [UNTRACKED], + "when using two-phase-borrows, allow two phases even for non-autoref `&mut` borrows"), time_passes: bool = (false, parse_bool, [UNTRACKED], "measure time of each rustc pass"), count_llvm_insns: bool = (false, parse_bool, diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index 647cf178310ad..217dfdf8d416e 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -707,6 +707,15 @@ impl InitializationRequiringAction { } impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { + /// Returns true if the borrow represented by `kind` is + /// allowed to be split into separate Reservation and + /// Activation phases. + fn allow_two_phase_borrow(&self, kind: BorrowKind) -> bool { + self.tcx.sess.two_phase_borrows() && + (kind.allows_two_phase_borrow() || + self.tcx.sess.opts.debugging_opts.two_phase_beyond_autoref) + } + /// Checks an access to the given place to see if it is allowed. Examines the set of borrows /// that are in scope, as well as which paths have been initialized, to ensure that (a) the /// place is initialized and (b) it is not borrowed in some way that would prevent this @@ -799,7 +808,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { (Read(kind), BorrowKind::Unique) | (Read(kind), BorrowKind::Mut { .. }) => { // Reading from mere reservations of mutable-borrows is OK. - if this.tcx.sess.two_phase_borrows() && index.is_reservation() + if this.allow_two_phase_borrow(borrow.kind) && index.is_reservation() { return Control::Continue; } @@ -947,7 +956,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { BorrowKind::Shared => (Deep, Read(ReadKind::Borrow(bk))), BorrowKind::Unique | BorrowKind::Mut { .. } => { let wk = WriteKind::MutableBorrow(bk); - if self.tcx.sess.two_phase_borrows() { + if self.allow_two_phase_borrow(bk) { (Deep, Reservation(wk)) } else { (Deep, Write(wk)) diff --git a/src/test/compile-fail/borrowck/two-phase-activation-sharing-interference.rs b/src/test/compile-fail/borrowck/two-phase-activation-sharing-interference.rs index a9797e4d215a5..709c00ba8464a 100644 --- a/src/test/compile-fail/borrowck/two-phase-activation-sharing-interference.rs +++ b/src/test/compile-fail/borrowck/two-phase-activation-sharing-interference.rs @@ -8,9 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// revisions: lxl nll -//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows -//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll +// ignore-tidy-linelength + +// revisions: lxl_beyond nll_beyond nll_target + +//[lxl_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref +//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref -Z nll +//[nll_target] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll // This is an important corner case pointed out by Niko: one is // allowed to initiate a shared borrow during a reservation, but it @@ -18,6 +22,14 @@ // // FIXME: for clarity, diagnostics for these cases might be better off // if they specifically said "cannot activate mutable borrow of `x`" +// +// The convention for the listed revisions: "lxl" means lexical +// lifetimes (which can be easier to reason about). "nll" means +// non-lexical lifetimes. "nll_target" means the initial conservative +// two-phase borrows that only applies to autoref-introduced borrows. +// "nll_beyond" means the generalization of two-phase borrows to all +// `&mut`-borrows (doing so makes it easier to write code for specific +// corner cases). #![allow(dead_code)] @@ -27,6 +39,7 @@ fn ok() { let mut x = 3; let y = &mut x; { let z = &x; read(z); } + //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable *y += 1; } @@ -34,9 +47,11 @@ fn not_ok() { let mut x = 3; let y = &mut x; let z = &x; + //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable *y += 1; - //[lxl]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable - //[nll]~^^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable + //[lxl_beyond]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable + //[nll_beyond]~^^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable + //[nll_target]~^^^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable read(z); } @@ -44,18 +59,21 @@ fn should_be_ok_with_nll() { let mut x = 3; let y = &mut x; let z = &x; + //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable read(z); *y += 1; - //[lxl]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable - // (okay with nll today) + //[lxl_beyond]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable + // (okay with (generalized) nll today) } fn should_also_eventually_be_ok_with_nll() { let mut x = 3; let y = &mut x; let _z = &x; + //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable *y += 1; - //[lxl]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable + //[lxl_beyond]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable + // (okay with (generalized) nll today) } fn main() { } diff --git a/src/test/compile-fail/borrowck/two-phase-allow-access-during-reservation.rs b/src/test/compile-fail/borrowck/two-phase-allow-access-during-reservation.rs index 7695bd3e4652c..dd174981fb1e2 100644 --- a/src/test/compile-fail/borrowck/two-phase-allow-access-during-reservation.rs +++ b/src/test/compile-fail/borrowck/two-phase-allow-access-during-reservation.rs @@ -8,9 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// revisions: lxl nll -//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows -//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll +// ignore-tidy-linelength + +// revisions: lxl_beyond nll_beyond nll_target +//[lxl_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two_phase_beyond_autoref +//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two_phase_beyond_autoref -Z nll +//[nll_target] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll // This is the second counter-example from Niko's blog post // smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/ @@ -18,6 +21,14 @@ // It is "artificial". It is meant to illustrate directly that we // should allow an aliasing access during reservation, but *not* while // the mutable borrow is active. +// +// The convention for the listed revisions: "lxl" means lexical +// lifetimes (which can be easier to reason about). "nll" means +// non-lexical lifetimes. "nll_target" means the initial conservative +// two-phase borrows that only applies to autoref-introduced borrows. +// "nll_beyond" means the generalization of two-phase borrows to all +// `&mut`-borrows (doing so makes it easier to write code for specific +// corner cases). fn main() { /*0*/ let mut i = 0; @@ -25,11 +36,13 @@ fn main() { /*1*/ let p = &mut i; // (reservation of `i` starts here) /*2*/ let j = i; // OK: `i` is only reserved here + //[nll_target]~^ ERROR cannot use `i` because it was mutably borrowed [E0503] /*3*/ *p += 1; // (mutable borrow of `i` starts here, since `p` is used) - /*4*/ let k = i; //[lxl]~ ERROR cannot use `i` because it was mutably borrowed [E0503] - //[nll]~^ ERROR cannot use `i` because it was mutably borrowed [E0503] + /*4*/ let k = i; //[lxl_beyond]~ ERROR cannot use `i` because it was mutably borrowed [E0503] + //[nll_beyond]~^ ERROR cannot use `i` because it was mutably borrowed [E0503] + //[nll_target]~^^ ERROR cannot use `i` because it was mutably borrowed [E0503] /*5*/ *p += 1; diff --git a/src/test/compile-fail/borrowck/two-phase-reservation-sharing-interference.rs b/src/test/compile-fail/borrowck/two-phase-reservation-sharing-interference.rs index cc85315263a4f..b5fda4985f23f 100644 --- a/src/test/compile-fail/borrowck/two-phase-reservation-sharing-interference.rs +++ b/src/test/compile-fail/borrowck/two-phase-reservation-sharing-interference.rs @@ -8,9 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// revisions: lxl nll -//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows -//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll +// ignore-tidy-linelength + +// revisions: lxl_beyond nll_beyond nll_target + +//[lxl_beyond]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref +//[nll_beyond]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref -Z nll +//[nll_target]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll // This is a corner case that the current implementation is (probably) // treating more conservatively than is necessary. But it also does @@ -19,6 +23,18 @@ // So this test is just making a note of the current behavior, with // the caveat that in the future, the rules may be loosened, at which // point this test might be thrown out. +// +// The convention for the listed revisions: "lxl" means lexical +// lifetimes (which can be easier to reason about). "nll" means +// non-lexical lifetimes. "nll_target" means the initial conservative +// two-phase borrows that only applies to autoref-introduced borrows. +// "nll_beyond" means the generalization of two-phase borrows to all +// `&mut`-borrows (doing so makes it easier to write code for specific +// corner cases). +// +// FIXME: in "nll_target", we currently see the same error reported +// twice. This is injected by `-Z two-phase-borrows`; not sure why as +// of yet. fn main() { let mut vec = vec![0, 1]; @@ -30,8 +46,10 @@ fn main() { // with the shared borrow. But in the current implementation, // its an error. delay = &mut vec; - //[lxl]~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable - //[nll]~^^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable + //[lxl_beyond]~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable + //[nll_beyond]~^^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable + //[nll_target]~^^^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable + //[nll_target]~| ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable shared[0]; } From c8041dd8ac780425f880e5e4e00d055e3bd0bece Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Tue, 23 Jan 2018 13:31:11 +0100 Subject: [PATCH 167/198] Add `AutoBorrowMutability`; its like `hir::Mutability` but w/ two-phase borrow info too. Namely, the mutable borrows also carries a flag indicating whether they should support two-phase borrows. This allows us to thread down, from the point of the borrow's introduction, whether the particular adjustment that created it is one that yields two-phase mutable borrows. --- src/librustc/ich/impls_ty.rs | 14 +++++++++ src/librustc/middle/expr_use_visitor.rs | 2 +- src/librustc/ty/adjustment.rs | 17 ++++++++++- src/librustc_lint/unused.rs | 6 ++-- src/librustc_mir/hair/cx/expr.rs | 33 +++++++++++++++------ src/librustc_typeck/check/callee.rs | 13 ++++++-- src/librustc_typeck/check/coercion.rs | 22 ++++++++++++-- src/librustc_typeck/check/method/confirm.rs | 23 ++++++++++++-- src/librustc_typeck/check/mod.rs | 26 ++++++++++++++-- src/librustc_typeck/check/op.rs | 24 +++++++++++++-- src/librustc_typeck/check/regionck.rs | 2 +- 11 files changed, 154 insertions(+), 28 deletions(-) diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index 107779ec3fa15..d1e431597e745 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -163,6 +163,20 @@ impl_stable_hash_for!(struct ty::adjustment::Adjustment<'tcx> { kind, target }); impl_stable_hash_for!(struct ty::adjustment::OverloadedDeref<'tcx> { region, mutbl }); impl_stable_hash_for!(struct ty::UpvarBorrow<'tcx> { kind, region }); +impl<'gcx> HashStable> for ty::adjustment::AutoBorrowMutability { + fn hash_stable(&self, + hcx: &mut StableHashingContext<'gcx>, + hasher: &mut StableHasher) { + mem::discriminant(self).hash_stable(hcx, hasher); + match *self { + ty::adjustment::AutoBorrowMutability::Mutable { ref allow_two_phase_borrow } => { + allow_two_phase_borrow.hash_stable(hcx, hasher); + } + ty::adjustment::AutoBorrowMutability::Immutable => {} + } + } +} + impl_stable_hash_for!(struct ty::UpvarId { var_id, closure_expr_id }); impl_stable_hash_for!(enum ty::BorrowKind { diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index c69005101c671..7db75a5166898 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -760,7 +760,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { expr.span, cmt_base, r, - ty::BorrowKind::from_mutbl(m), + ty::BorrowKind::from_mutbl(m.into()), AutoRef); } diff --git a/src/librustc/ty/adjustment.rs b/src/librustc/ty/adjustment.rs index 96d69b4fba21a..7579d95a8fe68 100644 --- a/src/librustc/ty/adjustment.rs +++ b/src/librustc/ty/adjustment.rs @@ -119,10 +119,25 @@ impl<'a, 'gcx, 'tcx> OverloadedDeref<'tcx> { } } +#[derive(Copy, Clone, PartialEq, Debug, RustcEncodable, RustcDecodable)] +pub enum AutoBorrowMutability { + Mutable { allow_two_phase_borrow: bool }, + Immutable, +} + +impl From for hir::Mutability { + fn from(m: AutoBorrowMutability) -> Self { + match m { + AutoBorrowMutability::Mutable { .. } => hir::MutMutable, + AutoBorrowMutability::Immutable => hir::MutImmutable, + } + } +} + #[derive(Copy, Clone, PartialEq, Debug, RustcEncodable, RustcDecodable)] pub enum AutoBorrow<'tcx> { /// Convert from T to &T. - Ref(ty::Region<'tcx>, hir::Mutability), + Ref(ty::Region<'tcx>, AutoBorrowMutability), /// Convert from T to *T. RawPtr(hir::Mutability), diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 56f863ab3aa84..439533fae49d9 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -437,8 +437,10 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation { for adj in cx.tables.expr_adjustments(e) { if let adjustment::Adjust::Borrow(adjustment::AutoBorrow::Ref(_, m)) = adj.kind { let msg = match m { - hir::MutImmutable => "unnecessary allocation, use & instead", - hir::MutMutable => "unnecessary allocation, use &mut instead" + adjustment::AutoBorrowMutability::Immutable => + "unnecessary allocation, use & instead", + adjustment::AutoBorrowMutability::Mutable { .. }=> + "unnecessary allocation, use &mut instead" }; cx.span_lint(UNUSED_ALLOCATION, e.span, msg); } diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index e33147a915b5f..00ab2e4599528 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -17,7 +17,7 @@ use hair::cx::to_ref::ToRef; use rustc::hir::def::{Def, CtorKind}; use rustc::middle::const_val::ConstVal; use rustc::ty::{self, AdtKind, VariantDef, Ty}; -use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow}; +use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability}; use rustc::ty::cast::CastKind as TyCastKind; use rustc::hir; use rustc::hir::def_id::LocalDefId; @@ -112,7 +112,7 @@ fn apply_adjustment<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, span, kind: ExprKind::Borrow { region: deref.region, - borrow_kind: to_borrow_kind(deref.mutbl, true), + borrow_kind: deref.mutbl.to_borrow_kind(), arg: expr.to_ref(), }, }; @@ -122,7 +122,7 @@ fn apply_adjustment<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, Adjust::Borrow(AutoBorrow::Ref(r, m)) => { ExprKind::Borrow { region: r, - borrow_kind: to_borrow_kind(m, true), + borrow_kind: m.to_borrow_kind(), arg: expr.to_ref(), } } @@ -142,7 +142,7 @@ fn apply_adjustment<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, span, kind: ExprKind::Borrow { region, - borrow_kind: to_borrow_kind(m, true), + borrow_kind: m.to_borrow_kind(), arg: expr.to_ref(), }, }; @@ -288,7 +288,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, }; ExprKind::Borrow { region, - borrow_kind: to_borrow_kind(mutbl, false), + borrow_kind: mutbl.to_borrow_kind(), arg: expr.to_ref(), } } @@ -643,10 +643,25 @@ fn method_callee<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } } -fn to_borrow_kind(m: hir::Mutability, allow_two_phase_borrow: bool) -> BorrowKind { - match m { - hir::MutMutable => BorrowKind::Mut { allow_two_phase_borrow }, - hir::MutImmutable => BorrowKind::Shared, +trait ToBorrowKind { fn to_borrow_kind(&self) -> BorrowKind; } + +impl ToBorrowKind for AutoBorrowMutability { + fn to_borrow_kind(&self) -> BorrowKind { + match *self { + AutoBorrowMutability::Mutable { allow_two_phase_borrow } => + BorrowKind::Mut { allow_two_phase_borrow }, + AutoBorrowMutability::Immutable => + BorrowKind::Shared, + } + } +} + +impl ToBorrowKind for hir::Mutability { + fn to_borrow_kind(&self) -> BorrowKind { + match *self { + hir::MutMutable => BorrowKind::Mut { allow_two_phase_borrow: false }, + hir::MutImmutable => BorrowKind::Shared, + } } } diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index 76df9be48386d..3d61ffe39336a 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -16,7 +16,7 @@ use hir::def::Def; use hir::def_id::{DefId, LOCAL_CRATE}; use rustc::{infer, traits}; use rustc::ty::{self, TyCtxt, TypeFoldable, Ty}; -use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow}; +use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability}; use syntax::abi; use syntax::symbol::Symbol; use syntax_pos::Span; @@ -176,8 +176,17 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let mut autoref = None; if borrow { if let ty::TyRef(region, mt) = method.sig.inputs()[0].sty { + let mutbl = match mt.mutbl { + hir::MutImmutable => AutoBorrowMutability::Immutable, + hir::MutMutable => AutoBorrowMutability::Mutable { + // For initial two-phase borrow + // deployment, conservatively omit + // overloaded function call ops. + allow_two_phase_borrow: false, + } + }; autoref = Some(Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(region, mt.mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), target: method.sig.inputs()[0] }); } diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index d0280bf0b30be..47e4b0272bed4 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -68,7 +68,7 @@ use rustc::infer::{Coercion, InferResult, InferOk}; use rustc::infer::type_variable::TypeVariableOrigin; use rustc::lint; use rustc::traits::{self, ObligationCause, ObligationCauseCode}; -use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow}; +use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability}; use rustc::ty::{self, TypeAndMut, Ty, ClosureSubsts}; use rustc::ty::fold::TypeFoldable; use rustc::ty::error::TypeError; @@ -421,8 +421,17 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { ty::TyRef(r_borrow, _) => r_borrow, _ => span_bug!(span, "expected a ref type, got {:?}", ty), }; + let mutbl = match mt_b.mutbl { + hir::MutImmutable => AutoBorrowMutability::Immutable, + hir::MutMutable => AutoBorrowMutability::Mutable { + // Deref-coercion is a case where we deliberately + // disallow two-phase borrows in its initial + // deployment; see discussion on PR #47489. + allow_two_phase_borrow: false, + } + }; adjustments.push(Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(r_borrow, mt_b.mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(r_borrow, mutbl)), target: ty }); @@ -461,11 +470,17 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { let coercion = Coercion(self.cause.span); let r_borrow = self.next_region_var(coercion); + let mutbl = match mt_b.mutbl { + hir::MutImmutable => AutoBorrowMutability::Immutable, + hir::MutMutable => AutoBorrowMutability::Mutable { + allow_two_phase_borrow: false, + } + }; Some((Adjustment { kind: Adjust::Deref(None), target: mt_a.ty }, Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(r_borrow, mt_b.mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(r_borrow, mutbl)), target: self.tcx.mk_ref(r_borrow, ty::TypeAndMut { mutbl: mt_b.mutbl, ty: mt_a.ty @@ -871,6 +886,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ] => { match self.node_ty(expr.hir_id).sty { ty::TyRef(_, mt_orig) => { + let mutbl_adj: hir::Mutability = mutbl_adj.into(); // Reborrow that we can safely ignore, because // the next adjustment can only be a Deref // which will be merged into it. diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 7f5b353f79ef7..20d5899149645 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -17,7 +17,7 @@ use rustc::ty::subst::Substs; use rustc::traits; use rustc::ty::{self, Ty}; use rustc::ty::subst::Subst; -use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, OverloadedDeref}; +use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability, OverloadedDeref}; use rustc::ty::fold::TypeFoldable; use rustc::infer::{self, InferOk}; use syntax_pos::Span; @@ -165,6 +165,14 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { mutbl, ty: target }); + let mutbl = match mutbl { + hir::MutImmutable => AutoBorrowMutability::Immutable, + hir::MutMutable => AutoBorrowMutability::Mutable { + // Method call receivers are the primary use case + // for two-phase borrows. + allow_two_phase_borrow: true, + } + }; adjustments.push(Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), target @@ -172,7 +180,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { if let Some(unsize_target) = pick.unsize { target = self.tcx.mk_ref(region, ty::TypeAndMut { - mutbl, + mutbl: mutbl.into(), ty: unsize_target }); adjustments.push(Adjustment { @@ -530,10 +538,19 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { for adjustment in &mut adjustments[..] { if let Adjust::Borrow(AutoBorrow::Ref(..)) = adjustment.kind { debug!("convert_place_op_to_mutable: converting autoref {:?}", adjustment); + let mutbl = match mutbl { + hir::MutImmutable => AutoBorrowMutability::Immutable, + hir::MutMutable => AutoBorrowMutability::Mutable { + // For initial two-phase borrow + // deployment, conservatively omit + // overloaded operators. + allow_two_phase_borrow: false, + } + }; adjustment.kind = Adjust::Borrow(AutoBorrow::Ref(region, mutbl)); adjustment.target = self.tcx.mk_ref(region, ty::TypeAndMut { ty: source, - mutbl + mutbl: mutbl.into(), }); } source = adjustment.target; diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 363d4a9dc0cd3..47bf085c9c05b 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -96,7 +96,7 @@ use rustc::middle::region; use rustc::ty::subst::{Kind, Subst, Substs}; use rustc::traits::{self, FulfillmentContext, ObligationCause, ObligationCauseCode}; use rustc::ty::{self, Ty, TyCtxt, Visibility, ToPredicate}; -use rustc::ty::adjustment::{Adjust, Adjustment, AutoBorrow}; +use rustc::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability}; use rustc::ty::fold::TypeFoldable; use rustc::ty::maps::Providers; use rustc::ty::util::{Representability, IntTypeExt}; @@ -2357,8 +2357,19 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let mut adjustments = autoderef.adjust_steps(needs); if let ty::TyRef(region, mt) = method.sig.inputs()[0].sty { + let mutbl = match mt.mutbl { + hir::MutImmutable => AutoBorrowMutability::Immutable, + hir::MutMutable => AutoBorrowMutability::Mutable { + // FIXME (#46747): arguably indexing is + // "just another kind of call"; perhaps it + // would be more consistent to allow + // two-phase borrows for .index() + // receivers here. + allow_two_phase_borrow: false, + } + }; adjustments.push(Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(region, mt.mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), target: self.tcx.mk_ref(region, ty::TypeAndMut { mutbl: mt.mutbl, ty: adjusted_ty @@ -3646,8 +3657,17 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { expr.span, oprnd_t, needs) { let method = self.register_infer_ok_obligations(ok); if let ty::TyRef(region, mt) = method.sig.inputs()[0].sty { + let mutbl = match mt.mutbl { + hir::MutImmutable => AutoBorrowMutability::Immutable, + hir::MutMutable => AutoBorrowMutability::Mutable { + // (It shouldn't actually matter for unary ops whether + // we enable two-phase borrows or not, since a unary + // op has no additional operands.) + allow_two_phase_borrow: false, + } + }; self.apply_adjustments(oprnd, vec![Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(region, mt.mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), target: method.sig.inputs()[0] }]); } diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index 0698e3ecb6edd..a6776a0fe8612 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -14,7 +14,7 @@ use super::{FnCtxt, Needs}; use super::method::MethodCallee; use rustc::ty::{self, Ty, TypeFoldable, TypeVariants}; use rustc::ty::TypeVariants::{TyStr, TyRef}; -use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow}; +use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability}; use rustc::infer::type_variable::TypeVariableOrigin; use errors; use syntax_pos::Span; @@ -198,8 +198,17 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let by_ref_binop = !op.node.is_by_value(); if is_assign == IsAssign::Yes || by_ref_binop { if let ty::TyRef(region, mt) = method.sig.inputs()[0].sty { + let mutbl = match mt.mutbl { + hir::MutImmutable => AutoBorrowMutability::Immutable, + hir::MutMutable => AutoBorrowMutability::Mutable { + // For initial two-phase borrow + // deployment, conservatively omit + // overloaded binary ops. + allow_two_phase_borrow: false, + } + }; let autoref = Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(region, mt.mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), target: method.sig.inputs()[0] }; self.apply_adjustments(lhs_expr, vec![autoref]); @@ -207,8 +216,17 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } if by_ref_binop { if let ty::TyRef(region, mt) = method.sig.inputs()[1].sty { + let mutbl = match mt.mutbl { + hir::MutImmutable => AutoBorrowMutability::Immutable, + hir::MutMutable => AutoBorrowMutability::Mutable { + // For initial two-phase borrow + // deployment, conservatively omit + // overloaded binary ops. + allow_two_phase_borrow: false, + } + }; let autoref = Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(region, mt.mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), target: method.sig.inputs()[1] }; // HACK(eddyb) Bypass checks due to reborrows being in diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index 64063ec5beda9..b5bf59fef9afc 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -1063,7 +1063,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { match *autoref { adjustment::AutoBorrow::Ref(r, m) => { self.link_region(expr.span, r, - ty::BorrowKind::from_mutbl(m), expr_cmt); + ty::BorrowKind::from_mutbl(m.into()), expr_cmt); } adjustment::AutoBorrow::RawPtr(m) => { From 81b93fa0b364e106f13c5810941857426a6c6756 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Tue, 6 Feb 2018 12:48:36 +0100 Subject: [PATCH 168/198] Test that autoref'ing beyond method receivers does not leak into two-phase borrows. --- .../borrowck/two-phase-nonrecv-autoref.rs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs diff --git a/src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs b/src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs new file mode 100644 index 0000000000000..ad34d4d00dd92 --- /dev/null +++ b/src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs @@ -0,0 +1,39 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// revisions: lxl nll g2p +//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows +//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll +//[g2p]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll -Z two-phase-beyond-autoref + +#![feature(rustc_attrs)] + +// This is a test checking that when we limit two-phase borrows to +// method receivers, we do not let other kinds of auto-ref to leak +// through. +// +// The g2p revision illustrates the "undesirable" behavior you would +// otherwise observe without limiting the phasing to autoref on method +// receivers (namely, that the test would pass). + +fn bar(x: &mut u32) { + foo(x, *x); + //[lxl]~^ ERROR cannot use `*x` because it was mutably borrowed [E0503] + //[nll]~^^ ERROR cannot use `*x` because it was mutably borrowed [E0503] +} + +fn foo(x: &mut u32, y: u32) { + *x += y; +} + +#[rustc_error] +fn main() { //[g2p]~ ERROR compilation successful + bar(&mut 5); +} From b55cd8cc7c55a50941cc55cd399f6d5aebdf77f8 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Tue, 6 Feb 2018 16:47:38 +0100 Subject: [PATCH 169/198] Fleshed out the test a lot more. --- .../borrowck/two-phase-nonrecv-autoref.rs | 239 +++++++++++++++++- 1 file changed, 230 insertions(+), 9 deletions(-) diff --git a/src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs b/src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs index ad34d4d00dd92..795d45a776db5 100644 --- a/src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs +++ b/src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs @@ -13,27 +13,248 @@ //[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll //[g2p]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll -Z two-phase-beyond-autoref -#![feature(rustc_attrs)] - // This is a test checking that when we limit two-phase borrows to // method receivers, we do not let other kinds of auto-ref to leak // through. // // The g2p revision illustrates the "undesirable" behavior you would // otherwise observe without limiting the phasing to autoref on method -// receivers (namely, that the test would pass). +// receivers (namely, in many cases demonstrated below, the error +// would not arise). + +// (If we revise the compiler or this test so that the g2p revision +// passes, turn the `rustc_attrs` feature back on and tag the `fn +// main` with `#[rustc_error]` so that this remains a valid +// compile-fail test.) +// +// #![feature(rustc_attrs)] + +use std::ops::{Index, IndexMut}; +use std::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign}; +use std::ops::{BitAndAssign, BitOrAssign, BitXorAssign, ShlAssign, ShrAssign}; -fn bar(x: &mut u32) { +// This is case outlined by Niko that we want to ensure we reject +// (at least initially). + +fn foo(x: &mut u32, y: u32) { + *x += y; +} + +fn deref_coercion(x: &mut u32) { foo(x, *x); //[lxl]~^ ERROR cannot use `*x` because it was mutably borrowed [E0503] //[nll]~^^ ERROR cannot use `*x` because it was mutably borrowed [E0503] } -fn foo(x: &mut u32, y: u32) { - *x += y; +// While adding a flag to adjustments (indicating whether they +// should support two-phase borrows, here are the cases I +// encountered: +// +// - [x] Resolving overloaded_call_traits (call, call_mut, call_once) +// - [x] deref_coercion (shown above) +// - [x] coerce_unsized e.g. `&[T; n]`, `&mut [T; n] -> &[T]`, +// `&mut [T; n] -> &mut [T]`, `&Concrete -> &Trait` +// - [x] Method Call Receivers (the case we want to support!) +// - [x] ExprIndex and ExprUnary Deref; only need to handle coerce_index_op +// - [x] overloaded_binops + +fn overloaded_call_traits() { + // Regarding overloaded call traits, note that there is no + // scenario where adding two-phase borrows should "fix" these + // cases, because either we will resolve both invocations to + // `call_mut` (in which case the inner call requires a mutable + // borrow which will conflict with the outer reservation), or we + // will resolve both to `call` (which will just work, regardless + // of two-phase borrow support), or we will resolve both to + // `call_once` (in which case the inner call requires moving the + // receiver, invalidating the outer call). + + fn twice_ten_sm i32>(f: &mut F) { + f(f(10)); + //[lxl]~^ ERROR cannot borrow `*f` as mutable more than once at a time + //[lxl]~| ERROR cannot borrow `*f` as mutable more than once at a time + //[nll]~^^^ ERROR cannot borrow `*f` as mutable more than once at a time + //[nll]~| ERROR cannot borrow `*f` as mutable more than once at a time + //[g2p]~^^^^^ ERROR cannot borrow `*f` as mutable more than once at a time + } + fn twice_ten_si i32>(f: &mut F) { + f(f(10)); + } + fn twice_ten_so i32>(f: Box) { + f(f(10)); + //[lxl]~^ ERROR use of moved value: `*f` + //[nll]~^^ ERROR use of moved value: `*f` + //[g2p]~^^^ ERROR use of moved value: `*f` + } + + fn twice_ten_om(f: &mut FnMut(i32) -> i32) { + f(f(10)); + //[lxl]~^ ERROR cannot borrow `*f` as mutable more than once at a time + //[lxl]~| ERROR cannot borrow `*f` as mutable more than once at a time + //[nll]~^^^ ERROR cannot borrow `*f` as mutable more than once at a time + //[nll]~| ERROR cannot borrow `*f` as mutable more than once at a time + //[g2p]~^^^^^ ERROR cannot borrow `*f` as mutable more than once at a time + } + fn twice_ten_oi(f: &mut Fn(i32) -> i32) { + f(f(10)); + } + fn twice_ten_oo(f: Box i32>) { + f(f(10)); + //[lxl]~^ ERROR cannot move a value of type + //[lxl]~^^ ERROR cannot move a value of type + //[lxl]~^^^ ERROR use of moved value: `*f` + //[nll]~^^^^ ERROR cannot move a value of type + //[nll]~^^^^^ ERROR cannot move a value of type + //[nll]~^^^^^^ ERROR cannot move a value of type + //[nll]~^^^^^^^ ERROR cannot move a value of type + //[nll]~^^^^^^^^ ERROR use of moved value: `*f` + //[g2p]~^^^^^^^^^ ERROR cannot move a value of type + //[g2p]~^^^^^^^^^^ ERROR cannot move a value of type + //[g2p]~^^^^^^^^^^^ ERROR cannot move a value of type + //[g2p]~^^^^^^^^^^^^ ERROR cannot move a value of type + //[g2p]~^^^^^^^^^^^^^ ERROR use of moved value: `*f` + } + + twice_ten_sm(&mut |x| x + 1); + twice_ten_si(&mut |x| x + 1); + twice_ten_so(Box::new(|x| x + 1)); + twice_ten_om(&mut |x| x + 1); + twice_ten_oi(&mut |x| x + 1); + twice_ten_oo(Box::new(|x| x + 1)); +} + +trait TwoMethods { + fn m(&mut self, x: i32) -> i32 { x + 1 } + fn i(&self, x: i32) -> i32 { x + 1 } +} + +struct T; + +impl TwoMethods for T { } + +struct S; + +impl S { + fn m(&mut self, x: i32) -> i32 { x + 1 } + fn i(&self, x: i32) -> i32 { x + 1 } +} + +impl TwoMethods for [i32; 3] { } + +fn double_access(m: &mut [X], s: &[X]) { + m[0] = s[1]; } -#[rustc_error] -fn main() { //[g2p]~ ERROR compilation successful - bar(&mut 5); +fn coerce_unsized() { + let mut a = [1, 2, 3]; + + // This is not okay. + double_access(&mut a, &a); + //[lxl]~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] + //[nll]~^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] + //[g2p]~^^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] + + // But this is okay. + a.m(a.i(10)); +} + +struct I(i32); + +impl Index for I { + type Output = i32; + fn index(&self, _: i32) -> &i32 { + &self.0 + } +} + +impl IndexMut for I { + fn index_mut(&mut self, _: i32) -> &mut i32 { + &mut self.0 + } +} + +fn coerce_index_op() { + let mut i = I(10); + i[i[3]] = 4; + //[lxl]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] + //[nll]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] + + i[3] = i[4]; + + i[i[3]] = i[4]; + //[lxl]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] + //[nll]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] +} + +struct A(i32); + +macro_rules! trivial_binop { + ($Trait:ident, $m:ident) => { + impl $Trait for A { fn $m(&mut self, rhs: i32) { self.0 = rhs; } } + } +} + +trivial_binop!(AddAssign, add_assign); +trivial_binop!(SubAssign, sub_assign); +trivial_binop!(MulAssign, mul_assign); +trivial_binop!(DivAssign, div_assign); +trivial_binop!(RemAssign, rem_assign); +trivial_binop!(BitAndAssign, bitand_assign); +trivial_binop!(BitOrAssign, bitor_assign); +trivial_binop!(BitXorAssign, bitxor_assign); +trivial_binop!(ShlAssign, shl_assign); +trivial_binop!(ShrAssign, shr_assign); + +fn overloaded_binops() { + let mut a = A(10); + a += a.0; + //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed + //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed + a -= a.0; + //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed + //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed + a *= a.0; + //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed + //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed + a /= a.0; + //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed + //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed + a &= a.0; + //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed + //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed + a |= a.0; + //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed + //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed + a ^= a.0; + //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed + //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed + a <<= a.0; + //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed + //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed + a >>= a.0; + //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed + //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed +} + +fn main() { + + // As a reminder, this is the basic case we want to ensure we handle. + let mut v = vec![1, 2, 3]; + v.push(v.len()); + + // (as a rule, pnkfelix does not like to write tests with dead code.) + + deref_coercion(&mut 5); + overloaded_call_traits(); + + + let mut s = S; + s.m(s.i(10)); + + let mut t = T; + t.m(t.i(10)); + + coerce_unsized(); + coerce_index_op(); + overloaded_binops(); } From 5f3dc8b7b2b8fb4837adfe5defa92367f8fe1000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Sat, 20 Jan 2018 17:09:55 +0100 Subject: [PATCH 170/198] Fix oversized loads on x86_64 SysV FFI calls The x86_64 SysV ABI should use exact sizes for small structs passed in registers, i.e. a struct that occupies 3 bytes should use an i24, instead of the i32 it currently uses. Refs #45543 --- src/librustc_trans/cabi_x86_64.rs | 13 ++--- src/test/codegen/abi-x86_64_sysv.rs | 39 ++++++++++++++ src/test/codegen/repr-transparent-sysv64.rs | 39 ++++++++++++++ src/test/codegen/repr-transparent.rs | 60 ++++----------------- 4 files changed, 94 insertions(+), 57 deletions(-) create mode 100644 src/test/codegen/abi-x86_64_sysv.rs create mode 100644 src/test/codegen/repr-transparent-sysv64.rs diff --git a/src/librustc_trans/cabi_x86_64.rs b/src/librustc_trans/cabi_x86_64.rs index 62bac8469ce4b..b8144a3ca7a3e 100644 --- a/src/librustc_trans/cabi_x86_64.rs +++ b/src/librustc_trans/cabi_x86_64.rs @@ -134,12 +134,13 @@ fn reg_component(cls: &[Option], i: &mut usize, size: Size) -> Option None, Some(Class::Int) => { *i += 1; - Some(match size.bytes() { - 1 => Reg::i8(), - 2 => Reg::i16(), - 3 | - 4 => Reg::i32(), - _ => Reg::i64() + Some(if size.bytes() < 8 { + Reg { + kind: RegKind::Integer, + size + } + } else { + Reg::i64() }) } Some(Class::Sse) => { diff --git a/src/test/codegen/abi-x86_64_sysv.rs b/src/test/codegen/abi-x86_64_sysv.rs new file mode 100644 index 0000000000000..88666e9c1fd47 --- /dev/null +++ b/src/test/codegen/abi-x86_64_sysv.rs @@ -0,0 +1,39 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// only-x86_64 + +// compile-flags: -C no-prepopulate-passes + +#![crate_type = "lib"] + +pub struct S24 { + a: i8, + b: i8, + c: i8, +} + +pub struct S48 { + a: i16, + b: i16, + c: i8, +} + +// CHECK: i24 @struct_24_bits(i24 +#[no_mangle] +pub extern "sysv64" fn struct_24_bits(a: S24) -> S24 { + a +} + +// CHECK: i48 @struct_48_bits(i48 +#[no_mangle] +pub extern "sysv64" fn struct_48_bits(a: S48) -> S48 { + a +} diff --git a/src/test/codegen/repr-transparent-sysv64.rs b/src/test/codegen/repr-transparent-sysv64.rs new file mode 100644 index 0000000000000..7a30983fdd338 --- /dev/null +++ b/src/test/codegen/repr-transparent-sysv64.rs @@ -0,0 +1,39 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// only-x86_64 + +// compile-flags: -C no-prepopulate-passes + +#![crate_type="lib"] +#![feature(repr_transparent)] + +#[repr(C)] +pub struct Rgb8 { r: u8, g: u8, b: u8 } + +#[repr(transparent)] +pub struct Rgb8Wrap(Rgb8); + +// CHECK: i24 @test_Rgb8Wrap(i24) +#[no_mangle] +pub extern "sysv64" fn test_Rgb8Wrap(_: Rgb8Wrap) -> Rgb8Wrap { loop {} } + +#[repr(C)] +pub union FloatBits { + float: f32, + bits: u32, +} + +#[repr(transparent)] +pub struct SmallUnion(FloatBits); + +// CHECK: i32 @test_SmallUnion(i32) +#[no_mangle] +pub extern "sysv64" fn test_SmallUnion(_: SmallUnion) -> SmallUnion { loop {} } diff --git a/src/test/codegen/repr-transparent.rs b/src/test/codegen/repr-transparent.rs index 31020d8b94f80..087fa9b16b4ed 100644 --- a/src/test/codegen/repr-transparent.rs +++ b/src/test/codegen/repr-transparent.rs @@ -123,55 +123,13 @@ pub struct StructWithProjection(::It); pub extern fn test_Projection(_: StructWithProjection) -> StructWithProjection { loop {} } -// The rest of this file tests newtypes around small aggregates on an ABI where small aggregates are -// packed into one register. This is ABI-dependent, so instead we focus on one ABI and supply a -// dummy definition for other ABIs to keep FileCheck happy. +// All that remains to be tested are aggregates. They are tested in separate files called repr- +// transparent-*.rs with `only-*` or `ignore-*` directives, because the expected LLVM IR +// function signatures vary so much that it's not reasonably possible to cover all of them with a +// single CHECK line. // -// Bigger aggregates are tested in separate files called repr-transparent-aggregate-*.rs because -// there, the expected LLVM IR function signatures vary so much that it's not reasonably possible to -// cover all of them with a single CHECK line. Instead we group ABIs by the general "shape" of the -// signature and have a separate test file for each bin. -// -// PS: You may be wondering why we don't just compare the return types and argument types for -// equality with FileCheck regex captures. Well, rustc doesn't perform newtype unwrapping on -// newtypes containing aggregates. This is OK on all ABIs we support, but because LLVM has not -// gotten rid of pointee types yet, the IR function signature will be syntactically different (%Foo* -// vs %FooWrapper*). - -#[repr(C)] -pub struct Rgb8 { r: u8, g: u8, b: u8 } - -#[repr(transparent)] -pub struct Rgb8Wrap(Rgb8); - -// NB: closing parenthesis is missing because sometimes the argument has a name and sometimes not -// CHECK: define i32 @test_Rgb8Wrap(i32 -#[no_mangle] -#[cfg(all(target_arch="x86_64", target_os="linux"))] -pub extern fn test_Rgb8Wrap(_: Rgb8Wrap) -> Rgb8Wrap { loop {} } - -#[cfg(not(all(target_arch="x86_64", target_os="linux")))] -#[no_mangle] -pub extern fn test_Rgb8Wrap(_: u32) -> u32 { loop {} } - -// Same as with the small struct above: ABI-dependent, we only test the interesting case -// (ABIs that pack the aggregate into a scalar) and stub it out on other ABIs - -#[repr(C)] -pub union FloatBits { - float: f32, - bits: u32, -} - -#[repr(transparent)] -pub struct SmallUnion(FloatBits); - -// NB: closing parenthesis is missing because sometimes the argument has a name and sometimes not -// CHECK: define i32 @test_SmallUnion(i32 -#[no_mangle] -#[cfg(all(target_arch="x86_64", target_os="linux"))] -pub extern fn test_SmallUnion(_: SmallUnion) -> SmallUnion { loop {} } - -#[cfg(not(all(target_arch="x86_64", target_os="linux")))] -#[no_mangle] -pub extern fn test_SmallUnion(_: u32) -> u32 { loop {} } +// You may be wondering why we don't just compare the return types and argument types for equality +// with FileCheck regex captures. Well, rustc doesn't perform newtype unwrapping on newtypes +// containing aggregates. This is OK on all ABIs we support, but because LLVM has not gotten rid of +// pointee types yet, the IR function signature will be syntactically different (%Foo* vs +// %FooWrapper*). From 4aa66dbe01758740fe1e716771db9fdfe9a2e07b Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Thu, 8 Feb 2018 17:15:41 +0200 Subject: [PATCH 171/198] rustc: don't ICE when using Rvalue::Discriminant on a non-ADT. --- src/librustc/mir/tcx.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index 53607764b3984..7c6e065d6a31e 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -182,9 +182,8 @@ impl<'tcx> Rvalue<'tcx> { if let ty::TyAdt(adt_def, _) = ty.sty { adt_def.repr.discr_type().to_ty(tcx) } else { - // Undefined behaviour, bug for now; may want to return something for - // the `discriminant` intrinsic later. - bug!("Rvalue::Discriminant on Place of type {:?}", ty); + // This can only be `0`, for now, so `u8` will suffice. + tcx.types.u8 } } Rvalue::NullaryOp(NullOp::Box, t) => tcx.mk_box(t), From 51f0c0dc4c0ce47f4019c78f4b865718bf278a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Wed, 7 Feb 2018 19:35:35 -0800 Subject: [PATCH 172/198] Move some E0XXX to `ui` --- .../{compile-fail => ui/error-codes}/E0001.rs | 0 src/test/ui/error-codes/E0001.stderr | 14 ++++ .../error-codes}/E0004-2.rs | 0 src/test/ui/error-codes/E0004-2.stderr | 14 ++++ .../{compile-fail => ui/error-codes}/E0004.rs | 0 src/test/ui/error-codes/E0004.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0005.rs | 0 src/test/ui/error-codes/E0005.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0007.rs | 0 src/test/ui/error-codes/E0007.stderr | 14 ++++ .../{compile-fail => ui/error-codes}/E0008.rs | 0 src/test/ui/error-codes/E0008.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0009.rs | 0 src/test/ui/error-codes/E0009.stderr | 10 +++ src/test/ui/error-codes/E0010-teach.rs | 18 +++++ src/test/ui/error-codes/E0010-teach.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0010.rs | 0 src/test/ui/error-codes/E0010.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0017.rs | 0 src/test/ui/error-codes/E0017.stderr | 26 ++++++ .../{compile-fail => ui/error-codes}/E0023.rs | 0 src/test/ui/error-codes/E0023.stderr | 20 +++++ .../{compile-fail => ui/error-codes}/E0025.rs | 0 src/test/ui/error-codes/E0025.stderr | 10 +++ src/test/ui/error-codes/E0026-teach.rs | 24 ++++++ src/test/ui/error-codes/E0026-teach.stderr | 12 +++ .../{compile-fail => ui/error-codes}/E0026.rs | 0 src/test/ui/error-codes/E0026.stderr | 8 ++ src/test/ui/error-codes/E0027-teach.rs | 25 ++++++ src/test/ui/error-codes/E0027-teach.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0027.rs | 0 src/test/ui/error-codes/E0027.stderr | 8 ++ src/test/ui/error-codes/E0029-teach.rs | 22 ++++++ src/test/ui/error-codes/E0029-teach.stderr | 20 +++++ .../{compile-fail => ui/error-codes}/E0029.rs | 0 src/test/ui/error-codes/E0029.stderr | 19 +++++ src/test/ui/error-codes/E0030-teach.rs | 18 +++++ src/test/ui/error-codes/E0030-teach.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0030.rs | 0 src/test/ui/error-codes/E0030.stderr | 8 ++ src/test/ui/error-codes/E0033-teach.rs | 25 ++++++ src/test/ui/error-codes/E0033-teach.stderr | 26 ++++++ .../{compile-fail => ui/error-codes}/E0033.rs | 0 src/test/ui/error-codes/E0033.stderr | 22 ++++++ .../{compile-fail => ui/error-codes}/E0034.rs | 0 src/test/ui/error-codes/E0034.stderr | 19 +++++ .../{compile-fail => ui/error-codes}/E0038.rs | 0 src/test/ui/error-codes/E0038.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0040.rs | 0 src/test/ui/error-codes/E0040.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0044.rs | 0 src/test/ui/error-codes/E0044.stderr | 14 ++++ .../{compile-fail => ui/error-codes}/E0045.rs | 0 src/test/ui/error-codes/E0045.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0049.rs | 0 src/test/ui/error-codes/E0049.stderr | 11 +++ .../{compile-fail => ui/error-codes}/E0050.rs | 0 src/test/ui/error-codes/E0050.stderr | 29 +++++++ .../{compile-fail => ui/error-codes}/E0054.rs | 0 src/test/ui/error-codes/E0054.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0055.rs | 0 src/test/ui/error-codes/E0055.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0057.rs | 0 src/test/ui/error-codes/E0057.stderr | 14 ++++ .../{compile-fail => ui/error-codes}/E0059.rs | 0 src/test/ui/error-codes/E0059.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0060.rs | 0 src/test/ui/error-codes/E0060.stderr | 11 +++ .../{compile-fail => ui/error-codes}/E0061.rs | 0 src/test/ui/error-codes/E0061.stderr | 20 +++++ .../{compile-fail => ui/error-codes}/E0062.rs | 0 src/test/ui/error-codes/E0062.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0063.rs | 0 src/test/ui/error-codes/E0063.stderr | 26 ++++++ .../{compile-fail => ui/error-codes}/E0067.rs | 0 src/test/ui/error-codes/E0067.stderr | 16 ++++ .../{compile-fail => ui/error-codes}/E0069.rs | 0 src/test/ui/error-codes/E0069.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0070.rs | 0 src/test/ui/error-codes/E0070.stderr | 29 +++++++ .../{compile-fail => ui/error-codes}/E0071.rs | 0 src/test/ui/error-codes/E0071.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0075.rs | 0 src/test/ui/error-codes/E0075.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0076.rs | 0 src/test/ui/error-codes/E0076.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0077.rs | 0 src/test/ui/error-codes/E0077.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0080.rs | 0 src/test/ui/error-codes/E0080.stderr | 28 +++++++ .../{compile-fail => ui/error-codes}/E0081.rs | 0 src/test/ui/error-codes/E0081.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0084.rs | 0 src/test/ui/error-codes/E0084.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0087.rs | 0 src/test/ui/error-codes/E0087.stderr | 14 ++++ .../{compile-fail => ui/error-codes}/E0088.rs | 0 src/test/ui/error-codes/E0088.stderr | 14 ++++ .../{compile-fail => ui/error-codes}/E0089.rs | 0 src/test/ui/error-codes/E0089.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0090.rs | 0 src/test/ui/error-codes/E0090.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0091.rs | 0 src/test/ui/error-codes/E0091.stderr | 14 ++++ .../{compile-fail => ui/error-codes}/E0092.rs | 0 src/test/ui/error-codes/E0092.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0093.rs | 0 src/test/ui/error-codes/E0093.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0094.rs | 0 src/test/ui/error-codes/E0094.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0106.rs | 0 src/test/ui/error-codes/E0106.stderr | 32 ++++++++ .../{compile-fail => ui/error-codes}/E0107.rs | 0 src/test/ui/error-codes/E0107.stderr | 20 +++++ .../{compile-fail => ui/error-codes}/E0109.rs | 0 src/test/ui/error-codes/E0109.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0110.rs | 0 src/test/ui/error-codes/E0110.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0116.rs | 0 src/test/ui/error-codes/E0116.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0117.rs | 0 src/test/ui/error-codes/E0117.stderr | 17 ++++ .../{compile-fail => ui/error-codes}/E0118.rs | 0 src/test/ui/error-codes/E0118.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0119.rs | 0 src/test/ui/error-codes/E0119.stderr | 11 +++ .../{compile-fail => ui/error-codes}/E0120.rs | 0 src/test/ui/error-codes/E0120.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0121.rs | 0 src/test/ui/error-codes/E0121.stderr | 14 ++++ .../{compile-fail => ui/error-codes}/E0124.rs | 0 src/test/ui/error-codes/E0124.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0128.rs | 0 src/test/ui/error-codes/E0128.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0130.rs | 0 src/test/ui/error-codes/E0130.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0131.rs | 0 src/test/ui/error-codes/E0131.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0132.rs | 0 src/test/ui/error-codes/E0132.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0133.rs | 0 src/test/ui/error-codes/E0133.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0137.rs | 0 src/test/ui/error-codes/E0137.stderr | 11 +++ .../{compile-fail => ui/error-codes}/E0138.rs | 0 src/test/ui/error-codes/E0138.stderr | 11 +++ .../{compile-fail => ui/error-codes}/E0152.rs | 0 src/test/ui/error-codes/E0152.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0161.rs | 0 src/test/ui/error-codes/E0161.stderr | 14 ++++ .../{compile-fail => ui/error-codes}/E0162.rs | 0 src/test/ui/error-codes/E0162.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0164.rs | 0 src/test/ui/error-codes/E0164.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0165.rs | 0 src/test/ui/error-codes/E0165.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0184.rs | 0 src/test/ui/error-codes/E0184.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0185.rs | 0 src/test/ui/error-codes/E0185.stderr | 11 +++ .../{compile-fail => ui/error-codes}/E0186.rs | 0 src/test/ui/error-codes/E0186.stderr | 11 +++ .../{compile-fail => ui/error-codes}/E0191.rs | 0 src/test/ui/error-codes/E0191.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0192.rs | 0 src/test/ui/error-codes/E0192.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0194.rs | 0 src/test/ui/error-codes/E0194.stderr | 11 +++ .../{compile-fail => ui/error-codes}/E0195.rs | 0 src/test/ui/error-codes/E0195.stderr | 11 +++ .../{compile-fail => ui/error-codes}/E0197.rs | 0 src/test/ui/error-codes/E0197.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0198.rs | 0 src/test/ui/error-codes/E0198.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0199.rs | 0 src/test/ui/error-codes/E0199.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0200.rs | 0 src/test/ui/error-codes/E0200.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0201.rs | 0 src/test/ui/error-codes/E0201.stderr | 27 +++++++ .../{compile-fail => ui/error-codes}/E0206.rs | 0 src/test/ui/error-codes/E0206.stderr | 23 ++++++ .../{compile-fail => ui/error-codes}/E0207.rs | 0 src/test/ui/error-codes/E0207.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0214.rs | 0 src/test/ui/error-codes/E0214.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0220.rs | 0 src/test/ui/error-codes/E0220.stderr | 14 ++++ .../{compile-fail => ui/error-codes}/E0221.rs | 0 src/test/ui/error-codes/E0221.stderr | 29 +++++++ .../{compile-fail => ui/error-codes}/E0223.rs | 0 src/test/ui/error-codes/E0223.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0225.rs | 0 src/test/ui/error-codes/E0225.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0229.rs | 0 src/test/ui/error-codes/E0229.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0232.rs | 0 src/test/ui/error-codes/E0232.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0243.rs | 0 src/test/ui/error-codes/E0243.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0244.rs | 0 src/test/ui/error-codes/E0244.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0252.rs | 0 src/test/ui/error-codes/E0252.stderr | 16 ++++ .../{compile-fail => ui/error-codes}/E0253.rs | 0 src/test/ui/error-codes/E0253.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0254.rs | 0 src/test/ui/error-codes/E0254.stderr | 17 ++++ .../{compile-fail => ui/error-codes}/E0255.rs | 0 src/test/ui/error-codes/E0255.stderr | 17 ++++ .../{compile-fail => ui/error-codes}/E0259.rs | 0 src/test/ui/error-codes/E0259.stderr | 16 ++++ .../{compile-fail => ui/error-codes}/E0260.rs | 0 src/test/ui/error-codes/E0260.stderr | 17 ++++ .../{compile-fail => ui/error-codes}/E0261.rs | 0 src/test/ui/error-codes/E0261.stderr | 14 ++++ .../{compile-fail => ui/error-codes}/E0262.rs | 0 src/test/ui/error-codes/E0262.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0263.rs | 0 src/test/ui/error-codes/E0263.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0264.rs | 0 src/test/ui/error-codes/E0264.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0267.rs | 0 src/test/ui/error-codes/E0267.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0268.rs | 0 src/test/ui/error-codes/E0268.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0271.rs | 0 src/test/ui/error-codes/E0271.stderr | 16 ++++ .../{compile-fail => ui/error-codes}/E0275.rs | 0 src/test/ui/error-codes/E0275.stderr | 79 +++++++++++++++++++ .../{compile-fail => ui/error-codes}/E0276.rs | 0 src/test/ui/error-codes/E0276.stderr | 11 +++ .../error-codes}/E0277-2.rs | 0 src/test/ui/error-codes/E0277-2.stderr | 18 +++++ .../{compile-fail => ui/error-codes}/E0277.rs | 0 src/test/ui/error-codes/E0277.stderr | 24 ++++++ .../{compile-fail => ui/error-codes}/E0282.rs | 0 src/test/ui/error-codes/E0282.stderr | 11 +++ .../{compile-fail => ui/error-codes}/E0283.rs | 0 src/test/ui/error-codes/E0283.stderr | 14 ++++ .../{compile-fail => ui/error-codes}/E0296.rs | 0 src/test/ui/error-codes/E0296.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0297.rs | 0 src/test/ui/error-codes/E0297.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0301.rs | 0 src/test/ui/error-codes/E0301.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0302.rs | 0 src/test/ui/error-codes/E0302.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0303.rs | 0 src/test/ui/error-codes/E0303.stderr | 17 ++++ .../error-codes}/E0308-4.rs | 0 src/test/ui/error-codes/E0308-4.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0308.rs | 0 src/test/ui/error-codes/E0308.stderr | 11 +++ .../{compile-fail => ui/error-codes}/E0365.rs | 0 src/test/ui/error-codes/E0365.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0370.rs | 0 src/test/ui/error-codes/E0370.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0374.rs | 0 src/test/ui/error-codes/E0374.stderr | 9 +++ .../{compile-fail => ui/error-codes}/E0375.rs | 0 src/test/ui/error-codes/E0375.stderr | 11 +++ .../{compile-fail => ui/error-codes}/E0376.rs | 0 src/test/ui/error-codes/E0376.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0388.rs | 0 src/test/ui/error-codes/E0388.stderr | 26 ++++++ .../{compile-fail => ui/error-codes}/E0389.rs | 0 src/test/ui/error-codes/E0389.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0390.rs | 0 src/test/ui/error-codes/E0390.stderr | 14 ++++ .../{compile-fail => ui/error-codes}/E0392.rs | 0 src/test/ui/error-codes/E0392.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0393.rs | 0 src/test/ui/error-codes/E0393.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0394.rs | 0 src/test/ui/error-codes/E0394.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0395.rs | 0 src/test/ui/error-codes/E0395.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0396.rs | 0 src/test/ui/error-codes/E0396.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0401.rs | 0 src/test/ui/error-codes/E0401.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0403.rs | 0 src/test/ui/error-codes/E0403.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0404.rs | 0 src/test/ui/error-codes/E0404.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0405.rs | 0 src/test/ui/error-codes/E0405.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0407.rs | 0 src/test/ui/error-codes/E0407.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0408.rs | 0 src/test/ui/error-codes/E0408.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0411.rs | 0 src/test/ui/error-codes/E0411.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0412.rs | 0 src/test/ui/error-codes/E0412.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0415.rs | 0 src/test/ui/error-codes/E0415.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0416.rs | 0 src/test/ui/error-codes/E0416.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0423.rs | 0 src/test/ui/error-codes/E0423.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0424.rs | 0 src/test/ui/error-codes/E0424.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0425.rs | 0 src/test/ui/error-codes/E0425.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0426.rs | 0 src/test/ui/error-codes/E0426.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0428.rs | 0 src/test/ui/error-codes/E0428.stderr | 12 +++ .../{compile-fail => ui/error-codes}/E0429.rs | 0 src/test/ui/error-codes/E0429.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0430.rs | 0 src/test/ui/error-codes/E0430.stderr | 24 ++++++ .../{compile-fail => ui/error-codes}/E0431.rs | 0 src/test/ui/error-codes/E0431.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0432.rs | 0 src/test/ui/error-codes/E0432.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0433.rs | 0 src/test/ui/error-codes/E0433.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0434.rs | 0 src/test/ui/error-codes/E0434.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0435.rs | 0 src/test/ui/error-codes/E0435.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0437.rs | 0 src/test/ui/error-codes/E0437.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0438.rs | 0 src/test/ui/error-codes/E0438.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0439.rs | 0 src/test/ui/error-codes/E0439.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0440.rs | 0 src/test/ui/error-codes/E0440.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0441.rs | 0 src/test/ui/error-codes/E0441.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0442.rs | 0 src/test/ui/error-codes/E0442.stderr | 20 +++++ .../{compile-fail => ui/error-codes}/E0443.rs | 0 src/test/ui/error-codes/E0443.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0444.rs | 0 src/test/ui/error-codes/E0444.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0445.rs | 0 src/test/ui/error-codes/E0445.stderr | 20 +++++ .../{compile-fail => ui/error-codes}/E0446.rs | 0 src/test/ui/error-codes/E0446.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0449.rs | 0 src/test/ui/error-codes/E0449.stderr | 24 ++++++ .../{compile-fail => ui/error-codes}/E0451.rs | 0 src/test/ui/error-codes/E0451.stderr | 14 ++++ .../{compile-fail => ui/error-codes}/E0452.rs | 0 src/test/ui/error-codes/E0452.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0453.rs | 0 src/test/ui/error-codes/E0453.stderr | 11 +++ .../{compile-fail => ui/error-codes}/E0454.rs | 0 src/test/ui/error-codes/E0454.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0458.rs | 0 src/test/ui/error-codes/E0458.stderr | 14 ++++ .../{compile-fail => ui/error-codes}/E0459.rs | 0 src/test/ui/error-codes/E0459.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0463.rs | 0 src/test/ui/error-codes/E0463.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0478.rs | 0 src/test/ui/error-codes/E0478.stderr | 19 +++++ .../{compile-fail => ui/error-codes}/E0492.rs | 0 src/test/ui/error-codes/E0492.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0494.rs | 0 src/test/ui/error-codes/E0494.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0496.rs | 0 src/test/ui/error-codes/E0496.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0499.rs | 0 src/test/ui/error-codes/E0499.stderr | 12 +++ .../{compile-fail => ui/error-codes}/E0502.rs | 0 src/test/ui/error-codes/E0502.stderr | 12 +++ .../{compile-fail => ui/error-codes}/E0503.rs | 0 src/test/ui/error-codes/E0503.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0504.rs | 0 src/test/ui/error-codes/E0504.stderr | 11 +++ .../{compile-fail => ui/error-codes}/E0505.rs | 0 src/test/ui/error-codes/E0505.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0507.rs | 0 src/test/ui/error-codes/E0507.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0509.rs | 0 src/test/ui/error-codes/E0509.stderr | 11 +++ .../{compile-fail => ui/error-codes}/E0511.rs | 0 src/test/ui/error-codes/E0511.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0512.rs | 0 src/test/ui/error-codes/E0512.stderr | 11 +++ .../{compile-fail => ui/error-codes}/E0516.rs | 0 src/test/ui/error-codes/E0516.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0517.rs | 0 src/test/ui/error-codes/E0517.stderr | 35 ++++++++ .../{compile-fail => ui/error-codes}/E0518.rs | 0 src/test/ui/error-codes/E0518.stderr | 19 +++++ .../{compile-fail => ui/error-codes}/E0520.rs | 0 src/test/ui/error-codes/E0520.stderr | 15 ++++ .../{compile-fail => ui/error-codes}/E0522.rs | 0 src/test/ui/error-codes/E0522.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0527.rs | 0 src/test/ui/error-codes/E0527.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0528.rs | 0 src/test/ui/error-codes/E0528.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0529.rs | 0 src/test/ui/error-codes/E0529.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0530.rs | 0 src/test/ui/error-codes/E0530.stderr | 11 +++ .../{compile-fail => ui/error-codes}/E0532.rs | 0 src/test/ui/error-codes/E0532.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0534.rs | 0 src/test/ui/error-codes/E0534.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0558.rs | 0 src/test/ui/error-codes/E0558.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0559.rs | 0 src/test/ui/error-codes/E0559.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0560.rs | 0 src/test/ui/error-codes/E0560.stderr | 10 +++ .../error-codes}/E0565-1.rs | 0 src/test/ui/error-codes/E0565-1.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0565.rs | 0 src/test/ui/error-codes/E0565.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0572.rs | 0 src/test/ui/error-codes/E0572.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0582.rs | 0 src/test/ui/error-codes/E0582.stderr | 14 ++++ .../{compile-fail => ui/error-codes}/E0585.rs | 0 src/test/ui/error-codes/E0585.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0586.rs | 0 src/test/ui/error-codes/E0586.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0597.rs | 0 src/test/ui/error-codes/E0597.stderr | 13 +++ .../{compile-fail => ui/error-codes}/E0599.rs | 0 src/test/ui/error-codes/E0599.stderr | 11 +++ .../{compile-fail => ui/error-codes}/E0600.rs | 0 src/test/ui/error-codes/E0600.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0602.rs | 0 src/test/ui/error-codes/E0602.stderr | 6 ++ .../{compile-fail => ui/error-codes}/E0603.rs | 0 src/test/ui/error-codes/E0603.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0604.rs | 0 src/test/ui/error-codes/E0604.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0605.rs | 0 src/test/ui/error-codes/E0605.stderr | 18 +++++ .../{compile-fail => ui/error-codes}/E0606.rs | 0 src/test/ui/error-codes/E0606.stderr | 14 ++++ .../{compile-fail => ui/error-codes}/E0607.rs | 0 src/test/ui/error-codes/E0607.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0608.rs | 0 src/test/ui/error-codes/E0608.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0609.rs | 0 src/test/ui/error-codes/E0609.stderr | 16 ++++ .../{compile-fail => ui/error-codes}/E0610.rs | 0 src/test/ui/error-codes/E0610.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0611.rs | 0 src/test/ui/error-codes/E0611.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0612.rs | 0 src/test/ui/error-codes/E0612.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0614.rs | 0 src/test/ui/error-codes/E0614.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0615.rs | 0 src/test/ui/error-codes/E0615.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0616.rs | 0 src/test/ui/error-codes/E0616.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0617.rs | 0 src/test/ui/error-codes/E0617.stderr | 42 ++++++++++ .../{compile-fail => ui/error-codes}/E0618.rs | 0 src/test/ui/error-codes/E0618.stderr | 23 ++++++ .../{compile-fail => ui/error-codes}/E0619.rs | 0 src/test/ui/error-codes/E0619.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0620.rs | 0 src/test/ui/error-codes/E0620.stderr | 14 ++++ .../E0621-does-not-trigger-for-closures.rs | 0 ...E0621-does-not-trigger-for-closures.stderr | 29 +++++++ .../{compile-fail => ui/error-codes}/E0622.rs | 0 src/test/ui/error-codes/E0622.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0624.rs | 0 src/test/ui/error-codes/E0624.stderr | 8 ++ .../{compile-fail => ui/error-codes}/E0637.rs | 0 src/test/ui/error-codes/E0637.stderr | 20 +++++ .../{compile-fail => ui/error-codes}/E0657.rs | 0 src/test/ui/error-codes/E0657.stderr | 14 ++++ .../{compile-fail => ui/error-codes}/E0658.rs | 0 src/test/ui/error-codes/E0658.stderr | 10 +++ .../{compile-fail => ui/error-codes}/E0659.rs | 0 src/test/ui/error-codes/E0659.stderr | 20 +++++ 482 files changed, 3026 insertions(+) rename src/test/{compile-fail => ui/error-codes}/E0001.rs (100%) create mode 100644 src/test/ui/error-codes/E0001.stderr rename src/test/{compile-fail => ui/error-codes}/E0004-2.rs (100%) create mode 100644 src/test/ui/error-codes/E0004-2.stderr rename src/test/{compile-fail => ui/error-codes}/E0004.rs (100%) create mode 100644 src/test/ui/error-codes/E0004.stderr rename src/test/{compile-fail => ui/error-codes}/E0005.rs (100%) create mode 100644 src/test/ui/error-codes/E0005.stderr rename src/test/{compile-fail => ui/error-codes}/E0007.rs (100%) create mode 100644 src/test/ui/error-codes/E0007.stderr rename src/test/{compile-fail => ui/error-codes}/E0008.rs (100%) create mode 100644 src/test/ui/error-codes/E0008.stderr rename src/test/{compile-fail => ui/error-codes}/E0009.rs (100%) create mode 100644 src/test/ui/error-codes/E0009.stderr create mode 100644 src/test/ui/error-codes/E0010-teach.rs create mode 100644 src/test/ui/error-codes/E0010-teach.stderr rename src/test/{compile-fail => ui/error-codes}/E0010.rs (100%) create mode 100644 src/test/ui/error-codes/E0010.stderr rename src/test/{compile-fail => ui/error-codes}/E0017.rs (100%) create mode 100644 src/test/ui/error-codes/E0017.stderr rename src/test/{compile-fail => ui/error-codes}/E0023.rs (100%) create mode 100644 src/test/ui/error-codes/E0023.stderr rename src/test/{compile-fail => ui/error-codes}/E0025.rs (100%) create mode 100644 src/test/ui/error-codes/E0025.stderr create mode 100644 src/test/ui/error-codes/E0026-teach.rs create mode 100644 src/test/ui/error-codes/E0026-teach.stderr rename src/test/{compile-fail => ui/error-codes}/E0026.rs (100%) create mode 100644 src/test/ui/error-codes/E0026.stderr create mode 100644 src/test/ui/error-codes/E0027-teach.rs create mode 100644 src/test/ui/error-codes/E0027-teach.stderr rename src/test/{compile-fail => ui/error-codes}/E0027.rs (100%) create mode 100644 src/test/ui/error-codes/E0027.stderr create mode 100644 src/test/ui/error-codes/E0029-teach.rs create mode 100644 src/test/ui/error-codes/E0029-teach.stderr rename src/test/{compile-fail => ui/error-codes}/E0029.rs (100%) create mode 100644 src/test/ui/error-codes/E0029.stderr create mode 100644 src/test/ui/error-codes/E0030-teach.rs create mode 100644 src/test/ui/error-codes/E0030-teach.stderr rename src/test/{compile-fail => ui/error-codes}/E0030.rs (100%) create mode 100644 src/test/ui/error-codes/E0030.stderr create mode 100644 src/test/ui/error-codes/E0033-teach.rs create mode 100644 src/test/ui/error-codes/E0033-teach.stderr rename src/test/{compile-fail => ui/error-codes}/E0033.rs (100%) create mode 100644 src/test/ui/error-codes/E0033.stderr rename src/test/{compile-fail => ui/error-codes}/E0034.rs (100%) create mode 100644 src/test/ui/error-codes/E0034.stderr rename src/test/{compile-fail => ui/error-codes}/E0038.rs (100%) create mode 100644 src/test/ui/error-codes/E0038.stderr rename src/test/{compile-fail => ui/error-codes}/E0040.rs (100%) create mode 100644 src/test/ui/error-codes/E0040.stderr rename src/test/{compile-fail => ui/error-codes}/E0044.rs (100%) create mode 100644 src/test/ui/error-codes/E0044.stderr rename src/test/{compile-fail => ui/error-codes}/E0045.rs (100%) create mode 100644 src/test/ui/error-codes/E0045.stderr rename src/test/{compile-fail => ui/error-codes}/E0049.rs (100%) create mode 100644 src/test/ui/error-codes/E0049.stderr rename src/test/{compile-fail => ui/error-codes}/E0050.rs (100%) create mode 100644 src/test/ui/error-codes/E0050.stderr rename src/test/{compile-fail => ui/error-codes}/E0054.rs (100%) create mode 100644 src/test/ui/error-codes/E0054.stderr rename src/test/{compile-fail => ui/error-codes}/E0055.rs (100%) create mode 100644 src/test/ui/error-codes/E0055.stderr rename src/test/{compile-fail => ui/error-codes}/E0057.rs (100%) create mode 100644 src/test/ui/error-codes/E0057.stderr rename src/test/{compile-fail => ui/error-codes}/E0059.rs (100%) create mode 100644 src/test/ui/error-codes/E0059.stderr rename src/test/{compile-fail => ui/error-codes}/E0060.rs (100%) create mode 100644 src/test/ui/error-codes/E0060.stderr rename src/test/{compile-fail => ui/error-codes}/E0061.rs (100%) create mode 100644 src/test/ui/error-codes/E0061.stderr rename src/test/{compile-fail => ui/error-codes}/E0062.rs (100%) create mode 100644 src/test/ui/error-codes/E0062.stderr rename src/test/{compile-fail => ui/error-codes}/E0063.rs (100%) create mode 100644 src/test/ui/error-codes/E0063.stderr rename src/test/{compile-fail => ui/error-codes}/E0067.rs (100%) create mode 100644 src/test/ui/error-codes/E0067.stderr rename src/test/{compile-fail => ui/error-codes}/E0069.rs (100%) create mode 100644 src/test/ui/error-codes/E0069.stderr rename src/test/{compile-fail => ui/error-codes}/E0070.rs (100%) create mode 100644 src/test/ui/error-codes/E0070.stderr rename src/test/{compile-fail => ui/error-codes}/E0071.rs (100%) create mode 100644 src/test/ui/error-codes/E0071.stderr rename src/test/{compile-fail => ui/error-codes}/E0075.rs (100%) create mode 100644 src/test/ui/error-codes/E0075.stderr rename src/test/{compile-fail => ui/error-codes}/E0076.rs (100%) create mode 100644 src/test/ui/error-codes/E0076.stderr rename src/test/{compile-fail => ui/error-codes}/E0077.rs (100%) create mode 100644 src/test/ui/error-codes/E0077.stderr rename src/test/{compile-fail => ui/error-codes}/E0080.rs (100%) create mode 100644 src/test/ui/error-codes/E0080.stderr rename src/test/{compile-fail => ui/error-codes}/E0081.rs (100%) create mode 100644 src/test/ui/error-codes/E0081.stderr rename src/test/{compile-fail => ui/error-codes}/E0084.rs (100%) create mode 100644 src/test/ui/error-codes/E0084.stderr rename src/test/{compile-fail => ui/error-codes}/E0087.rs (100%) create mode 100644 src/test/ui/error-codes/E0087.stderr rename src/test/{compile-fail => ui/error-codes}/E0088.rs (100%) create mode 100644 src/test/ui/error-codes/E0088.stderr rename src/test/{compile-fail => ui/error-codes}/E0089.rs (100%) create mode 100644 src/test/ui/error-codes/E0089.stderr rename src/test/{compile-fail => ui/error-codes}/E0090.rs (100%) create mode 100644 src/test/ui/error-codes/E0090.stderr rename src/test/{compile-fail => ui/error-codes}/E0091.rs (100%) create mode 100644 src/test/ui/error-codes/E0091.stderr rename src/test/{compile-fail => ui/error-codes}/E0092.rs (100%) create mode 100644 src/test/ui/error-codes/E0092.stderr rename src/test/{compile-fail => ui/error-codes}/E0093.rs (100%) create mode 100644 src/test/ui/error-codes/E0093.stderr rename src/test/{compile-fail => ui/error-codes}/E0094.rs (100%) create mode 100644 src/test/ui/error-codes/E0094.stderr rename src/test/{compile-fail => ui/error-codes}/E0106.rs (100%) create mode 100644 src/test/ui/error-codes/E0106.stderr rename src/test/{compile-fail => ui/error-codes}/E0107.rs (100%) create mode 100644 src/test/ui/error-codes/E0107.stderr rename src/test/{compile-fail => ui/error-codes}/E0109.rs (100%) create mode 100644 src/test/ui/error-codes/E0109.stderr rename src/test/{compile-fail => ui/error-codes}/E0110.rs (100%) create mode 100644 src/test/ui/error-codes/E0110.stderr rename src/test/{compile-fail => ui/error-codes}/E0116.rs (100%) create mode 100644 src/test/ui/error-codes/E0116.stderr rename src/test/{compile-fail => ui/error-codes}/E0117.rs (100%) create mode 100644 src/test/ui/error-codes/E0117.stderr rename src/test/{compile-fail => ui/error-codes}/E0118.rs (100%) create mode 100644 src/test/ui/error-codes/E0118.stderr rename src/test/{compile-fail => ui/error-codes}/E0119.rs (100%) create mode 100644 src/test/ui/error-codes/E0119.stderr rename src/test/{compile-fail => ui/error-codes}/E0120.rs (100%) create mode 100644 src/test/ui/error-codes/E0120.stderr rename src/test/{compile-fail => ui/error-codes}/E0121.rs (100%) create mode 100644 src/test/ui/error-codes/E0121.stderr rename src/test/{compile-fail => ui/error-codes}/E0124.rs (100%) create mode 100644 src/test/ui/error-codes/E0124.stderr rename src/test/{compile-fail => ui/error-codes}/E0128.rs (100%) create mode 100644 src/test/ui/error-codes/E0128.stderr rename src/test/{compile-fail => ui/error-codes}/E0130.rs (100%) create mode 100644 src/test/ui/error-codes/E0130.stderr rename src/test/{compile-fail => ui/error-codes}/E0131.rs (100%) create mode 100644 src/test/ui/error-codes/E0131.stderr rename src/test/{compile-fail => ui/error-codes}/E0132.rs (100%) create mode 100644 src/test/ui/error-codes/E0132.stderr rename src/test/{compile-fail => ui/error-codes}/E0133.rs (100%) create mode 100644 src/test/ui/error-codes/E0133.stderr rename src/test/{compile-fail => ui/error-codes}/E0137.rs (100%) create mode 100644 src/test/ui/error-codes/E0137.stderr rename src/test/{compile-fail => ui/error-codes}/E0138.rs (100%) create mode 100644 src/test/ui/error-codes/E0138.stderr rename src/test/{compile-fail => ui/error-codes}/E0152.rs (100%) create mode 100644 src/test/ui/error-codes/E0152.stderr rename src/test/{compile-fail => ui/error-codes}/E0161.rs (100%) create mode 100644 src/test/ui/error-codes/E0161.stderr rename src/test/{compile-fail => ui/error-codes}/E0162.rs (100%) create mode 100644 src/test/ui/error-codes/E0162.stderr rename src/test/{compile-fail => ui/error-codes}/E0164.rs (100%) create mode 100644 src/test/ui/error-codes/E0164.stderr rename src/test/{compile-fail => ui/error-codes}/E0165.rs (100%) create mode 100644 src/test/ui/error-codes/E0165.stderr rename src/test/{compile-fail => ui/error-codes}/E0184.rs (100%) create mode 100644 src/test/ui/error-codes/E0184.stderr rename src/test/{compile-fail => ui/error-codes}/E0185.rs (100%) create mode 100644 src/test/ui/error-codes/E0185.stderr rename src/test/{compile-fail => ui/error-codes}/E0186.rs (100%) create mode 100644 src/test/ui/error-codes/E0186.stderr rename src/test/{compile-fail => ui/error-codes}/E0191.rs (100%) create mode 100644 src/test/ui/error-codes/E0191.stderr rename src/test/{compile-fail => ui/error-codes}/E0192.rs (100%) create mode 100644 src/test/ui/error-codes/E0192.stderr rename src/test/{compile-fail => ui/error-codes}/E0194.rs (100%) create mode 100644 src/test/ui/error-codes/E0194.stderr rename src/test/{compile-fail => ui/error-codes}/E0195.rs (100%) create mode 100644 src/test/ui/error-codes/E0195.stderr rename src/test/{compile-fail => ui/error-codes}/E0197.rs (100%) create mode 100644 src/test/ui/error-codes/E0197.stderr rename src/test/{compile-fail => ui/error-codes}/E0198.rs (100%) create mode 100644 src/test/ui/error-codes/E0198.stderr rename src/test/{compile-fail => ui/error-codes}/E0199.rs (100%) create mode 100644 src/test/ui/error-codes/E0199.stderr rename src/test/{compile-fail => ui/error-codes}/E0200.rs (100%) create mode 100644 src/test/ui/error-codes/E0200.stderr rename src/test/{compile-fail => ui/error-codes}/E0201.rs (100%) create mode 100644 src/test/ui/error-codes/E0201.stderr rename src/test/{compile-fail => ui/error-codes}/E0206.rs (100%) create mode 100644 src/test/ui/error-codes/E0206.stderr rename src/test/{compile-fail => ui/error-codes}/E0207.rs (100%) create mode 100644 src/test/ui/error-codes/E0207.stderr rename src/test/{compile-fail => ui/error-codes}/E0214.rs (100%) create mode 100644 src/test/ui/error-codes/E0214.stderr rename src/test/{compile-fail => ui/error-codes}/E0220.rs (100%) create mode 100644 src/test/ui/error-codes/E0220.stderr rename src/test/{compile-fail => ui/error-codes}/E0221.rs (100%) create mode 100644 src/test/ui/error-codes/E0221.stderr rename src/test/{compile-fail => ui/error-codes}/E0223.rs (100%) create mode 100644 src/test/ui/error-codes/E0223.stderr rename src/test/{compile-fail => ui/error-codes}/E0225.rs (100%) create mode 100644 src/test/ui/error-codes/E0225.stderr rename src/test/{compile-fail => ui/error-codes}/E0229.rs (100%) create mode 100644 src/test/ui/error-codes/E0229.stderr rename src/test/{compile-fail => ui/error-codes}/E0232.rs (100%) create mode 100644 src/test/ui/error-codes/E0232.stderr rename src/test/{compile-fail => ui/error-codes}/E0243.rs (100%) create mode 100644 src/test/ui/error-codes/E0243.stderr rename src/test/{compile-fail => ui/error-codes}/E0244.rs (100%) create mode 100644 src/test/ui/error-codes/E0244.stderr rename src/test/{compile-fail => ui/error-codes}/E0252.rs (100%) create mode 100644 src/test/ui/error-codes/E0252.stderr rename src/test/{compile-fail => ui/error-codes}/E0253.rs (100%) create mode 100644 src/test/ui/error-codes/E0253.stderr rename src/test/{compile-fail => ui/error-codes}/E0254.rs (100%) create mode 100644 src/test/ui/error-codes/E0254.stderr rename src/test/{compile-fail => ui/error-codes}/E0255.rs (100%) create mode 100644 src/test/ui/error-codes/E0255.stderr rename src/test/{compile-fail => ui/error-codes}/E0259.rs (100%) create mode 100644 src/test/ui/error-codes/E0259.stderr rename src/test/{compile-fail => ui/error-codes}/E0260.rs (100%) create mode 100644 src/test/ui/error-codes/E0260.stderr rename src/test/{compile-fail => ui/error-codes}/E0261.rs (100%) create mode 100644 src/test/ui/error-codes/E0261.stderr rename src/test/{compile-fail => ui/error-codes}/E0262.rs (100%) create mode 100644 src/test/ui/error-codes/E0262.stderr rename src/test/{compile-fail => ui/error-codes}/E0263.rs (100%) create mode 100644 src/test/ui/error-codes/E0263.stderr rename src/test/{compile-fail => ui/error-codes}/E0264.rs (100%) create mode 100644 src/test/ui/error-codes/E0264.stderr rename src/test/{compile-fail => ui/error-codes}/E0267.rs (100%) create mode 100644 src/test/ui/error-codes/E0267.stderr rename src/test/{compile-fail => ui/error-codes}/E0268.rs (100%) create mode 100644 src/test/ui/error-codes/E0268.stderr rename src/test/{compile-fail => ui/error-codes}/E0271.rs (100%) create mode 100644 src/test/ui/error-codes/E0271.stderr rename src/test/{compile-fail => ui/error-codes}/E0275.rs (100%) create mode 100644 src/test/ui/error-codes/E0275.stderr rename src/test/{compile-fail => ui/error-codes}/E0276.rs (100%) create mode 100644 src/test/ui/error-codes/E0276.stderr rename src/test/{compile-fail => ui/error-codes}/E0277-2.rs (100%) create mode 100644 src/test/ui/error-codes/E0277-2.stderr rename src/test/{compile-fail => ui/error-codes}/E0277.rs (100%) create mode 100644 src/test/ui/error-codes/E0277.stderr rename src/test/{compile-fail => ui/error-codes}/E0282.rs (100%) create mode 100644 src/test/ui/error-codes/E0282.stderr rename src/test/{compile-fail => ui/error-codes}/E0283.rs (100%) create mode 100644 src/test/ui/error-codes/E0283.stderr rename src/test/{compile-fail => ui/error-codes}/E0296.rs (100%) create mode 100644 src/test/ui/error-codes/E0296.stderr rename src/test/{compile-fail => ui/error-codes}/E0297.rs (100%) create mode 100644 src/test/ui/error-codes/E0297.stderr rename src/test/{compile-fail => ui/error-codes}/E0301.rs (100%) create mode 100644 src/test/ui/error-codes/E0301.stderr rename src/test/{compile-fail => ui/error-codes}/E0302.rs (100%) create mode 100644 src/test/ui/error-codes/E0302.stderr rename src/test/{compile-fail => ui/error-codes}/E0303.rs (100%) create mode 100644 src/test/ui/error-codes/E0303.stderr rename src/test/{compile-fail => ui/error-codes}/E0308-4.rs (100%) create mode 100644 src/test/ui/error-codes/E0308-4.stderr rename src/test/{compile-fail => ui/error-codes}/E0308.rs (100%) create mode 100644 src/test/ui/error-codes/E0308.stderr rename src/test/{compile-fail => ui/error-codes}/E0365.rs (100%) create mode 100644 src/test/ui/error-codes/E0365.stderr rename src/test/{compile-fail => ui/error-codes}/E0370.rs (100%) create mode 100644 src/test/ui/error-codes/E0370.stderr rename src/test/{compile-fail => ui/error-codes}/E0374.rs (100%) create mode 100644 src/test/ui/error-codes/E0374.stderr rename src/test/{compile-fail => ui/error-codes}/E0375.rs (100%) create mode 100644 src/test/ui/error-codes/E0375.stderr rename src/test/{compile-fail => ui/error-codes}/E0376.rs (100%) create mode 100644 src/test/ui/error-codes/E0376.stderr rename src/test/{compile-fail => ui/error-codes}/E0388.rs (100%) create mode 100644 src/test/ui/error-codes/E0388.stderr rename src/test/{compile-fail => ui/error-codes}/E0389.rs (100%) create mode 100644 src/test/ui/error-codes/E0389.stderr rename src/test/{compile-fail => ui/error-codes}/E0390.rs (100%) create mode 100644 src/test/ui/error-codes/E0390.stderr rename src/test/{compile-fail => ui/error-codes}/E0392.rs (100%) create mode 100644 src/test/ui/error-codes/E0392.stderr rename src/test/{compile-fail => ui/error-codes}/E0393.rs (100%) create mode 100644 src/test/ui/error-codes/E0393.stderr rename src/test/{compile-fail => ui/error-codes}/E0394.rs (100%) create mode 100644 src/test/ui/error-codes/E0394.stderr rename src/test/{compile-fail => ui/error-codes}/E0395.rs (100%) create mode 100644 src/test/ui/error-codes/E0395.stderr rename src/test/{compile-fail => ui/error-codes}/E0396.rs (100%) create mode 100644 src/test/ui/error-codes/E0396.stderr rename src/test/{compile-fail => ui/error-codes}/E0401.rs (100%) create mode 100644 src/test/ui/error-codes/E0401.stderr rename src/test/{compile-fail => ui/error-codes}/E0403.rs (100%) create mode 100644 src/test/ui/error-codes/E0403.stderr rename src/test/{compile-fail => ui/error-codes}/E0404.rs (100%) create mode 100644 src/test/ui/error-codes/E0404.stderr rename src/test/{compile-fail => ui/error-codes}/E0405.rs (100%) create mode 100644 src/test/ui/error-codes/E0405.stderr rename src/test/{compile-fail => ui/error-codes}/E0407.rs (100%) create mode 100644 src/test/ui/error-codes/E0407.stderr rename src/test/{compile-fail => ui/error-codes}/E0408.rs (100%) create mode 100644 src/test/ui/error-codes/E0408.stderr rename src/test/{compile-fail => ui/error-codes}/E0411.rs (100%) create mode 100644 src/test/ui/error-codes/E0411.stderr rename src/test/{compile-fail => ui/error-codes}/E0412.rs (100%) create mode 100644 src/test/ui/error-codes/E0412.stderr rename src/test/{compile-fail => ui/error-codes}/E0415.rs (100%) create mode 100644 src/test/ui/error-codes/E0415.stderr rename src/test/{compile-fail => ui/error-codes}/E0416.rs (100%) create mode 100644 src/test/ui/error-codes/E0416.stderr rename src/test/{compile-fail => ui/error-codes}/E0423.rs (100%) create mode 100644 src/test/ui/error-codes/E0423.stderr rename src/test/{compile-fail => ui/error-codes}/E0424.rs (100%) create mode 100644 src/test/ui/error-codes/E0424.stderr rename src/test/{compile-fail => ui/error-codes}/E0425.rs (100%) create mode 100644 src/test/ui/error-codes/E0425.stderr rename src/test/{compile-fail => ui/error-codes}/E0426.rs (100%) create mode 100644 src/test/ui/error-codes/E0426.stderr rename src/test/{compile-fail => ui/error-codes}/E0428.rs (100%) create mode 100644 src/test/ui/error-codes/E0428.stderr rename src/test/{compile-fail => ui/error-codes}/E0429.rs (100%) create mode 100644 src/test/ui/error-codes/E0429.stderr rename src/test/{compile-fail => ui/error-codes}/E0430.rs (100%) create mode 100644 src/test/ui/error-codes/E0430.stderr rename src/test/{compile-fail => ui/error-codes}/E0431.rs (100%) create mode 100644 src/test/ui/error-codes/E0431.stderr rename src/test/{compile-fail => ui/error-codes}/E0432.rs (100%) create mode 100644 src/test/ui/error-codes/E0432.stderr rename src/test/{compile-fail => ui/error-codes}/E0433.rs (100%) create mode 100644 src/test/ui/error-codes/E0433.stderr rename src/test/{compile-fail => ui/error-codes}/E0434.rs (100%) create mode 100644 src/test/ui/error-codes/E0434.stderr rename src/test/{compile-fail => ui/error-codes}/E0435.rs (100%) create mode 100644 src/test/ui/error-codes/E0435.stderr rename src/test/{compile-fail => ui/error-codes}/E0437.rs (100%) create mode 100644 src/test/ui/error-codes/E0437.stderr rename src/test/{compile-fail => ui/error-codes}/E0438.rs (100%) create mode 100644 src/test/ui/error-codes/E0438.stderr rename src/test/{compile-fail => ui/error-codes}/E0439.rs (100%) create mode 100644 src/test/ui/error-codes/E0439.stderr rename src/test/{compile-fail => ui/error-codes}/E0440.rs (100%) create mode 100644 src/test/ui/error-codes/E0440.stderr rename src/test/{compile-fail => ui/error-codes}/E0441.rs (100%) create mode 100644 src/test/ui/error-codes/E0441.stderr rename src/test/{compile-fail => ui/error-codes}/E0442.rs (100%) create mode 100644 src/test/ui/error-codes/E0442.stderr rename src/test/{compile-fail => ui/error-codes}/E0443.rs (100%) create mode 100644 src/test/ui/error-codes/E0443.stderr rename src/test/{compile-fail => ui/error-codes}/E0444.rs (100%) create mode 100644 src/test/ui/error-codes/E0444.stderr rename src/test/{compile-fail => ui/error-codes}/E0445.rs (100%) create mode 100644 src/test/ui/error-codes/E0445.stderr rename src/test/{compile-fail => ui/error-codes}/E0446.rs (100%) create mode 100644 src/test/ui/error-codes/E0446.stderr rename src/test/{compile-fail => ui/error-codes}/E0449.rs (100%) create mode 100644 src/test/ui/error-codes/E0449.stderr rename src/test/{compile-fail => ui/error-codes}/E0451.rs (100%) create mode 100644 src/test/ui/error-codes/E0451.stderr rename src/test/{compile-fail => ui/error-codes}/E0452.rs (100%) create mode 100644 src/test/ui/error-codes/E0452.stderr rename src/test/{compile-fail => ui/error-codes}/E0453.rs (100%) create mode 100644 src/test/ui/error-codes/E0453.stderr rename src/test/{compile-fail => ui/error-codes}/E0454.rs (100%) create mode 100644 src/test/ui/error-codes/E0454.stderr rename src/test/{compile-fail => ui/error-codes}/E0458.rs (100%) create mode 100644 src/test/ui/error-codes/E0458.stderr rename src/test/{compile-fail => ui/error-codes}/E0459.rs (100%) create mode 100644 src/test/ui/error-codes/E0459.stderr rename src/test/{compile-fail => ui/error-codes}/E0463.rs (100%) create mode 100644 src/test/ui/error-codes/E0463.stderr rename src/test/{compile-fail => ui/error-codes}/E0478.rs (100%) create mode 100644 src/test/ui/error-codes/E0478.stderr rename src/test/{compile-fail => ui/error-codes}/E0492.rs (100%) create mode 100644 src/test/ui/error-codes/E0492.stderr rename src/test/{compile-fail => ui/error-codes}/E0494.rs (100%) create mode 100644 src/test/ui/error-codes/E0494.stderr rename src/test/{compile-fail => ui/error-codes}/E0496.rs (100%) create mode 100644 src/test/ui/error-codes/E0496.stderr rename src/test/{compile-fail => ui/error-codes}/E0499.rs (100%) create mode 100644 src/test/ui/error-codes/E0499.stderr rename src/test/{compile-fail => ui/error-codes}/E0502.rs (100%) create mode 100644 src/test/ui/error-codes/E0502.stderr rename src/test/{compile-fail => ui/error-codes}/E0503.rs (100%) create mode 100644 src/test/ui/error-codes/E0503.stderr rename src/test/{compile-fail => ui/error-codes}/E0504.rs (100%) create mode 100644 src/test/ui/error-codes/E0504.stderr rename src/test/{compile-fail => ui/error-codes}/E0505.rs (100%) create mode 100644 src/test/ui/error-codes/E0505.stderr rename src/test/{compile-fail => ui/error-codes}/E0507.rs (100%) create mode 100644 src/test/ui/error-codes/E0507.stderr rename src/test/{compile-fail => ui/error-codes}/E0509.rs (100%) create mode 100644 src/test/ui/error-codes/E0509.stderr rename src/test/{compile-fail => ui/error-codes}/E0511.rs (100%) create mode 100644 src/test/ui/error-codes/E0511.stderr rename src/test/{compile-fail => ui/error-codes}/E0512.rs (100%) create mode 100644 src/test/ui/error-codes/E0512.stderr rename src/test/{compile-fail => ui/error-codes}/E0516.rs (100%) create mode 100644 src/test/ui/error-codes/E0516.stderr rename src/test/{compile-fail => ui/error-codes}/E0517.rs (100%) create mode 100644 src/test/ui/error-codes/E0517.stderr rename src/test/{compile-fail => ui/error-codes}/E0518.rs (100%) create mode 100644 src/test/ui/error-codes/E0518.stderr rename src/test/{compile-fail => ui/error-codes}/E0520.rs (100%) create mode 100644 src/test/ui/error-codes/E0520.stderr rename src/test/{compile-fail => ui/error-codes}/E0522.rs (100%) create mode 100644 src/test/ui/error-codes/E0522.stderr rename src/test/{compile-fail => ui/error-codes}/E0527.rs (100%) create mode 100644 src/test/ui/error-codes/E0527.stderr rename src/test/{compile-fail => ui/error-codes}/E0528.rs (100%) create mode 100644 src/test/ui/error-codes/E0528.stderr rename src/test/{compile-fail => ui/error-codes}/E0529.rs (100%) create mode 100644 src/test/ui/error-codes/E0529.stderr rename src/test/{compile-fail => ui/error-codes}/E0530.rs (100%) create mode 100644 src/test/ui/error-codes/E0530.stderr rename src/test/{compile-fail => ui/error-codes}/E0532.rs (100%) create mode 100644 src/test/ui/error-codes/E0532.stderr rename src/test/{compile-fail => ui/error-codes}/E0534.rs (100%) create mode 100644 src/test/ui/error-codes/E0534.stderr rename src/test/{compile-fail => ui/error-codes}/E0558.rs (100%) create mode 100644 src/test/ui/error-codes/E0558.stderr rename src/test/{compile-fail => ui/error-codes}/E0559.rs (100%) create mode 100644 src/test/ui/error-codes/E0559.stderr rename src/test/{compile-fail => ui/error-codes}/E0560.rs (100%) create mode 100644 src/test/ui/error-codes/E0560.stderr rename src/test/{compile-fail => ui/error-codes}/E0565-1.rs (100%) create mode 100644 src/test/ui/error-codes/E0565-1.stderr rename src/test/{compile-fail => ui/error-codes}/E0565.rs (100%) create mode 100644 src/test/ui/error-codes/E0565.stderr rename src/test/{compile-fail => ui/error-codes}/E0572.rs (100%) create mode 100644 src/test/ui/error-codes/E0572.stderr rename src/test/{compile-fail => ui/error-codes}/E0582.rs (100%) create mode 100644 src/test/ui/error-codes/E0582.stderr rename src/test/{compile-fail => ui/error-codes}/E0585.rs (100%) create mode 100644 src/test/ui/error-codes/E0585.stderr rename src/test/{compile-fail => ui/error-codes}/E0586.rs (100%) create mode 100644 src/test/ui/error-codes/E0586.stderr rename src/test/{compile-fail => ui/error-codes}/E0597.rs (100%) create mode 100644 src/test/ui/error-codes/E0597.stderr rename src/test/{compile-fail => ui/error-codes}/E0599.rs (100%) create mode 100644 src/test/ui/error-codes/E0599.stderr rename src/test/{compile-fail => ui/error-codes}/E0600.rs (100%) create mode 100644 src/test/ui/error-codes/E0600.stderr rename src/test/{compile-fail => ui/error-codes}/E0602.rs (100%) create mode 100644 src/test/ui/error-codes/E0602.stderr rename src/test/{compile-fail => ui/error-codes}/E0603.rs (100%) create mode 100644 src/test/ui/error-codes/E0603.stderr rename src/test/{compile-fail => ui/error-codes}/E0604.rs (100%) create mode 100644 src/test/ui/error-codes/E0604.stderr rename src/test/{compile-fail => ui/error-codes}/E0605.rs (100%) create mode 100644 src/test/ui/error-codes/E0605.stderr rename src/test/{compile-fail => ui/error-codes}/E0606.rs (100%) create mode 100644 src/test/ui/error-codes/E0606.stderr rename src/test/{compile-fail => ui/error-codes}/E0607.rs (100%) create mode 100644 src/test/ui/error-codes/E0607.stderr rename src/test/{compile-fail => ui/error-codes}/E0608.rs (100%) create mode 100644 src/test/ui/error-codes/E0608.stderr rename src/test/{compile-fail => ui/error-codes}/E0609.rs (100%) create mode 100644 src/test/ui/error-codes/E0609.stderr rename src/test/{compile-fail => ui/error-codes}/E0610.rs (100%) create mode 100644 src/test/ui/error-codes/E0610.stderr rename src/test/{compile-fail => ui/error-codes}/E0611.rs (100%) create mode 100644 src/test/ui/error-codes/E0611.stderr rename src/test/{compile-fail => ui/error-codes}/E0612.rs (100%) create mode 100644 src/test/ui/error-codes/E0612.stderr rename src/test/{compile-fail => ui/error-codes}/E0614.rs (100%) create mode 100644 src/test/ui/error-codes/E0614.stderr rename src/test/{compile-fail => ui/error-codes}/E0615.rs (100%) create mode 100644 src/test/ui/error-codes/E0615.stderr rename src/test/{compile-fail => ui/error-codes}/E0616.rs (100%) create mode 100644 src/test/ui/error-codes/E0616.stderr rename src/test/{compile-fail => ui/error-codes}/E0617.rs (100%) create mode 100644 src/test/ui/error-codes/E0617.stderr rename src/test/{compile-fail => ui/error-codes}/E0618.rs (100%) create mode 100644 src/test/ui/error-codes/E0618.stderr rename src/test/{compile-fail => ui/error-codes}/E0619.rs (100%) create mode 100644 src/test/ui/error-codes/E0619.stderr rename src/test/{compile-fail => ui/error-codes}/E0620.rs (100%) create mode 100644 src/test/ui/error-codes/E0620.stderr rename src/test/{compile-fail => ui/error-codes}/E0621-does-not-trigger-for-closures.rs (100%) create mode 100644 src/test/ui/error-codes/E0621-does-not-trigger-for-closures.stderr rename src/test/{compile-fail => ui/error-codes}/E0622.rs (100%) create mode 100644 src/test/ui/error-codes/E0622.stderr rename src/test/{compile-fail => ui/error-codes}/E0624.rs (100%) create mode 100644 src/test/ui/error-codes/E0624.stderr rename src/test/{compile-fail => ui/error-codes}/E0637.rs (100%) create mode 100644 src/test/ui/error-codes/E0637.stderr rename src/test/{compile-fail => ui/error-codes}/E0657.rs (100%) create mode 100644 src/test/ui/error-codes/E0657.stderr rename src/test/{compile-fail => ui/error-codes}/E0658.rs (100%) create mode 100644 src/test/ui/error-codes/E0658.stderr rename src/test/{compile-fail => ui/error-codes}/E0659.rs (100%) create mode 100644 src/test/ui/error-codes/E0659.stderr diff --git a/src/test/compile-fail/E0001.rs b/src/test/ui/error-codes/E0001.rs similarity index 100% rename from src/test/compile-fail/E0001.rs rename to src/test/ui/error-codes/E0001.rs diff --git a/src/test/ui/error-codes/E0001.stderr b/src/test/ui/error-codes/E0001.stderr new file mode 100644 index 0000000000000..d7d67af1492c6 --- /dev/null +++ b/src/test/ui/error-codes/E0001.stderr @@ -0,0 +1,14 @@ +error: unreachable pattern + --> $DIR/E0001.rs:18:9 + | +18 | _ => {/* ... */} //~ ERROR unreachable pattern + | ^ + | +note: lint level defined here + --> $DIR/E0001.rs:11:9 + | +11 | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0004-2.rs b/src/test/ui/error-codes/E0004-2.rs similarity index 100% rename from src/test/compile-fail/E0004-2.rs rename to src/test/ui/error-codes/E0004-2.rs diff --git a/src/test/ui/error-codes/E0004-2.stderr b/src/test/ui/error-codes/E0004-2.stderr new file mode 100644 index 0000000000000..2f4d26e2f327c --- /dev/null +++ b/src/test/ui/error-codes/E0004-2.stderr @@ -0,0 +1,14 @@ +error[E0004]: non-exhaustive patterns: type std::option::Option is non-empty + --> $DIR/E0004-2.rs:14:11 + | +14 | match x { } //~ ERROR E0004 + | ^ + | +help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms. + --> $DIR/E0004-2.rs:14:11 + | +14 | match x { } //~ ERROR E0004 + | ^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0004.rs b/src/test/ui/error-codes/E0004.rs similarity index 100% rename from src/test/compile-fail/E0004.rs rename to src/test/ui/error-codes/E0004.rs diff --git a/src/test/ui/error-codes/E0004.stderr b/src/test/ui/error-codes/E0004.stderr new file mode 100644 index 0000000000000..836afaf05ba9f --- /dev/null +++ b/src/test/ui/error-codes/E0004.stderr @@ -0,0 +1,8 @@ +error[E0004]: non-exhaustive patterns: `HastaLaVistaBaby` not covered + --> $DIR/E0004.rs:19:11 + | +19 | match x { //~ ERROR E0004 + | ^ pattern `HastaLaVistaBaby` not covered + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0005.rs b/src/test/ui/error-codes/E0005.rs similarity index 100% rename from src/test/compile-fail/E0005.rs rename to src/test/ui/error-codes/E0005.rs diff --git a/src/test/ui/error-codes/E0005.stderr b/src/test/ui/error-codes/E0005.stderr new file mode 100644 index 0000000000000..d052c12e9fe9d --- /dev/null +++ b/src/test/ui/error-codes/E0005.stderr @@ -0,0 +1,8 @@ +error[E0005]: refutable pattern in local binding: `None` not covered + --> $DIR/E0005.rs:13:9 + | +13 | let Some(y) = x; //~ ERROR E0005 + | ^^^^^^^ pattern `None` not covered + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0007.rs b/src/test/ui/error-codes/E0007.rs similarity index 100% rename from src/test/compile-fail/E0007.rs rename to src/test/ui/error-codes/E0007.rs diff --git a/src/test/ui/error-codes/E0007.stderr b/src/test/ui/error-codes/E0007.stderr new file mode 100644 index 0000000000000..1370cacd7cbfa --- /dev/null +++ b/src/test/ui/error-codes/E0007.stderr @@ -0,0 +1,14 @@ +error[E0007]: cannot bind by-move with sub-bindings + --> $DIR/E0007.rs:14:9 + | +14 | op_string @ Some(s) => {}, + | ^^^^^^^^^^^^^^^^^^^ binds an already bound by-move value by moving it + +error[E0303]: pattern bindings are not allowed after an `@` + --> $DIR/E0007.rs:14:26 + | +14 | op_string @ Some(s) => {}, + | ^ not allowed after `@` + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0008.rs b/src/test/ui/error-codes/E0008.rs similarity index 100% rename from src/test/compile-fail/E0008.rs rename to src/test/ui/error-codes/E0008.rs diff --git a/src/test/ui/error-codes/E0008.stderr b/src/test/ui/error-codes/E0008.stderr new file mode 100644 index 0000000000000..6ae4506a6e390 --- /dev/null +++ b/src/test/ui/error-codes/E0008.stderr @@ -0,0 +1,8 @@ +error[E0008]: cannot bind by-move into a pattern guard + --> $DIR/E0008.rs:13:14 + | +13 | Some(s) if s.len() == 0 => {}, + | ^ moves value into pattern guard + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0009.rs b/src/test/ui/error-codes/E0009.rs similarity index 100% rename from src/test/compile-fail/E0009.rs rename to src/test/ui/error-codes/E0009.rs diff --git a/src/test/ui/error-codes/E0009.stderr b/src/test/ui/error-codes/E0009.stderr new file mode 100644 index 0000000000000..31db957621d21 --- /dev/null +++ b/src/test/ui/error-codes/E0009.stderr @@ -0,0 +1,10 @@ +error[E0009]: cannot bind by-move and by-ref in the same pattern + --> $DIR/E0009.rs:15:15 + | +15 | Some((y, ref z)) => {}, + | ^ ----- both by-ref and by-move used + | | + | by-move pattern here + +error: aborting due to previous error + diff --git a/src/test/ui/error-codes/E0010-teach.rs b/src/test/ui/error-codes/E0010-teach.rs new file mode 100644 index 0000000000000..e5ccf32af1473 --- /dev/null +++ b/src/test/ui/error-codes/E0010-teach.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z teach + +#![feature(box_syntax)] +#![allow(warnings)] + +const CON : Box = box 0; //~ ERROR E0010 + +fn main() {} diff --git a/src/test/ui/error-codes/E0010-teach.stderr b/src/test/ui/error-codes/E0010-teach.stderr new file mode 100644 index 0000000000000..46f8101ca65ad --- /dev/null +++ b/src/test/ui/error-codes/E0010-teach.stderr @@ -0,0 +1,10 @@ +error[E0010]: allocations are not allowed in constants + --> $DIR/E0010-teach.rs:16:24 + | +16 | const CON : Box = box 0; //~ ERROR E0010 + | ^^^^^ allocation not allowed in constants + | + = note: The value of statics and constants must be known at compile time, and they live for the entire lifetime of a program. Creating a boxed value allocates memory on the heap at runtime, and therefore cannot be done at compile time. + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0010.rs b/src/test/ui/error-codes/E0010.rs similarity index 100% rename from src/test/compile-fail/E0010.rs rename to src/test/ui/error-codes/E0010.rs diff --git a/src/test/ui/error-codes/E0010.stderr b/src/test/ui/error-codes/E0010.stderr new file mode 100644 index 0000000000000..5cef631e05ed6 --- /dev/null +++ b/src/test/ui/error-codes/E0010.stderr @@ -0,0 +1,8 @@ +error[E0010]: allocations are not allowed in constants + --> $DIR/E0010.rs:14:24 + | +14 | const CON : Box = box 0; //~ ERROR E0010 + | ^^^^^ allocation not allowed in constants + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0017.rs b/src/test/ui/error-codes/E0017.rs similarity index 100% rename from src/test/compile-fail/E0017.rs rename to src/test/ui/error-codes/E0017.rs diff --git a/src/test/ui/error-codes/E0017.stderr b/src/test/ui/error-codes/E0017.stderr new file mode 100644 index 0000000000000..f1fe1e58b34d7 --- /dev/null +++ b/src/test/ui/error-codes/E0017.stderr @@ -0,0 +1,26 @@ +error[E0017]: references in constants may only refer to immutable values + --> $DIR/E0017.rs:14:30 + | +14 | const CR: &'static mut i32 = &mut C; //~ ERROR E0017 + | ^^^^^^ constants require immutable values + +error[E0017]: references in statics may only refer to immutable values + --> $DIR/E0017.rs:15:39 + | +15 | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 + | ^^^^^^ statics require immutable values + +error[E0596]: cannot borrow immutable static item as mutable + --> $DIR/E0017.rs:15:44 + | +15 | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 + | ^ + +error[E0017]: references in statics may only refer to immutable values + --> $DIR/E0017.rs:17:38 + | +17 | static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017 + | ^^^^^^ statics require immutable values + +error: aborting due to 4 previous errors + diff --git a/src/test/compile-fail/E0023.rs b/src/test/ui/error-codes/E0023.rs similarity index 100% rename from src/test/compile-fail/E0023.rs rename to src/test/ui/error-codes/E0023.rs diff --git a/src/test/ui/error-codes/E0023.stderr b/src/test/ui/error-codes/E0023.stderr new file mode 100644 index 0000000000000..582dffeb19ce2 --- /dev/null +++ b/src/test/ui/error-codes/E0023.stderr @@ -0,0 +1,20 @@ +error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields + --> $DIR/E0023.rs:20:9 + | +20 | Fruit::Apple(a) => {}, //~ ERROR E0023 + | ^^^^^^^^^^^^^^^ expected 2 fields, found 1 + +error[E0023]: this pattern has 3 fields, but the corresponding tuple variant has 2 fields + --> $DIR/E0023.rs:21:9 + | +21 | Fruit::Apple(a, b, c) => {}, //~ ERROR E0023 + | ^^^^^^^^^^^^^^^^^^^^^ expected 2 fields, found 3 + +error[E0023]: this pattern has 2 fields, but the corresponding tuple variant has 1 field + --> $DIR/E0023.rs:22:9 + | +22 | Fruit::Pear(1, 2) => {}, //~ ERROR E0023 + | ^^^^^^^^^^^^^^^^^ expected 1 field, found 2 + +error: aborting due to 3 previous errors + diff --git a/src/test/compile-fail/E0025.rs b/src/test/ui/error-codes/E0025.rs similarity index 100% rename from src/test/compile-fail/E0025.rs rename to src/test/ui/error-codes/E0025.rs diff --git a/src/test/ui/error-codes/E0025.stderr b/src/test/ui/error-codes/E0025.stderr new file mode 100644 index 0000000000000..480cd2a5cc8a9 --- /dev/null +++ b/src/test/ui/error-codes/E0025.stderr @@ -0,0 +1,10 @@ +error[E0025]: field `a` bound multiple times in the pattern + --> $DIR/E0025.rs:18:21 + | +18 | let Foo { a: x, a: y, b: 0 } = x; + | ---- ^^^^ multiple uses of `a` in pattern + | | + | first use of `a` + +error: aborting due to previous error + diff --git a/src/test/ui/error-codes/E0026-teach.rs b/src/test/ui/error-codes/E0026-teach.rs new file mode 100644 index 0000000000000..e0ce44a8b6f5f --- /dev/null +++ b/src/test/ui/error-codes/E0026-teach.rs @@ -0,0 +1,24 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z teach + +struct Thing { + x: u32, + y: u32 +} + +fn main() { + let thing = Thing { x: 0, y: 0 }; + match thing { + Thing { x, y, z } => {} + //~^ ERROR struct `Thing` does not have a field named `z` [E0026] + } +} diff --git a/src/test/ui/error-codes/E0026-teach.stderr b/src/test/ui/error-codes/E0026-teach.stderr new file mode 100644 index 0000000000000..ee83cfb353515 --- /dev/null +++ b/src/test/ui/error-codes/E0026-teach.stderr @@ -0,0 +1,12 @@ +error[E0026]: struct `Thing` does not have a field named `z` + --> $DIR/E0026-teach.rs:21:23 + | +21 | Thing { x, y, z } => {} + | ^ struct `Thing` does not have field `z` + | + = note: This error indicates that a struct pattern attempted to extract a non-existent field from a struct. Struct fields are identified by the name used before the colon : so struct patterns should resemble the declaration of the struct type being matched. + + If you are using shorthand field patterns but want to refer to the struct field by a different name, you should rename it explicitly. + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0026.rs b/src/test/ui/error-codes/E0026.rs similarity index 100% rename from src/test/compile-fail/E0026.rs rename to src/test/ui/error-codes/E0026.rs diff --git a/src/test/ui/error-codes/E0026.stderr b/src/test/ui/error-codes/E0026.stderr new file mode 100644 index 0000000000000..c9819df3f9fbd --- /dev/null +++ b/src/test/ui/error-codes/E0026.stderr @@ -0,0 +1,8 @@ +error[E0026]: struct `Thing` does not have a field named `z` + --> $DIR/E0026.rs:19:23 + | +19 | Thing { x, y, z } => {} + | ^ struct `Thing` does not have field `z` + +error: aborting due to previous error + diff --git a/src/test/ui/error-codes/E0027-teach.rs b/src/test/ui/error-codes/E0027-teach.rs new file mode 100644 index 0000000000000..17e045bb8b086 --- /dev/null +++ b/src/test/ui/error-codes/E0027-teach.rs @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z teach + +struct Dog { + name: String, + age: u32, +} + +fn main() { + let d = Dog { name: "Rusty".to_string(), age: 8 }; + + match d { + Dog { age: x } => {} + //~^ ERROR pattern does not mention field `name` + } +} diff --git a/src/test/ui/error-codes/E0027-teach.stderr b/src/test/ui/error-codes/E0027-teach.stderr new file mode 100644 index 0000000000000..e9f9e4ba766f2 --- /dev/null +++ b/src/test/ui/error-codes/E0027-teach.stderr @@ -0,0 +1,10 @@ +error[E0027]: pattern does not mention field `name` + --> $DIR/E0027-teach.rs:22:9 + | +22 | Dog { age: x } => {} + | ^^^^^^^^^^^^^^ missing field `name` + | + = note: This error indicates that a pattern for a struct fails to specify a sub-pattern for every one of the struct's fields. Ensure that each field from the struct's definition is mentioned in the pattern, or use `..` to ignore unwanted fields. + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0027.rs b/src/test/ui/error-codes/E0027.rs similarity index 100% rename from src/test/compile-fail/E0027.rs rename to src/test/ui/error-codes/E0027.rs diff --git a/src/test/ui/error-codes/E0027.stderr b/src/test/ui/error-codes/E0027.stderr new file mode 100644 index 0000000000000..0f93a776b9ef1 --- /dev/null +++ b/src/test/ui/error-codes/E0027.stderr @@ -0,0 +1,8 @@ +error[E0027]: pattern does not mention field `name` + --> $DIR/E0027.rs:20:9 + | +20 | Dog { age: x } => {} + | ^^^^^^^^^^^^^^ missing field `name` + +error: aborting due to previous error + diff --git a/src/test/ui/error-codes/E0029-teach.rs b/src/test/ui/error-codes/E0029-teach.rs new file mode 100644 index 0000000000000..ca85f58133ccd --- /dev/null +++ b/src/test/ui/error-codes/E0029-teach.rs @@ -0,0 +1,22 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z teach + +fn main() { + let s = "hoho"; + + match s { + "hello" ... "world" => {} + //~^ ERROR only char and numeric types are allowed in range patterns + //~| ERROR non-reference pattern used to match a reference + _ => {} + } +} diff --git a/src/test/ui/error-codes/E0029-teach.stderr b/src/test/ui/error-codes/E0029-teach.stderr new file mode 100644 index 0000000000000..dbb8d972f5c22 --- /dev/null +++ b/src/test/ui/error-codes/E0029-teach.stderr @@ -0,0 +1,20 @@ +error[E0658]: non-reference pattern used to match a reference (see issue #42640) + --> $DIR/E0029-teach.rs:17:9 + | +17 | "hello" ... "world" => {} + | ^^^^^^^^^^^^^^^^^^^ help: consider using a reference: `&"hello" ... "world"` + | + = help: add #![feature(match_default_bindings)] to the crate attributes to enable + +error[E0029]: only char and numeric types are allowed in range patterns + --> $DIR/E0029-teach.rs:17:9 + | +17 | "hello" ... "world" => {} + | ^^^^^^^^^^^^^^^^^^^ ranges require char or numeric types + | + = note: start type: &'static str + = note: end type: &'static str + = note: In a match expression, only numbers and characters can be matched against a range. This is because the compiler checks that the range is non-empty at compile-time, and is unable to evaluate arbitrary comparison functions. If you want to capture values of an orderable type between two end-points, you can use a guard. + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0029.rs b/src/test/ui/error-codes/E0029.rs similarity index 100% rename from src/test/compile-fail/E0029.rs rename to src/test/ui/error-codes/E0029.rs diff --git a/src/test/ui/error-codes/E0029.stderr b/src/test/ui/error-codes/E0029.stderr new file mode 100644 index 0000000000000..02fbd20386f2d --- /dev/null +++ b/src/test/ui/error-codes/E0029.stderr @@ -0,0 +1,19 @@ +error[E0658]: non-reference pattern used to match a reference (see issue #42640) + --> $DIR/E0029.rs:15:9 + | +15 | "hello" ... "world" => {} + | ^^^^^^^^^^^^^^^^^^^ help: consider using a reference: `&"hello" ... "world"` + | + = help: add #![feature(match_default_bindings)] to the crate attributes to enable + +error[E0029]: only char and numeric types are allowed in range patterns + --> $DIR/E0029.rs:15:9 + | +15 | "hello" ... "world" => {} + | ^^^^^^^^^^^^^^^^^^^ ranges require char or numeric types + | + = note: start type: &'static str + = note: end type: &'static str + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/error-codes/E0030-teach.rs b/src/test/ui/error-codes/E0030-teach.rs new file mode 100644 index 0000000000000..2af32eda62be9 --- /dev/null +++ b/src/test/ui/error-codes/E0030-teach.rs @@ -0,0 +1,18 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z teach + +fn main() { + match 5u32 { + 1000 ... 5 => {} + //~^ ERROR lower range bound must be less than or equal to upper + } +} diff --git a/src/test/ui/error-codes/E0030-teach.stderr b/src/test/ui/error-codes/E0030-teach.stderr new file mode 100644 index 0000000000000..40b3d790e1245 --- /dev/null +++ b/src/test/ui/error-codes/E0030-teach.stderr @@ -0,0 +1,10 @@ +error[E0030]: lower range bound must be less than or equal to upper + --> $DIR/E0030-teach.rs:15:9 + | +15 | 1000 ... 5 => {} + | ^^^^ lower bound larger than upper bound + | + = note: When matching against a range, the compiler verifies that the range is non-empty. Range patterns include both end-points, so this is equivalent to requiring the start of the range to be less than or equal to the end of the range. + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0030.rs b/src/test/ui/error-codes/E0030.rs similarity index 100% rename from src/test/compile-fail/E0030.rs rename to src/test/ui/error-codes/E0030.rs diff --git a/src/test/ui/error-codes/E0030.stderr b/src/test/ui/error-codes/E0030.stderr new file mode 100644 index 0000000000000..7bdecd0028e74 --- /dev/null +++ b/src/test/ui/error-codes/E0030.stderr @@ -0,0 +1,8 @@ +error[E0030]: lower range bound must be less than or equal to upper + --> $DIR/E0030.rs:14:9 + | +14 | 1000 ... 5 => {} + | ^^^^ lower bound larger than upper bound + +error: aborting due to previous error + diff --git a/src/test/ui/error-codes/E0033-teach.rs b/src/test/ui/error-codes/E0033-teach.rs new file mode 100644 index 0000000000000..51a1390bf79d1 --- /dev/null +++ b/src/test/ui/error-codes/E0033-teach.rs @@ -0,0 +1,25 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// compile-flags: -Z teach + +trait SomeTrait { + fn foo(); +} + +fn main() { + let trait_obj: &SomeTrait = SomeTrait; + //~^ ERROR expected value, found trait `SomeTrait` + //~| ERROR E0038 + //~| method `foo` has no receiver + + let &invalid = trait_obj; + //~^ ERROR E0033 +} diff --git a/src/test/ui/error-codes/E0033-teach.stderr b/src/test/ui/error-codes/E0033-teach.stderr new file mode 100644 index 0000000000000..ea60fcb6ccf1c --- /dev/null +++ b/src/test/ui/error-codes/E0033-teach.stderr @@ -0,0 +1,26 @@ +error[E0423]: expected value, found trait `SomeTrait` + --> $DIR/E0033-teach.rs:18:33 + | +18 | let trait_obj: &SomeTrait = SomeTrait; + | ^^^^^^^^^ not a value + +error[E0038]: the trait `SomeTrait` cannot be made into an object + --> $DIR/E0033-teach.rs:18:20 + | +18 | let trait_obj: &SomeTrait = SomeTrait; + | ^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object + | + = note: method `foo` has no receiver + +error[E0033]: type `&SomeTrait` cannot be dereferenced + --> $DIR/E0033-teach.rs:23:9 + | +23 | let &invalid = trait_obj; + | ^^^^^^^^ type `&SomeTrait` cannot be dereferenced + | + = note: This error indicates that a pointer to a trait type cannot be implicitly dereferenced by a pattern. Every trait defines a type, but because the size of trait implementors isn't fixed, this type has no compile-time size. Therefore, all accesses to trait types must be through pointers. If you encounter this error you should try to avoid dereferencing the pointer. + + You can read more about trait objects in the Trait Objects section of the Reference: https://doc.rust-lang.org/reference/types.html#trait-objects + +error: aborting due to 3 previous errors + diff --git a/src/test/compile-fail/E0033.rs b/src/test/ui/error-codes/E0033.rs similarity index 100% rename from src/test/compile-fail/E0033.rs rename to src/test/ui/error-codes/E0033.rs diff --git a/src/test/ui/error-codes/E0033.stderr b/src/test/ui/error-codes/E0033.stderr new file mode 100644 index 0000000000000..abc535ee2a647 --- /dev/null +++ b/src/test/ui/error-codes/E0033.stderr @@ -0,0 +1,22 @@ +error[E0423]: expected value, found trait `SomeTrait` + --> $DIR/E0033.rs:16:33 + | +16 | let trait_obj: &SomeTrait = SomeTrait; + | ^^^^^^^^^ not a value + +error[E0038]: the trait `SomeTrait` cannot be made into an object + --> $DIR/E0033.rs:16:20 + | +16 | let trait_obj: &SomeTrait = SomeTrait; + | ^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object + | + = note: method `foo` has no receiver + +error[E0033]: type `&SomeTrait` cannot be dereferenced + --> $DIR/E0033.rs:21:9 + | +21 | let &invalid = trait_obj; + | ^^^^^^^^ type `&SomeTrait` cannot be dereferenced + +error: aborting due to 3 previous errors + diff --git a/src/test/compile-fail/E0034.rs b/src/test/ui/error-codes/E0034.rs similarity index 100% rename from src/test/compile-fail/E0034.rs rename to src/test/ui/error-codes/E0034.rs diff --git a/src/test/ui/error-codes/E0034.stderr b/src/test/ui/error-codes/E0034.stderr new file mode 100644 index 0000000000000..238fd0d67a080 --- /dev/null +++ b/src/test/ui/error-codes/E0034.stderr @@ -0,0 +1,19 @@ +error[E0034]: multiple applicable items in scope + --> $DIR/E0034.rs:30:5 + | +30 | Test::foo() //~ ERROR multiple applicable items in scope + | ^^^^^^^^^ multiple `foo` found + | +note: candidate #1 is defined in an impl of the trait `Trait1` for the type `Test` + --> $DIR/E0034.rs:22:5 + | +22 | fn foo() {} + | ^^^^^^^^ +note: candidate #2 is defined in an impl of the trait `Trait2` for the type `Test` + --> $DIR/E0034.rs:26:5 + | +26 | fn foo() {} + | ^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0038.rs b/src/test/ui/error-codes/E0038.rs similarity index 100% rename from src/test/compile-fail/E0038.rs rename to src/test/ui/error-codes/E0038.rs diff --git a/src/test/ui/error-codes/E0038.stderr b/src/test/ui/error-codes/E0038.stderr new file mode 100644 index 0000000000000..e9423561f3775 --- /dev/null +++ b/src/test/ui/error-codes/E0038.stderr @@ -0,0 +1,10 @@ +error[E0038]: the trait `Trait` cannot be made into an object + --> $DIR/E0038.rs:15:1 + | +15 | fn call_foo(x: Box) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` cannot be made into an object + | + = note: method `foo` references the `Self` type in its arguments or return type + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0040.rs b/src/test/ui/error-codes/E0040.rs similarity index 100% rename from src/test/compile-fail/E0040.rs rename to src/test/ui/error-codes/E0040.rs diff --git a/src/test/ui/error-codes/E0040.stderr b/src/test/ui/error-codes/E0040.stderr new file mode 100644 index 0000000000000..73cb49fbf9878 --- /dev/null +++ b/src/test/ui/error-codes/E0040.stderr @@ -0,0 +1,8 @@ +error[E0040]: explicit use of destructor method + --> $DIR/E0040.rs:23:7 + | +23 | x.drop(); + | ^^^^ explicit destructor calls not allowed + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0044.rs b/src/test/ui/error-codes/E0044.rs similarity index 100% rename from src/test/compile-fail/E0044.rs rename to src/test/ui/error-codes/E0044.rs diff --git a/src/test/ui/error-codes/E0044.stderr b/src/test/ui/error-codes/E0044.stderr new file mode 100644 index 0000000000000..65a429c1fcacd --- /dev/null +++ b/src/test/ui/error-codes/E0044.stderr @@ -0,0 +1,14 @@ +error[E0044]: foreign items may not have type parameters + --> $DIR/E0044.rs:11:10 + | +11 | extern { fn some_func(x: T); } //~ ERROR E0044 + | ^^^^^^^^^^^^^^^^^^^^^^ + | +help: consider using specialization instead of type parameters + --> $DIR/E0044.rs:11:10 + | +11 | extern { fn some_func(x: T); } //~ ERROR E0044 + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0045.rs b/src/test/ui/error-codes/E0045.rs similarity index 100% rename from src/test/compile-fail/E0045.rs rename to src/test/ui/error-codes/E0045.rs diff --git a/src/test/ui/error-codes/E0045.stderr b/src/test/ui/error-codes/E0045.stderr new file mode 100644 index 0000000000000..cd400564669f5 --- /dev/null +++ b/src/test/ui/error-codes/E0045.stderr @@ -0,0 +1,8 @@ +error[E0045]: variadic function must have C or cdecl calling convention + --> $DIR/E0045.rs:11:17 + | +11 | extern "Rust" { fn foo(x: u8, ...); } //~ ERROR E0045 + | ^^^^^^^^^^^^^^^^^^^ variadics require C or cdecl calling convention + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0049.rs b/src/test/ui/error-codes/E0049.rs similarity index 100% rename from src/test/compile-fail/E0049.rs rename to src/test/ui/error-codes/E0049.rs diff --git a/src/test/ui/error-codes/E0049.stderr b/src/test/ui/error-codes/E0049.stderr new file mode 100644 index 0000000000000..e6f72bab50ad4 --- /dev/null +++ b/src/test/ui/error-codes/E0049.stderr @@ -0,0 +1,11 @@ +error[E0049]: method `foo` has 0 type parameters but its trait declaration has 1 type parameter + --> $DIR/E0049.rs:18:5 + | +12 | fn foo(x: T) -> Self; + | --------------------------------- expected 1 type parameter +... +18 | fn foo(x: bool) -> Self { Bar } //~ ERROR E0049 + | ^^^^^^^^^^^^^^^^^^^^^^^ found 0 type parameters + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0050.rs b/src/test/ui/error-codes/E0050.rs similarity index 100% rename from src/test/compile-fail/E0050.rs rename to src/test/ui/error-codes/E0050.rs diff --git a/src/test/ui/error-codes/E0050.stderr b/src/test/ui/error-codes/E0050.stderr new file mode 100644 index 0000000000000..d95a2005b1876 --- /dev/null +++ b/src/test/ui/error-codes/E0050.stderr @@ -0,0 +1,29 @@ +error[E0050]: method `foo` has 1 parameter but the declaration in trait `Foo::foo` has 2 + --> $DIR/E0050.rs:20:12 + | +12 | fn foo(&self, x: u8) -> bool; + | -- trait requires 2 parameters +... +20 | fn foo(&self) -> bool { true } //~ ERROR E0050 + | ^^^^^ expected 2 parameters, found 1 + +error[E0050]: method `bar` has 1 parameter but the declaration in trait `Foo::bar` has 4 + --> $DIR/E0050.rs:21:12 + | +13 | fn bar(&self, x: u8, y: u8, z: u8); + | -- trait requires 4 parameters +... +21 | fn bar(&self) { } //~ ERROR E0050 + | ^^^^^ expected 4 parameters, found 1 + +error[E0050]: method `less` has 4 parameters but the declaration in trait `Foo::less` has 1 + --> $DIR/E0050.rs:22:37 + | +14 | fn less(&self); + | ----- trait requires 1 parameter +... +22 | fn less(&self, x: u8, y: u8, z: u8) { } //~ ERROR E0050 + | ^^ expected 1 parameter, found 4 + +error: aborting due to 3 previous errors + diff --git a/src/test/compile-fail/E0054.rs b/src/test/ui/error-codes/E0054.rs similarity index 100% rename from src/test/compile-fail/E0054.rs rename to src/test/ui/error-codes/E0054.rs diff --git a/src/test/ui/error-codes/E0054.stderr b/src/test/ui/error-codes/E0054.stderr new file mode 100644 index 0000000000000..fc331579ef5f5 --- /dev/null +++ b/src/test/ui/error-codes/E0054.stderr @@ -0,0 +1,10 @@ +error[E0054]: cannot cast as `bool` + --> $DIR/E0054.rs:13:24 + | +13 | let x_is_nonzero = x as bool; //~ ERROR E0054 + | ^^^^^^^^^ unsupported cast + | + = help: compare with zero instead + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0055.rs b/src/test/ui/error-codes/E0055.rs similarity index 100% rename from src/test/compile-fail/E0055.rs rename to src/test/ui/error-codes/E0055.rs diff --git a/src/test/ui/error-codes/E0055.stderr b/src/test/ui/error-codes/E0055.stderr new file mode 100644 index 0000000000000..001178e97c065 --- /dev/null +++ b/src/test/ui/error-codes/E0055.stderr @@ -0,0 +1,10 @@ +error[E0055]: reached the recursion limit while auto-dereferencing Foo + --> $DIR/E0055.rs:21:13 + | +21 | ref_foo.foo(); + | ^^^ deref recursion limit reached + | + = help: consider adding a `#![recursion_limit="4"]` attribute to your crate + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0057.rs b/src/test/ui/error-codes/E0057.rs similarity index 100% rename from src/test/compile-fail/E0057.rs rename to src/test/ui/error-codes/E0057.rs diff --git a/src/test/ui/error-codes/E0057.stderr b/src/test/ui/error-codes/E0057.stderr new file mode 100644 index 0000000000000..450c87ca0322b --- /dev/null +++ b/src/test/ui/error-codes/E0057.stderr @@ -0,0 +1,14 @@ +error[E0057]: this function takes 1 parameter but 0 parameters were supplied + --> $DIR/E0057.rs:13:13 + | +13 | let a = f(); //~ ERROR E0057 + | ^^^ expected 1 parameter + +error[E0057]: this function takes 1 parameter but 2 parameters were supplied + --> $DIR/E0057.rs:15:13 + | +15 | let c = f(2, 3); //~ ERROR E0057 + | ^^^^^^^ expected 1 parameter + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0059.rs b/src/test/ui/error-codes/E0059.rs similarity index 100% rename from src/test/compile-fail/E0059.rs rename to src/test/ui/error-codes/E0059.rs diff --git a/src/test/ui/error-codes/E0059.stderr b/src/test/ui/error-codes/E0059.stderr new file mode 100644 index 0000000000000..aca4b8881e28f --- /dev/null +++ b/src/test/ui/error-codes/E0059.stderr @@ -0,0 +1,8 @@ +error[E0059]: cannot use call notation; the first type parameter for the function trait is neither a tuple nor unit + --> $DIR/E0059.rs:13:41 + | +13 | fn foo>(f: F) -> F::Output { f(3) } //~ ERROR E0059 + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0060.rs b/src/test/ui/error-codes/E0060.rs similarity index 100% rename from src/test/compile-fail/E0060.rs rename to src/test/ui/error-codes/E0060.rs diff --git a/src/test/ui/error-codes/E0060.stderr b/src/test/ui/error-codes/E0060.stderr new file mode 100644 index 0000000000000..8207220ba72c5 --- /dev/null +++ b/src/test/ui/error-codes/E0060.stderr @@ -0,0 +1,11 @@ +error[E0060]: this function takes at least 1 parameter but 0 parameters were supplied + --> $DIR/E0060.rs:16:14 + | +12 | fn printf(_: *const u8, ...) -> u32; + | ------------------------------------ defined here +... +16 | unsafe { printf(); } + | ^^^^^^^^ expected at least 1 parameter + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0061.rs b/src/test/ui/error-codes/E0061.rs similarity index 100% rename from src/test/compile-fail/E0061.rs rename to src/test/ui/error-codes/E0061.rs diff --git a/src/test/ui/error-codes/E0061.stderr b/src/test/ui/error-codes/E0061.stderr new file mode 100644 index 0000000000000..89d81b5acd76c --- /dev/null +++ b/src/test/ui/error-codes/E0061.stderr @@ -0,0 +1,20 @@ +error[E0061]: this function takes 2 parameters but 1 parameter was supplied + --> $DIR/E0061.rs:16:5 + | +11 | fn f(a: u16, b: &str) {} + | --------------------- defined here +... +16 | f(0); + | ^^^^ expected 2 parameters + +error[E0061]: this function takes 1 parameter but 0 parameters were supplied + --> $DIR/E0061.rs:20:5 + | +13 | fn f2(a: u16) {} + | ------------- defined here +... +20 | f2(); + | ^^^^ expected 1 parameter + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0062.rs b/src/test/ui/error-codes/E0062.rs similarity index 100% rename from src/test/compile-fail/E0062.rs rename to src/test/ui/error-codes/E0062.rs diff --git a/src/test/ui/error-codes/E0062.stderr b/src/test/ui/error-codes/E0062.stderr new file mode 100644 index 0000000000000..6c5ecf48045b1 --- /dev/null +++ b/src/test/ui/error-codes/E0062.stderr @@ -0,0 +1,10 @@ +error[E0062]: field `x` specified more than once + --> $DIR/E0062.rs:18:9 + | +17 | x: 0, + | ---- first use of `x` +18 | x: 0, + | ^^ used more than once + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0063.rs b/src/test/ui/error-codes/E0063.rs similarity index 100% rename from src/test/compile-fail/E0063.rs rename to src/test/ui/error-codes/E0063.rs diff --git a/src/test/ui/error-codes/E0063.stderr b/src/test/ui/error-codes/E0063.stderr new file mode 100644 index 0000000000000..023819cc778d0 --- /dev/null +++ b/src/test/ui/error-codes/E0063.stderr @@ -0,0 +1,26 @@ +error[E0063]: missing field `x` in initializer of `SingleFoo` + --> $DIR/E0063.rs:42:13 + | +42 | let w = SingleFoo { }; + | ^^^^^^^^^ missing `x` + +error[E0063]: missing fields `y`, `z` in initializer of `PluralFoo` + --> $DIR/E0063.rs:44:13 + | +44 | let x = PluralFoo {x: 1}; + | ^^^^^^^^^ missing `y`, `z` + +error[E0063]: missing fields `a`, `b`, `y` and 1 other field in initializer of `TruncatedFoo` + --> $DIR/E0063.rs:46:13 + | +46 | let y = TruncatedFoo{x:1}; + | ^^^^^^^^^^^^ missing `a`, `b`, `y` and 1 other field + +error[E0063]: missing fields `a`, `b`, `c` and 2 other fields in initializer of `TruncatedPluralFoo` + --> $DIR/E0063.rs:48:13 + | +48 | let z = TruncatedPluralFoo{x:1}; + | ^^^^^^^^^^^^^^^^^^ missing `a`, `b`, `c` and 2 other fields + +error: aborting due to 4 previous errors + diff --git a/src/test/compile-fail/E0067.rs b/src/test/ui/error-codes/E0067.rs similarity index 100% rename from src/test/compile-fail/E0067.rs rename to src/test/ui/error-codes/E0067.rs diff --git a/src/test/ui/error-codes/E0067.stderr b/src/test/ui/error-codes/E0067.stderr new file mode 100644 index 0000000000000..a4e15619e8ba8 --- /dev/null +++ b/src/test/ui/error-codes/E0067.stderr @@ -0,0 +1,16 @@ +error[E0368]: binary assignment operation `+=` cannot be applied to type `std::collections::LinkedList<_>` + --> $DIR/E0067.rs:14:5 + | +14 | LinkedList::new() += 1; //~ ERROR E0368 + | -----------------^^^^^ + | | + | cannot use `+=` on type `std::collections::LinkedList<_>` + +error[E0067]: invalid left-hand side expression + --> $DIR/E0067.rs:14:5 + | +14 | LinkedList::new() += 1; //~ ERROR E0368 + | ^^^^^^^^^^^^^^^^^ invalid expression for left-hand side + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0069.rs b/src/test/ui/error-codes/E0069.rs similarity index 100% rename from src/test/compile-fail/E0069.rs rename to src/test/ui/error-codes/E0069.rs diff --git a/src/test/ui/error-codes/E0069.stderr b/src/test/ui/error-codes/E0069.stderr new file mode 100644 index 0000000000000..8424531889f0f --- /dev/null +++ b/src/test/ui/error-codes/E0069.stderr @@ -0,0 +1,8 @@ +error[E0069]: `return;` in a function whose return type is not `()` + --> $DIR/E0069.rs:12:5 + | +12 | return; + | ^^^^^^ return type is not () + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0070.rs b/src/test/ui/error-codes/E0070.rs similarity index 100% rename from src/test/compile-fail/E0070.rs rename to src/test/ui/error-codes/E0070.rs diff --git a/src/test/ui/error-codes/E0070.stderr b/src/test/ui/error-codes/E0070.stderr new file mode 100644 index 0000000000000..e1316e2e1306c --- /dev/null +++ b/src/test/ui/error-codes/E0070.stderr @@ -0,0 +1,29 @@ +error[E0070]: invalid left-hand side expression + --> $DIR/E0070.rs:16:5 + | +16 | SOME_CONST = 14; //~ ERROR E0070 + | ^^^^^^^^^^^^^^^ left-hand of expression not valid + +error[E0070]: invalid left-hand side expression + --> $DIR/E0070.rs:17:5 + | +17 | 1 = 3; //~ ERROR E0070 + | ^^^^^ left-hand of expression not valid + +error[E0308]: mismatched types + --> $DIR/E0070.rs:18:25 + | +18 | some_other_func() = 4; //~ ERROR E0070 + | ^ expected (), found integral variable + | + = note: expected type `()` + found type `{integer}` + +error[E0070]: invalid left-hand side expression + --> $DIR/E0070.rs:18:5 + | +18 | some_other_func() = 4; //~ ERROR E0070 + | ^^^^^^^^^^^^^^^^^^^^^ left-hand of expression not valid + +error: aborting due to 4 previous errors + diff --git a/src/test/compile-fail/E0071.rs b/src/test/ui/error-codes/E0071.rs similarity index 100% rename from src/test/compile-fail/E0071.rs rename to src/test/ui/error-codes/E0071.rs diff --git a/src/test/ui/error-codes/E0071.stderr b/src/test/ui/error-codes/E0071.stderr new file mode 100644 index 0000000000000..020dad3ac9f8e --- /dev/null +++ b/src/test/ui/error-codes/E0071.stderr @@ -0,0 +1,8 @@ +error[E0071]: expected struct, variant or union type, found enum `Foo` + --> $DIR/E0071.rs:15:13 + | +15 | let u = FooAlias { value: 0 }; + | ^^^^^^^^ not a struct + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0075.rs b/src/test/ui/error-codes/E0075.rs similarity index 100% rename from src/test/compile-fail/E0075.rs rename to src/test/ui/error-codes/E0075.rs diff --git a/src/test/ui/error-codes/E0075.stderr b/src/test/ui/error-codes/E0075.stderr new file mode 100644 index 0000000000000..39d27d6f7e462 --- /dev/null +++ b/src/test/ui/error-codes/E0075.stderr @@ -0,0 +1,8 @@ +error[E0075]: SIMD vector cannot be empty + --> $DIR/E0075.rs:14:1 + | +14 | struct Bad; //~ ERROR E0075 + | ^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0076.rs b/src/test/ui/error-codes/E0076.rs similarity index 100% rename from src/test/compile-fail/E0076.rs rename to src/test/ui/error-codes/E0076.rs diff --git a/src/test/ui/error-codes/E0076.stderr b/src/test/ui/error-codes/E0076.stderr new file mode 100644 index 0000000000000..02ce47977c8a2 --- /dev/null +++ b/src/test/ui/error-codes/E0076.stderr @@ -0,0 +1,8 @@ +error[E0076]: SIMD vector should be homogeneous + --> $DIR/E0076.rs:14:1 + | +14 | struct Bad(u16, u32, u32); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ SIMD elements must have the same type + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0077.rs b/src/test/ui/error-codes/E0077.rs similarity index 100% rename from src/test/compile-fail/E0077.rs rename to src/test/ui/error-codes/E0077.rs diff --git a/src/test/ui/error-codes/E0077.stderr b/src/test/ui/error-codes/E0077.stderr new file mode 100644 index 0000000000000..7e7b55f9b7e77 --- /dev/null +++ b/src/test/ui/error-codes/E0077.stderr @@ -0,0 +1,8 @@ +error[E0077]: SIMD vector element type should be machine type + --> $DIR/E0077.rs:14:1 + | +14 | struct Bad(String); //~ ERROR E0077 + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0080.rs b/src/test/ui/error-codes/E0080.rs similarity index 100% rename from src/test/compile-fail/E0080.rs rename to src/test/ui/error-codes/E0080.rs diff --git a/src/test/ui/error-codes/E0080.stderr b/src/test/ui/error-codes/E0080.stderr new file mode 100644 index 0000000000000..2ec2ad31b53bb --- /dev/null +++ b/src/test/ui/error-codes/E0080.stderr @@ -0,0 +1,28 @@ +warning: constant evaluation error: attempt to shift left with overflow + --> $DIR/E0080.rs:12:9 + | +12 | X = (1 << 500), //~ ERROR E0080 + | ^^^^^^^^^^ + | + = note: #[warn(const_err)] on by default + +error[E0080]: constant evaluation error + --> $DIR/E0080.rs:12:9 + | +12 | X = (1 << 500), //~ ERROR E0080 + | ^^^^^^^^^^ attempt to shift left with overflow + +warning: constant evaluation error: attempt to divide by zero + --> $DIR/E0080.rs:14:9 + | +14 | Y = (1 / 0) //~ ERROR E0080 + | ^^^^^^^ + +error[E0080]: constant evaluation error + --> $DIR/E0080.rs:14:9 + | +14 | Y = (1 / 0) //~ ERROR E0080 + | ^^^^^^^ attempt to divide by zero + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0081.rs b/src/test/ui/error-codes/E0081.rs similarity index 100% rename from src/test/compile-fail/E0081.rs rename to src/test/ui/error-codes/E0081.rs diff --git a/src/test/ui/error-codes/E0081.stderr b/src/test/ui/error-codes/E0081.stderr new file mode 100644 index 0000000000000..035638b2f31df --- /dev/null +++ b/src/test/ui/error-codes/E0081.stderr @@ -0,0 +1,10 @@ +error[E0081]: discriminant value `3isize` already exists + --> $DIR/E0081.rs:13:9 + | +12 | P = 3, + | - first use of `3isize` +13 | X = 3, + | ^ enum already has `3isize` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0084.rs b/src/test/ui/error-codes/E0084.rs similarity index 100% rename from src/test/compile-fail/E0084.rs rename to src/test/ui/error-codes/E0084.rs diff --git a/src/test/ui/error-codes/E0084.stderr b/src/test/ui/error-codes/E0084.stderr new file mode 100644 index 0000000000000..b39a129ba162e --- /dev/null +++ b/src/test/ui/error-codes/E0084.stderr @@ -0,0 +1,10 @@ +error[E0084]: unsupported representation for zero-variant enum + --> $DIR/E0084.rs:11:1 + | +11 | #[repr(i32)] //~ ERROR: E0084 + | ^^^^^^^^^^^^ +12 | enum Foo {} + | ----------- zero-variant enum + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0087.rs b/src/test/ui/error-codes/E0087.rs similarity index 100% rename from src/test/compile-fail/E0087.rs rename to src/test/ui/error-codes/E0087.rs diff --git a/src/test/ui/error-codes/E0087.stderr b/src/test/ui/error-codes/E0087.stderr new file mode 100644 index 0000000000000..20c8cd45dfada --- /dev/null +++ b/src/test/ui/error-codes/E0087.stderr @@ -0,0 +1,14 @@ +error[E0087]: too many type parameters provided: expected at most 0 type parameters, found 1 type parameter + --> $DIR/E0087.rs:15:11 + | +15 | foo::(); //~ ERROR expected at most 0 type parameters, found 1 type parameter [E0087] + | ^^^ expected 0 type parameters + +error[E0087]: too many type parameters provided: expected at most 1 type parameter, found 2 type parameters + --> $DIR/E0087.rs:17:16 + | +17 | bar::(); //~ ERROR expected at most 1 type parameter, found 2 type parameters [E0087] + | ^^^ expected 1 type parameter + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0088.rs b/src/test/ui/error-codes/E0088.rs similarity index 100% rename from src/test/compile-fail/E0088.rs rename to src/test/ui/error-codes/E0088.rs diff --git a/src/test/ui/error-codes/E0088.stderr b/src/test/ui/error-codes/E0088.stderr new file mode 100644 index 0000000000000..615df88f1bb2e --- /dev/null +++ b/src/test/ui/error-codes/E0088.stderr @@ -0,0 +1,14 @@ +error[E0088]: too many lifetime parameters provided: expected at most 0 lifetime parameters, found 1 lifetime parameter + --> $DIR/E0088.rs:15:9 + | +15 | f::<'static>(); //~ ERROR E0088 + | ^^^^^^^ expected 0 lifetime parameters + +error[E0088]: too many lifetime parameters provided: expected at most 1 lifetime parameter, found 2 lifetime parameters + --> $DIR/E0088.rs:16:18 + | +16 | g::<'static, 'static>(); //~ ERROR E0088 + | ^^^^^^^ expected 1 lifetime parameter + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0089.rs b/src/test/ui/error-codes/E0089.rs similarity index 100% rename from src/test/compile-fail/E0089.rs rename to src/test/ui/error-codes/E0089.rs diff --git a/src/test/ui/error-codes/E0089.stderr b/src/test/ui/error-codes/E0089.stderr new file mode 100644 index 0000000000000..38b45e27fa796 --- /dev/null +++ b/src/test/ui/error-codes/E0089.stderr @@ -0,0 +1,8 @@ +error[E0089]: too few type parameters provided: expected 2 type parameters, found 1 type parameter + --> $DIR/E0089.rs:14:5 + | +14 | foo::(); //~ ERROR expected 2 type parameters, found 1 type parameter [E0089] + | ^^^^^^^^^^ expected 2 type parameters + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0090.rs b/src/test/ui/error-codes/E0090.rs similarity index 100% rename from src/test/compile-fail/E0090.rs rename to src/test/ui/error-codes/E0090.rs diff --git a/src/test/ui/error-codes/E0090.stderr b/src/test/ui/error-codes/E0090.stderr new file mode 100644 index 0000000000000..050082d84df58 --- /dev/null +++ b/src/test/ui/error-codes/E0090.stderr @@ -0,0 +1,8 @@ +error[E0090]: too few lifetime parameters provided: expected 2 lifetime parameters, found 1 lifetime parameter + --> $DIR/E0090.rs:14:5 + | +14 | foo::<'static>(); //~ ERROR expected 2 lifetime parameters, found 1 lifetime parameter [E0090] + | ^^^^^^^^^^^^^^ expected 2 lifetime parameters + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0091.rs b/src/test/ui/error-codes/E0091.rs similarity index 100% rename from src/test/compile-fail/E0091.rs rename to src/test/ui/error-codes/E0091.rs diff --git a/src/test/ui/error-codes/E0091.stderr b/src/test/ui/error-codes/E0091.stderr new file mode 100644 index 0000000000000..7d951dd6dfd19 --- /dev/null +++ b/src/test/ui/error-codes/E0091.stderr @@ -0,0 +1,14 @@ +error[E0091]: type parameter `T` is unused + --> $DIR/E0091.rs:11:10 + | +11 | type Foo = u32; //~ ERROR E0091 + | ^ unused type parameter + +error[E0091]: type parameter `B` is unused + --> $DIR/E0091.rs:12:14 + | +12 | type Foo2 = Box; //~ ERROR E0091 + | ^ unused type parameter + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0092.rs b/src/test/ui/error-codes/E0092.rs similarity index 100% rename from src/test/compile-fail/E0092.rs rename to src/test/ui/error-codes/E0092.rs diff --git a/src/test/ui/error-codes/E0092.stderr b/src/test/ui/error-codes/E0092.stderr new file mode 100644 index 0000000000000..788f89944110a --- /dev/null +++ b/src/test/ui/error-codes/E0092.stderr @@ -0,0 +1,8 @@ +error[E0092]: unrecognized atomic operation function: `foo` + --> $DIR/E0092.rs:13:5 + | +13 | fn atomic_foo(); //~ ERROR E0092 + | ^^^^^^^^^^^^^^^^ unrecognized atomic operation + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0093.rs b/src/test/ui/error-codes/E0093.rs similarity index 100% rename from src/test/compile-fail/E0093.rs rename to src/test/ui/error-codes/E0093.rs diff --git a/src/test/ui/error-codes/E0093.stderr b/src/test/ui/error-codes/E0093.stderr new file mode 100644 index 0000000000000..959d64af433f5 --- /dev/null +++ b/src/test/ui/error-codes/E0093.stderr @@ -0,0 +1,8 @@ +error[E0093]: unrecognized intrinsic function: `foo` + --> $DIR/E0093.rs:13:5 + | +13 | fn foo(); + | ^^^^^^^^^ unrecognized intrinsic + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0094.rs b/src/test/ui/error-codes/E0094.rs similarity index 100% rename from src/test/compile-fail/E0094.rs rename to src/test/ui/error-codes/E0094.rs diff --git a/src/test/ui/error-codes/E0094.stderr b/src/test/ui/error-codes/E0094.stderr new file mode 100644 index 0000000000000..fdef3d8877bcf --- /dev/null +++ b/src/test/ui/error-codes/E0094.stderr @@ -0,0 +1,8 @@ +error[E0094]: intrinsic has wrong number of type parameters: found 2, expected 1 + --> $DIR/E0094.rs:13:15 + | +13 | fn size_of() -> usize; //~ ERROR E0094 + | ^^^^^^ expected 1 type parameter + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0106.rs b/src/test/ui/error-codes/E0106.rs similarity index 100% rename from src/test/compile-fail/E0106.rs rename to src/test/ui/error-codes/E0106.rs diff --git a/src/test/ui/error-codes/E0106.stderr b/src/test/ui/error-codes/E0106.stderr new file mode 100644 index 0000000000000..98442804708ea --- /dev/null +++ b/src/test/ui/error-codes/E0106.stderr @@ -0,0 +1,32 @@ +error[E0106]: missing lifetime specifier + --> $DIR/E0106.rs:12:8 + | +12 | x: &bool, + | ^ expected lifetime parameter + +error[E0106]: missing lifetime specifier + --> $DIR/E0106.rs:17:7 + | +17 | B(&bool), + | ^ expected lifetime parameter + +error[E0106]: missing lifetime specifier + --> $DIR/E0106.rs:20:14 + | +20 | type MyStr = &str; + | ^ expected lifetime parameter + +error[E0106]: missing lifetime specifier + --> $DIR/E0106.rs:27:10 + | +27 | baz: Baz, + | ^^^ expected lifetime parameter + +error[E0106]: missing lifetime specifiers + --> $DIR/E0106.rs:30:11 + | +30 | buzz: Buzz, + | ^^^^ expected 2 lifetime parameters + +error: aborting due to 5 previous errors + diff --git a/src/test/compile-fail/E0107.rs b/src/test/ui/error-codes/E0107.rs similarity index 100% rename from src/test/compile-fail/E0107.rs rename to src/test/ui/error-codes/E0107.rs diff --git a/src/test/ui/error-codes/E0107.stderr b/src/test/ui/error-codes/E0107.stderr new file mode 100644 index 0000000000000..6283486039c8d --- /dev/null +++ b/src/test/ui/error-codes/E0107.stderr @@ -0,0 +1,20 @@ +error[E0107]: wrong number of lifetime parameters: expected 2, found 1 + --> $DIR/E0107.rs:21:11 + | +21 | buzz: Buzz<'a>, + | ^^^^^^^^ expected 2 lifetime parameters + +error[E0107]: wrong number of lifetime parameters: expected 0, found 1 + --> $DIR/E0107.rs:24:10 + | +24 | bar: Bar<'a>, + | ^^^^^^^ unexpected lifetime parameter + +error[E0107]: wrong number of lifetime parameters: expected 1, found 3 + --> $DIR/E0107.rs:27:11 + | +27 | foo2: Foo<'a, 'b, 'c>, + | ^^^^^^^^^^^^^^^ 2 unexpected lifetime parameters + +error: aborting due to 3 previous errors + diff --git a/src/test/compile-fail/E0109.rs b/src/test/ui/error-codes/E0109.rs similarity index 100% rename from src/test/compile-fail/E0109.rs rename to src/test/ui/error-codes/E0109.rs diff --git a/src/test/ui/error-codes/E0109.stderr b/src/test/ui/error-codes/E0109.stderr new file mode 100644 index 0000000000000..59da11140b1e7 --- /dev/null +++ b/src/test/ui/error-codes/E0109.stderr @@ -0,0 +1,8 @@ +error[E0109]: type parameters are not allowed on this type + --> $DIR/E0109.rs:11:14 + | +11 | type X = u32; //~ ERROR E0109 + | ^^^ type parameter not allowed + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0110.rs b/src/test/ui/error-codes/E0110.rs similarity index 100% rename from src/test/compile-fail/E0110.rs rename to src/test/ui/error-codes/E0110.rs diff --git a/src/test/ui/error-codes/E0110.stderr b/src/test/ui/error-codes/E0110.stderr new file mode 100644 index 0000000000000..7417351c16d2c --- /dev/null +++ b/src/test/ui/error-codes/E0110.stderr @@ -0,0 +1,8 @@ +error[E0110]: lifetime parameters are not allowed on this type + --> $DIR/E0110.rs:11:14 + | +11 | type X = u32<'static>; //~ ERROR E0110 + | ^^^^^^^ lifetime parameter not allowed on this type + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0116.rs b/src/test/ui/error-codes/E0116.rs similarity index 100% rename from src/test/compile-fail/E0116.rs rename to src/test/ui/error-codes/E0116.rs diff --git a/src/test/ui/error-codes/E0116.stderr b/src/test/ui/error-codes/E0116.stderr new file mode 100644 index 0000000000000..c090060e7d67d --- /dev/null +++ b/src/test/ui/error-codes/E0116.stderr @@ -0,0 +1,10 @@ +error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined + --> $DIR/E0116.rs:11:1 + | +11 | impl Vec {} + | ^^^^^^^^^^^^^^^ impl for type defined outside of crate. + | + = note: define and implement a trait or new type instead + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0117.rs b/src/test/ui/error-codes/E0117.rs similarity index 100% rename from src/test/compile-fail/E0117.rs rename to src/test/ui/error-codes/E0117.rs diff --git a/src/test/ui/error-codes/E0117.stderr b/src/test/ui/error-codes/E0117.stderr new file mode 100644 index 0000000000000..9856692659a50 --- /dev/null +++ b/src/test/ui/error-codes/E0117.stderr @@ -0,0 +1,17 @@ +error[E0120]: the Drop trait may only be implemented on structures + --> $DIR/E0117.rs:11:15 + | +11 | impl Drop for u32 {} //~ ERROR E0117 + | ^^^ implementing Drop requires a struct + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/E0117.rs:11:1 + | +11 | impl Drop for u32 {} //~ ERROR E0117 + | ^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0118.rs b/src/test/ui/error-codes/E0118.rs similarity index 100% rename from src/test/compile-fail/E0118.rs rename to src/test/ui/error-codes/E0118.rs diff --git a/src/test/ui/error-codes/E0118.stderr b/src/test/ui/error-codes/E0118.stderr new file mode 100644 index 0000000000000..8c78890b88acc --- /dev/null +++ b/src/test/ui/error-codes/E0118.stderr @@ -0,0 +1,10 @@ +error[E0118]: no base type found for inherent implementation + --> $DIR/E0118.rs:11:6 + | +11 | impl (u8, u8) { //~ ERROR E0118 + | ^^^^^^^^ impl requires a base type + | + = note: either implement a trait on it or create a newtype to wrap it instead + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0119.rs b/src/test/ui/error-codes/E0119.rs similarity index 100% rename from src/test/compile-fail/E0119.rs rename to src/test/ui/error-codes/E0119.rs diff --git a/src/test/ui/error-codes/E0119.stderr b/src/test/ui/error-codes/E0119.stderr new file mode 100644 index 0000000000000..91bb74a10d67d --- /dev/null +++ b/src/test/ui/error-codes/E0119.stderr @@ -0,0 +1,11 @@ +error[E0119]: conflicting implementations of trait `MyTrait` for type `Foo`: + --> $DIR/E0119.rs:23:1 + | +15 | impl MyTrait for T { + | --------------------- first implementation here +... +23 | impl MyTrait for Foo { //~ ERROR E0119 + | ^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Foo` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0120.rs b/src/test/ui/error-codes/E0120.rs similarity index 100% rename from src/test/compile-fail/E0120.rs rename to src/test/ui/error-codes/E0120.rs diff --git a/src/test/ui/error-codes/E0120.stderr b/src/test/ui/error-codes/E0120.stderr new file mode 100644 index 0000000000000..7c666d9fd0a6d --- /dev/null +++ b/src/test/ui/error-codes/E0120.stderr @@ -0,0 +1,8 @@ +error[E0120]: the Drop trait may only be implemented on structures + --> $DIR/E0120.rs:13:15 + | +13 | impl Drop for MyTrait { + | ^^^^^^^ implementing Drop requires a struct + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0121.rs b/src/test/ui/error-codes/E0121.rs similarity index 100% rename from src/test/compile-fail/E0121.rs rename to src/test/ui/error-codes/E0121.rs diff --git a/src/test/ui/error-codes/E0121.stderr b/src/test/ui/error-codes/E0121.stderr new file mode 100644 index 0000000000000..fa54d67856318 --- /dev/null +++ b/src/test/ui/error-codes/E0121.stderr @@ -0,0 +1,14 @@ +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/E0121.rs:11:13 + | +11 | fn foo() -> _ { 5 } //~ ERROR E0121 + | ^ not allowed in type signatures + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/E0121.rs:13:13 + | +13 | static BAR: _ = "test"; //~ ERROR E0121 + | ^ not allowed in type signatures + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0124.rs b/src/test/ui/error-codes/E0124.rs similarity index 100% rename from src/test/compile-fail/E0124.rs rename to src/test/ui/error-codes/E0124.rs diff --git a/src/test/ui/error-codes/E0124.stderr b/src/test/ui/error-codes/E0124.stderr new file mode 100644 index 0000000000000..8e1ec51ea1cb7 --- /dev/null +++ b/src/test/ui/error-codes/E0124.stderr @@ -0,0 +1,10 @@ +error[E0124]: field `field1` is already declared + --> $DIR/E0124.rs:13:5 + | +12 | field1: i32, + | ----------- `field1` first declared here +13 | field1: i32, + | ^^^^^^^^^^^ field already declared + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0128.rs b/src/test/ui/error-codes/E0128.rs similarity index 100% rename from src/test/compile-fail/E0128.rs rename to src/test/ui/error-codes/E0128.rs diff --git a/src/test/ui/error-codes/E0128.stderr b/src/test/ui/error-codes/E0128.stderr new file mode 100644 index 0000000000000..fad2d0db8abdf --- /dev/null +++ b/src/test/ui/error-codes/E0128.stderr @@ -0,0 +1,8 @@ +error[E0128]: type parameters with a default cannot use forward declared identifiers + --> $DIR/E0128.rs:11:14 + | +11 | struct Foo { //~ ERROR E0128 + | ^ defaulted type parameters cannot be forward declared + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0130.rs b/src/test/ui/error-codes/E0130.rs similarity index 100% rename from src/test/compile-fail/E0130.rs rename to src/test/ui/error-codes/E0130.rs diff --git a/src/test/ui/error-codes/E0130.stderr b/src/test/ui/error-codes/E0130.stderr new file mode 100644 index 0000000000000..02aebe0362a13 --- /dev/null +++ b/src/test/ui/error-codes/E0130.stderr @@ -0,0 +1,8 @@ +error[E0130]: patterns aren't allowed in foreign function declarations + --> $DIR/E0130.rs:12:12 + | +12 | fn foo((a, b): (u32, u32)); + | ^^^^^^ pattern not allowed in foreign function + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0131.rs b/src/test/ui/error-codes/E0131.rs similarity index 100% rename from src/test/compile-fail/E0131.rs rename to src/test/ui/error-codes/E0131.rs diff --git a/src/test/ui/error-codes/E0131.stderr b/src/test/ui/error-codes/E0131.stderr new file mode 100644 index 0000000000000..d97e00fb82df1 --- /dev/null +++ b/src/test/ui/error-codes/E0131.stderr @@ -0,0 +1,8 @@ +error[E0131]: main function is not allowed to have type parameters + --> $DIR/E0131.rs:11:8 + | +11 | fn main() { + | ^^^ main cannot have type parameters + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0132.rs b/src/test/ui/error-codes/E0132.rs similarity index 100% rename from src/test/compile-fail/E0132.rs rename to src/test/ui/error-codes/E0132.rs diff --git a/src/test/ui/error-codes/E0132.stderr b/src/test/ui/error-codes/E0132.stderr new file mode 100644 index 0000000000000..5c66d67b907b3 --- /dev/null +++ b/src/test/ui/error-codes/E0132.stderr @@ -0,0 +1,8 @@ +error[E0132]: start function is not allowed to have type parameters + --> $DIR/E0132.rs:14:5 + | +14 | fn f< T >() {} //~ ERROR E0132 + | ^^^^^ start function cannot have type parameters + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0133.rs b/src/test/ui/error-codes/E0133.rs similarity index 100% rename from src/test/compile-fail/E0133.rs rename to src/test/ui/error-codes/E0133.rs diff --git a/src/test/ui/error-codes/E0133.stderr b/src/test/ui/error-codes/E0133.stderr new file mode 100644 index 0000000000000..4d2ebd111ddf6 --- /dev/null +++ b/src/test/ui/error-codes/E0133.stderr @@ -0,0 +1,8 @@ +error[E0133]: call to unsafe function requires unsafe function or block + --> $DIR/E0133.rs:14:5 + | +14 | f(); + | ^^^ call to unsafe function + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0137.rs b/src/test/ui/error-codes/E0137.rs similarity index 100% rename from src/test/compile-fail/E0137.rs rename to src/test/ui/error-codes/E0137.rs diff --git a/src/test/ui/error-codes/E0137.stderr b/src/test/ui/error-codes/E0137.stderr new file mode 100644 index 0000000000000..bc6bbffb18e72 --- /dev/null +++ b/src/test/ui/error-codes/E0137.stderr @@ -0,0 +1,11 @@ +error[E0137]: multiple functions with a #[main] attribute + --> $DIR/E0137.rs:17:1 + | +14 | fn foo() {} + | ----------- first #[main] function +... +17 | fn f() {} + | ^^^^^^^^^ additional #[main] function + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0138.rs b/src/test/ui/error-codes/E0138.rs similarity index 100% rename from src/test/compile-fail/E0138.rs rename to src/test/ui/error-codes/E0138.rs diff --git a/src/test/ui/error-codes/E0138.stderr b/src/test/ui/error-codes/E0138.stderr new file mode 100644 index 0000000000000..cee7cc5d90629 --- /dev/null +++ b/src/test/ui/error-codes/E0138.stderr @@ -0,0 +1,11 @@ +error[E0138]: multiple 'start' functions + --> $DIR/E0138.rs:17:1 + | +14 | fn foo(argc: isize, argv: *const *const u8) -> isize { 0 } + | ---------------------------------------------------------- previous `start` function here +... +17 | fn f(argc: isize, argv: *const *const u8) -> isize { 0 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ multiple `start` functions + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0152.rs b/src/test/ui/error-codes/E0152.rs similarity index 100% rename from src/test/compile-fail/E0152.rs rename to src/test/ui/error-codes/E0152.rs diff --git a/src/test/ui/error-codes/E0152.stderr b/src/test/ui/error-codes/E0152.stderr new file mode 100644 index 0000000000000..a1d5597f031f6 --- /dev/null +++ b/src/test/ui/error-codes/E0152.stderr @@ -0,0 +1,10 @@ +error[E0152]: duplicate lang item found: `panic_fmt`. + --> $DIR/E0152.rs:14:1 + | +14 | struct Foo; //~ ERROR E0152 + | ^^^^^^^^^^^ + | + = note: first defined in crate `std`. + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0161.rs b/src/test/ui/error-codes/E0161.rs similarity index 100% rename from src/test/compile-fail/E0161.rs rename to src/test/ui/error-codes/E0161.rs diff --git a/src/test/ui/error-codes/E0161.stderr b/src/test/ui/error-codes/E0161.stderr new file mode 100644 index 0000000000000..9914fdd2d6155 --- /dev/null +++ b/src/test/ui/error-codes/E0161.stderr @@ -0,0 +1,14 @@ +error[E0161]: cannot move a value of type str: the size of str cannot be statically determined + --> $DIR/E0161.rs:14:28 + | +14 | let _x: Box = box *"hello"; //~ ERROR E0161 + | ^^^^^^^^ + +error[E0507]: cannot move out of borrowed content + --> $DIR/E0161.rs:14:28 + | +14 | let _x: Box = box *"hello"; //~ ERROR E0161 + | ^^^^^^^^ cannot move out of borrowed content + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0162.rs b/src/test/ui/error-codes/E0162.rs similarity index 100% rename from src/test/compile-fail/E0162.rs rename to src/test/ui/error-codes/E0162.rs diff --git a/src/test/ui/error-codes/E0162.stderr b/src/test/ui/error-codes/E0162.stderr new file mode 100644 index 0000000000000..318a023d30213 --- /dev/null +++ b/src/test/ui/error-codes/E0162.stderr @@ -0,0 +1,8 @@ +error[E0162]: irrefutable if-let pattern + --> $DIR/E0162.rs:15:12 + | +15 | if let Irrefutable(x) = irr { //~ ERROR E0162 + | ^^^^^^^^^^^^^^ irrefutable pattern + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0164.rs b/src/test/ui/error-codes/E0164.rs similarity index 100% rename from src/test/compile-fail/E0164.rs rename to src/test/ui/error-codes/E0164.rs diff --git a/src/test/ui/error-codes/E0164.stderr b/src/test/ui/error-codes/E0164.stderr new file mode 100644 index 0000000000000..a515c83d14b2d --- /dev/null +++ b/src/test/ui/error-codes/E0164.stderr @@ -0,0 +1,8 @@ +error[E0164]: expected tuple struct/variant, found associated constant `::B` + --> $DIR/E0164.rs:20:9 + | +20 | Foo::B(i) => i, //~ ERROR E0164 + | ^^^^^^^^^ not a tuple variant or struct + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0165.rs b/src/test/ui/error-codes/E0165.rs similarity index 100% rename from src/test/compile-fail/E0165.rs rename to src/test/ui/error-codes/E0165.rs diff --git a/src/test/ui/error-codes/E0165.stderr b/src/test/ui/error-codes/E0165.stderr new file mode 100644 index 0000000000000..3c90f19a0dc7c --- /dev/null +++ b/src/test/ui/error-codes/E0165.stderr @@ -0,0 +1,8 @@ +error[E0165]: irrefutable while-let pattern + --> $DIR/E0165.rs:15:15 + | +15 | while let Irrefutable(x) = irr { //~ ERROR E0165 + | ^^^^^^^^^^^^^^ irrefutable pattern + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0184.rs b/src/test/ui/error-codes/E0184.rs similarity index 100% rename from src/test/compile-fail/E0184.rs rename to src/test/ui/error-codes/E0184.rs diff --git a/src/test/ui/error-codes/E0184.stderr b/src/test/ui/error-codes/E0184.stderr new file mode 100644 index 0000000000000..53bda3bb57591 --- /dev/null +++ b/src/test/ui/error-codes/E0184.stderr @@ -0,0 +1,8 @@ +error[E0184]: the trait `Copy` may not be implemented for this type; the type has a destructor + --> $DIR/E0184.rs:11:10 + | +11 | #[derive(Copy)] //~ ERROR E0184 + | ^^^^ Copy not allowed on types with destructors + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0185.rs b/src/test/ui/error-codes/E0185.rs similarity index 100% rename from src/test/compile-fail/E0185.rs rename to src/test/ui/error-codes/E0185.rs diff --git a/src/test/ui/error-codes/E0185.stderr b/src/test/ui/error-codes/E0185.stderr new file mode 100644 index 0000000000000..0d24a3712d558 --- /dev/null +++ b/src/test/ui/error-codes/E0185.stderr @@ -0,0 +1,11 @@ +error[E0185]: method `foo` has a `&self` declaration in the impl, but not in the trait + --> $DIR/E0185.rs:19:5 + | +12 | fn foo(); + | --------- trait method declared without `&self` +... +19 | fn foo(&self) {} + | ^^^^^^^^^^^^^ `&self` used in impl + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0186.rs b/src/test/ui/error-codes/E0186.rs similarity index 100% rename from src/test/compile-fail/E0186.rs rename to src/test/ui/error-codes/E0186.rs diff --git a/src/test/ui/error-codes/E0186.stderr b/src/test/ui/error-codes/E0186.stderr new file mode 100644 index 0000000000000..598057db3a662 --- /dev/null +++ b/src/test/ui/error-codes/E0186.stderr @@ -0,0 +1,11 @@ +error[E0186]: method `foo` has a `&self` declaration in the trait, but not in the impl + --> $DIR/E0186.rs:18:5 + | +12 | fn foo(&self); //~ `&self` used in trait + | -------------- `&self` used in trait +... +18 | fn foo() {} //~ ERROR E0186 + | ^^^^^^^^ expected `&self` in impl + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0191.rs b/src/test/ui/error-codes/E0191.rs similarity index 100% rename from src/test/compile-fail/E0191.rs rename to src/test/ui/error-codes/E0191.rs diff --git a/src/test/ui/error-codes/E0191.stderr b/src/test/ui/error-codes/E0191.stderr new file mode 100644 index 0000000000000..8f99a6ecffb99 --- /dev/null +++ b/src/test/ui/error-codes/E0191.stderr @@ -0,0 +1,8 @@ +error[E0191]: the value of the associated type `Bar` (from the trait `Trait`) must be specified + --> $DIR/E0191.rs:15:12 + | +15 | type Foo = Trait; //~ ERROR E0191 + | ^^^^^ missing associated type `Bar` value + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0192.rs b/src/test/ui/error-codes/E0192.rs similarity index 100% rename from src/test/compile-fail/E0192.rs rename to src/test/ui/error-codes/E0192.rs diff --git a/src/test/ui/error-codes/E0192.stderr b/src/test/ui/error-codes/E0192.stderr new file mode 100644 index 0000000000000..b592c87efa7a0 --- /dev/null +++ b/src/test/ui/error-codes/E0192.stderr @@ -0,0 +1,8 @@ +error[E0192]: negative impls are only allowed for auto traits (e.g., `Send` and `Sync`) + --> $DIR/E0192.rs:19:1 + | +19 | impl !Trait for Foo { } //~ ERROR E0192 + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0194.rs b/src/test/ui/error-codes/E0194.rs similarity index 100% rename from src/test/compile-fail/E0194.rs rename to src/test/ui/error-codes/E0194.rs diff --git a/src/test/ui/error-codes/E0194.stderr b/src/test/ui/error-codes/E0194.stderr new file mode 100644 index 0000000000000..360e8c08a3c97 --- /dev/null +++ b/src/test/ui/error-codes/E0194.stderr @@ -0,0 +1,11 @@ +error[E0194]: type parameter `T` shadows another type parameter of the same name + --> $DIR/E0194.rs:13:26 + | +11 | trait Foo { + | - first `T` declared here +12 | fn do_something(&self) -> T; +13 | fn do_something_else(&self, bar: T); + | ^ shadows another type parameter + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0195.rs b/src/test/ui/error-codes/E0195.rs similarity index 100% rename from src/test/compile-fail/E0195.rs rename to src/test/ui/error-codes/E0195.rs diff --git a/src/test/ui/error-codes/E0195.stderr b/src/test/ui/error-codes/E0195.stderr new file mode 100644 index 0000000000000..3cce3d0799416 --- /dev/null +++ b/src/test/ui/error-codes/E0195.stderr @@ -0,0 +1,11 @@ +error[E0195]: lifetime parameters or bounds on method `bar` do not match the trait declaration + --> $DIR/E0195.rs:19:5 + | +12 | fn bar<'a,'b:'a>(x: &'a str, y: &'b str); + | ----------------------------------------- lifetimes in impl do not match this method in trait +... +19 | fn bar<'a,'b>(x: &'a str, y: &'b str) { //~ ERROR E0195 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetimes do not match method in trait + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0197.rs b/src/test/ui/error-codes/E0197.rs similarity index 100% rename from src/test/compile-fail/E0197.rs rename to src/test/ui/error-codes/E0197.rs diff --git a/src/test/ui/error-codes/E0197.stderr b/src/test/ui/error-codes/E0197.stderr new file mode 100644 index 0000000000000..277f523e497aa --- /dev/null +++ b/src/test/ui/error-codes/E0197.stderr @@ -0,0 +1,8 @@ +error[E0197]: inherent impls cannot be unsafe + --> $DIR/E0197.rs:13:1 + | +13 | unsafe impl Foo { } //~ ERROR E0197 + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0198.rs b/src/test/ui/error-codes/E0198.rs similarity index 100% rename from src/test/compile-fail/E0198.rs rename to src/test/ui/error-codes/E0198.rs diff --git a/src/test/ui/error-codes/E0198.stderr b/src/test/ui/error-codes/E0198.stderr new file mode 100644 index 0000000000000..a85419e9a1397 --- /dev/null +++ b/src/test/ui/error-codes/E0198.stderr @@ -0,0 +1,8 @@ +error[E0198]: negative impls cannot be unsafe + --> $DIR/E0198.rs:15:1 + | +15 | unsafe impl !Send for Foo { } //~ ERROR E0198 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0199.rs b/src/test/ui/error-codes/E0199.rs similarity index 100% rename from src/test/compile-fail/E0199.rs rename to src/test/ui/error-codes/E0199.rs diff --git a/src/test/ui/error-codes/E0199.stderr b/src/test/ui/error-codes/E0199.stderr new file mode 100644 index 0000000000000..efbe066e52e7e --- /dev/null +++ b/src/test/ui/error-codes/E0199.stderr @@ -0,0 +1,8 @@ +error[E0199]: implementing the trait `Bar` is not unsafe + --> $DIR/E0199.rs:16:1 + | +16 | unsafe impl Bar for Foo { } //~ ERROR implementing the trait `Bar` is not unsafe [E0199] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0200.rs b/src/test/ui/error-codes/E0200.rs similarity index 100% rename from src/test/compile-fail/E0200.rs rename to src/test/ui/error-codes/E0200.rs diff --git a/src/test/ui/error-codes/E0200.stderr b/src/test/ui/error-codes/E0200.stderr new file mode 100644 index 0000000000000..fb71da23677bd --- /dev/null +++ b/src/test/ui/error-codes/E0200.stderr @@ -0,0 +1,8 @@ +error[E0200]: the trait `Bar` requires an `unsafe impl` declaration + --> $DIR/E0200.rs:15:1 + | +15 | impl Bar for Foo { } //~ ERROR E0200 + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0201.rs b/src/test/ui/error-codes/E0201.rs similarity index 100% rename from src/test/compile-fail/E0201.rs rename to src/test/ui/error-codes/E0201.rs diff --git a/src/test/ui/error-codes/E0201.stderr b/src/test/ui/error-codes/E0201.stderr new file mode 100644 index 0000000000000..01dbee6e09236 --- /dev/null +++ b/src/test/ui/error-codes/E0201.stderr @@ -0,0 +1,27 @@ +error[E0201]: duplicate definitions with name `bar`: + --> $DIR/E0201.rs:15:5 + | +14 | fn bar(&self) -> bool { self.0 > 5 } + | ------------------------------------ previous definition of `bar` here +15 | fn bar() {} //~ ERROR E0201 + | ^^^^^^^^^^^ duplicate definition + +error[E0201]: duplicate definitions with name `baz`: + --> $DIR/E0201.rs:27:5 + | +26 | fn baz(&self) -> bool { true } + | ------------------------------ previous definition of `baz` here +27 | fn baz(&self) -> bool { self.0 > 5 } //~ ERROR E0201 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definition + +error[E0201]: duplicate definitions with name `Quux`: + --> $DIR/E0201.rs:28:5 + | +24 | type Quux = u32; + | ---------------- previous definition of `Quux` here +... +28 | type Quux = u32; //~ ERROR E0201 + | ^^^^^^^^^^^^^^^^ duplicate definition + +error: aborting due to 3 previous errors + diff --git a/src/test/compile-fail/E0206.rs b/src/test/ui/error-codes/E0206.rs similarity index 100% rename from src/test/compile-fail/E0206.rs rename to src/test/ui/error-codes/E0206.rs diff --git a/src/test/ui/error-codes/E0206.stderr b/src/test/ui/error-codes/E0206.stderr new file mode 100644 index 0000000000000..8eeb94a42f4b8 --- /dev/null +++ b/src/test/ui/error-codes/E0206.stderr @@ -0,0 +1,23 @@ +error[E0206]: the trait `Copy` may not be implemented for this type + --> $DIR/E0206.rs:13:15 + | +13 | impl Copy for Foo { } + | ^^^ type is not a structure or enumeration + +error[E0206]: the trait `Copy` may not be implemented for this type + --> $DIR/E0206.rs:20:15 + | +20 | impl Copy for &'static Bar { } + | ^^^^^^^^^^^^ type is not a structure or enumeration + +error[E0117]: only traits defined in the current crate can be implemented for arbitrary types + --> $DIR/E0206.rs:13:1 + | +13 | impl Copy for Foo { } + | ^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate + | + = note: the impl does not reference any types defined in this crate + = note: define and implement a trait or new type instead + +error: aborting due to 3 previous errors + diff --git a/src/test/compile-fail/E0207.rs b/src/test/ui/error-codes/E0207.rs similarity index 100% rename from src/test/compile-fail/E0207.rs rename to src/test/ui/error-codes/E0207.rs diff --git a/src/test/ui/error-codes/E0207.stderr b/src/test/ui/error-codes/E0207.stderr new file mode 100644 index 0000000000000..35f9109fe99ed --- /dev/null +++ b/src/test/ui/error-codes/E0207.stderr @@ -0,0 +1,8 @@ +error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates + --> $DIR/E0207.rs:13:6 + | +13 | impl Foo { //~ ERROR E0207 + | ^ unconstrained type parameter + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0214.rs b/src/test/ui/error-codes/E0214.rs similarity index 100% rename from src/test/compile-fail/E0214.rs rename to src/test/ui/error-codes/E0214.rs diff --git a/src/test/ui/error-codes/E0214.stderr b/src/test/ui/error-codes/E0214.stderr new file mode 100644 index 0000000000000..30f5b960a364e --- /dev/null +++ b/src/test/ui/error-codes/E0214.stderr @@ -0,0 +1,8 @@ +error[E0214]: parenthesized parameters may only be used with a trait + --> $DIR/E0214.rs:12:15 + | +12 | let v: Vec(&str) = vec!["foo"]; + | ^^^^^^ only traits may use parentheses + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0220.rs b/src/test/ui/error-codes/E0220.rs similarity index 100% rename from src/test/compile-fail/E0220.rs rename to src/test/ui/error-codes/E0220.rs diff --git a/src/test/ui/error-codes/E0220.stderr b/src/test/ui/error-codes/E0220.stderr new file mode 100644 index 0000000000000..70b017b782f2d --- /dev/null +++ b/src/test/ui/error-codes/E0220.stderr @@ -0,0 +1,14 @@ +error[E0220]: associated type `F` not found for `Trait` + --> $DIR/E0220.rs:15:18 + | +15 | type Foo = Trait; //~ ERROR E0220 + | ^^^^^ associated type `F` not found + +error[E0191]: the value of the associated type `Bar` (from the trait `Trait`) must be specified + --> $DIR/E0220.rs:15:12 + | +15 | type Foo = Trait; //~ ERROR E0220 + | ^^^^^^^^^^^^ missing associated type `Bar` value + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0221.rs b/src/test/ui/error-codes/E0221.rs similarity index 100% rename from src/test/compile-fail/E0221.rs rename to src/test/ui/error-codes/E0221.rs diff --git a/src/test/ui/error-codes/E0221.stderr b/src/test/ui/error-codes/E0221.stderr new file mode 100644 index 0000000000000..3dd9393d6b32a --- /dev/null +++ b/src/test/ui/error-codes/E0221.stderr @@ -0,0 +1,29 @@ +error[E0221]: ambiguous associated type `A` in bounds of `Self` + --> $DIR/E0221.rs:21:16 + | +15 | type A: T1; + | ----------- ambiguous `A` from `Foo` +... +19 | type A: T2; + | ----------- ambiguous `A` from `Bar` +20 | fn do_something() { +21 | let _: Self::A; + | ^^^^^^^ ambiguous associated type `A` + +error[E0221]: ambiguous associated type `Err` in bounds of `Self` + --> $DIR/E0221.rs:31:16 + | +29 | type Err: T3; + | ------------- ambiguous `Err` from `My` +30 | fn test() { +31 | let _: Self::Err; + | ^^^^^^^^^ ambiguous associated type `Err` + | +note: associated type `Self` could derive from `std::str::FromStr` + --> $DIR/E0221.rs:31:16 + | +31 | let _: Self::Err; + | ^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0223.rs b/src/test/ui/error-codes/E0223.rs similarity index 100% rename from src/test/compile-fail/E0223.rs rename to src/test/ui/error-codes/E0223.rs diff --git a/src/test/ui/error-codes/E0223.stderr b/src/test/ui/error-codes/E0223.stderr new file mode 100644 index 0000000000000..efd0d7806581c --- /dev/null +++ b/src/test/ui/error-codes/E0223.stderr @@ -0,0 +1,10 @@ +error[E0223]: ambiguous associated type + --> $DIR/E0223.rs:14:14 + | +14 | let foo: MyTrait::X; + | ^^^^^^^^^^ ambiguous associated type + | + = note: specify the type using the syntax `::X` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0225.rs b/src/test/ui/error-codes/E0225.rs similarity index 100% rename from src/test/compile-fail/E0225.rs rename to src/test/ui/error-codes/E0225.rs diff --git a/src/test/ui/error-codes/E0225.stderr b/src/test/ui/error-codes/E0225.stderr new file mode 100644 index 0000000000000..35d40cb1017d1 --- /dev/null +++ b/src/test/ui/error-codes/E0225.stderr @@ -0,0 +1,8 @@ +error[E0225]: only auto traits can be used as additional traits in a trait object + --> $DIR/E0225.rs:12:32 + | +12 | let _: Box; + | ^^^^^^^^^^^^^^ non-auto additional trait + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0229.rs b/src/test/ui/error-codes/E0229.rs similarity index 100% rename from src/test/compile-fail/E0229.rs rename to src/test/ui/error-codes/E0229.rs diff --git a/src/test/ui/error-codes/E0229.stderr b/src/test/ui/error-codes/E0229.stderr new file mode 100644 index 0000000000000..6d88ef88bffc3 --- /dev/null +++ b/src/test/ui/error-codes/E0229.stderr @@ -0,0 +1,8 @@ +error[E0229]: associated type bindings are not allowed here + --> $DIR/E0229.rs:23:25 + | +23 | fn baz(x: &>::A) {} + | ^^^^^ associated type not allowed here + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0232.rs b/src/test/ui/error-codes/E0232.rs similarity index 100% rename from src/test/compile-fail/E0232.rs rename to src/test/ui/error-codes/E0232.rs diff --git a/src/test/ui/error-codes/E0232.stderr b/src/test/ui/error-codes/E0232.stderr new file mode 100644 index 0000000000000..e13ba62b073ce --- /dev/null +++ b/src/test/ui/error-codes/E0232.stderr @@ -0,0 +1,10 @@ +error[E0232]: `#[rustc_on_unimplemented]` requires a value + --> $DIR/E0232.rs:13:1 + | +13 | #[rustc_on_unimplemented] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ value required here + | + = note: eg `#[rustc_on_unimplemented = "foo"]` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0243.rs b/src/test/ui/error-codes/E0243.rs similarity index 100% rename from src/test/compile-fail/E0243.rs rename to src/test/ui/error-codes/E0243.rs diff --git a/src/test/ui/error-codes/E0243.stderr b/src/test/ui/error-codes/E0243.stderr new file mode 100644 index 0000000000000..82a90fff34208 --- /dev/null +++ b/src/test/ui/error-codes/E0243.stderr @@ -0,0 +1,8 @@ +error[E0243]: wrong number of type arguments: expected 1, found 0 + --> $DIR/E0243.rs:12:17 + | +12 | struct Bar { x: Foo } + | ^^^ expected 1 type argument + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0244.rs b/src/test/ui/error-codes/E0244.rs similarity index 100% rename from src/test/compile-fail/E0244.rs rename to src/test/ui/error-codes/E0244.rs diff --git a/src/test/ui/error-codes/E0244.stderr b/src/test/ui/error-codes/E0244.stderr new file mode 100644 index 0000000000000..d873fbe9819f8 --- /dev/null +++ b/src/test/ui/error-codes/E0244.stderr @@ -0,0 +1,8 @@ +error[E0244]: wrong number of type arguments: expected 0, found 2 + --> $DIR/E0244.rs:12:23 + | +12 | struct Bar { x: Foo } + | ^^^^^^^^^ expected no type arguments + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0252.rs b/src/test/ui/error-codes/E0252.rs similarity index 100% rename from src/test/compile-fail/E0252.rs rename to src/test/ui/error-codes/E0252.rs diff --git a/src/test/ui/error-codes/E0252.stderr b/src/test/ui/error-codes/E0252.stderr new file mode 100644 index 0000000000000..f63597d697086 --- /dev/null +++ b/src/test/ui/error-codes/E0252.stderr @@ -0,0 +1,16 @@ +error[E0252]: the name `baz` is defined multiple times + --> $DIR/E0252.rs:12:5 + | +11 | use foo::baz; + | -------- previous import of the type `baz` here +12 | use bar::baz; //~ ERROR E0252 + | ^^^^^^^^ `baz` reimported here + | + = note: `baz` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +12 | use bar::baz as other_baz; //~ ERROR E0252 + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0253.rs b/src/test/ui/error-codes/E0253.rs similarity index 100% rename from src/test/compile-fail/E0253.rs rename to src/test/ui/error-codes/E0253.rs diff --git a/src/test/ui/error-codes/E0253.stderr b/src/test/ui/error-codes/E0253.stderr new file mode 100644 index 0000000000000..e5a311537810d --- /dev/null +++ b/src/test/ui/error-codes/E0253.stderr @@ -0,0 +1,8 @@ +error[E0253]: `do_something` is not directly importable + --> $DIR/E0253.rs:17:5 + | +17 | use foo::MyTrait::do_something; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be imported directly + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0254.rs b/src/test/ui/error-codes/E0254.rs similarity index 100% rename from src/test/compile-fail/E0254.rs rename to src/test/ui/error-codes/E0254.rs diff --git a/src/test/ui/error-codes/E0254.stderr b/src/test/ui/error-codes/E0254.stderr new file mode 100644 index 0000000000000..4181c7b1f7fb0 --- /dev/null +++ b/src/test/ui/error-codes/E0254.stderr @@ -0,0 +1,17 @@ +error[E0254]: the name `alloc` is defined multiple times + --> $DIR/E0254.rs:22:5 + | +14 | extern crate alloc; + | ------------------- previous import of the extern crate `alloc` here +... +22 | use foo::alloc; + | ^^^^^^^^^^ `alloc` reimported here + | + = note: `alloc` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +22 | use foo::alloc as other_alloc; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0255.rs b/src/test/ui/error-codes/E0255.rs similarity index 100% rename from src/test/compile-fail/E0255.rs rename to src/test/ui/error-codes/E0255.rs diff --git a/src/test/ui/error-codes/E0255.stderr b/src/test/ui/error-codes/E0255.stderr new file mode 100644 index 0000000000000..924ac49695c63 --- /dev/null +++ b/src/test/ui/error-codes/E0255.stderr @@ -0,0 +1,17 @@ +error[E0255]: the name `foo` is defined multiple times + --> $DIR/E0255.rs:13:1 + | +11 | use bar::foo; + | -------- previous import of the value `foo` here +12 | +13 | fn foo() {} //~ ERROR E0255 + | ^^^^^^^^ `foo` redefined here + | + = note: `foo` must be defined only once in the value namespace of this module +help: You can use `as` to change the binding name of the import + | +11 | use bar::foo as other_foo; + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0259.rs b/src/test/ui/error-codes/E0259.rs similarity index 100% rename from src/test/compile-fail/E0259.rs rename to src/test/ui/error-codes/E0259.rs diff --git a/src/test/ui/error-codes/E0259.stderr b/src/test/ui/error-codes/E0259.stderr new file mode 100644 index 0000000000000..e05e4e1cac74e --- /dev/null +++ b/src/test/ui/error-codes/E0259.stderr @@ -0,0 +1,16 @@ +error[E0259]: the name `alloc` is defined multiple times + --> $DIR/E0259.rs:16:1 + | +14 | extern crate alloc; + | ------------------- previous import of the extern crate `alloc` here +15 | +16 | extern crate libc as alloc; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | `alloc` reimported here + | You can use `as` to change the binding name of the import + | + = note: `alloc` must be defined only once in the type namespace of this module + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0260.rs b/src/test/ui/error-codes/E0260.rs similarity index 100% rename from src/test/compile-fail/E0260.rs rename to src/test/ui/error-codes/E0260.rs diff --git a/src/test/ui/error-codes/E0260.stderr b/src/test/ui/error-codes/E0260.stderr new file mode 100644 index 0000000000000..3d899e636ee38 --- /dev/null +++ b/src/test/ui/error-codes/E0260.stderr @@ -0,0 +1,17 @@ +error[E0260]: the name `alloc` is defined multiple times + --> $DIR/E0260.rs:16:1 + | +14 | extern crate alloc; + | ------------------- previous import of the extern crate `alloc` here +15 | +16 | mod alloc { + | ^^^^^^^^^ `alloc` redefined here + | + = note: `alloc` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +14 | extern crate alloc as other_alloc; + | + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0261.rs b/src/test/ui/error-codes/E0261.rs similarity index 100% rename from src/test/compile-fail/E0261.rs rename to src/test/ui/error-codes/E0261.rs diff --git a/src/test/ui/error-codes/E0261.stderr b/src/test/ui/error-codes/E0261.stderr new file mode 100644 index 0000000000000..c8dd08211ecb0 --- /dev/null +++ b/src/test/ui/error-codes/E0261.stderr @@ -0,0 +1,14 @@ +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/E0261.rs:11:12 + | +11 | fn foo(x: &'a str) { } //~ ERROR E0261 + | ^^ undeclared lifetime + +error[E0261]: use of undeclared lifetime name `'a` + --> $DIR/E0261.rs:15:9 + | +15 | x: &'a str, //~ ERROR E0261 + | ^^ undeclared lifetime + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0262.rs b/src/test/ui/error-codes/E0262.rs similarity index 100% rename from src/test/compile-fail/E0262.rs rename to src/test/ui/error-codes/E0262.rs diff --git a/src/test/ui/error-codes/E0262.stderr b/src/test/ui/error-codes/E0262.stderr new file mode 100644 index 0000000000000..0910009d2c0dc --- /dev/null +++ b/src/test/ui/error-codes/E0262.stderr @@ -0,0 +1,8 @@ +error[E0262]: invalid lifetime parameter name: `'static` + --> $DIR/E0262.rs:11:8 + | +11 | fn foo<'static>(x: &'static str) { } //~ ERROR E0262 + | ^^^^^^^ 'static is a reserved lifetime name + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0263.rs b/src/test/ui/error-codes/E0263.rs similarity index 100% rename from src/test/compile-fail/E0263.rs rename to src/test/ui/error-codes/E0263.rs diff --git a/src/test/ui/error-codes/E0263.stderr b/src/test/ui/error-codes/E0263.stderr new file mode 100644 index 0000000000000..942718d50f727 --- /dev/null +++ b/src/test/ui/error-codes/E0263.stderr @@ -0,0 +1,10 @@ +error[E0263]: lifetime name `'a` declared twice in the same scope + --> $DIR/E0263.rs:11:16 + | +11 | fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str) { + | -- ^^ declared twice + | | + | previous declaration here + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0264.rs b/src/test/ui/error-codes/E0264.rs similarity index 100% rename from src/test/compile-fail/E0264.rs rename to src/test/ui/error-codes/E0264.rs diff --git a/src/test/ui/error-codes/E0264.stderr b/src/test/ui/error-codes/E0264.stderr new file mode 100644 index 0000000000000..b10494633edf3 --- /dev/null +++ b/src/test/ui/error-codes/E0264.stderr @@ -0,0 +1,8 @@ +error[E0264]: unknown external lang item: `cake` + --> $DIR/E0264.rs:15:5 + | +15 | fn cake(); //~ ERROR E0264 + | ^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0267.rs b/src/test/ui/error-codes/E0267.rs similarity index 100% rename from src/test/compile-fail/E0267.rs rename to src/test/ui/error-codes/E0267.rs diff --git a/src/test/ui/error-codes/E0267.stderr b/src/test/ui/error-codes/E0267.stderr new file mode 100644 index 0000000000000..2f6d9c72eeb1a --- /dev/null +++ b/src/test/ui/error-codes/E0267.stderr @@ -0,0 +1,8 @@ +error[E0267]: `break` inside of a closure + --> $DIR/E0267.rs:12:18 + | +12 | let w = || { break; }; //~ ERROR E0267 + | ^^^^^ cannot break inside of a closure + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0268.rs b/src/test/ui/error-codes/E0268.rs similarity index 100% rename from src/test/compile-fail/E0268.rs rename to src/test/ui/error-codes/E0268.rs diff --git a/src/test/ui/error-codes/E0268.stderr b/src/test/ui/error-codes/E0268.stderr new file mode 100644 index 0000000000000..cf89e46af047e --- /dev/null +++ b/src/test/ui/error-codes/E0268.stderr @@ -0,0 +1,8 @@ +error[E0268]: `break` outside of loop + --> $DIR/E0268.rs:12:5 + | +12 | break; //~ ERROR E0268 + | ^^^^^ cannot break outside of a loop + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0271.rs b/src/test/ui/error-codes/E0271.rs similarity index 100% rename from src/test/compile-fail/E0271.rs rename to src/test/ui/error-codes/E0271.rs diff --git a/src/test/ui/error-codes/E0271.stderr b/src/test/ui/error-codes/E0271.stderr new file mode 100644 index 0000000000000..c596b560ea7f8 --- /dev/null +++ b/src/test/ui/error-codes/E0271.stderr @@ -0,0 +1,16 @@ +error[E0271]: type mismatch resolving `::AssociatedType == u32` + --> $DIR/E0271.rs:20:5 + | +20 | foo(3_i8); //~ ERROR E0271 + | ^^^ expected reference, found u32 + | + = note: expected type `&'static str` + found type `u32` +note: required by `foo` + --> $DIR/E0271.rs:13:1 + | +13 | fn foo(t: T) where T: Trait { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0275.rs b/src/test/ui/error-codes/E0275.rs similarity index 100% rename from src/test/compile-fail/E0275.rs rename to src/test/ui/error-codes/E0275.rs diff --git a/src/test/ui/error-codes/E0275.stderr b/src/test/ui/error-codes/E0275.stderr new file mode 100644 index 0000000000000..2dbe5be215546 --- /dev/null +++ b/src/test/ui/error-codes/E0275.stderr @@ -0,0 +1,79 @@ +error[E0275]: overflow evaluating the requirement `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: std::marker::Sized` + --> $DIR/E0275.rs:15:1 + | +15 | impl Foo for T where Bar: Foo {} //~ ERROR E0275 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider adding a `#![recursion_limit="128"]` attribute to your crate + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>>` + = note: required because of the requirements on the impl of `Foo` for `Bar>` + = note: required because of the requirements on the impl of `Foo` for `Bar` +note: required by `Foo` + --> $DIR/E0275.rs:11:1 + | +11 | trait Foo {} + | ^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0276.rs b/src/test/ui/error-codes/E0276.rs similarity index 100% rename from src/test/compile-fail/E0276.rs rename to src/test/ui/error-codes/E0276.rs diff --git a/src/test/ui/error-codes/E0276.stderr b/src/test/ui/error-codes/E0276.stderr new file mode 100644 index 0000000000000..bcbe81ac11a05 --- /dev/null +++ b/src/test/ui/error-codes/E0276.stderr @@ -0,0 +1,11 @@ +error[E0276]: impl has stricter requirements than trait + --> $DIR/E0276.rs:16:5 + | +12 | fn foo(x: T); + | ---------------- definition of `foo` from trait +... +16 | fn foo(x: T) where T: Copy {} //~ ERROR E0276 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: std::marker::Copy` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0277-2.rs b/src/test/ui/error-codes/E0277-2.rs similarity index 100% rename from src/test/compile-fail/E0277-2.rs rename to src/test/ui/error-codes/E0277-2.rs diff --git a/src/test/ui/error-codes/E0277-2.stderr b/src/test/ui/error-codes/E0277-2.stderr new file mode 100644 index 0000000000000..6a0f21ef14438 --- /dev/null +++ b/src/test/ui/error-codes/E0277-2.stderr @@ -0,0 +1,18 @@ +error[E0277]: the trait bound `*const u8: std::marker::Send` is not satisfied in `Foo` + --> $DIR/E0277-2.rs:26:5 + | +26 | is_send::(); + | ^^^^^^^^^^^^^^ `*const u8` cannot be sent between threads safely + | + = help: within `Foo`, the trait `std::marker::Send` is not implemented for `*const u8` + = note: required because it appears within the type `Baz` + = note: required because it appears within the type `Bar` + = note: required because it appears within the type `Foo` +note: required by `is_send` + --> $DIR/E0277-2.rs:23:1 + | +23 | fn is_send() { } + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0277.rs b/src/test/ui/error-codes/E0277.rs similarity index 100% rename from src/test/compile-fail/E0277.rs rename to src/test/ui/error-codes/E0277.rs diff --git a/src/test/ui/error-codes/E0277.stderr b/src/test/ui/error-codes/E0277.stderr new file mode 100644 index 0000000000000..38d14ed7bce25 --- /dev/null +++ b/src/test/ui/error-codes/E0277.stderr @@ -0,0 +1,24 @@ +error[E0277]: the trait bound `[u8]: std::marker::Sized` is not satisfied in `std::path::Path` + --> $DIR/E0277.rs:23:6 + | +23 | fn f(p: Path) { } + | ^ `[u8]` does not have a constant size known at compile-time + | + = help: within `std::path::Path`, the trait `std::marker::Sized` is not implemented for `[u8]` + = note: required because it appears within the type `std::path::Path` + = note: all local variables must have a statically known size + +error[E0277]: the trait bound `i32: Foo` is not satisfied + --> $DIR/E0277.rs:27:5 + | +27 | some_func(5i32); + | ^^^^^^^^^ the trait `Foo` is not implemented for `i32` + | +note: required by `some_func` + --> $DIR/E0277.rs:19:1 + | +19 | fn some_func(foo: T) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0282.rs b/src/test/ui/error-codes/E0282.rs similarity index 100% rename from src/test/compile-fail/E0282.rs rename to src/test/ui/error-codes/E0282.rs diff --git a/src/test/ui/error-codes/E0282.stderr b/src/test/ui/error-codes/E0282.stderr new file mode 100644 index 0000000000000..835162740da90 --- /dev/null +++ b/src/test/ui/error-codes/E0282.stderr @@ -0,0 +1,11 @@ +error[E0282]: type annotations needed + --> $DIR/E0282.rs:12:9 + | +12 | let x = "hello".chars().rev().collect(); //~ ERROR E0282 + | ^ + | | + | cannot infer type for `_` + | consider giving `x` a type + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0283.rs b/src/test/ui/error-codes/E0283.rs similarity index 100% rename from src/test/compile-fail/E0283.rs rename to src/test/ui/error-codes/E0283.rs diff --git a/src/test/ui/error-codes/E0283.stderr b/src/test/ui/error-codes/E0283.stderr new file mode 100644 index 0000000000000..9fdb6b178c4d7 --- /dev/null +++ b/src/test/ui/error-codes/E0283.stderr @@ -0,0 +1,14 @@ +error[E0283]: type annotations required: cannot resolve `_: Generator` + --> $DIR/E0283.rs:28:21 + | +28 | let cont: u32 = Generator::create(); //~ ERROR E0283 + | ^^^^^^^^^^^^^^^^^ + | +note: required by `Generator::create` + --> $DIR/E0283.rs:12:5 + | +12 | fn create() -> u32; + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0296.rs b/src/test/ui/error-codes/E0296.rs similarity index 100% rename from src/test/compile-fail/E0296.rs rename to src/test/ui/error-codes/E0296.rs diff --git a/src/test/ui/error-codes/E0296.stderr b/src/test/ui/error-codes/E0296.stderr new file mode 100644 index 0000000000000..f6a2adc0ad3f7 --- /dev/null +++ b/src/test/ui/error-codes/E0296.stderr @@ -0,0 +1,8 @@ +error[E0296]: malformed recursion limit attribute, expected #![recursion_limit="N"] + --> $DIR/E0296.rs:11:1 + | +11 | #![recursion_limit] //~ ERROR E0296 + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0297.rs b/src/test/ui/error-codes/E0297.rs similarity index 100% rename from src/test/compile-fail/E0297.rs rename to src/test/ui/error-codes/E0297.rs diff --git a/src/test/ui/error-codes/E0297.stderr b/src/test/ui/error-codes/E0297.stderr new file mode 100644 index 0000000000000..2dfed66ecaca6 --- /dev/null +++ b/src/test/ui/error-codes/E0297.stderr @@ -0,0 +1,8 @@ +error[E0005]: refutable pattern in `for` loop binding: `None` not covered + --> $DIR/E0297.rs:14:9 + | +14 | for Some(x) in xs {} + | ^^^^^^^ pattern `None` not covered + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0301.rs b/src/test/ui/error-codes/E0301.rs similarity index 100% rename from src/test/compile-fail/E0301.rs rename to src/test/ui/error-codes/E0301.rs diff --git a/src/test/ui/error-codes/E0301.stderr b/src/test/ui/error-codes/E0301.stderr new file mode 100644 index 0000000000000..ff4ee32d47b09 --- /dev/null +++ b/src/test/ui/error-codes/E0301.stderr @@ -0,0 +1,8 @@ +error[E0301]: cannot mutably borrow in a pattern guard + --> $DIR/E0301.rs:14:19 + | +14 | option if option.take().is_none() => {}, //~ ERROR E0301 + | ^^^^^^ borrowed mutably in pattern guard + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0302.rs b/src/test/ui/error-codes/E0302.rs similarity index 100% rename from src/test/compile-fail/E0302.rs rename to src/test/ui/error-codes/E0302.rs diff --git a/src/test/ui/error-codes/E0302.stderr b/src/test/ui/error-codes/E0302.stderr new file mode 100644 index 0000000000000..c7b33a490d1c9 --- /dev/null +++ b/src/test/ui/error-codes/E0302.stderr @@ -0,0 +1,8 @@ +error[E0302]: cannot assign in a pattern guard + --> $DIR/E0302.rs:14:21 + | +14 | option if { option = None; false } => { }, //~ ERROR E0302 + | ^^^^^^^^^^^^^ assignment in pattern guard + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0303.rs b/src/test/ui/error-codes/E0303.rs similarity index 100% rename from src/test/compile-fail/E0303.rs rename to src/test/ui/error-codes/E0303.rs diff --git a/src/test/ui/error-codes/E0303.stderr b/src/test/ui/error-codes/E0303.stderr new file mode 100644 index 0000000000000..6528c97a560df --- /dev/null +++ b/src/test/ui/error-codes/E0303.stderr @@ -0,0 +1,17 @@ +error[E0009]: cannot bind by-move and by-ref in the same pattern + --> $DIR/E0303.rs:13:34 + | +13 | ref op_string_ref @ Some(s) => {}, + | -------------------------^- + | | | + | | by-move pattern here + | both by-ref and by-move used + +error[E0303]: pattern bindings are not allowed after an `@` + --> $DIR/E0303.rs:13:34 + | +13 | ref op_string_ref @ Some(s) => {}, + | ^ not allowed after `@` + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0308-4.rs b/src/test/ui/error-codes/E0308-4.rs similarity index 100% rename from src/test/compile-fail/E0308-4.rs rename to src/test/ui/error-codes/E0308-4.rs diff --git a/src/test/ui/error-codes/E0308-4.stderr b/src/test/ui/error-codes/E0308-4.stderr new file mode 100644 index 0000000000000..1e4beeae17691 --- /dev/null +++ b/src/test/ui/error-codes/E0308-4.stderr @@ -0,0 +1,8 @@ +error[E0308]: mismatched types + --> $DIR/E0308-4.rs:14:9 + | +14 | 0u8...3i8 => (), //~ ERROR E0308 + | ^^^^^^^^^ expected u8, found i8 + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0308.rs b/src/test/ui/error-codes/E0308.rs similarity index 100% rename from src/test/compile-fail/E0308.rs rename to src/test/ui/error-codes/E0308.rs diff --git a/src/test/ui/error-codes/E0308.stderr b/src/test/ui/error-codes/E0308.stderr new file mode 100644 index 0000000000000..905b0210abfbf --- /dev/null +++ b/src/test/ui/error-codes/E0308.stderr @@ -0,0 +1,11 @@ +error[E0308]: intrinsic has wrong type + --> $DIR/E0308.rs:14:5 + | +14 | fn size_of(); //~ ERROR E0308 + | ^^^^^^^^^^^^^^^^ expected (), found usize + | + = note: expected type `unsafe extern "rust-intrinsic" fn()` + found type `unsafe extern "rust-intrinsic" fn() -> usize` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0365.rs b/src/test/ui/error-codes/E0365.rs similarity index 100% rename from src/test/compile-fail/E0365.rs rename to src/test/ui/error-codes/E0365.rs diff --git a/src/test/ui/error-codes/E0365.stderr b/src/test/ui/error-codes/E0365.stderr new file mode 100644 index 0000000000000..ccb13856df9e1 --- /dev/null +++ b/src/test/ui/error-codes/E0365.stderr @@ -0,0 +1,10 @@ +error[E0365]: `foo` is private, and cannot be re-exported + --> $DIR/E0365.rs:15:9 + | +15 | pub use foo as foo2; + | ^^^^^^^^^^^ re-export of private `foo` + | + = note: consider declaring type or module `foo` with `pub` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0370.rs b/src/test/ui/error-codes/E0370.rs similarity index 100% rename from src/test/compile-fail/E0370.rs rename to src/test/ui/error-codes/E0370.rs diff --git a/src/test/ui/error-codes/E0370.stderr b/src/test/ui/error-codes/E0370.stderr new file mode 100644 index 0000000000000..1f248f4ed2c21 --- /dev/null +++ b/src/test/ui/error-codes/E0370.stderr @@ -0,0 +1,10 @@ +error[E0370]: enum discriminant overflowed + --> $DIR/E0370.rs:17:5 + | +17 | Y, //~ ERROR E0370 + | ^ overflowed on value after 9223372036854775807i64 + | + = note: explicitly set `Y = -9223372036854775808i64` if that is desired outcome + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0374.rs b/src/test/ui/error-codes/E0374.rs similarity index 100% rename from src/test/compile-fail/E0374.rs rename to src/test/ui/error-codes/E0374.rs diff --git a/src/test/ui/error-codes/E0374.stderr b/src/test/ui/error-codes/E0374.stderr new file mode 100644 index 0000000000000..edd463d705c19 --- /dev/null +++ b/src/test/ui/error-codes/E0374.stderr @@ -0,0 +1,9 @@ +error[E0374]: the trait `CoerceUnsized` may only be implemented for a coercion between structures with one field being coerced, none found + --> $DIR/E0374.rs:18:1 + | +18 | / impl CoerceUnsized> for Foo //~ ERROR E0374 +19 | | where T: CoerceUnsized {} + | |________________________________^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0375.rs b/src/test/ui/error-codes/E0375.rs similarity index 100% rename from src/test/compile-fail/E0375.rs rename to src/test/ui/error-codes/E0375.rs diff --git a/src/test/ui/error-codes/E0375.stderr b/src/test/ui/error-codes/E0375.stderr new file mode 100644 index 0000000000000..a37591521c8ca --- /dev/null +++ b/src/test/ui/error-codes/E0375.stderr @@ -0,0 +1,11 @@ +error[E0375]: implementing the trait `CoerceUnsized` requires multiple coercions + --> $DIR/E0375.rs:22:12 + | +22 | impl CoerceUnsized> for Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ requires multiple coercions + | + = note: `CoerceUnsized` may only be implemented for a coercion between structures with one field being coerced + = note: currently, 2 fields need coercions: b (T to U), c (U to T) + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0376.rs b/src/test/ui/error-codes/E0376.rs similarity index 100% rename from src/test/compile-fail/E0376.rs rename to src/test/ui/error-codes/E0376.rs diff --git a/src/test/ui/error-codes/E0376.stderr b/src/test/ui/error-codes/E0376.stderr new file mode 100644 index 0000000000000..d036adb4e2950 --- /dev/null +++ b/src/test/ui/error-codes/E0376.stderr @@ -0,0 +1,8 @@ +error[E0376]: the trait `CoerceUnsized` may only be implemented for a coercion between structures + --> $DIR/E0376.rs:18:1 + | +18 | impl CoerceUnsized for Foo {} //~ ERROR E0376 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0388.rs b/src/test/ui/error-codes/E0388.rs similarity index 100% rename from src/test/compile-fail/E0388.rs rename to src/test/ui/error-codes/E0388.rs diff --git a/src/test/ui/error-codes/E0388.stderr b/src/test/ui/error-codes/E0388.stderr new file mode 100644 index 0000000000000..ec210294cdbd4 --- /dev/null +++ b/src/test/ui/error-codes/E0388.stderr @@ -0,0 +1,26 @@ +error[E0017]: references in constants may only refer to immutable values + --> $DIR/E0388.rs:14:30 + | +14 | const CR: &'static mut i32 = &mut C; //~ ERROR E0017 + | ^^^^^^ constants require immutable values + +error[E0017]: references in statics may only refer to immutable values + --> $DIR/E0388.rs:15:39 + | +15 | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 + | ^^^^^^ statics require immutable values + +error[E0596]: cannot borrow immutable static item as mutable + --> $DIR/E0388.rs:15:44 + | +15 | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 + | ^ + +error[E0017]: references in statics may only refer to immutable values + --> $DIR/E0388.rs:17:38 + | +17 | static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017 + | ^^^^^^ statics require immutable values + +error: aborting due to 4 previous errors + diff --git a/src/test/compile-fail/E0389.rs b/src/test/ui/error-codes/E0389.rs similarity index 100% rename from src/test/compile-fail/E0389.rs rename to src/test/ui/error-codes/E0389.rs diff --git a/src/test/ui/error-codes/E0389.stderr b/src/test/ui/error-codes/E0389.stderr new file mode 100644 index 0000000000000..e085329bac508 --- /dev/null +++ b/src/test/ui/error-codes/E0389.stderr @@ -0,0 +1,8 @@ +error[E0389]: cannot assign to data in a `&` reference + --> $DIR/E0389.rs:18:5 + | +18 | fancy_ref.num = 6; //~ ERROR E0389 + | ^^^^^^^^^^^^^^^^^ assignment into an immutable reference + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0390.rs b/src/test/ui/error-codes/E0390.rs similarity index 100% rename from src/test/compile-fail/E0390.rs rename to src/test/ui/error-codes/E0390.rs diff --git a/src/test/ui/error-codes/E0390.stderr b/src/test/ui/error-codes/E0390.stderr new file mode 100644 index 0000000000000..a10b0b87f37bd --- /dev/null +++ b/src/test/ui/error-codes/E0390.stderr @@ -0,0 +1,14 @@ +error[E0390]: only a single inherent implementation marked with `#[lang = "mut_ptr"]` is allowed for the `*mut T` primitive + --> $DIR/E0390.rs:15:1 + | +15 | impl *mut Foo {} //~ ERROR E0390 + | ^^^^^^^^^^^^^^^^ + | +help: consider using a trait to implement these methods + --> $DIR/E0390.rs:15:1 + | +15 | impl *mut Foo {} //~ ERROR E0390 + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0392.rs b/src/test/ui/error-codes/E0392.rs similarity index 100% rename from src/test/compile-fail/E0392.rs rename to src/test/ui/error-codes/E0392.rs diff --git a/src/test/ui/error-codes/E0392.stderr b/src/test/ui/error-codes/E0392.stderr new file mode 100644 index 0000000000000..6c466cbb52e38 --- /dev/null +++ b/src/test/ui/error-codes/E0392.stderr @@ -0,0 +1,10 @@ +error[E0392]: parameter `T` is never used + --> $DIR/E0392.rs:11:10 + | +11 | enum Foo { Bar } //~ ERROR E0392 + | ^ unused type parameter + | + = help: consider removing `T` or using a marker such as `std::marker::PhantomData` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0393.rs b/src/test/ui/error-codes/E0393.rs similarity index 100% rename from src/test/compile-fail/E0393.rs rename to src/test/ui/error-codes/E0393.rs diff --git a/src/test/ui/error-codes/E0393.stderr b/src/test/ui/error-codes/E0393.stderr new file mode 100644 index 0000000000000..10728e21901cd --- /dev/null +++ b/src/test/ui/error-codes/E0393.stderr @@ -0,0 +1,10 @@ +error[E0393]: the type parameter `T` must be explicitly specified + --> $DIR/E0393.rs:13:43 + | +13 | fn together_we_will_rule_the_galaxy(son: &A) {} + | ^ missing reference to `T` + | + = note: because of the default `Self` reference, type parameters must be specified on object types + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0394.rs b/src/test/ui/error-codes/E0394.rs similarity index 100% rename from src/test/compile-fail/E0394.rs rename to src/test/ui/error-codes/E0394.rs diff --git a/src/test/ui/error-codes/E0394.stderr b/src/test/ui/error-codes/E0394.stderr new file mode 100644 index 0000000000000..728cec1032558 --- /dev/null +++ b/src/test/ui/error-codes/E0394.stderr @@ -0,0 +1,10 @@ +error[E0394]: cannot refer to other statics by value, use the address-of operator or a constant instead + --> $DIR/E0394.rs:14:17 + | +14 | static B: u32 = A; + | ^ referring to another static by value + | + = note: use the address-of operator or a constant instead + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0395.rs b/src/test/ui/error-codes/E0395.rs similarity index 100% rename from src/test/compile-fail/E0395.rs rename to src/test/ui/error-codes/E0395.rs diff --git a/src/test/ui/error-codes/E0395.stderr b/src/test/ui/error-codes/E0395.stderr new file mode 100644 index 0000000000000..e6d76a696d3cf --- /dev/null +++ b/src/test/ui/error-codes/E0395.stderr @@ -0,0 +1,8 @@ +error[E0395]: raw pointers cannot be compared in statics + --> $DIR/E0395.rs:14:22 + | +14 | static BAZ: bool = { (&FOO as *const i32) == (&BAR as *const i32) }; //~ ERROR E0395 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comparing raw pointers in static + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0396.rs b/src/test/ui/error-codes/E0396.rs similarity index 100% rename from src/test/compile-fail/E0396.rs rename to src/test/ui/error-codes/E0396.rs diff --git a/src/test/ui/error-codes/E0396.stderr b/src/test/ui/error-codes/E0396.stderr new file mode 100644 index 0000000000000..5c5c01cb98854 --- /dev/null +++ b/src/test/ui/error-codes/E0396.stderr @@ -0,0 +1,8 @@ +error[E0396]: raw pointers cannot be dereferenced in constants + --> $DIR/E0396.rs:13:28 + | +13 | const VALUE: u8 = unsafe { *REG_ADDR }; //~ ERROR E0396 + | ^^^^^^^^^ dereference of raw pointer in constant + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0401.rs b/src/test/ui/error-codes/E0401.rs similarity index 100% rename from src/test/compile-fail/E0401.rs rename to src/test/ui/error-codes/E0401.rs diff --git a/src/test/ui/error-codes/E0401.stderr b/src/test/ui/error-codes/E0401.stderr new file mode 100644 index 0000000000000..d63aa378eee7d --- /dev/null +++ b/src/test/ui/error-codes/E0401.stderr @@ -0,0 +1,8 @@ +error[E0401]: can't use type parameters from outer function; try using a local type parameter instead + --> $DIR/E0401.rs:12:15 + | +12 | fn bar(y: T) { //~ ERROR E0401 + | ^ use of type variable from outer function + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0403.rs b/src/test/ui/error-codes/E0403.rs similarity index 100% rename from src/test/compile-fail/E0403.rs rename to src/test/ui/error-codes/E0403.rs diff --git a/src/test/ui/error-codes/E0403.stderr b/src/test/ui/error-codes/E0403.stderr new file mode 100644 index 0000000000000..125af35cb5798 --- /dev/null +++ b/src/test/ui/error-codes/E0403.stderr @@ -0,0 +1,10 @@ +error[E0403]: the name `T` is already used for a type parameter in this type parameter list + --> $DIR/E0403.rs:11:11 + | +11 | fn foo(s: T, u: T) {} //~ ERROR E0403 + | - ^ already used + | | + | first use of `T` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0404.rs b/src/test/ui/error-codes/E0404.rs similarity index 100% rename from src/test/compile-fail/E0404.rs rename to src/test/ui/error-codes/E0404.rs diff --git a/src/test/ui/error-codes/E0404.stderr b/src/test/ui/error-codes/E0404.stderr new file mode 100644 index 0000000000000..c30d8c00b80e2 --- /dev/null +++ b/src/test/ui/error-codes/E0404.stderr @@ -0,0 +1,8 @@ +error[E0404]: expected trait, found struct `Foo` + --> $DIR/E0404.rs:14:6 + | +14 | impl Foo for Bar {} //~ ERROR E0404 + | ^^^ not a trait + +error: cannot continue compilation due to previous error + diff --git a/src/test/compile-fail/E0405.rs b/src/test/ui/error-codes/E0405.rs similarity index 100% rename from src/test/compile-fail/E0405.rs rename to src/test/ui/error-codes/E0405.rs diff --git a/src/test/ui/error-codes/E0405.stderr b/src/test/ui/error-codes/E0405.stderr new file mode 100644 index 0000000000000..29bab3f6dd99a --- /dev/null +++ b/src/test/ui/error-codes/E0405.stderr @@ -0,0 +1,8 @@ +error[E0405]: cannot find trait `SomeTrait` in this scope + --> $DIR/E0405.rs:13:6 + | +13 | impl SomeTrait for Foo {} //~ ERROR E0405 + | ^^^^^^^^^ not found in this scope + +error: cannot continue compilation due to previous error + diff --git a/src/test/compile-fail/E0407.rs b/src/test/ui/error-codes/E0407.rs similarity index 100% rename from src/test/compile-fail/E0407.rs rename to src/test/ui/error-codes/E0407.rs diff --git a/src/test/ui/error-codes/E0407.stderr b/src/test/ui/error-codes/E0407.stderr new file mode 100644 index 0000000000000..f71437cd6b07c --- /dev/null +++ b/src/test/ui/error-codes/E0407.stderr @@ -0,0 +1,8 @@ +error[E0407]: method `b` is not a member of trait `Foo` + --> $DIR/E0407.rs:19:5 + | +19 | fn b() {} + | ^^^^^^^^^ not a member of trait `Foo` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0408.rs b/src/test/ui/error-codes/E0408.rs similarity index 100% rename from src/test/compile-fail/E0408.rs rename to src/test/ui/error-codes/E0408.rs diff --git a/src/test/ui/error-codes/E0408.stderr b/src/test/ui/error-codes/E0408.stderr new file mode 100644 index 0000000000000..1c66bb0e5f07b --- /dev/null +++ b/src/test/ui/error-codes/E0408.stderr @@ -0,0 +1,10 @@ +error[E0408]: variable `y` is not bound in all patterns + --> $DIR/E0408.rs:15:19 + | +15 | Some(y) | None => {} //~ ERROR variable `y` is not bound in all patterns + | - ^^^^ pattern doesn't bind `y` + | | + | variable not in all patterns + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0411.rs b/src/test/ui/error-codes/E0411.rs similarity index 100% rename from src/test/compile-fail/E0411.rs rename to src/test/ui/error-codes/E0411.rs diff --git a/src/test/ui/error-codes/E0411.stderr b/src/test/ui/error-codes/E0411.stderr new file mode 100644 index 0000000000000..dda922b5b6891 --- /dev/null +++ b/src/test/ui/error-codes/E0411.stderr @@ -0,0 +1,8 @@ +error[E0411]: cannot find type `Self` in this scope + --> $DIR/E0411.rs:12:6 + | +12 | ::foo; //~ ERROR E0411 + | ^^^^ `Self` is only available in traits and impls + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0412.rs b/src/test/ui/error-codes/E0412.rs similarity index 100% rename from src/test/compile-fail/E0412.rs rename to src/test/ui/error-codes/E0412.rs diff --git a/src/test/ui/error-codes/E0412.stderr b/src/test/ui/error-codes/E0412.stderr new file mode 100644 index 0000000000000..6ee2125af04e8 --- /dev/null +++ b/src/test/ui/error-codes/E0412.stderr @@ -0,0 +1,8 @@ +error[E0412]: cannot find type `Something` in this scope + --> $DIR/E0412.rs:11:6 + | +11 | impl Something {} //~ ERROR E0412 + | ^^^^^^^^^ not found in this scope + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0415.rs b/src/test/ui/error-codes/E0415.rs similarity index 100% rename from src/test/compile-fail/E0415.rs rename to src/test/ui/error-codes/E0415.rs diff --git a/src/test/ui/error-codes/E0415.stderr b/src/test/ui/error-codes/E0415.stderr new file mode 100644 index 0000000000000..5e5cfe16e5038 --- /dev/null +++ b/src/test/ui/error-codes/E0415.stderr @@ -0,0 +1,8 @@ +error[E0415]: identifier `f` is bound more than once in this parameter list + --> $DIR/E0415.rs:11:16 + | +11 | fn foo(f: i32, f: i32) {} //~ ERROR E0415 + | ^ used as parameter more than once + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0416.rs b/src/test/ui/error-codes/E0416.rs similarity index 100% rename from src/test/compile-fail/E0416.rs rename to src/test/ui/error-codes/E0416.rs diff --git a/src/test/ui/error-codes/E0416.stderr b/src/test/ui/error-codes/E0416.stderr new file mode 100644 index 0000000000000..a48a3ade5c9a4 --- /dev/null +++ b/src/test/ui/error-codes/E0416.stderr @@ -0,0 +1,8 @@ +error[E0416]: identifier `x` is bound more than once in the same pattern + --> $DIR/E0416.rs:13:13 + | +13 | (x, x) => {} //~ ERROR E0416 + | ^ used in a pattern more than once + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0423.rs b/src/test/ui/error-codes/E0423.rs similarity index 100% rename from src/test/compile-fail/E0423.rs rename to src/test/ui/error-codes/E0423.rs diff --git a/src/test/ui/error-codes/E0423.stderr b/src/test/ui/error-codes/E0423.stderr new file mode 100644 index 0000000000000..aee398efeddee --- /dev/null +++ b/src/test/ui/error-codes/E0423.stderr @@ -0,0 +1,8 @@ +error[E0423]: expected function, found struct `Foo` + --> $DIR/E0423.rs:14:13 + | +14 | let f = Foo(); //~ ERROR E0423 + | ^^^ did you mean `Foo { /* fields */ }`? + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0424.rs b/src/test/ui/error-codes/E0424.rs similarity index 100% rename from src/test/compile-fail/E0424.rs rename to src/test/ui/error-codes/E0424.rs diff --git a/src/test/ui/error-codes/E0424.stderr b/src/test/ui/error-codes/E0424.stderr new file mode 100644 index 0000000000000..d1fd432f4f032 --- /dev/null +++ b/src/test/ui/error-codes/E0424.stderr @@ -0,0 +1,8 @@ +error[E0424]: expected value, found module `self` + --> $DIR/E0424.rs:17:9 + | +17 | self.bar(); //~ ERROR E0424 + | ^^^^ `self` value is only available in methods with `self` parameter + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0425.rs b/src/test/ui/error-codes/E0425.rs similarity index 100% rename from src/test/compile-fail/E0425.rs rename to src/test/ui/error-codes/E0425.rs diff --git a/src/test/ui/error-codes/E0425.stderr b/src/test/ui/error-codes/E0425.stderr new file mode 100644 index 0000000000000..250ecaeb368ee --- /dev/null +++ b/src/test/ui/error-codes/E0425.stderr @@ -0,0 +1,8 @@ +error[E0425]: cannot find value `elf` in this scope + --> $DIR/E0425.rs:13:9 + | +13 | elf; //~ ERROR E0425 + | ^^^ not found in this scope + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0426.rs b/src/test/ui/error-codes/E0426.rs similarity index 100% rename from src/test/compile-fail/E0426.rs rename to src/test/ui/error-codes/E0426.rs diff --git a/src/test/ui/error-codes/E0426.stderr b/src/test/ui/error-codes/E0426.stderr new file mode 100644 index 0000000000000..bb05effd732cd --- /dev/null +++ b/src/test/ui/error-codes/E0426.stderr @@ -0,0 +1,8 @@ +error[E0426]: use of undeclared label `'a` + --> $DIR/E0426.rs:13:15 + | +13 | break 'a; + | ^^ undeclared label `'a` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0428.rs b/src/test/ui/error-codes/E0428.rs similarity index 100% rename from src/test/compile-fail/E0428.rs rename to src/test/ui/error-codes/E0428.rs diff --git a/src/test/ui/error-codes/E0428.stderr b/src/test/ui/error-codes/E0428.stderr new file mode 100644 index 0000000000000..c739536c0ab55 --- /dev/null +++ b/src/test/ui/error-codes/E0428.stderr @@ -0,0 +1,12 @@ +error[E0428]: the name `Bar` is defined multiple times + --> $DIR/E0428.rs:12:1 + | +11 | struct Bar; //~ previous definition of the type `Bar` here + | ----------- previous definition of the type `Bar` here +12 | struct Bar; //~ ERROR E0428 + | ^^^^^^^^^^^ `Bar` redefined here + | + = note: `Bar` must be defined only once in the type namespace of this module + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0429.rs b/src/test/ui/error-codes/E0429.rs similarity index 100% rename from src/test/compile-fail/E0429.rs rename to src/test/ui/error-codes/E0429.rs diff --git a/src/test/ui/error-codes/E0429.stderr b/src/test/ui/error-codes/E0429.stderr new file mode 100644 index 0000000000000..96cf50500fdb4 --- /dev/null +++ b/src/test/ui/error-codes/E0429.stderr @@ -0,0 +1,8 @@ +error[E0429]: `self` imports are only allowed within a { } list + --> $DIR/E0429.rs:11:5 + | +11 | use std::fmt::self; //~ ERROR E0429 + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0430.rs b/src/test/ui/error-codes/E0430.rs similarity index 100% rename from src/test/compile-fail/E0430.rs rename to src/test/ui/error-codes/E0430.rs diff --git a/src/test/ui/error-codes/E0430.stderr b/src/test/ui/error-codes/E0430.stderr new file mode 100644 index 0000000000000..b5c80aa23f62d --- /dev/null +++ b/src/test/ui/error-codes/E0430.stderr @@ -0,0 +1,24 @@ +error[E0430]: `self` import can only appear once in an import list + --> $DIR/E0430.rs:11:16 + | +11 | use std::fmt::{self, self}; //~ ERROR E0430 + | ^^^^ ---- another `self` import appears here + | | + | can only appear once in an import list + +error[E0252]: the name `fmt` is defined multiple times + --> $DIR/E0430.rs:11:22 + | +11 | use std::fmt::{self, self}; //~ ERROR E0430 + | ---- ^^^^ `fmt` reimported here + | | + | previous import of the module `fmt` here + | + = note: `fmt` must be defined only once in the type namespace of this module +help: You can use `as` to change the binding name of the import + | +11 | use std::fmt::{self, self as other_fmt}; //~ ERROR E0430 + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0431.rs b/src/test/ui/error-codes/E0431.rs similarity index 100% rename from src/test/compile-fail/E0431.rs rename to src/test/ui/error-codes/E0431.rs diff --git a/src/test/ui/error-codes/E0431.stderr b/src/test/ui/error-codes/E0431.stderr new file mode 100644 index 0000000000000..c7a786b7402d2 --- /dev/null +++ b/src/test/ui/error-codes/E0431.stderr @@ -0,0 +1,8 @@ +error[E0431]: `self` import can only appear in an import list with a non-empty prefix + --> $DIR/E0431.rs:11:6 + | +11 | use {self}; //~ ERROR E0431 + | ^^^^ can only appear in an import list with a non-empty prefix + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0432.rs b/src/test/ui/error-codes/E0432.rs similarity index 100% rename from src/test/compile-fail/E0432.rs rename to src/test/ui/error-codes/E0432.rs diff --git a/src/test/ui/error-codes/E0432.stderr b/src/test/ui/error-codes/E0432.stderr new file mode 100644 index 0000000000000..6d808f038a333 --- /dev/null +++ b/src/test/ui/error-codes/E0432.stderr @@ -0,0 +1,8 @@ +error[E0432]: unresolved import `something` + --> $DIR/E0432.rs:11:5 + | +11 | use something::Foo; //~ ERROR E0432 + | ^^^^^^^^^ Maybe a missing `extern crate something;`? + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0433.rs b/src/test/ui/error-codes/E0433.rs similarity index 100% rename from src/test/compile-fail/E0433.rs rename to src/test/ui/error-codes/E0433.rs diff --git a/src/test/ui/error-codes/E0433.stderr b/src/test/ui/error-codes/E0433.stderr new file mode 100644 index 0000000000000..691c5922f8fbc --- /dev/null +++ b/src/test/ui/error-codes/E0433.stderr @@ -0,0 +1,8 @@ +error[E0433]: failed to resolve. Use of undeclared type or module `HashMap` + --> $DIR/E0433.rs:12:15 + | +12 | let map = HashMap::new(); //~ ERROR E0433 + | ^^^^^^^ Use of undeclared type or module `HashMap` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0434.rs b/src/test/ui/error-codes/E0434.rs similarity index 100% rename from src/test/compile-fail/E0434.rs rename to src/test/ui/error-codes/E0434.rs diff --git a/src/test/ui/error-codes/E0434.stderr b/src/test/ui/error-codes/E0434.stderr new file mode 100644 index 0000000000000..06880acdb3573 --- /dev/null +++ b/src/test/ui/error-codes/E0434.stderr @@ -0,0 +1,10 @@ +error[E0434]: can't capture dynamic environment in a fn item + --> $DIR/E0434.rs:14:9 + | +14 | y //~ ERROR E0434 + | ^ + | + = help: use the `|| { ... }` closure form instead + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0435.rs b/src/test/ui/error-codes/E0435.rs similarity index 100% rename from src/test/compile-fail/E0435.rs rename to src/test/ui/error-codes/E0435.rs diff --git a/src/test/ui/error-codes/E0435.stderr b/src/test/ui/error-codes/E0435.stderr new file mode 100644 index 0000000000000..855903b7ec35e --- /dev/null +++ b/src/test/ui/error-codes/E0435.stderr @@ -0,0 +1,8 @@ +error[E0435]: attempt to use a non-constant value in a constant + --> $DIR/E0435.rs:13:17 + | +13 | let _: [u8; foo]; //~ ERROR E0435 + | ^^^ non-constant value + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0437.rs b/src/test/ui/error-codes/E0437.rs similarity index 100% rename from src/test/compile-fail/E0437.rs rename to src/test/ui/error-codes/E0437.rs diff --git a/src/test/ui/error-codes/E0437.stderr b/src/test/ui/error-codes/E0437.stderr new file mode 100644 index 0000000000000..ffad571d06125 --- /dev/null +++ b/src/test/ui/error-codes/E0437.stderr @@ -0,0 +1,8 @@ +error[E0437]: type `Bar` is not a member of trait `Foo` + --> $DIR/E0437.rs:14:5 + | +14 | type Bar = bool; //~ ERROR E0437 + | ^^^^^^^^^^^^^^^^ not a member of trait `Foo` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0438.rs b/src/test/ui/error-codes/E0438.rs similarity index 100% rename from src/test/compile-fail/E0438.rs rename to src/test/ui/error-codes/E0438.rs diff --git a/src/test/ui/error-codes/E0438.stderr b/src/test/ui/error-codes/E0438.stderr new file mode 100644 index 0000000000000..df587395356f1 --- /dev/null +++ b/src/test/ui/error-codes/E0438.stderr @@ -0,0 +1,8 @@ +error[E0438]: const `BAR` is not a member of trait `Bar` + --> $DIR/E0438.rs:15:5 + | +15 | const BAR: bool = true; //~ ERROR E0438 + | ^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `Bar` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0439.rs b/src/test/ui/error-codes/E0439.rs similarity index 100% rename from src/test/compile-fail/E0439.rs rename to src/test/ui/error-codes/E0439.rs diff --git a/src/test/ui/error-codes/E0439.stderr b/src/test/ui/error-codes/E0439.stderr new file mode 100644 index 0000000000000..77930d5e08d94 --- /dev/null +++ b/src/test/ui/error-codes/E0439.stderr @@ -0,0 +1,8 @@ +error[E0439]: invalid `simd_shuffle`, needs length: `simd_shuffle` + --> $DIR/E0439.rs:14:5 + | +14 | fn simd_shuffle(a: A, b: A, c: [u32; 8]) -> B; //~ ERROR E0439 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0440.rs b/src/test/ui/error-codes/E0440.rs similarity index 100% rename from src/test/compile-fail/E0440.rs rename to src/test/ui/error-codes/E0440.rs diff --git a/src/test/ui/error-codes/E0440.stderr b/src/test/ui/error-codes/E0440.stderr new file mode 100644 index 0000000000000..83210a996e0e1 --- /dev/null +++ b/src/test/ui/error-codes/E0440.stderr @@ -0,0 +1,8 @@ +error[E0440]: platform-specific intrinsic has wrong number of type parameters: found 1, expected 0 + --> $DIR/E0440.rs:18:5 + | +18 | fn x86_mm_movemask_pd(x: f64x2) -> i32; //~ ERROR E0440 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0441.rs b/src/test/ui/error-codes/E0441.rs similarity index 100% rename from src/test/compile-fail/E0441.rs rename to src/test/ui/error-codes/E0441.rs diff --git a/src/test/ui/error-codes/E0441.stderr b/src/test/ui/error-codes/E0441.stderr new file mode 100644 index 0000000000000..34a387e64597a --- /dev/null +++ b/src/test/ui/error-codes/E0441.stderr @@ -0,0 +1,8 @@ +error[E0441]: unrecognized platform-specific intrinsic function: `x86_mm_adds_ep16` + --> $DIR/E0441.rs:18:5 + | +18 | fn x86_mm_adds_ep16(x: i16x8, y: i16x8) -> i16x8; //~ ERROR E0441 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0442.rs b/src/test/ui/error-codes/E0442.rs similarity index 100% rename from src/test/compile-fail/E0442.rs rename to src/test/ui/error-codes/E0442.rs diff --git a/src/test/ui/error-codes/E0442.stderr b/src/test/ui/error-codes/E0442.stderr new file mode 100644 index 0000000000000..6f19fd17eb2df --- /dev/null +++ b/src/test/ui/error-codes/E0442.stderr @@ -0,0 +1,20 @@ +error[E0442]: intrinsic argument 1 has wrong type: found vector with length 16, expected length 8 + --> $DIR/E0442.rs:23:5 + | +23 | fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0442]: intrinsic argument 2 has wrong type: found vector with length 4, expected length 8 + --> $DIR/E0442.rs:23:5 + | +23 | fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0442]: intrinsic return value has wrong type: found vector with length 2, expected length 8 + --> $DIR/E0442.rs:23:5 + | +23 | fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/src/test/compile-fail/E0443.rs b/src/test/ui/error-codes/E0443.rs similarity index 100% rename from src/test/compile-fail/E0443.rs rename to src/test/ui/error-codes/E0443.rs diff --git a/src/test/ui/error-codes/E0443.stderr b/src/test/ui/error-codes/E0443.stderr new file mode 100644 index 0000000000000..ebf8ef5ccf102 --- /dev/null +++ b/src/test/ui/error-codes/E0443.stderr @@ -0,0 +1,8 @@ +error[E0443]: intrinsic return value has wrong type: found `i64x8`, expected `i16x8` which was used for this vector type previously in this signature + --> $DIR/E0443.rs:20:5 + | +20 | fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i64x8; //~ ERROR E0443 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0444.rs b/src/test/ui/error-codes/E0444.rs similarity index 100% rename from src/test/compile-fail/E0444.rs rename to src/test/ui/error-codes/E0444.rs diff --git a/src/test/ui/error-codes/E0444.stderr b/src/test/ui/error-codes/E0444.stderr new file mode 100644 index 0000000000000..e44d9457045c4 --- /dev/null +++ b/src/test/ui/error-codes/E0444.stderr @@ -0,0 +1,8 @@ +error[E0444]: platform-specific intrinsic has invalid number of arguments: found 3, expected 1 + --> $DIR/E0444.rs:18:5 + | +18 | fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ ERROR E0444 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0445.rs b/src/test/ui/error-codes/E0445.rs similarity index 100% rename from src/test/compile-fail/E0445.rs rename to src/test/ui/error-codes/E0445.rs diff --git a/src/test/ui/error-codes/E0445.stderr b/src/test/ui/error-codes/E0445.stderr new file mode 100644 index 0000000000000..7b599543e00c6 --- /dev/null +++ b/src/test/ui/error-codes/E0445.stderr @@ -0,0 +1,20 @@ +error[E0445]: private trait `Foo` in public interface + --> $DIR/E0445.rs:15:1 + | +15 | pub trait Bar : Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait + +error[E0445]: private trait `Foo` in public interface + --> $DIR/E0445.rs:18:1 + | +18 | pub struct Bar2(pub T); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait + +error[E0445]: private trait `Foo` in public interface + --> $DIR/E0445.rs:21:1 + | +21 | pub fn foo (t: T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait + +error: aborting due to 3 previous errors + diff --git a/src/test/compile-fail/E0446.rs b/src/test/ui/error-codes/E0446.rs similarity index 100% rename from src/test/compile-fail/E0446.rs rename to src/test/ui/error-codes/E0446.rs diff --git a/src/test/ui/error-codes/E0446.stderr b/src/test/ui/error-codes/E0446.stderr new file mode 100644 index 0000000000000..1b61ca9b1773b --- /dev/null +++ b/src/test/ui/error-codes/E0446.stderr @@ -0,0 +1,10 @@ +error[E0446]: private type `Foo::Bar` in public interface + --> $DIR/E0446.rs:14:5 + | +14 | / pub fn bar() -> Bar { //~ ERROR E0446 +15 | | Bar(0) +16 | | } + | |_____^ can't leak private type + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0449.rs b/src/test/ui/error-codes/E0449.rs similarity index 100% rename from src/test/compile-fail/E0449.rs rename to src/test/ui/error-codes/E0449.rs diff --git a/src/test/ui/error-codes/E0449.stderr b/src/test/ui/error-codes/E0449.stderr new file mode 100644 index 0000000000000..2270167303a80 --- /dev/null +++ b/src/test/ui/error-codes/E0449.stderr @@ -0,0 +1,24 @@ +error[E0449]: unnecessary visibility qualifier + --> $DIR/E0449.rs:17:1 + | +17 | pub impl Bar {} //~ ERROR E0449 + | ^^^^^^^^^^^^^^^ `pub` not needed here + | + = note: place qualifiers on individual impl items instead + +error[E0449]: unnecessary visibility qualifier + --> $DIR/E0449.rs:19:1 + | +19 | / pub impl Foo for Bar { //~ ERROR E0449 +20 | | pub fn foo() {} //~ ERROR E0449 +21 | | } + | |_^ `pub` not needed here + +error[E0449]: unnecessary visibility qualifier + --> $DIR/E0449.rs:20:5 + | +20 | pub fn foo() {} //~ ERROR E0449 + | ^^^^^^^^^^^^^^^ `pub` not needed here + +error: aborting due to 3 previous errors + diff --git a/src/test/compile-fail/E0451.rs b/src/test/ui/error-codes/E0451.rs similarity index 100% rename from src/test/compile-fail/E0451.rs rename to src/test/ui/error-codes/E0451.rs diff --git a/src/test/ui/error-codes/E0451.stderr b/src/test/ui/error-codes/E0451.stderr new file mode 100644 index 0000000000000..0c29bee849b3b --- /dev/null +++ b/src/test/ui/error-codes/E0451.stderr @@ -0,0 +1,14 @@ +error[E0451]: field `b` of struct `Bar::Foo` is private + --> $DIR/E0451.rs:24:23 + | +24 | let Bar::Foo{a:a, b:b} = foo; //~ ERROR E0451 + | ^^^ field `b` is private + +error[E0451]: field `b` of struct `Bar::Foo` is private + --> $DIR/E0451.rs:28:29 + | +28 | let f = Bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451 + | ^^^^ field `b` is private + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0452.rs b/src/test/ui/error-codes/E0452.rs similarity index 100% rename from src/test/compile-fail/E0452.rs rename to src/test/ui/error-codes/E0452.rs diff --git a/src/test/ui/error-codes/E0452.stderr b/src/test/ui/error-codes/E0452.stderr new file mode 100644 index 0000000000000..d63d0edc2c60c --- /dev/null +++ b/src/test/ui/error-codes/E0452.stderr @@ -0,0 +1,8 @@ +error[E0452]: malformed lint attribute + --> $DIR/E0452.rs:11:10 + | +11 | #![allow(foo = "")] //~ ERROR E0452 + | ^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0453.rs b/src/test/ui/error-codes/E0453.rs similarity index 100% rename from src/test/compile-fail/E0453.rs rename to src/test/ui/error-codes/E0453.rs diff --git a/src/test/ui/error-codes/E0453.stderr b/src/test/ui/error-codes/E0453.stderr new file mode 100644 index 0000000000000..467784f336745 --- /dev/null +++ b/src/test/ui/error-codes/E0453.stderr @@ -0,0 +1,11 @@ +error[E0453]: allow(non_snake_case) overruled by outer forbid(non_snake_case) + --> $DIR/E0453.rs:13:9 + | +11 | #![forbid(non_snake_case)] + | -------------- `forbid` level set here +12 | +13 | #[allow(non_snake_case)] + | ^^^^^^^^^^^^^^ overruled by previous forbid + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0454.rs b/src/test/ui/error-codes/E0454.rs similarity index 100% rename from src/test/compile-fail/E0454.rs rename to src/test/ui/error-codes/E0454.rs diff --git a/src/test/ui/error-codes/E0454.stderr b/src/test/ui/error-codes/E0454.stderr new file mode 100644 index 0000000000000..aee8b53e39dd5 --- /dev/null +++ b/src/test/ui/error-codes/E0454.stderr @@ -0,0 +1,8 @@ +error[E0454]: #[link(name = "")] given with empty name + --> $DIR/E0454.rs:11:1 + | +11 | #[link(name = "")] extern {} + | ^^^^^^^^^^^^^^^^^^ empty name given + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0458.rs b/src/test/ui/error-codes/E0458.rs similarity index 100% rename from src/test/compile-fail/E0458.rs rename to src/test/ui/error-codes/E0458.rs diff --git a/src/test/ui/error-codes/E0458.stderr b/src/test/ui/error-codes/E0458.stderr new file mode 100644 index 0000000000000..9cdd0d5f3003a --- /dev/null +++ b/src/test/ui/error-codes/E0458.stderr @@ -0,0 +1,14 @@ +error[E0458]: unknown kind: `wonderful_unicorn` + --> $DIR/E0458.rs:11:1 + | +11 | #[link(kind = "wonderful_unicorn")] extern {} //~ ERROR E0458 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unknown kind + +error[E0459]: #[link(...)] specified without `name = "foo"` + --> $DIR/E0458.rs:11:1 + | +11 | #[link(kind = "wonderful_unicorn")] extern {} //~ ERROR E0458 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `name` argument + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0459.rs b/src/test/ui/error-codes/E0459.rs similarity index 100% rename from src/test/compile-fail/E0459.rs rename to src/test/ui/error-codes/E0459.rs diff --git a/src/test/ui/error-codes/E0459.stderr b/src/test/ui/error-codes/E0459.stderr new file mode 100644 index 0000000000000..512788e1948a7 --- /dev/null +++ b/src/test/ui/error-codes/E0459.stderr @@ -0,0 +1,8 @@ +error[E0459]: #[link(...)] specified without `name = "foo"` + --> $DIR/E0459.rs:11:1 + | +11 | #[link(kind = "dylib")] extern {} //~ ERROR E0459 + | ^^^^^^^^^^^^^^^^^^^^^^^ missing `name` argument + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0463.rs b/src/test/ui/error-codes/E0463.rs similarity index 100% rename from src/test/compile-fail/E0463.rs rename to src/test/ui/error-codes/E0463.rs diff --git a/src/test/ui/error-codes/E0463.stderr b/src/test/ui/error-codes/E0463.stderr new file mode 100644 index 0000000000000..208c00cc7c977 --- /dev/null +++ b/src/test/ui/error-codes/E0463.stderr @@ -0,0 +1,8 @@ +error[E0463]: can't find crate for `cookie_monster` + --> $DIR/E0463.rs:12:11 + | +12 | #![plugin(cookie_monster)] + | ^^^^^^^^^^^^^^ can't find crate + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0478.rs b/src/test/ui/error-codes/E0478.rs similarity index 100% rename from src/test/compile-fail/E0478.rs rename to src/test/ui/error-codes/E0478.rs diff --git a/src/test/ui/error-codes/E0478.stderr b/src/test/ui/error-codes/E0478.stderr new file mode 100644 index 0000000000000..f909fa48c2769 --- /dev/null +++ b/src/test/ui/error-codes/E0478.stderr @@ -0,0 +1,19 @@ +error[E0478]: lifetime bound not satisfied + --> $DIR/E0478.rs:14:5 + | +14 | child: Box + 'SnowWhite>, //~ ERROR E0478 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: lifetime parameter instantiated with the lifetime 'SnowWhite as defined on the struct at 13:1 + --> $DIR/E0478.rs:13:1 + | +13 | struct Prince<'kiss, 'SnowWhite> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: but lifetime parameter must outlive the lifetime 'kiss as defined on the struct at 13:1 + --> $DIR/E0478.rs:13:1 + | +13 | struct Prince<'kiss, 'SnowWhite> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0492.rs b/src/test/ui/error-codes/E0492.rs similarity index 100% rename from src/test/compile-fail/E0492.rs rename to src/test/ui/error-codes/E0492.rs diff --git a/src/test/ui/error-codes/E0492.stderr b/src/test/ui/error-codes/E0492.stderr new file mode 100644 index 0000000000000..c19896623128f --- /dev/null +++ b/src/test/ui/error-codes/E0492.stderr @@ -0,0 +1,8 @@ +error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead + --> $DIR/E0492.rs:14:34 + | +14 | static B: &'static AtomicUsize = &A; //~ ERROR E0492 + | ^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0494.rs b/src/test/ui/error-codes/E0494.rs similarity index 100% rename from src/test/compile-fail/E0494.rs rename to src/test/ui/error-codes/E0494.rs diff --git a/src/test/ui/error-codes/E0494.stderr b/src/test/ui/error-codes/E0494.stderr new file mode 100644 index 0000000000000..1d5ded5bd9aa1 --- /dev/null +++ b/src/test/ui/error-codes/E0494.stderr @@ -0,0 +1,8 @@ +error[E0494]: cannot refer to the interior of another static, use a constant instead + --> $DIR/E0494.rs:16:27 + | +16 | static A : &'static u32 = &S.a; //~ ERROR E0494 + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0496.rs b/src/test/ui/error-codes/E0496.rs similarity index 100% rename from src/test/compile-fail/E0496.rs rename to src/test/ui/error-codes/E0496.rs diff --git a/src/test/ui/error-codes/E0496.stderr b/src/test/ui/error-codes/E0496.stderr new file mode 100644 index 0000000000000..ab9a08a534897 --- /dev/null +++ b/src/test/ui/error-codes/E0496.stderr @@ -0,0 +1,10 @@ +error[E0496]: lifetime name `'a` shadows a lifetime name that is already in scope + --> $DIR/E0496.rs:16:10 + | +15 | impl<'a> Foo<'a> { + | -- first declared here +16 | fn f<'a>(x: &'a i32) { //~ ERROR E0496 + | ^^ lifetime 'a already in scope + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0499.rs b/src/test/ui/error-codes/E0499.rs similarity index 100% rename from src/test/compile-fail/E0499.rs rename to src/test/ui/error-codes/E0499.rs diff --git a/src/test/ui/error-codes/E0499.stderr b/src/test/ui/error-codes/E0499.stderr new file mode 100644 index 0000000000000..c3057d9b558d7 --- /dev/null +++ b/src/test/ui/error-codes/E0499.stderr @@ -0,0 +1,12 @@ +error[E0499]: cannot borrow `i` as mutable more than once at a time + --> $DIR/E0499.rs:14:22 + | +13 | let mut x = &mut i; + | - first mutable borrow occurs here +14 | let mut a = &mut i; //~ ERROR E0499 + | ^ second mutable borrow occurs here +15 | } + | - first borrow ends here + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0502.rs b/src/test/ui/error-codes/E0502.rs similarity index 100% rename from src/test/compile-fail/E0502.rs rename to src/test/ui/error-codes/E0502.rs diff --git a/src/test/ui/error-codes/E0502.stderr b/src/test/ui/error-codes/E0502.stderr new file mode 100644 index 0000000000000..e578cffe56463 --- /dev/null +++ b/src/test/ui/error-codes/E0502.stderr @@ -0,0 +1,12 @@ +error[E0502]: cannot borrow `*a` as mutable because `a` is also borrowed as immutable + --> $DIR/E0502.rs:14:9 + | +13 | let ref y = a; + | ----- immutable borrow occurs here +14 | bar(a); //~ ERROR E0502 + | ^ mutable borrow occurs here +15 | } + | - immutable borrow ends here + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0503.rs b/src/test/ui/error-codes/E0503.rs similarity index 100% rename from src/test/compile-fail/E0503.rs rename to src/test/ui/error-codes/E0503.rs diff --git a/src/test/ui/error-codes/E0503.stderr b/src/test/ui/error-codes/E0503.stderr new file mode 100644 index 0000000000000..112e2c477802e --- /dev/null +++ b/src/test/ui/error-codes/E0503.stderr @@ -0,0 +1,10 @@ +error[E0503]: cannot use `value` because it was mutably borrowed + --> $DIR/E0503.rs:14:16 + | +13 | let _borrow = &mut value; + | ----- borrow of `value` occurs here +14 | let _sum = value + 1; //~ ERROR E0503 + | ^^^^^ use of borrowed `value` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0504.rs b/src/test/ui/error-codes/E0504.rs similarity index 100% rename from src/test/compile-fail/E0504.rs rename to src/test/ui/error-codes/E0504.rs diff --git a/src/test/ui/error-codes/E0504.stderr b/src/test/ui/error-codes/E0504.stderr new file mode 100644 index 0000000000000..0f1b183dba92f --- /dev/null +++ b/src/test/ui/error-codes/E0504.stderr @@ -0,0 +1,11 @@ +error[E0504]: cannot move `fancy_num` into closure because it is borrowed + --> $DIR/E0504.rs:20:40 + | +17 | let fancy_ref = &fancy_num; + | --------- borrow of `fancy_num` occurs here +... +20 | println!("child function: {}", fancy_num.num); //~ ERROR E0504 + | ^^^^^^^^^ move into closure occurs here + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0505.rs b/src/test/ui/error-codes/E0505.rs similarity index 100% rename from src/test/compile-fail/E0505.rs rename to src/test/ui/error-codes/E0505.rs diff --git a/src/test/ui/error-codes/E0505.stderr b/src/test/ui/error-codes/E0505.stderr new file mode 100644 index 0000000000000..dfb327d48eaa5 --- /dev/null +++ b/src/test/ui/error-codes/E0505.stderr @@ -0,0 +1,10 @@ +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/E0505.rs:19:13 + | +18 | let _ref_to_val: &Value = &x; + | - borrow of `x` occurs here +19 | eat(x); //~ ERROR E0505 + | ^ move out of `x` occurs here + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0507.rs b/src/test/ui/error-codes/E0507.rs similarity index 100% rename from src/test/compile-fail/E0507.rs rename to src/test/ui/error-codes/E0507.rs diff --git a/src/test/ui/error-codes/E0507.stderr b/src/test/ui/error-codes/E0507.stderr new file mode 100644 index 0000000000000..407ebb8fc7be5 --- /dev/null +++ b/src/test/ui/error-codes/E0507.stderr @@ -0,0 +1,8 @@ +error[E0507]: cannot move out of borrowed content + --> $DIR/E0507.rs:22:5 + | +22 | x.borrow().nothing_is_true(); //~ ERROR E0507 + | ^^^^^^^^^^ cannot move out of borrowed content + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0509.rs b/src/test/ui/error-codes/E0509.rs similarity index 100% rename from src/test/compile-fail/E0509.rs rename to src/test/ui/error-codes/E0509.rs diff --git a/src/test/ui/error-codes/E0509.stderr b/src/test/ui/error-codes/E0509.stderr new file mode 100644 index 0000000000000..6da0fdbeb34e1 --- /dev/null +++ b/src/test/ui/error-codes/E0509.stderr @@ -0,0 +1,11 @@ +error[E0509]: cannot move out of type `DropStruct`, which implements the `Drop` trait + --> $DIR/E0509.rs:26:23 + | +26 | let fancy_field = drop_struct.fancy; //~ ERROR E0509 + | ^^^^^^^^^^^^^^^^^ + | | + | cannot move out of here + | help: consider using a reference instead: `&drop_struct.fancy` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0511.rs b/src/test/ui/error-codes/E0511.rs similarity index 100% rename from src/test/compile-fail/E0511.rs rename to src/test/ui/error-codes/E0511.rs diff --git a/src/test/ui/error-codes/E0511.stderr b/src/test/ui/error-codes/E0511.stderr new file mode 100644 index 0000000000000..b714350393b6a --- /dev/null +++ b/src/test/ui/error-codes/E0511.stderr @@ -0,0 +1,8 @@ +error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/E0511.rs:18:14 + | +18 | unsafe { simd_add(0, 1); } //~ ERROR E0511 + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0512.rs b/src/test/ui/error-codes/E0512.rs similarity index 100% rename from src/test/compile-fail/E0512.rs rename to src/test/ui/error-codes/E0512.rs diff --git a/src/test/ui/error-codes/E0512.stderr b/src/test/ui/error-codes/E0512.stderr new file mode 100644 index 0000000000000..ad25bb216a390 --- /dev/null +++ b/src/test/ui/error-codes/E0512.stderr @@ -0,0 +1,11 @@ +error[E0512]: transmute called with types of different sizes + --> $DIR/E0512.rs:14:23 + | +14 | unsafe { takes_u8(::std::mem::transmute(0u16)); } //~ ERROR E0512 + | ^^^^^^^^^^^^^^^^^^^^^ + | + = note: source type: u16 (16 bits) + = note: target type: u8 (8 bits) + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0516.rs b/src/test/ui/error-codes/E0516.rs similarity index 100% rename from src/test/compile-fail/E0516.rs rename to src/test/ui/error-codes/E0516.rs diff --git a/src/test/ui/error-codes/E0516.stderr b/src/test/ui/error-codes/E0516.stderr new file mode 100644 index 0000000000000..620929653f665 --- /dev/null +++ b/src/test/ui/error-codes/E0516.stderr @@ -0,0 +1,8 @@ +error[E0516]: `typeof` is a reserved keyword but unimplemented + --> $DIR/E0516.rs:12:12 + | +12 | let x: typeof(92) = 92; //~ ERROR E0516 + | ^^^^^^^^^^ reserved keyword + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0517.rs b/src/test/ui/error-codes/E0517.rs similarity index 100% rename from src/test/compile-fail/E0517.rs rename to src/test/ui/error-codes/E0517.rs diff --git a/src/test/ui/error-codes/E0517.stderr b/src/test/ui/error-codes/E0517.stderr new file mode 100644 index 0000000000000..968c47fa7a26f --- /dev/null +++ b/src/test/ui/error-codes/E0517.stderr @@ -0,0 +1,35 @@ +error[E0517]: attribute should be applied to struct, enum or union + --> $DIR/E0517.rs:11:8 + | +11 | #[repr(C)] //~ ERROR: E0517 + | ^ +12 | type Foo = u8; + | -------------- not a struct, enum or union + +error[E0517]: attribute should be applied to struct or union + --> $DIR/E0517.rs:14:8 + | +14 | #[repr(packed)] //~ ERROR: E0517 + | ^^^^^^ +15 | enum Foo2 {Bar, Baz} + | -------------------- not a struct or union + +error[E0517]: attribute should be applied to enum + --> $DIR/E0517.rs:17:8 + | +17 | #[repr(u8)] //~ ERROR: E0517 + | ^^ +18 | struct Foo3 {bar: bool, baz: bool} + | ---------------------------------- not an enum + +error[E0517]: attribute should be applied to struct, enum or union + --> $DIR/E0517.rs:20:8 + | +20 | #[repr(C)] //~ ERROR: E0517 + | ^ +21 | / impl Foo3 { +22 | | } + | |_- not a struct, enum or union + +error: aborting due to 4 previous errors + diff --git a/src/test/compile-fail/E0518.rs b/src/test/ui/error-codes/E0518.rs similarity index 100% rename from src/test/compile-fail/E0518.rs rename to src/test/ui/error-codes/E0518.rs diff --git a/src/test/ui/error-codes/E0518.stderr b/src/test/ui/error-codes/E0518.stderr new file mode 100644 index 0000000000000..99a4a63cc9f2e --- /dev/null +++ b/src/test/ui/error-codes/E0518.stderr @@ -0,0 +1,19 @@ +error[E0518]: attribute should be applied to function + --> $DIR/E0518.rs:11:1 + | +11 | #[inline(always)] //~ ERROR: E0518 + | ^^^^^^^^^^^^^^^^^ +12 | struct Foo; + | ----------- not a function + +error[E0518]: attribute should be applied to function + --> $DIR/E0518.rs:14:1 + | +14 | #[inline(never)] //~ ERROR: E0518 + | ^^^^^^^^^^^^^^^^ +15 | / impl Foo { +16 | | } + | |_- not a function + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0520.rs b/src/test/ui/error-codes/E0520.rs similarity index 100% rename from src/test/compile-fail/E0520.rs rename to src/test/ui/error-codes/E0520.rs diff --git a/src/test/ui/error-codes/E0520.stderr b/src/test/ui/error-codes/E0520.stderr new file mode 100644 index 0000000000000..272c38859ab0a --- /dev/null +++ b/src/test/ui/error-codes/E0520.stderr @@ -0,0 +1,15 @@ +error[E0520]: `fly` specializes an item from a parent `impl`, but that item is not marked `default` + --> $DIR/E0520.rs:26:5 + | +21 | / impl SpaceLlama for T { +22 | | fn fly(&self) {} +23 | | } + | |_- parent `impl` is here +... +26 | default fn fly(&self) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `fly` + | + = note: to specialize, `fly` in the parent `impl` must be marked `default` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0522.rs b/src/test/ui/error-codes/E0522.rs similarity index 100% rename from src/test/compile-fail/E0522.rs rename to src/test/ui/error-codes/E0522.rs diff --git a/src/test/ui/error-codes/E0522.stderr b/src/test/ui/error-codes/E0522.stderr new file mode 100644 index 0000000000000..819fab0088f55 --- /dev/null +++ b/src/test/ui/error-codes/E0522.stderr @@ -0,0 +1,10 @@ +error[E0601]: main function not found + +error[E0522]: definition of an unknown language item: `cookie` + --> $DIR/E0522.rs:13:1 + | +13 | #[lang = "cookie"] + | ^^^^^^^^^^^^^^^^^^ definition of unknown language item `cookie` + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0527.rs b/src/test/ui/error-codes/E0527.rs similarity index 100% rename from src/test/compile-fail/E0527.rs rename to src/test/ui/error-codes/E0527.rs diff --git a/src/test/ui/error-codes/E0527.stderr b/src/test/ui/error-codes/E0527.stderr new file mode 100644 index 0000000000000..7cd705e6d0b9d --- /dev/null +++ b/src/test/ui/error-codes/E0527.stderr @@ -0,0 +1,8 @@ +error[E0527]: pattern requires 2 elements but array has 4 + --> $DIR/E0527.rs:16:10 + | +16 | &[a, b] => { + | ^^^^^^ expected 4 elements + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0528.rs b/src/test/ui/error-codes/E0528.rs similarity index 100% rename from src/test/compile-fail/E0528.rs rename to src/test/ui/error-codes/E0528.rs diff --git a/src/test/ui/error-codes/E0528.stderr b/src/test/ui/error-codes/E0528.stderr new file mode 100644 index 0000000000000..ff75b07ced602 --- /dev/null +++ b/src/test/ui/error-codes/E0528.stderr @@ -0,0 +1,8 @@ +error[E0528]: pattern requires at least 3 elements but array has 2 + --> $DIR/E0528.rs:16:10 + | +16 | &[a, b, c, rest..] => { + | ^^^^^^^^^^^^^^^^^ pattern cannot match array of 2 elements + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0529.rs b/src/test/ui/error-codes/E0529.rs similarity index 100% rename from src/test/compile-fail/E0529.rs rename to src/test/ui/error-codes/E0529.rs diff --git a/src/test/ui/error-codes/E0529.stderr b/src/test/ui/error-codes/E0529.stderr new file mode 100644 index 0000000000000..be9039be2b668 --- /dev/null +++ b/src/test/ui/error-codes/E0529.stderr @@ -0,0 +1,8 @@ +error[E0529]: expected an array or slice, found `f32` + --> $DIR/E0529.rs:16:9 + | +16 | [a, b] => { + | ^^^^^^ pattern cannot match with input type `f32` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0530.rs b/src/test/ui/error-codes/E0530.rs similarity index 100% rename from src/test/compile-fail/E0530.rs rename to src/test/ui/error-codes/E0530.rs diff --git a/src/test/ui/error-codes/E0530.stderr b/src/test/ui/error-codes/E0530.stderr new file mode 100644 index 0000000000000..7c0306cc772fa --- /dev/null +++ b/src/test/ui/error-codes/E0530.stderr @@ -0,0 +1,11 @@ +error[E0530]: match bindings cannot shadow statics + --> $DIR/E0530.rs:16:9 + | +12 | static TEST: i32 = 0; + | --------------------- a static `TEST` is defined here +... +16 | TEST => {} //~ ERROR E0530 + | ^^^^ cannot be named the same as a static + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0532.rs b/src/test/ui/error-codes/E0532.rs similarity index 100% rename from src/test/compile-fail/E0532.rs rename to src/test/ui/error-codes/E0532.rs diff --git a/src/test/ui/error-codes/E0532.stderr b/src/test/ui/error-codes/E0532.stderr new file mode 100644 index 0000000000000..4eb91ce35d44a --- /dev/null +++ b/src/test/ui/error-codes/E0532.stderr @@ -0,0 +1,8 @@ +error[E0532]: expected tuple struct/variant, found constant `StructConst1` + --> $DIR/E0532.rs:15:9 + | +15 | StructConst1(_) => { }, + | ^^^^^^^^^^^^ not a tuple struct/variant + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0534.rs b/src/test/ui/error-codes/E0534.rs similarity index 100% rename from src/test/compile-fail/E0534.rs rename to src/test/ui/error-codes/E0534.rs diff --git a/src/test/ui/error-codes/E0534.stderr b/src/test/ui/error-codes/E0534.stderr new file mode 100644 index 0000000000000..fe7a5483e59df --- /dev/null +++ b/src/test/ui/error-codes/E0534.stderr @@ -0,0 +1,8 @@ +error[E0534]: expected one argument + --> $DIR/E0534.rs:11:1 + | +11 | #[inline()] //~ ERROR E0534 + | ^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0558.rs b/src/test/ui/error-codes/E0558.rs similarity index 100% rename from src/test/compile-fail/E0558.rs rename to src/test/ui/error-codes/E0558.rs diff --git a/src/test/ui/error-codes/E0558.stderr b/src/test/ui/error-codes/E0558.stderr new file mode 100644 index 0000000000000..c116201794d47 --- /dev/null +++ b/src/test/ui/error-codes/E0558.stderr @@ -0,0 +1,8 @@ +error[E0558]: export_name attribute has invalid format + --> $DIR/E0558.rs:11:1 + | +11 | #[export_name] + | ^^^^^^^^^^^^^^ did you mean #[export_name="*"]? + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0559.rs b/src/test/ui/error-codes/E0559.rs similarity index 100% rename from src/test/compile-fail/E0559.rs rename to src/test/ui/error-codes/E0559.rs diff --git a/src/test/ui/error-codes/E0559.stderr b/src/test/ui/error-codes/E0559.stderr new file mode 100644 index 0000000000000..5d145a9518095 --- /dev/null +++ b/src/test/ui/error-codes/E0559.stderr @@ -0,0 +1,10 @@ +error[E0559]: variant `Field::Fool` has no field named `joke` + --> $DIR/E0559.rs:16:27 + | +16 | let s = Field::Fool { joke: 0 }; + | ^^^^^ `Field::Fool` does not have this field + | + = note: available fields are: `x` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0560.rs b/src/test/ui/error-codes/E0560.rs similarity index 100% rename from src/test/compile-fail/E0560.rs rename to src/test/ui/error-codes/E0560.rs diff --git a/src/test/ui/error-codes/E0560.stderr b/src/test/ui/error-codes/E0560.stderr new file mode 100644 index 0000000000000..a0185aa8af64b --- /dev/null +++ b/src/test/ui/error-codes/E0560.stderr @@ -0,0 +1,10 @@ +error[E0560]: struct `Simba` has no field named `father` + --> $DIR/E0560.rs:16:32 + | +16 | let s = Simba { mother: 1, father: 0 }; + | ^^^^^^^ `Simba` does not have this field + | + = note: available fields are: `mother` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0565-1.rs b/src/test/ui/error-codes/E0565-1.rs similarity index 100% rename from src/test/compile-fail/E0565-1.rs rename to src/test/ui/error-codes/E0565-1.rs diff --git a/src/test/ui/error-codes/E0565-1.stderr b/src/test/ui/error-codes/E0565-1.stderr new file mode 100644 index 0000000000000..65b917ad4bd32 --- /dev/null +++ b/src/test/ui/error-codes/E0565-1.stderr @@ -0,0 +1,8 @@ +error[E0565]: unsupported literal + --> $DIR/E0565-1.rs:14:14 + | +14 | #[deprecated("since")] //~ ERROR E0565 + | ^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0565.rs b/src/test/ui/error-codes/E0565.rs similarity index 100% rename from src/test/compile-fail/E0565.rs rename to src/test/ui/error-codes/E0565.rs diff --git a/src/test/ui/error-codes/E0565.stderr b/src/test/ui/error-codes/E0565.stderr new file mode 100644 index 0000000000000..0041b7689a671 --- /dev/null +++ b/src/test/ui/error-codes/E0565.stderr @@ -0,0 +1,8 @@ +error[E0565]: unsupported literal + --> $DIR/E0565.rs:14:8 + | +14 | #[repr("C")] //~ ERROR E0565 + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0572.rs b/src/test/ui/error-codes/E0572.rs similarity index 100% rename from src/test/compile-fail/E0572.rs rename to src/test/ui/error-codes/E0572.rs diff --git a/src/test/ui/error-codes/E0572.stderr b/src/test/ui/error-codes/E0572.stderr new file mode 100644 index 0000000000000..cad313b90a613 --- /dev/null +++ b/src/test/ui/error-codes/E0572.stderr @@ -0,0 +1,8 @@ +error[E0572]: return statement outside of function body + --> $DIR/E0572.rs:11:18 + | +11 | const FOO: u32 = return 0; //~ ERROR E0572 + | ^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0582.rs b/src/test/ui/error-codes/E0582.rs similarity index 100% rename from src/test/compile-fail/E0582.rs rename to src/test/ui/error-codes/E0582.rs diff --git a/src/test/ui/error-codes/E0582.stderr b/src/test/ui/error-codes/E0582.stderr new file mode 100644 index 0000000000000..ac20683402302 --- /dev/null +++ b/src/test/ui/error-codes/E0582.stderr @@ -0,0 +1,14 @@ +error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types + --> $DIR/E0582.rs:38:30 + | +38 | where F: for<'a> Fn() -> Option<&'a i32> + | ^^^^^^^^^^^^^^^ + +error[E0582]: binding for associated type `Item` references lifetime `'a`, which does not appear in the trait input types + --> $DIR/E0582.rs:46:31 + | +46 | where F: for<'a> Iterator + | ^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0585.rs b/src/test/ui/error-codes/E0585.rs similarity index 100% rename from src/test/compile-fail/E0585.rs rename to src/test/ui/error-codes/E0585.rs diff --git a/src/test/ui/error-codes/E0585.stderr b/src/test/ui/error-codes/E0585.stderr new file mode 100644 index 0000000000000..49967f4ad81d5 --- /dev/null +++ b/src/test/ui/error-codes/E0585.stderr @@ -0,0 +1,10 @@ +error[E0585]: found a documentation comment that doesn't document anything + --> $DIR/E0585.rs:12:5 + | +12 | /// Hello! I'm useless... + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: doc comments must come before what they document, maybe a comment was intended with `//`? + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0586.rs b/src/test/ui/error-codes/E0586.rs similarity index 100% rename from src/test/compile-fail/E0586.rs rename to src/test/ui/error-codes/E0586.rs diff --git a/src/test/ui/error-codes/E0586.stderr b/src/test/ui/error-codes/E0586.stderr new file mode 100644 index 0000000000000..3cf16bdc3c318 --- /dev/null +++ b/src/test/ui/error-codes/E0586.stderr @@ -0,0 +1,10 @@ +error[E0586]: inclusive range with no end + --> $DIR/E0586.rs:13:22 + | +13 | let x = &tmp[1..=]; //~ ERROR E0586 + | ^ + | + = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0597.rs b/src/test/ui/error-codes/E0597.rs similarity index 100% rename from src/test/compile-fail/E0597.rs rename to src/test/ui/error-codes/E0597.rs diff --git a/src/test/ui/error-codes/E0597.stderr b/src/test/ui/error-codes/E0597.stderr new file mode 100644 index 0000000000000..7316ee6475f18 --- /dev/null +++ b/src/test/ui/error-codes/E0597.stderr @@ -0,0 +1,13 @@ +error[E0597]: `y` does not live long enough + --> $DIR/E0597.rs:18:17 + | +18 | x.x = Some(&y); + | ^ borrowed value does not live long enough +19 | //~^ `y` does not live long enough [E0597] +20 | } + | - `y` dropped here while still borrowed + | + = note: values in a scope are dropped in the opposite order they are created + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0599.rs b/src/test/ui/error-codes/E0599.rs similarity index 100% rename from src/test/compile-fail/E0599.rs rename to src/test/ui/error-codes/E0599.rs diff --git a/src/test/ui/error-codes/E0599.stderr b/src/test/ui/error-codes/E0599.stderr new file mode 100644 index 0000000000000..0274506926f8d --- /dev/null +++ b/src/test/ui/error-codes/E0599.stderr @@ -0,0 +1,11 @@ +error[E0599]: no associated item named `NotEvenReal` found for type `Foo` in the current scope + --> $DIR/E0599.rs:14:15 + | +11 | struct Foo; + | ----------- associated item `NotEvenReal` not found for this +... +14 | || if let Foo::NotEvenReal() = Foo {}; //~ ERROR E0599 + | ^^^^^^^^^^^^^^^^^^ associated item not found in `Foo` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0600.rs b/src/test/ui/error-codes/E0600.rs similarity index 100% rename from src/test/compile-fail/E0600.rs rename to src/test/ui/error-codes/E0600.rs diff --git a/src/test/ui/error-codes/E0600.stderr b/src/test/ui/error-codes/E0600.stderr new file mode 100644 index 0000000000000..fec5f4169196e --- /dev/null +++ b/src/test/ui/error-codes/E0600.stderr @@ -0,0 +1,8 @@ +error[E0600]: cannot apply unary operator `!` to type `&'static str` + --> $DIR/E0600.rs:12:5 + | +12 | !"a"; //~ ERROR E0600 + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0602.rs b/src/test/ui/error-codes/E0602.rs similarity index 100% rename from src/test/compile-fail/E0602.rs rename to src/test/ui/error-codes/E0602.rs diff --git a/src/test/ui/error-codes/E0602.stderr b/src/test/ui/error-codes/E0602.stderr new file mode 100644 index 0000000000000..cb6c05326e230 --- /dev/null +++ b/src/test/ui/error-codes/E0602.stderr @@ -0,0 +1,6 @@ +error[E0602]: unknown lint: `bogus` + | + = note: requested on the command line with `-D bogus` + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0603.rs b/src/test/ui/error-codes/E0603.rs similarity index 100% rename from src/test/compile-fail/E0603.rs rename to src/test/ui/error-codes/E0603.rs diff --git a/src/test/ui/error-codes/E0603.stderr b/src/test/ui/error-codes/E0603.stderr new file mode 100644 index 0000000000000..1d8e2fa9340e3 --- /dev/null +++ b/src/test/ui/error-codes/E0603.stderr @@ -0,0 +1,8 @@ +error[E0603]: constant `PRIVATE` is private + --> $DIR/E0603.rs:16:5 + | +16 | SomeModule::PRIVATE; //~ ERROR E0603 + | ^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0604.rs b/src/test/ui/error-codes/E0604.rs similarity index 100% rename from src/test/compile-fail/E0604.rs rename to src/test/ui/error-codes/E0604.rs diff --git a/src/test/ui/error-codes/E0604.stderr b/src/test/ui/error-codes/E0604.stderr new file mode 100644 index 0000000000000..78d1c4dd47654 --- /dev/null +++ b/src/test/ui/error-codes/E0604.stderr @@ -0,0 +1,8 @@ +error[E0604]: only `u8` can be cast as `char`, not `u32` + --> $DIR/E0604.rs:12:5 + | +12 | 1u32 as char; //~ ERROR E0604 + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0605.rs b/src/test/ui/error-codes/E0605.rs similarity index 100% rename from src/test/compile-fail/E0605.rs rename to src/test/ui/error-codes/E0605.rs diff --git a/src/test/ui/error-codes/E0605.stderr b/src/test/ui/error-codes/E0605.stderr new file mode 100644 index 0000000000000..0b44de25fb5cd --- /dev/null +++ b/src/test/ui/error-codes/E0605.stderr @@ -0,0 +1,18 @@ +error[E0605]: non-primitive cast: `u8` as `std::vec::Vec` + --> $DIR/E0605.rs:13:5 + | +13 | x as Vec; //~ ERROR E0605 + | ^^^^^^^^^^^^ + | + = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait + +error[E0605]: non-primitive cast: `*const u8` as `&u8` + --> $DIR/E0605.rs:16:5 + | +16 | v as &u8; //~ ERROR E0605 + | ^^^^^^^^ + | + = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0606.rs b/src/test/ui/error-codes/E0606.rs similarity index 100% rename from src/test/compile-fail/E0606.rs rename to src/test/ui/error-codes/E0606.rs diff --git a/src/test/ui/error-codes/E0606.stderr b/src/test/ui/error-codes/E0606.stderr new file mode 100644 index 0000000000000..17051da1319d9 --- /dev/null +++ b/src/test/ui/error-codes/E0606.stderr @@ -0,0 +1,14 @@ +error[E0606]: casting `&u8` as `u8` is invalid + --> $DIR/E0606.rs:12:5 + | +12 | &0u8 as u8; //~ ERROR E0606 + | ^^^^^^^^^^ cannot cast `&u8` as `u8` + | +help: did you mean `*&0u8`? + --> $DIR/E0606.rs:12:5 + | +12 | &0u8 as u8; //~ ERROR E0606 + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0607.rs b/src/test/ui/error-codes/E0607.rs similarity index 100% rename from src/test/compile-fail/E0607.rs rename to src/test/ui/error-codes/E0607.rs diff --git a/src/test/ui/error-codes/E0607.stderr b/src/test/ui/error-codes/E0607.stderr new file mode 100644 index 0000000000000..5dfe6ad59b879 --- /dev/null +++ b/src/test/ui/error-codes/E0607.stderr @@ -0,0 +1,8 @@ +error[E0607]: cannot cast thin pointer `*const u8` to fat pointer `*const [u8]` + --> $DIR/E0607.rs:13:5 + | +13 | v as *const [u8]; //~ ERROR E0607 + | ^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0608.rs b/src/test/ui/error-codes/E0608.rs similarity index 100% rename from src/test/compile-fail/E0608.rs rename to src/test/ui/error-codes/E0608.rs diff --git a/src/test/ui/error-codes/E0608.stderr b/src/test/ui/error-codes/E0608.stderr new file mode 100644 index 0000000000000..ab75fe82af350 --- /dev/null +++ b/src/test/ui/error-codes/E0608.stderr @@ -0,0 +1,8 @@ +error[E0608]: cannot index into a value of type `u8` + --> $DIR/E0608.rs:12:5 + | +12 | 0u8[2]; //~ ERROR E0608 + | ^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0609.rs b/src/test/ui/error-codes/E0609.rs similarity index 100% rename from src/test/compile-fail/E0609.rs rename to src/test/ui/error-codes/E0609.rs diff --git a/src/test/ui/error-codes/E0609.stderr b/src/test/ui/error-codes/E0609.stderr new file mode 100644 index 0000000000000..561164cd277dc --- /dev/null +++ b/src/test/ui/error-codes/E0609.stderr @@ -0,0 +1,16 @@ +error[E0609]: no field `foo` on type `Foo` + --> $DIR/E0609.rs:18:15 + | +18 | let _ = x.foo; //~ ERROR E0609 + | ^^^ unknown field + | + = note: available fields are: `x` + +error[E0609]: no field `1` on type `Bar` + --> $DIR/E0609.rs:21:5 + | +21 | y.1; //~ ERROR E0609 + | ^^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0610.rs b/src/test/ui/error-codes/E0610.rs similarity index 100% rename from src/test/compile-fail/E0610.rs rename to src/test/ui/error-codes/E0610.rs diff --git a/src/test/ui/error-codes/E0610.stderr b/src/test/ui/error-codes/E0610.stderr new file mode 100644 index 0000000000000..351e9208e95bd --- /dev/null +++ b/src/test/ui/error-codes/E0610.stderr @@ -0,0 +1,8 @@ +error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields + --> $DIR/E0610.rs:13:15 + | +13 | let _ = x.foo; //~ ERROR E0610 + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0611.rs b/src/test/ui/error-codes/E0611.rs similarity index 100% rename from src/test/compile-fail/E0611.rs rename to src/test/ui/error-codes/E0611.rs diff --git a/src/test/ui/error-codes/E0611.stderr b/src/test/ui/error-codes/E0611.stderr new file mode 100644 index 0000000000000..33fe78bc18c60 --- /dev/null +++ b/src/test/ui/error-codes/E0611.stderr @@ -0,0 +1,8 @@ +error[E0611]: field `0` of tuple-struct `a::Foo` is private + --> $DIR/E0611.rs:21:4 + | +21 | y.0; //~ ERROR E0611 + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0612.rs b/src/test/ui/error-codes/E0612.rs similarity index 100% rename from src/test/compile-fail/E0612.rs rename to src/test/ui/error-codes/E0612.rs diff --git a/src/test/ui/error-codes/E0612.stderr b/src/test/ui/error-codes/E0612.stderr new file mode 100644 index 0000000000000..21fdaf84dc94d --- /dev/null +++ b/src/test/ui/error-codes/E0612.stderr @@ -0,0 +1,8 @@ +error[E0612]: attempted out-of-bounds tuple index `1` on type `Foo` + --> $DIR/E0612.rs:15:4 + | +15 | y.1; //~ ERROR E0612 + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0614.rs b/src/test/ui/error-codes/E0614.rs similarity index 100% rename from src/test/compile-fail/E0614.rs rename to src/test/ui/error-codes/E0614.rs diff --git a/src/test/ui/error-codes/E0614.stderr b/src/test/ui/error-codes/E0614.stderr new file mode 100644 index 0000000000000..242cc36f0b9a1 --- /dev/null +++ b/src/test/ui/error-codes/E0614.stderr @@ -0,0 +1,8 @@ +error[E0614]: type `u32` cannot be dereferenced + --> $DIR/E0614.rs:13:5 + | +13 | *y; //~ ERROR E0614 + | ^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0615.rs b/src/test/ui/error-codes/E0615.rs similarity index 100% rename from src/test/compile-fail/E0615.rs rename to src/test/ui/error-codes/E0615.rs diff --git a/src/test/ui/error-codes/E0615.stderr b/src/test/ui/error-codes/E0615.stderr new file mode 100644 index 0000000000000..fb3f9269f7c2b --- /dev/null +++ b/src/test/ui/error-codes/E0615.stderr @@ -0,0 +1,10 @@ +error[E0615]: attempted to take value of method `method` on type `Foo` + --> $DIR/E0615.rs:21:7 + | +21 | f.method; //~ ERROR E0615 + | ^^^^^^ + | + = help: maybe a `()` to call it is missing? + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0616.rs b/src/test/ui/error-codes/E0616.rs similarity index 100% rename from src/test/compile-fail/E0616.rs rename to src/test/ui/error-codes/E0616.rs diff --git a/src/test/ui/error-codes/E0616.stderr b/src/test/ui/error-codes/E0616.stderr new file mode 100644 index 0000000000000..1dccd06b376d9 --- /dev/null +++ b/src/test/ui/error-codes/E0616.stderr @@ -0,0 +1,8 @@ +error[E0616]: field `x` of struct `a::Foo` is private + --> $DIR/E0616.rs:23:5 + | +23 | f.x; //~ ERROR E0616 + | ^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0617.rs b/src/test/ui/error-codes/E0617.rs similarity index 100% rename from src/test/compile-fail/E0617.rs rename to src/test/ui/error-codes/E0617.rs diff --git a/src/test/ui/error-codes/E0617.stderr b/src/test/ui/error-codes/E0617.stderr new file mode 100644 index 0000000000000..49d63538624e6 --- /dev/null +++ b/src/test/ui/error-codes/E0617.stderr @@ -0,0 +1,42 @@ +error[E0617]: can't pass `f32` to variadic function + --> $DIR/E0617.rs:19:36 + | +19 | printf(::std::ptr::null(), 0f32); + | ^^^^ help: cast the value to `c_double`: `0f32 as c_double` + +error[E0617]: can't pass `i8` to variadic function + --> $DIR/E0617.rs:22:36 + | +22 | printf(::std::ptr::null(), 0i8); + | ^^^ help: cast the value to `c_int`: `0i8 as c_int` + +error[E0617]: can't pass `i16` to variadic function + --> $DIR/E0617.rs:25:36 + | +25 | printf(::std::ptr::null(), 0i16); + | ^^^^ help: cast the value to `c_int`: `0i16 as c_int` + +error[E0617]: can't pass `u8` to variadic function + --> $DIR/E0617.rs:28:36 + | +28 | printf(::std::ptr::null(), 0u8); + | ^^^ help: cast the value to `c_uint`: `0u8 as c_uint` + +error[E0617]: can't pass `u16` to variadic function + --> $DIR/E0617.rs:31:36 + | +31 | printf(::std::ptr::null(), 0u16); + | ^^^^ help: cast the value to `c_uint`: `0u16 as c_uint` + +error[E0617]: can't pass `unsafe extern "C" fn(*const i8, ...) {printf}` to variadic function + --> $DIR/E0617.rs:34:36 + | +34 | printf(::std::ptr::null(), printf); + | ^^^^^^ +help: cast the value to `unsafe extern "C" fn(*const i8, ...)` + | +34 | printf(::std::ptr::null(), printf as unsafe extern "C" fn(*const i8, ...)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 6 previous errors + diff --git a/src/test/compile-fail/E0618.rs b/src/test/ui/error-codes/E0618.rs similarity index 100% rename from src/test/compile-fail/E0618.rs rename to src/test/ui/error-codes/E0618.rs diff --git a/src/test/ui/error-codes/E0618.stderr b/src/test/ui/error-codes/E0618.stderr new file mode 100644 index 0000000000000..8702437659693 --- /dev/null +++ b/src/test/ui/error-codes/E0618.stderr @@ -0,0 +1,23 @@ +error[E0618]: expected function, found enum variant `X::Entry` + --> $DIR/E0618.rs:16:5 + | +12 | Entry, + | ----- `X::Entry` defined here +... +16 | X::Entry(); + | ^^^^^^^^^^ not a function +help: `X::Entry` is a unit variant, you need to write it without the parenthesis + | +16 | X::Entry; + | ^^^^^^^^ + +error[E0618]: expected function, found `i32` + --> $DIR/E0618.rs:19:5 + | +18 | let x = 0i32; + | - `i32` defined here +19 | x(); + | ^^^ not a function + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0619.rs b/src/test/ui/error-codes/E0619.rs similarity index 100% rename from src/test/compile-fail/E0619.rs rename to src/test/ui/error-codes/E0619.rs diff --git a/src/test/ui/error-codes/E0619.stderr b/src/test/ui/error-codes/E0619.stderr new file mode 100644 index 0000000000000..cec336cfcec66 --- /dev/null +++ b/src/test/ui/error-codes/E0619.stderr @@ -0,0 +1,8 @@ +error[E0619]: the type of this value must be known in this context + --> $DIR/E0619.rs:15:9 + | +15 | (..) => {} //~ ERROR E0619 + | ^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0620.rs b/src/test/ui/error-codes/E0620.rs similarity index 100% rename from src/test/compile-fail/E0620.rs rename to src/test/ui/error-codes/E0620.rs diff --git a/src/test/ui/error-codes/E0620.stderr b/src/test/ui/error-codes/E0620.stderr new file mode 100644 index 0000000000000..564a9472ac9a2 --- /dev/null +++ b/src/test/ui/error-codes/E0620.stderr @@ -0,0 +1,14 @@ +error[E0620]: cast to unsized type: `&[usize; 2]` as `[usize]` + --> $DIR/E0620.rs:12:16 + | +12 | let _foo = &[1_usize, 2] as [usize]; //~ ERROR E0620 + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: consider using an implicit coercion to `&[usize]` instead + --> $DIR/E0620.rs:12:16 + | +12 | let _foo = &[1_usize, 2] as [usize]; //~ ERROR E0620 + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0621-does-not-trigger-for-closures.rs b/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.rs similarity index 100% rename from src/test/compile-fail/E0621-does-not-trigger-for-closures.rs rename to src/test/ui/error-codes/E0621-does-not-trigger-for-closures.rs diff --git a/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.stderr b/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.stderr new file mode 100644 index 0000000000000..c529a838bf739 --- /dev/null +++ b/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.stderr @@ -0,0 +1,29 @@ +error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements + --> $DIR/E0621-does-not-trigger-for-closures.rs:25:5 + | +25 | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495 + | ^^^^^^ + | +note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 25:16... + --> $DIR/E0621-does-not-trigger-for-closures.rs:25:16 + | +25 | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...so that reference does not outlive borrowed content + --> $DIR/E0621-does-not-trigger-for-closures.rs:25:45 + | +25 | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495 + | ^ +note: but, the lifetime must be valid for the call at 25:5... + --> $DIR/E0621-does-not-trigger-for-closures.rs:25:5 + | +25 | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...so type `&i32` of expression is valid during the expression + --> $DIR/E0621-does-not-trigger-for-closures.rs:25:5 + | +25 | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0622.rs b/src/test/ui/error-codes/E0622.rs similarity index 100% rename from src/test/compile-fail/E0622.rs rename to src/test/ui/error-codes/E0622.rs diff --git a/src/test/ui/error-codes/E0622.stderr b/src/test/ui/error-codes/E0622.stderr new file mode 100644 index 0000000000000..977f44a9c9781 --- /dev/null +++ b/src/test/ui/error-codes/E0622.stderr @@ -0,0 +1,8 @@ +error[E0622]: intrinsic must be a function + --> $DIR/E0622.rs:13:5 + | +13 | pub static breakpoint : unsafe extern "rust-intrinsic" fn(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected a function + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0624.rs b/src/test/ui/error-codes/E0624.rs similarity index 100% rename from src/test/compile-fail/E0624.rs rename to src/test/ui/error-codes/E0624.rs diff --git a/src/test/ui/error-codes/E0624.stderr b/src/test/ui/error-codes/E0624.stderr new file mode 100644 index 0000000000000..0afb05a8a5e81 --- /dev/null +++ b/src/test/ui/error-codes/E0624.stderr @@ -0,0 +1,8 @@ +error[E0624]: method `method` is private + --> $DIR/E0624.rs:21:9 + | +21 | foo.method(); //~ ERROR method `method` is private [E0624] + | ^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0637.rs b/src/test/ui/error-codes/E0637.rs similarity index 100% rename from src/test/compile-fail/E0637.rs rename to src/test/ui/error-codes/E0637.rs diff --git a/src/test/ui/error-codes/E0637.stderr b/src/test/ui/error-codes/E0637.stderr new file mode 100644 index 0000000000000..e314afd221e40 --- /dev/null +++ b/src/test/ui/error-codes/E0637.stderr @@ -0,0 +1,20 @@ +error[E0637]: invalid lifetime bound name: `'_` + --> $DIR/E0637.rs:12:16 + | +12 | struct Foo<'a: '_>(&'a u8); //~ ERROR invalid lifetime bound name: `'_` + | ^^ `'_` is a reserved lifetime name + +error[E0637]: invalid lifetime bound name: `'_` + --> $DIR/E0637.rs:13:12 + | +13 | fn foo<'a: '_>(_: &'a u8) {} //~ ERROR invalid lifetime bound name: `'_` + | ^^ `'_` is a reserved lifetime name + +error[E0637]: invalid lifetime bound name: `'_` + --> $DIR/E0637.rs:16:10 + | +16 | impl<'a: '_> Bar<'a> { //~ ERROR invalid lifetime bound name: `'_` + | ^^ `'_` is a reserved lifetime name + +error: aborting due to 3 previous errors + diff --git a/src/test/compile-fail/E0657.rs b/src/test/ui/error-codes/E0657.rs similarity index 100% rename from src/test/compile-fail/E0657.rs rename to src/test/ui/error-codes/E0657.rs diff --git a/src/test/ui/error-codes/E0657.stderr b/src/test/ui/error-codes/E0657.stderr new file mode 100644 index 0000000000000..d3b53d37a30a0 --- /dev/null +++ b/src/test/ui/error-codes/E0657.stderr @@ -0,0 +1,14 @@ +error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl level + --> $DIR/E0657.rs:20:32 + | +20 | -> impl for<'a> Id> + | ^^ + +error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl level + --> $DIR/E0657.rs:29:36 + | +29 | -> impl for<'a> Id> + | ^^ + +error: aborting due to 2 previous errors + diff --git a/src/test/compile-fail/E0658.rs b/src/test/ui/error-codes/E0658.rs similarity index 100% rename from src/test/compile-fail/E0658.rs rename to src/test/ui/error-codes/E0658.rs diff --git a/src/test/ui/error-codes/E0658.stderr b/src/test/ui/error-codes/E0658.stderr new file mode 100644 index 0000000000000..c18d8090233d4 --- /dev/null +++ b/src/test/ui/error-codes/E0658.stderr @@ -0,0 +1,10 @@ +error[E0658]: use of unstable library feature 'i128' (see issue #35118) + --> $DIR/E0658.rs:12:13 + | +12 | let _ = ::std::u128::MAX; //~ ERROR E0658 + | ^^^^^^^^^^^^^^^^ + | + = help: add #![feature(i128)] to the crate attributes to enable + +error: aborting due to previous error + diff --git a/src/test/compile-fail/E0659.rs b/src/test/ui/error-codes/E0659.rs similarity index 100% rename from src/test/compile-fail/E0659.rs rename to src/test/ui/error-codes/E0659.rs diff --git a/src/test/ui/error-codes/E0659.stderr b/src/test/ui/error-codes/E0659.stderr new file mode 100644 index 0000000000000..c2410e2f733bc --- /dev/null +++ b/src/test/ui/error-codes/E0659.stderr @@ -0,0 +1,20 @@ +error[E0659]: `foo` is ambiguous + --> $DIR/E0659.rs:25:5 + | +25 | collider::foo(); //~ ERROR E0659 + | ^^^^^^^^^^^^^ + | +note: `foo` could refer to the name imported here + --> $DIR/E0659.rs:20:13 + | +20 | pub use moon::*; + | ^^^^^^^ +note: `foo` could also refer to the name imported here + --> $DIR/E0659.rs:21:13 + | +21 | pub use earth::*; + | ^^^^^^^^ + = note: consider adding an explicit import of `foo` to disambiguate + +error: aborting due to previous error + From 35dca7edd3e5181459c8e410a59a1b6e3e97a360 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 8 Feb 2018 12:48:25 -0800 Subject: [PATCH 173/198] Add `rustc_args_required_const` to the feature whitelist Unfortunately left out it means that when the `#![feature(proc_macro)]` flag is in effect it fails to find `rustc_args_required_const` for expansion. This version, however, is verified to work with stdsimd's requirements! --- src/libsyntax/feature_gate.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 9c6520cd874a8..ae0556320b0ef 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -984,6 +984,11 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG "wasm_import_memory attribute is currently unstable", cfg_fn!(wasm_import_memory))), + ("rustc_args_required_const", Whitelisted, Gated(Stability::Unstable, + "rustc_attrs", + "never will be stable", + cfg_fn!(rustc_attrs))), + // Crate level attributes ("crate_name", CrateLevel, Ungated), ("crate_type", CrateLevel, Ungated), From 7a20fc14ef255df1ce2c417943605015aba2b1ff Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 8 Feb 2018 13:11:13 -0800 Subject: [PATCH 174/198] Disallow function pointers to #[rustc_args_required_const] This commit disallows acquiring a function pointer to functions tagged as `#[rustc_args_required_const]`. This is intended to be used as future-proofing for the stdsimd crate to avoid taking a function pointer to any intrinsic which has a hard requirement that one of the arguments is a constant value. --- src/librustc_mir/interpret/eval_context.rs | 4 +++ src/librustc_trans/mir/constant.rs | 4 +++ src/librustc_trans/mir/rvalue.rs | 4 +++ src/librustc_typeck/check/mod.rs | 32 +++++++++++++++++++ .../rustc-args-required-const2.rs | 20 ++++++++++++ 5 files changed, 64 insertions(+) create mode 100644 src/test/compile-fail/rustc-args-required-const2.rs diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 02fcb69fef5ac..52b87282180c4 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -716,6 +716,10 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { ReifyFnPointer => { match self.eval_operand(operand)?.ty.sty { ty::TyFnDef(def_id, substs) => { + if self.tcx.has_attr(def_id, "rustc_args_required_const") { + bug!("reifying a fn ptr that requires \ + const arguments"); + } let instance = self.resolve(def_id, substs)?; let fn_ptr = self.memory.create_fn_alloc(instance); let valty = ValTy { diff --git a/src/librustc_trans/mir/constant.rs b/src/librustc_trans/mir/constant.rs index cd1975488a24a..ff9ea40073fce 100644 --- a/src/librustc_trans/mir/constant.rs +++ b/src/librustc_trans/mir/constant.rs @@ -714,6 +714,10 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> { mir::CastKind::ReifyFnPointer => { match operand.ty.sty { ty::TyFnDef(def_id, substs) => { + if tcx.has_attr(def_id, "rustc_args_required_const") { + bug!("reifying a fn ptr that requires \ + const arguments"); + } callee::resolve_and_get_fn(self.cx, def_id, substs) } _ => { diff --git a/src/librustc_trans/mir/rvalue.rs b/src/librustc_trans/mir/rvalue.rs index d1bc4fe90014c..2e876ec118d57 100644 --- a/src/librustc_trans/mir/rvalue.rs +++ b/src/librustc_trans/mir/rvalue.rs @@ -195,6 +195,10 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> { mir::CastKind::ReifyFnPointer => { match operand.layout.ty.sty { ty::TyFnDef(def_id, substs) => { + if bx.cx.tcx.has_attr(def_id, "rustc_args_required_const") { + bug!("reifying a fn ptr that requires \ + const arguments"); + } OperandValue::Immediate( callee::resolve_and_get_fn(bx.cx, def_id, substs)) } diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index f044b2c711e20..8bb38332d0e67 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -4877,6 +4877,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } + self.check_rustc_args_require_const(def.def_id(), node_id, span); + debug!("instantiate_value_path: type of {:?} is {:?}", node_id, ty_substituted); @@ -4884,6 +4886,36 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ty_substituted } + fn check_rustc_args_require_const(&self, + def_id: DefId, + node_id: ast::NodeId, + span: Span) { + // We're only interested in functions tagged with + // #[rustc_args_required_const], so ignore anything that's not. + if !self.tcx.has_attr(def_id, "rustc_args_required_const") { + return + } + + // If our calling expression is indeed the function itself, we're good! + // If not, generate an error that this can only be called directly. + match self.tcx.hir.get(self.tcx.hir.get_parent_node(node_id)) { + Node::NodeExpr(expr) => { + match expr.node { + hir::ExprCall(ref callee, ..) => { + if callee.id == node_id { + return + } + } + _ => {} + } + } + _ => {} + } + + self.tcx.sess.span_err(span, "this function can only be invoked \ + directly, not through a function pointer"); + } + /// Report errors if the provided parameters are too few or too many. fn check_path_parameter_count(&self, span: Span, diff --git a/src/test/compile-fail/rustc-args-required-const2.rs b/src/test/compile-fail/rustc-args-required-const2.rs new file mode 100644 index 0000000000000..aa63019307b5b --- /dev/null +++ b/src/test/compile-fail/rustc-args-required-const2.rs @@ -0,0 +1,20 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(attr_literals, rustc_attrs, const_fn)] + +#[rustc_args_required_const(0)] +fn foo(_a: i32) { +} + +fn main() { + let a = foo; //~ ERROR: this function can only be invoked directly + a(2); +} From e9bcb4eb89048a5f95c2355007e3b22a4ab38093 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 8 Feb 2018 23:47:49 +0100 Subject: [PATCH 175/198] Hide theme button under menu in mobile mode and fix top margin issue (in mobile too) --- src/librustdoc/html/static/main.js | 37 +++++--------------------- src/librustdoc/html/static/rustdoc.css | 2 +- 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index ba9bcb7af7ae0..f688be89beebc 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -123,25 +123,9 @@ sidebar.appendChild(div); } } - var themeChoices = document.getElementById("theme-choices"); - if (themeChoices) { - if (!themesWidth) { - var savedState = themeChoices.style.display; - themeChoices.style.display = 'block'; - themesWidth = themeChoices.offsetWidth + 'px'; - themeChoices.style.display = savedState; - } - themeChoices.style.position = "fixed"; - themeChoices.style.width = themesWidth; - themeChoices.style.top = '78px'; - themeChoices.style.left = '250px'; - } - document.getElementsByTagName("body")[0].style.marginTop = '45px'; - var themePicker = document.getElementById("theme-picker"); - if (themePicker) { - themePicker.style.position = "fixed"; - themePicker.style.top = "50px"; - themePicker.style.left = "250px"; + var themePicker = document.getElementsByClassName("theme-picker"); + if (themePicker && themePicker.length > 0) { + themePicker[0].style.display = "none"; } } @@ -157,18 +141,9 @@ filler.remove(); } document.getElementsByTagName("body")[0].style.marginTop = ''; - var themePicker = document.getElementById("theme-picker"); - if (themePicker) { - themePicker.style.position = "absolute"; - themePicker.style.top = null; - themePicker.style.left = null; - } - var themeChoices = document.getElementById("theme-choices"); - if (themeChoices) { - themeChoices.style.position = 'absolute'; - themeChoices.style.width = null; - themeChoices.style.top = null; - themeChoices.style.left = null; + var themePicker = document.getElementsByClassName("theme-picker"); + if (themePicker && themePicker.length > 0) { + themePicker[0].style.display = null; } } diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 53d57b672303e..cd4f2cfa678e6 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -899,7 +899,7 @@ span.since { } #main { - margin-top: 50px; + margin-top: 45px; padding: 0; } From 64a8730e171367e4979cd9c25f0e0fdc2c157446 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 7 Feb 2018 12:56:04 -0800 Subject: [PATCH 176/198] rustbuild: Pass `ccache` to build scripts Right now the ccache setting is only used for LLVM, but this tweaks it to also be used for build scripts so C++ builds like `librustc_llvm` can be a bit speedier. --- src/bootstrap/builder.rs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index bf7b1015a4921..4ca45fbed6a20 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -600,9 +600,25 @@ impl<'a> Builder<'a> { // // FIXME: the guard against msvc shouldn't need to be here if !target.contains("msvc") { - let cc = self.cc(target); - cargo.env(format!("CC_{}", target), cc) - .env("CC", cc); + let ccache = self.config.ccache.as_ref(); + let ccacheify = |s: &Path| { + let ccache = match ccache { + Some(ref s) => s, + None => return s.display().to_string(), + }; + // FIXME: the cc-rs crate only recognizes the literal strings + // `ccache` and `sccache` when doing caching compilations, so we + // mirror that here. It should probably be fixed upstream to + // accept a new env var or otherwise work with custom ccache + // vars. + match &ccache[..] { + "ccache" | "sccache" => format!("{} {}", ccache, s.display()), + _ => s.display().to_string(), + } + }; + let cc = ccacheify(&self.cc(target)); + cargo.env(format!("CC_{}", target), &cc) + .env("CC", &cc); let cflags = self.cflags(target).join(" "); cargo.env(format!("CFLAGS_{}", target), cflags.clone()) @@ -617,8 +633,9 @@ impl<'a> Builder<'a> { } if let Ok(cxx) = self.cxx(target) { - cargo.env(format!("CXX_{}", target), cxx) - .env("CXX", cxx) + let cxx = ccacheify(&cxx); + cargo.env(format!("CXX_{}", target), &cxx) + .env("CXX", &cxx) .env(format!("CXXFLAGS_{}", target), cflags.clone()) .env("CXXFLAGS", cflags); } From 4cf3b65714726d2c3022717e108943590807b4a2 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Thu, 8 Feb 2018 18:40:00 -0600 Subject: [PATCH 177/198] Use the right tracking issue --- src/libsyntax/feature_gate.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 9358511018a93..382ee3525ec2c 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -454,9 +454,7 @@ declare_features! ( (active, repr_transparent, "1.25.0", Some(43036)), // Use `?` as the Kleene "at most one" operator - // FIXME(mark-i-m): make sure we use the correct issue number when there is - // a tracking issue... - (active, macro_at_most_once_rep, "1.25.0", None), + (active, macro_at_most_once_rep, "1.25.0", Some(48075)), ); declare_features! ( From 1bd086283b0fab7ecda60f451df870aa4e21d00b Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Thu, 8 Feb 2018 22:00:51 -0600 Subject: [PATCH 178/198] Update feature gate test --- src/test/ui/feature-gate-macro_at_most_once_rep.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ui/feature-gate-macro_at_most_once_rep.rs b/src/test/ui/feature-gate-macro_at_most_once_rep.rs index 19f5aca5730e1..27257eec277c1 100644 --- a/src/test/ui/feature-gate-macro_at_most_once_rep.rs +++ b/src/test/ui/feature-gate-macro_at_most_once_rep.rs @@ -12,7 +12,7 @@ // gate is not used. macro_rules! m { ($(a)?) => {} } -//~^ ERROR Using the `?` macro Kleene operator for "at most one" repetition is unstable +//~^ ERROR Using the `?` macro Kleene operator for "at most one" repetition is unstable (see issue #48075) fn main() { m!(); From b92e542ddd41affaf6fb5d1267b8e8dfc03089a5 Mon Sep 17 00:00:00 2001 From: Mark Mansi Date: Thu, 8 Feb 2018 23:00:38 -0600 Subject: [PATCH 179/198] Fix the test --- src/test/ui/feature-gate-macro_at_most_once_rep.rs | 2 +- src/test/ui/feature-gate-macro_at_most_once_rep.stderr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/ui/feature-gate-macro_at_most_once_rep.rs b/src/test/ui/feature-gate-macro_at_most_once_rep.rs index 27257eec277c1..19f5aca5730e1 100644 --- a/src/test/ui/feature-gate-macro_at_most_once_rep.rs +++ b/src/test/ui/feature-gate-macro_at_most_once_rep.rs @@ -12,7 +12,7 @@ // gate is not used. macro_rules! m { ($(a)?) => {} } -//~^ ERROR Using the `?` macro Kleene operator for "at most one" repetition is unstable (see issue #48075) +//~^ ERROR Using the `?` macro Kleene operator for "at most one" repetition is unstable fn main() { m!(); diff --git a/src/test/ui/feature-gate-macro_at_most_once_rep.stderr b/src/test/ui/feature-gate-macro_at_most_once_rep.stderr index 515c6243e668b..02dbab07bdecc 100644 --- a/src/test/ui/feature-gate-macro_at_most_once_rep.stderr +++ b/src/test/ui/feature-gate-macro_at_most_once_rep.stderr @@ -1,4 +1,4 @@ -error[E0658]: Using the `?` macro Kleene operator for "at most one" repetition is unstable +error[E0658]: Using the `?` macro Kleene operator for "at most one" repetition is unstable (see issue #48075) --> $DIR/feature-gate-macro_at_most_once_rep.rs:14:20 | 14 | macro_rules! m { ($(a)?) => {} } From 774997dab3c1a0a6e2ffa03d9d86c7048ec0481d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A5re=20Alsaker?= Date: Fri, 9 Feb 2018 09:48:54 +0100 Subject: [PATCH 180/198] Fix visitation order of calls so that it matches execution order. Fixes #48048 --- src/librustc/hir/intravisit.rs | 2 +- src/test/ui/generator/issue-48048.rs | 23 +++++++++++++++++++++++ src/test/ui/generator/issue-48048.stderr | 10 ++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/generator/issue-48048.rs create mode 100644 src/test/ui/generator/issue-48048.stderr diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 97cf9b01410b1..b804cf7bf5a34 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -965,8 +965,8 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { walk_list!(visitor, visit_expr, subexpressions); } ExprCall(ref callee_expression, ref arguments) => { + visitor.visit_expr(callee_expression); walk_list!(visitor, visit_expr, arguments); - visitor.visit_expr(callee_expression) } ExprMethodCall(ref segment, _, ref arguments) => { visitor.visit_path_segment(expression.span, segment); diff --git a/src/test/ui/generator/issue-48048.rs b/src/test/ui/generator/issue-48048.rs new file mode 100644 index 0000000000000..89739bd591cc8 --- /dev/null +++ b/src/test/ui/generator/issue-48048.rs @@ -0,0 +1,23 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![feature(generators)] + +fn main() { + let x = (|_| {},); + + || { + let x = x; + + x.0({ //~ ERROR borrow may still be in use when generator yields + yield; + }); + }; +} diff --git a/src/test/ui/generator/issue-48048.stderr b/src/test/ui/generator/issue-48048.stderr new file mode 100644 index 0000000000000..fd1667128ab60 --- /dev/null +++ b/src/test/ui/generator/issue-48048.stderr @@ -0,0 +1,10 @@ +error[E0626]: borrow may still be in use when generator yields + --> $DIR/issue-48048.rs:19:9 + | +19 | x.0({ //~ ERROR borrow may still be in use when generator yields + | ^^^ +20 | yield; + | ----- possible yield occurs here + +error: aborting due to previous error + From 9c05babe25bd25db423c7f83c31de000ee4d4db7 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 9 Feb 2018 10:12:32 -0800 Subject: [PATCH 181/198] ci: Actually bootstrap on i686 dist Right now the `--build` option was accidentally omitted, so we're bootstraping from `x86_64` to `i686`. In addition to being slower (more compiles) that's not actually bootstrapping! --- src/bootstrap/dist.rs | 7 +++++++ src/ci/docker/dist-i686-linux/Dockerfile | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 6717b1cb09883..460fb016f16ea 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -31,6 +31,7 @@ use channel; use util::{cp_r, libdir, is_dylib, cp_filtered, copy, replace_in_file}; use builder::{Builder, RunConfig, ShouldRun, Step}; use compile; +use native; use tool::{self, Tool}; use cache::{INTERNER, Interned}; use time; @@ -898,6 +899,12 @@ impl Step for PlainSourceTarball { .arg("--vers").arg(CARGO_VENDOR_VERSION) .arg("cargo-vendor") .env("RUSTC", &build.initial_rustc); + if let Some(dir) = build.openssl_install_dir(build.config.build) { + builder.ensure(native::Openssl { + target: build.config.build, + }); + cmd.env("OPENSSL_DIR", dir); + } build.run(&mut cmd); } diff --git a/src/ci/docker/dist-i686-linux/Dockerfile b/src/ci/docker/dist-i686-linux/Dockerfile index 0fd6af6e10d34..5e405aa72e83d 100644 --- a/src/ci/docker/dist-i686-linux/Dockerfile +++ b/src/ci/docker/dist-i686-linux/Dockerfile @@ -86,7 +86,8 @@ ENV RUST_CONFIGURE_ARGS \ --enable-extended \ --enable-sanitizers \ --enable-profiler \ - --enable-emscripten + --enable-emscripten \ + --build=i686-unknown-linux-gnu ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS # This is the only builder which will create source tarballs From fe8e0d98f17c0603bd324c21468d163ed2dcadb5 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Fri, 9 Feb 2018 11:27:47 -0700 Subject: [PATCH 182/198] Update books for next release --- src/doc/book | 2 +- src/doc/nomicon | 2 +- src/doc/reference | 2 +- src/doc/rust-by-example | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/doc/book b/src/doc/book index a645960fe4894..ec5660820dea9 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit a645960fe48946153936dd5628df4a90bd837981 +Subproject commit ec5660820dea91df470dab0b9eb26ef798f20889 diff --git a/src/doc/nomicon b/src/doc/nomicon index fec3182d0b0a3..ad5ddd62c098d 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit fec3182d0b0a3cf8122e192b3270064a5b19be5b +Subproject commit ad5ddd62c098d5b424151beda574ae7df2154df1 diff --git a/src/doc/reference b/src/doc/reference index e6a5d5d10aa2f..254df654a9b75 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit e6a5d5d10aa2fde0baed7b29bf672bd9f3af8962 +Subproject commit 254df654a9b75abf6ca08806535dbe1fad41be3f diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index 4ebb8169dfe56..919980be7df4e 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit 4ebb8169dfe569b3dcbeab560607800bb717978a +Subproject commit 919980be7df4ea7d45a9dca8efc34da89bcf7d6b From 8af134e03188507f12e8280eb2b27f3811cba68f Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Fri, 9 Feb 2018 16:49:38 +0200 Subject: [PATCH 183/198] rustc_mir: insert a dummy access to places being matched on, when building MIR. --- src/librustc_mir/build/matches/mod.rs | 16 +++ .../borrowck/borrowck-describe-lvalue.rs | 28 ++--- .../borrowck-match-already-borrowed.rs | 4 +- src/test/compile-fail/issue-47412.rs | 31 +++++ src/test/mir-opt/match_false_edges.rs | 107 +++++++++--------- src/test/ui/borrowck/issue-41962.rs | 1 + src/test/ui/borrowck/issue-41962.stderr | 19 +++- src/test/ui/nll/borrowed-match-issue-45045.rs | 2 +- .../ui/nll/borrowed-match-issue-45045.stderr | 15 ++- 9 files changed, 152 insertions(+), 71 deletions(-) create mode 100644 src/test/compile-fail/issue-47412.rs diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index 6cb9217776648..6b0b5b0ab9e88 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -38,6 +38,22 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { -> BlockAnd<()> { let discriminant_place = unpack!(block = self.as_place(block, discriminant)); + // Matching on a `discriminant_place` with an uninhabited type doesn't + // generate any memory reads by itself, and so if the place "expression" + // contains unsafe operations like raw pointer dereferences or union + // field projections, we wouldn't know to require an `unsafe` block + // around a `match` equivalent to `std::intrinsics::unreachable()`. + // See issue #47412 for this hole being discovered in the wild. + // + // HACK(eddyb) Work around the above issue by adding a dummy inspection + // of `discriminant_place`, specifically by applying `Rvalue::Discriminant` + // (which will work regardless of type) and storing the result in a temp. + let dummy_source_info = self.source_info(span); + let dummy_access = Rvalue::Discriminant(discriminant_place.clone()); + let dummy_ty = dummy_access.ty(&self.local_decls, self.hir.tcx()); + let dummy_temp = self.temp(dummy_ty, dummy_source_info.span); + self.cfg.push_assign(block, dummy_source_info, &dummy_temp, dummy_access); + let mut arm_blocks = ArmBlocks { blocks: arms.iter() .map(|_| self.cfg.start_new_block()) diff --git a/src/test/compile-fail/borrowck/borrowck-describe-lvalue.rs b/src/test/compile-fail/borrowck/borrowck-describe-lvalue.rs index 062cc976a3dc1..1d08b80746582 100644 --- a/src/test/compile-fail/borrowck/borrowck-describe-lvalue.rs +++ b/src/test/compile-fail/borrowck/borrowck-describe-lvalue.rs @@ -72,7 +72,7 @@ fn main() { { let mut e = Baz::X(2); let _e0 = e.x(); - match e { + match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed Baz::X(value) => value //[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed //[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed @@ -110,7 +110,7 @@ fn main() { { let mut e = Box::new(Baz::X(3)); let _e0 = e.x(); - match *e { + match *e { //[mir]~ ERROR cannot use `*e` because it was mutably borrowed Baz::X(value) => value //[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed //[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed @@ -127,25 +127,25 @@ fn main() { { let mut v = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let _v = &mut v; - match v { + match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed &[x, _, .., _, _] => println!("{}", x), //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } - match v { + match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed &[_, x, .., _, _] => println!("{}", x), //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } - match v { + match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed &[_, _, .., x, _] => println!("{}", x), //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } - match v { + match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed &[_, _, .., _, x] => println!("{}", x), //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed @@ -156,25 +156,25 @@ fn main() { { let mut v = &[1, 2, 3, 4, 5]; let _v = &mut v; - match v { + match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed &[x..] => println!("{:?}", x), //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } - match v { + match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed &[_, x..] => println!("{:?}", x), //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } - match v { + match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed &[x.., _] => println!("{:?}", x), //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } - match v { + match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed &[_, x.., _] => println!("{:?}", x), //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed @@ -187,7 +187,7 @@ fn main() { let mut e = E::A(3); let _e = &mut e; - match e { + match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed E::A(ref ax) => //[ast]~^ ERROR cannot borrow `e.0` as immutable because `e` is also borrowed as mutable //[mir]~^^ ERROR cannot borrow `e.0` as immutable because it is also borrowed as mutable @@ -205,14 +205,14 @@ fn main() { struct S { x: F, y: (u32, u32), }; let mut s = S { x: F { x: 1, y: 2}, y: (999, 998) }; let _s = &mut s; - match s { + match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed S { y: (ref y0, _), .. } => //[ast]~^ ERROR cannot borrow `s.y.0` as immutable because `s` is also borrowed as mutable //[mir]~^^ ERROR cannot borrow `s.y.0` as immutable because it is also borrowed as mutable println!("y0: {:?}", y0), _ => panic!("other case"), } - match s { + match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed S { x: F { y: ref x0, .. }, .. } => //[ast]~^ ERROR cannot borrow `s.x.y` as immutable because `s` is also borrowed as mutable //[mir]~^^ ERROR cannot borrow `s.x.y` as immutable because it is also borrowed as mutable @@ -263,7 +263,7 @@ fn main() { struct F {x: u32, y: u32}; let mut v = &[F{x: 1, y: 2}, F{x: 3, y: 4}]; let _v = &mut v; - match v { + match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed &[_, F {x: ref xf, ..}] => println!("{}", xf), //[mir]~^ ERROR cannot borrow `v[..].x` as immutable because it is also borrowed as mutable // No errors in AST diff --git a/src/test/compile-fail/borrowck/borrowck-match-already-borrowed.rs b/src/test/compile-fail/borrowck/borrowck-match-already-borrowed.rs index 4336812af9b58..3e57ac0ca1910 100644 --- a/src/test/compile-fail/borrowck/borrowck-match-already-borrowed.rs +++ b/src/test/compile-fail/borrowck/borrowck-match-already-borrowed.rs @@ -19,7 +19,7 @@ enum Foo { fn match_enum() { let mut foo = Foo::B; let p = &mut foo; - let _ = match foo { + let _ = match foo { //[mir]~ ERROR [E0503] Foo::B => 1, //[mir]~ ERROR [E0503] _ => 2, Foo::A(x) => x //[ast]~ ERROR [E0503] @@ -31,7 +31,7 @@ fn match_enum() { fn main() { let mut x = 1; let _x = &mut x; - let _ = match x { + let _ = match x { //[mir]~ ERROR [E0503] x => x + 1, //[ast]~ ERROR [E0503] //[mir]~^ ERROR [E0503] y => y + 2, //[ast]~ ERROR [E0503] diff --git a/src/test/compile-fail/issue-47412.rs b/src/test/compile-fail/issue-47412.rs new file mode 100644 index 0000000000000..7481befcb7952 --- /dev/null +++ b/src/test/compile-fail/issue-47412.rs @@ -0,0 +1,31 @@ +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[derive(Copy, Clone)] +enum Void {} + +// Tests that we detect unsafe places (specifically, union fields and +// raw pointer dereferences), even when they're matched on while having +// an uninhabited type (equivalent to `std::intrinsics::unreachable()`). + +fn union_field() { + union Union { unit: (), void: Void } + let u = Union { unit: () }; + match u.void {} + //~^ ERROR access to union field requires unsafe function or block +} + +fn raw_ptr_deref() { + let ptr = std::ptr::null::(); + match *ptr {} + //~^ ERROR dereference of raw pointer requires unsafe function or block +} + +fn main() {} diff --git a/src/test/mir-opt/match_false_edges.rs b/src/test/mir-opt/match_false_edges.rs index 1f892b0f9587a..ba1b54d59f69a 100644 --- a/src/test/mir-opt/match_false_edges.rs +++ b/src/test/mir-opt/match_false_edges.rs @@ -53,17 +53,18 @@ fn main() { // bb0: { // ... // _2 = std::option::Option::Some(const 42i32,); -// _5 = discriminant(_2); -// switchInt(move _5) -> [0isize: bb6, 1isize: bb4, otherwise: bb8]; +// _3 = discriminant(_2); +// _6 = discriminant(_2); +// switchInt(move _6) -> [0isize: bb6, 1isize: bb4, otherwise: bb8]; // } // bb1: { // resume; // } // bb2: { // arm1 -// StorageLive(_7); -// _7 = _3; -// _1 = (const 1i32, move _7); -// StorageDead(_7); +// StorageLive(_8); +// _8 = _4; +// _1 = (const 1i32, move _8); +// StorageDead(_8); // goto -> bb13; // } // bb3: { // binding3(empty) and arm3 @@ -86,24 +87,24 @@ fn main() { // unreachable; // } // bb9: { // binding1 and guard -// StorageLive(_3); -// _3 = ((_2 as Some).0: i32); -// StorageLive(_6); -// _6 = const guard() -> [return: bb10, unwind: bb1]; +// StorageLive(_4); +// _4 = ((_2 as Some).0: i32); +// StorageLive(_7); +// _7 = const guard() -> [return: bb10, unwind: bb1]; // } // bb10: { // end of guard -// switchInt(move _6) -> [0u8: bb11, otherwise: bb2]; +// switchInt(move _7) -> [0u8: bb11, otherwise: bb2]; // } // bb11: { // to pre_binding2 // falseEdges -> [real: bb5, imaginary: bb5]; // } // bb12: { // bindingNoLandingPads.before.mir2 and arm2 -// StorageLive(_4); -// _4 = ((_2 as Some).0: i32); -// StorageLive(_8); -// _8 = _4; -// _1 = (const 2i32, move _8); -// StorageDead(_8); +// StorageLive(_5); +// _5 = ((_2 as Some).0: i32); +// StorageLive(_9); +// _9 = _5; +// _1 = (const 2i32, move _9); +// StorageDead(_9); // goto -> bb13; // } // bb13: { @@ -116,17 +117,18 @@ fn main() { // bb0: { // ... // _2 = std::option::Option::Some(const 42i32,); -// _5 = discriminant(_2); -// switchInt(move _5) -> [0isize: bb5, 1isize: bb4, otherwise: bb8]; +// _3 = discriminant(_2); +// _6 = discriminant(_2); +// switchInt(move _6) -> [0isize: bb5, 1isize: bb4, otherwise: bb8]; // } // bb1: { // resume; // } // bb2: { // arm1 -// StorageLive(_7); -// _7 = _3; -// _1 = (const 1i32, move _7); -// StorageDead(_7); +// StorageLive(_8); +// _8 = _4; +// _1 = (const 1i32, move _8); +// StorageDead(_8); // goto -> bb13; // } // bb3: { // binding3(empty) and arm3 @@ -149,24 +151,24 @@ fn main() { // unreachable; // } // bb9: { // binding1 and guard -// StorageLive(_3); -// _3 = ((_2 as Some).0: i32); -// StorageLive(_6); -// _6 = const guard() -> [return: bb10, unwind: bb1]; +// StorageLive(_4); +// _4 = ((_2 as Some).0: i32); +// StorageLive(_7); +// _7 = const guard() -> [return: bb10, unwind: bb1]; // } // bb10: { // end of guard -// switchInt(move _6) -> [0u8: bb11, otherwise: bb2]; +// switchInt(move _7) -> [0u8: bb11, otherwise: bb2]; // } // bb11: { // to pre_binding2 // falseEdges -> [real: bb6, imaginary: bb5]; // } // bb12: { // binding2 and arm2 -// StorageLive(_4); -// _4 = ((_2 as Some).0: i32); -// StorageLive(_8); -// _8 = _4; -// _1 = (const 2i32, move _8); -// StorageDead(_8); +// StorageLive(_5); +// _5 = ((_2 as Some).0: i32); +// StorageLive(_9); +// _9 = _5; +// _1 = (const 2i32, move _9); +// StorageDead(_9); // goto -> bb13; // } // bb13: { @@ -179,8 +181,9 @@ fn main() { // bb0: { // ... // _2 = std::option::Option::Some(const 1i32,); -// _7 = discriminant(_2); -// switchInt(move _7) -> [1isize: bb4, otherwise: bb5]; +// _3 = discriminant(_2); +// _8 = discriminant(_2); +// switchInt(move _8) -> [1isize: bb4, otherwise: bb5]; // } // bb1: { // resume; @@ -210,41 +213,41 @@ fn main() { // unreachable; // } // bb9: { // binding1: Some(w) if guard() -// StorageLive(_3); -// _3 = ((_2 as Some).0: i32); -// StorageLive(_8); -// _8 = const guard() -> [return: bb10, unwind: bb1]; +// StorageLive(_4); +// _4 = ((_2 as Some).0: i32); +// StorageLive(_9); +// _9 = const guard() -> [return: bb10, unwind: bb1]; // } // bb10: { //end of guard -// switchInt(move _8) -> [0u8: bb11, otherwise: bb2]; +// switchInt(move _9) -> [0u8: bb11, otherwise: bb2]; // } // bb11: { // to pre_binding2 // falseEdges -> [real: bb5, imaginary: bb5]; // } // bb12: { // binding2 & arm2 -// StorageLive(_4); -// _4 = _2; +// StorageLive(_5); +// _5 = _2; // _1 = const 2i32; // goto -> bb17; // } // bb13: { // binding3: Some(y) if guard2(y) -// StorageLive(_5); -// _5 = ((_2 as Some).0: i32); -// StorageLive(_10); +// StorageLive(_6); +// _6 = ((_2 as Some).0: i32); // StorageLive(_11); -// _11 = _5; -// _10 = const guard2(move _11) -> [return: bb14, unwind: bb1]; +// StorageLive(_12); +// _12 = _6; +// _11 = const guard2(move _12) -> [return: bb14, unwind: bb1]; // } // bb14: { // end of guard2 -// StorageDead(_11); -// switchInt(move _10) -> [0u8: bb15, otherwise: bb3]; +// StorageDead(_12); +// switchInt(move _11) -> [0u8: bb15, otherwise: bb3]; // } // bb15: { // to pre_binding4 // falseEdges -> [real: bb7, imaginary: bb7]; // } // bb16: { // binding4 & arm4 -// StorageLive(_6); -// _6 = _2; +// StorageLive(_7); +// _7 = _2; // _1 = const 4i32; // goto -> bb17; // } diff --git a/src/test/ui/borrowck/issue-41962.rs b/src/test/ui/borrowck/issue-41962.rs index d592be11335e0..f7c33691ad072 100644 --- a/src/test/ui/borrowck/issue-41962.rs +++ b/src/test/ui/borrowck/issue-41962.rs @@ -18,6 +18,7 @@ pub fn main(){ //~^ ERROR use of partially moved value: `maybe` (Ast) [E0382] //~| ERROR use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) [E0382] //~| ERROR use of moved value: `maybe` (Mir) [E0382] + //~| ERROR use of moved value: `maybe` (Mir) [E0382] //~| ERROR use of moved value: `maybe.0` (Mir) [E0382] } } diff --git a/src/test/ui/borrowck/issue-41962.stderr b/src/test/ui/borrowck/issue-41962.stderr index 50d51c4d907fd..13305fd965626 100644 --- a/src/test/ui/borrowck/issue-41962.stderr +++ b/src/test/ui/borrowck/issue-41962.stderr @@ -16,6 +16,23 @@ error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) | = note: move occurs because the value has type `std::vec::Vec`, which does not implement the `Copy` trait +error[E0382]: use of moved value: `maybe` (Mir) + --> $DIR/issue-41962.rs:17:9 + | +17 | if let Some(thing) = maybe { + | ^ ----- value moved here + | _________| + | | +18 | | //~^ ERROR use of partially moved value: `maybe` (Ast) [E0382] +19 | | //~| ERROR use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) [E0382] +20 | | //~| ERROR use of moved value: `maybe` (Mir) [E0382] +21 | | //~| ERROR use of moved value: `maybe` (Mir) [E0382] +22 | | //~| ERROR use of moved value: `maybe.0` (Mir) [E0382] +23 | | } + | |_________^ value used here after move + | + = note: move occurs because `maybe` has type `std::option::Option>`, which does not implement the `Copy` trait + error[E0382]: use of moved value: `maybe` (Mir) --> $DIR/issue-41962.rs:17:16 | @@ -35,5 +52,5 @@ error[E0382]: use of moved value: `maybe.0` (Mir) | = note: move occurs because `maybe.0` has type `std::vec::Vec`, which does not implement the `Copy` trait -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors diff --git a/src/test/ui/nll/borrowed-match-issue-45045.rs b/src/test/ui/nll/borrowed-match-issue-45045.rs index 8688bfa86dc6f..4b95bbd5a052b 100644 --- a/src/test/ui/nll/borrowed-match-issue-45045.rs +++ b/src/test/ui/nll/borrowed-match-issue-45045.rs @@ -21,7 +21,7 @@ fn main() { let mut e = Xyz::A; let f = &mut e; let g = f; - match e { + match e { //~ cannot use `e` because it was mutably borrowed [E0503] Xyz::A => println!("a"), //~^ cannot use `e` because it was mutably borrowed [E0503] Xyz::B => println!("b"), diff --git a/src/test/ui/nll/borrowed-match-issue-45045.stderr b/src/test/ui/nll/borrowed-match-issue-45045.stderr index 15ca30010a55d..f5271b99c4be3 100644 --- a/src/test/ui/nll/borrowed-match-issue-45045.stderr +++ b/src/test/ui/nll/borrowed-match-issue-45045.stderr @@ -1,3 +1,16 @@ +error[E0503]: cannot use `e` because it was mutably borrowed + --> $DIR/borrowed-match-issue-45045.rs:24:5 + | +22 | let f = &mut e; + | ------ borrow of `e` occurs here +23 | let g = f; +24 | / match e { //~ cannot use `e` because it was mutably borrowed [E0503] +25 | | Xyz::A => println!("a"), +26 | | //~^ cannot use `e` because it was mutably borrowed [E0503] +27 | | Xyz::B => println!("b"), +28 | | }; + | |_____^ use of borrowed `e` + error[E0503]: cannot use `e` because it was mutably borrowed --> $DIR/borrowed-match-issue-45045.rs:25:9 | @@ -7,5 +20,5 @@ error[E0503]: cannot use `e` because it was mutably borrowed 25 | Xyz::A => println!("a"), | ^^^^^^ use of borrowed `e` -error: aborting due to previous error +error: aborting due to 2 previous errors From 1335b3da5a80fa4b74b25642e1bb651388bac3a8 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Fri, 9 Feb 2018 11:19:52 -0700 Subject: [PATCH 184/198] Add fetch_nand. cc #13226 (the tracking issue) --- src/libcore/sync/atomic.rs | 46 +++++++++++++++++++++++++++++++++++++ src/libcore/tests/atomic.rs | 14 +++++++++++ src/libcore/tests/lib.rs | 1 + 3 files changed, 61 insertions(+) diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index 8b47143f63caa..f22862ae70190 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -945,6 +945,7 @@ macro_rules! atomic_int { $stable_debug:meta, $stable_access:meta, $stable_from:meta, + $stable_nand:meta, $s_int_type:expr, $int_ref:expr, $int_type:ident $atomic_type:ident $atomic_init:ident) => { /// An integer type which can be safely shared between threads. @@ -1325,6 +1326,29 @@ macro_rules! atomic_int { unsafe { atomic_and(self.v.get(), val, order) } } + /// Bitwise "nand" with the current value. + /// + /// Performs a bitwise "nand" operation on the current value and the argument `val`, and + /// sets the new value to the result. + /// + /// Returns the previous value. + /// + /// # Examples + /// + /// ``` + /// #![feature(atomic_nand)] + /// + /// use std::sync::atomic::{AtomicIsize, Ordering}; + /// + /// let foo = AtomicIsize::new(0xf731); + /// assert_eq!(foo.fetch_nand(0x137f, Ordering::SeqCst), 0xf731); + /// assert_eq!(foo.load(Ordering::SeqCst), !(0xf731 & 0x137f)); + #[inline] + #[$stable_nand] + pub fn fetch_nand(&self, val: $int_type, order: Ordering) -> $int_type { + unsafe { atomic_nand(self.v.get(), val, order) } + } + /// Bitwise "or" with the current value. /// /// Performs a bitwise "or" operation on the current value and the argument `val`, and @@ -1377,6 +1401,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), + unstable(feature = "atomic_nand", issue = "13226"), "i8", "../../../std/primitive.i8.html", i8 AtomicI8 ATOMIC_I8_INIT } @@ -1387,6 +1412,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), + unstable(feature = "atomic_nand", issue = "13226"), "u8", "../../../std/primitive.u8.html", u8 AtomicU8 ATOMIC_U8_INIT } @@ -1397,6 +1423,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), + unstable(feature = "atomic_nand", issue = "13226"), "i16", "../../../std/primitive.i16.html", i16 AtomicI16 ATOMIC_I16_INIT } @@ -1407,6 +1434,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), + unstable(feature = "atomic_nand", issue = "13226"), "u16", "../../../std/primitive.u16.html", u16 AtomicU16 ATOMIC_U16_INIT } @@ -1417,6 +1445,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), + unstable(feature = "atomic_nand", issue = "13226"), "i32", "../../../std/primitive.i32.html", i32 AtomicI32 ATOMIC_I32_INIT } @@ -1427,6 +1456,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), + unstable(feature = "atomic_nand", issue = "13226"), "u32", "../../../std/primitive.u32.html", u32 AtomicU32 ATOMIC_U32_INIT } @@ -1437,6 +1467,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), + unstable(feature = "atomic_nand", issue = "13226"), "i64", "../../../std/primitive.i64.html", i64 AtomicI64 ATOMIC_I64_INIT } @@ -1447,6 +1478,7 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), + unstable(feature = "atomic_nand", issue = "13226"), "u64", "../../../std/primitive.u64.html", u64 AtomicU64 ATOMIC_U64_INIT } @@ -1457,6 +1489,7 @@ atomic_int!{ stable(feature = "atomic_debug", since = "1.3.0"), stable(feature = "atomic_access", since = "1.15.0"), stable(feature = "atomic_from", since = "1.23.0"), + unstable(feature = "atomic_nand", issue = "13226"), "isize", "../../../std/primitive.isize.html", isize AtomicIsize ATOMIC_ISIZE_INIT } @@ -1467,6 +1500,7 @@ atomic_int!{ stable(feature = "atomic_debug", since = "1.3.0"), stable(feature = "atomic_access", since = "1.15.0"), stable(feature = "atomic_from", since = "1.23.0"), + unstable(feature = "atomic_nand", issue = "13226"), "usize", "../../../std/primitive.usize.html", usize AtomicUsize ATOMIC_USIZE_INIT } @@ -1609,6 +1643,18 @@ unsafe fn atomic_and(dst: *mut T, val: T, order: Ordering) -> T { } } +#[inline] +unsafe fn atomic_nand(dst: *mut T, val: T, order: Ordering) -> T { + match order { + Acquire => intrinsics::atomic_nand_acq(dst, val), + Release => intrinsics::atomic_nand_rel(dst, val), + AcqRel => intrinsics::atomic_nand_acqrel(dst, val), + Relaxed => intrinsics::atomic_nand_relaxed(dst, val), + SeqCst => intrinsics::atomic_nand(dst, val), + __Nonexhaustive => panic!("invalid memory ordering"), + } +} + #[inline] unsafe fn atomic_or(dst: *mut T, val: T, order: Ordering) -> T { match order { diff --git a/src/libcore/tests/atomic.rs b/src/libcore/tests/atomic.rs index 9babe24a98563..f634fabe50399 100644 --- a/src/libcore/tests/atomic.rs +++ b/src/libcore/tests/atomic.rs @@ -48,6 +48,13 @@ fn uint_and() { assert_eq!(x.load(SeqCst), 0xf731 & 0x137f); } +#[test] +fn uint_nand() { + let x = AtomicUsize::new(0xf731); + assert_eq!(x.fetch_nand(0x137f, SeqCst), 0xf731); + assert_eq!(x.load(SeqCst), !(0xf731 & 0x137f)); +} + #[test] fn uint_or() { let x = AtomicUsize::new(0xf731); @@ -69,6 +76,13 @@ fn int_and() { assert_eq!(x.load(SeqCst), 0xf731 & 0x137f); } +#[test] +fn int_nand() { + let x = AtomicIsize::new(0xf731); + assert_eq!(x.fetch_nand(0x137f, SeqCst), 0xf731); + assert_eq!(x.load(SeqCst), !(0xf731 & 0x137f)); +} + #[test] fn int_or() { let x = AtomicIsize::new(0xf731); diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index 1c32452f84635..9e90313bc0e9e 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -42,6 +42,7 @@ #![feature(try_from)] #![feature(try_trait)] #![feature(exact_chunks)] +#![feature(atomic_nand)] extern crate core; extern crate test; From e6f910e31e578301cc8608f049f1763172569ca8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Fri, 9 Feb 2018 22:18:06 +0100 Subject: [PATCH 185/198] fix typo: substract -> subtract. --- src/libcore/ops/arith.rs | 4 ++-- src/test/ui/mismatched_types/binops.rs | 2 +- src/test/ui/mismatched_types/binops.stderr | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs index d0d0c09869e9d..88db019b02f07 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs @@ -181,7 +181,7 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "sub"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="cannot substract `{RHS}` from `{Self}`", +#[rustc_on_unimplemented(message="cannot subtract `{RHS}` from `{Self}`", label="no implementation for `{Self} - {RHS}`")] pub trait Sub { /// The resulting type after applying the `-` operator. @@ -716,7 +716,7 @@ add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "sub_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented(message="cannot substract-assign `{Rhs}` from `{Self}`", +#[rustc_on_unimplemented(message="cannot subtract-assign `{Rhs}` from `{Self}`", label="no implementation for `{Self} -= {Rhs}`")] pub trait SubAssign { /// Performs the `-=` operation. diff --git a/src/test/ui/mismatched_types/binops.rs b/src/test/ui/mismatched_types/binops.rs index 5144b59955cc9..3f2cb59b11dee 100644 --- a/src/test/ui/mismatched_types/binops.rs +++ b/src/test/ui/mismatched_types/binops.rs @@ -10,7 +10,7 @@ fn main() { 1 + Some(1); //~ ERROR cannot add `std::option::Option<{integer}>` to `{integer}` - 2 as usize - Some(1); //~ ERROR cannot substract `std::option::Option<{integer}>` from `usize` + 2 as usize - Some(1); //~ ERROR cannot subtract `std::option::Option<{integer}>` from `usize` 3 * (); //~ ERROR cannot multiply `()` to `{integer}` 4 / ""; //~ ERROR cannot divide `{integer}` by `&str` 5 < String::new(); //~ ERROR is not satisfied diff --git a/src/test/ui/mismatched_types/binops.stderr b/src/test/ui/mismatched_types/binops.stderr index 1b7fba050636f..828cf636951ed 100644 --- a/src/test/ui/mismatched_types/binops.stderr +++ b/src/test/ui/mismatched_types/binops.stderr @@ -6,10 +6,10 @@ error[E0277]: cannot add `std::option::Option<{integer}>` to `{integer}` | = help: the trait `std::ops::Add>` is not implemented for `{integer}` -error[E0277]: cannot substract `std::option::Option<{integer}>` from `usize` +error[E0277]: cannot subtract `std::option::Option<{integer}>` from `usize` --> $DIR/binops.rs:13:16 | -13 | 2 as usize - Some(1); //~ ERROR cannot substract `std::option::Option<{integer}>` from `usize` +13 | 2 as usize - Some(1); //~ ERROR cannot subtract `std::option::Option<{integer}>` from `usize` | ^ no implementation for `usize - std::option::Option<{integer}>` | = help: the trait `std::ops::Sub>` is not implemented for `usize` From 6b7b6b63a928479a29d9fc1282e553e409c66934 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 22 Jan 2018 14:23:30 -0800 Subject: [PATCH 186/198] rustc: Upgrade to LLVM 6 The following submodules have been updated for a new version of LLVM: - `src/llvm` - `src/libcompiler_builtins` - transitively contains compiler-rt - `src/dlmalloc` This also updates the docker container for dist-i686-freebsd as the old 16.04 container is no longer capable of building LLVM. The compiler-rt/compiler-builtins and dlmalloc updates are pretty routine without much interesting happening, but the LLVM update here is of particular note. Unlike previous updates I haven't cherry-picked all existing patches we had on top of our LLVM branch as we have a [huge amount][patches4] and have at this point forgotten what most of them are for. Instead I started from the current `release_60` branch in LLVM and only applied patches that were necessary to get our tests working and building. The current set of custom rustc-specific patches included in this LLVM update are: * rust-lang/llvm@1187443 - this is how we actually implement `cfg(target_feature)` for now and continues to not be upstreamed. While a hazard for SIMD stabilization this commit is otherwise keeping the status quo of a small rustc-specific feature. * rust-lang/llvm@013f2ec - this is a rustc-specific optimization that we haven't upstreamed, notably teaching LLVM about our allocation-related routines (which aren't malloc/free). Once we stabilize the global allocator routines we will likely want to upstream this patch, but for now it seems reasonable to keep it on our fork. * rust-lang/llvm@a65bbfd - I found this necessary to fix compilation of LLVM in our 32-bit linux container. I'm not really sure why it's necessary but my guess is that it's because of the absolutely ancient glibc that we're using. In any case it's only updating pieces we're not actually using in LLVM so I'm hoping it'll turn out alright. This doesn't seem like something we'll want to upstream.c * rust-lang/llvm@77ab1f0 - this is what's actually enabling LLVM to build in our i686-freebsd container, I'm not really sure what's going on but we for sure probably don't want to upstream this and otherwise it seems not too bad for now at least. * rust-lang/llvm@9eb9267 - we currently suffer on MSVC from an [upstream bug] which although diagnosed to a particular revision isn't currently fixed upstream (and the bug itself doesn't seem too active). This commit is a partial revert of the suspected cause of this regression (found via a bisection). I'm sort of hoping that this eventually gets fixed upstream with a similar fix (which we can replace in our branch), but for now I'm also hoping it's a relatively harmless change to have. After applying these patches (plus one [backport] which should be [backported upstream][llvm-back]) I believe we should have all tests working on all platforms in our current test suite. I'm like 99% sure that we'll need some more backports as issues are reported for LLVM 6 when this propagates through nightlies, but that's sort of just par for the course nowadays! In any case though some extra scrutiny of the patches here would definitely be welcome, along with scrutiny of the "missing patches" like a [change to pass manager order](rust-lang/llvm@27174447533), [another change to pass manager order](rust-lang/llvm@c782febb7b9), some [compile fixes for sparc](rust-lang/llvm@1a83de63c42), and some [fixes for solaris](rust-lang/llvm@c2bfe0abb). [patches4]: https://github.com/rust-lang/llvm/compare/5401fdf23...rust-llvm-release-4-0-1 [backport]: https://github.com/rust-lang/llvm/commit/5c54c252db [llvm-back]: https://bugs.llvm.org/show_bug.cgi?id=36114 [upstream bug]: https://bugs.llvm.org/show_bug.cgi?id=36096 --- The update to LLVM 6 is desirable for a number of reasons, notably: * This'll allow us to keep up with the upstream wasm backend, picking up new features as they start landing. * Upstream LLVM has fixed a number of SIMD-related compilation errors, especially around AVX-512 and such. * There's a few assorted known bugs which are fixed in LLVM 5 and aren't fixed in the LLVM 4 branch we're using. * Overall it's not a great idea to stagnate with our codegen backend! This update is mostly powered by #47730 which is allowing us to update LLVM *independent* of the version of LLVM that Emscripten is locked to. This means that when compiling code for Emscripten we'll still be using the old LLVM 4 backend, but when compiling code for any other target we'll be using the new LLVM 6 target. Once Emscripten updates we may no longer need this distinction, but we're not sure when that will happen! Closes #43370 Closes #43418 Closes #47015 Closes #47683 Closes rust-lang-nursery/stdsimd#157 Closes rust-lang-nursery/rust-wasm#3 --- src/bootstrap/native.rs | 2 +- src/ci/docker/dist-i686-freebsd/Dockerfile | 2 +- src/dlmalloc | 2 +- src/libcompiler_builtins | 2 +- src/librustc_resolve/resolve_imports.rs | 7 +++-- src/llvm | 2 +- src/rustllvm/RustWrapper.cpp | 2 ++ src/rustllvm/llvm-rebuild-trigger | 2 +- src/test/run-pass/backtrace-debuginfo.rs | 34 ++++++++++++++++++---- 9 files changed, 41 insertions(+), 14 deletions(-) diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 3f30756a568ce..2ea026244034f 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -186,7 +186,7 @@ impl Step for Llvm { } // http://llvm.org/docs/HowToCrossCompileLLVM.html - if target != build.build { + if target != build.build && !emscripten { builder.ensure(Llvm { target: build.build, emscripten: false, diff --git a/src/ci/docker/dist-i686-freebsd/Dockerfile b/src/ci/docker/dist-i686-freebsd/Dockerfile index 686afc97289b1..673fa4c0c4bc0 100644 --- a/src/ci/docker/dist-i686-freebsd/Dockerfile +++ b/src/ci/docker/dist-i686-freebsd/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:16.04 +FROM ubuntu:18.04 RUN apt-get update && apt-get install -y --no-install-recommends \ clang \ diff --git a/src/dlmalloc b/src/dlmalloc index d3812c3accaee..a2b424b600235 160000 --- a/src/dlmalloc +++ b/src/dlmalloc @@ -1 +1 @@ -Subproject commit d3812c3accaee7ad23068ed4fc089cc05c7a538f +Subproject commit a2b424b600235af58f453577c2da1b0e1de2ffa5 diff --git a/src/libcompiler_builtins b/src/libcompiler_builtins index 0a95675bab808..345447948f7a5 160000 --- a/src/libcompiler_builtins +++ b/src/libcompiler_builtins @@ -1 +1 @@ -Subproject commit 0a95675bab808c49f86208bacc89c5d9c53ac43f +Subproject commit 345447948f7a51eca970fa036cefd613d54a4f79 diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 07b08e2e61ac0..95a507ab9e351 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -1026,9 +1026,12 @@ fn import_path_to_string(names: &[SpannedIdent], if names.is_empty() { import_directive_subclass_to_string(subclass) } else { - (format!("{}::{}", + let x = format!("{}::{}", names_to_string(names), - import_directive_subclass_to_string(subclass))) + import_directive_subclass_to_string(subclass)); + assert!(!names.is_empty()); + assert!(!x.starts_with("::")); + return x } } } diff --git a/src/llvm b/src/llvm index bc344d5bc23c6..9f81beaf32608 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit bc344d5bc23c61ff9baf82d268a0edf199933cc3 +Subproject commit 9f81beaf32608fbe1fe0f2a82f974e800e9d8c62 diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 611d63f6a4d14..4dfc4029d75dc 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -552,9 +552,11 @@ static unsigned fromRust(LLVMRustDIFlags Flags) { if (isSet(Flags & LLVMRustDIFlags::FlagRValueReference)) { Result |= DINode::DIFlags::FlagRValueReference; } +#if LLVM_VERSION_LE(4, 0) if (isSet(Flags & LLVMRustDIFlags::FlagExternalTypeRef)) { Result |= DINode::DIFlags::FlagExternalTypeRef; } +#endif if (isSet(Flags & LLVMRustDIFlags::FlagIntroducedVirtual)) { Result |= DINode::DIFlags::FlagIntroducedVirtual; } diff --git a/src/rustllvm/llvm-rebuild-trigger b/src/rustllvm/llvm-rebuild-trigger index 2635ca73303e7..3cd044708cee2 100644 --- a/src/rustllvm/llvm-rebuild-trigger +++ b/src/rustllvm/llvm-rebuild-trigger @@ -1,4 +1,4 @@ # If this file is modified, then llvm will be (optionally) cleaned and then rebuilt. # The actual contents of this file do not matter, but to trigger a change on the # build bots then the contents should be changed so git updates the mtime. -2018-01-25 +2018-02-09 diff --git a/src/test/run-pass/backtrace-debuginfo.rs b/src/test/run-pass/backtrace-debuginfo.rs index e8b5f3490e50e..2b82a8943636e 100644 --- a/src/test/run-pass/backtrace-debuginfo.rs +++ b/src/test/run-pass/backtrace-debuginfo.rs @@ -15,11 +15,14 @@ // Unfortunately, LLVM has no "disable" option for this, so we have to set // "enable" to 0 instead. -// compile-flags:-g -Cllvm-args=-enable-tail-merge=0 +// compile-flags:-g -Cllvm-args=-enable-tail-merge=0 -Cllvm-args=-opt-bisect-limit=0 // ignore-pretty issue #37195 // ignore-cloudabi spawning processes is not supported // ignore-emscripten spawning processes is not supported +// note that above `-opt-bisect-limit=0` is used to basically disable +// optimizations + use std::env; #[path = "backtrace-debuginfo-aux.rs"] mod aux; @@ -114,18 +117,26 @@ fn outer(mut counter: i32, main_pos: Pos) { inner_inlined(&mut counter, main_pos, pos!()); } -fn check_trace(output: &str, error: &str) { +fn check_trace(output: &str, error: &str) -> Result<(), String> { // reverse the position list so we can start with the last item (which was the first line) let mut remaining: Vec<&str> = output.lines().map(|s| s.trim()).rev().collect(); - assert!(error.contains("stack backtrace"), "no backtrace in the error: {}", error); + if !error.contains("stack backtrace") { + return Err(format!("no backtrace found in stderr:\n{}", error)) + } for line in error.lines() { if !remaining.is_empty() && line.contains(remaining.last().unwrap()) { remaining.pop(); } } - assert!(remaining.is_empty(), - "trace does not match position list: {}\n---\n{}", error, output); + if !remaining.is_empty() { + return Err(format!("trace does not match position list\n\ + still need to find {:?}\n\n\ + --- stdout\n{}\n\ + --- stderr\n{}", + remaining, output, error)) + } + Ok(()) } fn run_test(me: &str) { @@ -133,6 +144,7 @@ fn run_test(me: &str) { use std::process::Command; let mut i = 0; + let mut errors = Vec::new(); loop { let out = Command::new(me) .env("RUST_BACKTRACE", "full") @@ -143,10 +155,20 @@ fn run_test(me: &str) { assert!(output.contains("done."), "bad output for successful run: {}", output); break; } else { - check_trace(output, error); + if let Err(e) = check_trace(output, error) { + errors.push(e); + } } i += 1; } + if errors.len() > 0 { + for error in errors { + println!("---------------------------------------"); + println!("{}", error); + } + + panic!("found some errors"); + } } #[inline(never)] From 9a6afa8f670af6da28a62c551d9df1fbe51b7434 Mon Sep 17 00:00:00 2001 From: Martin Algesten Date: Fri, 2 Feb 2018 08:29:59 +0100 Subject: [PATCH 187/198] Emit data::Impl in save-analysis --- src/Cargo.lock | 12 ++++++- src/librustc_save_analysis/Cargo.toml | 2 +- src/librustc_save_analysis/dump_visitor.rs | 8 +++-- src/librustc_save_analysis/json_dumper.rs | 6 +++- src/librustc_save_analysis/lib.rs | 41 +++++++++++++++++++--- 5 files changed, 59 insertions(+), 10 deletions(-) diff --git a/src/Cargo.lock b/src/Cargo.lock index afe7f841f2571..6b722db53ed3a 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -1685,6 +1685,15 @@ dependencies = [ "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "rls-data" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rls-rustc" version = "0.2.1" @@ -2122,7 +2131,7 @@ name = "rustc_save_analysis" version = "0.0.0" dependencies = [ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-data 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-data 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3107,6 +3116,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e" "checksum rls-analysis 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "38841e3c5271715a574ac220d9b408b59ed9e2626909c3bc54b5853b4eaadb7b" "checksum rls-data 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8024f1feaca72d0aa4ae1e2a8d454a31b9a33ed02f8d0e9c8559bf53c267ec3c" +"checksum rls-data 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bea04462e94b5512a78499837eecb7db182ff082144cd1b4bc32ef5d43de6510" "checksum rls-rustc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "85cfb9dde19e313da3e47738008f8a472e470cc42d910b71595a9238494701f2" "checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a" "checksum rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ffd34691a510938bb67fe0444fb363103c73ffb31c121d1e16bc92d8945ea8ff" diff --git a/src/librustc_save_analysis/Cargo.toml b/src/librustc_save_analysis/Cargo.toml index 8b2658b2a88c4..005faa55b5884 100644 --- a/src/librustc_save_analysis/Cargo.toml +++ b/src/librustc_save_analysis/Cargo.toml @@ -15,7 +15,7 @@ rustc_data_structures = { path = "../librustc_data_structures" } rustc_typeck = { path = "../librustc_typeck" } syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } -rls-data = "0.14" +rls-data = "0.15" rls-span = "0.4" # FIXME(#40527) should move rustc serialize out of tree rustc-serialize = "0.3" diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 69cef20622b1e..47530c4208520 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -770,8 +770,12 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { impl_items: &'l [ast::ImplItem], ) { if let Some(impl_data) = self.save_ctxt.get_item_data(item) { - down_cast_data!(impl_data, RelationData, item.span); - self.dumper.dump_relation(impl_data); + if let super::Data::RelationData(rel, imp) = impl_data { + self.dumper.dump_relation(rel); + self.dumper.dump_impl(imp); + } else { + span_bug!(item.span, "unexpected data kind: {:?}", impl_data); + } } self.visit_ty(&typ); if let &Some(ref trait_ref) = trait_ref { diff --git a/src/librustc_save_analysis/json_dumper.rs b/src/librustc_save_analysis/json_dumper.rs index 2b35a4123836b..1b09df16a7d16 100644 --- a/src/librustc_save_analysis/json_dumper.rs +++ b/src/librustc_save_analysis/json_dumper.rs @@ -13,7 +13,7 @@ use std::io::Write; use rustc_serialize::json::as_json; use rls_data::{self, Analysis, CratePreludeData, Def, DefKind, Import, MacroRef, Ref, RefKind, - Relation}; + Relation, Impl}; use rls_data::config::Config; use rls_span::{Column, Row}; @@ -142,4 +142,8 @@ impl<'b, O: DumpOutput + 'b> JsonDumper { pub fn dump_relation(&mut self, data: Relation) { self.result.relations.push(data); } + + pub fn dump_impl(&mut self, data: Impl) { + self.result.impls.push(data); + } } diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 841350bdb68e1..490dc4e5ac4a9 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -45,6 +45,7 @@ use rustc::session::config::CrateType::CrateTypeExecutable; use rustc::ty::{self, TyCtxt}; use rustc_typeck::hir_ty_to_ty; +use std::cell::Cell; use std::default::Default; use std::env; use std::fs::File; @@ -65,7 +66,7 @@ use dump_visitor::DumpVisitor; use span_utils::SpanUtils; use rls_data::{Def, DefKind, ExternalCrateData, GlobalCrateId, MacroRef, Ref, RefKind, Relation, - RelationKind, SpanData}; + RelationKind, SpanData, Impl, ImplKind}; use rls_data::config::Config; @@ -75,13 +76,14 @@ pub struct SaveContext<'l, 'tcx: 'l> { analysis: &'l ty::CrateAnalysis, span_utils: SpanUtils<'tcx>, config: Config, + impl_counter: Cell, } #[derive(Debug)] pub enum Data { RefData(Ref), DefData(Def), - RelationData(Relation), + RelationData(Relation, Impl), } impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { @@ -315,7 +317,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { attributes: lower_attributes(item.attrs.to_owned(), self), })) } - ast::ItemKind::Impl(.., ref trait_ref, ref typ, _) => { + ast::ItemKind::Impl(.., ref trait_ref, ref typ, ref impls) => { if let ast::TyKind::Path(None, ref path) = typ.node { // Common case impl for a struct or something basic. if generated_code(path.span) { @@ -324,17 +326,39 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { let sub_span = self.span_utils.sub_span_for_type_name(path.span); filter!(self.span_utils, sub_span, typ.span, None); + let impl_id = self.next_impl_id(); + let span = self.span_from_span(sub_span.unwrap()); + let type_data = self.lookup_ref_id(typ.id); type_data.map(|type_data| { Data::RelationData(Relation { - kind: RelationKind::Impl, - span: self.span_from_span(sub_span.unwrap()), + kind: RelationKind::Impl { + id: impl_id, + }, + span: span.clone(), from: id_from_def_id(type_data), to: trait_ref .as_ref() .and_then(|t| self.lookup_ref_id(t.ref_id)) .map(id_from_def_id) .unwrap_or(null_id()), + }, + Impl { + id: impl_id, + kind: match *trait_ref { + Some(_) => ImplKind::Direct, + None => ImplKind::Inherent, + }, + span: span, + value: String::new(), + parent: None, + children: impls + .iter() + .map(|i| id_from_node_id(i.id, self)) + .collect(), + docs: String::new(), + sig: None, + attributes: vec![], }) }) } else { @@ -893,6 +917,12 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { result } + + fn next_impl_id(&self) -> u32 { + let next = self.impl_counter.get(); + self.impl_counter.set(next + 1); + next + } } fn make_signature(decl: &ast::FnDecl, generics: &ast::Generics) -> String { @@ -1099,6 +1129,7 @@ pub fn process_crate<'l, 'tcx, H: SaveHandler>( analysis, span_utils: SpanUtils::new(&tcx.sess), config: find_config(config), + impl_counter: Cell::new(0), }; handler.save(save_ctxt, krate, cratename) From 7ee3e39f640a9532842e1441bf6bc98893b6a3ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 10 Feb 2018 12:22:57 +0100 Subject: [PATCH 188/198] fix typos in src/{bootstrap,ci,etc,lib{backtrace,core,fmt_macros}} --- src/bootstrap/builder.rs | 2 +- src/bootstrap/lib.rs | 2 +- src/bootstrap/test.rs | 2 +- src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh | 2 +- src/etc/installer/msi/rust.wxs | 4 ++-- src/etc/platform-intrinsics/generator.py | 2 +- src/etc/test-float-parse/runtests.py | 2 +- src/libbacktrace/ltmain.sh | 2 +- src/libbacktrace/macho.c | 2 +- src/libcore/macros.rs | 2 +- src/libfmt_macros/lib.rs | 2 +- 11 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 6c68ee18506bb..03630dfbed3e0 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -570,7 +570,7 @@ impl<'a> Builder<'a> { // build scripts in that situation. // // If LLVM support is disabled we need to use the snapshot compiler to compile - // build scripts, as the new compiler doesnt support executables. + // build scripts, as the new compiler doesn't support executables. if mode == Mode::Libstd || !self.build.config.llvm_enabled { cargo.env("RUSTC_SNAPSHOT", &self.initial_rustc) .env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir()); diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index a84a6a8990bbd..83c270865c0b7 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -666,7 +666,7 @@ impl Build { } } - /// Returns the path to the linker for the given target if it needs to be overriden. + /// Returns the path to the linker for the given target if it needs to be overridden. fn linker(&self, target: Interned) -> Option<&Path> { if let Some(linker) = self.config.target_config.get(&target) .and_then(|c| c.linker.as_ref()) { diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index eae8ec1311df7..f6b95f0bf9744 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -902,7 +902,7 @@ impl Step for Compiletest { } } if suite == "run-make" && !build.config.llvm_enabled { - println!("Ignoring run-make test suite as they generally dont work without LLVM"); + println!("Ignoring run-make test suite as they generally don't work without LLVM"); return; } diff --git a/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh b/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh index 5b4314d57e6cc..e730dd86087fb 100755 --- a/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh +++ b/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh @@ -54,7 +54,7 @@ cd usr/src # The options, in order, do the following # * this is an unprivileged build # * output to a predictable location -# * disable various uneeded stuff +# * disable various unneeded stuff MKUNPRIVED=yes TOOLDIR=/x-tools/x86_64-unknown-netbsd \ MKSHARE=no MKDOC=no MKHTML=no MKINFO=no MKKMOD=no MKLINT=no MKMAN=no MKNLS=no MKPROFILE=no \ hide_output ./build.sh -j10 -m amd64 tools diff --git a/src/etc/installer/msi/rust.wxs b/src/etc/installer/msi/rust.wxs index d95b096d732f4..a471ccc6f5b48 100644 --- a/src/etc/installer/msi/rust.wxs +++ b/src/etc/installer/msi/rust.wxs @@ -18,7 +18,7 @@ - + @@ -129,7 +129,7 @@ - + diff --git a/src/etc/platform-intrinsics/generator.py b/src/etc/platform-intrinsics/generator.py index e9cf71c32fe9a..d9f78978a251e 100644 --- a/src/etc/platform-intrinsics/generator.py +++ b/src/etc/platform-intrinsics/generator.py @@ -591,7 +591,7 @@ def parse_args(): The X86 architecture is specified as multiple files (for the different instruction sets that x86 supports). To generate the compiler definitions one needs to pass the script a "platform information file" - (with the -i flag) next to the files of the different intruction sets. + (with the -i flag) next to the files of the different instruction sets. For example, to generate the X86 compiler-definitions for SSE4.2, just: python generator.py --format compiler-defs -i x86/info.json sse42.json diff --git a/src/etc/test-float-parse/runtests.py b/src/etc/test-float-parse/runtests.py index d520c9bd5c30a..e9f5bba2312d8 100644 --- a/src/etc/test-float-parse/runtests.py +++ b/src/etc/test-float-parse/runtests.py @@ -41,7 +41,7 @@ (as a fraction, using the ``fractions`` module). Given an input string and the corresponding float computed via Rust, simply -decode the float into f * 2^k (for intergers f, k) and the ULP. +decode the float into f * 2^k (for integers f, k) and the ULP. We can now easily compute the error and check if it is within 0.5 ULP as it should be. Zero and infinites are handled similarly: diff --git a/src/libbacktrace/ltmain.sh b/src/libbacktrace/ltmain.sh index eff9e62be8a05..fd23815fc617a 100644 --- a/src/libbacktrace/ltmain.sh +++ b/src/libbacktrace/ltmain.sh @@ -487,7 +487,7 @@ func_mkdir_p () # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited - # list incase some portion of path contains whitespace. + # list in case some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done diff --git a/src/libbacktrace/macho.c b/src/libbacktrace/macho.c index 9af14e724b40d..ba7f94c079f8a 100644 --- a/src/libbacktrace/macho.c +++ b/src/libbacktrace/macho.c @@ -327,7 +327,7 @@ macho_get_commands (struct backtrace_state *state, int descriptor, goto end; file_header_view_valid = 1; - // The endianess of the slice may be different than the fat image + // The endianness of the slice may be different than the fat image switch (*(uint32_t *) file_header_view.data) { case MH_MAGIC: diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index f00128a8147de..cc5cf6523a9e7 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -327,7 +327,7 @@ macro_rules! debug_assert_ne { /// } /// } /// -/// // The prefered method of quick returning Errors +/// // The preferred method of quick returning Errors /// fn write_to_file_question() -> Result<(), MyError> { /// let mut file = File::create("my_best_friends.txt")?; /// file.write_all(b"This is a list of my best friends.")?; diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 44cdb5e8a3676..71519ab21fef9 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -73,7 +73,7 @@ pub struct FormatSpec<'a> { /// Enum describing where an argument for a format can be located. #[derive(Copy, Clone, PartialEq)] pub enum Position<'a> { - /// The arugment is implied to be located at an index + /// The argument is implied to be located at an index ArgumentImplicitlyIs(usize), /// The argument is located at a specific index given in the format ArgumentIs(usize), From 49f7ccd35ff1522fc2479f4fcec06871f6d3dc80 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 8 Feb 2018 20:45:45 -0800 Subject: [PATCH 189/198] Update the dlmalloc submodule A bug was recently fixed in dlmalloc which meant that released memory to the system accidentally wasn't getting reused, causing programs to be far slower than they should be! --- src/dlmalloc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dlmalloc b/src/dlmalloc index a2b424b600235..9b2dcac06c3e2 160000 --- a/src/dlmalloc +++ b/src/dlmalloc @@ -1 +1 @@ -Subproject commit a2b424b600235af58f453577c2da1b0e1de2ffa5 +Subproject commit 9b2dcac06c3e23235f8997b3c5f2325a6d3382df From 3a967676f8f9c1d78d493b87c02490d78c5bc0f1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Sat, 10 Feb 2018 07:03:35 -0800 Subject: [PATCH 190/198] Explain unusual debugging code in librustc Introduced in #47828 to help track down some bugs, it landed a bit hastily so this is intended on cleaning it up a bit. --- src/librustc_resolve/resolve_imports.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 95a507ab9e351..8cb25f449b667 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -1026,9 +1026,14 @@ fn import_path_to_string(names: &[SpannedIdent], if names.is_empty() { import_directive_subclass_to_string(subclass) } else { - let x = format!("{}::{}", - names_to_string(names), - import_directive_subclass_to_string(subclass)); + // Note that this code looks a little wonky, it's currently here to + // hopefully help debug #48116, but otherwise isn't intended to + // cause any problems. + let x = format!( + "{}::{}", + names_to_string(names), + import_directive_subclass_to_string(subclass), + ); assert!(!names.is_empty()); assert!(!x.starts_with("::")); return x From 28b39f5d7aec44176b06fbbad0d5fc6e711d28f3 Mon Sep 17 00:00:00 2001 From: Aaron Power Date: Tue, 9 Jan 2018 01:38:58 +0000 Subject: [PATCH 191/198] Update release notes for 1.24.0 --- RELEASES.md | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index 45c389d72afc7..d6f95f52075d2 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,117 @@ +Version 1.24.0 (2018-02-15) +========================== + +Language +-------- +- [External `sysv64` ffi is now available.][46528] + eg. `extern "sysv64" fn foo () {}` + +Compiler +-------- +- [rustc now uses 16 codegen units by default for release builds.][46910] + For the fastest builds, utilize `codegen-units=1`. +- [Added `armv4t-unknown-linux-gnueabi` target.][47018] +- [Add `aarch64-unknown-openbsd` support][46760] + +Libraries +--------- +- [`str::find::` now uses memchr.][46735] This should lead to a 10x + improvement in performance in the majority of cases. +- [`OsStr`'s `Debug` implementation is now lossless and consistent + with Windows.][46798] +- [`time::{SystemTime, Instant}` now implement `Hash`.][46828] +- [impl `From` for `AtomicBool`][46293] +- [impl `From<{CString, &CStr}>` for `{Arc, Rc}`][45990] +- [impl `From<{OsString, &OsStr}>` for `{Arc, Rc}`][45990] +- [impl `From<{PathBuf, &Path}>` for `{Arc, Rc}`][45990] +- [float::from_bits now just uses transmute.][46012] This provides + some optimisations from LLVM. +- [Copied `AsciiExt` methods onto `char`][46077] +- [Remove `T: Sized` requirement on `ptr::is_null()`][46094] +- [impl `From` for `{TryRecvError, RecvTimeoutError}`][45506] +- [Optimised `f32::{min, max}` to generate more efficent x86 assembly][47080] +- [`[u8]::contains` now uses memchr which provides a 3x speed improvement][46713] + +Stabilized APIs +--------------- +- [`RefCell::replace`] +- [`RefCell::swap`] +- [`atomic::spin_loop_hint`] + +The following functions can now be used in a constant expression. +eg. `let buffer: [u8; size_of::()];`, `static COUNTER: AtomicUsize = AtomicUsize::new(1);` + +- [`AtomicBool::new`][46287] +- [`AtomicUsize::new`][46287] +- [`AtomicIsize::new`][46287] +- [`AtomicPtr::new`][46287] +- [`Cell::new`][46287] +- [`{integer}::min_value`][46287] +- [`{integer}::max_value`][46287] +- [`mem::size_of`][46287] +- [`mem::align_of`][46287] +- [`ptr::null`][46287] +- [`ptr::null_mut`][46287] +- [`RefCell::new`][46287] +- [`UnsafeCell::new`][46287] + +Cargo +----- +- [Added a `workspace.default-members` config that + overrides implied `--all` in virtual workspaces.][cargo/4743] +- [Enable incremental by default on development builds.][cargo/4817] Also added + configuration keys to `Cargo.toml` and `.cargo/config` to disable on a + per-project or global basis respectively. + +Misc +---- + +Compatibility Notes +------------------- +- [Floating point types `Debug` impl now always prints a decimal point.][46831] +- [`Ipv6Addr` now rejects superfluous `::`'s in IPv6 addresses][46671] This is + in accordance with IETF RFC 4291 §2.2. +- [Unwinding will no longer go past FFI boundaries, and will instead abort.][46833] +- [`Formatter::flags` method is now deprecated.][46284] The `sign_plus`, + `sign_minus`, `alternate`, and `sign_aware_zero_pad` should be used instead. +- [Leading zeros in tuple struct members is now an error][47084] +- [`column!()` macro is one-based instead of zero-based][46977] +- [`fmt::Arguments` can no longer be shared across threads][45198] +- [Access to `#[repr(packed)]` struct fields is now unsafe][44884] + +[44884]: https://github.com/rust-lang/rust/pull/44884 +[45198]: https://github.com/rust-lang/rust/pull/45198 +[45506]: https://github.com/rust-lang/rust/pull/45506 +[45904]: https://github.com/rust-lang/rust/pull/45904 +[45990]: https://github.com/rust-lang/rust/pull/45990 +[46012]: https://github.com/rust-lang/rust/pull/46012 +[46077]: https://github.com/rust-lang/rust/pull/46077 +[46094]: https://github.com/rust-lang/rust/pull/46094 +[46284]: https://github.com/rust-lang/rust/pull/46284 +[46287]: https://github.com/rust-lang/rust/pull/46287 +[46293]: https://github.com/rust-lang/rust/pull/46293 +[46528]: https://github.com/rust-lang/rust/pull/46528 +[46671]: https://github.com/rust-lang/rust/pull/46671 +[46713]: https://github.com/rust-lang/rust/pull/46713 +[46735]: https://github.com/rust-lang/rust/pull/46735 +[46749]: https://github.com/rust-lang/rust/pull/46749 +[46760]: https://github.com/rust-lang/rust/pull/46760 +[46798]: https://github.com/rust-lang/rust/pull/46798 +[46828]: https://github.com/rust-lang/rust/pull/46828 +[46831]: https://github.com/rust-lang/rust/pull/46831 +[46833]: https://github.com/rust-lang/rust/pull/46833 +[46910]: https://github.com/rust-lang/rust/pull/46910 +[46977]: https://github.com/rust-lang/rust/pull/46977 +[47018]: https://github.com/rust-lang/rust/pull/47018 +[47080]: https://github.com/rust-lang/rust/pull/47080 +[47084]: https://github.com/rust-lang/rust/pull/47084 +[cargo/4743]: https://github.com/rust-lang/cargo/pull/4743 +[cargo/4817]: https://github.com/rust-lang/cargo/pull/4817 +[`RefCell::replace`]: https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.replace +[`RefCell::swap`]: https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.swap +[`atomic::spin_loop_hint`]: https://doc.rust-lang.org/std/sync/atomic/fn.spin_loop_hint.html + + Version 1.23.0 (2018-01-04) ========================== From 66ee33a43730d99409a586a1fd437b320d14f903 Mon Sep 17 00:00:00 2001 From: kennytm Date: Mon, 12 Feb 2018 03:04:43 +0800 Subject: [PATCH 192/198] compiletest: Delete the executable immediately after running. This should save a lot of space on musl test cases (whose standard library are linked statically). --- src/tools/compiletest/src/runtest.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 46df211cbaf65..940721f1cc1f0 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1343,7 +1343,7 @@ impl<'test> TestCx<'test> { fn exec_compiled_test(&self) -> ProcRes { let env = &self.props.exec_env; - match &*self.config.target { + let proc_res = match &*self.config.target { // This is pretty similar to below, we're transforming: // // program arg1 arg2 @@ -1398,7 +1398,13 @@ impl<'test> TestCx<'test> { None, ) } - } + }; + + // delete the executable after running it to save space. + // it is ok if the deletion failed. + let _ = fs::remove_file(self.make_exe_name()); + + proc_res } /// For each `aux-build: foo/bar` annotation, we check to find the From 00bce71144643c7b6c46f9feb6be69de6a61ceed Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Sun, 11 Feb 2018 16:27:33 -0700 Subject: [PATCH 193/198] Delete executables if the test ran successfully. This isn't a perfect heuristic, but since the amount of run-fail tests is far lower than run-pass tests for now, it should be sufficient to ensure that we don't run into CI limits. This makes it possible to run the test binary manually (e.g., under gdb/lldb) if it failed to attempt to find out why. --- src/tools/compiletest/src/runtest.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 940721f1cc1f0..a87809dd7bcfd 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1400,9 +1400,11 @@ impl<'test> TestCx<'test> { } }; - // delete the executable after running it to save space. - // it is ok if the deletion failed. - let _ = fs::remove_file(self.make_exe_name()); + if proc_res.status.success() { + // delete the executable after running it to save space. + // it is ok if the deletion failed. + let _ = fs::remove_file(self.make_exe_name()); + } proc_res } From 6889c0816907f2352193f6aa124565bc3053dd82 Mon Sep 17 00:00:00 2001 From: csmoe <35686186+csmoe@users.noreply.github.com> Date: Tue, 13 Feb 2018 14:34:23 +0800 Subject: [PATCH 194/198] upate tests --- src/librustc_typeck/diagnostics.rs | 1 + src/test/compile-fail/E0619.rs | 19 ------------------- src/test/compile-fail/issue-15965.rs | 2 +- src/test/compile-fail/issue-2151.rs | 4 ++-- src/test/compile-fail/match-vec-mismatch.rs | 2 +- src/test/compile-fail/pat-tuple-bad-type.rs | 2 +- .../unboxed-closures-failed-recursive-fn-2.rs | 2 +- 7 files changed, 7 insertions(+), 25 deletions(-) delete mode 100644 src/test/compile-fail/E0619.rs diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index ac7f54250d32b..0465a6a0f11bd 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -4368,6 +4368,7 @@ i_am_a_function(); "##, E0619: r##" +#### Note: this error code is no longer emitted by the compiler. The type-checker needed to know the type of an expression, but that type had not yet been inferred. diff --git a/src/test/compile-fail/E0619.rs b/src/test/compile-fail/E0619.rs deleted file mode 100644 index a5a5ff7218dcf..0000000000000 --- a/src/test/compile-fail/E0619.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let x; - - match x { - (..) => {} //~ ERROR E0619 - _ => {} - } -} - diff --git a/src/test/compile-fail/issue-15965.rs b/src/test/compile-fail/issue-15965.rs index 08b896f387bbe..76ba5a0f4b371 100644 --- a/src/test/compile-fail/issue-15965.rs +++ b/src/test/compile-fail/issue-15965.rs @@ -11,7 +11,7 @@ fn main() { return { return () } -//~^ ERROR the type of this value must be known in this context +//~^ ERROR type annotations needed [E0282] () ; } diff --git a/src/test/compile-fail/issue-2151.rs b/src/test/compile-fail/issue-2151.rs index fbd8f9163b5df..65957f42fd86d 100644 --- a/src/test/compile-fail/issue-2151.rs +++ b/src/test/compile-fail/issue-2151.rs @@ -9,6 +9,6 @@ // except according to those terms. fn main() { - let x = panic!(); - x.clone(); //~ ERROR the type of this value must be known in this context + let x = panic!(); //~ ERROR type annotations needed [E0282] + x.clone(); } diff --git a/src/test/compile-fail/match-vec-mismatch.rs b/src/test/compile-fail/match-vec-mismatch.rs index fed68da006889..a241b589a30fb 100644 --- a/src/test/compile-fail/match-vec-mismatch.rs +++ b/src/test/compile-fail/match-vec-mismatch.rs @@ -43,6 +43,6 @@ fn main() { fn another_fn_to_avoid_suppression() { match Default::default() { - [] => {} //~ ERROR the type of this value + [] => {} //~ ERROR type annotations needed [E0282] }; } diff --git a/src/test/compile-fail/pat-tuple-bad-type.rs b/src/test/compile-fail/pat-tuple-bad-type.rs index fd4ab5d253158..0b350fec9d479 100644 --- a/src/test/compile-fail/pat-tuple-bad-type.rs +++ b/src/test/compile-fail/pat-tuple-bad-type.rs @@ -12,7 +12,7 @@ fn main() { let x; match x { - (..) => {} //~ ERROR the type of this value must be known in this context + (..) => {} //~ ERROR type annotations needed [E0282] _ => {} } diff --git a/src/test/compile-fail/unboxed-closures-failed-recursive-fn-2.rs b/src/test/compile-fail/unboxed-closures-failed-recursive-fn-2.rs index 12b48b2a6c8aa..e9209616e57b5 100644 --- a/src/test/compile-fail/unboxed-closures-failed-recursive-fn-2.rs +++ b/src/test/compile-fail/unboxed-closures-failed-recursive-fn-2.rs @@ -24,7 +24,7 @@ fn a() { match closure0.take() { Some(c) => { return c(); - //~^ ERROR the type of this value must be known in this context + //~^ ERROR type annotations needed [E0282] } None => { } } From 32e9f6b6feb85aa721cf7e66e0a4dd7d9421a183 Mon Sep 17 00:00:00 2001 From: csmoe <35686186+csmoe@users.noreply.github.com> Date: Sat, 3 Feb 2018 20:22:33 +0800 Subject: [PATCH 195/198] inform user where to give a type annotation after a call to collect --- src/librustc_typeck/check/mod.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index 165b499cc62aa..e760636230d18 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -5086,9 +5086,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // If not, error. if alternative.is_ty_var() || alternative.references_error() { if !self.is_tainted_by_errors() { - type_error_struct!(self.tcx.sess, sp, ty, E0619, - "the type of this value must be known in this context") - .emit(); + self.need_type_info((**self).body_id, sp, ty); } self.demand_suptype(sp, self.tcx.types.err, ty); ty = self.tcx.types.err; From 2b16b6512d0cc38c0e4f42ada6ea7422169aabc4 Mon Sep 17 00:00:00 2001 From: csmoe <35686186+csmoe@users.noreply.github.com> Date: Tue, 13 Feb 2018 14:34:23 +0800 Subject: [PATCH 196/198] upate tests --- src/librustc_typeck/diagnostics.rs | 1 + src/test/compile-fail/issue-15965.rs | 2 +- src/test/compile-fail/issue-2151.rs | 4 ++-- src/test/compile-fail/match-vec-mismatch.rs | 2 +- src/test/compile-fail/pat-tuple-bad-type.rs | 2 +- .../unboxed-closures-failed-recursive-fn-2.rs | 2 +- src/test/ui/error-codes/E0619.rs | 19 ------------------- 7 files changed, 7 insertions(+), 25 deletions(-) delete mode 100644 src/test/ui/error-codes/E0619.rs diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index f59948e9fc42f..b5b13d120a343 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -4368,6 +4368,7 @@ i_am_a_function(); "##, E0619: r##" +#### Note: this error code is no longer emitted by the compiler. The type-checker needed to know the type of an expression, but that type had not yet been inferred. diff --git a/src/test/compile-fail/issue-15965.rs b/src/test/compile-fail/issue-15965.rs index 08b896f387bbe..76ba5a0f4b371 100644 --- a/src/test/compile-fail/issue-15965.rs +++ b/src/test/compile-fail/issue-15965.rs @@ -11,7 +11,7 @@ fn main() { return { return () } -//~^ ERROR the type of this value must be known in this context +//~^ ERROR type annotations needed [E0282] () ; } diff --git a/src/test/compile-fail/issue-2151.rs b/src/test/compile-fail/issue-2151.rs index fbd8f9163b5df..65957f42fd86d 100644 --- a/src/test/compile-fail/issue-2151.rs +++ b/src/test/compile-fail/issue-2151.rs @@ -9,6 +9,6 @@ // except according to those terms. fn main() { - let x = panic!(); - x.clone(); //~ ERROR the type of this value must be known in this context + let x = panic!(); //~ ERROR type annotations needed [E0282] + x.clone(); } diff --git a/src/test/compile-fail/match-vec-mismatch.rs b/src/test/compile-fail/match-vec-mismatch.rs index fed68da006889..a241b589a30fb 100644 --- a/src/test/compile-fail/match-vec-mismatch.rs +++ b/src/test/compile-fail/match-vec-mismatch.rs @@ -43,6 +43,6 @@ fn main() { fn another_fn_to_avoid_suppression() { match Default::default() { - [] => {} //~ ERROR the type of this value + [] => {} //~ ERROR type annotations needed [E0282] }; } diff --git a/src/test/compile-fail/pat-tuple-bad-type.rs b/src/test/compile-fail/pat-tuple-bad-type.rs index fd4ab5d253158..0b350fec9d479 100644 --- a/src/test/compile-fail/pat-tuple-bad-type.rs +++ b/src/test/compile-fail/pat-tuple-bad-type.rs @@ -12,7 +12,7 @@ fn main() { let x; match x { - (..) => {} //~ ERROR the type of this value must be known in this context + (..) => {} //~ ERROR type annotations needed [E0282] _ => {} } diff --git a/src/test/compile-fail/unboxed-closures-failed-recursive-fn-2.rs b/src/test/compile-fail/unboxed-closures-failed-recursive-fn-2.rs index 12b48b2a6c8aa..e9209616e57b5 100644 --- a/src/test/compile-fail/unboxed-closures-failed-recursive-fn-2.rs +++ b/src/test/compile-fail/unboxed-closures-failed-recursive-fn-2.rs @@ -24,7 +24,7 @@ fn a() { match closure0.take() { Some(c) => { return c(); - //~^ ERROR the type of this value must be known in this context + //~^ ERROR type annotations needed [E0282] } None => { } } diff --git a/src/test/ui/error-codes/E0619.rs b/src/test/ui/error-codes/E0619.rs deleted file mode 100644 index a5a5ff7218dcf..0000000000000 --- a/src/test/ui/error-codes/E0619.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - let x; - - match x { - (..) => {} //~ ERROR E0619 - _ => {} - } -} - From db99689117034c7b3f3682f038026cf6a54879a3 Mon Sep 17 00:00:00 2001 From: csmoe <35686186+csmoe@users.noreply.github.com> Date: Tue, 13 Feb 2018 17:27:31 +0800 Subject: [PATCH 197/198] rebase --- src/binaryen | 2 +- src/dlmalloc | 2 +- src/doc/book | 2 +- src/doc/nomicon | 2 +- src/doc/reference | 2 +- src/doc/rust-by-example | 2 +- src/libcompiler_builtins | 2 +- src/librustc_typeck/diagnostics.rs | 2 +- src/llvm | 2 +- src/test/ui/span/issue-42234-unknown-receiver-type.rs | 4 ++-- src/tools/clippy | 2 +- src/tools/miri | 2 +- src/tools/rls | 2 +- src/tools/rustfmt | 2 +- 14 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/binaryen b/src/binaryen index 17841e155edf8..1c9bf65aa0e37 160000 --- a/src/binaryen +++ b/src/binaryen @@ -1 +1 @@ -Subproject commit 17841e155edf858c8ea7802dd5f5ecbef54b989f +Subproject commit 1c9bf65aa0e371b84755a8ddd6e79497fac57171 diff --git a/src/dlmalloc b/src/dlmalloc index 9b2dcac06c3e2..d3812c3accaee 160000 --- a/src/dlmalloc +++ b/src/dlmalloc @@ -1 +1 @@ -Subproject commit 9b2dcac06c3e23235f8997b3c5f2325a6d3382df +Subproject commit d3812c3accaee7ad23068ed4fc089cc05c7a538f diff --git a/src/doc/book b/src/doc/book index ec5660820dea9..194eb8d5f1753 160000 --- a/src/doc/book +++ b/src/doc/book @@ -1 +1 @@ -Subproject commit ec5660820dea91df470dab0b9eb26ef798f20889 +Subproject commit 194eb8d5f1753fb5f4501011cebdc1b585712474 diff --git a/src/doc/nomicon b/src/doc/nomicon index ad5ddd62c098d..fec3182d0b0a3 160000 --- a/src/doc/nomicon +++ b/src/doc/nomicon @@ -1 +1 @@ -Subproject commit ad5ddd62c098d5b424151beda574ae7df2154df1 +Subproject commit fec3182d0b0a3cf8122e192b3270064a5b19be5b diff --git a/src/doc/reference b/src/doc/reference index 254df654a9b75..1d791b55b23ec 160000 --- a/src/doc/reference +++ b/src/doc/reference @@ -1 +1 @@ -Subproject commit 254df654a9b75abf6ca08806535dbe1fad41be3f +Subproject commit 1d791b55b23ec5389fbd5b3cee80db3f8bbdd162 diff --git a/src/doc/rust-by-example b/src/doc/rust-by-example index 919980be7df4e..4ebb8169dfe56 160000 --- a/src/doc/rust-by-example +++ b/src/doc/rust-by-example @@ -1 +1 @@ -Subproject commit 919980be7df4ea7d45a9dca8efc34da89bcf7d6b +Subproject commit 4ebb8169dfe569b3dcbeab560607800bb717978a diff --git a/src/libcompiler_builtins b/src/libcompiler_builtins index 345447948f7a5..0a95675bab808 160000 --- a/src/libcompiler_builtins +++ b/src/libcompiler_builtins @@ -1 +1 @@ -Subproject commit 345447948f7a51eca970fa036cefd613d54a4f79 +Subproject commit 0a95675bab808c49f86208bacc89c5d9c53ac43f diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index b5b13d120a343..1c0e084832ebc 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -4374,7 +4374,7 @@ yet been inferred. Erroneous code example: -```compile_fail,E0619 +```compile_fail let mut x = vec![]; match x.pop() { Some(v) => { diff --git a/src/llvm b/src/llvm index 9f81beaf32608..bc344d5bc23c6 160000 --- a/src/llvm +++ b/src/llvm @@ -1 +1 @@ -Subproject commit 9f81beaf32608fbe1fe0f2a82f974e800e9d8c62 +Subproject commit bc344d5bc23c61ff9baf82d268a0edf199933cc3 diff --git a/src/test/ui/span/issue-42234-unknown-receiver-type.rs b/src/test/ui/span/issue-42234-unknown-receiver-type.rs index d9cdd99c245e6..2d910b520ff9f 100644 --- a/src/test/ui/span/issue-42234-unknown-receiver-type.rs +++ b/src/test/ui/span/issue-42234-unknown-receiver-type.rs @@ -15,11 +15,11 @@ fn shines_a_beacon_through_the_darkness() { let x: Option<_> = None; x.unwrap().method_that_could_exist_on_some_type(); - //~^ ERROR 17:5: 17:15: the type of this value must be known in this context + //~^ ERROR 17:5: 17:15: type annotations needed [E0282] } fn courier_to_des_moines_and_points_west(data: &[u32]) -> String { - data.iter() //~ ERROR 22:5: 23:20: the type of this value must be known in this context + data.iter() //~ ERROR 22:5: 23:20: type annotations needed [E0282] .sum::<_>() .to_string() } diff --git a/src/tools/clippy b/src/tools/clippy index ce47e529d29f0..7d7fef1690218 160000 --- a/src/tools/clippy +++ b/src/tools/clippy @@ -1 +1 @@ -Subproject commit ce47e529d29f0bf19b31ae80b37b467e42fb97e2 +Subproject commit 7d7fef1690218bbb406cf3bcadf7bb29dbb40cc5 diff --git a/src/tools/miri b/src/tools/miri index 61833b9aeab8b..919604e1ead82 160000 --- a/src/tools/miri +++ b/src/tools/miri @@ -1 +1 @@ -Subproject commit 61833b9aeab8bf8f0c0c0e42b7c96b6eceb37d0d +Subproject commit 919604e1ead8294c8ca14f101be4380ea1ea370c diff --git a/src/tools/rls b/src/tools/rls index dee42bda8156a..511321ae1c2fa 160000 --- a/src/tools/rls +++ b/src/tools/rls @@ -1 +1 @@ -Subproject commit dee42bda8156a28ead609080e27b02173bb9c29e +Subproject commit 511321ae1c2fa3f0e334885fecf406dd6c882836 diff --git a/src/tools/rustfmt b/src/tools/rustfmt index 346238f49740d..e0e3e22248cd1 160000 --- a/src/tools/rustfmt +++ b/src/tools/rustfmt @@ -1 +1 @@ -Subproject commit 346238f49740d6c98102a6a59811b1625c73a9d7 +Subproject commit e0e3e22248cd14ebbe0253e9720261a0328bfc59 From 57437f26f37da21708dec62e37255080e7a711fe Mon Sep 17 00:00:00 2001 From: csmoe <35686186+csmoe@users.noreply.github.com> Date: Tue, 13 Feb 2018 18:49:41 +0800 Subject: [PATCH 198/198] Revert "Merge branch 'give_type_annotation_after_collect' of https://github.com/csmoe/rust into give_type_annotation_after_collect" This reverts commit 9a394719bcd53862942495a8bffd71174d3f747c, reversing changes made to 6889c0816907f2352193f6aa124565bc3053dd82. --- RELEASES.md | 114 ---- config.toml.example | 18 +- src/Cargo.lock | 146 ++---- src/Cargo.toml | 1 - src/bootstrap/Cargo.toml | 1 - src/bootstrap/builder.rs | 69 +-- src/bootstrap/check.rs | 1 + src/bootstrap/compile.rs | 3 +- src/bootstrap/config.rs | 13 +- src/bootstrap/configure.py | 2 - src/bootstrap/dist.rs | 21 +- src/bootstrap/install.rs | 30 +- src/bootstrap/lib.rs | 6 +- src/bootstrap/native.rs | 2 +- src/bootstrap/test.rs | 55 +- src/bootstrap/tool.rs | 1 - src/ci/docker/dist-i686-freebsd/Dockerfile | 2 +- src/ci/docker/dist-i686-linux/Dockerfile | 3 +- .../build-netbsd-toolchain.sh | 2 +- src/ci/docker/x86_64-gnu-tools/checktools.sh | 2 +- src/ci/run.sh | 1 - .../src/language-features/generators.md | 6 +- .../src/language-features/lang-items.md | 21 +- .../macro-at-most-once-rep.md | 17 - .../language-features/match-beginning-vert.md | 23 + .../language-features/use-nested-groups.md | 90 ++++ src/etc/installer/msi/rust.wxs | 4 +- src/etc/platform-intrinsics/generator.py | 2 +- src/etc/test-float-parse/runtests.py | 2 +- src/etc/wasm32-shim.js | 149 +++--- src/liballoc/btree/map.rs | 5 - src/libbacktrace/ltmain.sh | 2 +- src/libbacktrace/macho.c | 2 +- src/libcore/any.rs | 27 - src/libcore/char.rs | 2 +- src/libcore/convert.rs | 6 +- src/libcore/fmt/mod.rs | 19 +- src/libcore/fmt/num.rs | 1 - src/libcore/intrinsics.rs | 2 +- src/libcore/iter/iterator.rs | 13 +- src/libcore/iter/mod.rs | 61 --- src/libcore/iter/range.rs | 77 +-- src/libcore/iter/sources.rs | 3 - src/libcore/iter/traits.rs | 6 +- src/libcore/lib.rs | 2 - src/libcore/macros.rs | 2 +- src/libcore/mem.rs | 1 - src/libcore/num/f32.rs | 4 +- src/libcore/num/f64.rs | 3 - src/libcore/ops/arith.rs | 40 +- src/libcore/ops/bit.rs | 30 +- src/libcore/ptr.rs | 87 +--- src/libcore/sync/atomic.rs | 46 -- src/libcore/tests/atomic.rs | 14 - src/libcore/tests/iter.rs | 144 ------ src/libcore/tests/lib.rs | 1 - src/libfmt_macros/lib.rs | 2 +- src/libpanic_abort/lib.rs | 3 - src/libproc_macro/lib.rs | 2 +- src/librustc/README.md | 1 - src/librustc/dep_graph/dep_node.rs | 3 - src/librustc/diagnostics.rs | 22 - src/librustc/hir/intravisit.rs | 2 +- src/librustc/ich/impls_mir.rs | 24 +- src/librustc/ich/impls_ty.rs | 14 - src/librustc/infer/error_reporting/mod.rs | 71 +-- src/librustc/infer/error_reporting/note.rs | 10 +- src/librustc/lib.rs | 2 - src/librustc/lint/builtin.rs | 10 +- src/librustc/lint/context.rs | 21 +- src/librustc/middle/entry.rs | 4 - src/librustc/middle/expr_use_visitor.rs | 2 +- src/librustc/middle/liveness.rs | 63 +-- src/librustc/middle/region.rs | 9 +- src/librustc/middle/resolve_lifetime.rs | 16 +- src/librustc/mir/mod.rs | 62 +-- src/librustc/mir/tcx.rs | 7 +- src/librustc/mir/visit.rs | 16 +- src/librustc/session/config.rs | 68 +-- src/librustc/session/mod.rs | 32 +- src/librustc/traits/coherence.rs | 50 +- src/librustc/traits/error_reporting.rs | 176 +++---- src/librustc/traits/mod.rs | 15 - src/librustc/traits/on_unimplemented.rs | 37 +- src/librustc/traits/select.rs | 104 ++-- .../traits/specialize/specialization_graph.rs | 37 +- src/librustc/traits/structural_impls.rs | 3 - src/librustc/ty/adjustment.rs | 17 +- src/librustc/ty/layout.rs | 171 +++--- src/librustc/ty/maps/mod.rs | 1 - src/librustc/ty/maps/plumbing.rs | 2 - src/librustc/ty/sty.rs | 13 +- src/librustc/util/nodemap.rs | 4 +- src/librustc_back/target/mod.rs | 7 - src/librustc_back/target/msp430_none_elf.rs | 6 - .../target/wasm32_unknown_unknown.rs | 3 - src/librustc_binaryen/BinaryenWrapper.cpp | 34 +- src/librustc_binaryen/lib.rs | 22 - src/librustc_borrowck/borrowck/mod.rs | 12 +- src/librustc_borrowck/borrowck/unused.rs | 2 +- src/librustc_const_eval/check_match.rs | 11 +- src/librustc_const_eval/eval.rs | 7 +- src/librustc_const_eval/pattern.rs | 15 +- src/librustc_data_structures/blake2b.rs | 363 +++++++++++++ src/librustc_data_structures/lib.rs | 2 + src/librustc_data_structures/veccell/mod.rs | 47 ++ src/librustc_driver/driver.rs | 106 +--- src/librustc_driver/lib.rs | 35 +- src/librustc_errors/diagnostic.rs | 37 -- src/librustc_errors/diagnostic_builder.rs | 10 - src/librustc_errors/emitter.rs | 44 +- src/librustc_errors/lib.rs | 8 +- src/librustc_errors/snippet.rs | 23 + src/librustc_errors/styled_buffer.rs | 21 - src/librustc_lint/types.rs | 4 +- src/librustc_lint/unused.rs | 43 +- .../borrow_check/error_reporting.rs | 41 +- src/librustc_mir/borrow_check/mod.rs | 90 ++-- .../nll/region_infer/annotation.rs | 7 +- .../borrow_check/nll/type_check/liveness.rs | 115 ++--- .../borrow_check/nll/type_check/mod.rs | 51 +- .../borrow_check/nll/universal_regions.rs | 77 ++- src/librustc_mir/build/expr/into.rs | 38 +- src/librustc_mir/build/matches/mod.rs | 22 +- .../dataflow/impls/borrowed_locals.rs | 118 ----- src/librustc_mir/dataflow/impls/borrows.rs | 6 +- src/librustc_mir/dataflow/impls/mod.rs | 4 - src/librustc_mir/dataflow/mod.rs | 9 - .../dataflow/move_paths/builder.rs | 1 - src/librustc_mir/hair/cx/expr.rs | 70 +-- src/librustc_mir/interpret/const_eval.rs | 6 - src/librustc_mir/interpret/eval_context.rs | 6 +- src/librustc_mir/interpret/terminator/mod.rs | 1 - src/librustc_mir/monomorphize/collector.rs | 3 +- src/librustc_mir/monomorphize/partitioning.rs | 18 +- src/librustc_mir/shim.rs | 148 +++--- src/librustc_mir/transform/check_unsafety.rs | 3 +- src/librustc_mir/transform/generator.rs | 68 +-- src/librustc_mir/transform/inline.rs | 10 +- src/librustc_mir/transform/promote_consts.rs | 19 +- src/librustc_mir/transform/qualify_consts.rs | 220 ++------ .../transform/remove_noop_landing_pads.rs | 3 +- .../transform/simplify_branches.rs | 3 - src/librustc_mir/util/elaborate_drops.rs | 10 +- src/librustc_passes/consts.rs | 18 +- src/librustc_passes/loops.rs | 5 - src/librustc_passes/mir_stats.rs | 1 - src/librustc_resolve/lib.rs | 12 +- src/librustc_resolve/resolve_imports.rs | 14 +- src/librustc_save_analysis/Cargo.toml | 2 +- src/librustc_save_analysis/dump_visitor.rs | 8 +- src/librustc_save_analysis/json_dumper.rs | 6 +- src/librustc_save_analysis/lib.rs | 54 +- src/librustc_trans/allocator.rs | 4 - src/librustc_trans/asm.rs | 5 +- src/librustc_trans/back/symbol_export.rs | 3 - src/librustc_trans/back/write.rs | 24 +- src/librustc_trans/cabi_x86_64.rs | 13 +- src/librustc_trans/context.rs | 3 +- src/librustc_trans/llvm_util.rs | 6 +- src/librustc_trans/mir/analyze.rs | 3 +- src/librustc_trans/mir/block.rs | 5 +- src/librustc_trans/mir/constant.rs | 11 +- src/librustc_trans/mir/rvalue.rs | 4 - src/librustc_trans/type_of.rs | 4 +- src/librustc_typeck/check/_match.rs | 94 +--- src/librustc_typeck/check/callee.rs | 13 +- src/librustc_typeck/check/coercion.rs | 22 +- src/librustc_typeck/check/compare_method.rs | 37 +- .../check/generator_interior.rs | 8 +- src/librustc_typeck/check/method/confirm.rs | 23 +- src/librustc_typeck/check/method/probe.rs | 18 +- src/librustc_typeck/check/mod.rs | 67 +-- src/librustc_typeck/check/op.rs | 24 +- src/librustc_typeck/check/regionck.rs | 2 +- .../coherence/inherent_impls_overlap.rs | 46 +- src/librustc_typeck/collect.rs | 36 +- src/librustc_typeck/diagnostics.rs | 51 +- src/librustdoc/clean/mod.rs | 15 +- src/librustdoc/clean/simplify.rs | 4 +- src/librustdoc/html/markdown.rs | 2 +- src/librustdoc/html/static/main.js | 15 +- src/librustdoc/html/static/rustdoc.css | 61 +-- src/librustdoc/html/static/themes/dark.css | 5 +- src/librustdoc/lib.rs | 53 +- src/librustdoc/test.rs | 1 - src/librustdoc/theme.rs | 379 -------------- src/libstd/Cargo.toml | 1 - src/libstd/collections/hash/map.rs | 9 +- src/libstd/f32.rs | 1 - src/libstd/ffi/c_str.rs | 18 +- src/libstd/fs.rs | 38 +- src/libstd/io/error.rs | 8 +- src/libstd/lib.rs | 1 - src/libstd/os/{raw/mod.rs => raw.rs} | 38 +- src/libstd/os/raw/char.md | 11 - src/libstd/os/raw/double.md | 7 - src/libstd/os/raw/float.md | 6 - src/libstd/os/raw/int.md | 7 - src/libstd/os/raw/long.md | 7 - src/libstd/os/raw/longlong.md | 7 - src/libstd/os/raw/schar.md | 6 - src/libstd/os/raw/short.md | 6 - src/libstd/os/raw/uchar.md | 6 - src/libstd/os/raw/uint.md | 7 - src/libstd/os/raw/ulong.md | 7 - src/libstd/os/raw/ulonglong.md | 7 - src/libstd/os/raw/ushort.md | 6 - src/libstd/panic.rs | 2 +- src/libstd/process.rs | 6 - src/libstd/sys/cloudabi/thread.rs | 5 +- src/libstd/sys/redox/thread.rs | 5 +- src/libstd/sys/unix/process/process_common.rs | 16 +- src/libstd/sys/unix/stack_overflow.rs | 9 +- src/libstd/sys/unix/thread.rs | 115 ++--- src/libstd/sys/wasm/args.rs | 38 +- src/libstd/sys/wasm/mod.rs | 233 +-------- src/libstd/sys/wasm/os.rs | 38 +- src/libstd/sys/wasm/stdio.rs | 35 +- src/libstd/sys/wasm/thread.rs | 5 +- src/libstd/sys/wasm/time.rs | 44 +- src/libstd/sys/windows/thread.rs | 5 +- src/libstd/sys_common/thread_info.rs | 9 +- .../time.rs => libstd/time/duration.rs} | 15 +- src/libstd/{time.rs => time/mod.rs} | 4 +- src/libsyntax/ast.rs | 1 + src/libsyntax/codemap.rs | 26 +- src/libsyntax/ext/build.rs | 1 + src/libsyntax/ext/tt/macro_parser.rs | 488 +++++------------- src/libsyntax/ext/tt/macro_rules.rs | 6 +- src/libsyntax/ext/tt/quoted.rs | 363 +++---------- src/libsyntax/feature_gate.rs | 54 +- src/libsyntax/fold.rs | 3 +- src/libsyntax/json.rs | 42 +- src/libsyntax/lib.rs | 1 - src/libsyntax/parse/lexer/mod.rs | 32 +- src/libsyntax/parse/parser.rs | 38 +- src/libsyntax/parse/token.rs | 1 - src/libsyntax/test_snippet.rs | 1 - src/libsyntax_ext/asm.rs | 6 - src/libsyntax_ext/deriving/encodable.rs | 16 +- src/libsyntax_pos/lib.rs | 23 +- src/libtest/lib.rs | 17 +- src/rustllvm/PassWrapper.cpp | 11 - src/rustllvm/RustWrapper.cpp | 2 - src/rustllvm/llvm-rebuild-trigger | 2 +- src/test/codegen/function-arguments.rs | 4 +- src/test/codegen/no-output-asm-is-volatile.rs | 26 - src/test/codegen/repeat-trusted-len.rs | 23 - src/test/codegen/repr-transparent-sysv64.rs | 39 -- src/test/codegen/repr-transparent.rs | 60 ++- src/test/codegen/stack-probes.rs | 2 +- .../{ui/error-codes => compile-fail}/E0001.rs | 0 .../error-codes => compile-fail}/E0004-2.rs | 0 .../{ui/error-codes => compile-fail}/E0004.rs | 0 .../{ui/error-codes => compile-fail}/E0005.rs | 0 .../{ui/error-codes => compile-fail}/E0007.rs | 0 .../{ui/error-codes => compile-fail}/E0008.rs | 0 .../{ui/error-codes => compile-fail}/E0009.rs | 0 .../{ui/error-codes => compile-fail}/E0010.rs | 0 .../{ui/error-codes => compile-fail}/E0017.rs | 0 .../{ui/error-codes => compile-fail}/E0023.rs | 0 .../{ui/error-codes => compile-fail}/E0025.rs | 0 .../{ui/error-codes => compile-fail}/E0026.rs | 0 .../{ui/error-codes => compile-fail}/E0027.rs | 0 .../{ui/error-codes => compile-fail}/E0029.rs | 0 .../{ui/error-codes => compile-fail}/E0030.rs | 0 .../{ui/error-codes => compile-fail}/E0033.rs | 0 .../{ui/error-codes => compile-fail}/E0034.rs | 0 .../{ui/error-codes => compile-fail}/E0038.rs | 0 .../{ui/error-codes => compile-fail}/E0040.rs | 0 .../{ui/error-codes => compile-fail}/E0044.rs | 0 .../{ui/error-codes => compile-fail}/E0045.rs | 0 .../{ui/error-codes => compile-fail}/E0049.rs | 0 .../{ui/error-codes => compile-fail}/E0050.rs | 0 .../{ui/error-codes => compile-fail}/E0054.rs | 0 .../{ui/error-codes => compile-fail}/E0055.rs | 0 .../{ui/error-codes => compile-fail}/E0057.rs | 0 .../{ui/error-codes => compile-fail}/E0059.rs | 0 .../{ui/error-codes => compile-fail}/E0060.rs | 0 .../{ui/error-codes => compile-fail}/E0061.rs | 0 .../{ui/error-codes => compile-fail}/E0062.rs | 0 .../{ui/error-codes => compile-fail}/E0063.rs | 0 .../{ui/error-codes => compile-fail}/E0067.rs | 0 .../{ui/error-codes => compile-fail}/E0069.rs | 0 .../{ui/error-codes => compile-fail}/E0070.rs | 0 .../{ui/error-codes => compile-fail}/E0071.rs | 0 .../{ui/error-codes => compile-fail}/E0075.rs | 0 .../{ui/error-codes => compile-fail}/E0076.rs | 0 .../{ui/error-codes => compile-fail}/E0077.rs | 0 .../{ui/error-codes => compile-fail}/E0080.rs | 0 .../{ui/error-codes => compile-fail}/E0081.rs | 0 .../{ui/error-codes => compile-fail}/E0084.rs | 0 .../{ui/error-codes => compile-fail}/E0087.rs | 0 .../{ui/error-codes => compile-fail}/E0088.rs | 0 .../{ui/error-codes => compile-fail}/E0089.rs | 0 .../{ui/error-codes => compile-fail}/E0090.rs | 0 .../{ui/error-codes => compile-fail}/E0091.rs | 0 .../{ui/error-codes => compile-fail}/E0092.rs | 0 .../{ui/error-codes => compile-fail}/E0093.rs | 0 .../{ui/error-codes => compile-fail}/E0094.rs | 0 .../{ui/error-codes => compile-fail}/E0106.rs | 0 .../{ui/error-codes => compile-fail}/E0107.rs | 0 .../{ui/error-codes => compile-fail}/E0109.rs | 0 .../{ui/error-codes => compile-fail}/E0110.rs | 0 .../{ui/error-codes => compile-fail}/E0116.rs | 0 .../{ui/error-codes => compile-fail}/E0117.rs | 0 .../{ui/error-codes => compile-fail}/E0118.rs | 0 .../{ui/error-codes => compile-fail}/E0119.rs | 0 .../{ui/error-codes => compile-fail}/E0120.rs | 0 .../{ui/error-codes => compile-fail}/E0121.rs | 0 .../{ui/error-codes => compile-fail}/E0124.rs | 0 .../{ui/error-codes => compile-fail}/E0128.rs | 0 .../{ui/error-codes => compile-fail}/E0130.rs | 0 .../{ui/error-codes => compile-fail}/E0131.rs | 0 .../{ui/error-codes => compile-fail}/E0132.rs | 0 .../{ui/error-codes => compile-fail}/E0133.rs | 0 .../{ui/error-codes => compile-fail}/E0137.rs | 0 .../{ui/error-codes => compile-fail}/E0138.rs | 0 .../{ui/error-codes => compile-fail}/E0152.rs | 0 .../{ui/error-codes => compile-fail}/E0161.rs | 0 .../{ui/error-codes => compile-fail}/E0162.rs | 0 .../{ui/error-codes => compile-fail}/E0164.rs | 0 .../{ui/error-codes => compile-fail}/E0165.rs | 0 .../{ui/error-codes => compile-fail}/E0184.rs | 0 .../{ui/error-codes => compile-fail}/E0185.rs | 0 .../{ui/error-codes => compile-fail}/E0186.rs | 0 .../{ui/error-codes => compile-fail}/E0191.rs | 0 .../{ui/error-codes => compile-fail}/E0192.rs | 0 .../{ui/error-codes => compile-fail}/E0194.rs | 0 .../{ui/error-codes => compile-fail}/E0195.rs | 3 +- .../{ui/error-codes => compile-fail}/E0197.rs | 0 .../{ui/error-codes => compile-fail}/E0198.rs | 0 .../{ui/error-codes => compile-fail}/E0199.rs | 0 .../{ui/error-codes => compile-fail}/E0200.rs | 0 .../{ui/error-codes => compile-fail}/E0201.rs | 0 .../{ui/error-codes => compile-fail}/E0206.rs | 0 .../{ui/error-codes => compile-fail}/E0207.rs | 0 .../{ui/error-codes => compile-fail}/E0214.rs | 0 .../{ui/error-codes => compile-fail}/E0220.rs | 0 .../{ui/error-codes => compile-fail}/E0221.rs | 0 .../{ui/error-codes => compile-fail}/E0223.rs | 0 .../{ui/error-codes => compile-fail}/E0225.rs | 0 .../{ui/error-codes => compile-fail}/E0229.rs | 0 .../{ui/error-codes => compile-fail}/E0232.rs | 0 .../{ui/error-codes => compile-fail}/E0243.rs | 0 .../{ui/error-codes => compile-fail}/E0244.rs | 0 .../{ui/error-codes => compile-fail}/E0252.rs | 0 .../{ui/error-codes => compile-fail}/E0253.rs | 0 .../{ui/error-codes => compile-fail}/E0254.rs | 0 .../{ui/error-codes => compile-fail}/E0255.rs | 0 .../{ui/error-codes => compile-fail}/E0259.rs | 0 .../{ui/error-codes => compile-fail}/E0260.rs | 0 .../{ui/error-codes => compile-fail}/E0261.rs | 0 .../{ui/error-codes => compile-fail}/E0262.rs | 0 .../{ui/error-codes => compile-fail}/E0263.rs | 0 .../{ui/error-codes => compile-fail}/E0264.rs | 0 .../{ui/error-codes => compile-fail}/E0267.rs | 0 .../{ui/error-codes => compile-fail}/E0268.rs | 0 .../{ui/error-codes => compile-fail}/E0271.rs | 0 .../{ui/error-codes => compile-fail}/E0275.rs | 0 .../{ui/error-codes => compile-fail}/E0276.rs | 0 .../error-codes => compile-fail}/E0277-2.rs | 0 .../{ui/error-codes => compile-fail}/E0277.rs | 0 .../{ui/error-codes => compile-fail}/E0282.rs | 0 .../{ui/error-codes => compile-fail}/E0283.rs | 0 .../{ui/error-codes => compile-fail}/E0296.rs | 0 .../{ui/error-codes => compile-fail}/E0297.rs | 0 .../{ui/error-codes => compile-fail}/E0301.rs | 0 .../{ui/error-codes => compile-fail}/E0302.rs | 0 .../{ui/error-codes => compile-fail}/E0303.rs | 0 .../error-codes => compile-fail}/E0308-4.rs | 0 .../{ui/error-codes => compile-fail}/E0308.rs | 0 .../{ui/error-codes => compile-fail}/E0365.rs | 0 .../{ui/error-codes => compile-fail}/E0370.rs | 0 .../{ui/error-codes => compile-fail}/E0374.rs | 0 .../{ui/error-codes => compile-fail}/E0375.rs | 0 .../{ui/error-codes => compile-fail}/E0376.rs | 0 .../{ui/error-codes => compile-fail}/E0388.rs | 0 .../{ui/error-codes => compile-fail}/E0389.rs | 0 .../{ui/error-codes => compile-fail}/E0390.rs | 0 .../{ui/error-codes => compile-fail}/E0392.rs | 0 .../{ui/error-codes => compile-fail}/E0393.rs | 0 .../{ui/error-codes => compile-fail}/E0394.rs | 0 .../{ui/error-codes => compile-fail}/E0395.rs | 0 .../{ui/error-codes => compile-fail}/E0396.rs | 0 .../{ui/error-codes => compile-fail}/E0401.rs | 0 .../{ui/error-codes => compile-fail}/E0403.rs | 0 .../{ui/error-codes => compile-fail}/E0404.rs | 0 .../{ui/error-codes => compile-fail}/E0405.rs | 0 .../{ui/error-codes => compile-fail}/E0407.rs | 0 .../{ui/error-codes => compile-fail}/E0408.rs | 0 .../{ui/error-codes => compile-fail}/E0411.rs | 0 .../{ui/error-codes => compile-fail}/E0412.rs | 0 .../{ui/error-codes => compile-fail}/E0415.rs | 0 .../{ui/error-codes => compile-fail}/E0416.rs | 0 .../{ui/error-codes => compile-fail}/E0423.rs | 0 .../{ui/error-codes => compile-fail}/E0424.rs | 0 .../{ui/error-codes => compile-fail}/E0425.rs | 0 .../{ui/error-codes => compile-fail}/E0426.rs | 0 .../{ui/error-codes => compile-fail}/E0428.rs | 0 .../{ui/error-codes => compile-fail}/E0429.rs | 0 .../{ui/error-codes => compile-fail}/E0430.rs | 0 .../{ui/error-codes => compile-fail}/E0431.rs | 0 .../{ui/error-codes => compile-fail}/E0432.rs | 0 .../{ui/error-codes => compile-fail}/E0433.rs | 0 .../{ui/error-codes => compile-fail}/E0434.rs | 0 .../{ui/error-codes => compile-fail}/E0435.rs | 0 .../{ui/error-codes => compile-fail}/E0437.rs | 0 .../{ui/error-codes => compile-fail}/E0438.rs | 0 .../{ui/error-codes => compile-fail}/E0439.rs | 0 .../{ui/error-codes => compile-fail}/E0440.rs | 0 .../{ui/error-codes => compile-fail}/E0441.rs | 0 .../{ui/error-codes => compile-fail}/E0442.rs | 0 .../{ui/error-codes => compile-fail}/E0443.rs | 0 .../{ui/error-codes => compile-fail}/E0444.rs | 0 .../{ui/error-codes => compile-fail}/E0445.rs | 0 .../{ui/error-codes => compile-fail}/E0446.rs | 0 .../{ui/error-codes => compile-fail}/E0449.rs | 0 .../{ui/error-codes => compile-fail}/E0451.rs | 0 .../{ui/error-codes => compile-fail}/E0452.rs | 0 .../{ui/error-codes => compile-fail}/E0453.rs | 0 .../{ui/error-codes => compile-fail}/E0454.rs | 0 .../{ui/error-codes => compile-fail}/E0458.rs | 0 .../{ui/error-codes => compile-fail}/E0459.rs | 0 .../{ui/error-codes => compile-fail}/E0463.rs | 0 .../{ui/error-codes => compile-fail}/E0478.rs | 0 .../{ui/error-codes => compile-fail}/E0492.rs | 0 .../{ui/error-codes => compile-fail}/E0494.rs | 0 .../{ui/error-codes => compile-fail}/E0496.rs | 0 .../{ui/error-codes => compile-fail}/E0499.rs | 0 .../{ui/error-codes => compile-fail}/E0502.rs | 0 .../{ui/error-codes => compile-fail}/E0503.rs | 0 .../{ui/error-codes => compile-fail}/E0504.rs | 0 .../{ui/error-codes => compile-fail}/E0505.rs | 0 .../{ui/error-codes => compile-fail}/E0507.rs | 0 .../{ui/error-codes => compile-fail}/E0509.rs | 0 .../{ui/error-codes => compile-fail}/E0511.rs | 0 .../{ui/error-codes => compile-fail}/E0512.rs | 0 .../{ui/error-codes => compile-fail}/E0516.rs | 0 .../{ui/error-codes => compile-fail}/E0517.rs | 0 .../{ui/error-codes => compile-fail}/E0518.rs | 0 .../{ui/error-codes => compile-fail}/E0520.rs | 0 .../{ui/error-codes => compile-fail}/E0522.rs | 0 .../{ui/error-codes => compile-fail}/E0527.rs | 0 .../{ui/error-codes => compile-fail}/E0528.rs | 0 .../{ui/error-codes => compile-fail}/E0529.rs | 0 .../{ui/error-codes => compile-fail}/E0530.rs | 0 .../{ui/error-codes => compile-fail}/E0532.rs | 0 .../{ui/error-codes => compile-fail}/E0534.rs | 0 .../{ui/error-codes => compile-fail}/E0558.rs | 0 .../{ui/error-codes => compile-fail}/E0559.rs | 0 .../{ui/error-codes => compile-fail}/E0560.rs | 0 .../error-codes => compile-fail}/E0565-1.rs | 0 .../{ui/error-codes => compile-fail}/E0565.rs | 0 .../{ui/error-codes => compile-fail}/E0572.rs | 0 .../{ui/error-codes => compile-fail}/E0582.rs | 0 .../{ui/error-codes => compile-fail}/E0585.rs | 0 .../{ui/error-codes => compile-fail}/E0586.rs | 0 .../{ui/error-codes => compile-fail}/E0597.rs | 0 .../{ui/error-codes => compile-fail}/E0599.rs | 0 .../{ui/error-codes => compile-fail}/E0600.rs | 0 .../{ui/error-codes => compile-fail}/E0602.rs | 0 .../{ui/error-codes => compile-fail}/E0603.rs | 0 .../{ui/error-codes => compile-fail}/E0604.rs | 0 .../{ui/error-codes => compile-fail}/E0605.rs | 0 .../{ui/error-codes => compile-fail}/E0606.rs | 0 .../{ui/error-codes => compile-fail}/E0607.rs | 0 .../{ui/error-codes => compile-fail}/E0608.rs | 0 .../{ui/error-codes => compile-fail}/E0609.rs | 0 .../{ui/error-codes => compile-fail}/E0610.rs | 0 .../{ui/error-codes => compile-fail}/E0611.rs | 0 .../{ui/error-codes => compile-fail}/E0612.rs | 0 .../{ui/error-codes => compile-fail}/E0614.rs | 0 .../{ui/error-codes => compile-fail}/E0615.rs | 0 .../{ui/error-codes => compile-fail}/E0616.rs | 0 .../{ui/error-codes => compile-fail}/E0617.rs | 0 .../{ui/error-codes => compile-fail}/E0618.rs | 0 .../{ui/error-codes => compile-fail}/E0620.rs | 0 .../E0621-does-not-trigger-for-closures.rs | 0 .../{ui/error-codes => compile-fail}/E0622.rs | 0 .../{ui/error-codes => compile-fail}/E0624.rs | 0 .../{ui/error-codes => compile-fail}/E0637.rs | 0 .../{ui/error-codes => compile-fail}/E0657.rs | 0 .../{ui/error-codes => compile-fail}/E0658.rs | 0 .../{ui/error-codes => compile-fail}/E0659.rs | 0 .../absolute-paths-in-nested-use-groups.rs | 1 + .../associated-const-type-parameter-arms.rs | 7 +- .../borrowck/borrowck-describe-lvalue.rs | 28 +- .../borrowck-match-already-borrowed.rs | 4 +- ...o-phase-activation-sharing-interference.rs | 34 +- ...o-phase-allow-access-during-reservation.rs | 23 +- .../borrowck/two-phase-nonrecv-autoref.rs | 260 ---------- ...-phase-reservation-sharing-interference.rs | 28 +- .../compile-fail/const-eval-overflow-4b.rs | 2 +- src/test/compile-fail/const-typeid-of.rs | 18 - src/test/compile-fail/dst-bad-assign-3.rs | 2 +- .../epoch-raw-pointer-method-2015.rs | 23 - .../epoch-raw-pointer-method-2018.rs | 22 - src/test/compile-fail/issue-16048.rs | 5 +- src/test/compile-fail/issue-39388.rs | 2 +- src/test/compile-fail/issue-42344.rs | 17 - src/test/compile-fail/issue-44415.rs | 22 - src/test/compile-fail/issue-46036.rs | 23 - src/test/compile-fail/issue-46604.rs | 3 +- src/test/compile-fail/issue-47412.rs | 31 -- .../macro-at-most-once-rep-ambig.rs | 53 -- .../do-not-ignore-lifetime-bounds-in-copy.rs | 23 - .../reference-carried-through-struct-field.rs | 3 +- .../compile-fail/private-in-public-warn.rs | 2 +- .../regions-bound-missing-bound-in-impl.rs | 0 .../compile-fail/rustc-args-required-const.rs | 36 -- .../rustc-args-required-const2.rs | 20 - .../compile-fail/ufcs-qpath-self-mismatch.rs | 2 +- .../incremental/hashes/loop_expressions.rs | 2 +- src/test/mir-opt/end_region_2.rs | 12 +- src/test/mir-opt/end_region_3.rs | 12 +- src/test/mir-opt/end_region_9.rs | 22 +- src/test/mir-opt/end_region_cyclic.rs | 27 +- src/test/mir-opt/issue-38669.rs | 19 +- src/test/mir-opt/loop_test.rs | 49 -- src/test/mir-opt/match_false_edges.rs | 107 ++-- .../mir-opt/nll/liveness-drop-intra-block.rs | 16 +- src/test/mir-opt/validate_5.rs | 9 +- src/test/parse-fail/bad-char-literals.rs | 2 +- src/test/parse-fail/issue-33569.rs | 2 +- src/test/parse-fail/lex-stray-backslash.rs | 13 - .../Makefile | 7 - .../foo.rs | 11 - .../output-filename-overwrites-input/Makefile | 5 +- .../output-filename-overwrites-input/bar.rs | 11 - .../output-filename-overwrites-input/foo.rs | 2 +- src/test/run-make/save-analysis-fail/foo.rs | 8 - src/test/run-make/save-analysis/extra-docs.md | 1 - src/test/run-make/save-analysis/foo.rs | 4 - src/test/run-make/stdin-non-utf8/Makefile | 6 - src/test/run-make/stdin-non-utf8/non-utf8 | 1 - .../auxiliary/procedural_mbe_matching.rs | 9 +- src/test/run-pass/backtrace-debuginfo.rs | 34 +- src/test/run-pass/const-typeid-of.rs | 43 -- src/test/run-pass/env-home-dir.rs | 5 +- .../too-live-local-in-immovable-gen.rs | 28 - src/test/run-pass/issue-47139-1.rs | 87 ---- src/test/run-pass/issue-47139-2.rs | 75 --- src/test/run-pass/issue-47638.rs | 18 - src/test/run-pass/issue-47673.rs | 1 + src/test/run-pass/issue-47722.rs | 26 - src/test/run-pass/issue-47789.rs | 20 - src/test/run-pass/macro-at-most-once-rep.rs | 88 ---- src/test/run-pass/match-beginning-vert.rs | 28 - src/test/run-pass/nll/issue-47589.rs | 33 -- src/test/run-pass/sse2.rs | 2 +- src/test/run-pass/stack-probes-lto.rs | 2 +- src/test/run-pass/stack-probes.rs | 2 +- src/test/run-pass/use-nested-groups.rs | 9 +- src/test/rustdoc/auxiliary/unit-return.rs | 13 - src/test/rustdoc/const-evalutation-ice.rs | 22 - src/test/rustdoc/issue-47639.rs | 16 - src/test/rustdoc/link-title-escape.rs | 19 - src/test/rustdoc/unit-return.rs | 27 - ...ssociated-const-impl-wrong-lifetime.stderr | 7 +- src/test/ui/blind-item-item-shadow.stderr | 4 +- src/test/ui/borrowck/issue-41962.rs | 1 - src/test/ui/borrowck/issue-41962.stderr | 19 +- ...regions-bound-missing-bound-in-impl.stderr | 48 -- .../expect-region-supply-region.stderr | 20 +- src/test/ui/cross-file-errors/main.rs | 16 - src/test/ui/cross-file-errors/main.stderr | 11 - src/test/ui/cross-file-errors/underscore.rs | 20 - src/test/ui/double-import.stderr | 4 +- src/test/ui/error-codes/E0001.stderr | 14 - src/test/ui/error-codes/E0004-2.stderr | 14 - src/test/ui/error-codes/E0004.stderr | 8 - src/test/ui/error-codes/E0005.stderr | 8 - src/test/ui/error-codes/E0007.stderr | 14 - src/test/ui/error-codes/E0008.stderr | 8 - src/test/ui/error-codes/E0009.stderr | 10 - src/test/ui/error-codes/E0010-teach.rs | 18 - src/test/ui/error-codes/E0010-teach.stderr | 10 - src/test/ui/error-codes/E0010.stderr | 8 - src/test/ui/error-codes/E0017.stderr | 26 - src/test/ui/error-codes/E0023.stderr | 20 - src/test/ui/error-codes/E0025.stderr | 10 - src/test/ui/error-codes/E0026-teach.rs | 24 - src/test/ui/error-codes/E0026-teach.stderr | 12 - src/test/ui/error-codes/E0026.stderr | 8 - src/test/ui/error-codes/E0027-teach.rs | 25 - src/test/ui/error-codes/E0027-teach.stderr | 10 - src/test/ui/error-codes/E0027.stderr | 8 - src/test/ui/error-codes/E0029-teach.rs | 22 - src/test/ui/error-codes/E0029-teach.stderr | 20 - src/test/ui/error-codes/E0029.stderr | 19 - src/test/ui/error-codes/E0030-teach.rs | 18 - src/test/ui/error-codes/E0030-teach.stderr | 10 - src/test/ui/error-codes/E0030.stderr | 8 - src/test/ui/error-codes/E0033-teach.rs | 25 - src/test/ui/error-codes/E0033-teach.stderr | 26 - src/test/ui/error-codes/E0033.stderr | 22 - src/test/ui/error-codes/E0034.stderr | 19 - src/test/ui/error-codes/E0038.stderr | 10 - src/test/ui/error-codes/E0040.stderr | 8 - src/test/ui/error-codes/E0044.stderr | 14 - src/test/ui/error-codes/E0045.stderr | 8 - src/test/ui/error-codes/E0049.stderr | 11 - src/test/ui/error-codes/E0050.stderr | 29 -- src/test/ui/error-codes/E0054.stderr | 10 - src/test/ui/error-codes/E0055.stderr | 10 - src/test/ui/error-codes/E0057.stderr | 14 - src/test/ui/error-codes/E0059.stderr | 8 - src/test/ui/error-codes/E0060.stderr | 11 - src/test/ui/error-codes/E0061.stderr | 20 - src/test/ui/error-codes/E0062.stderr | 10 - src/test/ui/error-codes/E0063.stderr | 26 - src/test/ui/error-codes/E0067.stderr | 16 - src/test/ui/error-codes/E0069.stderr | 8 - src/test/ui/error-codes/E0070.stderr | 29 -- src/test/ui/error-codes/E0071.stderr | 8 - src/test/ui/error-codes/E0075.stderr | 8 - src/test/ui/error-codes/E0076.stderr | 8 - src/test/ui/error-codes/E0077.stderr | 8 - src/test/ui/error-codes/E0080.stderr | 28 - src/test/ui/error-codes/E0081.stderr | 10 - src/test/ui/error-codes/E0084.stderr | 10 - src/test/ui/error-codes/E0087.stderr | 14 - src/test/ui/error-codes/E0088.stderr | 14 - src/test/ui/error-codes/E0089.stderr | 8 - src/test/ui/error-codes/E0090.stderr | 8 - src/test/ui/error-codes/E0091.stderr | 14 - src/test/ui/error-codes/E0092.stderr | 8 - src/test/ui/error-codes/E0093.stderr | 8 - src/test/ui/error-codes/E0094.stderr | 8 - src/test/ui/error-codes/E0106.stderr | 32 -- src/test/ui/error-codes/E0107.stderr | 20 - src/test/ui/error-codes/E0109.stderr | 8 - src/test/ui/error-codes/E0110.stderr | 8 - src/test/ui/error-codes/E0116.stderr | 10 - src/test/ui/error-codes/E0117.stderr | 17 - src/test/ui/error-codes/E0118.stderr | 10 - src/test/ui/error-codes/E0119.stderr | 11 - src/test/ui/error-codes/E0120.stderr | 8 - src/test/ui/error-codes/E0121.stderr | 14 - src/test/ui/error-codes/E0124.stderr | 10 - src/test/ui/error-codes/E0128.stderr | 8 - src/test/ui/error-codes/E0130.stderr | 8 - src/test/ui/error-codes/E0131.stderr | 8 - src/test/ui/error-codes/E0132.stderr | 8 - src/test/ui/error-codes/E0133.stderr | 8 - src/test/ui/error-codes/E0137.stderr | 11 - src/test/ui/error-codes/E0138.stderr | 11 - src/test/ui/error-codes/E0152.stderr | 10 - src/test/ui/error-codes/E0161.stderr | 14 - src/test/ui/error-codes/E0162.stderr | 8 - src/test/ui/error-codes/E0164.stderr | 8 - src/test/ui/error-codes/E0165.stderr | 8 - src/test/ui/error-codes/E0184.stderr | 8 - src/test/ui/error-codes/E0185.stderr | 11 - src/test/ui/error-codes/E0186.stderr | 11 - src/test/ui/error-codes/E0191.stderr | 8 - src/test/ui/error-codes/E0192.stderr | 8 - src/test/ui/error-codes/E0194.stderr | 11 - src/test/ui/error-codes/E0195.stderr | 11 - src/test/ui/error-codes/E0197.stderr | 8 - src/test/ui/error-codes/E0198.stderr | 8 - src/test/ui/error-codes/E0199.stderr | 8 - src/test/ui/error-codes/E0200.stderr | 8 - src/test/ui/error-codes/E0201.stderr | 27 - src/test/ui/error-codes/E0206.stderr | 23 - src/test/ui/error-codes/E0207.stderr | 8 - src/test/ui/error-codes/E0214.stderr | 8 - src/test/ui/error-codes/E0220.stderr | 14 - src/test/ui/error-codes/E0221.stderr | 29 -- src/test/ui/error-codes/E0223.stderr | 10 - src/test/ui/error-codes/E0225.stderr | 8 - src/test/ui/error-codes/E0229.stderr | 8 - src/test/ui/error-codes/E0232.stderr | 10 - src/test/ui/error-codes/E0243.stderr | 8 - src/test/ui/error-codes/E0244.stderr | 8 - src/test/ui/error-codes/E0252.stderr | 16 - src/test/ui/error-codes/E0253.stderr | 8 - src/test/ui/error-codes/E0254.stderr | 17 - src/test/ui/error-codes/E0255.stderr | 17 - src/test/ui/error-codes/E0259.stderr | 16 - src/test/ui/error-codes/E0260.stderr | 17 - src/test/ui/error-codes/E0261.stderr | 14 - src/test/ui/error-codes/E0262.stderr | 8 - src/test/ui/error-codes/E0263.stderr | 10 - src/test/ui/error-codes/E0264.stderr | 8 - src/test/ui/error-codes/E0267.stderr | 8 - src/test/ui/error-codes/E0268.stderr | 8 - src/test/ui/error-codes/E0271.stderr | 16 - src/test/ui/error-codes/E0275.stderr | 79 --- src/test/ui/error-codes/E0276.stderr | 11 - src/test/ui/error-codes/E0277-2.stderr | 18 - src/test/ui/error-codes/E0277.stderr | 24 - src/test/ui/error-codes/E0282.stderr | 11 - src/test/ui/error-codes/E0283.stderr | 14 - src/test/ui/error-codes/E0296.stderr | 8 - src/test/ui/error-codes/E0297.stderr | 8 - src/test/ui/error-codes/E0301.stderr | 8 - src/test/ui/error-codes/E0302.stderr | 8 - src/test/ui/error-codes/E0303.stderr | 17 - src/test/ui/error-codes/E0308-4.stderr | 8 - src/test/ui/error-codes/E0308.stderr | 11 - src/test/ui/error-codes/E0365.stderr | 10 - src/test/ui/error-codes/E0370.stderr | 10 - src/test/ui/error-codes/E0374.stderr | 9 - src/test/ui/error-codes/E0375.stderr | 11 - src/test/ui/error-codes/E0376.stderr | 8 - src/test/ui/error-codes/E0388.stderr | 26 - src/test/ui/error-codes/E0389.stderr | 8 - src/test/ui/error-codes/E0390.stderr | 14 - src/test/ui/error-codes/E0392.stderr | 10 - src/test/ui/error-codes/E0393.stderr | 10 - src/test/ui/error-codes/E0394.stderr | 10 - src/test/ui/error-codes/E0395.stderr | 8 - src/test/ui/error-codes/E0396.stderr | 8 - src/test/ui/error-codes/E0401.stderr | 8 - src/test/ui/error-codes/E0403.stderr | 10 - src/test/ui/error-codes/E0404.stderr | 8 - src/test/ui/error-codes/E0405.stderr | 8 - src/test/ui/error-codes/E0407.stderr | 8 - src/test/ui/error-codes/E0408.stderr | 10 - src/test/ui/error-codes/E0411.stderr | 8 - src/test/ui/error-codes/E0412.stderr | 8 - src/test/ui/error-codes/E0415.stderr | 8 - src/test/ui/error-codes/E0416.stderr | 8 - src/test/ui/error-codes/E0423.stderr | 8 - src/test/ui/error-codes/E0424.stderr | 8 - src/test/ui/error-codes/E0425.stderr | 8 - src/test/ui/error-codes/E0426.stderr | 8 - src/test/ui/error-codes/E0428.stderr | 12 - src/test/ui/error-codes/E0429.stderr | 8 - src/test/ui/error-codes/E0430.stderr | 24 - src/test/ui/error-codes/E0431.stderr | 8 - src/test/ui/error-codes/E0432.stderr | 8 - src/test/ui/error-codes/E0433.stderr | 8 - src/test/ui/error-codes/E0434.stderr | 10 - src/test/ui/error-codes/E0435.stderr | 8 - src/test/ui/error-codes/E0437.stderr | 8 - src/test/ui/error-codes/E0438.stderr | 8 - src/test/ui/error-codes/E0439.stderr | 8 - src/test/ui/error-codes/E0440.stderr | 8 - src/test/ui/error-codes/E0441.stderr | 8 - src/test/ui/error-codes/E0442.stderr | 20 - src/test/ui/error-codes/E0443.stderr | 8 - src/test/ui/error-codes/E0444.stderr | 8 - src/test/ui/error-codes/E0445.stderr | 20 - src/test/ui/error-codes/E0446.stderr | 10 - src/test/ui/error-codes/E0449.stderr | 24 - src/test/ui/error-codes/E0451.stderr | 14 - src/test/ui/error-codes/E0452.stderr | 8 - src/test/ui/error-codes/E0453.stderr | 11 - src/test/ui/error-codes/E0454.stderr | 8 - src/test/ui/error-codes/E0458.stderr | 14 - src/test/ui/error-codes/E0459.stderr | 8 - src/test/ui/error-codes/E0463.stderr | 8 - src/test/ui/error-codes/E0478.stderr | 19 - src/test/ui/error-codes/E0492.stderr | 8 - src/test/ui/error-codes/E0494.stderr | 8 - src/test/ui/error-codes/E0496.stderr | 10 - src/test/ui/error-codes/E0499.stderr | 12 - src/test/ui/error-codes/E0502.stderr | 12 - src/test/ui/error-codes/E0503.stderr | 10 - src/test/ui/error-codes/E0504.stderr | 11 - src/test/ui/error-codes/E0505.stderr | 10 - src/test/ui/error-codes/E0507.stderr | 8 - src/test/ui/error-codes/E0509.stderr | 11 - src/test/ui/error-codes/E0511.stderr | 8 - src/test/ui/error-codes/E0512.stderr | 11 - src/test/ui/error-codes/E0516.stderr | 8 - src/test/ui/error-codes/E0517.stderr | 35 -- src/test/ui/error-codes/E0518.stderr | 19 - src/test/ui/error-codes/E0520.stderr | 15 - src/test/ui/error-codes/E0522.stderr | 10 - src/test/ui/error-codes/E0527.stderr | 8 - src/test/ui/error-codes/E0528.stderr | 8 - src/test/ui/error-codes/E0529.stderr | 8 - src/test/ui/error-codes/E0530.stderr | 11 - src/test/ui/error-codes/E0532.stderr | 8 - src/test/ui/error-codes/E0534.stderr | 8 - src/test/ui/error-codes/E0558.stderr | 8 - src/test/ui/error-codes/E0559.stderr | 10 - src/test/ui/error-codes/E0560.stderr | 10 - src/test/ui/error-codes/E0565-1.stderr | 8 - src/test/ui/error-codes/E0565.stderr | 8 - src/test/ui/error-codes/E0572.stderr | 8 - src/test/ui/error-codes/E0582.stderr | 14 - src/test/ui/error-codes/E0585.stderr | 10 - src/test/ui/error-codes/E0586.stderr | 10 - src/test/ui/error-codes/E0597.stderr | 13 - src/test/ui/error-codes/E0599.stderr | 11 - src/test/ui/error-codes/E0600.stderr | 8 - src/test/ui/error-codes/E0602.stderr | 6 - src/test/ui/error-codes/E0603.stderr | 8 - src/test/ui/error-codes/E0604.stderr | 8 - src/test/ui/error-codes/E0605.stderr | 18 - src/test/ui/error-codes/E0606.stderr | 14 - src/test/ui/error-codes/E0607.stderr | 8 - src/test/ui/error-codes/E0608.stderr | 8 - src/test/ui/error-codes/E0609.stderr | 16 - src/test/ui/error-codes/E0610.stderr | 8 - src/test/ui/error-codes/E0611.stderr | 8 - src/test/ui/error-codes/E0612.stderr | 8 - src/test/ui/error-codes/E0614.stderr | 8 - src/test/ui/error-codes/E0615.stderr | 10 - src/test/ui/error-codes/E0616.stderr | 8 - src/test/ui/error-codes/E0617.stderr | 42 -- src/test/ui/error-codes/E0618.stderr | 23 - src/test/ui/error-codes/E0619.stderr | 8 - src/test/ui/error-codes/E0620.stderr | 14 - ...E0621-does-not-trigger-for-closures.stderr | 29 -- src/test/ui/error-codes/E0622.stderr | 8 - src/test/ui/error-codes/E0624.stderr | 8 - src/test/ui/error-codes/E0637.stderr | 20 - src/test/ui/error-codes/E0657.stderr | 14 - src/test/ui/error-codes/E0658.stderr | 10 - src/test/ui/error-codes/E0659.stderr | 20 - .../ui/feature-gate-macro_at_most_once_rep.rs | 19 - ...feature-gate-macro_at_most_once_rep.stderr | 10 - .../ui/feature-gate-match_beginning_vert.rs | 36 ++ .../feature-gate-match_beginning_vert.stderr | 26 + .../feature-gate-use_nested_groups.rs} | 38 +- .../ui/feature-gate-use_nested_groups.stderr | 26 + .../ui/generator/generator-with-nll.stderr | 18 +- src/test/ui/generator/issue-48048.rs | 23 - src/test/ui/generator/issue-48048.stderr | 10 - src/test/ui/generator/pattern-borrow.rs | 23 - src/test/ui/generator/pattern-borrow.stderr | 10 - src/test/ui/generator/sized-yield.rs | 21 - src/test/ui/generator/sized-yield.stderr | 22 - .../yield-while-local-borrowed.stderr | 18 +- src/test/ui/impl-trait/equality.rs | 2 +- src/test/ui/impl-trait/equality.stderr | 2 +- src/test/ui/impl-trait/trait_type.stderr | 4 +- src/test/ui/imports/duplicate.stderr | 4 +- .../ui/in-band-lifetimes/ellided-lifetimes.rs | 19 - .../ellided-lifetimes.stderr | 14 - .../mismatched_trait_impl-2.rs | 22 - .../mismatched_trait_impl-2.stderr | 22 - .../mismatched_trait_impl.stderr | 31 +- src/test/ui/issue-26886.stderr | 4 +- src/test/ui/issue-27942.stderr | 20 +- src/test/ui/issue-37884.stderr | 10 +- src/test/ui/issue-45697-1.rs | 35 -- src/test/ui/issue-45697-1.stderr | 18 - src/test/ui/issue-45697.rs | 35 -- src/test/ui/issue-45697.stderr | 18 - src/test/ui/issue-46472.stderr | 16 +- src/test/ui/issue-47706-trait.rs | 16 - src/test/ui/issue-47706-trait.stderr | 12 - ...47390-unused-variable-in-struct-pattern.rs | 34 -- ...0-unused-variable-in-struct-pattern.stderr | 40 -- ...775-nested-macro-unnecessary-parens-arg.rs | 40 -- ...nested-macro-unnecessary-parens-arg.stderr | 15 - src/test/ui/lint/suggestions.rs | 8 +- src/test/ui/lint/suggestions.stderr | 68 +-- src/test/ui/loop-break-value-no-repeat.stderr | 4 - src/test/ui/macro_backtrace/main.stderr | 10 +- .../ui/macros/span-covering-argument-1.rs | 23 - .../ui/macros/span-covering-argument-1.stderr | 13 - src/test/ui/mismatched_types/binops.rs | 8 +- src/test/ui/mismatched_types/binops.stderr | 16 +- .../ui/mismatched_types/closure-arg-count.rs | 3 - .../mismatched_types/closure-arg-count.stderr | 12 +- src/test/ui/nll/borrowed-match-issue-45045.rs | 2 +- .../ui/nll/borrowed-match-issue-45045.stderr | 15 +- src/test/ui/nll/trait-associated-constant.rs | 42 -- .../ui/nll/trait-associated-constant.stderr | 40 -- .../ui/on-unimplemented/auxiliary/no_debug.rs | 14 - src/test/ui/on-unimplemented/no-debug.rs | 27 - src/test/ui/on-unimplemented/no-debug.stderr | 38 -- src/test/ui/param-bounds-ignored.rs | 33 -- src/test/ui/param-bounds-ignored.stderr | 18 - src/test/ui/recursive-requirements.rs | 27 - src/test/ui/recursive-requirements.stderr | 14 - .../ui/resolve-conflict-item-vs-import.stderr | 4 +- src/test/ui/span/issue-24690.stderr | 3 +- .../span/issue-42234-unknown-receiver-type.rs | 27 - .../issue-42234-unknown-receiver-type.stderr | 15 - .../ui/span/macro-span-replacement.stderr | 4 +- src/test/ui/span/multiline-span-simple.rs | 2 +- src/test/ui/span/multiline-span-simple.stderr | 4 +- src/test/ui/static-lifetime.stderr | 2 +- src/test/ui/suggestions/for-c-in-str.stderr | 2 +- ...-crate-rename-suggestion-formatting.stderr | 2 +- src/test/ui/use-mod.stderr | 2 +- src/test/ui/use-nested-groups-error.rs | 25 - src/test/ui/use-nested-groups-error.stderr | 8 - src/tools/compiletest/src/header.rs | 2 +- src/tools/compiletest/src/runtest.rs | 20 +- src/tools/rustbook/Cargo.toml | 2 +- src/tools/rustbook/src/main.rs | 10 +- src/tools/rustdoc-themes/Cargo.toml | 8 - src/tools/rustdoc-themes/main.rs | 59 --- src/tools/tidy/src/deps.rs | 2 - 895 files changed, 2742 insertions(+), 11246 deletions(-) delete mode 100644 src/doc/unstable-book/src/language-features/macro-at-most-once-rep.md create mode 100644 src/doc/unstable-book/src/language-features/match-beginning-vert.md create mode 100644 src/doc/unstable-book/src/language-features/use-nested-groups.md create mode 100644 src/librustc_data_structures/blake2b.rs create mode 100644 src/librustc_data_structures/veccell/mod.rs delete mode 100644 src/librustc_mir/dataflow/impls/borrowed_locals.rs delete mode 100644 src/librustdoc/theme.rs rename src/libstd/os/{raw/mod.rs => raw.rs} (76%) delete mode 100644 src/libstd/os/raw/char.md delete mode 100644 src/libstd/os/raw/double.md delete mode 100644 src/libstd/os/raw/float.md delete mode 100644 src/libstd/os/raw/int.md delete mode 100644 src/libstd/os/raw/long.md delete mode 100644 src/libstd/os/raw/longlong.md delete mode 100644 src/libstd/os/raw/schar.md delete mode 100644 src/libstd/os/raw/short.md delete mode 100644 src/libstd/os/raw/uchar.md delete mode 100644 src/libstd/os/raw/uint.md delete mode 100644 src/libstd/os/raw/ulong.md delete mode 100644 src/libstd/os/raw/ulonglong.md delete mode 100644 src/libstd/os/raw/ushort.md rename src/{libcore/time.rs => libstd/time/duration.rs} (98%) rename src/libstd/{time.rs => time/mod.rs} (99%) delete mode 100644 src/test/codegen/no-output-asm-is-volatile.rs delete mode 100644 src/test/codegen/repeat-trusted-len.rs delete mode 100644 src/test/codegen/repr-transparent-sysv64.rs rename src/test/{ui/error-codes => compile-fail}/E0001.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0004-2.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0004.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0005.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0007.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0008.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0009.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0010.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0017.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0023.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0025.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0026.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0027.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0029.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0030.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0033.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0034.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0038.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0040.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0044.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0045.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0049.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0050.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0054.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0055.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0057.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0059.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0060.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0061.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0062.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0063.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0067.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0069.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0070.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0071.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0075.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0076.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0077.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0080.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0081.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0084.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0087.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0088.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0089.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0090.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0091.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0092.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0093.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0094.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0106.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0107.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0109.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0110.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0116.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0117.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0118.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0119.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0120.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0121.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0124.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0128.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0130.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0131.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0132.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0133.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0137.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0138.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0152.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0161.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0162.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0164.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0165.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0184.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0185.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0186.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0191.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0192.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0194.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0195.rs (84%) rename src/test/{ui/error-codes => compile-fail}/E0197.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0198.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0199.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0200.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0201.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0206.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0207.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0214.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0220.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0221.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0223.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0225.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0229.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0232.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0243.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0244.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0252.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0253.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0254.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0255.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0259.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0260.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0261.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0262.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0263.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0264.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0267.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0268.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0271.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0275.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0276.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0277-2.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0277.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0282.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0283.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0296.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0297.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0301.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0302.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0303.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0308-4.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0308.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0365.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0370.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0374.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0375.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0376.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0388.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0389.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0390.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0392.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0393.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0394.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0395.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0396.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0401.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0403.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0404.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0405.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0407.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0408.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0411.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0412.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0415.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0416.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0423.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0424.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0425.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0426.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0428.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0429.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0430.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0431.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0432.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0433.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0434.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0435.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0437.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0438.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0439.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0440.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0441.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0442.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0443.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0444.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0445.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0446.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0449.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0451.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0452.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0453.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0454.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0458.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0459.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0463.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0478.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0492.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0494.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0496.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0499.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0502.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0503.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0504.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0505.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0507.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0509.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0511.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0512.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0516.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0517.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0518.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0520.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0522.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0527.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0528.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0529.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0530.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0532.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0534.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0558.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0559.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0560.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0565-1.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0565.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0572.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0582.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0585.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0586.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0597.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0599.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0600.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0602.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0603.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0604.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0605.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0606.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0607.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0608.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0609.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0610.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0611.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0612.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0614.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0615.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0616.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0617.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0618.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0620.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0621-does-not-trigger-for-closures.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0622.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0624.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0637.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0657.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0658.rs (100%) rename src/test/{ui/error-codes => compile-fail}/E0659.rs (100%) delete mode 100644 src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs delete mode 100644 src/test/compile-fail/const-typeid-of.rs delete mode 100644 src/test/compile-fail/epoch-raw-pointer-method-2015.rs delete mode 100644 src/test/compile-fail/epoch-raw-pointer-method-2018.rs delete mode 100644 src/test/compile-fail/issue-42344.rs delete mode 100644 src/test/compile-fail/issue-44415.rs delete mode 100644 src/test/compile-fail/issue-46036.rs delete mode 100644 src/test/compile-fail/issue-47412.rs delete mode 100644 src/test/compile-fail/macro-at-most-once-rep-ambig.rs delete mode 100644 src/test/compile-fail/nll/do-not-ignore-lifetime-bounds-in-copy.rs rename src/test/{ui/borrowck => compile-fail}/regions-bound-missing-bound-in-impl.rs (100%) delete mode 100644 src/test/compile-fail/rustc-args-required-const.rs delete mode 100644 src/test/compile-fail/rustc-args-required-const2.rs delete mode 100644 src/test/mir-opt/loop_test.rs delete mode 100644 src/test/parse-fail/lex-stray-backslash.rs delete mode 100644 src/test/run-make/output-filename-conflicts-with-directory/Makefile delete mode 100644 src/test/run-make/output-filename-conflicts-with-directory/foo.rs delete mode 100644 src/test/run-make/output-filename-overwrites-input/bar.rs delete mode 100644 src/test/run-make/save-analysis/extra-docs.md delete mode 100644 src/test/run-make/stdin-non-utf8/Makefile delete mode 100644 src/test/run-make/stdin-non-utf8/non-utf8 delete mode 100644 src/test/run-pass/const-typeid-of.rs delete mode 100644 src/test/run-pass/generator/too-live-local-in-immovable-gen.rs delete mode 100644 src/test/run-pass/issue-47139-1.rs delete mode 100644 src/test/run-pass/issue-47139-2.rs delete mode 100644 src/test/run-pass/issue-47638.rs delete mode 100644 src/test/run-pass/issue-47722.rs delete mode 100644 src/test/run-pass/issue-47789.rs delete mode 100644 src/test/run-pass/macro-at-most-once-rep.rs delete mode 100644 src/test/run-pass/match-beginning-vert.rs delete mode 100644 src/test/run-pass/nll/issue-47589.rs delete mode 100644 src/test/rustdoc/auxiliary/unit-return.rs delete mode 100644 src/test/rustdoc/const-evalutation-ice.rs delete mode 100644 src/test/rustdoc/issue-47639.rs delete mode 100644 src/test/rustdoc/link-title-escape.rs delete mode 100644 src/test/rustdoc/unit-return.rs delete mode 100644 src/test/ui/borrowck/regions-bound-missing-bound-in-impl.stderr delete mode 100644 src/test/ui/cross-file-errors/main.rs delete mode 100644 src/test/ui/cross-file-errors/main.stderr delete mode 100644 src/test/ui/cross-file-errors/underscore.rs delete mode 100644 src/test/ui/error-codes/E0001.stderr delete mode 100644 src/test/ui/error-codes/E0004-2.stderr delete mode 100644 src/test/ui/error-codes/E0004.stderr delete mode 100644 src/test/ui/error-codes/E0005.stderr delete mode 100644 src/test/ui/error-codes/E0007.stderr delete mode 100644 src/test/ui/error-codes/E0008.stderr delete mode 100644 src/test/ui/error-codes/E0009.stderr delete mode 100644 src/test/ui/error-codes/E0010-teach.rs delete mode 100644 src/test/ui/error-codes/E0010-teach.stderr delete mode 100644 src/test/ui/error-codes/E0010.stderr delete mode 100644 src/test/ui/error-codes/E0017.stderr delete mode 100644 src/test/ui/error-codes/E0023.stderr delete mode 100644 src/test/ui/error-codes/E0025.stderr delete mode 100644 src/test/ui/error-codes/E0026-teach.rs delete mode 100644 src/test/ui/error-codes/E0026-teach.stderr delete mode 100644 src/test/ui/error-codes/E0026.stderr delete mode 100644 src/test/ui/error-codes/E0027-teach.rs delete mode 100644 src/test/ui/error-codes/E0027-teach.stderr delete mode 100644 src/test/ui/error-codes/E0027.stderr delete mode 100644 src/test/ui/error-codes/E0029-teach.rs delete mode 100644 src/test/ui/error-codes/E0029-teach.stderr delete mode 100644 src/test/ui/error-codes/E0029.stderr delete mode 100644 src/test/ui/error-codes/E0030-teach.rs delete mode 100644 src/test/ui/error-codes/E0030-teach.stderr delete mode 100644 src/test/ui/error-codes/E0030.stderr delete mode 100644 src/test/ui/error-codes/E0033-teach.rs delete mode 100644 src/test/ui/error-codes/E0033-teach.stderr delete mode 100644 src/test/ui/error-codes/E0033.stderr delete mode 100644 src/test/ui/error-codes/E0034.stderr delete mode 100644 src/test/ui/error-codes/E0038.stderr delete mode 100644 src/test/ui/error-codes/E0040.stderr delete mode 100644 src/test/ui/error-codes/E0044.stderr delete mode 100644 src/test/ui/error-codes/E0045.stderr delete mode 100644 src/test/ui/error-codes/E0049.stderr delete mode 100644 src/test/ui/error-codes/E0050.stderr delete mode 100644 src/test/ui/error-codes/E0054.stderr delete mode 100644 src/test/ui/error-codes/E0055.stderr delete mode 100644 src/test/ui/error-codes/E0057.stderr delete mode 100644 src/test/ui/error-codes/E0059.stderr delete mode 100644 src/test/ui/error-codes/E0060.stderr delete mode 100644 src/test/ui/error-codes/E0061.stderr delete mode 100644 src/test/ui/error-codes/E0062.stderr delete mode 100644 src/test/ui/error-codes/E0063.stderr delete mode 100644 src/test/ui/error-codes/E0067.stderr delete mode 100644 src/test/ui/error-codes/E0069.stderr delete mode 100644 src/test/ui/error-codes/E0070.stderr delete mode 100644 src/test/ui/error-codes/E0071.stderr delete mode 100644 src/test/ui/error-codes/E0075.stderr delete mode 100644 src/test/ui/error-codes/E0076.stderr delete mode 100644 src/test/ui/error-codes/E0077.stderr delete mode 100644 src/test/ui/error-codes/E0080.stderr delete mode 100644 src/test/ui/error-codes/E0081.stderr delete mode 100644 src/test/ui/error-codes/E0084.stderr delete mode 100644 src/test/ui/error-codes/E0087.stderr delete mode 100644 src/test/ui/error-codes/E0088.stderr delete mode 100644 src/test/ui/error-codes/E0089.stderr delete mode 100644 src/test/ui/error-codes/E0090.stderr delete mode 100644 src/test/ui/error-codes/E0091.stderr delete mode 100644 src/test/ui/error-codes/E0092.stderr delete mode 100644 src/test/ui/error-codes/E0093.stderr delete mode 100644 src/test/ui/error-codes/E0094.stderr delete mode 100644 src/test/ui/error-codes/E0106.stderr delete mode 100644 src/test/ui/error-codes/E0107.stderr delete mode 100644 src/test/ui/error-codes/E0109.stderr delete mode 100644 src/test/ui/error-codes/E0110.stderr delete mode 100644 src/test/ui/error-codes/E0116.stderr delete mode 100644 src/test/ui/error-codes/E0117.stderr delete mode 100644 src/test/ui/error-codes/E0118.stderr delete mode 100644 src/test/ui/error-codes/E0119.stderr delete mode 100644 src/test/ui/error-codes/E0120.stderr delete mode 100644 src/test/ui/error-codes/E0121.stderr delete mode 100644 src/test/ui/error-codes/E0124.stderr delete mode 100644 src/test/ui/error-codes/E0128.stderr delete mode 100644 src/test/ui/error-codes/E0130.stderr delete mode 100644 src/test/ui/error-codes/E0131.stderr delete mode 100644 src/test/ui/error-codes/E0132.stderr delete mode 100644 src/test/ui/error-codes/E0133.stderr delete mode 100644 src/test/ui/error-codes/E0137.stderr delete mode 100644 src/test/ui/error-codes/E0138.stderr delete mode 100644 src/test/ui/error-codes/E0152.stderr delete mode 100644 src/test/ui/error-codes/E0161.stderr delete mode 100644 src/test/ui/error-codes/E0162.stderr delete mode 100644 src/test/ui/error-codes/E0164.stderr delete mode 100644 src/test/ui/error-codes/E0165.stderr delete mode 100644 src/test/ui/error-codes/E0184.stderr delete mode 100644 src/test/ui/error-codes/E0185.stderr delete mode 100644 src/test/ui/error-codes/E0186.stderr delete mode 100644 src/test/ui/error-codes/E0191.stderr delete mode 100644 src/test/ui/error-codes/E0192.stderr delete mode 100644 src/test/ui/error-codes/E0194.stderr delete mode 100644 src/test/ui/error-codes/E0195.stderr delete mode 100644 src/test/ui/error-codes/E0197.stderr delete mode 100644 src/test/ui/error-codes/E0198.stderr delete mode 100644 src/test/ui/error-codes/E0199.stderr delete mode 100644 src/test/ui/error-codes/E0200.stderr delete mode 100644 src/test/ui/error-codes/E0201.stderr delete mode 100644 src/test/ui/error-codes/E0206.stderr delete mode 100644 src/test/ui/error-codes/E0207.stderr delete mode 100644 src/test/ui/error-codes/E0214.stderr delete mode 100644 src/test/ui/error-codes/E0220.stderr delete mode 100644 src/test/ui/error-codes/E0221.stderr delete mode 100644 src/test/ui/error-codes/E0223.stderr delete mode 100644 src/test/ui/error-codes/E0225.stderr delete mode 100644 src/test/ui/error-codes/E0229.stderr delete mode 100644 src/test/ui/error-codes/E0232.stderr delete mode 100644 src/test/ui/error-codes/E0243.stderr delete mode 100644 src/test/ui/error-codes/E0244.stderr delete mode 100644 src/test/ui/error-codes/E0252.stderr delete mode 100644 src/test/ui/error-codes/E0253.stderr delete mode 100644 src/test/ui/error-codes/E0254.stderr delete mode 100644 src/test/ui/error-codes/E0255.stderr delete mode 100644 src/test/ui/error-codes/E0259.stderr delete mode 100644 src/test/ui/error-codes/E0260.stderr delete mode 100644 src/test/ui/error-codes/E0261.stderr delete mode 100644 src/test/ui/error-codes/E0262.stderr delete mode 100644 src/test/ui/error-codes/E0263.stderr delete mode 100644 src/test/ui/error-codes/E0264.stderr delete mode 100644 src/test/ui/error-codes/E0267.stderr delete mode 100644 src/test/ui/error-codes/E0268.stderr delete mode 100644 src/test/ui/error-codes/E0271.stderr delete mode 100644 src/test/ui/error-codes/E0275.stderr delete mode 100644 src/test/ui/error-codes/E0276.stderr delete mode 100644 src/test/ui/error-codes/E0277-2.stderr delete mode 100644 src/test/ui/error-codes/E0277.stderr delete mode 100644 src/test/ui/error-codes/E0282.stderr delete mode 100644 src/test/ui/error-codes/E0283.stderr delete mode 100644 src/test/ui/error-codes/E0296.stderr delete mode 100644 src/test/ui/error-codes/E0297.stderr delete mode 100644 src/test/ui/error-codes/E0301.stderr delete mode 100644 src/test/ui/error-codes/E0302.stderr delete mode 100644 src/test/ui/error-codes/E0303.stderr delete mode 100644 src/test/ui/error-codes/E0308-4.stderr delete mode 100644 src/test/ui/error-codes/E0308.stderr delete mode 100644 src/test/ui/error-codes/E0365.stderr delete mode 100644 src/test/ui/error-codes/E0370.stderr delete mode 100644 src/test/ui/error-codes/E0374.stderr delete mode 100644 src/test/ui/error-codes/E0375.stderr delete mode 100644 src/test/ui/error-codes/E0376.stderr delete mode 100644 src/test/ui/error-codes/E0388.stderr delete mode 100644 src/test/ui/error-codes/E0389.stderr delete mode 100644 src/test/ui/error-codes/E0390.stderr delete mode 100644 src/test/ui/error-codes/E0392.stderr delete mode 100644 src/test/ui/error-codes/E0393.stderr delete mode 100644 src/test/ui/error-codes/E0394.stderr delete mode 100644 src/test/ui/error-codes/E0395.stderr delete mode 100644 src/test/ui/error-codes/E0396.stderr delete mode 100644 src/test/ui/error-codes/E0401.stderr delete mode 100644 src/test/ui/error-codes/E0403.stderr delete mode 100644 src/test/ui/error-codes/E0404.stderr delete mode 100644 src/test/ui/error-codes/E0405.stderr delete mode 100644 src/test/ui/error-codes/E0407.stderr delete mode 100644 src/test/ui/error-codes/E0408.stderr delete mode 100644 src/test/ui/error-codes/E0411.stderr delete mode 100644 src/test/ui/error-codes/E0412.stderr delete mode 100644 src/test/ui/error-codes/E0415.stderr delete mode 100644 src/test/ui/error-codes/E0416.stderr delete mode 100644 src/test/ui/error-codes/E0423.stderr delete mode 100644 src/test/ui/error-codes/E0424.stderr delete mode 100644 src/test/ui/error-codes/E0425.stderr delete mode 100644 src/test/ui/error-codes/E0426.stderr delete mode 100644 src/test/ui/error-codes/E0428.stderr delete mode 100644 src/test/ui/error-codes/E0429.stderr delete mode 100644 src/test/ui/error-codes/E0430.stderr delete mode 100644 src/test/ui/error-codes/E0431.stderr delete mode 100644 src/test/ui/error-codes/E0432.stderr delete mode 100644 src/test/ui/error-codes/E0433.stderr delete mode 100644 src/test/ui/error-codes/E0434.stderr delete mode 100644 src/test/ui/error-codes/E0435.stderr delete mode 100644 src/test/ui/error-codes/E0437.stderr delete mode 100644 src/test/ui/error-codes/E0438.stderr delete mode 100644 src/test/ui/error-codes/E0439.stderr delete mode 100644 src/test/ui/error-codes/E0440.stderr delete mode 100644 src/test/ui/error-codes/E0441.stderr delete mode 100644 src/test/ui/error-codes/E0442.stderr delete mode 100644 src/test/ui/error-codes/E0443.stderr delete mode 100644 src/test/ui/error-codes/E0444.stderr delete mode 100644 src/test/ui/error-codes/E0445.stderr delete mode 100644 src/test/ui/error-codes/E0446.stderr delete mode 100644 src/test/ui/error-codes/E0449.stderr delete mode 100644 src/test/ui/error-codes/E0451.stderr delete mode 100644 src/test/ui/error-codes/E0452.stderr delete mode 100644 src/test/ui/error-codes/E0453.stderr delete mode 100644 src/test/ui/error-codes/E0454.stderr delete mode 100644 src/test/ui/error-codes/E0458.stderr delete mode 100644 src/test/ui/error-codes/E0459.stderr delete mode 100644 src/test/ui/error-codes/E0463.stderr delete mode 100644 src/test/ui/error-codes/E0478.stderr delete mode 100644 src/test/ui/error-codes/E0492.stderr delete mode 100644 src/test/ui/error-codes/E0494.stderr delete mode 100644 src/test/ui/error-codes/E0496.stderr delete mode 100644 src/test/ui/error-codes/E0499.stderr delete mode 100644 src/test/ui/error-codes/E0502.stderr delete mode 100644 src/test/ui/error-codes/E0503.stderr delete mode 100644 src/test/ui/error-codes/E0504.stderr delete mode 100644 src/test/ui/error-codes/E0505.stderr delete mode 100644 src/test/ui/error-codes/E0507.stderr delete mode 100644 src/test/ui/error-codes/E0509.stderr delete mode 100644 src/test/ui/error-codes/E0511.stderr delete mode 100644 src/test/ui/error-codes/E0512.stderr delete mode 100644 src/test/ui/error-codes/E0516.stderr delete mode 100644 src/test/ui/error-codes/E0517.stderr delete mode 100644 src/test/ui/error-codes/E0518.stderr delete mode 100644 src/test/ui/error-codes/E0520.stderr delete mode 100644 src/test/ui/error-codes/E0522.stderr delete mode 100644 src/test/ui/error-codes/E0527.stderr delete mode 100644 src/test/ui/error-codes/E0528.stderr delete mode 100644 src/test/ui/error-codes/E0529.stderr delete mode 100644 src/test/ui/error-codes/E0530.stderr delete mode 100644 src/test/ui/error-codes/E0532.stderr delete mode 100644 src/test/ui/error-codes/E0534.stderr delete mode 100644 src/test/ui/error-codes/E0558.stderr delete mode 100644 src/test/ui/error-codes/E0559.stderr delete mode 100644 src/test/ui/error-codes/E0560.stderr delete mode 100644 src/test/ui/error-codes/E0565-1.stderr delete mode 100644 src/test/ui/error-codes/E0565.stderr delete mode 100644 src/test/ui/error-codes/E0572.stderr delete mode 100644 src/test/ui/error-codes/E0582.stderr delete mode 100644 src/test/ui/error-codes/E0585.stderr delete mode 100644 src/test/ui/error-codes/E0586.stderr delete mode 100644 src/test/ui/error-codes/E0597.stderr delete mode 100644 src/test/ui/error-codes/E0599.stderr delete mode 100644 src/test/ui/error-codes/E0600.stderr delete mode 100644 src/test/ui/error-codes/E0602.stderr delete mode 100644 src/test/ui/error-codes/E0603.stderr delete mode 100644 src/test/ui/error-codes/E0604.stderr delete mode 100644 src/test/ui/error-codes/E0605.stderr delete mode 100644 src/test/ui/error-codes/E0606.stderr delete mode 100644 src/test/ui/error-codes/E0607.stderr delete mode 100644 src/test/ui/error-codes/E0608.stderr delete mode 100644 src/test/ui/error-codes/E0609.stderr delete mode 100644 src/test/ui/error-codes/E0610.stderr delete mode 100644 src/test/ui/error-codes/E0611.stderr delete mode 100644 src/test/ui/error-codes/E0612.stderr delete mode 100644 src/test/ui/error-codes/E0614.stderr delete mode 100644 src/test/ui/error-codes/E0615.stderr delete mode 100644 src/test/ui/error-codes/E0616.stderr delete mode 100644 src/test/ui/error-codes/E0617.stderr delete mode 100644 src/test/ui/error-codes/E0618.stderr delete mode 100644 src/test/ui/error-codes/E0619.stderr delete mode 100644 src/test/ui/error-codes/E0620.stderr delete mode 100644 src/test/ui/error-codes/E0621-does-not-trigger-for-closures.stderr delete mode 100644 src/test/ui/error-codes/E0622.stderr delete mode 100644 src/test/ui/error-codes/E0624.stderr delete mode 100644 src/test/ui/error-codes/E0637.stderr delete mode 100644 src/test/ui/error-codes/E0657.stderr delete mode 100644 src/test/ui/error-codes/E0658.stderr delete mode 100644 src/test/ui/error-codes/E0659.stderr delete mode 100644 src/test/ui/feature-gate-macro_at_most_once_rep.rs delete mode 100644 src/test/ui/feature-gate-macro_at_most_once_rep.stderr create mode 100644 src/test/ui/feature-gate-match_beginning_vert.rs create mode 100644 src/test/ui/feature-gate-match_beginning_vert.stderr rename src/test/{codegen/abi-x86_64_sysv.rs => ui/feature-gate-use_nested_groups.rs} (51%) create mode 100644 src/test/ui/feature-gate-use_nested_groups.stderr delete mode 100644 src/test/ui/generator/issue-48048.rs delete mode 100644 src/test/ui/generator/issue-48048.stderr delete mode 100644 src/test/ui/generator/pattern-borrow.rs delete mode 100644 src/test/ui/generator/pattern-borrow.stderr delete mode 100644 src/test/ui/generator/sized-yield.rs delete mode 100644 src/test/ui/generator/sized-yield.stderr delete mode 100644 src/test/ui/in-band-lifetimes/ellided-lifetimes.rs delete mode 100644 src/test/ui/in-band-lifetimes/ellided-lifetimes.stderr delete mode 100644 src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs delete mode 100644 src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr delete mode 100644 src/test/ui/issue-45697-1.rs delete mode 100644 src/test/ui/issue-45697-1.stderr delete mode 100644 src/test/ui/issue-45697.rs delete mode 100644 src/test/ui/issue-45697.stderr delete mode 100644 src/test/ui/issue-47706-trait.rs delete mode 100644 src/test/ui/issue-47706-trait.stderr delete mode 100644 src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs delete mode 100644 src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.stderr delete mode 100644 src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.rs delete mode 100644 src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.stderr delete mode 100644 src/test/ui/macros/span-covering-argument-1.rs delete mode 100644 src/test/ui/macros/span-covering-argument-1.stderr delete mode 100644 src/test/ui/nll/trait-associated-constant.rs delete mode 100644 src/test/ui/nll/trait-associated-constant.stderr delete mode 100644 src/test/ui/on-unimplemented/auxiliary/no_debug.rs delete mode 100644 src/test/ui/on-unimplemented/no-debug.rs delete mode 100644 src/test/ui/on-unimplemented/no-debug.stderr delete mode 100644 src/test/ui/param-bounds-ignored.rs delete mode 100644 src/test/ui/param-bounds-ignored.stderr delete mode 100644 src/test/ui/recursive-requirements.rs delete mode 100644 src/test/ui/recursive-requirements.stderr delete mode 100644 src/test/ui/span/issue-42234-unknown-receiver-type.rs delete mode 100644 src/test/ui/span/issue-42234-unknown-receiver-type.stderr delete mode 100644 src/test/ui/use-nested-groups-error.rs delete mode 100644 src/test/ui/use-nested-groups-error.stderr delete mode 100644 src/tools/rustdoc-themes/Cargo.toml delete mode 100644 src/tools/rustdoc-themes/main.rs diff --git a/RELEASES.md b/RELEASES.md index d6f95f52075d2..45c389d72afc7 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,117 +1,3 @@ -Version 1.24.0 (2018-02-15) -========================== - -Language --------- -- [External `sysv64` ffi is now available.][46528] - eg. `extern "sysv64" fn foo () {}` - -Compiler --------- -- [rustc now uses 16 codegen units by default for release builds.][46910] - For the fastest builds, utilize `codegen-units=1`. -- [Added `armv4t-unknown-linux-gnueabi` target.][47018] -- [Add `aarch64-unknown-openbsd` support][46760] - -Libraries ---------- -- [`str::find::` now uses memchr.][46735] This should lead to a 10x - improvement in performance in the majority of cases. -- [`OsStr`'s `Debug` implementation is now lossless and consistent - with Windows.][46798] -- [`time::{SystemTime, Instant}` now implement `Hash`.][46828] -- [impl `From` for `AtomicBool`][46293] -- [impl `From<{CString, &CStr}>` for `{Arc, Rc}`][45990] -- [impl `From<{OsString, &OsStr}>` for `{Arc, Rc}`][45990] -- [impl `From<{PathBuf, &Path}>` for `{Arc, Rc}`][45990] -- [float::from_bits now just uses transmute.][46012] This provides - some optimisations from LLVM. -- [Copied `AsciiExt` methods onto `char`][46077] -- [Remove `T: Sized` requirement on `ptr::is_null()`][46094] -- [impl `From` for `{TryRecvError, RecvTimeoutError}`][45506] -- [Optimised `f32::{min, max}` to generate more efficent x86 assembly][47080] -- [`[u8]::contains` now uses memchr which provides a 3x speed improvement][46713] - -Stabilized APIs ---------------- -- [`RefCell::replace`] -- [`RefCell::swap`] -- [`atomic::spin_loop_hint`] - -The following functions can now be used in a constant expression. -eg. `let buffer: [u8; size_of::()];`, `static COUNTER: AtomicUsize = AtomicUsize::new(1);` - -- [`AtomicBool::new`][46287] -- [`AtomicUsize::new`][46287] -- [`AtomicIsize::new`][46287] -- [`AtomicPtr::new`][46287] -- [`Cell::new`][46287] -- [`{integer}::min_value`][46287] -- [`{integer}::max_value`][46287] -- [`mem::size_of`][46287] -- [`mem::align_of`][46287] -- [`ptr::null`][46287] -- [`ptr::null_mut`][46287] -- [`RefCell::new`][46287] -- [`UnsafeCell::new`][46287] - -Cargo ------ -- [Added a `workspace.default-members` config that - overrides implied `--all` in virtual workspaces.][cargo/4743] -- [Enable incremental by default on development builds.][cargo/4817] Also added - configuration keys to `Cargo.toml` and `.cargo/config` to disable on a - per-project or global basis respectively. - -Misc ----- - -Compatibility Notes -------------------- -- [Floating point types `Debug` impl now always prints a decimal point.][46831] -- [`Ipv6Addr` now rejects superfluous `::`'s in IPv6 addresses][46671] This is - in accordance with IETF RFC 4291 §2.2. -- [Unwinding will no longer go past FFI boundaries, and will instead abort.][46833] -- [`Formatter::flags` method is now deprecated.][46284] The `sign_plus`, - `sign_minus`, `alternate`, and `sign_aware_zero_pad` should be used instead. -- [Leading zeros in tuple struct members is now an error][47084] -- [`column!()` macro is one-based instead of zero-based][46977] -- [`fmt::Arguments` can no longer be shared across threads][45198] -- [Access to `#[repr(packed)]` struct fields is now unsafe][44884] - -[44884]: https://github.com/rust-lang/rust/pull/44884 -[45198]: https://github.com/rust-lang/rust/pull/45198 -[45506]: https://github.com/rust-lang/rust/pull/45506 -[45904]: https://github.com/rust-lang/rust/pull/45904 -[45990]: https://github.com/rust-lang/rust/pull/45990 -[46012]: https://github.com/rust-lang/rust/pull/46012 -[46077]: https://github.com/rust-lang/rust/pull/46077 -[46094]: https://github.com/rust-lang/rust/pull/46094 -[46284]: https://github.com/rust-lang/rust/pull/46284 -[46287]: https://github.com/rust-lang/rust/pull/46287 -[46293]: https://github.com/rust-lang/rust/pull/46293 -[46528]: https://github.com/rust-lang/rust/pull/46528 -[46671]: https://github.com/rust-lang/rust/pull/46671 -[46713]: https://github.com/rust-lang/rust/pull/46713 -[46735]: https://github.com/rust-lang/rust/pull/46735 -[46749]: https://github.com/rust-lang/rust/pull/46749 -[46760]: https://github.com/rust-lang/rust/pull/46760 -[46798]: https://github.com/rust-lang/rust/pull/46798 -[46828]: https://github.com/rust-lang/rust/pull/46828 -[46831]: https://github.com/rust-lang/rust/pull/46831 -[46833]: https://github.com/rust-lang/rust/pull/46833 -[46910]: https://github.com/rust-lang/rust/pull/46910 -[46977]: https://github.com/rust-lang/rust/pull/46977 -[47018]: https://github.com/rust-lang/rust/pull/47018 -[47080]: https://github.com/rust-lang/rust/pull/47080 -[47084]: https://github.com/rust-lang/rust/pull/47084 -[cargo/4743]: https://github.com/rust-lang/cargo/pull/4743 -[cargo/4817]: https://github.com/rust-lang/cargo/pull/4817 -[`RefCell::replace`]: https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.replace -[`RefCell::swap`]: https://doc.rust-lang.org/std/cell/struct.RefCell.html#method.swap -[`atomic::spin_loop_hint`]: https://doc.rust-lang.org/std/sync/atomic/fn.spin_loop_hint.html - - Version 1.23.0 (2018-01-04) ========================== diff --git a/config.toml.example b/config.toml.example index f153562a53894..1d60d8c949441 100644 --- a/config.toml.example +++ b/config.toml.example @@ -151,10 +151,6 @@ # default. #extended = false -# Installs choosen set of extended tools if enables. By default builds all. -# If choosen tool failed to build the installation fails. -#tools = ["cargo", "rls", "rustfmt", "analysis", "src"] - # Verbosity level: 0 == not verbose, 1 == verbose, 2 == very verbose #verbose = 0 @@ -239,11 +235,6 @@ # compiler. #codegen-units = 1 -# Whether to enable ThinLTO (and increase the codegen units to either a default -# or the configured value). On by default. If we want the fastest possible -# compiler, we should disable this. -#thinlto = true - # Whether or not debug assertions are enabled for the compiler and standard # library. Also enables compilation of debug! and trace! logging macros. #debug-assertions = false @@ -299,7 +290,7 @@ # Flag indicating whether git info will be retrieved from .git automatically. # Having the git information can cause a lot of rebuilds during development. -# Note: If this attribute is not explicitly set (e.g. if left commented out) it +# Note: If this attribute is not explicity set (e.g. if left commented out) it # will default to true if channel = "dev", but will default to false otherwise. #ignore-git = true @@ -321,11 +312,6 @@ # bootstrap) #codegen-backends = ["llvm"] -# Flag indicating whether `libstd` calls an imported function to handle basic IO -# when targeting WebAssembly. Enable this to debug tests for the `wasm32-unknown-unknown` -# target, as without this option the test output will not be captured. -#wasm-syscall = false - # ============================================================================= # Options for specific targets # @@ -353,7 +339,7 @@ #linker = "cc" # Path to the `llvm-config` binary of the installation of a custom LLVM to link -# against. Note that if this is specified we don't compile LLVM at all for this +# against. Note that if this is specifed we don't compile LLVM at all for this # target. #llvm-config = "../path/to/llvm/root/bin/llvm-config" diff --git a/src/Cargo.lock b/src/Cargo.lock index 6b722db53ed3a..d26098903eec5 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -133,7 +133,6 @@ dependencies = [ "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -292,14 +291,14 @@ dependencies = [ [[package]] name = "clippy" -version = "0.0.186" +version = "0.0.174" dependencies = [ "cargo_metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "clippy-mini-macro-test 0.2.0", - "clippy_lints 0.0.186", - "compiletest_rs 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "clippy-mini-macro-test 0.1.0", + "clippy_lints 0.0.174", + "compiletest_rs 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "duct 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", @@ -307,15 +306,15 @@ dependencies = [ [[package]] name = "clippy-mini-macro-test" -version = "0.2.0" +version = "0.1.0" [[package]] name = "clippy_lints" -version = "0.0.186" +version = "0.0.174" dependencies = [ "if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "itertools 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.0.15 (registry+https://github.com/rust-lang/crates.io-index)", "quine-mc_cluskey 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", @@ -387,7 +386,7 @@ dependencies = [ [[package]] name = "compiletest_rs" -version = "0.3.6" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "diff 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", @@ -929,11 +928,6 @@ dependencies = [ "xz2 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "is-match" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "itertools" version = "0.6.5" @@ -942,14 +936,6 @@ dependencies = [ "either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "itertools" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "either 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "itoa" version = "0.3.4" @@ -1143,28 +1129,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "mdbook" -version = "0.1.2" +version = "0.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "chrono 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)", - "env_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", + "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", "handlebars 0.29.1 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "open 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "pulldown-cmark 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", - "shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", - "toml-query 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1209,7 +1190,7 @@ version = "0.1.0" dependencies = [ "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "cargo_metadata 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "compiletest_rs 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "compiletest_rs 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -1637,7 +1618,7 @@ version = "0.1.0" [[package]] name = "rls" -version = "0.125.0" +version = "0.124.0" dependencies = [ "cargo 0.26.0", "env_logger 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1654,7 +1635,7 @@ dependencies = [ "rls-rustc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", - "rustfmt-nightly 0.3.8", + "rustfmt-nightly 0.3.6", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1685,15 +1666,6 @@ dependencies = [ "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rls-data" -version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "rls-rustc" version = "0.2.1" @@ -1723,7 +1695,7 @@ name = "rustbook" version = "0.1.0" dependencies = [ "clap 2.29.0 (registry+https://github.com/rust-lang/crates.io-index)", - "mdbook 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "mdbook 0.0.28 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1751,7 +1723,7 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_cratesio_shim" -version = "29.0.0" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1760,57 +1732,57 @@ dependencies = [ [[package]] name = "rustc-ap-rustc_data_structures" -version = "29.0.0" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "parking_lot_core 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "stable_deref_trait 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-rustc_errors" -version = "29.0.0" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-ap-rustc_data_structures 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax_pos 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax_pos 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-serialize" -version = "29.0.0" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "rustc-ap-syntax" -version = "29.0.0" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_cratesio_shim 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_data_structures 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_errors 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax_pos 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_cratesio_shim 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_errors 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax_pos 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rustc-ap-syntax_pos" -version = "29.0.0" +version = "12.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "rustc-ap-rustc_data_structures 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-serialize 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_data_structures 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-serialize 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "term 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -2131,7 +2103,7 @@ name = "rustc_save_analysis" version = "0.0.0" dependencies = [ "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", - "rls-data 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rls-data 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rustc 0.0.0", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2226,10 +2198,6 @@ dependencies = [ "tempdir 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "rustdoc-themes" -version = "0.1.0" - [[package]] name = "rustdoc-tool" version = "0.0.0" @@ -2239,7 +2207,7 @@ dependencies = [ [[package]] name = "rustfmt-nightly" -version = "0.3.8" +version = "0.3.6" dependencies = [ "cargo_metadata 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "derive-new 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2251,8 +2219,8 @@ dependencies = [ "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-rustc_errors 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "rustc-ap-syntax 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-rustc_errors 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustc-ap-syntax 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2411,11 +2379,6 @@ name = "shell-escape" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "shlex" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "siphasher" version = "0.2.2" @@ -2739,18 +2702,6 @@ dependencies = [ "serde 1.0.27 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "toml-query" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "error-chain 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", - "is-match 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "lazy_static 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "regex 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "unicode-bidi" version = "0.3.4" @@ -2990,7 +2941,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum coco 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c06169f5beb7e31c7c67ebf5540b8b472d23e3eade3b2ec7d1f5b504a85f91bd" "checksum commoncrypto 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d056a8586ba25a1e4d61cb090900e495952c7886786fc55f909ab2f819b69007" "checksum commoncrypto-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1fed34f46747aa73dfaa578069fd8279d2818ade2b55f38f22a9401c7f4083e2" -"checksum compiletest_rs 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6c5aafb5d4a77c6b5fa384fe93c7a9a3561bd88c4b8b8e45187cf5e779b1badc" +"checksum compiletest_rs 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "562bafeec9aef1e3e08f1c5b0c542220bb80ff2894e5373a1f9d17c346412c66" "checksum core-foundation 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8047f547cd6856d45b1cdd75ef8d2f21f3d0e4bf1dab0a0041b0ae9a5dda9c0e" "checksum core-foundation-sys 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "152195421a2e6497a8179195672e9d4ee8e45ed8c465b626f1606d27a08ebcd5" "checksum crossbeam 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "bd66663db5a988098a89599d4857919b3acf7f61402e61365acfd3919857b9be" @@ -3041,9 +2992,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" "checksum if_chain 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "61bb90bdd39e3af69b0172dfc6130f6cd6332bf040fbb9bdd4401d37adbd48b8" "checksum ignore 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "bb2f0238094bd1b41800fb6eb9b16fdd5e9832ed6053ed91409f0cd5bf28dcfd" -"checksum is-match 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7e5b386aef33a1c677be65237cb9d32c3f3ef56bd035949710c4bb13083eb053" "checksum itertools 0.6.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d3f2be4da1690a039e9ae5fd575f706a63ad5a2120f161b1d653c9da3930dd21" -"checksum itertools 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "b07332223953b5051bceb67e8c4700aa65291535568e1f12408c43c4a42c0394" "checksum itoa 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8324a32baf01e2ae060e9de58ed0bc2320c9a2833491ee36cd3b4c414de4db8c" "checksum jobserver 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)" = "565f6106bd87b394398f813bea4e5ecad6d6b0f6aa077592d088f882a506481d" "checksum json 0.11.12 (registry+https://github.com/rust-lang/crates.io-index)" = "39ebf0fac977ee3a4a3242b6446004ff64514889e3e2730bbd4f764a67a2e483" @@ -3065,7 +3014,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum mac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" "checksum markup5ever 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "047150a0e03b57e638fc45af33a0b63a0362305d5b9f92ecef81df472a4cceb0" "checksum matches 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "100aabe6b8ff4e4a7e32c1c13523379802df0772b82466207ac25b013f193376" -"checksum mdbook 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "fef236caad7ba3b5b3944df946f19ab3e190bca53c111dd00fe05fa8d879f2fd" +"checksum mdbook 0.0.28 (registry+https://github.com/rust-lang/crates.io-index)" = "1ee8ba20c002000546681dc78d7f7e91fd35832058b1e2fdd492ca842bb6e9be" "checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20" "checksum memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "796fba70e76612589ed2ce7f45282f5af869e0fdd7cc6199fa1aa1f1d591ba9d" "checksum miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "609ce024854aeb19a0ef7567d348aaa5a746b32fb72e336df7fcc16869d7e2b4" @@ -3116,16 +3065,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum regex-syntax 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8e931c58b93d86f080c734bfd2bce7dd0079ae2331235818133c8be7f422e20e" "checksum rls-analysis 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "38841e3c5271715a574ac220d9b408b59ed9e2626909c3bc54b5853b4eaadb7b" "checksum rls-data 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8024f1feaca72d0aa4ae1e2a8d454a31b9a33ed02f8d0e9c8559bf53c267ec3c" -"checksum rls-data 0.15.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bea04462e94b5512a78499837eecb7db182ff082144cd1b4bc32ef5d43de6510" "checksum rls-rustc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "85cfb9dde19e313da3e47738008f8a472e470cc42d910b71595a9238494701f2" "checksum rls-span 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5d7c7046dc6a92f2ae02ed302746db4382e75131b9ce20ce967259f6b5867a6a" "checksum rls-vfs 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ffd34691a510938bb67fe0444fb363103c73ffb31c121d1e16bc92d8945ea8ff" -"checksum rustc-ap-rustc_cratesio_shim 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "4ad5e562044ea78a6764dd75ae8afe4b21fde49f4548024b5fdf6345c21fb524" -"checksum rustc-ap-rustc_data_structures 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c0d65325492aba7db72899e3edbab34d39af98c42ab7c7e450c9a288ffe4ad" -"checksum rustc-ap-rustc_errors 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "87d4ab2e06a671b5b5c5b0359dac346f164c99d059dce6a22feb08f2f56bd182" -"checksum rustc-ap-serialize 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e0745fa445ff41c4b6699936cf35ce3ca49502377dd7b3929c829594772c3a7b" -"checksum rustc-ap-syntax 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "82efedabe30f393161e11214a9130edfa01ad476372d1c6f3fec1f8d30488c9d" -"checksum rustc-ap-syntax_pos 29.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "db9de2e927e280c75b8efab9c5f591ad31082d5d2c4c562c68fdba2ee77286b0" +"checksum rustc-ap-rustc_cratesio_shim 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f1a51c10af5abd5d698b7e3487e869e6d15f6feb04cbedb5c792e2824f9d845e" +"checksum rustc-ap-rustc_data_structures 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1aa227490501072780d57f74b1164d361833ff8e172f817da0da2cdf2e4280cc" +"checksum rustc-ap-rustc_errors 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "21ff6c6e13ac4fc04b7d4d398828b024c4b6577045cb3175b33d35fea35ff6d0" +"checksum rustc-ap-serialize 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6b4e7f51e298675c2bf830f7265621a8936fb09e63b825b58144cbaac969e604" +"checksum rustc-ap-syntax 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8bf5639869ba2f7fa581939cd217cb71a85506b82ad0ea520614fb0dceb2386c" +"checksum rustc-ap-syntax_pos 12.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1c020cdb7379e1c733ae0a311ae47c748337ba584d2dd7b7f53baaae78de6f8b" "checksum rustc-demangle 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "aee45432acc62f7b9a108cc054142dac51f979e69e71ddce7d6fc7adf29e817e" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum same-file 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d931a44fdaa43b8637009e7632a02adc4f2b2e0733c08caa4cf00e8da4a117a7" @@ -3146,7 +3094,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum serde_json 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "c9db7266c7d63a4c4b7fe8719656ccdd51acf1bed6124b174f933b009fb10bcb" "checksum shared_child 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "099b38928dbe4a0a01fcd8c233183072f14a7d126a34bed05880869be66e14cc" "checksum shell-escape 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "dd5cc96481d54583947bfe88bf30c23d53f883c6cd0145368b69989d97b84ef8" -"checksum shlex 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" "checksum siphasher 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0df90a788073e8d0235a67e50441d47db7c8ad9debd91cbf43736a2a92d36537" "checksum smallvec 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4f8266519bc1d17d0b5b16f6c21295625d562841c708f6376f49028a43e9c11e" "checksum smallvec 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "44db0ecb22921ef790d17ae13a3f6d15784183ff5f2a01aa32098c7498d2b4b9" @@ -3175,7 +3122,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum time 0.1.39 (registry+https://github.com/rust-lang/crates.io-index)" = "a15375f1df02096fb3317256ce2cee6a1f42fc84ea5ad5fc8c421cfe40c73098" "checksum toml 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "736b60249cb25337bc196faa43ee12c705e426f3d55c214d73a4e7be06f92cb4" "checksum toml 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "a7540f4ffc193e0d3c94121edb19b055670d369f77d5804db11ae053a45b6e7e" -"checksum toml-query 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6854664bfc6df0360c695480836ee90e2d0c965f06db291d10be9344792d43e8" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "51ccda9ef9efa3f7ef5d91e8f9b83bbe6955f9bf86aec89d5cce2c874625920f" "checksum unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8083c594e02b8ae1654ae26f0ade5158b119bd88ad0e8227a5d8fcd72407946" diff --git a/src/Cargo.toml b/src/Cargo.toml index c03301852cd3b..c22ba7a37c8b0 100644 --- a/src/Cargo.toml +++ b/src/Cargo.toml @@ -22,7 +22,6 @@ members = [ "tools/rls", "tools/rustfmt", "tools/miri", - "tools/rustdoc-themes", # FIXME(https://github.com/rust-lang/cargo/issues/4089): move these to exclude "tools/rls/test_data/bin_lib", "tools/rls/test_data/borrow_error", diff --git a/src/bootstrap/Cargo.toml b/src/bootstrap/Cargo.toml index 2d47834131784..bbbbf0e191555 100644 --- a/src/bootstrap/Cargo.toml +++ b/src/bootstrap/Cargo.toml @@ -41,4 +41,3 @@ serde_derive = "1.0.8" serde_json = "1.0.2" toml = "0.4" lazy_static = "0.2" -time = "0.1" diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 74dd4a6fa0144..79058984b1352 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -258,7 +258,7 @@ impl<'a> Builder<'a> { test::HostCompiletest, test::Crate, test::CrateLibrustc, test::Rustdoc, test::Linkcheck, test::Cargotest, test::Cargo, test::Rls, test::Docs, test::ErrorIndex, test::Distcheck, test::Rustfmt, test::Miri, test::Clippy, - test::RustdocJS, test::RustdocTheme), + test::RustdocJS), Kind::Bench => describe!(test::Crate, test::CrateLibrustc), Kind::Doc => describe!(doc::UnstableBook, doc::UnstableBookGen, doc::TheBook, doc::Standalone, doc::Std, doc::Test, doc::Rustc, doc::ErrorIndex, doc::Nomicon, @@ -377,11 +377,6 @@ impl<'a> Builder<'a> { self.ensure(Libdir { compiler, target }) } - pub fn sysroot_codegen_backends(&self, compiler: Compiler) -> PathBuf { - self.sysroot_libdir(compiler, compiler.host) - .with_file_name("codegen-backends") - } - /// Returns the compiler's libdir where it stores the dynamic libraries that /// it itself links against. /// @@ -474,18 +469,6 @@ impl<'a> Builder<'a> { stage = compiler.stage; } - let mut extra_args = env::var(&format!("RUSTFLAGS_STAGE_{}", stage)).unwrap_or_default(); - if stage != 0 { - let s = env::var("RUSTFLAGS_STAGE_NOT_0").unwrap_or_default(); - extra_args.push_str(" "); - extra_args.push_str(&s); - } - - if !extra_args.is_empty() { - cargo.env("RUSTFLAGS", - format!("{} {}", env::var("RUSTFLAGS").unwrap_or_default(), extra_args)); - } - // Customize the compiler we're running. Specify the compiler to cargo // as our shim and then pass it some various options used to configure // how the actual compiler itself is called. @@ -509,6 +492,10 @@ impl<'a> Builder<'a> { }) .env("TEST_MIRI", self.config.test_miri.to_string()) .env("RUSTC_ERROR_METADATA_DST", self.extended_error_dir()); + if let Some(n) = self.config.rust_codegen_units { + cargo.env("RUSTC_CODEGEN_UNITS", n.to_string()); + } + if let Some(host_linker) = self.build.linker(compiler.host) { cargo.env("RUSTC_HOST_LINKER", host_linker); @@ -570,7 +557,7 @@ impl<'a> Builder<'a> { // build scripts in that situation. // // If LLVM support is disabled we need to use the snapshot compiler to compile - // build scripts, as the new compiler doesn't support executables. + // build scripts, as the new compiler doesnt support executables. if mode == Mode::Libstd || !self.build.config.llvm_enabled { cargo.env("RUSTC_SNAPSHOT", &self.initial_rustc) .env("RUSTC_SNAPSHOT_LIBDIR", self.rustc_snapshot_libdir()); @@ -600,25 +587,9 @@ impl<'a> Builder<'a> { // // FIXME: the guard against msvc shouldn't need to be here if !target.contains("msvc") { - let ccache = self.config.ccache.as_ref(); - let ccacheify = |s: &Path| { - let ccache = match ccache { - Some(ref s) => s, - None => return s.display().to_string(), - }; - // FIXME: the cc-rs crate only recognizes the literal strings - // `ccache` and `sccache` when doing caching compilations, so we - // mirror that here. It should probably be fixed upstream to - // accept a new env var or otherwise work with custom ccache - // vars. - match &ccache[..] { - "ccache" | "sccache" => format!("{} {}", ccache, s.display()), - _ => s.display().to_string(), - } - }; - let cc = ccacheify(&self.cc(target)); - cargo.env(format!("CC_{}", target), &cc) - .env("CC", &cc); + let cc = self.cc(target); + cargo.env(format!("CC_{}", target), cc) + .env("CC", cc); let cflags = self.cflags(target).join(" "); cargo.env(format!("CFLAGS_{}", target), cflags.clone()) @@ -633,9 +604,8 @@ impl<'a> Builder<'a> { } if let Ok(cxx) = self.cxx(target) { - let cxx = ccacheify(&cxx); - cargo.env(format!("CXX_{}", target), &cxx) - .env("CXX", &cxx) + cargo.env(format!("CXX_{}", target), cxx) + .env("CXX", cxx) .env(format!("CXXFLAGS_{}", target), cflags.clone()) .env("CXXFLAGS", cflags); } @@ -692,13 +662,6 @@ impl<'a> Builder<'a> { if self.is_very_verbose() { cargo.arg("-v"); } - - // This must be kept before the thinlto check, as we set codegen units - // to 1 forcibly there. - if let Some(n) = self.config.rust_codegen_units { - cargo.env("RUSTC_CODEGEN_UNITS", n.to_string()); - } - if self.config.rust_optimize { // FIXME: cargo bench does not accept `--release` if cmd != "bench" { @@ -706,17 +669,11 @@ impl<'a> Builder<'a> { } if self.config.rust_codegen_units.is_none() && - self.build.is_rust_llvm(compiler.host) && - self.config.rust_thinlto { + self.build.is_rust_llvm(compiler.host) + { cargo.env("RUSTC_THINLTO", "1"); - } else if self.config.rust_codegen_units.is_none() { - // Generally, if ThinLTO has been disabled for some reason, we - // want to set the codegen units to 1. However, we shouldn't do - // this if the option was specifically set by the user. - cargo.env("RUSTC_CODEGEN_UNITS", "1"); } } - if self.config.locked_deps { cargo.arg("--locked"); } diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index ede403491d7fc..e6871764b2c78 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -160,3 +160,4 @@ pub fn libtest_stamp(build: &Build, compiler: Compiler, target: Interned pub fn librustc_stamp(build: &Build, compiler: Compiler, target: Interned) -> PathBuf { build.cargo_out(compiler, Mode::Librustc, target).join(".librustc-check.stamp") } + diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 1d5e11c5d6d41..fa289bbd76a8b 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -724,7 +724,8 @@ fn copy_codegen_backends_to_sysroot(builder: &Builder, // // Here we're looking for the output dylib of the `CodegenBackend` step and // we're copying that into the `codegen-backends` folder. - let dst = builder.sysroot_codegen_backends(target_compiler); + let libdir = builder.sysroot_libdir(target_compiler, target); + let dst = libdir.join("codegen-backends"); t!(fs::create_dir_all(&dst)); for backend in builder.config.rust_codegen_backends.iter() { diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 4f4fd14ae8cab..dbeb27cbfb7d3 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -13,7 +13,7 @@ //! This module implements parsing `config.toml` configuration files to tweak //! how the build runs. -use std::collections::{HashMap, HashSet}; +use std::collections::HashMap; use std::env; use std::fs::File; use std::io::prelude::*; @@ -52,7 +52,6 @@ pub struct Config { pub target_config: HashMap, Target>, pub full_bootstrap: bool, pub extended: bool, - pub tools: Option>, pub sanitizers: bool, pub profiler: bool, pub ignore_git: bool, @@ -82,7 +81,6 @@ pub struct Config { // rust codegen options pub rust_optimize: bool, pub rust_codegen_units: Option, - pub rust_thinlto: bool, pub rust_debug_assertions: bool, pub rust_debuginfo: bool, pub rust_debuginfo_lines: bool, @@ -109,7 +107,6 @@ pub struct Config { pub debug_jemalloc: bool, pub use_jemalloc: bool, pub backtrace: bool, // support for RUST_BACKTRACE - pub wasm_syscall: bool, // misc pub low_priority: bool, @@ -192,7 +189,6 @@ struct Build { python: Option, full_bootstrap: Option, extended: Option, - tools: Option>, verbose: Option, sanitizers: Option, profiler: Option, @@ -264,7 +260,6 @@ impl Default for StringOrBool { struct Rust { optimize: Option, codegen_units: Option, - thinlto: Option, debug_assertions: Option, debuginfo: Option, debuginfo_lines: Option, @@ -287,7 +282,6 @@ struct Rust { test_miri: Option, save_toolstates: Option, codegen_backends: Option>, - wasm_syscall: Option, } /// TOML representation of how each build target is configured. @@ -397,7 +391,6 @@ impl Config { set(&mut config.vendor, build.vendor); set(&mut config.full_bootstrap, build.full_bootstrap); set(&mut config.extended, build.extended); - config.tools = build.tools; set(&mut config.verbose, build.verbose); set(&mut config.sanitizers, build.sanitizers); set(&mut config.profiler, build.profiler); @@ -417,7 +410,6 @@ impl Config { // Store off these values as options because if they're not provided // we'll infer default values for them later - let mut thinlto = None; let mut llvm_assertions = None; let mut debuginfo_lines = None; let mut debuginfo_only_std = None; @@ -461,7 +453,6 @@ impl Config { optimize = rust.optimize; ignore_git = rust.ignore_git; debug_jemalloc = rust.debug_jemalloc; - thinlto = rust.thinlto; set(&mut config.rust_optimize_tests, rust.optimize_tests); set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests); set(&mut config.codegen_tests, rust.codegen_tests); @@ -472,7 +463,6 @@ impl Config { set(&mut config.rust_dist_src, rust.dist_src); set(&mut config.quiet_tests, rust.quiet_tests); set(&mut config.test_miri, rust.test_miri); - set(&mut config.wasm_syscall, rust.wasm_syscall); config.rustc_parallel_queries = rust.experimental_parallel_queries.unwrap_or(false); config.rustc_default_linker = rust.default_linker.clone(); config.musl_root = rust.musl_root.clone().map(PathBuf::from); @@ -546,7 +536,6 @@ impl Config { "stable" | "beta" | "nightly" => true, _ => false, }; - config.rust_thinlto = thinlto.unwrap_or(true); config.rust_debuginfo_lines = debuginfo_lines.unwrap_or(default); config.rust_debuginfo_only_std = debuginfo_only_std.unwrap_or(default); diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index 99a3ee4e4c369..bc6f666d0012f 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -70,7 +70,6 @@ def v(*args): # Optimization and debugging options. These may be overridden by the release # channel, etc. o("optimize", "rust.optimize", "build optimized rust code") -o("thinlto", "rust.thinlto", "build Rust with ThinLTO enabled") o("optimize-llvm", "llvm.optimize", "build optimized LLVM") o("llvm-assertions", "llvm.assertions", "build LLVM with assertions") o("debug-assertions", "rust.debug-assertions", "build with debugging assertions") @@ -144,7 +143,6 @@ def v(*args): o("full-bootstrap", "build.full-bootstrap", "build three compilers instead of two") o("extended", "build.extended", "build an extended rust tool set") -v("tools", "build.tools", "List of extended tools will be installed") v("build", "build.build", "GNUs ./configure syntax LLVM build triple") v("host", None, "GNUs ./configure syntax LLVM host triples") v("target", None, "GNUs ./configure syntax LLVM target triples") diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs index 460fb016f16ea..4127239dc49b8 100644 --- a/src/bootstrap/dist.rs +++ b/src/bootstrap/dist.rs @@ -31,10 +31,8 @@ use channel; use util::{cp_r, libdir, is_dylib, cp_filtered, copy, replace_in_file}; use builder::{Builder, RunConfig, ShouldRun, Step}; use compile; -use native; use tool::{self, Tool}; use cache::{INTERNER, Interned}; -use time; pub fn pkgname(build: &Build, component: &str) -> String { if component == "cargo" { @@ -437,9 +435,11 @@ impl Step for Rustc { } // Copy over the codegen backends - let backends_src = builder.sysroot_codegen_backends(compiler); - let backends_rel = backends_src.strip_prefix(&src).unwrap(); - let backends_dst = image.join(&backends_rel); + let backends_src = builder.sysroot_libdir(compiler, host) + .join("codegen-backends"); + let backends_dst = image.join("lib/rustlib") + .join(&*host) + .join("lib/codegen-backends"); t!(fs::create_dir_all(&backends_dst)); cp_r(&backends_src, &backends_dst); @@ -447,7 +447,8 @@ impl Step for Rustc { t!(fs::create_dir_all(image.join("share/man/man1"))); let man_src = build.src.join("src/doc/man"); let man_dst = image.join("share/man/man1"); - let month_year = t!(time::strftime("%B %Y", &time::now())); + let date_output = output(Command::new("date").arg("+%B %Y")); + let month_year = date_output.trim(); // don't use our `bootstrap::util::{copy, cp_r}`, because those try // to hardlink, and we don't want to edit the source templates for entry_result in t!(fs::read_dir(man_src)) { @@ -457,7 +458,7 @@ impl Step for Rustc { t!(fs::copy(&page_src, &page_dst)); // template in month/year and version number replace_in_file(&page_dst, - &[("", &month_year), + &[("", month_year), ("", channel::CFG_RELEASE_NUM)]); } @@ -899,12 +900,6 @@ impl Step for PlainSourceTarball { .arg("--vers").arg(CARGO_VENDOR_VERSION) .arg("cargo-vendor") .env("RUSTC", &build.initial_rustc); - if let Some(dir) = build.openssl_install_dir(build.config.build) { - builder.ensure(native::Openssl { - target: build.config.build, - }); - cmd.env("OPENSSL_DIR", dir); - } build.run(&mut cmd); } diff --git a/src/bootstrap/install.rs b/src/bootstrap/install.rs index 20f7d379a6967..743f32ece99c6 100644 --- a/src/bootstrap/install.rs +++ b/src/bootstrap/install.rs @@ -22,7 +22,6 @@ use dist::{self, pkgname, sanitize_sh, tmpdir}; use builder::{Builder, RunConfig, ShouldRun, Step}; use cache::Interned; -use config::Config; pub fn install_docs(builder: &Builder, stage: u32, host: Interned) { install_sh(builder, "docs", "rust-docs", stage, Some(host)); @@ -145,19 +144,6 @@ macro_rules! install { pub host: Interned, } - impl $name { - #[allow(dead_code)] - fn should_build(config: &Config) -> bool { - config.extended && config.tools.as_ref() - .map_or(true, |t| t.contains($path)) - } - - #[allow(dead_code)] - fn should_install(builder: &Builder) -> bool { - builder.config.tools.as_ref().map_or(false, |t| t.contains($path)) - } - } - impl Step for $name { type Output = (); const DEFAULT: bool = true; @@ -199,34 +185,32 @@ install!((self, builder, _config), install_std(builder, self.stage, *target); } }; - Cargo, "cargo", Self::should_build(_config), only_hosts: true, { + Cargo, "cargo", _config.extended, only_hosts: true, { builder.ensure(dist::Cargo { stage: self.stage, target: self.target }); install_cargo(builder, self.stage, self.target); }; - Rls, "rls", Self::should_build(_config), only_hosts: true, { - if builder.ensure(dist::Rls { stage: self.stage, target: self.target }).is_some() || - Self::should_install(builder) { + Rls, "rls", _config.extended, only_hosts: true, { + if builder.ensure(dist::Rls { stage: self.stage, target: self.target }).is_some() { install_rls(builder, self.stage, self.target); } else { println!("skipping Install RLS stage{} ({})", self.stage, self.target); } }; - Rustfmt, "rustfmt", Self::should_build(_config), only_hosts: true, { - if builder.ensure(dist::Rustfmt { stage: self.stage, target: self.target }).is_some() || - Self::should_install(builder) { + Rustfmt, "rustfmt", _config.extended, only_hosts: true, { + if builder.ensure(dist::Rustfmt { stage: self.stage, target: self.target }).is_some() { install_rustfmt(builder, self.stage, self.target); } else { println!("skipping Install Rustfmt stage{} ({})", self.stage, self.target); } }; - Analysis, "analysis", Self::should_build(_config), only_hosts: false, { + Analysis, "analysis", _config.extended, only_hosts: false, { builder.ensure(dist::Analysis { compiler: builder.compiler(self.stage, self.host), target: self.target }); install_analysis(builder, self.stage, self.target); }; - Src, "src", Self::should_build(_config) , only_hosts: true, { + Src, "src", _config.extended, only_hosts: true, { builder.ensure(dist::Src); install_src(builder, self.stage); }, ONLY_BUILD; diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 83c270865c0b7..aae0a4f056f08 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -130,7 +130,6 @@ extern crate cc; extern crate getopts; extern crate num_cpus; extern crate toml; -extern crate time; #[cfg(unix)] extern crate libc; @@ -424,9 +423,6 @@ impl Build { if self.config.profiler { features.push_str(" profiler"); } - if self.config.wasm_syscall { - features.push_str(" wasm_syscall"); - } features } @@ -666,7 +662,7 @@ impl Build { } } - /// Returns the path to the linker for the given target if it needs to be overridden. + /// Returns the path to the linker for the given target if it needs to be overriden. fn linker(&self, target: Interned) -> Option<&Path> { if let Some(linker) = self.config.target_config.get(&target) .and_then(|c| c.linker.as_ref()) { diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs index 2ea026244034f..3f30756a568ce 100644 --- a/src/bootstrap/native.rs +++ b/src/bootstrap/native.rs @@ -186,7 +186,7 @@ impl Step for Llvm { } // http://llvm.org/docs/HowToCrossCompileLLVM.html - if target != build.build && !emscripten { + if target != build.build { builder.ensure(Llvm { target: build.build, emscripten: false, diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index f6b95f0bf9744..a316b0f7ef91b 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -113,7 +113,7 @@ impl Step for Linkcheck { let _time = util::timeit(); try_run(build, builder.tool_cmd(Tool::Linkchecker) - .arg(build.out.join(host).join("doc"))); + .arg(build.out.join(host).join("doc"))); } fn should_run(run: ShouldRun) -> ShouldRun { @@ -424,47 +424,6 @@ fn path_for_cargo(builder: &Builder, compiler: Compiler) -> OsString { env::join_paths(iter::once(path).chain(env::split_paths(&old_path))).expect("") } -#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] -pub struct RustdocTheme { - pub compiler: Compiler, -} - -impl Step for RustdocTheme { - type Output = (); - const DEFAULT: bool = true; - const ONLY_HOSTS: bool = true; - - fn should_run(run: ShouldRun) -> ShouldRun { - run.path("src/tools/rustdoc-themes") - } - - fn make_run(run: RunConfig) { - let compiler = run.builder.compiler(run.builder.top_stage, run.host); - - run.builder.ensure(RustdocTheme { - compiler: compiler, - }); - } - - fn run(self, builder: &Builder) { - let rustdoc = builder.rustdoc(self.compiler.host); - let mut cmd = builder.tool_cmd(Tool::RustdocTheme); - cmd.arg(rustdoc.to_str().unwrap()) - .arg(builder.src.join("src/librustdoc/html/static/themes").to_str().unwrap()) - .env("RUSTC_STAGE", self.compiler.stage.to_string()) - .env("RUSTC_SYSROOT", builder.sysroot(self.compiler)) - .env("RUSTDOC_LIBDIR", builder.sysroot_libdir(self.compiler, self.compiler.host)) - .env("CFG_RELEASE_CHANNEL", &builder.build.config.channel) - .env("RUSTDOC_REAL", builder.rustdoc(self.compiler.host)) - .env("RUSTDOC_CRATE_VERSION", builder.build.rust_version()) - .env("RUSTC_BOOTSTRAP", "1"); - if let Some(linker) = builder.build.linker(self.compiler.host) { - cmd.env("RUSTC_TARGET_LINKER", linker); - } - try_run(builder.build, &mut cmd); - } -} - #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] pub struct RustdocJS { pub host: Interned, @@ -651,6 +610,7 @@ static HOST_COMPILETESTS: &[Test] = &[ mode: "incremental", suite: "incremental-fulldeps", }, + Test { path: "src/test/run-make", mode: "run-make", suite: "run-make" }, Test { path: "src/test/rustdoc", mode: "rustdoc", suite: "rustdoc" }, Test { path: "src/test/pretty", mode: "pretty", suite: "pretty" }, @@ -659,7 +619,6 @@ static HOST_COMPILETESTS: &[Test] = &[ Test { path: "src/test/run-pass-valgrind/pretty", mode: "pretty", suite: "run-pass-valgrind" }, Test { path: "src/test/run-pass-fulldeps/pretty", mode: "pretty", suite: "run-pass-fulldeps" }, Test { path: "src/test/run-fail-fulldeps/pretty", mode: "pretty", suite: "run-fail-fulldeps" }, - Test { path: "src/test/run-make", mode: "run-make", suite: "run-make" }, ]; #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] @@ -902,7 +861,7 @@ impl Step for Compiletest { } } if suite == "run-make" && !build.config.llvm_enabled { - println!("Ignoring run-make test suite as they generally don't work without LLVM"); + println!("Ignoring run-make test suite as they generally dont work without LLVM"); return; } @@ -1327,14 +1286,6 @@ impl Step for Crate { cargo.env(format!("CARGO_TARGET_{}_RUNNER", envify(&target)), build.config.nodejs.as_ref().expect("nodejs not configured")); } else if target.starts_with("wasm32") { - // Warn about running tests without the `wasm_syscall` feature enabled. - // The javascript shim implements the syscall interface so that test - // output can be correctly reported. - if !build.config.wasm_syscall { - println!("Libstd was built without `wasm_syscall` feature enabled: \ - test output may not be visible."); - } - // On the wasm32-unknown-unknown target we're using LTO which is // incompatible with `-C prefer-dynamic`, so disable that here cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1"); diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index 9036eb044b5a5..ea055cb5d1b99 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -260,7 +260,6 @@ tool!( BuildManifest, "src/tools/build-manifest", "build-manifest", Mode::Libstd; RemoteTestClient, "src/tools/remote-test-client", "remote-test-client", Mode::Libstd; RustInstaller, "src/tools/rust-installer", "fabricate", Mode::Libstd; - RustdocTheme, "src/tools/rustdoc-themes", "rustdoc-themes", Mode::Libstd; ); #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)] diff --git a/src/ci/docker/dist-i686-freebsd/Dockerfile b/src/ci/docker/dist-i686-freebsd/Dockerfile index 673fa4c0c4bc0..686afc97289b1 100644 --- a/src/ci/docker/dist-i686-freebsd/Dockerfile +++ b/src/ci/docker/dist-i686-freebsd/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:16.04 RUN apt-get update && apt-get install -y --no-install-recommends \ clang \ diff --git a/src/ci/docker/dist-i686-linux/Dockerfile b/src/ci/docker/dist-i686-linux/Dockerfile index 5e405aa72e83d..0fd6af6e10d34 100644 --- a/src/ci/docker/dist-i686-linux/Dockerfile +++ b/src/ci/docker/dist-i686-linux/Dockerfile @@ -86,8 +86,7 @@ ENV RUST_CONFIGURE_ARGS \ --enable-extended \ --enable-sanitizers \ --enable-profiler \ - --enable-emscripten \ - --build=i686-unknown-linux-gnu + --enable-emscripten ENV SCRIPT python2.7 ../x.py dist --host $HOSTS --target $HOSTS # This is the only builder which will create source tarballs diff --git a/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh b/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh index e730dd86087fb..5b4314d57e6cc 100755 --- a/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh +++ b/src/ci/docker/dist-x86_64-netbsd/build-netbsd-toolchain.sh @@ -54,7 +54,7 @@ cd usr/src # The options, in order, do the following # * this is an unprivileged build # * output to a predictable location -# * disable various unneeded stuff +# * disable various uneeded stuff MKUNPRIVED=yes TOOLDIR=/x-tools/x86_64-unknown-netbsd \ MKSHARE=no MKDOC=no MKHTML=no MKINFO=no MKKMOD=no MKLINT=no MKMAN=no MKNLS=no MKPROFILE=no \ hide_output ./build.sh -j10 -m amd64 tools diff --git a/src/ci/docker/x86_64-gnu-tools/checktools.sh b/src/ci/docker/x86_64-gnu-tools/checktools.sh index 61bb5a84d21ac..b9268fe62ed06 100755 --- a/src/ci/docker/x86_64-gnu-tools/checktools.sh +++ b/src/ci/docker/x86_64-gnu-tools/checktools.sh @@ -32,7 +32,7 @@ cat "$TOOLSTATE_FILE" # If this PR is intended to update one of these tools, do not let the build pass # when they do not test-pass. -for TOOL in rls rustfmt clippy; do +for TOOL in rls rustfmt miri clippy; do echo "Verifying status of $TOOL..." if echo "$CHANGED_FILES" | grep -q "^M[[:blank:]]src/tools/$TOOL$"; then echo "This PR updated 'src/tools/$TOOL', verifying if status is 'test-pass'..." diff --git a/src/ci/run.sh b/src/ci/run.sh index 02480c6937de1..dab385c09649c 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -46,7 +46,6 @@ export RUST_RELEASE_CHANNEL=nightly if [ "$DEPLOY$DEPLOY_ALT" != "" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL" RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp" - RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-thinlto" if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions" diff --git a/src/doc/unstable-book/src/language-features/generators.md b/src/doc/unstable-book/src/language-features/generators.md index e8e2132dca254..7a559a7bec866 100644 --- a/src/doc/unstable-book/src/language-features/generators.md +++ b/src/doc/unstable-book/src/language-features/generators.md @@ -139,11 +139,11 @@ closure-like semantics. Namely: types and such. * Traits like `Send` and `Sync` are automatically implemented for a `Generator` - depending on the captured variables of the environment. Unlike closures, + depending on the captured variables of the environment. Unlike closures though generators also depend on variables live across suspension points. This means that although the ambient environment may be `Send` or `Sync`, the generator itself may not be due to internal variables live across `yield` points being - not-`Send` or not-`Sync`. Note that generators, like closures, do + not-`Send` or not-`Sync`. Note, though, that generators, like closures, do not implement traits like `Copy` or `Clone` automatically. * Whenever a generator is dropped it will drop all captured environment @@ -155,7 +155,7 @@ lifted at a future date, the design is ongoing! ### Generators as state machines -In the compiler, generators are currently compiled as state machines. Each +In the compiler generators are currently compiled as state machines. Each `yield` expression will correspond to a different state that stores all live variables over that suspension point. Resumption of a generator will dispatch on the current state and then execute internally until a `yield` is reached, at diff --git a/src/doc/unstable-book/src/language-features/lang-items.md b/src/doc/unstable-book/src/language-features/lang-items.md index c51674186146b..0137a052a62d8 100644 --- a/src/doc/unstable-book/src/language-features/lang-items.md +++ b/src/doc/unstable-book/src/language-features/lang-items.md @@ -37,23 +37,28 @@ unsafe fn allocate(size: usize, _align: usize) -> *mut u8 { p } +#[lang = "exchange_free"] +unsafe fn deallocate(ptr: *mut u8, _size: usize, _align: usize) { + libc::free(ptr as *mut libc::c_void) +} + #[lang = "box_free"] unsafe fn box_free(ptr: *mut T) { - libc::free(ptr as *mut libc::c_void) + deallocate(ptr as *mut u8, ::core::mem::size_of_val(&*ptr), ::core::mem::align_of_val(&*ptr)); } #[start] -fn main(_argc: isize, _argv: *const *const u8) -> isize { - let _x = box 1; +fn main(argc: isize, argv: *const *const u8) -> isize { + let x = box 1; 0 } #[lang = "eh_personality"] extern fn rust_eh_personality() {} #[lang = "panic_fmt"] extern fn rust_begin_panic() -> ! { unsafe { intrinsics::abort() } } -#[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {} -#[no_mangle] pub extern fn rust_eh_register_frames () {} -#[no_mangle] pub extern fn rust_eh_unregister_frames () {} +# #[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {} +# #[no_mangle] pub extern fn rust_eh_register_frames () {} +# #[no_mangle] pub extern fn rust_eh_unregister_frames () {} ``` Note the use of `abort`: the `exchange_malloc` lang item is assumed to @@ -75,7 +80,7 @@ Other features provided by lang items include: Lang items are loaded lazily by the compiler; e.g. if one never uses `Box` then there is no need to define functions for `exchange_malloc` -and `box_free`. `rustc` will emit an error when an item is needed +and `exchange_free`. `rustc` will emit an error when an item is needed but not found in the current crate or any that it depends on. Most lang items are defined by `libcore`, but if you're trying to build @@ -313,4 +318,4 @@ the source code. - `phantom_data`: `libcore/marker.rs` - `freeze`: `libcore/marker.rs` - `debug_trait`: `libcore/fmt/mod.rs` - - `non_zero`: `libcore/nonzero.rs` + - `non_zero`: `libcore/nonzero.rs` \ No newline at end of file diff --git a/src/doc/unstable-book/src/language-features/macro-at-most-once-rep.md b/src/doc/unstable-book/src/language-features/macro-at-most-once-rep.md deleted file mode 100644 index dbaf91b6e78b2..0000000000000 --- a/src/doc/unstable-book/src/language-features/macro-at-most-once-rep.md +++ /dev/null @@ -1,17 +0,0 @@ -# `macro_at_most_once_rep` - -The tracking issue for this feature is: TODO(mark-i-m) - -With this feature gate enabled, one can use `?` as a Kleene operator meaning "0 -or 1 repetitions" in a macro definition. Previously only `+` and `*` were allowed. - -For example: -```rust -macro_rules! foo { - (something $(,)?) // `?` indicates `,` is "optional"... - => {} -} -``` - ------------------------- - diff --git a/src/doc/unstable-book/src/language-features/match-beginning-vert.md b/src/doc/unstable-book/src/language-features/match-beginning-vert.md new file mode 100644 index 0000000000000..f0a51af7fd1c8 --- /dev/null +++ b/src/doc/unstable-book/src/language-features/match-beginning-vert.md @@ -0,0 +1,23 @@ +# `match_beginning_vert` + +The tracking issue for this feature is [#44101]. + +With this feature enabled, you are allowed to add a '|' to the beginning of a +match arm: + +```rust +#![feature(match_beginning_vert)] + +enum Foo { A, B, C } + +fn main() { + let x = Foo::A; + match x { + | Foo::A + | Foo::B => println!("AB"), + | Foo::C => println!("C"), + } +} +``` + +[#44101]: https://github.com/rust-lang/rust/issues/44101 \ No newline at end of file diff --git a/src/doc/unstable-book/src/language-features/use-nested-groups.md b/src/doc/unstable-book/src/language-features/use-nested-groups.md new file mode 100644 index 0000000000000..47b635bad736f --- /dev/null +++ b/src/doc/unstable-book/src/language-features/use-nested-groups.md @@ -0,0 +1,90 @@ +# `use_nested_groups` + +The tracking issue for this feature is: [#44494] + +[#44494]: https://github.com/rust-lang/rust/issues/44494 + +------------------------ + +The `use_nested_groups` feature allows you to import multiple items from a +complex module tree easily, by nesting different imports in the same +declaration. For example: + +```rust +#![feature(use_nested_groups)] +# #![allow(unused_imports, dead_code)] +# +# mod foo { +# pub mod bar { +# pub type Foo = (); +# } +# pub mod baz { +# pub mod quux { +# pub type Bar = (); +# } +# } +# } + +use foo::{ + bar::{self, Foo}, + baz::{*, quux::Bar}, +}; +# +# fn main() {} +``` + +## Snippet for the book's new features appendix + +When stabilizing, add this to +`src/doc/book/second-edition/src/appendix-07-newest-features.md`: + +### Nested groups in `use` declarations + +If you have a complex module tree with many different submodules and you need +to import a few items from each one, it might be useful to group all the +imports in the same declaration to keep your code clean and avoid repeating the +base modules' name. + +The `use` declaration supports nesting to help you in those cases, both with +simple imports and glob ones. For example this snippets imports `bar`, `Foo`, +all the items in `baz` and `Bar`: + +```rust +# #![feature(use_nested_groups)] +# #![allow(unused_imports, dead_code)] +# +# mod foo { +# pub mod bar { +# pub type Foo = (); +# } +# pub mod baz { +# pub mod quux { +# pub type Bar = (); +# } +# } +# } +# +use foo::{ + bar::{self, Foo}, + baz::{*, quux::Bar}, +}; +# +# fn main() {} +``` + +## Updated reference + +When stabilizing, replace the shortcut list in +`src/doc/reference/src/items/use-declarations.md` with this updated one: + +* Simultaneously binding a list of paths with a common prefix, using the + glob-like brace syntax `use a::b::{c, d, e::f, g::h::i};` +* Simultaneously binding a list of paths with a common prefix and their common + parent module, using the `self` keyword, such as `use a::b::{self, c, d::e};` +* Rebinding the target name as a new local name, using the syntax `use p::q::r + as x;`. This can also be used with the last two features: + `use a::b::{self as ab, c as abc}`. +* Binding all paths matching a given prefix, using the asterisk wildcard syntax + `use a::b::*;`. +* Nesting groups of the previous features multiple times, such as + `use a::b::{self as ab, c d::{*, e::f}};` diff --git a/src/etc/installer/msi/rust.wxs b/src/etc/installer/msi/rust.wxs index a471ccc6f5b48..d95b096d732f4 100644 --- a/src/etc/installer/msi/rust.wxs +++ b/src/etc/installer/msi/rust.wxs @@ -18,7 +18,7 @@ - + @@ -129,7 +129,7 @@ - + diff --git a/src/etc/platform-intrinsics/generator.py b/src/etc/platform-intrinsics/generator.py index d9f78978a251e..e9cf71c32fe9a 100644 --- a/src/etc/platform-intrinsics/generator.py +++ b/src/etc/platform-intrinsics/generator.py @@ -591,7 +591,7 @@ def parse_args(): The X86 architecture is specified as multiple files (for the different instruction sets that x86 supports). To generate the compiler definitions one needs to pass the script a "platform information file" - (with the -i flag) next to the files of the different instruction sets. + (with the -i flag) next to the files of the different intruction sets. For example, to generate the X86 compiler-definitions for SSE4.2, just: python generator.py --format compiler-defs -i x86/info.json sse42.json diff --git a/src/etc/test-float-parse/runtests.py b/src/etc/test-float-parse/runtests.py index e9f5bba2312d8..d520c9bd5c30a 100644 --- a/src/etc/test-float-parse/runtests.py +++ b/src/etc/test-float-parse/runtests.py @@ -41,7 +41,7 @@ (as a fraction, using the ``fractions`` module). Given an input string and the corresponding float computed via Rust, simply -decode the float into f * 2^k (for integers f, k) and the ULP. +decode the float into f * 2^k (for intergers f, k) and the ULP. We can now easily compute the error and check if it is within 0.5 ULP as it should be. Zero and infinites are handled similarly: diff --git a/src/etc/wasm32-shim.js b/src/etc/wasm32-shim.js index 69647f37eecc6..d55083e0f8e03 100644 --- a/src/etc/wasm32-shim.js +++ b/src/etc/wasm32-shim.js @@ -28,74 +28,12 @@ let m = new WebAssembly.Module(buffer); let memory = null; -function viewstruct(data, fields) { - return new Uint32Array(memory.buffer).subarray(data/4, data/4 + fields); -} - function copystr(a, b) { - let view = new Uint8Array(memory.buffer).subarray(a, a + b); - return String.fromCharCode.apply(null, view); -} - -function syscall_write([fd, ptr, len]) { - let s = copystr(ptr, len); - switch (fd) { - case 1: process.stdout.write(s); break; - case 2: process.stderr.write(s); break; + if (memory === null) { + return null } -} - -function syscall_exit([code]) { - process.exit(code); -} - -function syscall_args(params) { - let [ptr, len] = params; - - // Calculate total required buffer size - let totalLen = -1; - for (let i = 2; i < process.argv.length; ++i) { - totalLen += Buffer.byteLength(process.argv[i]) + 1; - } - if (totalLen < 0) { totalLen = 0; } - params[2] = totalLen; - - // If buffer is large enough, copy data - if (len >= totalLen) { - let view = new Uint8Array(memory.buffer); - for (let i = 2; i < process.argv.length; ++i) { - let value = process.argv[i]; - Buffer.from(value).copy(view, ptr); - ptr += Buffer.byteLength(process.argv[i]) + 1; - } - } -} - -function syscall_getenv(params) { - let [keyPtr, keyLen, valuePtr, valueLen] = params; - - let key = copystr(keyPtr, keyLen); - let value = process.env[key]; - - if (value == null) { - params[4] = 0xFFFFFFFF; - } else { - let view = new Uint8Array(memory.buffer); - let totalLen = Buffer.byteLength(value); - params[4] = totalLen; - if (valueLen >= totalLen) { - Buffer.from(value).copy(view, valuePtr); - } - } -} - -function syscall_time(params) { - let t = Date.now(); - let secs = Math.floor(t / 1000); - let millis = t % 1000; - params[1] = Math.floor(secs / 0x100000000); - params[2] = secs % 0x100000000; - params[3] = Math.floor(millis * 1000000); + let view = new Uint8Array(memory.buffer).slice(a, a + b); + return String.fromCharCode.apply(null, view); } let imports = {}; @@ -110,25 +48,68 @@ imports.env = { log10: Math.log10, log10f: Math.log10, - rust_wasm_syscall: function(index, data) { - switch (index) { - case 1: syscall_write(viewstruct(data, 3)); return true; - case 2: syscall_exit(viewstruct(data, 1)); return true; - case 3: syscall_args(viewstruct(data, 3)); return true; - case 4: syscall_getenv(viewstruct(data, 5)); return true; - case 6: syscall_time(viewstruct(data, 4)); return true; - default: - console.log("Unsupported syscall: " + index); - return false; + // These are called in src/libstd/sys/wasm/stdio.rs and are used when + // debugging is enabled. + rust_wasm_write_stdout: function(a, b) { + let s = copystr(a, b); + if (s !== null) { + process.stdout.write(s); } - } + }, + rust_wasm_write_stderr: function(a, b) { + let s = copystr(a, b); + if (s !== null) { + process.stderr.write(s); + } + }, + + // These are called in src/libstd/sys/wasm/args.rs and are used when + // debugging is enabled. + rust_wasm_args_count: function() { + if (memory === null) + return 0; + return process.argv.length - 2; + }, + rust_wasm_args_arg_size: function(i) { + return Buffer.byteLength(process.argv[i + 2]); + }, + rust_wasm_args_arg_fill: function(idx, ptr) { + let arg = process.argv[idx + 2]; + let view = new Uint8Array(memory.buffer); + Buffer.from(arg).copy(view, ptr); + }, + + // These are called in src/libstd/sys/wasm/os.rs and are used when + // debugging is enabled. + rust_wasm_getenv_len: function(a, b) { + let key = copystr(a, b); + if (key === null) { + return -1; + } + if (!(key in process.env)) { + return -1; + } + return Buffer.byteLength(process.env[key]); + }, + rust_wasm_getenv_data: function(a, b, ptr) { + let key = copystr(a, b); + let value = process.env[key]; + let view = new Uint8Array(memory.buffer); + Buffer.from(value).copy(view, ptr); + }, }; -let instance = new WebAssembly.Instance(m, imports); -memory = instance.exports.memory; -try { - instance.exports.main(); -} catch (e) { - console.error(e); - process.exit(101); +let module_imports = WebAssembly.Module.imports(m); + +for (var i = 0; i < module_imports.length; i++) { + let imp = module_imports[i]; + if (imp.module != 'env') { + continue + } + if (imp.name == 'memory' && imp.kind == 'memory') { + memory = new WebAssembly.Memory({initial: 20}); + imports.env.memory = memory; + } } + +let instance = new WebAssembly.Instance(m, imports); diff --git a/src/liballoc/btree/map.rs b/src/liballoc/btree/map.rs index b320bed54320a..b114dc640fbaf 100644 --- a/src/liballoc/btree/map.rs +++ b/src/liballoc/btree/map.rs @@ -1748,11 +1748,6 @@ impl<'a, K: Ord, Q: ?Sized, V> Index<&'a Q> for BTreeMap { type Output = V; - /// Returns a reference to the value corresponding to the supplied key. - /// - /// # Panics - /// - /// Panics if the key is not present in the `BTreeMap`. #[inline] fn index(&self, key: &Q) -> &V { self.get(key).expect("no entry found for key") diff --git a/src/libbacktrace/ltmain.sh b/src/libbacktrace/ltmain.sh index fd23815fc617a..eff9e62be8a05 100644 --- a/src/libbacktrace/ltmain.sh +++ b/src/libbacktrace/ltmain.sh @@ -487,7 +487,7 @@ func_mkdir_p () # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited - # list in case some portion of path contains whitespace. + # list incase some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done diff --git a/src/libbacktrace/macho.c b/src/libbacktrace/macho.c index ba7f94c079f8a..9af14e724b40d 100644 --- a/src/libbacktrace/macho.c +++ b/src/libbacktrace/macho.c @@ -327,7 +327,7 @@ macho_get_commands (struct backtrace_state *state, int descriptor, goto end; file_header_view_valid = 1; - // The endianness of the slice may be different than the fat image + // The endianess of the slice may be different than the fat image switch (*(uint32_t *) file_header_view.data) { case MH_MAGIC: diff --git a/src/libcore/any.rs b/src/libcore/any.rs index 566bfe2a3fb5e..338e5c7fd95b4 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -367,36 +367,9 @@ impl TypeId { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] - #[cfg(stage0)] pub fn of() -> TypeId { TypeId { t: unsafe { intrinsics::type_id::() }, } } - - /// Returns the `TypeId` of the type this generic function has been - /// instantiated with. - /// - /// # Examples - /// - /// ``` - /// use std::any::{Any, TypeId}; - /// - /// fn is_string(_s: &T) -> bool { - /// TypeId::of::() == TypeId::of::() - /// } - /// - /// fn main() { - /// assert_eq!(is_string(&0), false); - /// assert_eq!(is_string(&"cookie monster".to_string()), true); - /// } - /// ``` - #[stable(feature = "rust1", since = "1.0.0")] - #[rustc_const_unstable(feature="const_type_id")] - #[cfg(not(stage0))] - pub const fn of() -> TypeId { - TypeId { - t: unsafe { intrinsics::type_id::() }, - } - } } diff --git a/src/libcore/char.rs b/src/libcore/char.rs index 7215bd2a47684..e8b81db07067c 100644 --- a/src/libcore/char.rs +++ b/src/libcore/char.rs @@ -211,7 +211,7 @@ impl From for char { /// An error which can be returned when parsing a char. #[stable(feature = "char_from_str", since = "1.20.0")] -#[derive(Clone, Debug, PartialEq, Eq)] +#[derive(Clone, Debug)] pub struct ParseCharError { kind: CharErrorKind, } diff --git a/src/libcore/convert.rs b/src/libcore/convert.rs index d3a83dc795c85..e815d72d36646 100644 --- a/src/libcore/convert.rs +++ b/src/libcore/convert.rs @@ -141,9 +141,9 @@ pub trait AsRef { /// /// # Generic Implementations /// -/// - `AsMut` auto-dereferences if the inner type is a mutable reference -/// (e.g.: `foo.as_mut()` will work the same if `foo` has type `&mut Foo` -/// or `&mut &mut Foo`) +/// - `AsMut` auto-dereferences if the inner type is a reference or a mutable +/// reference (e.g.: `foo.as_ref()` will work the same if `foo` has type +/// `&mut Foo` or `&&mut Foo`) /// /// # Examples /// diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 8ad5a9861a02f..65aacb23bd768 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -530,12 +530,9 @@ impl<'a> Display for Arguments<'a> { /// } /// ``` #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented( - on(crate_local, label="`{Self}` cannot be formatted using `:?`; \ - add `#[derive(Debug)]` or manually implement `{Debug}`"), - message="`{Self}` doesn't implement `{Debug}`", - label="`{Self}` cannot be formatted using `:?` because it doesn't implement `{Debug}`", -)] +#[rustc_on_unimplemented = "`{Self}` cannot be formatted using `:?`; if it is \ + defined in your crate, add `#[derive(Debug)]` or \ + manually implement it"] #[lang = "debug_trait"] pub trait Debug { /// Formats the value using the given formatter. @@ -596,11 +593,9 @@ pub trait Debug { /// /// println!("The origin is: {}", origin); /// ``` -#[rustc_on_unimplemented( - message="`{Self}` doesn't implement `{Display}`", - label="`{Self}` cannot be formatted with the default formatter; \ - try using `:?` instead if you are using a format string", -)] +#[rustc_on_unimplemented = "`{Self}` cannot be formatted with the default \ + formatter; try using `:?` instead if you are using \ + a format string"] #[stable(feature = "rust1", since = "1.0.0")] pub trait Display { /// Formats the value using the given formatter. @@ -1591,7 +1586,6 @@ impl Display for ! { #[stable(feature = "rust1", since = "1.0.0")] impl Debug for bool { - #[inline] fn fmt(&self, f: &mut Formatter) -> Result { Display::fmt(self, f) } @@ -1754,7 +1748,6 @@ impl Debug for [T] { #[stable(feature = "rust1", since = "1.0.0")] impl Debug for () { - #[inline] fn fmt(&self, f: &mut Formatter) -> Result { f.pad("()") } diff --git a/src/libcore/fmt/num.rs b/src/libcore/fmt/num.rs index 2992e7cf8db34..ee989854a3772 100644 --- a/src/libcore/fmt/num.rs +++ b/src/libcore/fmt/num.rs @@ -157,7 +157,6 @@ macro_rules! debug { ($T:ident) => { #[stable(feature = "rust1", since = "1.0.0")] impl fmt::Debug for $T { - #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(self, f) } diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index a05d67a304fa0..a611dc02469e8 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -992,7 +992,7 @@ extern "rust-intrinsic" { /// ptr::copy_nonoverlapping(y, x, 1); /// ptr::copy_nonoverlapping(&t, y, 1); /// - /// // y and t now point to the same thing, but we need to completely forget `t` + /// // y and t now point to the same thing, but we need to completely forget `tmp` /// // because it's no longer relevant. /// mem::forget(t); /// } diff --git a/src/libcore/iter/iterator.rs b/src/libcore/iter/iterator.rs index 33adb3f49dd0d..35cd7441c66bc 100644 --- a/src/libcore/iter/iterator.rs +++ b/src/libcore/iter/iterator.rs @@ -28,13 +28,8 @@ fn _assert_is_object_safe(_: &Iterator) {} /// [module-level documentation]: index.html /// [impl]: index.html#implementing-iterator #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented( - on( - _Self="&str", - label="`{Self}` is not an iterator; try calling `.chars()` or `.bytes()`" - ), - label="`{Self}` is not an iterator; maybe try calling `.iter()` or a similar method" -)] +#[rustc_on_unimplemented = "`{Self}` is not an iterator; maybe try calling \ + `.iter()` or a similar method"] #[doc(spotlight)] pub trait Iterator { /// The type of the elements being iterated over. @@ -1431,10 +1426,6 @@ pub trait Iterator { /// Folding is useful whenever you have a collection of something, and want /// to produce a single value from it. /// - /// Note: `fold()`, and similar methods that traverse the entire iterator, - /// may not terminate for infinite iterators, even on traits for which a - /// result is determinable in finite time. - /// /// # Examples /// /// Basic usage: diff --git a/src/libcore/iter/mod.rs b/src/libcore/iter/mod.rs index 29b62c901f310..06c29b47bf921 100644 --- a/src/libcore/iter/mod.rs +++ b/src/libcore/iter/mod.rs @@ -298,21 +298,7 @@ //! //! This will print the numbers `0` through `4`, each on their own line. //! -//! Bear in mind that methods on infinite iterators, even those for which a -//! result can be determined mathematically in finite time, may not terminate. -//! Specifically, methods such as [`min`], which in the general case require -//! traversing every element in the iterator, are likely not to return -//! successfully for any infinite iterators. -//! -//! ```no_run -//! let ones = std::iter::repeat(1); -//! let least = ones.min().unwrap(); // Oh no! An infinite loop! -//! // `ones.min()` causes an infinite loop, so we won't reach this point! -//! println!("The smallest number one is {}.", least); -//! ``` -//! //! [`take`]: trait.Iterator.html#method.take -//! [`min`]: trait.Iterator.html#method.min #![stable(feature = "rust1", since = "1.0.0")] @@ -321,7 +307,6 @@ use fmt; use iter_private::TrustedRandomAccess; use ops::Try; use usize; -use intrinsics; #[stable(feature = "rust1", since = "1.0.0")] pub use self::iterator::Iterator; @@ -709,49 +694,6 @@ impl Iterator for StepBy where I: Iterator { (f(inner_hint.0), inner_hint.1.map(f)) } } - - #[inline] - fn nth(&mut self, mut n: usize) -> Option { - if self.first_take { - self.first_take = false; - let first = self.iter.next(); - if n == 0 { - return first; - } - n -= 1; - } - // n and self.step are indices, we need to add 1 to get the amount of elements - // When calling `.nth`, we need to subtract 1 again to convert back to an index - // step + 1 can't overflow because `.step_by` sets `self.step` to `step - 1` - let mut step = self.step + 1; - // n + 1 could overflow - // thus, if n is usize::MAX, instead of adding one, we call .nth(step) - if n == usize::MAX { - self.iter.nth(step - 1); - } else { - n += 1; - } - - // overflow handling - loop { - let mul = n.checked_mul(step); - if unsafe { intrinsics::likely(mul.is_some()) } { - return self.iter.nth(mul.unwrap() - 1); - } - let div_n = usize::MAX / n; - let div_step = usize::MAX / step; - let nth_n = div_n * n; - let nth_step = div_step * step; - let nth = if nth_n > nth_step { - step -= div_n; - nth_n - } else { - n -= div_step; - nth_step - }; - self.iter.nth(nth - 1); - } - } } // StepBy can only make the iterator shorter, so the len will still fit. @@ -2336,9 +2278,6 @@ impl ExactSizeIterator for Take where I: ExactSizeIterator {} #[unstable(feature = "fused", issue = "35602")] impl FusedIterator for Take where I: FusedIterator {} -#[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl TrustedLen for Take {} - /// An iterator to maintain state while iterating another iterator. /// /// This `struct` is created by the [`scan`] method on [`Iterator`]. See its diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs index 65b38c94dda3f..66a76a24df45a 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -10,7 +10,7 @@ use convert::TryFrom; use mem; -use ops::{self, Add, Sub, Try}; +use ops::{self, Add, Sub}; use usize; use super::{FusedIterator, TrustedLen}; @@ -325,26 +325,25 @@ impl Iterator for ops::RangeFrom { #[unstable(feature = "fused", issue = "35602")] impl FusedIterator for ops::RangeFrom {} -#[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl TrustedLen for ops::RangeFrom {} - #[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")] impl Iterator for ops::RangeInclusive { type Item = A; #[inline] fn next(&mut self) -> Option { - if self.start <= self.end { - if self.start < self.end { + use cmp::Ordering::*; + + match self.start.partial_cmp(&self.end) { + Some(Less) => { let n = self.start.add_one(); Some(mem::replace(&mut self.start, n)) - } else { + }, + Some(Equal) => { let last = self.start.replace_one(); self.end.replace_zero(); Some(last) - } - } else { - None + }, + _ => None, } } @@ -398,68 +397,26 @@ impl Iterator for ops::RangeInclusive { fn max(mut self) -> Option { self.next_back() } - - #[inline] - fn try_fold(&mut self, init: B, mut f: F) -> R where - Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try - { - let mut accum = init; - if self.start <= self.end { - loop { - let (x, done) = - if self.start < self.end { - let n = self.start.add_one(); - (mem::replace(&mut self.start, n), false) - } else { - self.end.replace_zero(); - (self.start.replace_one(), true) - }; - accum = f(accum, x)?; - if done { break } - } - } - Try::from_ok(accum) - } } #[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")] impl DoubleEndedIterator for ops::RangeInclusive { #[inline] fn next_back(&mut self) -> Option { - if self.start <= self.end { - if self.start < self.end { + use cmp::Ordering::*; + + match self.start.partial_cmp(&self.end) { + Some(Less) => { let n = self.end.sub_one(); Some(mem::replace(&mut self.end, n)) - } else { + }, + Some(Equal) => { let last = self.end.replace_zero(); self.start.replace_one(); Some(last) - } - } else { - None - } - } - - #[inline] - fn try_rfold(&mut self, init: B, mut f: F) -> R where - Self: Sized, F: FnMut(B, Self::Item) -> R, R: Try - { - let mut accum = init; - if self.start <= self.end { - loop { - let (x, done) = - if self.start < self.end { - let n = self.end.sub_one(); - (mem::replace(&mut self.end, n), false) - } else { - self.start.replace_one(); - (self.end.replace_zero(), true) - }; - accum = f(accum, x)?; - if done { break } - } + }, + _ => None, } - Try::from_ok(accum) } } diff --git a/src/libcore/iter/sources.rs b/src/libcore/iter/sources.rs index b05a893e66104..b405f35d5e4db 100644 --- a/src/libcore/iter/sources.rs +++ b/src/libcore/iter/sources.rs @@ -44,9 +44,6 @@ impl DoubleEndedIterator for Repeat { #[unstable(feature = "fused", issue = "35602")] impl FusedIterator for Repeat {} -#[unstable(feature = "trusted_len", issue = "37572")] -unsafe impl TrustedLen for Repeat {} - /// Creates a new iterator that endlessly repeats a single element. /// /// The `repeat()` function repeats a single value over and over and over and diff --git a/src/libcore/iter/traits.rs b/src/libcore/iter/traits.rs index be4889f24877c..11e668d228c48 100644 --- a/src/libcore/iter/traits.rs +++ b/src/libcore/iter/traits.rs @@ -970,11 +970,9 @@ impl<'a, I: FusedIterator + ?Sized> FusedIterator for &'a mut I {} /// The iterator reports a size hint where it is either exact /// (lower bound is equal to upper bound), or the upper bound is [`None`]. /// The upper bound must only be [`None`] if the actual iterator length is -/// larger than [`usize::MAX`]. In that case, the lower bound must be -/// [`usize::MAX`], resulting in a [`.size_hint`] of `(usize::MAX, None)`. +/// larger than [`usize::MAX`]. /// -/// The iterator must produce exactly the number of elements it reported -/// or diverge before reaching the end. +/// The iterator must produce exactly the number of elements it reported. /// /// # Safety /// diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 59a296c2a762c..d5190b65863cb 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -91,7 +91,6 @@ #![feature(untagged_unions)] #![feature(unwind_attributes)] #![feature(doc_spotlight)] -#![feature(rustc_const_unstable)] #[prelude_import] #[allow(unused)] @@ -169,7 +168,6 @@ pub mod slice; pub mod str; pub mod hash; pub mod fmt; -pub mod time; // note: does not need to be public mod char_private; diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index cc5cf6523a9e7..f00128a8147de 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -327,7 +327,7 @@ macro_rules! debug_assert_ne { /// } /// } /// -/// // The preferred method of quick returning Errors +/// // The prefered method of quick returning Errors /// fn write_to_file_question() -> Result<(), MyError> { /// let mut file = File::create("my_best_friends.txt")?; /// file.write_all(b"This is a list of my best friends.")?; diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 21a0beccbf64d..93f6a0214d77d 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -189,7 +189,6 @@ pub fn forget(t: T) { /// Type | size_of::\() /// ---- | --------------- /// () | 0 -/// bool | 1 /// u8 | 1 /// u16 | 2 /// u32 | 4 diff --git a/src/libcore/num/f32.rs b/src/libcore/num/f32.rs index 3586fa5442fb4..207df84d080f2 100644 --- a/src/libcore/num/f32.rs +++ b/src/libcore/num/f32.rs @@ -239,9 +239,7 @@ impl Float for f32 { /// Converts to degrees, assuming the number is in radians. #[inline] fn to_degrees(self) -> f32 { - // Use a constant for better precision. - const PIS_IN_180: f32 = 57.2957795130823208767981548141051703_f32; - self * PIS_IN_180 + self * (180.0f32 / consts::PI) } /// Converts to radians, assuming the number is in degrees. diff --git a/src/libcore/num/f64.rs b/src/libcore/num/f64.rs index 64c0d508b388c..9206132e8b46f 100644 --- a/src/libcore/num/f64.rs +++ b/src/libcore/num/f64.rs @@ -237,9 +237,6 @@ impl Float for f64 { /// Converts to degrees, assuming the number is in radians. #[inline] fn to_degrees(self) -> f64 { - // The division here is correctly rounded with respect to the true - // value of 180/π. (This differs from f32, where a constant must be - // used to ensure a correctly rounded result.) self * (180.0f64 / consts::PI) } diff --git a/src/libcore/ops/arith.rs b/src/libcore/ops/arith.rs index 88db019b02f07..8b3d662a6db77 100644 --- a/src/libcore/ops/arith.rs +++ b/src/libcore/ops/arith.rs @@ -75,18 +75,7 @@ /// ``` #[lang = "add"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented( - on( - all(_Self="{integer}", RHS="{float}"), - message="cannot add a float to an integer", - ), - on( - all(_Self="{float}", RHS="{integer}"), - message="cannot add an integer to a float", - ), - message="cannot add `{RHS}` to `{Self}`", - label="no implementation for `{Self} + {RHS}`", -)] +#[rustc_on_unimplemented = "no implementation for `{Self} + {RHS}`"] pub trait Add { /// The resulting type after applying the `+` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -181,8 +170,7 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "sub"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="cannot subtract `{RHS}` from `{Self}`", - label="no implementation for `{Self} - {RHS}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} - {RHS}`"] pub trait Sub { /// The resulting type after applying the `-` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -299,8 +287,7 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "mul"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="cannot multiply `{RHS}` to `{Self}`", - label="no implementation for `{Self} * {RHS}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} * {RHS}`"] pub trait Mul { /// The resulting type after applying the `*` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -421,8 +408,7 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "div"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="cannot divide `{Self}` by `{RHS}`", - label="no implementation for `{Self} / {RHS}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} / {RHS}`"] pub trait Div { /// The resulting type after applying the `/` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -504,8 +490,7 @@ div_impl_float! { f32 f64 } /// ``` #[lang = "rem"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="cannot mod `{Self}` by `{RHS}`", - label="no implementation for `{Self} % {RHS}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} % {RHS}`"] pub trait Rem { /// The resulting type after applying the `%` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -662,8 +647,7 @@ neg_impl_numeric! { isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "add_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented(message="cannot add-assign `{Rhs}` to `{Self}`", - label="no implementation for `{Self} += {Rhs}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} += {Rhs}`"] pub trait AddAssign { /// Performs the `+=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -716,8 +700,7 @@ add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "sub_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented(message="cannot subtract-assign `{Rhs}` from `{Self}`", - label="no implementation for `{Self} -= {Rhs}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} -= {Rhs}`"] pub trait SubAssign { /// Performs the `-=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -761,8 +744,7 @@ sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "mul_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented(message="cannot multiply-assign `{Rhs}` to `{Self}`", - label="no implementation for `{Self} *= {Rhs}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} *= {Rhs}`"] pub trait MulAssign { /// Performs the `*=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -806,8 +788,7 @@ mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "div_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented(message="cannot divide-assign `{Self}` by `{Rhs}`", - label="no implementation for `{Self} /= {Rhs}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} /= {Rhs}`"] pub trait DivAssign { /// Performs the `/=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -854,8 +835,7 @@ div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } /// ``` #[lang = "rem_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented(message="cannot mod-assign `{Self}` by `{Rhs}``", - label="no implementation for `{Self} %= {Rhs}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} %= {Rhs}`"] pub trait RemAssign { /// Performs the `%=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] diff --git a/src/libcore/ops/bit.rs b/src/libcore/ops/bit.rs index a0ecd6cf75ce9..7ac5fc4debf14 100644 --- a/src/libcore/ops/bit.rs +++ b/src/libcore/ops/bit.rs @@ -120,8 +120,7 @@ not_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "bitand"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="no implementation for `{Self} & {RHS}`", - label="no implementation for `{Self} & {RHS}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} & {RHS}`"] pub trait BitAnd { /// The resulting type after applying the `&` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -202,8 +201,7 @@ bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "bitor"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="no implementation for `{Self} | {RHS}`", - label="no implementation for `{Self} | {RHS}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} | {RHS}`"] pub trait BitOr { /// The resulting type after applying the `|` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -287,8 +285,7 @@ bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "bitxor"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="no implementation for `{Self} ^ {RHS}`", - label="no implementation for `{Self} ^ {RHS}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} ^ {RHS}`"] pub trait BitXor { /// The resulting type after applying the `^` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -368,8 +365,7 @@ bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "shl"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="no implementation for `{Self} << {RHS}`", - label="no implementation for `{Self} << {RHS}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} << {RHS}`"] pub trait Shl { /// The resulting type after applying the `<<` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -470,8 +466,7 @@ shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 } /// ``` #[lang = "shr"] #[stable(feature = "rust1", since = "1.0.0")] -#[rustc_on_unimplemented(message="no implementation for `{Self} >> {RHS}`", - label="no implementation for `{Self} >> {RHS}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} >> {RHS}`"] pub trait Shr { /// The resulting type after applying the `>>` operator. #[stable(feature = "rust1", since = "1.0.0")] @@ -584,8 +579,7 @@ shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } /// ``` #[lang = "bitand_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented(message="no implementation for `{Self} &= {Rhs}`", - label="no implementation for `{Self} &= {Rhs}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} &= {Rhs}`"] pub trait BitAndAssign { /// Performs the `&=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -632,8 +626,7 @@ bitand_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "bitor_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented(message="no implementation for `{Self} |= {Rhs}`", - label="no implementation for `{Self} |= {Rhs}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} |= {Rhs}`"] pub trait BitOrAssign { /// Performs the `|=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -680,8 +673,7 @@ bitor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "bitxor_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented(message="no implementation for `{Self} ^= {Rhs}`", - label="no implementation for `{Self} ^= {Rhs}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} ^= {Rhs}`"] pub trait BitXorAssign { /// Performs the `^=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -726,8 +718,7 @@ bitxor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 } /// ``` #[lang = "shl_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented(message="no implementation for `{Self} <<= {Rhs}`", - label="no implementation for `{Self} <<= {Rhs}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} <<= {Rhs}`"] pub trait ShlAssign { /// Performs the `<<=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] @@ -793,8 +784,7 @@ shl_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } /// ``` #[lang = "shr_assign"] #[stable(feature = "op_assign_traits", since = "1.8.0")] -#[rustc_on_unimplemented(message="no implementation for `{Self} >>= {Rhs}`", - label="no implementation for `{Self} >>= {Rhs}`")] +#[rustc_on_unimplemented = "no implementation for `{Self} >>= {Rhs}`"] pub trait ShrAssign { /// Performs the `>>=` operation. #[stable(feature = "op_assign_traits", since = "1.8.0")] diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index 3d84e910fe662..fab5832d905df 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2461,7 +2461,7 @@ impl<'a, T: ?Sized> From> for Unique { } /// Previous name of `NonNull`. -#[rustc_deprecated(since = "1.25.0", reason = "renamed to `NonNull`")] +#[rustc_deprecated(since = "1.24", reason = "renamed to `NonNull`")] #[unstable(feature = "shared", issue = "27730")] pub type Shared = NonNull; @@ -2482,19 +2482,26 @@ pub type Shared = NonNull; /// Usually this won't be necessary; covariance is correct for most safe abstractions, /// such as Box, Rc, Arc, Vec, and LinkedList. This is the case because they /// provide a public API that follows the normal shared XOR mutable rules of Rust. -#[stable(feature = "nonnull", since = "1.25.0")] +#[stable(feature = "nonnull", since = "1.24.0")] pub struct NonNull { pointer: NonZero<*const T>, } +#[stable(feature = "nonnull", since = "1.24.0")] +impl fmt::Debug for NonNull { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt::Pointer::fmt(&self.as_ptr(), f) + } +} + /// `NonNull` pointers are not `Send` because the data they reference may be aliased. // NB: This impl is unnecessary, but should provide better error messages. -#[stable(feature = "nonnull", since = "1.25.0")] +#[stable(feature = "nonnull", since = "1.24.0")] impl !Send for NonNull { } /// `NonNull` pointers are not `Sync` because the data they reference may be aliased. // NB: This impl is unnecessary, but should provide better error messages. -#[stable(feature = "nonnull", since = "1.25.0")] +#[stable(feature = "nonnull", since = "1.24.0")] impl !Sync for NonNull { } impl NonNull { @@ -2502,7 +2509,7 @@ impl NonNull { /// /// This is useful for initializing types which lazily allocate, like /// `Vec::new` does. - #[stable(feature = "nonnull", since = "1.25.0")] + #[stable(feature = "nonnull", since = "1.24.0")] pub fn dangling() -> Self { unsafe { let ptr = mem::align_of::() as *mut T; @@ -2517,19 +2524,19 @@ impl NonNull { /// # Safety /// /// `ptr` must be non-null. - #[stable(feature = "nonnull", since = "1.25.0")] + #[stable(feature = "nonnull", since = "1.24.0")] pub const unsafe fn new_unchecked(ptr: *mut T) -> Self { NonNull { pointer: NonZero::new_unchecked(ptr) } } /// Creates a new `NonNull` if `ptr` is non-null. - #[stable(feature = "nonnull", since = "1.25.0")] + #[stable(feature = "nonnull", since = "1.24.0")] pub fn new(ptr: *mut T) -> Option { NonZero::new(ptr as *const T).map(|nz| NonNull { pointer: nz }) } /// Acquires the underlying `*mut` pointer. - #[stable(feature = "nonnull", since = "1.25.0")] + #[stable(feature = "nonnull", since = "1.24.0")] pub fn as_ptr(self) -> *mut T { self.pointer.get() as *mut T } @@ -2539,7 +2546,7 @@ impl NonNull { /// The resulting lifetime is bound to self so this behaves "as if" /// it were actually an instance of T that is getting borrowed. If a longer /// (unbound) lifetime is needed, use `&*my_ptr.as_ptr()`. - #[stable(feature = "nonnull", since = "1.25.0")] + #[stable(feature = "nonnull", since = "1.24.0")] pub unsafe fn as_ref(&self) -> &T { &*self.as_ptr() } @@ -2549,93 +2556,47 @@ impl NonNull { /// The resulting lifetime is bound to self so this behaves "as if" /// it were actually an instance of T that is getting borrowed. If a longer /// (unbound) lifetime is needed, use `&mut *my_ptr.as_ptr()`. - #[stable(feature = "nonnull", since = "1.25.0")] + #[stable(feature = "nonnull", since = "1.24.0")] pub unsafe fn as_mut(&mut self) -> &mut T { &mut *self.as_ptr() } - - /// Cast to a pointer of another type - #[unstable(feature = "nonnull_cast", issue = "47653")] - pub fn cast(self) -> NonNull { - unsafe { - NonNull::new_unchecked(self.as_ptr() as *mut U) - } - } } -#[stable(feature = "nonnull", since = "1.25.0")] +#[stable(feature = "nonnull", since = "1.24.0")] impl Clone for NonNull { fn clone(&self) -> Self { *self } } -#[stable(feature = "nonnull", since = "1.25.0")] +#[stable(feature = "nonnull", since = "1.24.0")] impl Copy for NonNull { } -#[stable(feature = "nonnull", since = "1.25.0")] +#[stable(feature = "nonnull", since = "1.24.0")] impl CoerceUnsized> for NonNull where T: Unsize { } -#[stable(feature = "nonnull", since = "1.25.0")] -impl fmt::Debug for NonNull { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt::Pointer::fmt(&self.as_ptr(), f) - } -} - -#[stable(feature = "nonnull", since = "1.25.0")] +#[stable(feature = "nonnull", since = "1.24.0")] impl fmt::Pointer for NonNull { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Pointer::fmt(&self.as_ptr(), f) } } -#[stable(feature = "nonnull", since = "1.25.0")] -impl Eq for NonNull {} - -#[stable(feature = "nonnull", since = "1.25.0")] -impl PartialEq for NonNull { - fn eq(&self, other: &Self) -> bool { - self.as_ptr() == other.as_ptr() - } -} - -#[stable(feature = "nonnull", since = "1.25.0")] -impl Ord for NonNull { - fn cmp(&self, other: &Self) -> Ordering { - self.as_ptr().cmp(&other.as_ptr()) - } -} - -#[stable(feature = "nonnull", since = "1.25.0")] -impl PartialOrd for NonNull { - fn partial_cmp(&self, other: &Self) -> Option { - self.as_ptr().partial_cmp(&other.as_ptr()) - } -} - -#[stable(feature = "nonnull", since = "1.25.0")] -impl hash::Hash for NonNull { - fn hash(&self, state: &mut H) { - self.as_ptr().hash(state) - } -} - -#[stable(feature = "nonnull", since = "1.25.0")] +#[stable(feature = "nonnull", since = "1.24.0")] impl From> for NonNull { fn from(unique: Unique) -> Self { NonNull { pointer: unique.pointer } } } -#[stable(feature = "nonnull", since = "1.25.0")] +#[stable(feature = "nonnull", since = "1.24.0")] impl<'a, T: ?Sized> From<&'a mut T> for NonNull { fn from(reference: &'a mut T) -> Self { NonNull { pointer: NonZero::from(reference) } } } -#[stable(feature = "nonnull", since = "1.25.0")] +#[stable(feature = "nonnull", since = "1.24.0")] impl<'a, T: ?Sized> From<&'a T> for NonNull { fn from(reference: &'a T) -> Self { NonNull { pointer: NonZero::from(reference) } diff --git a/src/libcore/sync/atomic.rs b/src/libcore/sync/atomic.rs index f22862ae70190..8b47143f63caa 100644 --- a/src/libcore/sync/atomic.rs +++ b/src/libcore/sync/atomic.rs @@ -945,7 +945,6 @@ macro_rules! atomic_int { $stable_debug:meta, $stable_access:meta, $stable_from:meta, - $stable_nand:meta, $s_int_type:expr, $int_ref:expr, $int_type:ident $atomic_type:ident $atomic_init:ident) => { /// An integer type which can be safely shared between threads. @@ -1326,29 +1325,6 @@ macro_rules! atomic_int { unsafe { atomic_and(self.v.get(), val, order) } } - /// Bitwise "nand" with the current value. - /// - /// Performs a bitwise "nand" operation on the current value and the argument `val`, and - /// sets the new value to the result. - /// - /// Returns the previous value. - /// - /// # Examples - /// - /// ``` - /// #![feature(atomic_nand)] - /// - /// use std::sync::atomic::{AtomicIsize, Ordering}; - /// - /// let foo = AtomicIsize::new(0xf731); - /// assert_eq!(foo.fetch_nand(0x137f, Ordering::SeqCst), 0xf731); - /// assert_eq!(foo.load(Ordering::SeqCst), !(0xf731 & 0x137f)); - #[inline] - #[$stable_nand] - pub fn fetch_nand(&self, val: $int_type, order: Ordering) -> $int_type { - unsafe { atomic_nand(self.v.get(), val, order) } - } - /// Bitwise "or" with the current value. /// /// Performs a bitwise "or" operation on the current value and the argument `val`, and @@ -1401,7 +1377,6 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "atomic_nand", issue = "13226"), "i8", "../../../std/primitive.i8.html", i8 AtomicI8 ATOMIC_I8_INIT } @@ -1412,7 +1387,6 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "atomic_nand", issue = "13226"), "u8", "../../../std/primitive.u8.html", u8 AtomicU8 ATOMIC_U8_INIT } @@ -1423,7 +1397,6 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "atomic_nand", issue = "13226"), "i16", "../../../std/primitive.i16.html", i16 AtomicI16 ATOMIC_I16_INIT } @@ -1434,7 +1407,6 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "atomic_nand", issue = "13226"), "u16", "../../../std/primitive.u16.html", u16 AtomicU16 ATOMIC_U16_INIT } @@ -1445,7 +1417,6 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "atomic_nand", issue = "13226"), "i32", "../../../std/primitive.i32.html", i32 AtomicI32 ATOMIC_I32_INIT } @@ -1456,7 +1427,6 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "atomic_nand", issue = "13226"), "u32", "../../../std/primitive.u32.html", u32 AtomicU32 ATOMIC_U32_INIT } @@ -1467,7 +1437,6 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "atomic_nand", issue = "13226"), "i64", "../../../std/primitive.i64.html", i64 AtomicI64 ATOMIC_I64_INIT } @@ -1478,7 +1447,6 @@ atomic_int! { unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), unstable(feature = "integer_atomics", issue = "32976"), - unstable(feature = "atomic_nand", issue = "13226"), "u64", "../../../std/primitive.u64.html", u64 AtomicU64 ATOMIC_U64_INIT } @@ -1489,7 +1457,6 @@ atomic_int!{ stable(feature = "atomic_debug", since = "1.3.0"), stable(feature = "atomic_access", since = "1.15.0"), stable(feature = "atomic_from", since = "1.23.0"), - unstable(feature = "atomic_nand", issue = "13226"), "isize", "../../../std/primitive.isize.html", isize AtomicIsize ATOMIC_ISIZE_INIT } @@ -1500,7 +1467,6 @@ atomic_int!{ stable(feature = "atomic_debug", since = "1.3.0"), stable(feature = "atomic_access", since = "1.15.0"), stable(feature = "atomic_from", since = "1.23.0"), - unstable(feature = "atomic_nand", issue = "13226"), "usize", "../../../std/primitive.usize.html", usize AtomicUsize ATOMIC_USIZE_INIT } @@ -1643,18 +1609,6 @@ unsafe fn atomic_and(dst: *mut T, val: T, order: Ordering) -> T { } } -#[inline] -unsafe fn atomic_nand(dst: *mut T, val: T, order: Ordering) -> T { - match order { - Acquire => intrinsics::atomic_nand_acq(dst, val), - Release => intrinsics::atomic_nand_rel(dst, val), - AcqRel => intrinsics::atomic_nand_acqrel(dst, val), - Relaxed => intrinsics::atomic_nand_relaxed(dst, val), - SeqCst => intrinsics::atomic_nand(dst, val), - __Nonexhaustive => panic!("invalid memory ordering"), - } -} - #[inline] unsafe fn atomic_or(dst: *mut T, val: T, order: Ordering) -> T { match order { diff --git a/src/libcore/tests/atomic.rs b/src/libcore/tests/atomic.rs index f634fabe50399..9babe24a98563 100644 --- a/src/libcore/tests/atomic.rs +++ b/src/libcore/tests/atomic.rs @@ -48,13 +48,6 @@ fn uint_and() { assert_eq!(x.load(SeqCst), 0xf731 & 0x137f); } -#[test] -fn uint_nand() { - let x = AtomicUsize::new(0xf731); - assert_eq!(x.fetch_nand(0x137f, SeqCst), 0xf731); - assert_eq!(x.load(SeqCst), !(0xf731 & 0x137f)); -} - #[test] fn uint_or() { let x = AtomicUsize::new(0xf731); @@ -76,13 +69,6 @@ fn int_and() { assert_eq!(x.load(SeqCst), 0xf731 & 0x137f); } -#[test] -fn int_nand() { - let x = AtomicIsize::new(0xf731); - assert_eq!(x.fetch_nand(0x137f, SeqCst), 0xf731); - assert_eq!(x.load(SeqCst), !(0xf731 & 0x137f)); -} - #[test] fn int_or() { let x = AtomicIsize::new(0xf731); diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index b2a5243d5e67b..8997cf9c6bff9 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -161,68 +161,6 @@ fn test_iterator_step_by() { assert_eq!(it.next(), None); } -#[test] -fn test_iterator_step_by_nth() { - let mut it = (0..16).step_by(5); - assert_eq!(it.nth(0), Some(0)); - assert_eq!(it.nth(0), Some(5)); - assert_eq!(it.nth(0), Some(10)); - assert_eq!(it.nth(0), Some(15)); - assert_eq!(it.nth(0), None); - - let it = (0..18).step_by(5); - assert_eq!(it.clone().nth(0), Some(0)); - assert_eq!(it.clone().nth(1), Some(5)); - assert_eq!(it.clone().nth(2), Some(10)); - assert_eq!(it.clone().nth(3), Some(15)); - assert_eq!(it.clone().nth(4), None); - assert_eq!(it.clone().nth(42), None); -} - -#[test] -fn test_iterator_step_by_nth_overflow() { - #[cfg(target_pointer_width = "8")] - type Bigger = u16; - #[cfg(target_pointer_width = "16")] - type Bigger = u32; - #[cfg(target_pointer_width = "32")] - type Bigger = u64; - #[cfg(target_pointer_width = "64")] - type Bigger = u128; - - #[derive(Clone)] - struct Test(Bigger); - impl<'a> Iterator for &'a mut Test { - type Item = i32; - fn next(&mut self) -> Option { Some(21) } - fn nth(&mut self, n: usize) -> Option { - self.0 += n as Bigger + 1; - Some(42) - } - } - - let mut it = Test(0); - let root = usize::MAX >> (::std::mem::size_of::() * 8 / 2); - let n = root + 20; - (&mut it).step_by(n).nth(n); - assert_eq!(it.0, n as Bigger * n as Bigger); - - // large step - let mut it = Test(0); - (&mut it).step_by(usize::MAX).nth(5); - assert_eq!(it.0, (usize::MAX as Bigger) * 5); - - // n + 1 overflows - let mut it = Test(0); - (&mut it).step_by(2).nth(usize::MAX); - assert_eq!(it.0, (usize::MAX as Bigger) * 2); - - // n + 1 overflows - let mut it = Test(0); - (&mut it).step_by(1).nth(usize::MAX); - assert_eq!(it.0, (usize::MAX as Bigger) * 1); -} - #[test] #[should_panic] fn test_iterator_step_by_zero() { @@ -1332,18 +1270,6 @@ fn test_range_inclusive_exhaustion() { assert_eq!(r.next_back(), Some(10)); assert_eq!(r, 1..=0); - let mut r = 10..=12; - assert_eq!(r.next(), Some(10)); - assert_eq!(r.next(), Some(11)); - assert_eq!(r.next(), Some(12)); - assert_eq!(r, 1..=0); - - let mut r = 10..=12; - assert_eq!(r.next_back(), Some(12)); - assert_eq!(r.next_back(), Some(11)); - assert_eq!(r.next_back(), Some(10)); - assert_eq!(r, 1..=0); - let mut r = 10..=12; assert_eq!(r.nth(2), Some(12)); assert_eq!(r, 1..=0); @@ -1352,13 +1278,6 @@ fn test_range_inclusive_exhaustion() { assert_eq!(r.nth(5), None); assert_eq!(r, 1..=0); - let mut r = 100..=10; - assert_eq!(r.next(), None); - assert_eq!(r, 100..=10); - - let mut r = 100..=10; - assert_eq!(r.next_back(), None); - assert_eq!(r, 100..=10); } #[test] @@ -1390,29 +1309,6 @@ fn test_range_from_nth() { assert_eq!(r, 16..); assert_eq!(r.nth(10), Some(26)); assert_eq!(r, 27..); - - assert_eq!((0..).size_hint(), (usize::MAX, None)); -} - -fn is_trusted_len(_: I) {} - -#[test] -fn test_range_from_take() { - let mut it = (0..).take(3); - assert_eq!(it.next(), Some(0)); - assert_eq!(it.next(), Some(1)); - assert_eq!(it.next(), Some(2)); - assert_eq!(it.next(), None); - is_trusted_len((0..).take(3)); - assert_eq!((0..).take(3).size_hint(), (3, Some(3))); - assert_eq!((0..).take(0).size_hint(), (0, Some(0))); - assert_eq!((0..).take(usize::MAX).size_hint(), (usize::MAX, Some(usize::MAX))); -} - -#[test] -fn test_range_from_take_collect() { - let v: Vec<_> = (0..).take(3).collect(); - assert_eq!(v, vec![0, 1, 2]); } #[test] @@ -1501,52 +1397,12 @@ fn test_range_inclusive_min() { assert_eq!(r.min(), None); } -#[test] -fn test_range_inclusive_folds() { - assert_eq!((1..=10).sum::(), 55); - assert_eq!((1..=10).rev().sum::(), 55); - - let mut it = 40..=50; - assert_eq!(it.try_fold(0, i8::checked_add), None); - assert_eq!(it, 44..=50); - assert_eq!(it.try_rfold(0, i8::checked_add), None); - assert_eq!(it, 44..=47); - - let mut it = 10..=20; - assert_eq!(it.try_fold(0, |a,b| Some(a+b)), Some(165)); - assert_eq!(it, 1..=0); - - let mut it = 10..=20; - assert_eq!(it.try_rfold(0, |a,b| Some(a+b)), Some(165)); - assert_eq!(it, 1..=0); -} - #[test] fn test_repeat() { let mut it = repeat(42); assert_eq!(it.next(), Some(42)); assert_eq!(it.next(), Some(42)); assert_eq!(it.next(), Some(42)); - assert_eq!(repeat(42).size_hint(), (usize::MAX, None)); -} - -#[test] -fn test_repeat_take() { - let mut it = repeat(42).take(3); - assert_eq!(it.next(), Some(42)); - assert_eq!(it.next(), Some(42)); - assert_eq!(it.next(), Some(42)); - assert_eq!(it.next(), None); - is_trusted_len(repeat(42).take(3)); - assert_eq!(repeat(42).take(3).size_hint(), (3, Some(3))); - assert_eq!(repeat(42).take(0).size_hint(), (0, Some(0))); - assert_eq!(repeat(42).take(usize::MAX).size_hint(), (usize::MAX, Some(usize::MAX))); -} - -#[test] -fn test_repeat_take_collect() { - let v: Vec<_> = repeat(42).take(3).collect(); - assert_eq!(v, vec![42, 42, 42]); } #[test] diff --git a/src/libcore/tests/lib.rs b/src/libcore/tests/lib.rs index 9e90313bc0e9e..1c32452f84635 100644 --- a/src/libcore/tests/lib.rs +++ b/src/libcore/tests/lib.rs @@ -42,7 +42,6 @@ #![feature(try_from)] #![feature(try_trait)] #![feature(exact_chunks)] -#![feature(atomic_nand)] extern crate core; extern crate test; diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 71519ab21fef9..44cdb5e8a3676 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -73,7 +73,7 @@ pub struct FormatSpec<'a> { /// Enum describing where an argument for a format can be located. #[derive(Copy, Clone, PartialEq)] pub enum Position<'a> { - /// The argument is implied to be located at an index + /// The arugment is implied to be located at an index ArgumentImplicitlyIs(usize), /// The argument is located at a specific index given in the format ArgumentIs(usize), diff --git a/src/libpanic_abort/lib.rs b/src/libpanic_abort/lib.rs index 5f768ef4399e8..c3bd6a2bc187d 100644 --- a/src/libpanic_abort/lib.rs +++ b/src/libpanic_abort/lib.rs @@ -27,12 +27,10 @@ #![feature(libc)] #![feature(panic_runtime)] #![feature(staged_api)] -#![feature(rustc_attrs)] // Rust's "try" function, but if we're aborting on panics we just call the // function as there's nothing else we need to do here. #[no_mangle] -#[rustc_std_internal_symbol] pub unsafe extern fn __rust_maybe_catch_panic(f: fn(*mut u8), data: *mut u8, _data_ptr: *mut usize, @@ -52,7 +50,6 @@ pub unsafe extern fn __rust_maybe_catch_panic(f: fn(*mut u8), // will kill us with an illegal instruction, which will do a good enough job for // now hopefully. #[no_mangle] -#[rustc_std_internal_symbol] pub unsafe extern fn __rust_start_panic(_data: usize, _vtable: usize) -> u32 { abort(); diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 6768e0ade4304..b9e816baac0dc 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -685,7 +685,7 @@ impl TokenTree { }) } - DotEq => joint!('.', Eq), + DotEq => unreachable!(), OpenDelim(..) | CloseDelim(..) => unreachable!(), Whitespace | Comment | Shebang(..) | Eof => unreachable!(), }; diff --git a/src/librustc/README.md b/src/librustc/README.md index 722456a76ce59..ddf71a06d607c 100644 --- a/src/librustc/README.md +++ b/src/librustc/README.md @@ -176,7 +176,6 @@ pointers for understanding them better. - `'gcx` -- the lifetime of the global arena (see `librustc/ty`). - generics -- the set of generic type parameters defined on a type or item - ICE -- internal compiler error. When the compiler crashes. -- ICH -- incremental compilation hash. - infcx -- the inference context (see `librustc/infer`) - MIR -- the **Mid-level IR** that is created after type-checking for use by borrowck and trans. Defined in the `src/librustc/mir/` module, but much of the code that manipulates it is diff --git a/src/librustc/dep_graph/dep_node.rs b/src/librustc/dep_graph/dep_node.rs index 4034055d04155..1de9091b5df7d 100644 --- a/src/librustc/dep_graph/dep_node.rs +++ b/src/librustc/dep_graph/dep_node.rs @@ -639,9 +639,6 @@ define_dep_nodes!( <'tcx> [] TargetFeaturesEnabled(DefId), [] InstanceDefSizeEstimate { instance_def: InstanceDef<'tcx> }, - - [] GetSymbolExportLevel(DefId), - ); trait DepNodeParams<'a, 'gcx: 'tcx + 'a, 'tcx: 'a> : fmt::Debug { diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 4c256556191fa..8bd89b834d6b6 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -256,28 +256,6 @@ trait Foo { } ``` -### The trait cannot contain associated constants - -Just like static functions, associated constants aren't stored on the method -table. If the trait or any subtrait contain an associated constant, they cannot -be made into an object. - -```compile_fail,E0038 -trait Foo { - const X: i32; -} - -impl Foo {} -``` - -A simple workaround is to use a helper method instead: - -``` -trait Foo { - fn x(&self) -> i32; -} -``` - ### The trait cannot use `Self` as a type parameter in the supertrait listing This is similar to the second sub-error, but subtler. It happens in situations diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index b804cf7bf5a34..97cf9b01410b1 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -965,8 +965,8 @@ pub fn walk_expr<'v, V: Visitor<'v>>(visitor: &mut V, expression: &'v Expr) { walk_list!(visitor, visit_expr, subexpressions); } ExprCall(ref callee_expression, ref arguments) => { - visitor.visit_expr(callee_expression); walk_list!(visitor, visit_expr, arguments); + visitor.visit_expr(callee_expression) } ExprMethodCall(ref segment, _, ref arguments) => { visitor.visit_path_segment(expression.span, segment); diff --git a/src/librustc/ich/impls_mir.rs b/src/librustc/ich/impls_mir.rs index 67b4cfb6fa7e4..f46b590d2dc59 100644 --- a/src/librustc/ich/impls_mir.rs +++ b/src/librustc/ich/impls_mir.rs @@ -20,6 +20,7 @@ use std::mem; impl_stable_hash_for!(struct mir::GeneratorLayout<'tcx> { fields }); impl_stable_hash_for!(struct mir::SourceInfo { span, scope }); impl_stable_hash_for!(enum mir::Mutability { Mut, Not }); +impl_stable_hash_for!(enum mir::BorrowKind { Shared, Unique, Mut }); impl_stable_hash_for!(enum mir::LocalKind { Var, Temp, Arg, ReturnPointer }); impl_stable_hash_for!(struct mir::LocalDecl<'tcx> { mutability, @@ -35,25 +36,6 @@ impl_stable_hash_for!(struct mir::BasicBlockData<'tcx> { statements, terminator, impl_stable_hash_for!(struct mir::UnsafetyViolation { source_info, description, kind }); impl_stable_hash_for!(struct mir::UnsafetyCheckResult { violations, unsafe_blocks }); -impl<'gcx> HashStable> -for mir::BorrowKind { - #[inline] - fn hash_stable(&self, - hcx: &mut StableHashingContext<'gcx>, - hasher: &mut StableHasher) { - mem::discriminant(self).hash_stable(hcx, hasher); - - match *self { - mir::BorrowKind::Shared | - mir::BorrowKind::Unique => {} - mir::BorrowKind::Mut { allow_two_phase_borrow } => { - allow_two_phase_borrow.hash_stable(hcx, hasher); - } - } - } -} - - impl<'gcx> HashStable> for mir::UnsafetyViolationKind { #[inline] @@ -219,10 +201,6 @@ for mir::TerminatorKind<'gcx> { target.hash_stable(hcx, hasher); } } - mir::TerminatorKind::FalseUnwind { ref real_target, ref unwind } => { - real_target.hash_stable(hcx, hasher); - unwind.hash_stable(hcx, hasher); - } } } } diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index d1e431597e745..107779ec3fa15 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -163,20 +163,6 @@ impl_stable_hash_for!(struct ty::adjustment::Adjustment<'tcx> { kind, target }); impl_stable_hash_for!(struct ty::adjustment::OverloadedDeref<'tcx> { region, mutbl }); impl_stable_hash_for!(struct ty::UpvarBorrow<'tcx> { kind, region }); -impl<'gcx> HashStable> for ty::adjustment::AutoBorrowMutability { - fn hash_stable(&self, - hcx: &mut StableHashingContext<'gcx>, - hasher: &mut StableHasher) { - mem::discriminant(self).hash_stable(hcx, hasher); - match *self { - ty::adjustment::AutoBorrowMutability::Mutable { ref allow_two_phase_borrow } => { - allow_two_phase_borrow.hash_stable(hcx, hasher); - } - ty::adjustment::AutoBorrowMutability::Immutable => {} - } - } -} - impl_stable_hash_for!(struct ty::UpvarId { var_id, closure_expr_id }); impl_stable_hash_for!(enum ty::BorrowKind { diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs index 03fc40b2e39fc..b10e742595720 100644 --- a/src/librustc/infer/error_reporting/mod.rs +++ b/src/librustc/infer/error_reporting/mod.rs @@ -175,6 +175,25 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { ty::ReEarlyBound(_) | ty::ReFree(_) => { let scope = region.free_region_binding_scope(self); + let prefix = match *region { + ty::ReEarlyBound(ref br) => { + format!("the lifetime {} as defined on", br.name) + } + ty::ReFree(ref fr) => { + match fr.bound_region { + ty::BrAnon(idx) => { + format!("the anonymous lifetime #{} defined on", idx + 1) + } + ty::BrFresh(_) => "an anonymous lifetime defined on".to_owned(), + _ => { + format!("the lifetime {} as defined on", + fr.bound_region) + } + } + } + _ => bug!() + }; + let node = self.hir.as_local_node_id(scope) .unwrap_or(DUMMY_NODE_ID); let unknown; @@ -199,26 +218,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { &unknown } }; - let (prefix, span) = match *region { - ty::ReEarlyBound(ref br) => { - (format!("the lifetime {} as defined on", br.name), - self.sess.codemap().def_span(self.hir.span(node))) - } - ty::ReFree(ref fr) => { - match fr.bound_region { - ty::BrAnon(idx) => { - (format!("the anonymous lifetime #{} defined on", idx + 1), - self.hir.span(node)) - } - ty::BrFresh(_) => ("an anonymous lifetime defined on".to_owned(), - self.hir.span(node)), - _ => (format!("the lifetime {} as defined on", fr.bound_region), - self.sess.codemap().def_span(self.hir.span(node))), - } - } - _ => bug!() - }; - let (msg, opt_span) = explain_span(self, tag, span); + let (msg, opt_span) = explain_span(self, tag, self.hir.span(node)); (format!("{} {}", prefix, msg), opt_span) } @@ -807,7 +807,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } }; - let span = cause.span(&self.tcx); + let span = cause.span; diag.span_label(span, terr.to_string()); if let Some((sp, msg)) = secondary_span { @@ -842,7 +842,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { "did you mean `{}(/* fields */)`?", self.tcx.item_path_str(def_id) ); - diag.span_label(span, message); + diag.span_label(cause.span, message); } } } @@ -870,7 +870,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { trace, terr); - let span = trace.cause.span(&self.tcx); + let span = trace.cause.span; let failure_code = trace.cause.as_failure_code(terr); let mut diag = match failure_code { FailureCode::Error0317(failure_str) => { @@ -1076,31 +1076,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { sup_region, "..."); - match (&sup_origin, &sub_origin) { - (&infer::Subtype(ref sup_trace), &infer::Subtype(ref sub_trace)) => { - if let (Some((sup_expected, sup_found)), - Some((sub_expected, sub_found))) = (self.values_str(&sup_trace.values), - self.values_str(&sub_trace.values)) { - if sub_expected == sup_expected && sub_found == sup_found { - self.tcx.note_and_explain_region( - region_scope_tree, - &mut err, - "...but the lifetime must also be valid for ", - sub_region, - "...", - ); - err.note(&format!("...so that the {}:\nexpected {}\n found {}", - sup_trace.cause.as_requirement_str(), - sup_expected.content(), - sup_found.content())); - err.emit(); - return; - } - } - } - _ => {} - } - self.note_region_origin(&mut err, &sup_origin); self.tcx.note_and_explain_region(region_scope_tree, &mut err, diff --git a/src/librustc/infer/error_reporting/note.rs b/src/librustc/infer/error_reporting/note.rs index 02ec9fe74c1fe..e46613b3e4da0 100644 --- a/src/librustc/infer/error_reporting/note.rs +++ b/src/librustc/infer/error_reporting/note.rs @@ -23,10 +23,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { if let Some((expected, found)) = self.values_str(&trace.values) { let expected = expected.content(); let found = found.content(); - err.note(&format!("...so that the {}:\nexpected {}\n found {}", - trace.cause.as_requirement_str(), - expected, - found)); + // FIXME: do we want a "the" here? + err.span_note(trace.cause.span, + &format!("...so that {} (expected {}, found {})", + trace.cause.as_requirement_str(), + expected, + found)); } else { // FIXME: this really should be handled at some earlier stage. Our // handling of region checking when type errors are present is diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index a7a2619505931..d727dfb0c4b2d 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -58,7 +58,6 @@ #![feature(macro_vis_matcher)] #![feature(match_default_bindings)] #![feature(never_type)] -#![feature(non_exhaustive)] #![feature(nonzero)] #![feature(quote)] #![feature(refcell_replace_swap)] @@ -67,7 +66,6 @@ #![feature(specialization)] #![feature(unboxed_closures)] #![feature(underscore_lifetimes)] -#![feature(universal_impl_trait)] #![feature(trace_macros)] #![feature(catch_expr)] #![feature(test)] diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 0577800f3f411..143d2c2ea28bb 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -246,12 +246,6 @@ declare_lint! { "raw pointer to an inference variable" } -declare_lint! { - pub ELIDED_LIFETIME_IN_PATH, - Allow, - "hidden lifetime parameters are deprecated, try `Foo<'_>`" -} - /// Does nothing as a lint pass, but registers some `Lint`s /// which are used by other parts of the compiler. #[derive(Copy, Clone)] @@ -297,9 +291,7 @@ impl LintPass for HardwiredLints { UNUSED_MUT, COERCE_NEVER, SINGLE_USE_LIFETIME, - TYVAR_BEHIND_RAW_POINTER, - ELIDED_LIFETIME_IN_PATH - + TYVAR_BEHIND_RAW_POINTER ) } } diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index ed937046e5ed7..5336c1944e8c4 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -631,7 +631,7 @@ impl<'a, 'tcx> LayoutOf> for &'a LateContext<'a, 'tcx> { type TyLayout = Result, LayoutError<'tcx>>; fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout { - self.tcx.layout_of(self.param_env.and(ty)) + (self.tcx, self.param_env.reveal_all()).layout_of(ty) } } @@ -1042,20 +1042,11 @@ pub fn check_ast_crate(sess: &Session, krate: &ast::Crate) { // Put the lint store levels and passes back in the session. cx.lint_sess.restore(&sess.lint_store); - // All of the buffered lints should have been emitted at this point. - // If not, that means that we somehow buffered a lint for a node id - // that was not lint-checked (perhaps it doesn't exist?). This is a bug. - // - // Rustdoc runs everybody-loops before the early lints and removes - // function bodies, so it's totally possible for linted - // node ids to not exist (e.g. macros defined within functions for the - // unused_macro lint) anymore. So we only run this check - // when we're not in rustdoc mode. (see issue #47639) - if !sess.opts.actually_rustdoc { - for (_id, lints) in cx.buffered.map { - for early_lint in lints { - span_bug!(early_lint.span, "failed to process buffered lint here"); - } + // Emit all buffered lints from early on in the session now that we've + // calculated the lint levels for all AST nodes. + for (_id, lints) in cx.buffered.map { + for early_lint in lints { + span_bug!(early_lint.span, "failed to process buffered lint here"); } } } diff --git a/src/librustc/middle/entry.rs b/src/librustc/middle/entry.rs index 8b4b9aaeac848..31e054ec1cb93 100644 --- a/src/librustc/middle/entry.rs +++ b/src/librustc/middle/entry.rs @@ -175,10 +175,6 @@ fn configure_main(this: &mut EntryContext) { err.emit(); this.session.abort_if_errors(); } else { - if this.session.teach(&err.get_code().unwrap()) { - err.note("If you don't know the basics of Rust, you can go look to the Rust Book \ - to get started: https://doc.rust-lang.org/book/"); - } err.emit(); } } diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 7db75a5166898..c69005101c671 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -760,7 +760,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { expr.span, cmt_base, r, - ty::BorrowKind::from_mutbl(m.into()), + ty::BorrowKind::from_mutbl(m), AutoRef); } diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 10497c95e27d0..297586f140e34 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -109,7 +109,7 @@ use self::VarKind::*; use hir::def::*; use ty::{self, TyCtxt}; use lint; -use util::nodemap::{NodeMap, NodeSet}; +use util::nodemap::NodeMap; use std::{fmt, usize}; use std::io::prelude::*; @@ -244,8 +244,7 @@ struct CaptureInfo { #[derive(Copy, Clone, Debug)] struct LocalInfo { id: NodeId, - name: ast::Name, - is_shorthand: bool, + name: ast::Name } #[derive(Copy, Clone, Debug)] @@ -334,13 +333,6 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> { } } - fn variable_is_shorthand(&self, var: Variable) -> bool { - match self.var_kinds[var.get()] { - Local(LocalInfo { is_shorthand, .. }) => is_shorthand, - Arg(..) | CleanExit => false - } - } - fn set_captures(&mut self, node_id: NodeId, cs: Vec) { self.capture_info_map.insert(node_id, Rc::new(cs)); } @@ -392,9 +384,8 @@ fn visit_local<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, local: &'tcx hir::Local) { let name = path1.node; ir.add_live_node_for_node(p_id, VarDefNode(sp)); ir.add_variable(Local(LocalInfo { - id: p_id, - name, - is_shorthand: false, + id: p_id, + name, })); }); intravisit::walk_local(ir, local); @@ -402,22 +393,6 @@ fn visit_local<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, local: &'tcx hir::Local) { fn visit_arm<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, arm: &'tcx hir::Arm) { for pat in &arm.pats { - // for struct patterns, take note of which fields used shorthand (`x` - // rather than `x: x`) - // - // FIXME: according to the rust-lang-nursery/rustc-guide book and - // librustc/README.md, `NodeId`s are to be phased out in favor of - // `HirId`s; however, we need to match the signature of `each_binding`, - // which uses `NodeIds`. - let mut shorthand_field_ids = NodeSet(); - if let hir::PatKind::Struct(_, ref fields, _) = pat.node { - for field in fields { - if field.node.is_shorthand { - shorthand_field_ids.insert(field.node.pat.id); - } - } - } - pat.each_binding(|bm, p_id, sp, path1| { debug!("adding local variable {} from match with bm {:?}", p_id, bm); @@ -425,8 +400,7 @@ fn visit_arm<'a, 'tcx>(ir: &mut IrMaps<'a, 'tcx>, arm: &'tcx hir::Arm) { ir.add_live_node_for_node(p_id, VarDefNode(sp)); ir.add_variable(Local(LocalInfo { id: p_id, - name: name, - is_shorthand: shorthand_field_ids.contains(&p_id) + name, })); }) } @@ -1509,26 +1483,17 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { self.assigned_on_exit(ln, var).is_some() }; - let suggest_underscore_msg = format!("consider using `_{}` instead", - name); if is_assigned { - self.ir.tcx - .lint_node_note(lint::builtin::UNUSED_VARIABLES, id, sp, - &format!("variable `{}` is assigned to, but never used", - name), - &suggest_underscore_msg); + self.ir.tcx.lint_node_note(lint::builtin::UNUSED_VARIABLES, id, sp, + &format!("variable `{}` is assigned to, but never used", + name), + &format!("to avoid this warning, consider using `_{}` instead", + name)); } else if name != "self" { - let msg = format!("unused variable: `{}`", name); - let mut err = self.ir.tcx - .struct_span_lint_node(lint::builtin::UNUSED_VARIABLES, id, sp, &msg); - if self.ir.variable_is_shorthand(var) { - err.span_suggestion(sp, "try ignoring the field", - format!("{}: _", name)); - } else { - err.span_suggestion_short(sp, &suggest_underscore_msg, - format!("_{}", name)); - } - err.emit() + self.ir.tcx.lint_node_note(lint::builtin::UNUSED_VARIABLES, id, sp, + &format!("unused variable: `{}`", name), + &format!("to avoid this warning, consider using `_{}` instead", + name)); } } true diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index e5619f469e774..dad2d7a7c90fb 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -467,13 +467,9 @@ impl<'tcx> Visitor<'tcx> for ExprLocatorVisitor { } fn visit_pat(&mut self, pat: &'tcx Pat) { - intravisit::walk_pat(self, pat); - self.expr_and_pat_count += 1; - if pat.id == self.id { - self.result = Some(self.expr_and_pat_count); - } + intravisit::walk_pat(self, pat); } fn visit_expr(&mut self, expr: &'tcx Expr) { @@ -818,8 +814,7 @@ impl<'tcx> ScopeTree { /// Checks whether the given scope contains a `yield`. If so, /// returns `Some((span, expr_count))` with the span of a yield we found and - /// the number of expressions and patterns appearing before the `yield` in the body + 1. - /// If there a are multiple yields in a scope, the one with the highest number is returned. + /// the number of expressions appearing before the `yield` in the body. pub fn yield_in_scope(&self, scope: Scope) -> Option<(Span, usize)> { self.yield_in_scope.get(&scope).cloned() } diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 59460141166b1..944d770516375 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -737,7 +737,7 @@ impl<'a, 'tcx> Visitor<'tcx> for LifetimeContext<'a, 'tcx> { fn visit_lifetime(&mut self, lifetime_ref: &'tcx hir::Lifetime) { if lifetime_ref.is_elided() { - self.resolve_elided_lifetimes(slice::from_ref(lifetime_ref), false); + self.resolve_elided_lifetimes(slice::from_ref(lifetime_ref)); return; } if lifetime_ref.is_static() { @@ -1444,7 +1444,7 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } if params.lifetimes.iter().all(|l| l.is_elided()) { - self.resolve_elided_lifetimes(¶ms.lifetimes, true); + self.resolve_elided_lifetimes(¶ms.lifetimes); } else { for l in ¶ms.lifetimes { self.visit_lifetime(l); @@ -1803,24 +1803,14 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> { } } - fn resolve_elided_lifetimes(&mut self, lifetime_refs: &'tcx [hir::Lifetime], deprecated: bool) { + fn resolve_elided_lifetimes(&mut self, lifetime_refs: &'tcx [hir::Lifetime]) { if lifetime_refs.is_empty() { return; } let span = lifetime_refs[0].span; - let id = lifetime_refs[0].id; let mut late_depth = 0; let mut scope = self.scope; - if deprecated { - self.tcx - .struct_span_lint_node( - lint::builtin::ELIDED_LIFETIME_IN_PATH, - id, - span, - &format!("hidden lifetime parameters are deprecated, try `Foo<'_>`")) - .emit(); - } let error = loop { match *scope { // Do not assign any resolution, it will be inferred. diff --git a/src/librustc/mir/mod.rs b/src/librustc/mir/mod.rs index 439be667861a2..3b644aa13f321 100644 --- a/src/librustc/mir/mod.rs +++ b/src/librustc/mir/mod.rs @@ -413,20 +413,7 @@ pub enum BorrowKind { Unique, /// Data is mutable and not aliasable. - Mut { - /// True if this borrow arose from method-call auto-ref - /// (i.e. `adjustment::Adjust::Borrow`) - allow_two_phase_borrow: bool - } -} - -impl BorrowKind { - pub fn allows_two_phase_borrow(&self) -> bool { - match *self { - BorrowKind::Shared | BorrowKind::Unique => false, - BorrowKind::Mut { allow_two_phase_borrow } => allow_two_phase_borrow, - } - } + Mut, } /////////////////////////////////////////////////////////////////////////// @@ -816,28 +803,9 @@ pub enum TerminatorKind<'tcx> { /// Indicates the end of the dropping of a generator GeneratorDrop, - /// A block where control flow only ever takes one real path, but borrowck - /// needs to be more conservative. FalseEdges { - /// The target normal control flow will take real_target: BasicBlock, - /// The list of blocks control flow could conceptually take, but won't - /// in practice - imaginary_targets: Vec, - }, - /// A terminator for blocks that only take one path in reality, but where we - /// reserve the right to unwind in borrowck, even if it won't happen in practice. - /// This can arise in infinite loops with no function calls for example. - FalseUnwind { - /// The target normal control flow will take - real_target: BasicBlock, - /// The imaginary cleanup block link. This particular path will never be taken - /// in practice, but in order to avoid fragility we want to always - /// consider it in borrowck. We don't want to accept programs which - /// pass borrowck only when panic=abort or some assertions are disabled - /// due to release vs. debug mode builds. This needs to be an Option because - /// of the remove_noop_landing_pads and no_landing_pads passes - unwind: Option, + imaginary_targets: Vec }, } @@ -897,8 +865,6 @@ impl<'tcx> TerminatorKind<'tcx> { s.extend_from_slice(imaginary_targets); s.into_cow() } - FalseUnwind { real_target: t, unwind: Some(u) } => vec![t, u].into_cow(), - FalseUnwind { real_target: ref t, unwind: None } => slice::from_ref(t).into_cow(), } } @@ -931,8 +897,6 @@ impl<'tcx> TerminatorKind<'tcx> { s.extend(imaginary_targets.iter_mut()); s } - FalseUnwind { real_target: ref mut t, unwind: Some(ref mut u) } => vec![t, u], - FalseUnwind { ref mut real_target, unwind: None } => vec![real_target], } } @@ -952,8 +916,7 @@ impl<'tcx> TerminatorKind<'tcx> { TerminatorKind::Call { cleanup: ref mut unwind, .. } | TerminatorKind::Assert { cleanup: ref mut unwind, .. } | TerminatorKind::DropAndReplace { ref mut unwind, .. } | - TerminatorKind::Drop { ref mut unwind, .. } | - TerminatorKind::FalseUnwind { ref mut unwind, .. } => { + TerminatorKind::Drop { ref mut unwind, .. } => { Some(unwind) } } @@ -1082,8 +1045,7 @@ impl<'tcx> TerminatorKind<'tcx> { write!(fmt, ")") }, - FalseEdges { .. } => write!(fmt, "falseEdges"), - FalseUnwind { .. } => write!(fmt, "falseUnwind"), + FalseEdges { .. } => write!(fmt, "falseEdges") } } @@ -1125,8 +1087,6 @@ impl<'tcx> TerminatorKind<'tcx> { l.resize(imaginary_targets.len() + 1, "imaginary".into()); l } - FalseUnwind { unwind: Some(_), .. } => vec!["real".into(), "cleanup".into()], - FalseUnwind { unwind: None, .. } => vec!["real".into()], } } } @@ -1555,8 +1515,8 @@ pub enum AggregateKind<'tcx> { Array(Ty<'tcx>), Tuple, - /// The second field is the variant index. It's equal to 0 for struct - /// and union expressions. The fourth field is + /// The second field is variant number (discriminant), it's equal + /// to 0 for struct and union expressions. The fourth field is /// active field number and is present only for union expressions /// -- e.g. for a union expression `SomeUnion { c: .. }`, the /// active field index would identity the field `c` @@ -1651,7 +1611,7 @@ impl<'tcx> Debug for Rvalue<'tcx> { Ref(region, borrow_kind, ref place) => { let kind_str = match borrow_kind { BorrowKind::Shared => "", - BorrowKind::Mut { .. } | BorrowKind::Unique => "mut ", + BorrowKind::Mut | BorrowKind::Unique => "mut ", }; // When printing regions, add trailing space if necessary. @@ -1865,7 +1825,7 @@ pub struct Location { /// the location is within this block pub block: BasicBlock, - /// the location is the start of the statement; or, if `statement_index` + /// the location is the start of the this statement; or, if `statement_index` /// == num-statements, then the start of the terminator. pub statement_index: usize, } @@ -2229,8 +2189,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> { Return => Return, Unreachable => Unreachable, FalseEdges { real_target, ref imaginary_targets } => - FalseEdges { real_target, imaginary_targets: imaginary_targets.clone() }, - FalseUnwind { real_target, unwind } => FalseUnwind { real_target, unwind }, + FalseEdges { real_target, imaginary_targets: imaginary_targets.clone() } }; Terminator { source_info: self.source_info, @@ -2272,8 +2231,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> { Return | GeneratorDrop | Unreachable | - FalseEdges { .. } | - FalseUnwind { .. } => false + FalseEdges { .. } => false } } } diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index bbfb9c89b3fc4..53607764b3984 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -182,8 +182,9 @@ impl<'tcx> Rvalue<'tcx> { if let ty::TyAdt(adt_def, _) = ty.sty { adt_def.repr.discr_type().to_ty(tcx) } else { - // This can only be `0`, for now, so `u8` will suffice. - tcx.types.u8 + // Undefined behaviour, bug for now; may want to return something for + // the `discriminant` intrinsic later. + bug!("Rvalue::Discriminant on Place of type {:?}", ty); } } Rvalue::NullaryOp(NullOp::Box, t) => tcx.mk_box(t), @@ -263,7 +264,7 @@ impl<'tcx> BinOp { impl BorrowKind { pub fn to_mutbl_lossy(self) -> hir::Mutability { match self { - BorrowKind::Mut { .. } => hir::MutMutable, + BorrowKind::Mut => hir::MutMutable, BorrowKind::Shared => hir::MutImmutable, // We have no type corresponding to a unique imm borrow, so diff --git a/src/librustc/mir/visit.rs b/src/librustc/mir/visit.rs index 0b6f1275bdb4c..57ed41f2f06e6 100644 --- a/src/librustc/mir/visit.rs +++ b/src/librustc/mir/visit.rs @@ -495,21 +495,15 @@ macro_rules! make_mir_visitor { self.visit_operand(value, source_location); self.visit_branch(block, resume); drop.map(|t| self.visit_branch(block, t)); + } - TerminatorKind::FalseEdges { real_target, ref imaginary_targets} => { + TerminatorKind::FalseEdges { real_target, ref imaginary_targets } => { self.visit_branch(block, real_target); for target in imaginary_targets { self.visit_branch(block, *target); } } - - TerminatorKind::FalseUnwind { real_target, unwind } => { - self.visit_branch(block, real_target); - if let Some(unwind) = unwind { - self.visit_branch(block, unwind); - } - } } } @@ -957,10 +951,9 @@ impl<'tcx> PlaceContext<'tcx> { pub fn is_mutating_use(&self) -> bool { match *self { PlaceContext::Store | PlaceContext::AsmOutput | PlaceContext::Call | - PlaceContext::Borrow { kind: BorrowKind::Mut { .. }, .. } | + PlaceContext::Borrow { kind: BorrowKind::Mut, .. } | PlaceContext::Projection(Mutability::Mut) | PlaceContext::Drop => true, - PlaceContext::Inspect | PlaceContext::Borrow { kind: BorrowKind::Shared, .. } | PlaceContext::Borrow { kind: BorrowKind::Unique, .. } | @@ -978,8 +971,7 @@ impl<'tcx> PlaceContext<'tcx> { PlaceContext::Borrow { kind: BorrowKind::Unique, .. } | PlaceContext::Projection(Mutability::Not) | PlaceContext::Copy | PlaceContext::Move => true, - - PlaceContext::Borrow { kind: BorrowKind::Mut { .. }, .. } | PlaceContext::Store | + PlaceContext::Borrow { kind: BorrowKind::Mut, .. } | PlaceContext::Store | PlaceContext::AsmOutput | PlaceContext::Call | PlaceContext::Projection(Mutability::Mut) | PlaceContext::Drop | PlaceContext::StorageLive | PlaceContext::StorageDead | diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 5b8092e86da04..b9546143a054b 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -112,31 +112,6 @@ pub enum OutputType { DepInfo, } -/// The epoch of the compiler (RFC 2052) -#[derive(Clone, Copy, Hash, PartialOrd, Ord, Eq, PartialEq)] -#[non_exhaustive] -pub enum Epoch { - // epochs must be kept in order, newest to oldest - - /// The 2015 epoch - Epoch2015, - /// The 2018 epoch - Epoch2018, - - // when adding new epochs, be sure to update: - // - // - the list in the `parse_epoch` static - // - the match in the `parse_epoch` function - // - add a `rust_####()` function to the session - // - update the enum in Cargo's sources as well - // - // When -Zepoch becomes --epoch, there will - // also be a check for the epoch being nightly-only - // somewhere. That will need to be updated - // whenever we're stabilizing/introducing a new epoch - // as well as changing the default Cargo template. -} - impl_stable_hash_for!(enum self::OutputType { Bitcode, Assembly, @@ -573,6 +548,25 @@ impl OutputFilenames { pub fn filestem(&self) -> String { format!("{}{}", self.out_filestem, self.extra) } + + pub fn contains_path(&self, input_path: &PathBuf) -> bool { + let input_path = input_path.canonicalize().ok(); + if input_path.is_none() { + return false + } + match self.single_output_file { + Some(ref output_path) => output_path.canonicalize().ok() == input_path, + None => { + for k in self.outputs.keys() { + let output_path = self.path(k.to_owned()); + if output_path.canonicalize().ok() == input_path { + return true; + } + } + false + } + } + } } pub fn host_triple() -> &'static str { @@ -808,13 +802,11 @@ macro_rules! options { Some("`string` or `string=string`"); pub const parse_lto: Option<&'static str> = Some("one of `thin`, `fat`, or omitted"); - pub const parse_epoch: Option<&'static str> = - Some("one of: `2015`, `2018`"); } #[allow(dead_code)] mod $mod_set { - use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer, Lto, Epoch}; + use super::{$struct_name, Passes, SomePasses, AllPasses, Sanitizer, Lto}; use rustc_back::{LinkerFlavor, PanicStrategy, RelroLevel}; use std::path::PathBuf; @@ -1018,15 +1010,6 @@ macro_rules! options { }; true } - - fn parse_epoch(slot: &mut Epoch, v: Option<&str>) -> bool { - match v { - Some("2015") => *slot = Epoch::Epoch2015, - Some("2018") => *slot = Epoch::Epoch2018, - _ => return false, - } - true - } } ) } @@ -1121,8 +1104,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, "select which borrowck is used (`ast`, `mir`, or `compare`)"), two_phase_borrows: bool = (false, parse_bool, [UNTRACKED], "use two-phase reserved/active distinction for `&mut` borrows in MIR borrowck"), - two_phase_beyond_autoref: bool = (false, parse_bool, [UNTRACKED], - "when using two-phase-borrows, allow two phases even for non-autoref `&mut` borrows"), time_passes: bool = (false, parse_bool, [UNTRACKED], "measure time of each rustc pass"), count_llvm_insns: bool = (false, parse_bool, @@ -1307,8 +1288,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, dep_info_omit_d_target: bool = (false, parse_bool, [TRACKED], "in dep-info output, omit targets for tracking dependencies of the dep-info files \ themselves"), - approximate_suggestions: bool = (false, parse_bool, [UNTRACKED], - "include machine-applicability of suggestions in JSON output"), unpretty: Option = (None, parse_unpretty, [UNTRACKED], "Present the input source, unstable (and less-pretty) variants; valid types are any of the types for `--pretty`, as well as: @@ -1316,10 +1295,6 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options, `everybody_loops` (all function bodies replaced with `loop {}`), `hir` (the HIR), `hir,identified`, or `hir,typed` (HIR with types for each node)."), - epoch: Epoch = (Epoch::Epoch2015, parse_epoch, [TRACKED], - "The epoch to build Rust with. Newer epochs may include features - that require breaking changes. The default epoch is 2015 (the first - epoch). Crates compiled with different epochs can be linked together."), } pub fn default_lib_output() -> CrateType { @@ -2111,7 +2086,7 @@ mod dep_tracking { use std::path::PathBuf; use std::collections::hash_map::DefaultHasher; use super::{Passes, CrateType, OptLevel, DebugInfoLevel, Lto, - OutputTypes, Externs, ErrorOutputType, Sanitizer, Epoch}; + OutputTypes, Externs, ErrorOutputType, Sanitizer}; use syntax::feature_gate::UnstableFeatures; use rustc_back::{PanicStrategy, RelroLevel}; @@ -2173,7 +2148,6 @@ mod dep_tracking { impl_dep_tracking_hash_via_hash!(cstore::NativeLibraryKind); impl_dep_tracking_hash_via_hash!(Sanitizer); impl_dep_tracking_hash_via_hash!(Option); - impl_dep_tracking_hash_via_hash!(Epoch); impl_dep_tracking_hash_for_sortable_vec_of!(String); impl_dep_tracking_hash_for_sortable_vec_of!(PathBuf); diff --git a/src/librustc/session/mod.rs b/src/librustc/session/mod.rs index 9d7a9acc3d533..2765239d5e649 100644 --- a/src/librustc/session/mod.rs +++ b/src/librustc/session/mod.rs @@ -19,7 +19,7 @@ use lint; use middle::allocator::AllocatorKind; use middle::dependency_format; use session::search_paths::PathKind; -use session::config::{BorrowckMode, DebugInfoLevel, OutputType, Epoch}; +use session::config::{BorrowckMode, DebugInfoLevel, OutputType}; use ty::tls; use util::nodemap::{FxHashMap, FxHashSet}; use util::common::{duration_to_secs_str, ErrorReported}; @@ -864,11 +864,6 @@ impl Session { pub fn teach(&self, code: &DiagnosticId) -> bool { self.opts.debugging_opts.teach && !self.parse_sess.span_diagnostic.code_emitted(code) } - - /// Are we allowed to use features from the Rust 2018 epoch? - pub fn rust_2018(&self) -> bool { - self.opts.debugging_opts.epoch >= Epoch::Epoch2018 - } } pub fn build_session(sopts: config::Options, @@ -909,27 +904,22 @@ pub fn build_session_with_codemap(sopts: config::Options, let emitter: Box = match (sopts.error_format, emitter_dest) { (config::ErrorOutputType::HumanReadable(color_config), None) => { - Box::new(EmitterWriter::stderr(color_config, - Some(codemap.clone()), - false, - sopts.debugging_opts.teach)) + Box::new(EmitterWriter::stderr(color_config, Some(codemap.clone()), false)) } (config::ErrorOutputType::HumanReadable(_), Some(dst)) => { - Box::new(EmitterWriter::new(dst, Some(codemap.clone()), false, false)) + Box::new(EmitterWriter::new(dst, Some(codemap.clone()), false)) } (config::ErrorOutputType::Json(pretty), None) => { - Box::new(JsonEmitter::stderr(Some(registry), codemap.clone(), - pretty, sopts.debugging_opts.approximate_suggestions)) + Box::new(JsonEmitter::stderr(Some(registry), codemap.clone(), pretty)) } (config::ErrorOutputType::Json(pretty), Some(dst)) => { - Box::new(JsonEmitter::new(dst, Some(registry), codemap.clone(), - pretty, sopts.debugging_opts.approximate_suggestions)) + Box::new(JsonEmitter::new(dst, Some(registry), codemap.clone(), pretty)) } (config::ErrorOutputType::Short(color_config), None) => { - Box::new(EmitterWriter::stderr(color_config, Some(codemap.clone()), true, false)) + Box::new(EmitterWriter::stderr(color_config, Some(codemap.clone()), true)) } (config::ErrorOutputType::Short(_), Some(dst)) => { - Box::new(EmitterWriter::new(dst, Some(codemap.clone()), true, false)) + Box::new(EmitterWriter::new(dst, Some(codemap.clone()), true)) } }; @@ -1105,11 +1095,11 @@ pub enum IncrCompSession { pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! { let emitter: Box = match output { config::ErrorOutputType::HumanReadable(color_config) => { - Box::new(EmitterWriter::stderr(color_config, None, false, false)) + Box::new(EmitterWriter::stderr(color_config, None, false)) } config::ErrorOutputType::Json(pretty) => Box::new(JsonEmitter::basic(pretty)), config::ErrorOutputType::Short(color_config) => { - Box::new(EmitterWriter::stderr(color_config, None, true, false)) + Box::new(EmitterWriter::stderr(color_config, None, true)) } }; let handler = errors::Handler::with_emitter(true, false, emitter); @@ -1120,11 +1110,11 @@ pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! { pub fn early_warn(output: config::ErrorOutputType, msg: &str) { let emitter: Box = match output { config::ErrorOutputType::HumanReadable(color_config) => { - Box::new(EmitterWriter::stderr(color_config, None, false, false)) + Box::new(EmitterWriter::stderr(color_config, None, false)) } config::ErrorOutputType::Json(pretty) => Box::new(JsonEmitter::basic(pretty)), config::ErrorOutputType::Short(color_config) => { - Box::new(EmitterWriter::stderr(color_config, None, true, false)) + Box::new(EmitterWriter::stderr(color_config, None, true)) } }; let handler = errors::Handler::with_emitter(true, false, emitter); diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index 9de18612d816c..ae68e3fe8d01f 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -19,7 +19,7 @@ use ty::{self, Ty, TyCtxt}; use ty::fold::TypeFoldable; use ty::subst::Subst; -use infer::{InferOk}; +use infer::{InferCtxt, InferOk}; /// Whether we do the orphan check relative to this crate or /// to some remote crate. @@ -40,20 +40,13 @@ pub struct OverlapResult<'tcx> { pub intercrate_ambiguity_causes: Vec, } -/// If there are types that satisfy both impls, invokes `on_overlap` -/// with a suitably-freshened `ImplHeader` with those types -/// substituted. Otherwise, invokes `no_overlap`. -pub fn overlapping_impls<'gcx, F1, F2, R>( - tcx: TyCtxt<'_, 'gcx, 'gcx>, - impl1_def_id: DefId, - impl2_def_id: DefId, - intercrate_mode: IntercrateMode, - on_overlap: F1, - no_overlap: F2, -) -> R -where - F1: FnOnce(OverlapResult<'_>) -> R, - F2: FnOnce() -> R, +/// If there are types that satisfy both impls, returns a suitably-freshened +/// `ImplHeader` with those types substituted +pub fn overlapping_impls<'cx, 'gcx, 'tcx>(infcx: &InferCtxt<'cx, 'gcx, 'tcx>, + impl1_def_id: DefId, + impl2_def_id: DefId, + intercrate_mode: IntercrateMode) + -> Option> { debug!("impl_can_satisfy(\ impl1_def_id={:?}, \ @@ -63,23 +56,8 @@ where impl2_def_id, intercrate_mode); - let overlaps = tcx.infer_ctxt().enter(|infcx| { - let selcx = &mut SelectionContext::intercrate(&infcx, intercrate_mode); - overlap(selcx, impl1_def_id, impl2_def_id).is_some() - }); - - if !overlaps { - return no_overlap(); - } - - // In the case where we detect an error, run the check again, but - // this time tracking intercrate ambuiguity causes for better - // diagnostics. (These take time and can lead to false errors.) - tcx.infer_ctxt().enter(|infcx| { - let selcx = &mut SelectionContext::intercrate(&infcx, intercrate_mode); - selcx.enable_tracking_intercrate_ambiguity_causes(); - on_overlap(overlap(selcx, impl1_def_id, impl2_def_id).unwrap()) - }) + let selcx = &mut SelectionContext::intercrate(infcx, intercrate_mode); + overlap(selcx, impl1_def_id, impl2_def_id) } fn with_fresh_ty_vars<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, @@ -157,10 +135,10 @@ fn overlap<'cx, 'gcx, 'tcx>(selcx: &mut SelectionContext<'cx, 'gcx, 'tcx>, return None } - let impl_header = selcx.infcx().resolve_type_vars_if_possible(&a_impl_header); - let intercrate_ambiguity_causes = selcx.take_intercrate_ambiguity_causes(); - debug!("overlap: intercrate_ambiguity_causes={:#?}", intercrate_ambiguity_causes); - Some(OverlapResult { impl_header, intercrate_ambiguity_causes }) + Some(OverlapResult { + impl_header: selcx.infcx().resolve_type_vars_if_possible(&a_impl_header), + intercrate_ambiguity_causes: selcx.intercrate_ambiguity_causes().to_vec(), + }) } pub fn trait_ref_is_knowable<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 214d8ec325f2b..42200a3a44728 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -348,7 +348,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { if direct { // this is a "direct", user-specified, rather than derived, // obligation. - flags.push(("direct".to_string(), None)); + flags.push(("direct", None)); } if let ObligationCauseCode::ItemObligation(item) = obligation.cause.code { @@ -359,37 +359,21 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { // Currently I'm leaving it for what I need for `try`. if self.tcx.trait_of_item(item) == Some(trait_ref.def_id) { method = self.tcx.item_name(item); - flags.push(("from_method".to_string(), None)); - flags.push(("from_method".to_string(), Some(method.to_string()))); + flags.push(("from_method", None)); + flags.push(("from_method", Some(&*method))); } } if let Some(k) = obligation.cause.span.compiler_desugaring_kind() { desugaring = k.as_symbol().as_str(); - flags.push(("from_desugaring".to_string(), None)); - flags.push(("from_desugaring".to_string(), Some(desugaring.to_string()))); - } - let generics = self.tcx.generics_of(def_id); - let self_ty = trait_ref.self_ty(); - let self_ty_str = self_ty.to_string(); - flags.push(("_Self".to_string(), Some(self_ty_str.clone()))); - - for param in generics.types.iter() { - let name = param.name.as_str().to_string(); - let ty = trait_ref.substs.type_for_def(param); - let ty_str = ty.to_string(); - flags.push((name.clone(), - Some(ty_str.clone()))); - } - - if let Some(true) = self_ty.ty_to_def_id().map(|def_id| def_id.is_local()) { - flags.push(("crate_local".to_string(), None)); + flags.push(("from_desugaring", None)); + flags.push(("from_desugaring", Some(&*desugaring))); } if let Ok(Some(command)) = OnUnimplementedDirective::of_item( self.tcx, trait_ref.def_id, def_id ) { - command.evaluate(self.tcx, trait_ref, &flags[..]) + command.evaluate(self.tcx, trait_ref, &flags) } else { OnUnimplementedNote::empty() } @@ -565,7 +549,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { .map(|t| (format!(" in `{}`", t), format!("within `{}`, ", t))) .unwrap_or((String::new(), String::new())); - let OnUnimplementedNote { message, label, note } + let OnUnimplementedNote { message, label } = self.on_unimplemented_note(trait_ref, obligation); let have_alt_message = message.is_some() || label.is_some(); @@ -594,10 +578,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { trait_ref, trait_ref.self_ty())); } - if let Some(ref s) = note { - // If it has a custom "#[rustc_on_unimplemented]" note, let's display it - err.note(s.as_str()); - } self.suggest_borrow_on_unsized_slice(&obligation.cause.code, &mut err); @@ -764,10 +744,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } else { let (closure_span, found) = found_did .and_then(|did| self.tcx.hir.get_if_local(did)) - .map(|node| { - let (found_span, found) = self.get_fn_like_arguments(node); - (Some(found_span), found) - }).unwrap_or((found_span, found)); + .map(|node| self.get_fn_like_arguments(node)) + .unwrap_or((found_span.unwrap(), found)); self.report_arg_count_mismatch(span, closure_span, @@ -853,11 +831,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { span, node: hir::ImplItemKind::Method(hir::MethodSig { ref decl, .. }, _), .. - }) | - hir::map::NodeTraitItem(&hir::TraitItem { - span, - node: hir::TraitItemKind::Method(hir::MethodSig { ref decl, .. }, _), - .. }) => { (self.tcx.sess.codemap().def_span(span), decl.inputs.iter() .map(|arg| match arg.clone().into_inner().node { @@ -877,7 +850,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { fn report_arg_count_mismatch( &self, span: Span, - found_span: Option, + found_span: Span, expected_args: Vec, found_args: Vec, is_closure: bool, @@ -915,51 +888,48 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { ); err.span_label(span, format!( "expected {} that takes {}", kind, expected_str)); - - if let Some(found_span) = found_span { - err.span_label(found_span, format!("takes {}", found_str)); - - if let &[ArgKind::Tuple(_, ref fields)] = &found_args[..] { - if fields.len() == expected_args.len() { - let sugg = fields.iter() - .map(|(name, _)| name.to_owned()) - .collect::>().join(", "); - err.span_suggestion(found_span, - "change the closure to take multiple arguments instead of \ - a single tuple", - format!("|{}|", sugg)); - } + err.span_label(found_span, format!("takes {}", found_str)); + + if let &[ArgKind::Tuple(_, ref fields)] = &found_args[..] { + if fields.len() == expected_args.len() { + let sugg = fields.iter() + .map(|(name, _)| name.to_owned()) + .collect::>().join(", "); + err.span_suggestion(found_span, + "change the closure to take multiple arguments instead of \ + a single tuple", + format!("|{}|", sugg)); } - if let &[ArgKind::Tuple(_, ref fields)] = &expected_args[..] { - if fields.len() == found_args.len() && is_closure { - let sugg = format!( - "|({}){}|", - found_args.iter() - .map(|arg| match arg { - ArgKind::Arg(name, _) => name.to_owned(), - _ => "_".to_owned(), - }) - .collect::>() - .join(", "), - // add type annotations if available - if found_args.iter().any(|arg| match arg { - ArgKind::Arg(_, ty) => ty != "_", - _ => false, - }) { - format!(": ({})", - fields.iter() - .map(|(_, ty)| ty.to_owned()) - .collect::>() - .join(", ")) - } else { - "".to_owned() - }, - ); - err.span_suggestion(found_span, - "change the closure to accept a tuple instead of \ - individual arguments", - sugg); - } + } + if let &[ArgKind::Tuple(_, ref fields)] = &expected_args[..] { + if fields.len() == found_args.len() && is_closure { + let sugg = format!( + "|({}){}|", + found_args.iter() + .map(|arg| match arg { + ArgKind::Arg(name, _) => name.to_owned(), + _ => "_".to_owned(), + }) + .collect::>() + .join(", "), + // add type annotations if available + if found_args.iter().any(|arg| match arg { + ArgKind::Arg(_, ty) => ty != "_", + _ => false, + }) { + format!(": ({})", + fields.iter() + .map(|(_, ty)| ty.to_owned()) + .collect::>() + .join(", ")) + } else { + "".to_owned() + }, + ); + err.span_suggestion(found_span, + "change the closure to accept a tuple instead of individual \ + arguments", + sugg); } } @@ -1224,15 +1194,13 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { { self.note_obligation_cause_code(err, &obligation.predicate, - &obligation.cause.code, - &mut vec![]); + &obligation.cause.code); } fn note_obligation_cause_code(&self, err: &mut DiagnosticBuilder, predicate: &T, - cause_code: &ObligationCauseCode<'tcx>, - obligated_types: &mut Vec<&ty::TyS<'tcx>>) + cause_code: &ObligationCauseCode<'tcx>) where T: fmt::Display { let tcx = self.tcx; @@ -1293,10 +1261,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { err.note("the return type of a function must have a \ statically known size"); } - ObligationCauseCode::SizedYieldType => { - err.note("the yield type of a generator must have a \ - statically known size"); - } ObligationCauseCode::AssignmentLhsSized => { err.note("the left-hand-side of an assignment must have a statically known size"); } @@ -1328,17 +1292,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { } ObligationCauseCode::BuiltinDerivedObligation(ref data) => { let parent_trait_ref = self.resolve_type_vars_if_possible(&data.parent_trait_ref); - let ty = parent_trait_ref.0.self_ty(); - err.note(&format!("required because it appears within the type `{}`", ty)); - obligated_types.push(ty); - + err.note(&format!("required because it appears within the type `{}`", + parent_trait_ref.0.self_ty())); let parent_predicate = parent_trait_ref.to_predicate(); - if !self.is_recursive_obligation(obligated_types, &data.parent_code) { - self.note_obligation_cause_code(err, - &parent_predicate, - &data.parent_code, - obligated_types); - } + self.note_obligation_cause_code(err, + &parent_predicate, + &data.parent_code); } ObligationCauseCode::ImplDerivedObligation(ref data) => { let parent_trait_ref = self.resolve_type_vars_if_possible(&data.parent_trait_ref); @@ -1348,9 +1307,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { parent_trait_ref.0.self_ty())); let parent_predicate = parent_trait_ref.to_predicate(); self.note_obligation_cause_code(err, - &parent_predicate, - &data.parent_code, - obligated_types); + &parent_predicate, + &data.parent_code); } ObligationCauseCode::CompareImplMethodObligation { .. } => { err.note( @@ -1369,20 +1327,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { err.help(&format!("consider adding a `#![recursion_limit=\"{}\"]` attribute to your crate", suggested_limit)); } - - fn is_recursive_obligation(&self, - obligated_types: &mut Vec<&ty::TyS<'tcx>>, - cause_code: &ObligationCauseCode<'tcx>) -> bool { - if let ObligationCauseCode::BuiltinDerivedObligation(ref data) = cause_code { - let parent_trait_ref = self.resolve_type_vars_if_possible(&data.parent_trait_ref); - for obligated_type in obligated_types { - if obligated_type == &parent_trait_ref.0.self_ty() { - return true; - } - } - } - return false; - } } enum ArgKind { diff --git a/src/librustc/traits/mod.rs b/src/librustc/traits/mod.rs index 80819a86b7c46..fd47e09aad7f9 100644 --- a/src/librustc/traits/mod.rs +++ b/src/librustc/traits/mod.rs @@ -100,19 +100,6 @@ pub struct ObligationCause<'tcx> { pub code: ObligationCauseCode<'tcx> } -impl<'tcx> ObligationCause<'tcx> { - pub fn span<'a, 'gcx>(&self, tcx: &TyCtxt<'a, 'gcx, 'tcx>) -> Span { - match self.code { - ObligationCauseCode::CompareImplMethodObligation { .. } | - ObligationCauseCode::MainFunctionType | - ObligationCauseCode::StartFunctionType => { - tcx.sess.codemap().def_span(self.span) - } - _ => self.span, - } - } -} - #[derive(Clone, Debug, PartialEq, Eq)] pub enum ObligationCauseCode<'tcx> { /// Not well classified or should be obvious from span. @@ -151,8 +138,6 @@ pub enum ObligationCauseCode<'tcx> { VariableType(ast::NodeId), /// Return type must be Sized SizedReturnType, - /// Yield type must be Sized - SizedYieldType, /// [T,..n] --> T must be Copy RepeatVec, diff --git a/src/librustc/traits/on_unimplemented.rs b/src/librustc/traits/on_unimplemented.rs index 8c2c1cfa45472..757b078086d9c 100644 --- a/src/librustc/traits/on_unimplemented.rs +++ b/src/librustc/traits/on_unimplemented.rs @@ -29,18 +29,16 @@ pub struct OnUnimplementedDirective { pub subcommands: Vec, pub message: Option, pub label: Option, - pub note: Option, } pub struct OnUnimplementedNote { pub message: Option, pub label: Option, - pub note: Option, } impl OnUnimplementedNote { pub fn empty() -> Self { - OnUnimplementedNote { message: None, label: None, note: None } + OnUnimplementedNote { message: None, label: None } } } @@ -91,7 +89,6 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { let mut message = None; let mut label = None; - let mut note = None; let mut subcommands = vec![]; for item in item_iter { if item.check_name("message") && message.is_none() { @@ -106,14 +103,8 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { tcx, trait_def_id, label_.as_str(), span)?); continue; } - } else if item.check_name("note") && note.is_none() { - if let Some(note_) = item.value_str() { - note = Some(OnUnimplementedFormatString::try_parse( - tcx, trait_def_id, note_.as_str(), span)?); - continue; - } } else if item.check_name("on") && is_root && - message.is_none() && label.is_none() && note.is_none() + message.is_none() && label.is_none() { if let Some(items) = item.meta_item_list() { if let Ok(subcommand) = @@ -137,7 +128,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { if errored { Err(ErrorReported) } else { - Ok(OnUnimplementedDirective { condition, message, label, subcommands, note }) + Ok(OnUnimplementedDirective { condition, message, label, subcommands }) } } @@ -163,8 +154,7 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { message: None, subcommands: vec![], label: Some(OnUnimplementedFormatString::try_parse( - tcx, trait_def_id, value.as_str(), attr.span)?), - note: None, + tcx, trait_def_id, value.as_str(), attr.span)?) })) } else { return Err(parse_error(tcx, attr.span, @@ -179,20 +169,20 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { pub fn evaluate(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>, trait_ref: ty::TraitRef<'tcx>, - options: &[(String, Option)]) + options: &[(&str, Option<&str>)]) -> OnUnimplementedNote { let mut message = None; let mut label = None; - let mut note = None; - info!("evaluate({:?}, trait_ref={:?}, options={:?})", self, trait_ref, options); + info!("evaluate({:?}, trait_ref={:?}, options={:?})", + self, trait_ref, options); for command in self.subcommands.iter().chain(Some(self)).rev() { if let Some(ref condition) = command.condition { if !attr::eval_condition(condition, &tcx.sess.parse_sess, &mut |c| { - options.contains(&(c.name().as_str().to_string(), - match c.value_str().map(|s| s.as_str().to_string()) { - Some(s) => Some(s), + options.contains(&(&c.name().as_str(), + match c.value_str().map(|s| s.as_str()) { + Some(ref s) => Some(s), None => None })) }) { @@ -208,16 +198,11 @@ impl<'a, 'gcx, 'tcx> OnUnimplementedDirective { if let Some(ref label_) = command.label { label = Some(label_.clone()); } - - if let Some(ref note_) = command.note { - note = Some(note_.clone()); - } } OnUnimplementedNote { label: label.map(|l| l.format(tcx, trait_ref)), - message: message.map(|m| m.format(tcx, trait_ref)), - note: note.map(|n| n.format(tcx, trait_ref)), + message: message.map(|m| m.format(tcx, trait_ref)) } } } diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 4ed25646d436d..55cbc890e1e91 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -92,10 +92,10 @@ pub struct SelectionContext<'cx, 'gcx: 'cx+'tcx, 'tcx: 'cx> { inferred_obligations: SnapshotVec>, - intercrate_ambiguity_causes: Option>, + intercrate_ambiguity_causes: Vec, } -#[derive(Clone, Debug)] +#[derive(Clone)] pub enum IntercrateAmbiguityCause { DownstreamCrate { trait_desc: String, @@ -423,7 +423,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { freshener: infcx.freshener(), intercrate: None, inferred_obligations: SnapshotVec::new(), - intercrate_ambiguity_causes: None, + intercrate_ambiguity_causes: Vec::new(), } } @@ -435,30 +435,10 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { freshener: infcx.freshener(), intercrate: Some(mode), inferred_obligations: SnapshotVec::new(), - intercrate_ambiguity_causes: None, + intercrate_ambiguity_causes: Vec::new(), } } - /// Enables tracking of intercrate ambiguity causes. These are - /// used in coherence to give improved diagnostics. We don't do - /// this until we detect a coherence error because it can lead to - /// false overflow results (#47139) and because it costs - /// computation time. - pub fn enable_tracking_intercrate_ambiguity_causes(&mut self) { - assert!(self.intercrate.is_some()); - assert!(self.intercrate_ambiguity_causes.is_none()); - self.intercrate_ambiguity_causes = Some(vec![]); - debug!("selcx: enable_tracking_intercrate_ambiguity_causes"); - } - - /// Gets the intercrate ambiguity causes collected since tracking - /// was enabled and disables tracking at the same time. If - /// tracking is not enabled, just returns an empty vector. - pub fn take_intercrate_ambiguity_causes(&mut self) -> Vec { - assert!(self.intercrate.is_some()); - self.intercrate_ambiguity_causes.take().unwrap_or(vec![]) - } - pub fn infcx(&self) -> &'cx InferCtxt<'cx, 'gcx, 'tcx> { self.infcx } @@ -471,6 +451,10 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { self.infcx } + pub fn intercrate_ambiguity_causes(&self) -> &[IntercrateAmbiguityCause] { + &self.intercrate_ambiguity_causes + } + /// Wraps the inference context's in_snapshot s.t. snapshot handling is only from the selection /// context's self. fn in_snapshot(&mut self, f: F) -> R @@ -844,23 +828,19 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { debug!("evaluate_stack({:?}) --> unbound argument, intercrate --> ambiguous", stack.fresh_trait_ref); // Heuristics: show the diagnostics when there are no candidates in crate. - if self.intercrate_ambiguity_causes.is_some() { - debug!("evaluate_stack: intercrate_ambiguity_causes is some"); - if let Ok(candidate_set) = self.assemble_candidates(stack) { - if !candidate_set.ambiguous && candidate_set.vec.is_empty() { - let trait_ref = stack.obligation.predicate.skip_binder().trait_ref; - let self_ty = trait_ref.self_ty(); - let cause = IntercrateAmbiguityCause::DownstreamCrate { - trait_desc: trait_ref.to_string(), - self_desc: if self_ty.has_concrete_skeleton() { - Some(self_ty.to_string()) - } else { - None - }, - }; - debug!("evaluate_stack: pushing cause = {:?}", cause); - self.intercrate_ambiguity_causes.as_mut().unwrap().push(cause); - } + if let Ok(candidate_set) = self.assemble_candidates(stack) { + if !candidate_set.ambiguous && candidate_set.vec.is_empty() { + let trait_ref = stack.obligation.predicate.skip_binder().trait_ref; + let self_ty = trait_ref.self_ty(); + let cause = IntercrateAmbiguityCause::DownstreamCrate { + trait_desc: trait_ref.to_string(), + self_desc: if self_ty.has_concrete_skeleton() { + Some(self_ty.to_string()) + } else { + None + }, + }; + self.intercrate_ambiguity_causes.push(cause); } } return EvaluatedToAmbig; @@ -1112,29 +1092,25 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { None => {} Some(conflict) => { debug!("coherence stage: not knowable"); - if self.intercrate_ambiguity_causes.is_some() { - debug!("evaluate_stack: intercrate_ambiguity_causes is some"); - // Heuristics: show the diagnostics when there are no candidates in crate. - let candidate_set = self.assemble_candidates(stack)?; - if !candidate_set.ambiguous && candidate_set.vec.iter().all(|c| { - !self.evaluate_candidate(stack, &c).may_apply() - }) { - let trait_ref = stack.obligation.predicate.skip_binder().trait_ref; - let self_ty = trait_ref.self_ty(); - let trait_desc = trait_ref.to_string(); - let self_desc = if self_ty.has_concrete_skeleton() { - Some(self_ty.to_string()) - } else { - None - }; - let cause = if let Conflict::Upstream = conflict { - IntercrateAmbiguityCause::UpstreamCrateUpdate { trait_desc, self_desc } - } else { - IntercrateAmbiguityCause::DownstreamCrate { trait_desc, self_desc } - }; - debug!("evaluate_stack: pushing cause = {:?}", cause); - self.intercrate_ambiguity_causes.as_mut().unwrap().push(cause); - } + // Heuristics: show the diagnostics when there are no candidates in crate. + let candidate_set = self.assemble_candidates(stack)?; + if !candidate_set.ambiguous && candidate_set.vec.iter().all(|c| { + !self.evaluate_candidate(stack, &c).may_apply() + }) { + let trait_ref = stack.obligation.predicate.skip_binder().trait_ref; + let self_ty = trait_ref.self_ty(); + let trait_desc = trait_ref.to_string(); + let self_desc = if self_ty.has_concrete_skeleton() { + Some(self_ty.to_string()) + } else { + None + }; + let cause = if let Conflict::Upstream = conflict { + IntercrateAmbiguityCause::UpstreamCrateUpdate { trait_desc, self_desc } + } else { + IntercrateAmbiguityCause::DownstreamCrate { trait_desc, self_desc } + }; + self.intercrate_ambiguity_causes.push(cause); } return Ok(None); } diff --git a/src/librustc/traits/specialize/specialization_graph.rs b/src/librustc/traits/specialize/specialization_graph.rs index a10169e13e60a..834389e5d009c 100644 --- a/src/librustc/traits/specialize/specialization_graph.rs +++ b/src/librustc/traits/specialize/specialization_graph.rs @@ -133,12 +133,12 @@ impl<'a, 'gcx, 'tcx> Children { }; let tcx = tcx.global_tcx(); - let (le, ge) = traits::overlapping_impls( - tcx, - possible_sibling, - impl_def_id, - traits::IntercrateMode::Issue43355, - |overlap| { + let (le, ge) = tcx.infer_ctxt().enter(|infcx| { + let overlap = traits::overlapping_impls(&infcx, + possible_sibling, + impl_def_id, + traits::IntercrateMode::Issue43355); + if let Some(overlap) = overlap { if tcx.impls_are_allowed_to_overlap(impl_def_id, possible_sibling) { return Ok((false, false)); } @@ -151,9 +151,10 @@ impl<'a, 'gcx, 'tcx> Children { } else { Ok((le, ge)) } - }, - || Ok((false, false)), - )?; + } else { + Ok((false, false)) + } + })?; if le && !ge { debug!("descending as child of TraitRef {:?}", @@ -170,14 +171,16 @@ impl<'a, 'gcx, 'tcx> Children { return Ok(Inserted::Replaced(possible_sibling)); } else { if !tcx.impls_are_allowed_to_overlap(impl_def_id, possible_sibling) { - traits::overlapping_impls( - tcx, - possible_sibling, - impl_def_id, - traits::IntercrateMode::Fixed, - |overlap| last_lint = Some(overlap_error(overlap)), - || (), - ); + tcx.infer_ctxt().enter(|infcx| { + if let Some(overlap) = traits::overlapping_impls( + &infcx, + possible_sibling, + impl_def_id, + traits::IntercrateMode::Fixed) + { + last_lint = Some(overlap_error(overlap)); + } + }); } // no overlap (error bailed already via ?) diff --git a/src/librustc/traits/structural_impls.rs b/src/librustc/traits/structural_impls.rs index 1eb14a222787d..e1e2798ecb51c 100644 --- a/src/librustc/traits/structural_impls.rs +++ b/src/librustc/traits/structural_impls.rs @@ -209,7 +209,6 @@ impl<'a, 'tcx> Lift<'tcx> for traits::ObligationCauseCode<'a> { super::VariableType(id) => Some(super::VariableType(id)), super::ReturnType(id) => Some(super::ReturnType(id)), super::SizedReturnType => Some(super::SizedReturnType), - super::SizedYieldType => Some(super::SizedYieldType), super::RepeatVec => Some(super::RepeatVec), super::FieldSized(item) => Some(super::FieldSized(item)), super::ConstSized => Some(super::ConstSized), @@ -527,7 +526,6 @@ impl<'tcx> TypeFoldable<'tcx> for traits::ObligationCauseCode<'tcx> { super::VariableType(_) | super::ReturnType(_) | super::SizedReturnType | - super::SizedYieldType | super::ReturnNoExpression | super::RepeatVec | super::FieldSized(_) | @@ -576,7 +574,6 @@ impl<'tcx> TypeFoldable<'tcx> for traits::ObligationCauseCode<'tcx> { super::VariableType(_) | super::ReturnType(_) | super::SizedReturnType | - super::SizedYieldType | super::ReturnNoExpression | super::RepeatVec | super::FieldSized(_) | diff --git a/src/librustc/ty/adjustment.rs b/src/librustc/ty/adjustment.rs index 7579d95a8fe68..96d69b4fba21a 100644 --- a/src/librustc/ty/adjustment.rs +++ b/src/librustc/ty/adjustment.rs @@ -119,25 +119,10 @@ impl<'a, 'gcx, 'tcx> OverloadedDeref<'tcx> { } } -#[derive(Copy, Clone, PartialEq, Debug, RustcEncodable, RustcDecodable)] -pub enum AutoBorrowMutability { - Mutable { allow_two_phase_borrow: bool }, - Immutable, -} - -impl From for hir::Mutability { - fn from(m: AutoBorrowMutability) -> Self { - match m { - AutoBorrowMutability::Mutable { .. } => hir::MutMutable, - AutoBorrowMutability::Immutable => hir::MutImmutable, - } - } -} - #[derive(Copy, Clone, PartialEq, Debug, RustcEncodable, RustcDecodable)] pub enum AutoBorrow<'tcx> { /// Convert from T to &T. - Ref(ty::Region<'tcx>, AutoBorrowMutability), + Ref(ty::Region<'tcx>, hir::Mutability), /// Convert from T to *T. RawPtr(hir::Mutability), diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 63b91ff110161..69d07eafdca7a 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -895,8 +895,7 @@ fn layout_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } tcx.layout_depth.set(depth+1); - let cx = LayoutCx { tcx, param_env }; - let layout = cx.layout_raw_uncached(ty); + let layout = LayoutDetails::compute_uncached(tcx, param_env, ty); tcx.layout_depth.set(depth); layout @@ -909,18 +908,13 @@ pub fn provide(providers: &mut ty::maps::Providers) { }; } -#[derive(Copy, Clone)] -pub struct LayoutCx<'tcx, C> { - pub tcx: C, - pub param_env: ty::ParamEnv<'tcx> -} - -impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { - fn layout_raw_uncached(self, ty: Ty<'tcx>) - -> Result<&'tcx LayoutDetails, LayoutError<'tcx>> { - let tcx = self.tcx; - let param_env = self.param_env; - let dl = self.data_layout(); +impl<'a, 'tcx> LayoutDetails { + fn compute_uncached(tcx: TyCtxt<'a, 'tcx, 'tcx>, + param_env: ty::ParamEnv<'tcx>, + ty: Ty<'tcx>) + -> Result<&'tcx Self, LayoutError<'tcx>> { + let cx = (tcx, param_env); + let dl = cx.data_layout(); let scalar_unit = |value: Primitive| { let bits = value.size(dl).bits(); assert!(bits <= 128); @@ -930,7 +924,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { } }; let scalar = |value: Primitive| { - tcx.intern_layout(LayoutDetails::scalar(self, scalar_unit(value))) + tcx.intern_layout(LayoutDetails::scalar(cx, scalar_unit(value))) }; let scalar_pair = |a: Scalar, b: Scalar| { let align = a.value.align(dl).max(b.value.align(dl)).max(dl.aggregate_align); @@ -1164,13 +1158,13 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { Ok(match ty.sty { // Basic scalars. ty::TyBool => { - tcx.intern_layout(LayoutDetails::scalar(self, Scalar { + tcx.intern_layout(LayoutDetails::scalar(cx, Scalar { value: Int(I8, false), valid_range: 0..=1 })) } ty::TyChar => { - tcx.intern_layout(LayoutDetails::scalar(self, Scalar { + tcx.intern_layout(LayoutDetails::scalar(cx, Scalar { value: Int(I32, false), valid_range: 0..=0x10FFFF })) @@ -1186,7 +1180,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { ty::TyFnPtr(_) => { let mut ptr = scalar_unit(Pointer); ptr.valid_range.start = 1; - tcx.intern_layout(LayoutDetails::scalar(self, ptr)) + tcx.intern_layout(LayoutDetails::scalar(cx, ptr)) } // The never type. @@ -1204,13 +1198,13 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { let pointee = tcx.normalize_associated_type_in_env(&pointee, param_env); if pointee.is_sized(tcx, param_env, DUMMY_SP) { - return Ok(tcx.intern_layout(LayoutDetails::scalar(self, data_ptr))); + return Ok(tcx.intern_layout(LayoutDetails::scalar(cx, data_ptr))); } let unsized_part = tcx.struct_tail(pointee); let metadata = match unsized_part.sty { ty::TyForeign(..) => { - return Ok(tcx.intern_layout(LayoutDetails::scalar(self, data_ptr))); + return Ok(tcx.intern_layout(LayoutDetails::scalar(cx, data_ptr))); } ty::TySlice(_) | ty::TyStr => { scalar_unit(Int(dl.ptr_sized_integer(), false)) @@ -1236,7 +1230,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { } } - let element = self.layout_of(element)?; + let element = cx.layout_of(element)?; let count = count.val.to_const_int().unwrap().to_u64().unwrap(); let size = element.size.checked_mul(count, dl) .ok_or(LayoutError::SizeOverflow(ty))?; @@ -1253,7 +1247,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { }) } ty::TySlice(element) => { - let element = self.layout_of(element)?; + let element = cx.layout_of(element)?; tcx.intern_layout(LayoutDetails { variants: Variants::Single { index: 0 }, fields: FieldPlacement::Array { @@ -1295,14 +1289,14 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { // Tuples, generators and closures. ty::TyGenerator(def_id, ref substs, _) => { let tys = substs.field_tys(def_id, tcx); - univariant(&tys.map(|ty| self.layout_of(ty)).collect::, _>>()?, + univariant(&tys.map(|ty| cx.layout_of(ty)).collect::, _>>()?, &ReprOptions::default(), StructKind::AlwaysSized)? } ty::TyClosure(def_id, ref substs) => { let tys = substs.upvar_tys(def_id, tcx); - univariant(&tys.map(|ty| self.layout_of(ty)).collect::, _>>()?, + univariant(&tys.map(|ty| cx.layout_of(ty)).collect::, _>>()?, &ReprOptions::default(), StructKind::AlwaysSized)? } @@ -1314,13 +1308,13 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { StructKind::MaybeUnsized }; - univariant(&tys.iter().map(|ty| self.layout_of(ty)).collect::, _>>()?, + univariant(&tys.iter().map(|ty| cx.layout_of(ty)).collect::, _>>()?, &ReprOptions::default(), kind)? } // SIMD vector types. ty::TyAdt(def, ..) if def.repr.simd() => { - let element = self.layout_of(ty.simd_type(tcx))?; + let element = cx.layout_of(ty.simd_type(tcx))?; let count = ty.simd_size(tcx) as u64; assert!(count > 0); let scalar = match element.abi { @@ -1356,7 +1350,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { // Cache the field layouts. let variants = def.variants.iter().map(|v| { v.fields.iter().map(|field| { - self.layout_of(field.ty(tcx, substs)) + cx.layout_of(field.ty(tcx, substs)) }).collect::, _>>() }).collect::, _>>()?; @@ -1436,7 +1430,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { let mut st = univariant_uninterned(&variants[v], &def.repr, kind)?; st.variants = Variants::Single { index: v }; // Exclude 0 from the range of a newtype ABI NonZero. - if Some(def.did) == self.tcx.lang_items().non_zero() { + if Some(def.did) == cx.tcx().lang_items().non_zero() { match st.abi { Abi::Scalar(ref mut scalar) | Abi::ScalarPair(ref mut scalar, _) => { @@ -1488,7 +1482,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { let count = (niche_variants.end - niche_variants.start + 1) as u128; for (field_index, field) in variants[i].iter().enumerate() { let (offset, niche, niche_start) = - match field.find_niche(self, count)? { + match field.find_niche(cx, count)? { Some(niche) => niche, None => continue }; @@ -1693,49 +1687,56 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { /// This is invoked by the `layout_raw` query to record the final /// layout of each type. #[inline] - fn record_layout_for_printing(self, layout: TyLayout<'tcx>) { + fn record_layout_for_printing(tcx: TyCtxt<'a, 'tcx, 'tcx>, + ty: Ty<'tcx>, + param_env: ty::ParamEnv<'tcx>, + layout: TyLayout<'tcx>) { // If we are running with `-Zprint-type-sizes`, record layouts for // dumping later. Ignore layouts that are done with non-empty // environments or non-monomorphic layouts, as the user only wants // to see the stuff resulting from the final trans session. if - !self.tcx.sess.opts.debugging_opts.print_type_sizes || - layout.ty.has_param_types() || - layout.ty.has_self_ty() || - !self.param_env.caller_bounds.is_empty() + !tcx.sess.opts.debugging_opts.print_type_sizes || + ty.has_param_types() || + ty.has_self_ty() || + !param_env.caller_bounds.is_empty() { return; } - self.record_layout_for_printing_outlined(layout) + Self::record_layout_for_printing_outlined(tcx, ty, param_env, layout) } - fn record_layout_for_printing_outlined(self, layout: TyLayout<'tcx>) { + fn record_layout_for_printing_outlined(tcx: TyCtxt<'a, 'tcx, 'tcx>, + ty: Ty<'tcx>, + param_env: ty::ParamEnv<'tcx>, + layout: TyLayout<'tcx>) { + let cx = (tcx, param_env); // (delay format until we actually need it) let record = |kind, opt_discr_size, variants| { - let type_desc = format!("{:?}", layout.ty); - self.tcx.sess.code_stats.borrow_mut().record_type_size(kind, - type_desc, - layout.align, - layout.size, - opt_discr_size, - variants); + let type_desc = format!("{:?}", ty); + tcx.sess.code_stats.borrow_mut().record_type_size(kind, + type_desc, + layout.align, + layout.size, + opt_discr_size, + variants); }; - let adt_def = match layout.ty.sty { + let adt_def = match ty.sty { ty::TyAdt(ref adt_def, _) => { - debug!("print-type-size t: `{:?}` process adt", layout.ty); + debug!("print-type-size t: `{:?}` process adt", ty); adt_def } ty::TyClosure(..) => { - debug!("print-type-size t: `{:?}` record closure", layout.ty); + debug!("print-type-size t: `{:?}` record closure", ty); record(DataTypeKind::Closure, None, vec![]); return; } _ => { - debug!("print-type-size t: `{:?}` skip non-nominal", layout.ty); + debug!("print-type-size t: `{:?}` skip non-nominal", ty); return; } }; @@ -1747,7 +1748,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { layout: TyLayout<'tcx>| { let mut min_size = Size::from_bytes(0); let field_info: Vec<_> = flds.iter().enumerate().map(|(i, &name)| { - match layout.field(self, i) { + match layout.field(cx, i) { Err(err) => { bug!("no layout found for field {}: `{:?}`", name, err); } @@ -1807,18 +1808,18 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { Variants::NicheFilling { .. } | Variants::Tagged { .. } => { debug!("print-type-size `{:#?}` adt general variants def {}", - layout.ty, adt_def.variants.len()); + ty, adt_def.variants.len()); let variant_infos: Vec<_> = adt_def.variants.iter().enumerate().map(|(i, variant_def)| { let fields: Vec<_> = variant_def.fields.iter().map(|f| f.name).collect(); build_variant_info(Some(variant_def.name), &fields, - layout.for_variant(self, i)) + layout.for_variant(cx, i)) }) .collect(); record(adt_kind.into(), match layout.variants { - Variants::Tagged { ref discr, .. } => Some(discr.value.size(self)), + Variants::Tagged { ref discr, .. } => Some(discr.value.size(tcx)), _ => None }, variant_infos); } @@ -1854,7 +1855,7 @@ impl<'a, 'tcx> SizeSkeleton<'tcx> { assert!(!ty.has_infer_types()); // First try computing a static layout. - let err = match tcx.layout_of(param_env.and(ty)) { + let err = match (tcx, param_env).layout_of(ty) { Ok(layout) => { return Ok(SizeSkeleton::Known(layout.size)); } @@ -2000,15 +2001,15 @@ impl<'a, 'gcx, 'tcx> HasTyCtxt<'gcx> for TyCtxt<'a, 'gcx, 'tcx> { } } -impl<'tcx, T: HasDataLayout> HasDataLayout for LayoutCx<'tcx, T> { +impl<'a, 'gcx, 'tcx, T: Copy> HasDataLayout for (TyCtxt<'a, 'gcx, 'tcx>, T) { fn data_layout(&self) -> &TargetDataLayout { - self.tcx.data_layout() + self.0.data_layout() } } -impl<'gcx, 'tcx, T: HasTyCtxt<'gcx>> HasTyCtxt<'gcx> for LayoutCx<'tcx, T> { +impl<'a, 'gcx, 'tcx, T: Copy> HasTyCtxt<'gcx> for (TyCtxt<'a, 'gcx, 'tcx>, T) { fn tcx<'b>(&'b self) -> TyCtxt<'b, 'gcx, 'gcx> { - self.tcx.tcx() + self.0.tcx() } } @@ -2041,15 +2042,17 @@ pub trait LayoutOf { fn layout_of(self, ty: T) -> Self::TyLayout; } -impl<'a, 'tcx> LayoutOf> for LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { +impl<'a, 'tcx> LayoutOf> for (TyCtxt<'a, 'tcx, 'tcx>, ty::ParamEnv<'tcx>) { type TyLayout = Result, LayoutError<'tcx>>; /// Computes the layout of a type. Note that this implicitly /// executes in "reveal all" mode. + #[inline] fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout { - let param_env = self.param_env.reveal_all(); - let ty = self.tcx.normalize_associated_type_in_env(&ty, param_env); - let details = self.tcx.layout_raw(param_env.and(ty))?; + let (tcx, param_env) = self; + + let ty = tcx.normalize_associated_type_in_env(&ty, param_env.reveal_all()); + let details = tcx.layout_raw(param_env.reveal_all().and(ty))?; let layout = TyLayout { ty, details @@ -2061,21 +2064,24 @@ impl<'a, 'tcx> LayoutOf> for LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> { // completed, to avoid problems around recursive structures // and the like. (Admitedly, I wasn't able to reproduce a problem // here, but it seems like the right thing to do. -nmatsakis) - self.record_layout_for_printing(layout); + LayoutDetails::record_layout_for_printing(tcx, ty, param_env, layout); Ok(layout) } } -impl<'a, 'tcx> LayoutOf> for LayoutCx<'tcx, ty::maps::TyCtxtAt<'a, 'tcx, 'tcx>> { +impl<'a, 'tcx> LayoutOf> for (ty::maps::TyCtxtAt<'a, 'tcx, 'tcx>, + ty::ParamEnv<'tcx>) { type TyLayout = Result, LayoutError<'tcx>>; /// Computes the layout of a type. Note that this implicitly /// executes in "reveal all" mode. + #[inline] fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout { - let param_env = self.param_env.reveal_all(); - let ty = self.tcx.normalize_associated_type_in_env(&ty, param_env.reveal_all()); - let details = self.tcx.layout_raw(param_env.reveal_all().and(ty))?; + let (tcx_at, param_env) = self; + + let ty = tcx_at.tcx.normalize_associated_type_in_env(&ty, param_env.reveal_all()); + let details = tcx_at.layout_raw(param_env.reveal_all().and(ty))?; let layout = TyLayout { ty, details @@ -2087,45 +2093,12 @@ impl<'a, 'tcx> LayoutOf> for LayoutCx<'tcx, ty::maps::TyCtxtAt<'a, 'tcx // completed, to avoid problems around recursive structures // and the like. (Admitedly, I wasn't able to reproduce a problem // here, but it seems like the right thing to do. -nmatsakis) - let cx = LayoutCx { - tcx: *self.tcx, - param_env: self.param_env - }; - cx.record_layout_for_printing(layout); + LayoutDetails::record_layout_for_printing(tcx_at.tcx, ty, param_env, layout); Ok(layout) } } -// Helper (inherent) `layout_of` methods to avoid pushing `LayoutCx` to users. -impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> { - /// Computes the layout of a type. Note that this implicitly - /// executes in "reveal all" mode. - #[inline] - pub fn layout_of(self, param_env_and_ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) - -> Result, LayoutError<'tcx>> { - let cx = LayoutCx { - tcx: self, - param_env: param_env_and_ty.param_env - }; - cx.layout_of(param_env_and_ty.value) - } -} - -impl<'a, 'tcx> ty::maps::TyCtxtAt<'a, 'tcx, 'tcx> { - /// Computes the layout of a type. Note that this implicitly - /// executes in "reveal all" mode. - #[inline] - pub fn layout_of(self, param_env_and_ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) - -> Result, LayoutError<'tcx>> { - let cx = LayoutCx { - tcx: self, - param_env: param_env_and_ty.param_env - }; - cx.layout_of(param_env_and_ty.value) - } -} - impl<'a, 'tcx> TyLayout<'tcx> { pub fn for_variant(&self, cx: C, variant_index: usize) -> Self where C: LayoutOf> + HasTyCtxt<'tcx>, diff --git a/src/librustc/ty/maps/mod.rs b/src/librustc/ty/maps/mod.rs index 85fca68187fe6..6c79f6a62fa0b 100644 --- a/src/librustc/ty/maps/mod.rs +++ b/src/librustc/ty/maps/mod.rs @@ -343,7 +343,6 @@ define_maps! { <'tcx> -> (Arc, Arc>>>), [] fn export_name: ExportName(DefId) -> Option, [] fn contains_extern_indicator: ContainsExternIndicator(DefId) -> bool, - [] fn symbol_export_level: GetSymbolExportLevel(DefId) -> SymbolExportLevel, [] fn is_translated_function: IsTranslatedFunction(DefId) -> bool, [] fn codegen_unit: CodegenUnit(InternedString) -> Arc>, [] fn compile_codegen_unit: CompileCodegenUnit(InternedString) -> Stats, diff --git a/src/librustc/ty/maps/plumbing.rs b/src/librustc/ty/maps/plumbing.rs index 0ab6ee1a54a9b..c9eebc3d2a0a7 100644 --- a/src/librustc/ty/maps/plumbing.rs +++ b/src/librustc/ty/maps/plumbing.rs @@ -921,8 +921,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>, DepKind::TargetFeaturesWhitelist => { force!(target_features_whitelist, LOCAL_CRATE); } DepKind::TargetFeaturesEnabled => { force!(target_features_enabled, def_id!()); } - - DepKind::GetSymbolExportLevel => { force!(symbol_export_level, def_id!()); } } true diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 1593b452cdffc..0c1ebd1a2ba2f 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -390,21 +390,14 @@ impl<'a, 'gcx, 'tcx> ClosureSubsts<'tcx> { state.map(move |d| d.ty.subst(tcx, self.substs)) } - /// This is the types of the fields of a generate which - /// is available before the generator transformation. - /// It includes the upvars and the state discriminant which is u32. - pub fn pre_transforms_tys(self, def_id: DefId, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> - impl Iterator> + 'a - { - self.upvar_tys(def_id, tcx).chain(iter::once(tcx.types.u32)) - } - /// This is the types of all the fields stored in a generator. /// It includes the upvars, state types and the state discriminant which is u32. pub fn field_tys(self, def_id: DefId, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> impl Iterator> + 'a { - self.pre_transforms_tys(def_id, tcx).chain(self.state_tys(def_id, tcx)) + let upvars = self.upvar_tys(def_id, tcx); + let state = self.state_tys(def_id, tcx); + upvars.chain(iter::once(tcx.types.u32)).chain(state) } } diff --git a/src/librustc/util/nodemap.rs b/src/librustc/util/nodemap.rs index f98a8f834df8a..674f67d5cd2f1 100644 --- a/src/librustc/util/nodemap.rs +++ b/src/librustc/util/nodemap.rs @@ -13,7 +13,7 @@ #![allow(non_snake_case)] use hir::def_id::DefId; -use hir::{HirId, ItemLocalId}; +use hir::ItemLocalId; use syntax::ast; pub use rustc_data_structures::fx::FxHashMap; @@ -21,12 +21,10 @@ pub use rustc_data_structures::fx::FxHashSet; pub type NodeMap = FxHashMap; pub type DefIdMap = FxHashMap; -pub type HirIdMap = FxHashMap; pub type ItemLocalMap = FxHashMap; pub type NodeSet = FxHashSet; pub type DefIdSet = FxHashSet; -pub type HirIdSet = FxHashSet; pub type ItemLocalSet = FxHashSet; pub fn NodeMap() -> NodeMap { FxHashMap() } diff --git a/src/librustc_back/target/mod.rs b/src/librustc_back/target/mod.rs index 2872c59157d6b..3c8a676dcc200 100644 --- a/src/librustc_back/target/mod.rs +++ b/src/librustc_back/target/mod.rs @@ -468,10 +468,6 @@ pub struct TargetOptions { /// The codegen backend to use for this target, typically "llvm" pub codegen_backend: String, - - /// The default visibility for symbols in this target should be "hidden" - /// rather than "default" - pub default_hidden_visibility: bool, } impl Default for TargetOptions { @@ -542,7 +538,6 @@ impl Default for TargetOptions { no_builtins: false, i128_lowering: false, codegen_backend: "llvm".to_string(), - default_hidden_visibility: false, } } } @@ -790,7 +785,6 @@ impl Target { key!(singlethread, bool); key!(no_builtins, bool); key!(codegen_backend); - key!(default_hidden_visibility, bool); if let Some(array) = obj.find("abi-blacklist").and_then(Json::as_array) { for name in array.iter().filter_map(|abi| abi.as_string()) { @@ -988,7 +982,6 @@ impl ToJson for Target { target_option_val!(singlethread); target_option_val!(no_builtins); target_option_val!(codegen_backend); - target_option_val!(default_hidden_visibility); if default.abi_blacklist != self.options.abi_blacklist { d.insert("abi-blacklist".to_string(), self.options.abi_blacklist.iter() diff --git a/src/librustc_back/target/msp430_none_elf.rs b/src/librustc_back/target/msp430_none_elf.rs index 966df897f01f1..509a7cf5e0323 100644 --- a/src/librustc_back/target/msp430_none_elf.rs +++ b/src/librustc_back/target/msp430_none_elf.rs @@ -53,12 +53,6 @@ pub fn target() -> TargetResult { // don't want to invoke that many gcc instances. default_codegen_units: Some(1), - // Since MSP430 doesn't meaningfully support faulting on illegal - // instructions, LLVM generates a call to abort() function instead - // of a trap instruction. Such calls are 4 bytes long, and that is - // too much overhead for such small target. - trap_unreachable: false, - .. Default::default( ) } }) diff --git a/src/librustc_back/target/wasm32_unknown_unknown.rs b/src/librustc_back/target/wasm32_unknown_unknown.rs index 242860e5c6e92..7e1011ab8af96 100644 --- a/src/librustc_back/target/wasm32_unknown_unknown.rs +++ b/src/librustc_back/target/wasm32_unknown_unknown.rs @@ -83,9 +83,6 @@ pub fn target() -> Result { // performing LTO with compiler-builtins. no_builtins: true, - // no dynamic linking, no need for default visibility! - default_hidden_visibility: true, - .. Default::default() }; Ok(Target { diff --git a/src/librustc_binaryen/BinaryenWrapper.cpp b/src/librustc_binaryen/BinaryenWrapper.cpp index 55f11665f6d0b..d1095a7819d4a 100644 --- a/src/librustc_binaryen/BinaryenWrapper.cpp +++ b/src/librustc_binaryen/BinaryenWrapper.cpp @@ -14,7 +14,6 @@ #include #include -#include #include #include "s2wasm.h" @@ -25,7 +24,6 @@ using namespace wasm; struct BinaryenRustModule { BufferWithRandomAccess buffer; - std::string sourceMapJSON; }; struct BinaryenRustModuleOptions { @@ -38,7 +36,6 @@ struct BinaryenRustModuleOptions { bool ignoreUnknownSymbols; bool debugInfo; std::string startFunction; - std::string sourceMapUrl; BinaryenRustModuleOptions() : globalBase(0), @@ -49,8 +46,7 @@ struct BinaryenRustModuleOptions { importMemory(false), ignoreUnknownSymbols(false), debugInfo(false), - startFunction(""), - sourceMapUrl("") + startFunction("") {} }; @@ -77,12 +73,6 @@ BinaryenRustModuleOptionsSetStart(BinaryenRustModuleOptions *options, options->startFunction = start; } -extern "C" void -BinaryenRustModuleOptionsSetSourceMapUrl(BinaryenRustModuleOptions *options, - char *sourceMapUrl) { - options->sourceMapUrl = sourceMapUrl; -} - extern "C" void BinaryenRustModuleOptionsSetStackAllocation(BinaryenRustModuleOptions *options, uint64_t stack) { @@ -116,20 +106,12 @@ BinaryenRustModuleCreate(const BinaryenRustModuleOptions *options, { WasmBinaryWriter writer(&linker.getOutput().wasm, ret->buffer, options->debug); writer.setNamesSection(options->debugInfo); - - std::unique_ptr sourceMapStream = nullptr; - { - sourceMapStream = make_unique(); - writer.setSourceMap(sourceMapStream.get(), options->sourceMapUrl); - } + // FIXME: support source maps? + // writer.setSourceMap(sourceMapStream.get(), sourceMapUrl); // FIXME: support symbol maps? // writer.setSymbolMap(symbolMap); writer.write(); - - if (sourceMapStream) { - ret->sourceMapJSON = sourceMapStream->str(); - } } return ret.release(); } @@ -144,16 +126,6 @@ BinaryenRustModuleLen(const BinaryenRustModule *M) { return M->buffer.size(); } -extern "C" const char* -BinaryenRustModuleSourceMapPtr(const BinaryenRustModule *M) { - return M->sourceMapJSON.data(); -} - -extern "C" size_t -BinaryenRustModuleSourceMapLen(const BinaryenRustModule *M) { - return M->sourceMapJSON.length(); -} - extern "C" void BinaryenRustModuleFree(BinaryenRustModule *M) { delete M; diff --git a/src/librustc_binaryen/lib.rs b/src/librustc_binaryen/lib.rs index 36174e11ba04a..6c7feb6a7a9d3 100644 --- a/src/librustc_binaryen/lib.rs +++ b/src/librustc_binaryen/lib.rs @@ -51,15 +51,6 @@ impl Module { slice::from_raw_parts(ptr, len) } } - - /// Returns the data of the source map JSON. - pub fn source_map(&self) -> &[u8] { - unsafe { - let ptr = BinaryenRustModuleSourceMapPtr(self.ptr); - let len = BinaryenRustModuleSourceMapLen(self.ptr); - slice::from_raw_parts(ptr, len) - } - } } impl Drop for Module { @@ -103,15 +94,6 @@ impl ModuleOptions { self } - /// Configures a `sourceMappingURL` custom section value for the module. - pub fn source_map_url(&mut self, url: &str) -> &mut Self { - let url = CString::new(url).unwrap(); - unsafe { - BinaryenRustModuleOptionsSetSourceMapUrl(self.ptr, url.as_ptr()); - } - self - } - /// Configures how much stack is initially allocated for the module. 1MB is /// probably good enough for now. pub fn stack(&mut self, amt: u64) -> &mut Self { @@ -148,8 +130,6 @@ extern { -> *mut BinaryenRustModule; fn BinaryenRustModulePtr(module: *const BinaryenRustModule) -> *const u8; fn BinaryenRustModuleLen(module: *const BinaryenRustModule) -> usize; - fn BinaryenRustModuleSourceMapPtr(module: *const BinaryenRustModule) -> *const u8; - fn BinaryenRustModuleSourceMapLen(module: *const BinaryenRustModule) -> usize; fn BinaryenRustModuleFree(module: *mut BinaryenRustModule); fn BinaryenRustModuleOptionsCreate() @@ -158,8 +138,6 @@ extern { debuginfo: bool); fn BinaryenRustModuleOptionsSetStart(module: *mut BinaryenRustModuleOptions, start: *const libc::c_char); - fn BinaryenRustModuleOptionsSetSourceMapUrl(module: *mut BinaryenRustModuleOptions, - sourceMapUrl: *const libc::c_char); fn BinaryenRustModuleOptionsSetStackAllocation( module: *mut BinaryenRustModuleOptions, stack: u64, diff --git a/src/librustc_borrowck/borrowck/mod.rs b/src/librustc_borrowck/borrowck/mod.rs index 738c0d82ee1b5..84ca2a9318ab3 100644 --- a/src/librustc_borrowck/borrowck/mod.rs +++ b/src/librustc_borrowck/borrowck/mod.rs @@ -1068,12 +1068,22 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { }; match cause { + mc::AliasableStatic => { + // This happens when we have an `&mut` or assignment to a + // static. We should have already reported a mutability + // violation first, but may have continued compiling. + self.tcx.sess.delay_span_bug( + span, + &format!("aliasability violation for static `{}`", prefix) + ); + return; + } mc::AliasableStaticMut => { // This path cannot occur. `static mut X` is not checked // for aliasability violations. span_bug!(span, "aliasability violation for static mut `{}`", prefix) } - mc::AliasableStatic | mc::AliasableBorrowed => {} + mc::AliasableBorrowed => {} }; let blame = cmt.immutability_blame(); let mut err = match blame { diff --git a/src/librustc_borrowck/borrowck/unused.rs b/src/librustc_borrowck/borrowck/unused.rs index 7bcd8a185453b..ddee122d0a6bd 100644 --- a/src/librustc_borrowck/borrowck/unused.rs +++ b/src/librustc_borrowck/borrowck/unused.rs @@ -77,7 +77,7 @@ impl<'a, 'tcx> UnusedMutCx<'a, 'tcx> { continue } - let mut_span = tcx.sess.codemap().span_until_non_whitespace(ids[0].2); + let mut_span = tcx.sess.codemap().span_until_char(ids[0].2, ' '); // Ok, every name wasn't used mutably, so issue a warning that this // didn't need to be mutable. diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index ae53ed0e1140d..fd171b8992470 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -127,16 +127,13 @@ impl<'a, 'tcx> Visitor<'tcx> for MatchVisitor<'a, 'tcx> { } } - impl<'a, 'tcx> PatternContext<'a, 'tcx> { fn report_inlining_errors(&self, pat_span: Span) { for error in &self.errors { match *error { PatternError::StaticInPattern(span) => { - self.span_e0158(span, "statics cannot be referenced in patterns") - } - PatternError::AssociatedConstInPattern(span) => { - self.span_e0158(span, "associated consts cannot be referenced in patterns") + span_err!(self.tcx.sess, span, E0158, + "statics cannot be referenced in patterns"); } PatternError::ConstEval(ref err) => { err.report(self.tcx, pat_span, "pattern"); @@ -144,10 +141,6 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { } } } - - fn span_e0158(&self, span: Span, text: &str) { - span_err!(self.tcx.sess, span, E0158, "{}", text) - } } impl<'a, 'tcx> MatchVisitor<'a, 'tcx> { diff --git a/src/librustc_const_eval/eval.rs b/src/librustc_const_eval/eval.rs index 8e4ec93c14bae..418bd4b5effc6 100644 --- a/src/librustc_const_eval/eval.rs +++ b/src/librustc_const_eval/eval.rs @@ -17,6 +17,7 @@ use rustc::hir::map::blocks::FnLikeNode; use rustc::hir::def::{Def, CtorKind}; use rustc::hir::def_id::DefId; use rustc::ty::{self, Ty, TyCtxt}; +use rustc::ty::layout::LayoutOf; use rustc::ty::util::IntTypeExt; use rustc::ty::subst::{Substs, Subst}; use rustc::util::common::ErrorReported; @@ -312,7 +313,7 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>, if tcx.fn_sig(def_id).abi() == Abi::RustIntrinsic { let layout_of = |ty: Ty<'tcx>| { let ty = tcx.erase_regions(&ty); - tcx.at(e.span).layout_of(cx.param_env.and(ty)).map_err(|err| { + (tcx.at(e.span), cx.param_env).layout_of(ty).map_err(|err| { ConstEvalErr { span: e.span, kind: LayoutError(err) } }) }; @@ -327,10 +328,6 @@ fn eval_const_expr_partial<'a, 'tcx>(cx: &ConstContext<'a, 'tcx>, return Ok(mk_const(Integral(Usize(ConstUsize::new(align, tcx.sess.target.usize_ty).unwrap())))); } - "type_id" => { - let type_id = tcx.type_id_hash(substs.type_at(0)); - return Ok(mk_const(Integral(U64(type_id)))); - } _ => signal!(e, TypeckError) } } diff --git a/src/librustc_const_eval/pattern.rs b/src/librustc_const_eval/pattern.rs index bdb1001124de6..3577feaf90c1a 100644 --- a/src/librustc_const_eval/pattern.rs +++ b/src/librustc_const_eval/pattern.rs @@ -27,7 +27,6 @@ use syntax_pos::Span; #[derive(Clone, Debug)] pub enum PatternError<'tcx> { - AssociatedConstInPattern(Span), StaticInPattern(Span), ConstEval(ConstEvalErr<'tcx>), } @@ -134,7 +133,7 @@ impl<'tcx> fmt::Display for Pattern<'tcx> { BindingMode::ByValue => mutability == Mutability::Mut, BindingMode::ByRef(_, bk) => { write!(f, "ref ")?; - match bk { BorrowKind::Mut { .. } => true, _ => false } + bk == BorrowKind::Mut } }; if is_mut { @@ -429,7 +428,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { (Mutability::Not, BindingMode::ByValue), ty::BindByReference(hir::MutMutable) => (Mutability::Not, BindingMode::ByRef( - region.unwrap(), BorrowKind::Mut { allow_two_phase_borrow: false })), + region.unwrap(), BorrowKind::Mut)), ty::BindByReference(hir::MutImmutable) => (Mutability::Not, BindingMode::ByRef( region.unwrap(), BorrowKind::Shared)), @@ -636,10 +635,6 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { -> Pattern<'tcx> { let ty = self.tables.node_id_to_type(id); let def = self.tables.qpath_def(qpath, id); - let is_associated_const = match def { - Def::AssociatedConst(_) => true, - _ => false, - }; let kind = match def { Def::Const(def_id) | Def::AssociatedConst(def_id) => { let substs = self.tables.node_substs(id); @@ -661,11 +656,7 @@ impl<'a, 'tcx> PatternContext<'a, 'tcx> { return pat; } None => { - self.errors.push(if is_associated_const { - PatternError::AssociatedConstInPattern(span) - } else { - PatternError::StaticInPattern(span) - }); + self.errors.push(PatternError::StaticInPattern(span)); PatternKind::Wild } } diff --git a/src/librustc_data_structures/blake2b.rs b/src/librustc_data_structures/blake2b.rs new file mode 100644 index 0000000000000..6b8bf8df0d33f --- /dev/null +++ b/src/librustc_data_structures/blake2b.rs @@ -0,0 +1,363 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + + +// An implementation of the Blake2b cryptographic hash function. +// The implementation closely follows: https://tools.ietf.org/html/rfc7693 +// +// "BLAKE2 is a cryptographic hash function faster than MD5, SHA-1, SHA-2, and +// SHA-3, yet is at least as secure as the latest standard SHA-3." +// according to their own website :) +// +// Indeed this implementation is two to three times as fast as our SHA-256 +// implementation. If you have the luxury of being able to use crates from +// crates.io, you can go there and find still faster implementations. + +use std::mem; +use std::slice; + +#[repr(C)] +struct Blake2bCtx { + b: [u8; 128], + h: [u64; 8], + t: [u64; 2], + c: usize, + outlen: u16, + finalized: bool, + + #[cfg(debug_assertions)] + fnv_hash: u64, +} + +#[cfg(debug_assertions)] +impl ::std::fmt::Debug for Blake2bCtx { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + write!(fmt, "{:x}", self.fnv_hash) + } +} + +#[cfg(not(debug_assertions))] +impl ::std::fmt::Debug for Blake2bCtx { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + write!(fmt, "Enable debug_assertions() for more info.") + } +} + +#[inline(always)] +fn b2b_g(v: &mut [u64; 16], + a: usize, + b: usize, + c: usize, + d: usize, + x: u64, + y: u64) +{ + v[a] = v[a].wrapping_add(v[b]).wrapping_add(x); + v[d] = (v[d] ^ v[a]).rotate_right(32); + v[c] = v[c].wrapping_add(v[d]); + v[b] = (v[b] ^ v[c]).rotate_right(24); + v[a] = v[a].wrapping_add(v[b]).wrapping_add(y); + v[d] = (v[d] ^ v[a]).rotate_right(16); + v[c] = v[c].wrapping_add(v[d]); + v[b] = (v[b] ^ v[c]).rotate_right(63); +} + +// Initialization vector +const BLAKE2B_IV: [u64; 8] = [ + 0x6A09E667F3BCC908, 0xBB67AE8584CAA73B, + 0x3C6EF372FE94F82B, 0xA54FF53A5F1D36F1, + 0x510E527FADE682D1, 0x9B05688C2B3E6C1F, + 0x1F83D9ABFB41BD6B, 0x5BE0CD19137E2179 +]; + +fn blake2b_compress(ctx: &mut Blake2bCtx, last: bool) { + + const SIGMA: [[usize; 16]; 12] = [ + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 ], + [11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4 ], + [7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8 ], + [9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13 ], + [2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9 ], + [12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11 ], + [13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10 ], + [6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5 ], + [10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13, 0 ], + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ], + [14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3 ] + ]; + + let mut v: [u64; 16] = [ + ctx.h[0], + ctx.h[1], + ctx.h[2], + ctx.h[3], + ctx.h[4], + ctx.h[5], + ctx.h[6], + ctx.h[7], + + BLAKE2B_IV[0], + BLAKE2B_IV[1], + BLAKE2B_IV[2], + BLAKE2B_IV[3], + BLAKE2B_IV[4], + BLAKE2B_IV[5], + BLAKE2B_IV[6], + BLAKE2B_IV[7], + ]; + + v[12] ^= ctx.t[0]; // low 64 bits of offset + v[13] ^= ctx.t[1]; // high 64 bits + if last { + v[14] = !v[14]; + } + + { + // Re-interpret the input buffer in the state as an array + // of little-endian u64s, converting them to machine + // endianness. It's OK to modify the buffer in place + // since this is the last time this data will be accessed + // before it's overwritten. + + let m: &mut [u64; 16] = unsafe { + let b: &mut [u8; 128] = &mut ctx.b; + ::std::mem::transmute(b) + }; + + if cfg!(target_endian = "big") { + for word in &mut m[..] { + *word = u64::from_le(*word); + } + } + + for i in 0 .. 12 { + b2b_g(&mut v, 0, 4, 8, 12, m[SIGMA[i][ 0]], m[SIGMA[i][ 1]]); + b2b_g(&mut v, 1, 5, 9, 13, m[SIGMA[i][ 2]], m[SIGMA[i][ 3]]); + b2b_g(&mut v, 2, 6, 10, 14, m[SIGMA[i][ 4]], m[SIGMA[i][ 5]]); + b2b_g(&mut v, 3, 7, 11, 15, m[SIGMA[i][ 6]], m[SIGMA[i][ 7]]); + b2b_g(&mut v, 0, 5, 10, 15, m[SIGMA[i][ 8]], m[SIGMA[i][ 9]]); + b2b_g(&mut v, 1, 6, 11, 12, m[SIGMA[i][10]], m[SIGMA[i][11]]); + b2b_g(&mut v, 2, 7, 8, 13, m[SIGMA[i][12]], m[SIGMA[i][13]]); + b2b_g(&mut v, 3, 4, 9, 14, m[SIGMA[i][14]], m[SIGMA[i][15]]); + } + } + + for i in 0 .. 8 { + ctx.h[i] ^= v[i] ^ v[i + 8]; + } +} + +fn blake2b_new(outlen: usize, key: &[u8]) -> Blake2bCtx { + assert!(outlen > 0 && outlen <= 64 && key.len() <= 64); + + let mut ctx = Blake2bCtx { + b: [0; 128], + h: BLAKE2B_IV, + t: [0; 2], + c: 0, + outlen: outlen as u16, + finalized: false, + + #[cfg(debug_assertions)] + fnv_hash: 0xcbf29ce484222325, + }; + + ctx.h[0] ^= 0x01010000 ^ ((key.len() << 8) as u64) ^ (outlen as u64); + + if key.len() > 0 { + blake2b_update(&mut ctx, key); + ctx.c = ctx.b.len(); + } + + ctx +} + +fn blake2b_update(ctx: &mut Blake2bCtx, mut data: &[u8]) { + assert!(!ctx.finalized, "Blake2bCtx already finalized"); + + let mut bytes_to_copy = data.len(); + let mut space_in_buffer = ctx.b.len() - ctx.c; + + while bytes_to_copy > space_in_buffer { + checked_mem_copy(data, &mut ctx.b[ctx.c .. ], space_in_buffer); + + ctx.t[0] = ctx.t[0].wrapping_add(ctx.b.len() as u64); + if ctx.t[0] < (ctx.b.len() as u64) { + ctx.t[1] += 1; + } + blake2b_compress(ctx, false); + ctx.c = 0; + + data = &data[space_in_buffer .. ]; + bytes_to_copy -= space_in_buffer; + space_in_buffer = ctx.b.len(); + } + + if bytes_to_copy > 0 { + checked_mem_copy(data, &mut ctx.b[ctx.c .. ], bytes_to_copy); + ctx.c += bytes_to_copy; + } + + #[cfg(debug_assertions)] + { + // compute additional FNV hash for simpler to read debug output + const MAGIC_PRIME: u64 = 0x00000100000001b3; + + for &byte in data { + ctx.fnv_hash = (ctx.fnv_hash ^ byte as u64).wrapping_mul(MAGIC_PRIME); + } + } +} + +fn blake2b_final(ctx: &mut Blake2bCtx) +{ + assert!(!ctx.finalized, "Blake2bCtx already finalized"); + + ctx.t[0] = ctx.t[0].wrapping_add(ctx.c as u64); + if ctx.t[0] < ctx.c as u64 { + ctx.t[1] += 1; + } + + while ctx.c < 128 { + ctx.b[ctx.c] = 0; + ctx.c += 1; + } + + blake2b_compress(ctx, true); + + // Modify our buffer to little-endian format as it will be read + // as a byte array. It's OK to modify the buffer in place since + // this is the last time this data will be accessed. + if cfg!(target_endian = "big") { + for word in &mut ctx.h { + *word = word.to_le(); + } + } + + ctx.finalized = true; +} + +#[inline(always)] +fn checked_mem_copy(from: &[T1], to: &mut [T2], byte_count: usize) { + let from_size = from.len() * mem::size_of::(); + let to_size = to.len() * mem::size_of::(); + assert!(from_size >= byte_count); + assert!(to_size >= byte_count); + let from_byte_ptr = from.as_ptr() as * const u8; + let to_byte_ptr = to.as_mut_ptr() as * mut u8; + unsafe { + ::std::ptr::copy_nonoverlapping(from_byte_ptr, to_byte_ptr, byte_count); + } +} + +pub fn blake2b(out: &mut [u8], key: &[u8], data: &[u8]) +{ + let mut ctx = blake2b_new(out.len(), key); + blake2b_update(&mut ctx, data); + blake2b_final(&mut ctx); + checked_mem_copy(&ctx.h, out, ctx.outlen as usize); +} + +pub struct Blake2bHasher(Blake2bCtx); + +impl ::std::hash::Hasher for Blake2bHasher { + fn write(&mut self, bytes: &[u8]) { + blake2b_update(&mut self.0, bytes); + } + + fn finish(&self) -> u64 { + assert!(self.0.outlen == 8, + "Hasher initialized with incompatible output length"); + u64::from_le(self.0.h[0]) + } +} + +impl Blake2bHasher { + pub fn new(outlen: usize, key: &[u8]) -> Blake2bHasher { + Blake2bHasher(blake2b_new(outlen, key)) + } + + pub fn finalize(&mut self) -> &[u8] { + if !self.0.finalized { + blake2b_final(&mut self.0); + } + debug_assert!(mem::size_of_val(&self.0.h) >= self.0.outlen as usize); + let raw_ptr = (&self.0.h[..]).as_ptr() as * const u8; + unsafe { + slice::from_raw_parts(raw_ptr, self.0.outlen as usize) + } + } +} + +impl ::std::fmt::Debug for Blake2bHasher { + fn fmt(&self, fmt: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error> { + write!(fmt, "{:?}", self.0) + } +} + +#[cfg(test)] +fn selftest_seq(out: &mut [u8], seed: u32) +{ + let mut a: u32 = 0xDEAD4BADu32.wrapping_mul(seed); + let mut b: u32 = 1; + + for i in 0 .. out.len() { + let t: u32 = a.wrapping_add(b); + a = b; + b = t; + out[i] = ((t >> 24) & 0xFF) as u8; + } +} + +#[test] +fn blake2b_selftest() +{ + use std::hash::Hasher; + + // grand hash of hash results + const BLAKE2B_RES: [u8; 32] = [ + 0xC2, 0x3A, 0x78, 0x00, 0xD9, 0x81, 0x23, 0xBD, + 0x10, 0xF5, 0x06, 0xC6, 0x1E, 0x29, 0xDA, 0x56, + 0x03, 0xD7, 0x63, 0xB8, 0xBB, 0xAD, 0x2E, 0x73, + 0x7F, 0x5E, 0x76, 0x5A, 0x7B, 0xCC, 0xD4, 0x75 + ]; + + // parameter sets + const B2B_MD_LEN: [usize; 4] = [20, 32, 48, 64]; + const B2B_IN_LEN: [usize; 6] = [0, 3, 128, 129, 255, 1024]; + + let mut data = [0u8; 1024]; + let mut md = [0u8; 64]; + let mut key = [0u8; 64]; + + let mut hasher = Blake2bHasher::new(32, &[]); + + for i in 0 .. 4 { + let outlen = B2B_MD_LEN[i]; + for j in 0 .. 6 { + let inlen = B2B_IN_LEN[j]; + + selftest_seq(&mut data[.. inlen], inlen as u32); // unkeyed hash + blake2b(&mut md[.. outlen], &[], &data[.. inlen]); + hasher.write(&md[.. outlen]); // hash the hash + + selftest_seq(&mut key[0 .. outlen], outlen as u32); // keyed hash + blake2b(&mut md[.. outlen], &key[.. outlen], &data[.. inlen]); + hasher.write(&md[.. outlen]); // hash the hash + } + } + + // compute and compare the hash of hashes + let md = hasher.finalize(); + for i in 0 .. 32 { + assert_eq!(md[i], BLAKE2B_RES[i]); + } +} diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index 33d760d0a1482..a35ef2f7ce7ba 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -57,6 +57,7 @@ pub mod small_vec; pub mod base_n; pub mod bitslice; pub mod bitvec; +pub mod blake2b; pub mod graph; pub mod indexed_set; pub mod indexed_vec; @@ -69,6 +70,7 @@ pub mod transitive_relation; pub mod unify; pub mod fx; pub mod tuple_slice; +pub mod veccell; pub mod control_flow_graph; pub mod flock; pub mod sync; diff --git a/src/librustc_data_structures/veccell/mod.rs b/src/librustc_data_structures/veccell/mod.rs new file mode 100644 index 0000000000000..054eee8829a4a --- /dev/null +++ b/src/librustc_data_structures/veccell/mod.rs @@ -0,0 +1,47 @@ +// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +use std::cell::UnsafeCell; +use std::mem; + +pub struct VecCell { + data: UnsafeCell>, +} + +impl VecCell { + pub fn with_capacity(capacity: usize) -> VecCell { + VecCell { data: UnsafeCell::new(Vec::with_capacity(capacity)) } + } + + #[inline] + pub fn push(&self, data: T) -> usize { + // The logic here, and in `swap` below, is that the `push` + // method on the vector will not recursively access this + // `VecCell`. Therefore, we can temporarily obtain mutable + // access, secure in the knowledge that even if aliases exist + // -- indeed, even if aliases are reachable from within the + // vector -- they will not be used for the duration of this + // particular fn call. (Note that we also are relying on the + // fact that `VecCell` is not `Sync`.) + unsafe { + let v = self.data.get(); + (*v).push(data); + (*v).len() + } + } + + pub fn swap(&self, mut data: Vec) -> Vec { + unsafe { + let v = self.data.get(); + mem::swap(&mut *v, &mut data); + } + data + } +} diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index f344624666a6c..e97d83ed1ee5a 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -121,8 +121,23 @@ pub fn compile_input(trans: Box, }; let outputs = build_output_filenames(input, outdir, output, &krate.attrs, sess); + + // Ensure the source file isn't accidentally overwritten during compilation. + match *input_path { + Some(ref input_path) => { + if outputs.contains_path(input_path) && sess.opts.will_create_output_file() { + sess.err(&format!( + "the input file \"{}\" would be overwritten by the generated executable", + input_path.display())); + return Err(CompileIncomplete::Stopped); + } + }, + None => {} + } + let crate_name = ::rustc_trans_utils::link::find_crate_name(Some(sess), &krate.attrs, input); + let ExpansionResult { expanded_crate, defs, analysis, resolutions, mut hir_forest } = { phase_2_configure_and_expand( sess, @@ -142,41 +157,12 @@ pub fn compile_input(trans: Box, )? }; - let output_paths = generated_output_paths(sess, &outputs, output.is_some(), &crate_name); - - // Ensure the source file isn't accidentally overwritten during compilation. - if let Some(ref input_path) = *input_path { - if sess.opts.will_create_output_file() { - if output_contains_path(&output_paths, input_path) { - sess.err(&format!( - "the input file \"{}\" would be overwritten by the generated \ - executable", - input_path.display())); - return Err(CompileIncomplete::Stopped); - } - if let Some(dir_path) = output_conflicts_with_dir(&output_paths) { - sess.err(&format!( - "the generated executable for the input file \"{}\" conflicts with the \ - existing directory \"{}\"", - input_path.display(), dir_path.display())); - return Err(CompileIncomplete::Stopped); - } - } - } - - write_out_deps(sess, &outputs, &output_paths); + write_out_deps(sess, &outputs, &crate_name); if sess.opts.output_types.contains_key(&OutputType::DepInfo) && sess.opts.output_types.keys().count() == 1 { return Ok(()) } - if let &Some(ref dir) = outdir { - if fs::create_dir_all(dir).is_err() { - sess.err("failed to find or create the directory specified by --out-dir"); - return Err(CompileIncomplete::Stopped); - } - } - let arenas = AllArenas::new(); // Construct the HIR map @@ -1115,22 +1101,16 @@ fn escape_dep_filename(filename: &FileName) -> String { filename.to_string().replace(" ", "\\ ") } -// Returns all the paths that correspond to generated files. -fn generated_output_paths(sess: &Session, - outputs: &OutputFilenames, - exact_name: bool, - crate_name: &str) -> Vec { +fn write_out_deps(sess: &Session, outputs: &OutputFilenames, crate_name: &str) { let mut out_filenames = Vec::new(); for output_type in sess.opts.output_types.keys() { let file = outputs.path(*output_type); match *output_type { - // If the filename has been overridden using `-o`, it will not be modified - // by appending `.rlib`, `.exe`, etc., so we can skip this transformation. - OutputType::Exe if !exact_name => { - for crate_type in sess.crate_types.borrow().iter() { + OutputType::Exe => { + for output in sess.crate_types.borrow().iter() { let p = ::rustc_trans_utils::link::filename_for_input( sess, - *crate_type, + *output, crate_name, outputs ); @@ -1145,46 +1125,7 @@ fn generated_output_paths(sess: &Session, } } } - out_filenames -} -// Runs `f` on every output file path and returns the first non-None result, or None if `f` -// returns None for every file path. -fn check_output(output_paths: &Vec, f: F) -> Option - where F: Fn(&PathBuf) -> Option { - for output_path in output_paths { - if let Some(result) = f(output_path) { - return Some(result); - } - } - None -} - -pub fn output_contains_path(output_paths: &Vec, input_path: &PathBuf) -> bool { - let input_path = input_path.canonicalize().ok(); - if input_path.is_none() { - return false - } - let check = |output_path: &PathBuf| { - if output_path.canonicalize().ok() == input_path { - Some(()) - } else { None } - }; - check_output(output_paths, check).is_some() -} - -pub fn output_conflicts_with_dir(output_paths: &Vec) -> Option { - let check = |output_path: &PathBuf| { - if output_path.is_dir() { - Some(output_path.clone()) - } else { None } - }; - check_output(output_paths, check) -} - -fn write_out_deps(sess: &Session, - outputs: &OutputFilenames, - out_filenames: &Vec) { // Write out dependency rules to the dep-info file if requested if !sess.opts.output_types.contains_key(&OutputType::DepInfo) { return; @@ -1203,7 +1144,7 @@ fn write_out_deps(sess: &Session, .map(|fmap| escape_dep_filename(&fmap.name)) .collect(); let mut file = fs::File::create(&deps_filename)?; - for path in out_filenames { + for path in &out_filenames { write!(file, "{}: {}\n\n", path.display(), files.join(" "))?; } @@ -1386,10 +1327,7 @@ pub fn build_output_filenames(input: &Input, Some(out_file.clone()) }; if *odir != None { - sess.warn("ignoring --out-dir flag due to -o flag"); - } - if !sess.opts.cg.extra_filename.is_empty() { - sess.warn("ignoring -C extra-filename flag due to -o flag"); + sess.warn("ignoring --out-dir flag due to -o flag."); } let cur_dir = Path::new(""); diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 05dcaf731352a..6118ee94c84cf 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -167,8 +167,7 @@ pub fn run(run_compiler: F) -> isize let emitter = errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto, None, - true, - false); + true); let handler = errors::Handler::with_emitter(true, false, Box::new(emitter)); handler.emit(&MultiSpan::new(), "aborting due to previous error(s)", @@ -290,7 +289,7 @@ fn get_trans_sysroot(backend_name: &str) -> fn() -> Box { let sysroot = sysroot_candidates.iter() .map(|sysroot| { let libdir = filesearch::relative_target_lib_path(&sysroot, &target); - sysroot.join(libdir).with_file_name("codegen-backends") + sysroot.join(&libdir).join("codegen-backends") }) .filter(|f| { info!("codegen backend candidate: {}", f.display()); @@ -457,13 +456,10 @@ pub fn run_compiler<'a>(args: &[String], None); let (odir, ofile) = make_output(&matches); - let (input, input_file_path, input_err) = match make_input(&matches.free) { - Some((input, input_file_path, input_err)) => { - let (input, input_file_path) = callbacks.some_input(input, input_file_path); - (input, input_file_path, input_err) - }, + let (input, input_file_path) = match make_input(&matches.free) { + Some((input, input_file_path)) => callbacks.some_input(input, input_file_path), None => match callbacks.no_input(&matches, &sopts, &cfg, &odir, &ofile, &descriptions) { - Some((input, input_file_path)) => (input, input_file_path, None), + Some((input, input_file_path)) => (input, input_file_path), None => return (Ok(()), None), }, }; @@ -474,13 +470,6 @@ pub fn run_compiler<'a>(args: &[String], sopts, input_file_path.clone(), descriptions, codemap, emitter_dest, ); - if let Some(err) = input_err { - // Immediately stop compilation if there was an issue reading - // the input (for example if the input stream is not UTF-8). - sess.err(&format!("{}", err)); - return (Err(CompileIncomplete::Stopped), Some(sess)); - } - let trans = get_trans(&sess); rustc_lint::register_builtins(&mut sess.lint_store.borrow_mut(), Some(&sess)); @@ -523,22 +512,17 @@ fn make_output(matches: &getopts::Matches) -> (Option, Option) } // Extract input (string or file and optional path) from matches. -fn make_input(free_matches: &[String]) -> Option<(Input, Option, Option)> { +fn make_input(free_matches: &[String]) -> Option<(Input, Option)> { if free_matches.len() == 1 { let ifile = &free_matches[0]; if ifile == "-" { let mut src = String::new(); - let err = if io::stdin().read_to_string(&mut src).is_err() { - Some(io::Error::new(io::ErrorKind::InvalidData, - "couldn't read from stdin, as it did not contain valid UTF-8")) - } else { - None - }; + io::stdin().read_to_string(&mut src).unwrap(); Some((Input::Str { name: FileName::Anon, input: src }, - None, err)) + None)) } else { Some((Input::File(PathBuf::from(ifile)), - Some(PathBuf::from(ifile)), None)) + Some(PathBuf::from(ifile)))) } } else { None @@ -1450,7 +1434,6 @@ pub fn monitor(f: F) { let emitter = Box::new(errors::emitter::EmitterWriter::stderr(errors::ColorConfig::Auto, None, - false, false)); let handler = errors::Handler::with_emitter(true, false, emitter); diff --git a/src/librustc_errors/diagnostic.rs b/src/librustc_errors/diagnostic.rs index 40e4efb397d30..2e654fe9929a6 100644 --- a/src/librustc_errors/diagnostic.rs +++ b/src/librustc_errors/diagnostic.rs @@ -222,7 +222,6 @@ impl Diagnostic { }], msg: msg.to_owned(), show_code_when_inline: false, - approximate: false, }); self } @@ -253,7 +252,6 @@ impl Diagnostic { }], msg: msg.to_owned(), show_code_when_inline: true, - approximate: false, }); self } @@ -269,41 +267,6 @@ impl Diagnostic { }).collect(), msg: msg.to_owned(), show_code_when_inline: true, - approximate: false, - }); - self - } - - /// This is a suggestion that may contain mistakes or fillers and should - /// be read and understood by a human. - pub fn span_approximate_suggestion(&mut self, sp: Span, msg: &str, - suggestion: String) -> &mut Self { - self.suggestions.push(CodeSuggestion { - substitutions: vec![Substitution { - parts: vec![SubstitutionPart { - snippet: suggestion, - span: sp, - }], - }], - msg: msg.to_owned(), - show_code_when_inline: true, - approximate: true, - }); - self - } - - pub fn span_approximate_suggestions(&mut self, sp: Span, msg: &str, - suggestions: Vec) -> &mut Self { - self.suggestions.push(CodeSuggestion { - substitutions: suggestions.into_iter().map(|snippet| Substitution { - parts: vec![SubstitutionPart { - snippet, - span: sp, - }], - }).collect(), - msg: msg.to_owned(), - show_code_when_inline: true, - approximate: true, }); self } diff --git a/src/librustc_errors/diagnostic_builder.rs b/src/librustc_errors/diagnostic_builder.rs index 2536fc648c70a..61674ada6fa63 100644 --- a/src/librustc_errors/diagnostic_builder.rs +++ b/src/librustc_errors/diagnostic_builder.rs @@ -186,16 +186,6 @@ impl<'a> DiagnosticBuilder<'a> { msg: &str, suggestions: Vec) -> &mut Self); - forward!(pub fn span_approximate_suggestion(&mut self, - sp: Span, - msg: &str, - suggestion: String) - -> &mut Self); - forward!(pub fn span_approximate_suggestions(&mut self, - sp: Span, - msg: &str, - suggestions: Vec) - -> &mut Self); forward!(pub fn set_span>(&mut self, sp: S) -> &mut Self); forward!(pub fn code(&mut self, s: DiagnosticId) -> &mut Self); diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index a49284eb55a46..8a4fd24a29b89 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -106,7 +106,6 @@ pub struct EmitterWriter { dst: Destination, cm: Option>, short_message: bool, - teach: bool, } struct FileWithAnnotatedLines { @@ -118,37 +117,32 @@ struct FileWithAnnotatedLines { impl EmitterWriter { pub fn stderr(color_config: ColorConfig, code_map: Option>, - short_message: bool, - teach: bool) + short_message: bool) -> EmitterWriter { if color_config.use_color() { let dst = Destination::from_stderr(); EmitterWriter { dst, cm: code_map, - short_message, - teach, + short_message: short_message, } } else { EmitterWriter { dst: Raw(Box::new(io::stderr())), cm: code_map, - short_message, - teach, + short_message: short_message, } } } pub fn new(dst: Box, code_map: Option>, - short_message: bool, - teach: bool) + short_message: bool) -> EmitterWriter { EmitterWriter { dst: Raw(dst), cm: code_map, - short_message, - teach, + short_message: short_message, } } @@ -290,10 +284,6 @@ impl EmitterWriter { line: &Line, width_offset: usize, code_offset: usize) -> Vec<(usize, Style)> { - if line.line_index == 0 { - return Vec::new(); - } - let source_string = match file.get_line(line.line_index - 1) { Some(s) => s, None => return Vec::new(), @@ -561,14 +551,7 @@ impl EmitterWriter { code_offset + annotation.start_col, style); } - _ if self.teach => { - buffer.set_style_range(line_offset, - code_offset + annotation.start_col, - code_offset + annotation.end_col, - style, - annotation.is_primary); - } - _ => {} + _ => (), } } @@ -1031,21 +1014,8 @@ impl EmitterWriter { // Then, the secondary file indicator buffer.prepend(buffer_msg_line_offset + 1, "::: ", Style::LineNumber); - let loc = if let Some(first_line) = annotated_file.lines.first() { - let col = if let Some(first_annotation) = first_line.annotations.first() { - format!(":{}", first_annotation.start_col + 1) - } else { - "".to_string() - }; - format!("{}:{}{}", - annotated_file.file.name, - cm.doctest_offset_line(first_line.line_index), - col) - } else { - annotated_file.file.name.to_string() - }; buffer.append(buffer_msg_line_offset + 1, - &loc, + &annotated_file.file.name.to_string(), Style::LineAndColumn); for _ in 0..max_line_num_len { buffer.prepend(buffer_msg_line_offset + 1, " ", Style::NoStyle); diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 236698ed2d45d..3d50c95d3f4f9 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -83,12 +83,6 @@ pub struct CodeSuggestion { pub substitutions: Vec, pub msg: String, pub show_code_when_inline: bool, - /// Whether or not the suggestion is approximate - /// - /// Sometimes we may show suggestions with placeholders, - /// which are useful for users but not useful for - /// tools like rustfix - pub approximate: bool, } #[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)] @@ -303,7 +297,7 @@ impl Handler { cm: Option>, flags: HandlerFlags) -> Handler { - let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false, false)); + let emitter = Box::new(EmitterWriter::stderr(color_config, cm, false)); Handler::with_emitter_and_flags(emitter, flags) } diff --git a/src/librustc_errors/snippet.rs b/src/librustc_errors/snippet.rs index 7d416f13ffc8a..c2f4701999ea9 100644 --- a/src/librustc_errors/snippet.rs +++ b/src/librustc_errors/snippet.rs @@ -10,8 +10,31 @@ // Code for annotating snippets. +use syntax_pos::{Span, FileMap}; +use CodeMapper; +use std::rc::Rc; use Level; +#[derive(Clone)] +pub struct SnippetData { + codemap: Rc, + files: Vec, +} + +#[derive(Clone)] +pub struct FileInfo { + file: Rc, + + /// The "primary file", if any, gets a `-->` marker instead of + /// `>>>`, and has a line-number/column printed and not just a + /// filename. It appears first in the listing. It is known to + /// contain at least one primary span, though primary spans (which + /// are designated with `^^^`) may also occur in other files. + primary_span: Option, + + lines: Vec, +} + #[derive(Clone, Debug, PartialOrd, Ord, PartialEq, Eq)] pub struct Line { pub line_index: usize, diff --git a/src/librustc_errors/styled_buffer.rs b/src/librustc_errors/styled_buffer.rs index 2c736ec22c3b3..2c33f80520360 100644 --- a/src/librustc_errors/styled_buffer.rs +++ b/src/librustc_errors/styled_buffer.rs @@ -144,25 +144,4 @@ impl StyledBuffer { pub fn num_lines(&self) -> usize { self.text.len() } - - pub fn set_style_range(&mut self, - line: usize, - col_start: usize, - col_end: usize, - style: Style, - overwrite: bool) { - for col in col_start..col_end { - self.set_style(line, col, style, overwrite); - } - } - - pub fn set_style(&mut self, line: usize, col: usize, style: Style, overwrite: bool) { - if let Some(ref mut line) = self.styles.get_mut(line) { - if let Some(s) = line.get_mut(col) { - if *s == Style::NoStyle || *s == Style::Quotation || overwrite { - *s = style; - } - } - } - } } diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index e7e4119b9999b..e0999db6e3e66 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -437,8 +437,8 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { // repr(transparent) types are allowed to have arbitrary ZSTs, not just // PhantomData -- skip checking all ZST fields if def.repr.transparent() { - let is_zst = cx - .layout_of(cx.param_env(field.did).and(field_ty)) + let is_zst = (cx, cx.param_env(field.did)) + .layout_of(field_ty) .map(|layout| layout.is_zst()) .unwrap_or(false); if is_zst { diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 439533fae49d9..ef6475f9ee4c7 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -302,38 +302,19 @@ impl EarlyLintPass for UnusedParens { Assign(_, ref value) => (value, "assigned value", false), AssignOp(.., ref value) => (value, "assigned value", false), InPlace(_, ref value) => (value, "emplacement value", false), - // either function/method call, or something this lint doesn't care about - ref call_or_other => { - let args_to_check; - let call_kind; - match *call_or_other { - Call(_, ref args) => { - call_kind = "function"; - args_to_check = &args[..]; - }, - MethodCall(_, ref args) => { - call_kind = "method"; - // first "argument" is self (which sometimes needs parens) - args_to_check = &args[1..]; - } - // actual catch-all arm - _ => { return; } - } - // Don't lint if this is a nested macro expansion: otherwise, the lint could - // trigger in situations that macro authors shouldn't have to care about, e.g., - // when a parenthesized token tree matched in one macro expansion is matched as - // an expression in another and used as a fn/method argument (Issue #47775) - if e.span.ctxt().outer().expn_info() - .map_or(false, |info| info.call_site.ctxt().outer() - .expn_info().is_some()) { - return; + Call(_, ref args) => { + for arg in args { + self.check_unused_parens_core(cx, arg, "function argument", false) } - let msg = format!("{} argument", call_kind); - for arg in args_to_check { - self.check_unused_parens_core(cx, arg, &msg, false); + return; + }, + MethodCall(_, ref args) => { + for arg in &args[1..] { // first "argument" is self (which sometimes needs parens) + self.check_unused_parens_core(cx, arg, "method argument", false) } return; } + _ => return, }; self.check_unused_parens_core(cx, &value, msg, struct_lit_needs_parens); } @@ -437,10 +418,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedAllocation { for adj in cx.tables.expr_adjustments(e) { if let adjustment::Adjust::Borrow(adjustment::AutoBorrow::Ref(_, m)) = adj.kind { let msg = match m { - adjustment::AutoBorrowMutability::Immutable => - "unnecessary allocation, use & instead", - adjustment::AutoBorrowMutability::Mutable { .. }=> - "unnecessary allocation, use &mut instead" + hir::MutImmutable => "unnecessary allocation, use & instead", + hir::MutMutable => "unnecessary allocation, use &mut instead" }; cx.span_lint(UNUSED_ALLOCATION, e.span, msg); } diff --git a/src/librustc_mir/borrow_check/error_reporting.rs b/src/librustc_mir/borrow_check/error_reporting.rs index 34551e8e76f59..7bd3b6e39f053 100644 --- a/src/librustc_mir/borrow_check/error_reporting.rs +++ b/src/librustc_mir/borrow_check/error_reporting.rs @@ -256,8 +256,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { "immutable", "mutable", ) { - (BorrowKind::Shared, lft, _, BorrowKind::Mut { .. }, _, rgt) | - (BorrowKind::Mut { .. }, _, lft, BorrowKind::Shared, rgt, _) => self.tcx + (BorrowKind::Shared, lft, _, BorrowKind::Mut, _, rgt) | + (BorrowKind::Mut, _, lft, BorrowKind::Shared, rgt, _) => self.tcx .cannot_reborrow_already_borrowed( span, &desc_place, @@ -271,7 +271,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { Origin::Mir, ), - (BorrowKind::Mut { .. }, _, _, BorrowKind::Mut { .. }, _, _) => self.tcx + (BorrowKind::Mut, _, _, BorrowKind::Mut, _, _) => self.tcx .cannot_mutably_borrow_multiply( span, &desc_place, @@ -314,7 +314,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { Origin::Mir, ), - (BorrowKind::Mut { .. }, _, lft, BorrowKind::Unique, _, _) => self.tcx + (BorrowKind::Mut, _, lft, BorrowKind::Unique, _, _) => self.tcx .cannot_reborrow_already_uniquely_borrowed( span, &desc_place, @@ -362,20 +362,33 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { let scope_tree = borrows.0.scope_tree(); let root_place = self.prefixes(&borrow.borrowed_place, PrefixSet::All).last().unwrap(); + match root_place { + &Place::Local(local) => { + if let Some(_) = self.storage_dead_or_drop_error_reported_l.replace(local) { + debug!("report_does_not_live_long_enough({:?}): ", + (borrow, drop_span)); + return + } + } + &Place::Static(ref statik) => { + if let Some(_) = self.storage_dead_or_drop_error_reported_s + .replace(statik.def_id) + { + debug!("report_does_not_live_long_enough({:?}): ", + (borrow, drop_span)); + return + } + }, + &Place::Projection(_) => + unreachable!("root_place is an unreachable???") + }; + let borrow_span = self.mir.source_info(borrow.location).span; let proper_span = match *root_place { Place::Local(local) => self.mir.local_decls[local].source_info.span, _ => drop_span, }; - if self.access_place_error_reported.contains(&(root_place.clone(), borrow_span)) { - debug!("suppressing access_place error when borrow doesn't live long enough for {:?}", - borrow_span); - return; - } - - self.access_place_error_reported.insert((root_place.clone(), borrow_span)); - match (borrow.region, &self.describe_place(&borrow.borrowed_place)) { (RegionKind::ReScope(_), Some(name)) => { self.report_scoped_local_value_does_not_live_long_enough( @@ -733,12 +746,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { self.describe_field_from_ty(&tnm.ty, field) } ty::TyArray(ty, _) | ty::TySlice(ty) => self.describe_field_from_ty(&ty, field), - ty::TyClosure(def_id, _) | ty::TyGenerator(def_id, _, _) => { + ty::TyClosure(closure_def_id, _) => { // Convert the def-id into a node-id. node-ids are only valid for // the local code in the current crate, so this returns an `Option` in case // the closure comes from another crate. But in that case we wouldn't // be borrowck'ing it, so we can just unwrap: - let node_id = self.tcx.hir.as_local_node_id(def_id).unwrap(); + let node_id = self.tcx.hir.as_local_node_id(closure_def_id).unwrap(); let freevar = self.tcx.with_freevars(node_id, |fv| fv[field.index()]); self.tcx.hir.name(freevar.var_id()).to_string() diff --git a/src/librustc_mir/borrow_check/mod.rs b/src/librustc_mir/borrow_check/mod.rs index c4df7349391e2..9a6d83b8eb759 100644 --- a/src/librustc_mir/borrow_check/mod.rs +++ b/src/librustc_mir/borrow_check/mod.rs @@ -17,7 +17,7 @@ use rustc::hir::map::definitions::DefPathData; use rustc::infer::InferCtxt; use rustc::ty::{self, ParamEnv, TyCtxt}; use rustc::ty::maps::Providers; -use rustc::mir::{AssertMessage, BasicBlock, BorrowKind, Location, Place}; +use rustc::mir::{AssertMessage, BasicBlock, BorrowKind, Local, Location, Place}; use rustc::mir::{Mir, Mutability, Operand, Projection, ProjectionElem, Rvalue}; use rustc::mir::{Field, Statement, StatementKind, Terminator, TerminatorKind}; use rustc::mir::ClosureRegionRequirements; @@ -228,7 +228,8 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>( hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(_) => false, hir::BodyOwnerKind::Fn => true, }, - access_place_error_reported: FxHashSet(), + storage_dead_or_drop_error_reported_l: FxHashSet(), + storage_dead_or_drop_error_reported_s: FxHashSet(), reservation_error_reported: FxHashSet(), nonlexical_regioncx: opt_regioncx.clone(), }; @@ -293,12 +294,12 @@ pub struct MirBorrowckCtxt<'cx, 'gcx: 'tcx, 'tcx: 'cx> { /// I'm not sure this is the right approach - @eddyb could you try and /// figure this out? locals_are_invalidated_at_exit: bool, - /// This field keeps track of when borrow errors are reported in the access_place function - /// so that there is no duplicate reporting. This field cannot also be used for the conflicting - /// borrow errors that is handled by the `reservation_error_reported` field as the inclusion - /// of the `Span` type (while required to mute some errors) stops the muting of the reservation - /// errors. - access_place_error_reported: FxHashSet<(Place<'tcx>, Span)>, + /// This field keeps track of when storage dead or drop errors are reported + /// in order to stop duplicate error reporting and identify the conditions required + /// for a "temporary value dropped here while still borrowed" error. See #45360. + storage_dead_or_drop_error_reported_l: FxHashSet, + /// Same as the above, but for statics (thread-locals) + storage_dead_or_drop_error_reported_s: FxHashSet, /// This field keeps track of when borrow conflict errors are reported /// for reservations, so that we don't report seemingly duplicate /// errors for corresponding activations @@ -347,13 +348,6 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx match stmt.kind { StatementKind::Assign(ref lhs, ref rhs) => { - self.consume_rvalue( - ContextKind::AssignRhs.new(location), - (rhs, span), - location, - flow_state, - ); - self.mutate_place( ContextKind::AssignLhs.new(location), (lhs, span), @@ -361,6 +355,13 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx JustWrite, flow_state, ); + + self.consume_rvalue( + ContextKind::AssignRhs.new(location), + (rhs, span), + location, + flow_state, + ); } StatementKind::SetDiscriminant { ref place, @@ -575,8 +576,7 @@ impl<'cx, 'gcx, 'tcx> DataflowResultsConsumer<'cx, 'tcx> for MirBorrowckCtxt<'cx TerminatorKind::Goto { target: _ } | TerminatorKind::Abort | TerminatorKind::Unreachable - | TerminatorKind::FalseEdges { real_target: _, imaginary_targets: _ } - | TerminatorKind::FalseUnwind { real_target: _, unwind: _ } => { + | TerminatorKind::FalseEdges { .. } => { // no data used, thus irrelevant to borrowck } } @@ -708,15 +708,6 @@ impl InitializationRequiringAction { } impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { - /// Returns true if the borrow represented by `kind` is - /// allowed to be split into separate Reservation and - /// Activation phases. - fn allow_two_phase_borrow(&self, kind: BorrowKind) -> bool { - self.tcx.sess.two_phase_borrows() && - (kind.allows_two_phase_borrow() || - self.tcx.sess.opts.debugging_opts.two_phase_beyond_autoref) - } - /// Checks an access to the given place to see if it is allowed. Examines the set of borrows /// that are in scope, as well as which paths have been initialized, to ensure that (a) the /// place is initialized and (b) it is not borrowed in some way that would prevent this @@ -735,8 +726,12 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { if let Activation(_, borrow_index) = rw { if self.reservation_error_reported.contains(&place_span.0) { - debug!("skipping access_place for activation of invalid reservation \ - place: {:?} borrow_index: {:?}", place_span.0, borrow_index); + debug!( + "skipping access_place for activation of invalid reservation \ + place: {:?} borrow_index: {:?}", + place_span.0, + borrow_index + ); return AccessErrorsReported { mutability_error: false, conflict_error: true, @@ -744,26 +739,11 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } } - if self.access_place_error_reported.contains(&(place_span.0.clone(), place_span.1)) { - debug!("access_place: suppressing error place_span=`{:?}` kind=`{:?}`", - place_span, kind); - return AccessErrorsReported { - mutability_error: false, - conflict_error: true, - }; - } - let mutability_error = self.check_access_permissions(place_span, rw, is_local_mutation_allowed); let conflict_error = self.check_access_for_conflict(context, place_span, sd, rw, flow_state); - if conflict_error || mutability_error { - debug!("access_place: logging error place_span=`{:?}` kind=`{:?}`", - place_span, kind); - self.access_place_error_reported.insert((place_span.0.clone(), place_span.1)); - } - AccessErrorsReported { mutability_error, conflict_error, @@ -807,9 +787,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { Control::Continue } - (Read(kind), BorrowKind::Unique) | (Read(kind), BorrowKind::Mut { .. }) => { + (Read(kind), BorrowKind::Unique) | (Read(kind), BorrowKind::Mut) => { // Reading from mere reservations of mutable-borrows is OK. - if this.allow_two_phase_borrow(borrow.kind) && index.is_reservation() + if this.tcx.sess.two_phase_borrows() && index.is_reservation() { return Control::Continue; } @@ -838,7 +818,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { } (Reservation(kind), BorrowKind::Unique) - | (Reservation(kind), BorrowKind::Mut { .. }) + | (Reservation(kind), BorrowKind::Mut) | (Activation(kind, _), _) | (Write(kind), _) => { match rw { @@ -849,15 +829,15 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { place_span.0 ); this.reservation_error_reported.insert(place_span.0.clone()); - }, + } Activation(_, activating) => { debug!( "observing check_place for activation of \ borrow_index: {:?}", activating ); - }, - Read(..) | Write(..) => {}, + } + Read(..) | Write(..) => {} } match kind { @@ -955,9 +935,9 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { Rvalue::Ref(_ /*rgn*/, bk, ref place) => { let access_kind = match bk { BorrowKind::Shared => (Deep, Read(ReadKind::Borrow(bk))), - BorrowKind::Unique | BorrowKind::Mut { .. } => { + BorrowKind::Unique | BorrowKind::Mut => { let wk = WriteKind::MutableBorrow(bk); - if self.allow_two_phase_borrow(bk) { + if self.tcx.sess.two_phase_borrows() { (Deep, Reservation(wk)) } else { (Deep, Write(wk)) @@ -1206,7 +1186,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { // mutable borrow before we check it. match borrow.kind { BorrowKind::Shared => return, - BorrowKind::Unique | BorrowKind::Mut { .. } => {} + BorrowKind::Unique | BorrowKind::Mut => {} } self.access_place( @@ -1477,8 +1457,8 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { span_bug!(span, "&unique borrow for {:?} should not fail", place); } } - Reservation(WriteKind::MutableBorrow(BorrowKind::Mut { .. })) - | Write(WriteKind::MutableBorrow(BorrowKind::Mut { .. })) => if let Err(place_err) = + Reservation(WriteKind::MutableBorrow(BorrowKind::Mut)) + | Write(WriteKind::MutableBorrow(BorrowKind::Mut)) => if let Err(place_err) = self.is_mutable(place, is_local_mutation_allowed) { error_reported = true; @@ -1542,7 +1522,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> { Activation(..) => {} // permission checks are done at Reservation point. Read(ReadKind::Borrow(BorrowKind::Unique)) - | Read(ReadKind::Borrow(BorrowKind::Mut { .. })) + | Read(ReadKind::Borrow(BorrowKind::Mut)) | Read(ReadKind::Borrow(BorrowKind::Shared)) | Read(ReadKind::Copy) => {} // Access authorized } diff --git a/src/librustc_mir/borrow_check/nll/region_infer/annotation.rs b/src/librustc_mir/borrow_check/nll/region_infer/annotation.rs index d213f376d2bca..e8a23acd798de 100644 --- a/src/librustc_mir/borrow_check/nll/region_infer/annotation.rs +++ b/src/librustc_mir/borrow_check/nll/region_infer/annotation.rs @@ -45,11 +45,10 @@ impl<'gcx, 'tcx> RegionInferenceContext<'tcx> { &substs[..] )); } - DefiningTy::Const(def_id, substs) => { + DefiningTy::Const(ty) => { err.note(&format!( - "defining constant type: {:?} with substs {:#?}", - def_id, - &substs[..] + "defining type: {:?}", + ty )); } } diff --git a/src/librustc_mir/borrow_check/nll/type_check/liveness.rs b/src/librustc_mir/borrow_check/nll/type_check/liveness.rs index a50b99937475e..6c2037810d326 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/liveness.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/liveness.rs @@ -15,10 +15,7 @@ use dataflow::move_paths::{HasMoveData, MoveData}; use rustc::mir::{BasicBlock, Location, Mir}; use rustc::mir::Local; use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; -use rustc::traits; -use rustc::infer::InferOk; use rustc::util::common::ErrorReported; -use borrow_check::nll::type_check::AtLocation; use rustc_data_structures::fx::FxHashSet; use syntax::codemap::DUMMY_SP; use util::liveness::LivenessResults; @@ -187,86 +184,48 @@ impl<'gen, 'typeck, 'flow, 'gcx, 'tcx> TypeLivenessGenerator<'gen, 'typeck, 'flo location ); - // If we end visiting the same type twice (usually due to a cycle involving - // associated types), we need to ensure that its region types match up with the type - // we added to the 'known' map the first time around. For this reason, we need - // our infcx to hold onto its calculated region constraints after each call - // to dtorck_constraint_for_ty. Otherwise, normalizing the corresponding associated - // type will end up instantiating the type with a new set of inference variables - // Since this new type will never be in 'known', we end up looping forever. - // - // For this reason, we avoid calling TypeChecker.normalize, instead doing all normalization - // ourselves in one large 'fully_perform_op' callback. - let (type_constraints, kind_constraints) = self.cx.fully_perform_op(location.at_self(), - |cx| { - - let tcx = cx.infcx.tcx; - let mut selcx = traits::SelectionContext::new(cx.infcx); - let cause = cx.misc(cx.last_span); - - let mut types = vec![(dropped_ty, 0)]; - let mut final_obligations = Vec::new(); - let mut type_constraints = Vec::new(); - let mut kind_constraints = Vec::new(); - - let mut known = FxHashSet(); - - while let Some((ty, depth)) = types.pop() { - let span = DUMMY_SP; // FIXME - let result = match tcx.dtorck_constraint_for_ty(span, dropped_ty, depth, ty) { - Ok(result) => result, - Err(ErrorReported) => { - continue; - } - }; - - let ty::DtorckConstraint { - outlives, - dtorck_types, - } = result; - - // All things in the `outlives` array may be touched by - // the destructor and must be live at this point. - for outlive in outlives { - let cause = Cause::DropVar(dropped_local, location); - kind_constraints.push((outlive, location, cause)); + let tcx = self.cx.infcx.tcx; + let mut types = vec![(dropped_ty, 0)]; + let mut known = FxHashSet(); + while let Some((ty, depth)) = types.pop() { + let span = DUMMY_SP; // FIXME + let result = match tcx.dtorck_constraint_for_ty(span, dropped_ty, depth, ty) { + Ok(result) => result, + Err(ErrorReported) => { + continue; } + }; + + let ty::DtorckConstraint { + outlives, + dtorck_types, + } = result; + + // All things in the `outlives` array may be touched by + // the destructor and must be live at this point. + for outlive in outlives { + let cause = Cause::DropVar(dropped_local, location); + self.push_type_live_constraint(outlive, location, cause); + } - // However, there may also be some types that - // `dtorck_constraint_for_ty` could not resolve (e.g., - // associated types and parameters). We need to normalize - // associated types here and possibly recursively process. - for ty in dtorck_types { - let traits::Normalized { value: ty, obligations } = - traits::normalize(&mut selcx, cx.param_env, cause.clone(), &ty); - - final_obligations.extend(obligations); - - let ty = cx.infcx.resolve_type_and_region_vars_if_possible(&ty); - match ty.sty { - ty::TyParam(..) | ty::TyProjection(..) | ty::TyAnon(..) => { - let cause = Cause::DropVar(dropped_local, location); - type_constraints.push((ty, location, cause)); - } - - _ => if known.insert(ty) { - types.push((ty, depth + 1)); - }, + // However, there may also be some types that + // `dtorck_constraint_for_ty` could not resolve (e.g., + // associated types and parameters). We need to normalize + // associated types here and possibly recursively process. + for ty in dtorck_types { + let ty = self.cx.normalize(&ty, location); + let ty = self.cx.infcx.resolve_type_and_region_vars_if_possible(&ty); + match ty.sty { + ty::TyParam(..) | ty::TyProjection(..) | ty::TyAnon(..) => { + let cause = Cause::DropVar(dropped_local, location); + self.push_type_live_constraint(ty, location, cause); } + + _ => if known.insert(ty) { + types.push((ty, depth + 1)); + }, } } - - Ok(InferOk { - value: (type_constraints, kind_constraints), obligations: final_obligations - }) - }).unwrap(); - - for (ty, location, cause) in type_constraints { - self.push_type_live_constraint(ty, location, cause); - } - - for (kind, location, cause) in kind_constraints { - self.push_type_live_constraint(kind, location, cause); } } } diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs index 7ca8d0bdd500b..015eb8a3b6643 100644 --- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs +++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs @@ -374,20 +374,13 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { } }; if let PlaceContext::Copy = context { - let tcx = self.tcx(); - let trait_ref = ty::TraitRef { - def_id: tcx.lang_items().copy_trait().unwrap(), - substs: tcx.mk_substs_trait(place_ty.to_ty(tcx), &[]), - }; - - // In order to have a Copy operand, the type T of the value must be Copy. Note that we - // prove that T: Copy, rather than using the type_moves_by_default test. This is - // important because type_moves_by_default ignores the resulting region obligations and - // assumes they pass. This can result in bounds from Copy impls being unsoundly ignored - // (e.g., #29149). Note that we decide to use Copy before knowing whether the bounds - // fully apply: in effect, the rule is that if a value of some type could implement - // Copy, then it must. - self.cx.prove_trait_ref(trait_ref, location); + let ty = place_ty.to_ty(self.tcx()); + if self.cx + .infcx + .type_moves_by_default(self.cx.param_env, ty, DUMMY_SP) + { + span_mirbug!(self, place, "attempted copy of non-Copy type ({:?})", ty); + } } place_ty } @@ -540,17 +533,15 @@ impl<'a, 'b, 'gcx, 'tcx> TypeVerifier<'a, 'b, 'gcx, 'tcx> { } } ty::TyGenerator(def_id, substs, _) => { - // Try pre-transform fields first (upvars and current state) - if let Some(ty) = substs.pre_transforms_tys(def_id, tcx).nth(field.index()) { + // Try upvars first. `field_tys` requires final optimized MIR. + if let Some(ty) = substs.upvar_tys(def_id, tcx).nth(field.index()) { return Ok(ty); } - // Then try `field_tys` which contains all the fields, but it - // requires the final optimized MIR. return match substs.field_tys(def_id, tcx).nth(field.index()) { Some(ty) => Ok(ty), None => Err(FieldAccessError::OutOfRange { - field_count: substs.field_tys(def_id, tcx).count(), + field_count: substs.field_tys(def_id, tcx).count() + 1, }), }; } @@ -796,8 +787,7 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { | TerminatorKind::GeneratorDrop | TerminatorKind::Unreachable | TerminatorKind::Drop { .. } - | TerminatorKind::FalseEdges { .. } - | TerminatorKind::FalseUnwind { .. } => { + | TerminatorKind::FalseEdges { .. } => { // no checks needed for these } @@ -1153,18 +1143,6 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { self.assert_iscleanup(mir, block_data, *target, is_cleanup); } } - TerminatorKind::FalseUnwind { - real_target, - unwind - } => { - self.assert_iscleanup(mir, block_data, real_target, is_cleanup); - if let Some(unwind) = unwind { - if is_cleanup { - span_mirbug!(self, block_data, "cleanup in cleanup block via false unwind"); - } - self.assert_iscleanup(mir, block_data, unwind, true); - } - } } } @@ -1255,16 +1233,13 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { } } AggregateKind::Generator(def_id, substs, _) => { - // Try pre-transform fields first (upvars and current state) - if let Some(ty) = substs.pre_transforms_tys(def_id, tcx).nth(field_index) { + if let Some(ty) = substs.upvar_tys(def_id, tcx).nth(field_index) { Ok(ty) } else { - // Then try `field_tys` which contains all the fields, but it - // requires the final optimized MIR. match substs.field_tys(def_id, tcx).nth(field_index) { Some(ty) => Ok(ty), None => Err(FieldAccessError::OutOfRange { - field_count: substs.field_tys(def_id, tcx).count(), + field_count: substs.field_tys(def_id, tcx).count() + 1, }), } } diff --git a/src/librustc_mir/borrow_check/nll/universal_regions.rs b/src/librustc_mir/borrow_check/nll/universal_regions.rs index 668172749fecb..e47e3c728dff2 100644 --- a/src/librustc_mir/borrow_check/nll/universal_regions.rs +++ b/src/librustc_mir/borrow_check/nll/universal_regions.rs @@ -125,7 +125,7 @@ pub enum DefiningTy<'tcx> { /// The MIR represents some form of constant. The signature then /// is that it has no inputs and a single return value, which is /// the value of the constant. - Const(DefId, &'tcx Substs<'tcx>), + Const(Ty<'tcx>), } #[derive(Debug)] @@ -534,42 +534,34 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> { /// see `DefiningTy` for details. fn defining_ty(&self) -> DefiningTy<'tcx> { let tcx = self.infcx.tcx; + let closure_base_def_id = tcx.closure_base_def_id(self.mir_def_id); + let defining_ty = if self.mir_def_id == closure_base_def_id { + tcx.type_of(closure_base_def_id) + } else { + let tables = tcx.typeck_tables_of(self.mir_def_id); + tables.node_id_to_type(self.mir_hir_id) + }; + + let defining_ty = self.infcx + .replace_free_regions_with_nll_infer_vars(FR, &defining_ty); + match tcx.hir.body_owner_kind(self.mir_node_id) { - BodyOwnerKind::Fn => { - let defining_ty = if self.mir_def_id == closure_base_def_id { - tcx.type_of(closure_base_def_id) - } else { - let tables = tcx.typeck_tables_of(self.mir_def_id); - tables.node_id_to_type(self.mir_hir_id) - }; - - let defining_ty = self.infcx - .replace_free_regions_with_nll_infer_vars(FR, &defining_ty); - - match defining_ty.sty { - ty::TyClosure(def_id, substs) => DefiningTy::Closure(def_id, substs), - ty::TyGenerator(def_id, substs, interior) => { - DefiningTy::Generator(def_id, substs, interior) - } - ty::TyFnDef(def_id, substs) => DefiningTy::FnDef(def_id, substs), - _ => span_bug!( - tcx.def_span(self.mir_def_id), - "expected defining type for `{:?}`: `{:?}`", - self.mir_def_id, - defining_ty - ), + BodyOwnerKind::Fn => match defining_ty.sty { + ty::TyClosure(def_id, substs) => DefiningTy::Closure(def_id, substs), + ty::TyGenerator(def_id, substs, interior) => { + DefiningTy::Generator(def_id, substs, interior) } - } - - BodyOwnerKind::Const | BodyOwnerKind::Static(..) => { - assert_eq!(closure_base_def_id, self.mir_def_id); - let identity_substs = Substs::identity_for_item(tcx, closure_base_def_id); - let substs = self.infcx - .replace_free_regions_with_nll_infer_vars(FR, &identity_substs); - DefiningTy::Const(self.mir_def_id, substs) - } + ty::TyFnDef(def_id, substs) => DefiningTy::FnDef(def_id, substs), + _ => span_bug!( + tcx.def_span(self.mir_def_id), + "expected defining type for `{:?}`: `{:?}`", + self.mir_def_id, + defining_ty + ), + }, + BodyOwnerKind::Const | BodyOwnerKind::Static(..) => DefiningTy::Const(defining_ty), } } @@ -600,7 +592,13 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> { substs.substs } - DefiningTy::FnDef(_, substs) | DefiningTy::Const(_, substs) => substs, + DefiningTy::FnDef(_, substs) => substs, + + // When we encounter a constant body, just return whatever + // substitutions are in scope for that constant. + DefiningTy::Const(_) => { + identity_substs + } }; let global_mapping = iter::once((gcx.types.re_static, fr_static)); @@ -662,14 +660,9 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> { sig.inputs_and_output() } - DefiningTy::Const(def_id, _) => { - // For a constant body, there are no inputs, and one - // "output" (the type of the constant). - assert_eq!(self.mir_def_id, def_id); - let ty = tcx.type_of(def_id); - let ty = indices.fold_to_region_vids(tcx, &ty); - ty::Binder::dummy(tcx.mk_type_list(iter::once(ty))) - } + // For a constant body, there are no inputs, and one + // "output" (the type of the constant). + DefiningTy::Const(ty) => ty::Binder::dummy(tcx.mk_type_list(iter::once(ty))), } } diff --git a/src/librustc_mir/build/expr/into.rs b/src/librustc_mir/build/expr/into.rs index 28dc329e4fe7c..68b23d1ae17e8 100644 --- a/src/librustc_mir/build/expr/into.rs +++ b/src/librustc_mir/build/expr/into.rs @@ -104,8 +104,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // Or: // // [block: If(lhs)] -false-> [else_block: If(rhs)] -true-> [true_block] - // | (true) | (false) - // [true_block] [false_block] + // | | (false) + // +----------true------------+-------------------> [false_block] let (true_block, false_block, mut else_block, join_block) = (this.cfg.start_new_block(), this.cfg.start_new_block(), @@ -147,24 +147,20 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { join_block.unit() } ExprKind::Loop { condition: opt_cond_expr, body } => { - // [block] --> [loop_block] -/eval. cond./-> [loop_block_end] -1-> [exit_block] - // ^ | - // | 0 - // | | - // | v - // [body_block_end] <-/eval. body/-- [body_block] + // [block] --> [loop_block] ~~> [loop_block_end] -1-> [exit_block] + // ^ | + // | 0 + // | | + // | v + // [body_block_end] <~~~ [body_block] // // If `opt_cond_expr` is `None`, then the graph is somewhat simplified: // - // [block] - // | - // [loop_block] -> [body_block] -/eval. body/-> [body_block_end] - // | ^ | - // false link | | - // | +-----------------------------------------+ - // +-> [diverge_cleanup] - // The false link is required to make sure borrowck considers unwinds through the - // body, even when the exact code in the body cannot unwind + // [block] --> [loop_block / body_block ] ~~> [body_block_end] [exit_block] + // ^ | + // | | + // +--------------------------+ + // let loop_block = this.cfg.start_new_block(); let exit_block = this.cfg.start_new_block(); @@ -192,13 +188,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { // always `()` anyway this.cfg.push_assign_unit(exit_block, source_info, destination); } else { - body_block = this.cfg.start_new_block(); - let diverge_cleanup = this.diverge_cleanup(); - this.cfg.terminate(loop_block, source_info, - TerminatorKind::FalseUnwind { - real_target: body_block, - unwind: Some(diverge_cleanup) - }) + body_block = loop_block; } // The “return” value of the loop body must always be an unit. We therefore diff --git a/src/librustc_mir/build/matches/mod.rs b/src/librustc_mir/build/matches/mod.rs index 8053a0a69484f..6cb9217776648 100644 --- a/src/librustc_mir/build/matches/mod.rs +++ b/src/librustc_mir/build/matches/mod.rs @@ -38,22 +38,6 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { -> BlockAnd<()> { let discriminant_place = unpack!(block = self.as_place(block, discriminant)); - // Matching on a `discriminant_place` with an uninhabited type doesn't - // generate any memory reads by itself, and so if the place "expression" - // contains unsafe operations like raw pointer dereferences or union - // field projections, we wouldn't know to require an `unsafe` block - // around a `match` equivalent to `std::intrinsics::unreachable()`. - // See issue #47412 for this hole being discovered in the wild. - // - // HACK(eddyb) Work around the above issue by adding a dummy inspection - // of `discriminant_place`, specifically by applying `Rvalue::Discriminant` - // (which will work regardless of type) and storing the result in a temp. - let dummy_source_info = self.source_info(span); - let dummy_access = Rvalue::Discriminant(discriminant_place.clone()); - let dummy_ty = dummy_access.ty(&self.local_decls, self.hir.tcx()); - let dummy_temp = self.temp(dummy_ty, dummy_source_info.span); - self.cfg.push_assign(block, dummy_source_info, &dummy_temp, dummy_access); - let mut arm_blocks = ArmBlocks { blocks: arms.iter() .map(|_| self.cfg.start_new_block()) @@ -744,8 +728,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { TerminatorKind::FalseEdges { real_target: block, imaginary_targets: - vec![candidate.next_candidate_pre_binding_block], - }); + vec![candidate.next_candidate_pre_binding_block]}); self.bind_matched_candidate(block, candidate.bindings); @@ -766,8 +749,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { TerminatorKind::FalseEdges { real_target: otherwise, imaginary_targets: - vec![candidate.next_candidate_pre_binding_block], - }); + vec![candidate.next_candidate_pre_binding_block] }); Some(otherwise) } else { self.cfg.terminate(block, candidate_source_info, diff --git a/src/librustc_mir/dataflow/impls/borrowed_locals.rs b/src/librustc_mir/dataflow/impls/borrowed_locals.rs deleted file mode 100644 index 244e8b5ccd7e4..0000000000000 --- a/src/librustc_mir/dataflow/impls/borrowed_locals.rs +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub use super::*; - -use rustc::mir::*; -use rustc::mir::visit::Visitor; -use dataflow::BitDenotation; - -/// This calculates if any part of a MIR local could have previously been borrowed. -/// This means that once a local has been borrowed, its bit will always be set -/// from that point and onwards, even if the borrow ends. You could also think of this -/// as computing the lifetimes of infinite borrows. -/// This is used to compute which locals are live during a yield expression for -/// immovable generators. -#[derive(Copy, Clone)] -pub struct HaveBeenBorrowedLocals<'a, 'tcx: 'a> { - mir: &'a Mir<'tcx>, -} - -impl<'a, 'tcx: 'a> HaveBeenBorrowedLocals<'a, 'tcx> { - pub fn new(mir: &'a Mir<'tcx>) - -> Self { - HaveBeenBorrowedLocals { mir: mir } - } - - pub fn mir(&self) -> &Mir<'tcx> { - self.mir - } -} - -impl<'a, 'tcx> BitDenotation for HaveBeenBorrowedLocals<'a, 'tcx> { - type Idx = Local; - fn name() -> &'static str { "has_been_borrowed_locals" } - fn bits_per_block(&self) -> usize { - self.mir.local_decls.len() - } - - fn start_block_effect(&self, _sets: &mut IdxSet) { - // Nothing is borrowed on function entry - } - - fn statement_effect(&self, - sets: &mut BlockSets, - loc: Location) { - BorrowedLocalsVisitor { - sets, - }.visit_statement(loc.block, &self.mir[loc.block].statements[loc.statement_index], loc); - } - - fn terminator_effect(&self, - sets: &mut BlockSets, - loc: Location) { - BorrowedLocalsVisitor { - sets, - }.visit_terminator(loc.block, self.mir[loc.block].terminator(), loc); - } - - fn propagate_call_return(&self, - _in_out: &mut IdxSet, - _call_bb: mir::BasicBlock, - _dest_bb: mir::BasicBlock, - _dest_place: &mir::Place) { - // Nothing to do when a call returns successfully - } -} - -impl<'a, 'tcx> BitwiseOperator for HaveBeenBorrowedLocals<'a, 'tcx> { - #[inline] - fn join(&self, pred1: usize, pred2: usize) -> usize { - pred1 | pred2 // "maybe" means we union effects of both preds - } -} - -impl<'a, 'tcx> InitialFlow for HaveBeenBorrowedLocals<'a, 'tcx> { - #[inline] - fn bottom_value() -> bool { - false // bottom = unborrowed - } -} - -struct BorrowedLocalsVisitor<'b, 'c: 'b> { - sets: &'b mut BlockSets<'c, Local>, -} - -fn find_local<'tcx>(place: &Place<'tcx>) -> Option { - match *place { - Place::Local(l) => Some(l), - Place::Static(..) => None, - Place::Projection(ref proj) => { - match proj.elem { - ProjectionElem::Deref => None, - _ => find_local(&proj.base) - } - } - } -} - -impl<'tcx, 'b, 'c> Visitor<'tcx> for BorrowedLocalsVisitor<'b, 'c> { - fn visit_rvalue(&mut self, - rvalue: &Rvalue<'tcx>, - location: Location) { - if let Rvalue::Ref(_, _, ref place) = *rvalue { - if let Some(local) = find_local(place) { - self.sets.gen(&local); - } - } - - self.super_rvalue(rvalue, location) - } -} diff --git a/src/librustc_mir/dataflow/impls/borrows.rs b/src/librustc_mir/dataflow/impls/borrows.rs index e798cc93cb09a..632bb5b34284d 100644 --- a/src/librustc_mir/dataflow/impls/borrows.rs +++ b/src/librustc_mir/dataflow/impls/borrows.rs @@ -122,7 +122,7 @@ impl<'tcx> fmt::Display for BorrowData<'tcx> { let kind = match self.kind { mir::BorrowKind::Shared => "", mir::BorrowKind::Unique => "uniq ", - mir::BorrowKind::Mut { .. } => "mut ", + mir::BorrowKind::Mut => "mut ", }; let region = format!("{}", self.region); let region = if region.len() > 0 { format!("{} ", region) } else { region }; @@ -396,7 +396,8 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> { // Issue #46746: Two-phase borrows handles // stmts of form `Tmp = &mut Borrow` ... match lhs { - Place::Local(..) | Place::Static(..) => {} // okay + Place::Local(..) => {} // okay + Place::Static(..) => unreachable!(), // (filtered by is_unsafe_place) Place::Projection(..) => { // ... can assign into projections, // e.g. `box (&mut _)`. Current @@ -517,7 +518,6 @@ impl<'a, 'gcx, 'tcx> Borrows<'a, 'gcx, 'tcx> { mir::TerminatorKind::Yield {..} | mir::TerminatorKind::Goto {..} | mir::TerminatorKind::FalseEdges {..} | - mir::TerminatorKind::FalseUnwind {..} | mir::TerminatorKind::Unreachable => {} } } diff --git a/src/librustc_mir/dataflow/impls/mod.rs b/src/librustc_mir/dataflow/impls/mod.rs index c5f5492cd2c2c..e7c15625cbe2b 100644 --- a/src/librustc_mir/dataflow/impls/mod.rs +++ b/src/librustc_mir/dataflow/impls/mod.rs @@ -33,10 +33,6 @@ mod storage_liveness; pub use self::storage_liveness::*; -mod borrowed_locals; - -pub use self::borrowed_locals::*; - #[allow(dead_code)] pub(super) mod borrows; diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs index 9c7d9b398cc56..bd63198ecd0d2 100644 --- a/src/librustc_mir/dataflow/mod.rs +++ b/src/librustc_mir/dataflow/mod.rs @@ -30,7 +30,6 @@ pub use self::impls::{MaybeInitializedPlaces, MaybeUninitializedPlaces}; pub use self::impls::{DefinitelyInitializedPlaces, MovingOutStatements}; pub use self::impls::EverInitializedPlaces; pub use self::impls::borrows::{Borrows, BorrowData}; -pub use self::impls::HaveBeenBorrowedLocals; pub(crate) use self::impls::borrows::{ActiveBorrows, Reservations, ReserveOrActivateIndex}; pub use self::at_location::{FlowAtLocation, FlowsAtLocation}; pub(crate) use self::drop_flag_effects::*; @@ -864,14 +863,6 @@ impl<'a, 'tcx: 'a, D> DataflowAnalysis<'a, 'tcx, D> where D: BitDenotation self.propagate_bits_into_entry_set_for(in_out, changed, target); } } - mir::TerminatorKind::FalseUnwind { ref real_target, unwind } => { - self.propagate_bits_into_entry_set_for(in_out, changed, real_target); - if let Some(ref unwind) = unwind { - if !self.dead_unwinds.contains(&bb) { - self.propagate_bits_into_entry_set_for(in_out, changed, unwind); - } - } - } } } diff --git a/src/librustc_mir/dataflow/move_paths/builder.rs b/src/librustc_mir/dataflow/move_paths/builder.rs index 635d99e7737a9..cd36282eca0a6 100644 --- a/src/librustc_mir/dataflow/move_paths/builder.rs +++ b/src/librustc_mir/dataflow/move_paths/builder.rs @@ -346,7 +346,6 @@ impl<'b, 'a, 'gcx, 'tcx> Gatherer<'b, 'a, 'gcx, 'tcx> { TerminatorKind::Abort | TerminatorKind::GeneratorDrop | TerminatorKind::FalseEdges { .. } | - TerminatorKind::FalseUnwind { .. } | TerminatorKind::Unreachable => { } TerminatorKind::Return => { diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index 00ab2e4599528..848c2d3c811e9 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -17,11 +17,10 @@ use hair::cx::to_ref::ToRef; use rustc::hir::def::{Def, CtorKind}; use rustc::middle::const_val::ConstVal; use rustc::ty::{self, AdtKind, VariantDef, Ty}; -use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability}; +use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow}; use rustc::ty::cast::CastKind as TyCastKind; use rustc::hir; use rustc::hir::def_id::LocalDefId; -use rustc::mir::{BorrowKind}; impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr { type Output = Expr<'tcx>; @@ -112,7 +111,7 @@ fn apply_adjustment<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, span, kind: ExprKind::Borrow { region: deref.region, - borrow_kind: deref.mutbl.to_borrow_kind(), + borrow_kind: to_borrow_kind(deref.mutbl), arg: expr.to_ref(), }, }; @@ -122,7 +121,7 @@ fn apply_adjustment<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, Adjust::Borrow(AutoBorrow::Ref(r, m)) => { ExprKind::Borrow { region: r, - borrow_kind: m.to_borrow_kind(), + borrow_kind: to_borrow_kind(m), arg: expr.to_ref(), } } @@ -142,43 +141,11 @@ fn apply_adjustment<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, span, kind: ExprKind::Borrow { region, - borrow_kind: m.to_borrow_kind(), + borrow_kind: to_borrow_kind(m), arg: expr.to_ref(), }, }; - let cast_expr = Expr { - temp_lifetime, - ty: adjustment.target, - span, - kind: ExprKind::Cast { source: expr.to_ref() } - }; - - // To ensure that both implicit and explicit coercions are - // handled the same way, we insert an extra layer of indirection here. - // For explicit casts (e.g. 'foo as *const T'), the source of the 'Use' - // will be an ExprKind::Hair with the appropriate cast expression. Here, - // we make our Use source the generated Cast from the original coercion. - // - // In both cases, this outer 'Use' ensures that the inner 'Cast' is handled by - // as_operand, not by as_rvalue - causing the cast result to be stored in a temporary. - // Ordinary, this is identical to using the cast directly as an rvalue. However, if the - // source of the cast was previously borrowed as mutable, storing the cast in a - // temporary gives the source a chance to expire before the cast is used. For - // structs with a self-referential *mut ptr, this allows assignment to work as - // expected. - // - // For example, consider the type 'struct Foo { field: *mut Foo }', - // The method 'fn bar(&mut self) { self.field = self }' - // triggers a coercion from '&mut self' to '*mut self'. In order - // for the assignment to be valid, the implicit borrow - // of 'self' involved in the coercion needs to end before the local - // containing the '*mut T' is assigned to 'self.field' - otherwise, - // we end up trying to assign to 'self.field' while we have another mutable borrow - // active. - // - // We only need to worry about this kind of thing for coercions from refs to ptrs, - // since they get rid of a borrow implicitly. - ExprKind::Use { source: cast_expr.to_ref() } + ExprKind::Cast { source: expr.to_ref() } } Adjust::Unsize => { ExprKind::Unsize { source: expr.to_ref() } @@ -288,7 +255,7 @@ fn make_mirror_unadjusted<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, }; ExprKind::Borrow { region, - borrow_kind: mutbl.to_borrow_kind(), + borrow_kind: to_borrow_kind(mutbl), arg: expr.to_ref(), } } @@ -643,25 +610,10 @@ fn method_callee<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, } } -trait ToBorrowKind { fn to_borrow_kind(&self) -> BorrowKind; } - -impl ToBorrowKind for AutoBorrowMutability { - fn to_borrow_kind(&self) -> BorrowKind { - match *self { - AutoBorrowMutability::Mutable { allow_two_phase_borrow } => - BorrowKind::Mut { allow_two_phase_borrow }, - AutoBorrowMutability::Immutable => - BorrowKind::Shared, - } - } -} - -impl ToBorrowKind for hir::Mutability { - fn to_borrow_kind(&self) -> BorrowKind { - match *self { - hir::MutMutable => BorrowKind::Mut { allow_two_phase_borrow: false }, - hir::MutImmutable => BorrowKind::Shared, - } +fn to_borrow_kind(m: hir::Mutability) -> BorrowKind { + match m { + hir::MutMutable => BorrowKind::Mut, + hir::MutImmutable => BorrowKind::Shared, } } @@ -963,7 +915,7 @@ fn capture_freevar<'a, 'gcx, 'tcx>(cx: &mut Cx<'a, 'gcx, 'tcx>, let borrow_kind = match upvar_borrow.kind { ty::BorrowKind::ImmBorrow => BorrowKind::Shared, ty::BorrowKind::UniqueImmBorrow => BorrowKind::Unique, - ty::BorrowKind::MutBorrow => BorrowKind::Mut { allow_two_phase_borrow: false } + ty::BorrowKind::MutBorrow => BorrowKind::Mut, }; Expr { temp_lifetime, diff --git a/src/librustc_mir/interpret/const_eval.rs b/src/librustc_mir/interpret/const_eval.rs index d3b084fde6ab8..2913f72460e3e 100644 --- a/src/librustc_mir/interpret/const_eval.rs +++ b/src/librustc_mir/interpret/const_eval.rs @@ -243,12 +243,6 @@ impl<'tcx> super::Machine<'tcx> for CompileTimeEvaluator { ecx.write_primval(dest, PrimVal::from_u128(size), dest_layout.ty)?; } - "type_id" => { - let ty = substs.type_at(0); - let type_id = ecx.tcx.type_id_hash(ty) as u128; - ecx.write_primval(dest, PrimVal::from_u128(type_id), dest_layout.ty)?; - } - name => return Err(ConstEvalError::NeedsRfc(format!("calling intrinsic `{}`", name)).into()), } diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 52b87282180c4..baec0fea50f1e 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -172,7 +172,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> LayoutOf> for &'a EvalContext<'a, 'tcx type TyLayout = EvalResult<'tcx, TyLayout<'tcx>>; fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout { - self.tcx.layout_of(self.param_env.and(ty)) + (self.tcx, self.param_env).layout_of(ty) .map_err(|layout| EvalErrorKind::Layout(layout).into()) } } @@ -716,10 +716,6 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { ReifyFnPointer => { match self.eval_operand(operand)?.ty.sty { ty::TyFnDef(def_id, substs) => { - if self.tcx.has_attr(def_id, "rustc_args_required_const") { - bug!("reifying a fn ptr that requires \ - const arguments"); - } let instance = self.resolve(def_id, substs)?; let fn_ptr = self.memory.create_fn_alloc(instance); let valty = ValTy { diff --git a/src/librustc_mir/interpret/terminator/mod.rs b/src/librustc_mir/interpret/terminator/mod.rs index 606bda51edb1f..c8a0dbdd90308 100644 --- a/src/librustc_mir/interpret/terminator/mod.rs +++ b/src/librustc_mir/interpret/terminator/mod.rs @@ -165,7 +165,6 @@ impl<'a, 'tcx, M: Machine<'tcx>> EvalContext<'a, 'tcx, M> { Resume => unimplemented!(), Abort => unimplemented!(), FalseEdges { .. } => bug!("should have been eliminated by `simplify_branches` mir pass"), - FalseUnwind { .. } => bug!("should have been eliminated by `simplify_branches` mir pass"), Unreachable => return err!(Unreachable), } diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index a80dfaef0dab1..f16187797d4e5 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -636,8 +636,7 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { mir::TerminatorKind::Assert { .. } => {} mir::TerminatorKind::GeneratorDrop | mir::TerminatorKind::Yield { .. } | - mir::TerminatorKind::FalseEdges { .. } | - mir::TerminatorKind::FalseUnwind { .. } => bug!(), + mir::TerminatorKind::FalseEdges { .. } => bug!(), } self.super_terminator_kind(block, kind, location); diff --git a/src/librustc_mir/monomorphize/partitioning.rs b/src/librustc_mir/monomorphize/partitioning.rs index e9471cdb4f949..806d787c84522 100644 --- a/src/librustc_mir/monomorphize/partitioning.rs +++ b/src/librustc_mir/monomorphize/partitioning.rs @@ -107,7 +107,6 @@ use rustc::dep_graph::WorkProductId; use rustc::hir::def_id::DefId; use rustc::hir::map::DefPathData; use rustc::mir::mono::{Linkage, Visibility}; -use rustc::middle::exported_symbols::SymbolExportLevel; use rustc::ty::{self, TyCtxt, InstanceDef}; use rustc::ty::item_path::characteristic_def_id_of_type; use rustc::util::nodemap::{FxHashMap, FxHashSet}; @@ -323,16 +322,7 @@ fn place_root_translation_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>, .or_insert_with(make_codegen_unit); let mut can_be_internalized = true; - let default_visibility = |id: DefId| { - if tcx.sess.target.target.options.default_hidden_visibility && - tcx.symbol_export_level(id) != SymbolExportLevel::C - { - Visibility::Hidden - } else { - Visibility::Default - } - }; - let (linkage, mut visibility) = match trans_item.explicit_linkage(tcx) { + let (linkage, visibility) = match trans_item.explicit_linkage(tcx) { Some(explicit_linkage) => (explicit_linkage, Visibility::Default), None => { match trans_item { @@ -362,8 +352,7 @@ fn place_root_translation_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>, Visibility::Hidden } else if def_id.is_local() { if tcx.is_exported_symbol(def_id) { - can_be_internalized = false; - default_visibility(def_id) + Visibility::Default } else { Visibility::Hidden } @@ -386,8 +375,7 @@ fn place_root_translation_items<'a, 'tcx, I>(tcx: TyCtxt<'a, 'tcx, 'tcx>, MonoItem::GlobalAsm(node_id) => { let def_id = tcx.hir.local_def_id(node_id); let visibility = if tcx.is_exported_symbol(def_id) { - can_be_internalized = false; - default_visibility(def_id) + Visibility::Default } else { Visibility::Hidden }; diff --git a/src/librustc_mir/shim.rs b/src/librustc_mir/shim.rs index e6ebdd3d6c167..c206d0ea9b5fd 100644 --- a/src/librustc_mir/shim.rs +++ b/src/librustc_mir/shim.rs @@ -294,25 +294,22 @@ fn build_clone_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, { debug!("build_clone_shim(def_id={:?})", def_id); - let mut builder = CloneShimBuilder::new(tcx, def_id, self_ty); + let mut builder = CloneShimBuilder::new(tcx, def_id); let is_copy = !self_ty.moves_by_default(tcx, tcx.param_env(def_id), builder.span); - let dest = Place::Local(RETURN_PLACE); - let src = Place::Local(Local::new(1+0)).deref(); - match self_ty.sty { _ if is_copy => builder.copy_shim(), ty::TyArray(ty, len) => { let len = len.val.to_const_int().unwrap().to_u64().unwrap(); - builder.array_shim(dest, src, ty, len) + builder.array_shim(ty, len) } ty::TyClosure(def_id, substs) => { builder.tuple_like_shim( - dest, src, - substs.upvar_tys(def_id, tcx) + &substs.upvar_tys(def_id, tcx).collect::>(), + AggregateKind::Closure(def_id, substs) ) } - ty::TyTuple(tys, _) => builder.tuple_like_shim(dest, src, tys.iter().cloned()), + ty::TyTuple(tys, _) => builder.tuple_like_shim(&**tys, AggregateKind::Tuple), _ => { bug!("clone shim for `{:?}` which is not `Copy` and is not an aggregate", self_ty) } @@ -331,14 +328,8 @@ struct CloneShimBuilder<'a, 'tcx: 'a> { } impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { - fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, - def_id: DefId, - self_ty: Ty<'tcx>) -> Self { - // we must subst the self_ty because it's - // otherwise going to be TySelf and we can't index - // or access fields of a Place of type TySelf. - let substs = tcx.mk_substs_trait(self_ty, &[]); - let sig = tcx.fn_sig(def_id).subst(tcx, substs); + fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Self { + let sig = tcx.fn_sig(def_id); let sig = tcx.erase_late_bound_regions(&sig); let span = tcx.def_span(def_id); @@ -386,14 +377,6 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { }) } - /// Gives the index of an upcoming BasicBlock, with an offset. - /// offset=0 will give you the index of the next BasicBlock, - /// offset=1 will give the index of the next-to-next block, - /// offset=-1 will give you the index of the last-created block - fn block_index_offset(&mut self, offset: usize) -> BasicBlock { - BasicBlock::new(self.blocks.len() + offset) - } - fn make_statement(&self, kind: StatementKind<'tcx>) -> Statement<'tcx> { Statement { source_info: self.source_info(), @@ -421,12 +404,11 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { fn make_clone_call( &mut self, - dest: Place<'tcx>, - src: Place<'tcx>, ty: Ty<'tcx>, + rcvr_field: Place<'tcx>, next: BasicBlock, cleanup: BasicBlock - ) { + ) -> Place<'tcx> { let tcx = self.tcx; let substs = Substs::for_item( @@ -457,11 +439,13 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { }) ); - // `let ref_loc: &ty = &src;` + let loc = self.make_place(Mutability::Not, ty); + + // `let ref_loc: &ty = &rcvr_field;` let statement = self.make_statement( StatementKind::Assign( ref_loc.clone(), - Rvalue::Ref(tcx.types.re_erased, BorrowKind::Shared, src) + Rvalue::Ref(tcx.types.re_erased, BorrowKind::Shared, rcvr_field) ) ); @@ -469,9 +453,11 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { self.block(vec![statement], TerminatorKind::Call { func, args: vec![Operand::Move(ref_loc)], - destination: Some((dest, next)), + destination: Some((loc.clone(), next)), cleanup: Some(cleanup), }, false); + + loc } fn loop_header( @@ -514,12 +500,14 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { } } - fn array_shim(&mut self, dest: Place<'tcx>, src: Place<'tcx>, ty: Ty<'tcx>, len: u64) { + fn array_shim(&mut self, ty: Ty<'tcx>, len: u64) { let tcx = self.tcx; let span = self.span; + let rcvr = Place::Local(Local::new(1+0)).deref(); let beg = self.local_decls.push(temp_decl(Mutability::Mut, tcx.types.usize, span)); let end = self.make_place(Mutability::Not, tcx.types.usize); + let ret = self.make_place(Mutability::Mut, tcx.mk_array(ty, len)); // BB #0 // `let mut beg = 0;` @@ -549,17 +537,23 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { self.loop_header(Place::Local(beg), end, BasicBlock::new(2), BasicBlock::new(4), false); // BB #2 - // `dest[i] = Clone::clone(src[beg])`; + // `let cloned = Clone::clone(rcvr[beg])`; // Goto #3 if ok, #5 if unwinding happens. - let dest_field = dest.clone().index(beg); - let src_field = src.clone().index(beg); - self.make_clone_call(dest_field, src_field, ty, BasicBlock::new(3), - BasicBlock::new(5)); + let rcvr_field = rcvr.clone().index(beg); + let cloned = self.make_clone_call(ty, rcvr_field, BasicBlock::new(3), BasicBlock::new(5)); // BB #3 + // `ret[beg] = cloned;` // `beg = beg + 1;` // `goto #1`; + let ret_field = ret.clone().index(beg); let statements = vec![ + self.make_statement( + StatementKind::Assign( + ret_field, + Rvalue::Use(Operand::Move(cloned)) + ) + ), self.make_statement( StatementKind::Assign( Place::Local(beg), @@ -574,8 +568,14 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { self.block(statements, TerminatorKind::Goto { target: BasicBlock::new(1) }, false); // BB #4 - // `return dest;` - self.block(vec![], TerminatorKind::Return, false); + // `return ret;` + let ret_statement = self.make_statement( + StatementKind::Assign( + Place::Local(RETURN_PLACE), + Rvalue::Use(Operand::Move(ret.clone())), + ) + ); + self.block(vec![ret_statement], TerminatorKind::Return, false); // BB #5 (cleanup) // `let end = beg;` @@ -600,9 +600,9 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { BasicBlock::new(7), BasicBlock::new(9), true); // BB #7 (cleanup) - // `drop(dest[beg])`; + // `drop(ret[beg])`; self.block(vec![], TerminatorKind::Drop { - location: dest.index(beg), + location: ret.index(beg), target: BasicBlock::new(8), unwind: None, }, true); @@ -626,50 +626,55 @@ impl<'a, 'tcx> CloneShimBuilder<'a, 'tcx> { self.block(vec![], TerminatorKind::Resume, true); } - fn tuple_like_shim(&mut self, dest: Place<'tcx>, - src: Place<'tcx>, tys: I) - where I: Iterator> { - let mut previous_field = None; - for (i, ity) in tys.enumerate() { - let field = Field::new(i); - let src_field = src.clone().field(field, ity); + fn tuple_like_shim(&mut self, tys: &[ty::Ty<'tcx>], kind: AggregateKind<'tcx>) { + match kind { + AggregateKind::Tuple | AggregateKind::Closure(..) => (), + _ => bug!("only tuples and closures are accepted"), + }; - let dest_field = dest.clone().field(field, ity); + let rcvr = Place::Local(Local::new(1+0)).deref(); - // #(2i + 1) is the cleanup block for the previous clone operation - let cleanup_block = self.block_index_offset(1); - // #(2i + 2) is the next cloning block - // (or the Return terminator if this is the last block) - let next_block = self.block_index_offset(2); + let mut returns = Vec::new(); + for (i, ity) in tys.iter().enumerate() { + let rcvr_field = rcvr.clone().field(Field::new(i), *ity); // BB #(2i) - // `dest.i = Clone::clone(&src.i);` + // `returns[i] = Clone::clone(&rcvr.i);` // Goto #(2i + 2) if ok, #(2i + 1) if unwinding happens. - self.make_clone_call( - dest_field.clone(), - src_field, - ity, - next_block, - cleanup_block, + returns.push( + self.make_clone_call( + *ity, + rcvr_field, + BasicBlock::new(2 * i + 2), + BasicBlock::new(2 * i + 1), + ) ); // BB #(2i + 1) (cleanup) - if let Some((previous_field, previous_cleanup)) = previous_field.take() { + if i == 0 { + // Nothing to drop, just resume. + self.block(vec![], TerminatorKind::Resume, true); + } else { // Drop previous field and goto previous cleanup block. self.block(vec![], TerminatorKind::Drop { - location: previous_field, - target: previous_cleanup, + location: returns[i - 1].clone(), + target: BasicBlock::new(2 * i - 1), unwind: None, }, true); - } else { - // Nothing to drop, just resume. - self.block(vec![], TerminatorKind::Resume, true); } - - previous_field = Some((dest_field, cleanup_block)); } - self.block(vec![], TerminatorKind::Return, false); + // `return kind(returns[0], returns[1], ..., returns[tys.len() - 1]);` + let ret_statement = self.make_statement( + StatementKind::Assign( + Place::Local(RETURN_PLACE), + Rvalue::Aggregate( + box kind, + returns.into_iter().map(Operand::Move).collect() + ) + ) + ); + self.block(vec![ret_statement], TerminatorKind::Return, false); } } @@ -716,14 +721,11 @@ fn build_call_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }), span )); - let borrow_kind = BorrowKind::Mut { - allow_two_phase_borrow: false, - }; statements.push(Statement { source_info, kind: StatementKind::Assign( Place::Local(ref_rcvr), - Rvalue::Ref(tcx.types.re_erased, borrow_kind, rcvr_l) + Rvalue::Ref(tcx.types.re_erased, BorrowKind::Mut, rcvr_l) ) }); Operand::Move(Place::Local(ref_rcvr)) diff --git a/src/librustc_mir/transform/check_unsafety.rs b/src/librustc_mir/transform/check_unsafety.rs index bbc7803b84d8e..ae27f54e618a1 100644 --- a/src/librustc_mir/transform/check_unsafety.rs +++ b/src/librustc_mir/transform/check_unsafety.rs @@ -76,8 +76,7 @@ impl<'a, 'tcx> Visitor<'tcx> for UnsafetyChecker<'a, 'tcx> { TerminatorKind::Abort | TerminatorKind::Return | TerminatorKind::Unreachable | - TerminatorKind::FalseEdges { .. } | - TerminatorKind::FalseUnwind { .. } => { + TerminatorKind::FalseEdges { .. } => { // safe (at least as emitted during MIR construction) } diff --git a/src/librustc_mir/transform/generator.rs b/src/librustc_mir/transform/generator.rs index 812665f5fa498..ebd34f81deb29 100644 --- a/src/librustc_mir/transform/generator.rs +++ b/src/librustc_mir/transform/generator.rs @@ -78,8 +78,7 @@ use std::mem; use transform::{MirPass, MirSource}; use transform::simplify; use transform::no_landing_pads::no_landing_pads; -use dataflow::{do_dataflow, DebugFormatted, state_for_location}; -use dataflow::{MaybeStorageLive, HaveBeenBorrowedLocals}; +use dataflow::{do_dataflow, DebugFormatted, MaybeStorageLive, state_for_location}; pub struct StateTransform; @@ -370,33 +369,17 @@ fn locals_live_across_suspend_points<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, HashMap) { let dead_unwinds = IdxSetBuf::new_empty(mir.basic_blocks().len()); let node_id = tcx.hir.as_local_node_id(source.def_id).unwrap(); - - // Calculate when MIR locals have live storage. This gives us an upper bound of their - // lifetimes. - let storage_live_analysis = MaybeStorageLive::new(mir); + let analysis = MaybeStorageLive::new(mir); let storage_live = - do_dataflow(tcx, mir, node_id, &[], &dead_unwinds, storage_live_analysis, + do_dataflow(tcx, mir, node_id, &[], &dead_unwinds, analysis, |bd, p| DebugFormatted::new(&bd.mir().local_decls[p])); - // Find the MIR locals which do not use StorageLive/StorageDead statements. - // The storage of these locals are always live. let mut ignored = StorageIgnored(IdxSetBuf::new_filled(mir.local_decls.len())); ignored.visit_mir(mir); - // Calculate the MIR locals which have been previously - // borrowed (even if they are still active). - // This is only used for immovable generators. - let borrowed_locals = if !movable { - let analysis = HaveBeenBorrowedLocals::new(mir); - let result = - do_dataflow(tcx, mir, node_id, &[], &dead_unwinds, analysis, - |bd, p| DebugFormatted::new(&bd.mir().local_decls[p])); - Some((analysis, result)) - } else { - None - }; + let mut borrowed_locals = BorrowedLocals(IdxSetBuf::new_empty(mir.local_decls.len())); + borrowed_locals.visit_mir(mir); - // Calculate the liveness of MIR locals ignoring borrows. let mut set = liveness::LocalSet::new_empty(mir.local_decls.len()); let mut liveness = liveness::liveness_of_locals(mir, LivenessMode { include_regular_use: true, @@ -413,41 +396,24 @@ fn locals_live_across_suspend_points<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, statement_index: data.statements.len(), }; - if let Some((ref analysis, ref result)) = borrowed_locals { - let borrowed_locals = state_for_location(loc, - analysis, - result, - mir); - // The `liveness` variable contains the liveness of MIR locals ignoring borrows. - // This is correct for movable generators since borrows cannot live across - // suspension points. However for immovable generators we need to account for - // borrows, so we conseratively assume that all borrowed locals live forever. - // To do this we just union our `liveness` result with `borrowed_locals`, which - // contains all the locals which has been borrowed before this suspension point. - // If a borrow is converted to a raw reference, we must also assume that it lives - // forever. Note that the final liveness is still bounded by the storage liveness - // of the local, which happens using the `intersect` operation below. - liveness.outs[block].union(&borrowed_locals); - } - - let mut storage_liveness = state_for_location(loc, - &storage_live_analysis, - &storage_live, - mir); + let storage_liveness = state_for_location(loc, &analysis, &storage_live, mir); - // Store the storage liveness for later use so we can restore the state - // after a suspension point storage_liveness_map.insert(block, storage_liveness.clone()); + let mut live_locals = storage_liveness; + // Mark locals without storage statements as always having live storage - storage_liveness.union(&ignored.0); + live_locals.union(&ignored.0); - // Locals live are live at this point only if they are used across - // suspension points (the `liveness` variable) - // and their storage is live (the `storage_liveness` variable) - storage_liveness.intersect(&liveness.outs[block]); + if !movable { + // For immovable generators we consider borrowed locals to always be live. + // This effectively makes those locals use just the storage liveness. + liveness.outs[block].union(&borrowed_locals.0); + } - let live_locals = storage_liveness; + // Locals live are live at this point only if they are used across suspension points + // and their storage is live + live_locals.intersect(&liveness.outs[block]); // Add the locals life at this suspension point to the set of locals which live across // any suspension points diff --git a/src/librustc_mir/transform/inline.rs b/src/librustc_mir/transform/inline.rs index 08a9757fb326a..43ee75d1e2ba2 100644 --- a/src/librustc_mir/transform/inline.rs +++ b/src/librustc_mir/transform/inline.rs @@ -19,6 +19,7 @@ use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc::mir::*; use rustc::mir::visit::*; use rustc::ty::{self, Instance, Ty, TyCtxt, TypeFoldable}; +use rustc::ty::layout::LayoutOf; use rustc::ty::subst::{Subst,Substs}; use std::collections::VecDeque; @@ -426,7 +427,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { debug!("Creating temp for return destination"); let dest = Rvalue::Ref( self.tcx.types.re_erased, - BorrowKind::Mut { allow_two_phase_borrow: false }, + BorrowKind::Mut, destination.0); let ty = dest.ty(caller_mir, self.tcx); @@ -511,7 +512,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { callsite: &CallSite<'tcx>, caller_mir: &mut Mir<'tcx>) -> Local { let arg = Rvalue::Ref( self.tcx.types.re_erased, - BorrowKind::Mut { allow_two_phase_borrow: false }, + BorrowKind::Mut, arg.deref()); let ty = arg.ty(caller_mir, self.tcx); @@ -654,7 +655,7 @@ impl<'a, 'tcx> Inliner<'a, 'tcx> { fn type_size_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, param_env: ty::ParamEnv<'tcx>, ty: Ty<'tcx>) -> Option { - tcx.layout_of(param_env.and(ty)).ok().map(|layout| layout.size.bytes()) + (tcx, param_env).layout_of(ty).ok().map(|layout| layout.size.bytes()) } fn subst_and_normalize<'a, 'tcx: 'a>( @@ -813,9 +814,6 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Integrator<'a, 'tcx> { *target = self.update_target(*target); } } - TerminatorKind::FalseUnwind { real_target: _ , unwind: _ } => - // see the ordering of passes in the optimized_mir query. - bug!("False unwinds should have been removed before inlining") } } diff --git a/src/librustc_mir/transform/promote_consts.rs b/src/librustc_mir/transform/promote_consts.rs index b732eeb624c6d..1545040f2da79 100644 --- a/src/librustc_mir/transform/promote_consts.rs +++ b/src/librustc_mir/transform/promote_consts.rs @@ -71,12 +71,9 @@ pub enum Candidate { /// Borrow of a constant temporary. Ref(Location), - /// Currently applied to function calls where the callee has the unstable - /// `#[rustc_args_required_const]` attribute as well as the SIMD shuffle - /// intrinsic. The intrinsic requires the arguments are indeed constant and - /// the attribute currently provides the semantic requirement that arguments - /// must be constant. - Argument { bb: BasicBlock, index: usize }, + /// Array of indices found in the third argument of + /// a call to one of the simd_shuffleN intrinsics. + ShuffleIndices(BasicBlock) } struct TempCollector<'tcx> { @@ -306,10 +303,10 @@ impl<'a, 'tcx> Promoter<'a, 'tcx> { _ => bug!() } } - Candidate::Argument { bb, index } => { + Candidate::ShuffleIndices(bb) => { match self.source[bb].terminator_mut().kind { TerminatorKind::Call { ref mut args, .. } => { - Rvalue::Use(mem::replace(&mut args[index], new_operand)) + Rvalue::Use(mem::replace(&mut args[2], new_operand)) } _ => bug!() } @@ -362,15 +359,15 @@ pub fn promote_candidates<'a, 'tcx>(mir: &mut Mir<'tcx>, } (statement.source_info.span, dest.ty(mir, tcx).to_ty(tcx)) } - Candidate::Argument { bb, index } => { + Candidate::ShuffleIndices(bb) => { let terminator = mir[bb].terminator(); let ty = match terminator.kind { TerminatorKind::Call { ref args, .. } => { - args[index].ty(mir, tcx) + args[2].ty(mir, tcx) } _ => { span_bug!(terminator.source_info.span, - "expected call argument to promote"); + "expected simd_shuffleN call to promote"); } }; (terminator.source_info.span, ty) diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 2b9ee223b01a4..b896e6ca85343 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -17,7 +17,6 @@ use rustc_data_structures::bitvec::BitVector; use rustc_data_structures::indexed_set::IdxSetBuf; use rustc_data_structures::indexed_vec::{IndexVec, Idx}; -use rustc_data_structures::fx::FxHashSet; use rustc::hir; use rustc::hir::def_id::DefId; use rustc::middle::const_val::ConstVal; @@ -31,7 +30,6 @@ use rustc::mir::visit::{PlaceContext, Visitor}; use rustc::middle::lang_items; use syntax::abi::Abi; use syntax::attr; -use syntax::ast::LitKind; use syntax::feature_gate::UnstableFeatures; use syntax_pos::{Span, DUMMY_SP}; @@ -170,20 +168,8 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { fn not_const(&mut self) { self.add(Qualif::NOT_CONST); if self.mode != Mode::Fn { - let mut err = struct_span_err!( - self.tcx.sess, - self.span, - E0019, - "{} contains unimplemented expression type", - self.mode - ); - if self.tcx.sess.teach(&err.get_code().unwrap()) { - err.note("A function call isn't allowed in the const's initialization expression \ - because the expression's value must be known at compile-time."); - err.note("Remember: you can't use a function call inside a const's initialization \ - expression! However, you can use it anywhere else."); - } - err.emit(); + span_err!(self.tcx.sess, self.span, E0019, + "{} contains unimplemented expression type", self.mode); } } @@ -191,19 +177,9 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { fn statement_like(&mut self) { self.add(Qualif::NOT_CONST); if self.mode != Mode::Fn { - let mut err = struct_span_err!( - self.tcx.sess, - self.span, - E0016, - "blocks in {}s are limited to items and tail expressions", - self.mode - ); - if self.tcx.sess.teach(&err.get_code().unwrap()) { - err.note("Blocks in constants may only contain items (such as constant, function \ - definition, etc...) and a tail expression."); - err.help("To avoid it, you have to replace the non-item object."); - } - err.emit(); + span_err!(self.tcx.sess, self.span, E0016, + "blocks in {}s are limited to items and tail expressions", + self.mode); } } @@ -351,8 +327,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } | TerminatorKind::Unreachable | - TerminatorKind::FalseEdges { .. } | - TerminatorKind::FalseUnwind { .. } => None, + TerminatorKind::FalseEdges { .. } => None, TerminatorKind::Return => { // Check for unused values. This usually means @@ -432,7 +407,7 @@ impl<'a, 'tcx> Qualifier<'a, 'tcx, 'tcx> { _ => {} } } - Candidate::Argument { .. } => {} + Candidate::ShuffleIndices(_) => {} } } @@ -497,19 +472,9 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } if self.mode == Mode::Const || self.mode == Mode::ConstFn { - let mut err = struct_span_err!(self.tcx.sess, self.span, E0013, - "{}s cannot refer to statics, use \ - a constant instead", self.mode); - if self.tcx.sess.teach(&err.get_code().unwrap()) { - err.note( - "Static and const variables can refer to other const variables. But a \ - const variable cannot refer to a static variable." - ); - err.help( - "To fix this, the value can be extracted as a const and then used." - ); - } - err.emit() + span_err!(self.tcx.sess, self.span, E0013, + "{}s cannot refer to statics, use \ + a constant instead", self.mode); } } Place::Projection(ref proj) => { @@ -530,25 +495,13 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { if let ty::TyRawPtr(_) = base_ty.sty { this.add(Qualif::NOT_CONST); if this.mode != Mode::Fn { - let mut err = struct_span_err!( - this.tcx.sess, - this.span, - E0396, + struct_span_err!(this.tcx.sess, + this.span, E0396, "raw pointers cannot be dereferenced in {}s", - this.mode - ); - err.span_label(this.span, - "dereference of raw pointer in constant"); - if this.tcx.sess.teach(&err.get_code().unwrap()) { - err.note( - "The value behind a raw pointer can't be determined \ - at compile-time (or even link-time), which means it \ - can't be used in a constant expression." - ); - err.help("A possible fix is to dereference your pointer \ - at some point in run-time."); - } - err.emit(); + this.mode) + .span_label(this.span, + "dereference of raw pointer in constant") + .emit(); } } } @@ -647,7 +600,7 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { } let ty = place.ty(self.mir, self.tcx).to_ty(self.tcx); - if let BorrowKind::Mut { .. } = kind { + if kind == BorrowKind::Mut { // In theory, any zero-sized value could be borrowed // mutably without consequences. However, only &mut [] // is allowed right now, and only in functions. @@ -667,22 +620,12 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { if !allow { self.add(Qualif::NOT_CONST); if self.mode != Mode::Fn { - let mut err = struct_span_err!(self.tcx.sess, self.span, E0017, - "references in {}s may only refer \ - to immutable values", self.mode); - err.span_label(self.span, format!("{}s require immutable values", - self.mode)); - if self.tcx.sess.teach(&err.get_code().unwrap()) { - err.note("References in statics and constants may only refer to \ - immutable values.\n\n\ - Statics are shared everywhere, and if they refer to \ - mutable data one might violate memory safety since \ - holding multiple mutable references to shared data is \ - not allowed.\n\n\ - If you really want global mutable state, try using \ - static mut or a global UnsafeCell."); - } - err.emit(); + struct_span_err!(self.tcx.sess, self.span, E0017, + "references in {}s may only refer \ + to immutable values", self.mode) + .span_label(self.span, format!("{}s require immutable values", + self.mode)) + .emit(); } } } else { @@ -723,42 +666,9 @@ impl<'a, 'tcx> Visitor<'tcx> for Qualifier<'a, 'tcx, 'tcx> { (CastTy::FnPtr, CastTy::Int(_)) => { self.add(Qualif::NOT_CONST); if self.mode != Mode::Fn { - let mut err = struct_span_err!( - self.tcx.sess, - self.span, - E0018, - "raw pointers cannot be cast to integers in {}s", - self.mode - ); - if self.tcx.sess.teach(&err.get_code().unwrap()) { - err.note("\ -The value of static and constant integers must be known at compile time. You can't cast a pointer \ -to an integer because the address of a pointer can vary. - -For example, if you write: - -``` -static MY_STATIC: u32 = 42; -static MY_STATIC_ADDR: usize = &MY_STATIC as *const _ as usize; -static WHAT: usize = (MY_STATIC_ADDR^17) + MY_STATIC_ADDR; -``` - -Then `MY_STATIC_ADDR` would contain the address of `MY_STATIC`. However, the address can change \ -when the program is linked, as well as change between different executions due to ASLR, and many \ -linkers would not be able to calculate the value of `WHAT`. - -On the other hand, static and constant pointers can point either to a known numeric address or to \ -the address of a symbol. - -``` -static MY_STATIC: u32 = 42; -static MY_STATIC_ADDR: &'static u32 = &MY_STATIC; -const CONST_ADDR: *const u8 = 0x5f3759df as *const u8; -``` - -This does not pose a problem by itself because they can't be accessed directly."); - } - err.emit(); + span_err!(self.tcx.sess, self.span, E0018, + "raw pointers cannot be cast to integers in {}s", + self.mode); } } _ => {} @@ -789,18 +699,10 @@ This does not pose a problem by itself because they can't be accessed directly." Rvalue::NullaryOp(NullOp::Box, _) => { self.add(Qualif::NOT_CONST); if self.mode != Mode::Fn { - let mut err = struct_span_err!(self.tcx.sess, self.span, E0010, - "allocations are not allowed in {}s", self.mode); - err.span_label(self.span, format!("allocation not allowed in {}s", self.mode)); - if self.tcx.sess.teach(&err.get_code().unwrap()) { - err.note( - "The value of statics and constants must be known at compile time, \ - and they live for the entire lifetime of a program. Creating a boxed \ - value allocates memory on the heap at runtime, and therefore cannot \ - be done at compile time." - ); - } - err.emit(); + struct_span_err!(self.tcx.sess, self.span, E0010, + "allocations are not allowed in {}s", self.mode) + .span_label(self.span, format!("allocation not allowed in {}s", self.mode)) + .emit(); } } @@ -828,16 +730,14 @@ This does not pose a problem by itself because they can't be accessed directly." self.visit_operand(func, location); let fn_ty = func.ty(self.mir, self.tcx); - let mut callee_def_id = None; let (mut is_shuffle, mut is_const_fn) = (false, None); if let ty::TyFnDef(def_id, _) = fn_ty.sty { - callee_def_id = Some(def_id); match self.tcx.fn_sig(def_id).abi() { Abi::RustIntrinsic | Abi::PlatformIntrinsic => { assert!(!self.tcx.is_const_fn(def_id)); match &self.tcx.item_name(def_id)[..] { - "size_of" | "min_align_of" | "type_id" => is_const_fn = Some(def_id), + "size_of" | "min_align_of" => is_const_fn = Some(def_id), name if name.starts_with("simd_shuffle") => { is_shuffle = true; @@ -854,39 +754,17 @@ This does not pose a problem by itself because they can't be accessed directly." } } - let constant_arguments = callee_def_id.and_then(|id| { - args_required_const(self.tcx, id) - }); for (i, arg) in args.iter().enumerate() { self.nest(|this| { this.visit_operand(arg, location); - if this.mode != Mode::Fn { - return - } - let candidate = Candidate::Argument { bb, index: i }; - if is_shuffle && i == 2 { + if is_shuffle && i == 2 && this.mode == Mode::Fn { + let candidate = Candidate::ShuffleIndices(bb); if this.can_promote() { this.promotion_candidates.push(candidate); } else { span_err!(this.tcx.sess, this.span, E0526, "shuffle indices are not constant"); } - return - } - - let constant_arguments = match constant_arguments.as_ref() { - Some(s) => s, - None => return, - }; - if !constant_arguments.contains(&i) { - return - } - if this.can_promote() { - this.promotion_candidates.push(candidate); - } else { - this.tcx.sess.span_err(this.span, - &format!("argument {} is required to be a constant", - i + 1)); } }); } @@ -1026,22 +904,9 @@ This does not pose a problem by itself because they can't be accessed directly." // Avoid a generic error for other uses of arguments. if self.qualif.intersects(Qualif::FN_ARGUMENT) { let decl = &self.mir.local_decls[index]; - let mut err = struct_span_err!( - self.tcx.sess, - decl.source_info.span, - E0022, - "arguments of constant functions can only be immutable by-value bindings" - ); - if self.tcx.sess.teach(&err.get_code().unwrap()) { - err.note("Constant functions are not allowed to mutate anything. Thus, \ - binding to an argument with a mutable pattern is not allowed."); - err.note("Remove any mutable bindings from the argument list to fix this \ - error. In case you need to mutate the argument, try lazily \ - initializing a global variable instead of using a const fn, or \ - refactoring the code to a functional style to avoid mutation if \ - possible."); - } - err.emit(); + span_err!(self.tcx.sess, decl.source_info.span, E0022, + "arguments of constant functions can only \ + be immutable by-value bindings"); return; } } @@ -1220,16 +1085,3 @@ impl MirPass for QualifyAndPromoteConstants { } } } - -fn args_required_const(tcx: TyCtxt, def_id: DefId) -> Option> { - let attrs = tcx.get_attrs(def_id); - let attr = attrs.iter().find(|a| a.check_name("rustc_args_required_const"))?; - let mut ret = FxHashSet(); - for meta in attr.meta_item_list()? { - match meta.literal()?.node { - LitKind::Int(a, _) => { ret.insert(a as usize); } - _ => return None, - } - } - Some(ret) -} diff --git a/src/librustc_mir/transform/remove_noop_landing_pads.rs b/src/librustc_mir/transform/remove_noop_landing_pads.rs index cd80d25c410f1..e7cab469bc222 100644 --- a/src/librustc_mir/transform/remove_noop_landing_pads.rs +++ b/src/librustc_mir/transform/remove_noop_landing_pads.rs @@ -75,8 +75,7 @@ impl RemoveNoopLandingPads { TerminatorKind::Goto { .. } | TerminatorKind::Resume | TerminatorKind::SwitchInt { .. } | - TerminatorKind::FalseEdges { .. } | - TerminatorKind::FalseUnwind { .. } => { + TerminatorKind::FalseEdges { .. } => { terminator.successors().iter().all(|succ| { nop_landing_pads.contains(succ.index()) }) diff --git a/src/librustc_mir/transform/simplify_branches.rs b/src/librustc_mir/transform/simplify_branches.rs index 41089f567bd71..20c33bab1aacb 100644 --- a/src/librustc_mir/transform/simplify_branches.rs +++ b/src/librustc_mir/transform/simplify_branches.rs @@ -64,9 +64,6 @@ impl MirPass for SimplifyBranches { TerminatorKind::FalseEdges { real_target, .. } => { TerminatorKind::Goto { target: real_target } }, - TerminatorKind::FalseUnwind { real_target, .. } => { - TerminatorKind::Goto { target: real_target } - }, _ => continue }; } diff --git a/src/librustc_mir/util/elaborate_drops.rs b/src/librustc_mir/util/elaborate_drops.rs index e2feb0ed39054..6577106801499 100644 --- a/src/librustc_mir/util/elaborate_drops.rs +++ b/src/librustc_mir/util/elaborate_drops.rs @@ -531,9 +531,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> let result = BasicBlockData { statements: vec![self.assign( &Place::Local(ref_place), - Rvalue::Ref(tcx.types.re_erased, - BorrowKind::Mut { allow_two_phase_borrow: false }, - self.place.clone()) + Rvalue::Ref(tcx.types.re_erased, BorrowKind::Mut, self.place.clone()) )], terminator: Some(Terminator { kind: TerminatorKind::Call { @@ -593,7 +591,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> } else { (Rvalue::Ref( tcx.types.re_erased, - BorrowKind::Mut { allow_two_phase_borrow: false }, + BorrowKind::Mut, self.place.clone().index(cur)), Rvalue::BinaryOp(BinOp::Add, copy(&Place::Local(cur)), one)) }; @@ -737,9 +735,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D> // cur = tmp as *mut T; // end = Offset(cur, len); drop_block_stmts.push(self.assign(&tmp, Rvalue::Ref( - tcx.types.re_erased, - BorrowKind::Mut { allow_two_phase_borrow: false }, - self.place.clone() + tcx.types.re_erased, BorrowKind::Mut, self.place.clone() ))); drop_block_stmts.push(self.assign(&cur, Rvalue::Cast( CastKind::Misc, Operand::Move(tmp.clone()), iter_ty diff --git a/src/librustc_passes/consts.rs b/src/librustc_passes/consts.rs index 59864182a7e40..6df860492f05a 100644 --- a/src/librustc_passes/consts.rs +++ b/src/librustc_passes/consts.rs @@ -237,20 +237,10 @@ impl<'a, 'tcx> Visitor<'tcx> for CheckCrateVisitor<'a, 'tcx> { Ok(Ordering::Less) | Ok(Ordering::Equal) => {} Ok(Ordering::Greater) => { - let mut err = struct_span_err!( - self.tcx.sess, - start.span, - E0030, - "lower range bound must be less than or equal to upper" - ); - err.span_label(start.span, "lower bound larger than upper bound"); - if self.tcx.sess.teach(&err.get_code().unwrap()) { - err.note("When matching against a range, the compiler verifies that \ - the range is non-empty. Range patterns include both \ - end-points, so this is equivalent to requiring the start of \ - the range to be less than or equal to the end of the range."); - } - err.emit(); + struct_span_err!(self.tcx.sess, start.span, E0030, + "lower range bound must be less than or equal to upper") + .span_label(start.span, "lower bound larger than upper bound") + .emit(); } Err(ErrorReported) => {} } diff --git a/src/librustc_passes/loops.rs b/src/librustc_passes/loops.rs index 008c71cc9ce3d..c23f28fe2205f 100644 --- a/src/librustc_passes/loops.rs +++ b/src/librustc_passes/loops.rs @@ -119,11 +119,6 @@ impl<'a, 'hir> Visitor<'hir> for CheckLoopVisitor<'a, 'hir> { kind.name()) .span_label(e.span, "can only break with a value inside `loop`") - .span_suggestion(e.span, - &format!("instead, use `break` on its own \ - without a value inside this `{}` loop", - kind.name()), - "break".to_string()) .emit(); } } diff --git a/src/librustc_passes/mir_stats.rs b/src/librustc_passes/mir_stats.rs index e4705674e2292..b379a174b23f6 100644 --- a/src/librustc_passes/mir_stats.rs +++ b/src/librustc_passes/mir_stats.rs @@ -123,7 +123,6 @@ impl<'a, 'tcx> mir_visit::Visitor<'tcx> for StatCollector<'a, 'tcx> { TerminatorKind::GeneratorDrop => "TerminatorKind::GeneratorDrop", TerminatorKind::Yield { .. } => "TerminatorKind::Yield", TerminatorKind::FalseEdges { .. } => "TerminatorKind::FalseEdges", - TerminatorKind::FalseUnwind { .. } => "TerminatorKind::FalseUnwind", }, kind); self.super_terminator_kind(block, kind, location); } diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 2da4bfedd3a17..ecf3c9e42d58f 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -3998,20 +3998,14 @@ impl<'a> Resolver<'a> { if let (Ok(snippet), false) = (cm.span_to_snippet(binding.span), binding.is_renamed_extern_crate()) { - let suggested_name = if name.as_str().chars().next().unwrap().is_uppercase() { - format!("Other{}", name) - } else { - format!("other_{}", name) - }; - err.span_suggestion(binding.span, rename_msg, if snippet.ends_with(';') { - format!("{} as {};", + format!("{} as Other{};", &snippet[..snippet.len()-1], - suggested_name) + name) } else { - format!("{} as {}", snippet, suggested_name) + format!("{} as Other{}", snippet, name) }); } else { err.span_label(binding.span, rename_msg); diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 8cb25f449b667..07b08e2e61ac0 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -1026,17 +1026,9 @@ fn import_path_to_string(names: &[SpannedIdent], if names.is_empty() { import_directive_subclass_to_string(subclass) } else { - // Note that this code looks a little wonky, it's currently here to - // hopefully help debug #48116, but otherwise isn't intended to - // cause any problems. - let x = format!( - "{}::{}", - names_to_string(names), - import_directive_subclass_to_string(subclass), - ); - assert!(!names.is_empty()); - assert!(!x.starts_with("::")); - return x + (format!("{}::{}", + names_to_string(names), + import_directive_subclass_to_string(subclass))) } } } diff --git a/src/librustc_save_analysis/Cargo.toml b/src/librustc_save_analysis/Cargo.toml index 005faa55b5884..8b2658b2a88c4 100644 --- a/src/librustc_save_analysis/Cargo.toml +++ b/src/librustc_save_analysis/Cargo.toml @@ -15,7 +15,7 @@ rustc_data_structures = { path = "../librustc_data_structures" } rustc_typeck = { path = "../librustc_typeck" } syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } -rls-data = "0.15" +rls-data = "0.14" rls-span = "0.4" # FIXME(#40527) should move rustc serialize out of tree rustc-serialize = "0.3" diff --git a/src/librustc_save_analysis/dump_visitor.rs b/src/librustc_save_analysis/dump_visitor.rs index 47530c4208520..69cef20622b1e 100644 --- a/src/librustc_save_analysis/dump_visitor.rs +++ b/src/librustc_save_analysis/dump_visitor.rs @@ -770,12 +770,8 @@ impl<'l, 'tcx: 'l, 'll, O: DumpOutput + 'll> DumpVisitor<'l, 'tcx, 'll, O> { impl_items: &'l [ast::ImplItem], ) { if let Some(impl_data) = self.save_ctxt.get_item_data(item) { - if let super::Data::RelationData(rel, imp) = impl_data { - self.dumper.dump_relation(rel); - self.dumper.dump_impl(imp); - } else { - span_bug!(item.span, "unexpected data kind: {:?}", impl_data); - } + down_cast_data!(impl_data, RelationData, item.span); + self.dumper.dump_relation(impl_data); } self.visit_ty(&typ); if let &Some(ref trait_ref) = trait_ref { diff --git a/src/librustc_save_analysis/json_dumper.rs b/src/librustc_save_analysis/json_dumper.rs index 1b09df16a7d16..2b35a4123836b 100644 --- a/src/librustc_save_analysis/json_dumper.rs +++ b/src/librustc_save_analysis/json_dumper.rs @@ -13,7 +13,7 @@ use std::io::Write; use rustc_serialize::json::as_json; use rls_data::{self, Analysis, CratePreludeData, Def, DefKind, Import, MacroRef, Ref, RefKind, - Relation, Impl}; + Relation}; use rls_data::config::Config; use rls_span::{Column, Row}; @@ -142,8 +142,4 @@ impl<'b, O: DumpOutput + 'b> JsonDumper { pub fn dump_relation(&mut self, data: Relation) { self.result.relations.push(data); } - - pub fn dump_impl(&mut self, data: Impl) { - self.result.impls.push(data); - } } diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 490dc4e5ac4a9..2e494fdfad8b8 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -45,7 +45,6 @@ use rustc::session::config::CrateType::CrateTypeExecutable; use rustc::ty::{self, TyCtxt}; use rustc_typeck::hir_ty_to_ty; -use std::cell::Cell; use std::default::Default; use std::env; use std::fs::File; @@ -66,7 +65,7 @@ use dump_visitor::DumpVisitor; use span_utils::SpanUtils; use rls_data::{Def, DefKind, ExternalCrateData, GlobalCrateId, MacroRef, Ref, RefKind, Relation, - RelationKind, SpanData, Impl, ImplKind}; + RelationKind, SpanData}; use rls_data::config::Config; @@ -76,14 +75,13 @@ pub struct SaveContext<'l, 'tcx: 'l> { analysis: &'l ty::CrateAnalysis, span_utils: SpanUtils<'tcx>, config: Config, - impl_counter: Cell, } #[derive(Debug)] pub enum Data { RefData(Ref), DefData(Def), - RelationData(Relation, Impl), + RelationData(Relation), } impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { @@ -317,7 +315,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { attributes: lower_attributes(item.attrs.to_owned(), self), })) } - ast::ItemKind::Impl(.., ref trait_ref, ref typ, ref impls) => { + ast::ItemKind::Impl(.., ref trait_ref, ref typ, _) => { if let ast::TyKind::Path(None, ref path) = typ.node { // Common case impl for a struct or something basic. if generated_code(path.span) { @@ -326,39 +324,17 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { let sub_span = self.span_utils.sub_span_for_type_name(path.span); filter!(self.span_utils, sub_span, typ.span, None); - let impl_id = self.next_impl_id(); - let span = self.span_from_span(sub_span.unwrap()); - let type_data = self.lookup_ref_id(typ.id); type_data.map(|type_data| { Data::RelationData(Relation { - kind: RelationKind::Impl { - id: impl_id, - }, - span: span.clone(), + kind: RelationKind::Impl, + span: self.span_from_span(sub_span.unwrap()), from: id_from_def_id(type_data), to: trait_ref .as_ref() .and_then(|t| self.lookup_ref_id(t.ref_id)) .map(id_from_def_id) .unwrap_or(null_id()), - }, - Impl { - id: impl_id, - kind: match *trait_ref { - Some(_) => ImplKind::Direct, - None => ImplKind::Inherent, - }, - span: span, - value: String::new(), - parent: None, - children: impls - .iter() - .map(|i| id_from_node_id(i.id, self)) - .collect(), - docs: String::new(), - sig: None, - attributes: vec![], }) }) } else { @@ -815,7 +791,7 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { field_ref: &ast::Field, variant: &ty::VariantDef, ) -> Option { - let f = variant.find_field_named(field_ref.ident.node.name)?; + let f = variant.field_named(field_ref.ident.node.name); // We don't really need a sub-span here, but no harm done let sub_span = self.span_utils.span_for_last_ident(field_ref.ident.span); filter!(self.span_utils, sub_span, field_ref.ident.span, None); @@ -894,17 +870,6 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { result.push_str(&val.as_str()); } result.push('\n'); - } else if let Some(meta_list) = attr.meta_item_list() { - meta_list.into_iter() - .filter(|it| it.check_name("include")) - .filter_map(|it| it.meta_item_list().map(|l| l.to_owned())) - .flat_map(|it| it) - .filter(|meta| meta.check_name("contents")) - .filter_map(|meta| meta.value_str()) - .for_each(|val| { - result.push_str(&val.as_str()); - result.push('\n'); - }); } } } @@ -917,12 +882,6 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> { result } - - fn next_impl_id(&self) -> u32 { - let next = self.impl_counter.get(); - self.impl_counter.set(next + 1); - next - } } fn make_signature(decl: &ast::FnDecl, generics: &ast::Generics) -> String { @@ -1129,7 +1088,6 @@ pub fn process_crate<'l, 'tcx, H: SaveHandler>( analysis, span_utils: SpanUtils::new(&tcx.sess), config: find_config(config), - impl_counter: Cell::new(0), }; handler.save(save_ctxt, krate, cratename) diff --git a/src/librustc_trans/allocator.rs b/src/librustc_trans/allocator.rs index e1c145b122d76..fd5aa1364d381 100644 --- a/src/librustc_trans/allocator.rs +++ b/src/librustc_trans/allocator.rs @@ -86,10 +86,6 @@ pub(crate) unsafe fn trans(tcx: TyCtxt, mods: &ModuleLlvm, kind: AllocatorKind) name.as_ptr(), ty); - if tcx.sess.target.target.options.default_hidden_visibility { - llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden); - } - let callee = CString::new(kind.fn_name(method.name)).unwrap(); let callee = llvm::LLVMRustGetOrInsertFunction(llmod, callee.as_ptr(), diff --git a/src/librustc_trans/asm.rs b/src/librustc_trans/asm.rs index 751f8148a2a90..c7be0c4e67d71 100644 --- a/src/librustc_trans/asm.rs +++ b/src/librustc_trans/asm.rs @@ -59,9 +59,8 @@ pub fn trans_inline_asm<'a, 'tcx>( // Default per-arch clobbers // Basically what clang does let arch_clobbers = match &bx.sess().target.target.arch[..] { - "x86" | "x86_64" => vec!["~{dirflag}", "~{fpsr}", "~{flags}"], - "mips" | "mips64" => vec!["~{$1}"], - _ => Vec::new() + "x86" | "x86_64" => vec!["~{dirflag}", "~{fpsr}", "~{flags}"], + _ => Vec::new() }; let all_constraints = diff --git a/src/librustc_trans/back/symbol_export.rs b/src/librustc_trans/back/symbol_export.rs index 989ef8a953746..15ff59c7df998 100644 --- a/src/librustc_trans/back/symbol_export.rs +++ b/src/librustc_trans/back/symbol_export.rs @@ -133,8 +133,6 @@ pub fn provide(providers: &mut Providers) { Arc::new(local_crate) }; - - providers.symbol_export_level = export_level; } pub fn provide_extern(providers: &mut Providers) { @@ -205,7 +203,6 @@ pub fn provide_extern(providers: &mut Providers) { Arc::new(crate_exports) }; - providers.symbol_export_level = export_level; } fn export_level(tcx: TyCtxt, sym_def_id: DefId) -> SymbolExportLevel { diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index ded9a296817b3..8afa63a5e9735 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -759,10 +759,7 @@ unsafe fn codegen(cgcx: &CodegenContext, if asm2wasm && config.emit_obj { let assembly = cgcx.output_filenames.temp_path(OutputType::Assembly, module_name); - let suffix = ".wasm.map"; // FIXME use target suffix - let map = cgcx.output_filenames.path(OutputType::Exe) - .with_extension(&suffix[1..]); - binaryen_assemble(cgcx, diag_handler, &assembly, &obj_out, &map); + binaryen_assemble(cgcx, diag_handler, &assembly, &obj_out); timeline.record("binaryen"); if !config.emit_asm { @@ -817,8 +814,7 @@ unsafe fn codegen(cgcx: &CodegenContext, fn binaryen_assemble(cgcx: &CodegenContext, handler: &Handler, assembly: &Path, - object: &Path, - map: &Path) { + object: &Path) { use rustc_binaryen::{Module, ModuleOptions}; let input = fs::read(&assembly).and_then(|contents| { @@ -827,10 +823,10 @@ fn binaryen_assemble(cgcx: &CodegenContext, let mut options = ModuleOptions::new(); if cgcx.debuginfo != config::NoDebugInfo { options.debuginfo(true); - let map_file_name = map.file_name().unwrap(); - options.source_map_url(map_file_name.to_str().unwrap()); } - + if cgcx.crate_types.contains(&config::CrateTypeExecutable) { + options.start("main"); + } options.stack(1024 * 1024); options.import_memory(cgcx.wasm_import_memory); let assembled = input.and_then(|input| { @@ -838,13 +834,7 @@ fn binaryen_assemble(cgcx: &CodegenContext, .map_err(|e| io::Error::new(io::ErrorKind::Other, e)) }); let err = assembled.and_then(|binary| { - fs::write(&object, binary.data()).and_then(|()| { - if cgcx.debuginfo != config::NoDebugInfo { - fs::write(map, binary.source_map()) - } else { - Ok(()) - } - }) + fs::write(&object, binary.data()) }); if let Err(e) = err { handler.err(&format!("failed to run binaryen assembler: {}", e)); @@ -1462,7 +1452,7 @@ fn start_executing_work(tcx: TyCtxt, target_pointer_width: tcx.sess.target.target.target_pointer_width.clone(), binaryen_linker: tcx.sess.linker_flavor() == LinkerFlavor::Binaryen, debuginfo: tcx.sess.opts.debuginfo, - wasm_import_memory, + wasm_import_memory: wasm_import_memory, assembler_cmd, }; diff --git a/src/librustc_trans/cabi_x86_64.rs b/src/librustc_trans/cabi_x86_64.rs index b8144a3ca7a3e..62bac8469ce4b 100644 --- a/src/librustc_trans/cabi_x86_64.rs +++ b/src/librustc_trans/cabi_x86_64.rs @@ -134,13 +134,12 @@ fn reg_component(cls: &[Option], i: &mut usize, size: Size) -> Option None, Some(Class::Int) => { *i += 1; - Some(if size.bytes() < 8 { - Reg { - kind: RegKind::Integer, - size - } - } else { - Reg::i64() + Some(match size.bytes() { + 1 => Reg::i8(), + 2 => Reg::i16(), + 3 | + 4 => Reg::i32(), + _ => Reg::i64() }) } Some(Class::Sse) => { diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index a285e5f263ab7..06b8d9ff7b306 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -464,7 +464,8 @@ impl<'a, 'tcx> LayoutOf> for &'a CodegenCx<'a, 'tcx> { type TyLayout = TyLayout<'tcx>; fn layout_of(self, ty: Ty<'tcx>) -> Self::TyLayout { - self.tcx.layout_of(ty::ParamEnv::empty(traits::Reveal::All).and(ty)) + (self.tcx, ty::ParamEnv::empty(traits::Reveal::All)) + .layout_of(ty) .unwrap_or_else(|e| match e { LayoutError::SizeOverflow(_) => self.sess().fatal(&e.to_string()), _ => bug!("failed to get layout for `{}`: {}", ty, e) diff --git a/src/librustc_trans/llvm_util.rs b/src/librustc_trans/llvm_util.rs index 843231d376f6c..15988008de2fc 100644 --- a/src/librustc_trans/llvm_util.rs +++ b/src/librustc_trans/llvm_util.rs @@ -79,16 +79,16 @@ unsafe fn configure_llvm(sess: &Session) { // detection code will walk past the end of the feature array, // leading to crashes. -const ARM_WHITELIST: &'static [&'static str] = &["neon\0", "v7\0", "vfp2\0", "vfp3\0", "vfp4\0"]; +const ARM_WHITELIST: &'static [&'static str] = &["neon\0", "vfp2\0", "vfp3\0", "vfp4\0"]; -const AARCH64_WHITELIST: &'static [&'static str] = &["neon\0", "v7\0"]; +const AARCH64_WHITELIST: &'static [&'static str] = &["neon\0"]; const X86_WHITELIST: &'static [&'static str] = &["avx\0", "avx2\0", "bmi\0", "bmi2\0", "sse\0", "sse2\0", "sse3\0", "sse4.1\0", "sse4.2\0", "ssse3\0", "tbm\0", "lzcnt\0", "popcnt\0", "sse4a\0", "rdrnd\0", "rdseed\0", "fma\0", "xsave\0", "xsaveopt\0", "xsavec\0", - "xsaves\0", "aes\0", + "xsaves\0", "avx512bw\0", "avx512cd\0", "avx512dq\0", "avx512er\0", "avx512f\0", "avx512ifma\0", diff --git a/src/librustc_trans/mir/analyze.rs b/src/librustc_trans/mir/analyze.rs index f683703ce6d53..bf82e1d50c473 100644 --- a/src/librustc_trans/mir/analyze.rs +++ b/src/librustc_trans/mir/analyze.rs @@ -242,8 +242,7 @@ pub fn cleanup_kinds<'a, 'tcx>(mir: &mir::Mir<'tcx>) -> IndexVec { + TerminatorKind::FalseEdges { .. } => { /* nothing to do */ } TerminatorKind::Call { cleanup: unwind, .. } | diff --git a/src/librustc_trans/mir/block.rs b/src/librustc_trans/mir/block.rs index bb2a7840faee7..af1e30a4b19a6 100644 --- a/src/librustc_trans/mir/block.rs +++ b/src/librustc_trans/mir/block.rs @@ -608,9 +608,8 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> { cleanup); } mir::TerminatorKind::GeneratorDrop | - mir::TerminatorKind::Yield { .. } => bug!("generator ops in trans"), - mir::TerminatorKind::FalseEdges { .. } | - mir::TerminatorKind::FalseUnwind { .. } => bug!("borrowck false edges in trans"), + mir::TerminatorKind::Yield { .. } | + mir::TerminatorKind::FalseEdges { .. } => bug!("generator ops in trans"), } } diff --git a/src/librustc_trans/mir/constant.rs b/src/librustc_trans/mir/constant.rs index d470f92b75231..a3e55205dd875 100644 --- a/src/librustc_trans/mir/constant.rs +++ b/src/librustc_trans/mir/constant.rs @@ -411,11 +411,6 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> { self.cx.align_of(substs.type_at(0)).abi()); Ok(Const::new(llval, tcx.types.usize)) } - "type_id" => { - let llval = C_u64(self.cx, - self.cx.tcx.type_id_hash(substs.type_at(0))); - Ok(Const::new(llval, tcx.types.u64)) - } _ => span_bug!(span, "{:?} in constant", terminator.kind) } } else if let Some((op, is_checked)) = self.is_binop_lang_item(def_id) { @@ -714,10 +709,6 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> { mir::CastKind::ReifyFnPointer => { match operand.ty.sty { ty::TyFnDef(def_id, substs) => { - if tcx.has_attr(def_id, "rustc_args_required_const") { - bug!("reifying a fn ptr that requires \ - const arguments"); - } callee::resolve_and_get_fn(self.cx, def_id, substs) } _ => { @@ -874,7 +865,7 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> { } else { self.cx.tcx.data_layout.pointer_align }; - if let mir::BorrowKind::Mut { .. } = bk { + if bk == mir::BorrowKind::Mut { consts::addr_of_mut(self.cx, llval, align, "ref_mut") } else { consts::addr_of(self.cx, llval, align, "ref") diff --git a/src/librustc_trans/mir/rvalue.rs b/src/librustc_trans/mir/rvalue.rs index 2e876ec118d57..d1bc4fe90014c 100644 --- a/src/librustc_trans/mir/rvalue.rs +++ b/src/librustc_trans/mir/rvalue.rs @@ -195,10 +195,6 @@ impl<'a, 'tcx> FunctionCx<'a, 'tcx> { mir::CastKind::ReifyFnPointer => { match operand.layout.ty.sty { ty::TyFnDef(def_id, substs) => { - if bx.cx.tcx.has_attr(def_id, "rustc_args_required_const") { - bug!("reifying a fn ptr that requires \ - const arguments"); - } OperandValue::Immediate( callee::resolve_and_get_fn(bx.cx, def_id, substs)) } diff --git a/src/librustc_trans/type_of.rs b/src/librustc_trans/type_of.rs index af957500f7002..b1533cfad19f5 100644 --- a/src/librustc_trans/type_of.rs +++ b/src/librustc_trans/type_of.rs @@ -57,9 +57,7 @@ fn uncached_llvm_type<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>, ty::TyClosure(..) | ty::TyGenerator(..) | ty::TyAdt(..) | - // FIXME(eddyb) producing readable type names for trait objects can result - // in problematically distinct types due to HRTB and subtyping (see #47638). - // ty::TyDynamic(..) | + ty::TyDynamic(..) | ty::TyForeign(..) | ty::TyStr => { let mut name = String::with_capacity(32); diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs index bf253a88d27c2..1a285cd869aec 100644 --- a/src/librustc_typeck/check/_match.rs +++ b/src/librustc_typeck/check/_match.rs @@ -214,25 +214,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { end.span }; - let mut err = struct_span_err!( - tcx.sess, - span, - E0029, - "only char and numeric types are allowed in range patterns" - ); - err.span_label(span, "ranges require char or numeric types"); - err.note(&format!("start type: {}", self.ty_to_string(lhs_ty))); - err.note(&format!("end type: {}", self.ty_to_string(rhs_ty))); - if tcx.sess.teach(&err.get_code().unwrap()) { - err.note( - "In a match expression, only numbers and characters can be matched \ - against a range. This is because the compiler checks that the range \ - is non-empty at compile-time, and is unable to evaluate arbitrary \ - comparison functions. If you want to capture values of an orderable \ - type between two end-points, you can use a guard." - ); - } - err.emit(); + struct_span_err!(tcx.sess, span, E0029, + "only char and numeric types are allowed in range patterns") + .span_label(span, "ranges require char or numeric types") + .note(&format!("start type: {}", self.ty_to_string(lhs_ty))) + .note(&format!("end type: {}", self.ty_to_string(rhs_ty))) + .emit(); return; } @@ -518,25 +505,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // This is "x = SomeTrait" being reduced from // "let &x = &SomeTrait" or "let box x = Box", an error. let type_str = self.ty_to_string(expected); - let mut err = struct_span_err!( - self.tcx.sess, - span, - E0033, - "type `{}` cannot be dereferenced", - type_str - ); - err.span_label(span, format!("type `{}` cannot be dereferenced", type_str)); - if self.tcx.sess.teach(&err.get_code().unwrap()) { - err.note("\ -This error indicates that a pointer to a trait type cannot be implicitly dereferenced by a \ -pattern. Every trait defines a type, but because the size of trait implementors isn't fixed, \ -this type has no compile-time size. Therefore, all accesses to trait types must be through \ -pointers. If you encounter this error you should try to avoid dereferencing the pointer. - -You can read more about trait objects in the Trait Objects section of the Reference: \ -https://doc.rust-lang.org/reference/types.html#trait-objects"); - } - err.emit(); + struct_span_err!(self.tcx.sess, span, E0033, + "type `{}` cannot be dereferenced", type_str) + .span_label(span, format!("type `{}` cannot be dereferenced", type_str)) + .emit(); return false } } @@ -909,33 +881,17 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); self.field_ty(span, f, substs) }) .unwrap_or_else(|| { - let mut err = struct_span_err!( - tcx.sess, - span, - E0026, - "{} `{}` does not have a field named `{}`", - kind_name, - tcx.item_path_str(variant.did), - field.name - ); - err.span_label(span, - format!("{} `{}` does not have field `{}`", - kind_name, - tcx.item_path_str(variant.did), - field.name)); - if tcx.sess.teach(&err.get_code().unwrap()) { - err.note( - "This error indicates that a struct pattern attempted to \ - extract a non-existent field from a struct. Struct fields \ - are identified by the name used before the colon : so struct \ - patterns should resemble the declaration of the struct type \ - being matched.\n\n\ - If you are using shorthand field patterns but want to refer \ - to the struct field by a different name, you should rename \ - it explicitly." - ); - } - err.emit(); + struct_span_err!(tcx.sess, span, E0026, + "{} `{}` does not have a field named `{}`", + kind_name, + tcx.item_path_str(variant.did), + field.name) + .span_label(span, + format!("{} `{}` does not have field `{}`", + kind_name, + tcx.item_path_str(variant.did), + field.name)) + .emit(); tcx.types.err }) @@ -971,14 +927,6 @@ https://doc.rust-lang.org/reference/types.html#trait-objects"); if variant.ctor_kind == CtorKind::Fn { diag.note("trying to match a tuple variant with a struct variant pattern"); } - if tcx.sess.teach(&diag.get_code().unwrap()) { - diag.note( - "This error indicates that a pattern for a struct fails to specify a \ - sub-pattern for every one of the struct's fields. Ensure that each field \ - from the struct's definition is mentioned in the pattern, or use `..` to \ - ignore unwanted fields." - ); - } diag.emit(); } } diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index 3d61ffe39336a..76df9be48386d 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -16,7 +16,7 @@ use hir::def::Def; use hir::def_id::{DefId, LOCAL_CRATE}; use rustc::{infer, traits}; use rustc::ty::{self, TyCtxt, TypeFoldable, Ty}; -use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability}; +use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow}; use syntax::abi; use syntax::symbol::Symbol; use syntax_pos::Span; @@ -176,17 +176,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let mut autoref = None; if borrow { if let ty::TyRef(region, mt) = method.sig.inputs()[0].sty { - let mutbl = match mt.mutbl { - hir::MutImmutable => AutoBorrowMutability::Immutable, - hir::MutMutable => AutoBorrowMutability::Mutable { - // For initial two-phase borrow - // deployment, conservatively omit - // overloaded function call ops. - allow_two_phase_borrow: false, - } - }; autoref = Some(Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(region, mt.mutbl)), target: method.sig.inputs()[0] }); } diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index 47e4b0272bed4..d0280bf0b30be 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -68,7 +68,7 @@ use rustc::infer::{Coercion, InferResult, InferOk}; use rustc::infer::type_variable::TypeVariableOrigin; use rustc::lint; use rustc::traits::{self, ObligationCause, ObligationCauseCode}; -use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability}; +use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow}; use rustc::ty::{self, TypeAndMut, Ty, ClosureSubsts}; use rustc::ty::fold::TypeFoldable; use rustc::ty::error::TypeError; @@ -421,17 +421,8 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { ty::TyRef(r_borrow, _) => r_borrow, _ => span_bug!(span, "expected a ref type, got {:?}", ty), }; - let mutbl = match mt_b.mutbl { - hir::MutImmutable => AutoBorrowMutability::Immutable, - hir::MutMutable => AutoBorrowMutability::Mutable { - // Deref-coercion is a case where we deliberately - // disallow two-phase borrows in its initial - // deployment; see discussion on PR #47489. - allow_two_phase_borrow: false, - } - }; adjustments.push(Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(r_borrow, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(r_borrow, mt_b.mutbl)), target: ty }); @@ -470,17 +461,11 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { let coercion = Coercion(self.cause.span); let r_borrow = self.next_region_var(coercion); - let mutbl = match mt_b.mutbl { - hir::MutImmutable => AutoBorrowMutability::Immutable, - hir::MutMutable => AutoBorrowMutability::Mutable { - allow_two_phase_borrow: false, - } - }; Some((Adjustment { kind: Adjust::Deref(None), target: mt_a.ty }, Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(r_borrow, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(r_borrow, mt_b.mutbl)), target: self.tcx.mk_ref(r_borrow, ty::TypeAndMut { mutbl: mt_b.mutbl, ty: mt_a.ty @@ -886,7 +871,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ] => { match self.node_ty(expr.hir_id).sty { ty::TyRef(_, mt_orig) => { - let mutbl_adj: hir::Mutability = mutbl_adj.into(); // Reborrow that we can safely ignore, because // the next adjustment can only be a Deref // which will be merged into it. diff --git a/src/librustc_typeck/check/compare_method.rs b/src/librustc_typeck/check/compare_method.rs index 4c10f28eb8e5d..570eecfc267de 100644 --- a/src/librustc_typeck/check/compare_method.rs +++ b/src/librustc_typeck/check/compare_method.rs @@ -40,8 +40,6 @@ pub fn compare_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, debug!("compare_impl_method(impl_trait_ref={:?})", impl_trait_ref); - let impl_m_span = tcx.sess.codemap().def_span(impl_m_span); - if let Err(ErrorReported) = compare_self_type(tcx, impl_m, impl_m_span, @@ -188,7 +186,6 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, check_region_bounds_on_impl_method(tcx, impl_m_span, impl_m, - trait_m, &trait_m_generics, &impl_m_generics, trait_to_skol_substs)?; @@ -313,7 +310,7 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, }; let mut diag = struct_span_err!(tcx.sess, - cause.span(&tcx), + cause.span, E0053, "method `{}` has an incompatible type for trait", trait_m.name); @@ -349,12 +346,10 @@ fn compare_predicate_entailment<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, span: Span, impl_m: &ty::AssociatedItem, - trait_m: &ty::AssociatedItem, trait_generics: &ty::Generics, impl_generics: &ty::Generics, trait_to_skol_substs: &Substs<'tcx>) -> Result<(), ErrorReported> { - let span = tcx.sess.codemap().def_span(span); let trait_params = &trait_generics.regions[..]; let impl_params = &impl_generics.regions[..]; @@ -376,18 +371,14 @@ fn check_region_bounds_on_impl_method<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // are zero. Since I don't quite know how to phrase things at // the moment, give a kind of vague error message. if trait_params.len() != impl_params.len() { - let mut err = struct_span_err!(tcx.sess, - span, - E0195, - "lifetime parameters or bounds on method `{}` do not match \ - the trait declaration", - impl_m.name); - err.span_label(span, "lifetimes do not match method in trait"); - if let Some(sp) = tcx.hir.span_if_local(trait_m.def_id) { - err.span_label(tcx.sess.codemap().def_span(sp), - "lifetimes in impl do not match this method in trait"); - } - err.emit(); + struct_span_err!(tcx.sess, + span, + E0195, + "lifetime parameters or bounds on method `{}` do not match the \ + trait declaration", + impl_m.name) + .span_label(span, "lifetimes do not match trait") + .emit(); return Err(ErrorReported); } @@ -433,9 +424,9 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a }).map(|(ref impl_arg, ref trait_arg)| { (impl_arg.span, Some(trait_arg.span)) }) - .unwrap_or_else(|| (cause.span(&tcx), tcx.hir.span_if_local(trait_m.def_id))) + .unwrap_or_else(|| (cause.span, tcx.hir.span_if_local(trait_m.def_id))) } else { - (cause.span(&tcx), tcx.hir.span_if_local(trait_m.def_id)) + (cause.span, tcx.hir.span_if_local(trait_m.def_id)) } } TypeError::Sorts(ExpectedFound { .. }) => { @@ -468,14 +459,14 @@ fn extract_spans_for_error_reporting<'a, 'gcx, 'tcx>(infcx: &infer::InferCtxt<'a { (impl_m_output.span(), Some(trait_m_output.span())) } else { - (cause.span(&tcx), tcx.hir.span_if_local(trait_m.def_id)) + (cause.span, tcx.hir.span_if_local(trait_m.def_id)) } }) } else { - (cause.span(&tcx), tcx.hir.span_if_local(trait_m.def_id)) + (cause.span, tcx.hir.span_if_local(trait_m.def_id)) } } - _ => (cause.span(&tcx), tcx.hir.span_if_local(trait_m.def_id)), + _ => (cause.span, tcx.hir.span_if_local(trait_m.def_id)), } } diff --git a/src/librustc_typeck/check/generator_interior.rs b/src/librustc_typeck/check/generator_interior.rs index 2e45e3b1f3521..781eeaef2482c 100644 --- a/src/librustc_typeck/check/generator_interior.rs +++ b/src/librustc_typeck/check/generator_interior.rs @@ -150,15 +150,15 @@ impl<'a, 'gcx, 'tcx> Visitor<'tcx> for InteriorVisitor<'a, 'gcx, 'tcx> { } fn visit_pat(&mut self, pat: &'tcx Pat) { - intravisit::walk_pat(self, pat); - - self.expr_count += 1; - if let PatKind::Binding(..) = pat.node { let scope = self.region_scope_tree.var_scope(pat.hir_id.local_id); let ty = self.fcx.tables.borrow().pat_ty(pat); self.record(ty, Some(scope), None, pat.span); } + + self.expr_count += 1; + + intravisit::walk_pat(self, pat); } fn visit_expr(&mut self, expr: &'tcx Expr) { diff --git a/src/librustc_typeck/check/method/confirm.rs b/src/librustc_typeck/check/method/confirm.rs index 20d5899149645..7f5b353f79ef7 100644 --- a/src/librustc_typeck/check/method/confirm.rs +++ b/src/librustc_typeck/check/method/confirm.rs @@ -17,7 +17,7 @@ use rustc::ty::subst::Substs; use rustc::traits; use rustc::ty::{self, Ty}; use rustc::ty::subst::Subst; -use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability, OverloadedDeref}; +use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, OverloadedDeref}; use rustc::ty::fold::TypeFoldable; use rustc::infer::{self, InferOk}; use syntax_pos::Span; @@ -165,14 +165,6 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { mutbl, ty: target }); - let mutbl = match mutbl { - hir::MutImmutable => AutoBorrowMutability::Immutable, - hir::MutMutable => AutoBorrowMutability::Mutable { - // Method call receivers are the primary use case - // for two-phase borrows. - allow_two_phase_borrow: true, - } - }; adjustments.push(Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), target @@ -180,7 +172,7 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { if let Some(unsize_target) = pick.unsize { target = self.tcx.mk_ref(region, ty::TypeAndMut { - mutbl: mutbl.into(), + mutbl, ty: unsize_target }); adjustments.push(Adjustment { @@ -538,19 +530,10 @@ impl<'a, 'gcx, 'tcx> ConfirmContext<'a, 'gcx, 'tcx> { for adjustment in &mut adjustments[..] { if let Adjust::Borrow(AutoBorrow::Ref(..)) = adjustment.kind { debug!("convert_place_op_to_mutable: converting autoref {:?}", adjustment); - let mutbl = match mutbl { - hir::MutImmutable => AutoBorrowMutability::Immutable, - hir::MutMutable => AutoBorrowMutability::Mutable { - // For initial two-phase borrow - // deployment, conservatively omit - // overloaded operators. - allow_two_phase_borrow: false, - } - }; adjustment.kind = Adjust::Borrow(AutoBorrow::Ref(region, mutbl)); adjustment.target = self.tcx.mk_ref(region, ty::TypeAndMut { ty: source, - mutbl: mutbl.into(), + mutbl }); } source = adjustment.target; diff --git a/src/librustc_typeck/check/method/probe.rs b/src/librustc_typeck/check/method/probe.rs index e8c3966f23f08..c88bbd03af82b 100644 --- a/src/librustc_typeck/check/method/probe.rs +++ b/src/librustc_typeck/check/method/probe.rs @@ -326,19 +326,13 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if reached_raw_pointer && !self.tcx.sess.features.borrow().arbitrary_self_types { // this case used to be allowed by the compiler, - // so we do a future-compat lint here for the 2015 epoch + // so we do a future-compat lint here // (see https://github.com/rust-lang/rust/issues/46906) - if self.tcx.sess.rust_2018() { - span_err!(self.tcx.sess, span, E0908, - "the type of this value must be known \ - to call a method on a raw pointer on it"); - } else { - self.tcx.lint_node( - lint::builtin::TYVAR_BEHIND_RAW_POINTER, - scope_expr_id, - span, - &format!("the type of this value must be known in this context")); - } + self.tcx.lint_node( + lint::builtin::TYVAR_BEHIND_RAW_POINTER, + scope_expr_id, + span, + &format!("the type of this value must be known in this context")); } else { let t = self.structurally_resolved_type(span, final_ty); assert_eq!(t, self.tcx.types.err); diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index e760636230d18..9a3dba440eae1 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -96,10 +96,11 @@ use rustc::middle::region; use rustc::ty::subst::{Kind, Subst, Substs}; use rustc::traits::{self, FulfillmentContext, ObligationCause, ObligationCauseCode}; use rustc::ty::{self, Ty, TyCtxt, Visibility, ToPredicate}; -use rustc::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability}; +use rustc::ty::adjustment::{Adjust, Adjustment, AutoBorrow}; use rustc::ty::fold::TypeFoldable; use rustc::ty::maps::Providers; use rustc::ty::util::{Representability, IntTypeExt}; +use rustc::ty::layout::LayoutOf; use errors::{DiagnosticBuilder, DiagnosticId}; use require_c_abi_if_variadic; @@ -1014,9 +1015,7 @@ fn check_fn<'a, 'gcx, 'tcx>(inherited: &'a Inherited<'a, 'gcx, 'tcx>, let span = body.value.span; if body.is_generator && can_be_generator.is_some() { - let yield_ty = fcx.next_ty_var(TypeVariableOrigin::TypeInference(span)); - fcx.require_type_is_sized(yield_ty, span, traits::SizedYieldType); - fcx.yield_ty = Some(yield_ty); + fcx.yield_ty = Some(fcx.next_ty_var(TypeVariableOrigin::TypeInference(span))); } GatherLocalsVisitor { fcx: &fcx, }.visit_body(body); @@ -1552,7 +1551,7 @@ fn check_transparent<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, sp: Span, def_id: De let field_infos: Vec<_> = adt.non_enum_variant().fields.iter().map(|field| { let ty = field.ty(tcx, Substs::identity_for_item(tcx, field.did)); let param_env = tcx.param_env(field.did); - let layout = tcx.layout_of(param_env.and(ty)); + let layout = (tcx, param_env).layout_of(ty); // We are currently checking the type this field came from, so it must be local let span = tcx.hir.span_if_local(field.did).unwrap(); let zst = layout.map(|layout| layout.is_zst()).unwrap_or(false); @@ -2357,19 +2356,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let mut adjustments = autoderef.adjust_steps(needs); if let ty::TyRef(region, mt) = method.sig.inputs()[0].sty { - let mutbl = match mt.mutbl { - hir::MutImmutable => AutoBorrowMutability::Immutable, - hir::MutMutable => AutoBorrowMutability::Mutable { - // FIXME (#46747): arguably indexing is - // "just another kind of call"; perhaps it - // would be more consistent to allow - // two-phase borrows for .index() - // receivers here. - allow_two_phase_borrow: false, - } - }; adjustments.push(Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(region, mt.mutbl)), target: self.tcx.mk_ref(region, ty::TypeAndMut { mutbl: mt.mutbl, ty: adjusted_ty @@ -2936,7 +2924,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let rcvr = &args[0]; let rcvr_t = self.check_expr_with_needs(&rcvr, needs); // no need to check for bot/err -- callee does that - let rcvr_t = self.structurally_resolved_type(args[0].span, rcvr_t); + let rcvr_t = self.structurally_resolved_type(expr.span, rcvr_t); let method = match self.lookup_method(rcvr_t, segment, @@ -3657,17 +3645,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { expr.span, oprnd_t, needs) { let method = self.register_infer_ok_obligations(ok); if let ty::TyRef(region, mt) = method.sig.inputs()[0].sty { - let mutbl = match mt.mutbl { - hir::MutImmutable => AutoBorrowMutability::Immutable, - hir::MutMutable => AutoBorrowMutability::Mutable { - // (It shouldn't actually matter for unary ops whether - // we enable two-phase borrows or not, since a unary - // op has no additional operands.) - allow_two_phase_borrow: false, - } - }; self.apply_adjustments(oprnd, vec![Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(region, mt.mutbl)), target: method.sig.inputs()[0] }]); } @@ -4897,8 +4876,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } } - self.check_rustc_args_require_const(def.def_id(), node_id, span); - debug!("instantiate_value_path: type of {:?} is {:?}", node_id, ty_substituted); @@ -4906,36 +4883,6 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { ty_substituted } - fn check_rustc_args_require_const(&self, - def_id: DefId, - node_id: ast::NodeId, - span: Span) { - // We're only interested in functions tagged with - // #[rustc_args_required_const], so ignore anything that's not. - if !self.tcx.has_attr(def_id, "rustc_args_required_const") { - return - } - - // If our calling expression is indeed the function itself, we're good! - // If not, generate an error that this can only be called directly. - match self.tcx.hir.get(self.tcx.hir.get_parent_node(node_id)) { - Node::NodeExpr(expr) => { - match expr.node { - hir::ExprCall(ref callee, ..) => { - if callee.id == node_id { - return - } - } - _ => {} - } - } - _ => {} - } - - self.tcx.sess.span_err(span, "this function can only be invoked \ - directly, not through a function pointer"); - } - /// Report errors if the provided parameters are too few or too many. fn check_path_parameter_count(&self, span: Span, diff --git a/src/librustc_typeck/check/op.rs b/src/librustc_typeck/check/op.rs index a6776a0fe8612..0698e3ecb6edd 100644 --- a/src/librustc_typeck/check/op.rs +++ b/src/librustc_typeck/check/op.rs @@ -14,7 +14,7 @@ use super::{FnCtxt, Needs}; use super::method::MethodCallee; use rustc::ty::{self, Ty, TypeFoldable, TypeVariants}; use rustc::ty::TypeVariants::{TyStr, TyRef}; -use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow, AutoBorrowMutability}; +use rustc::ty::adjustment::{Adjustment, Adjust, AutoBorrow}; use rustc::infer::type_variable::TypeVariableOrigin; use errors; use syntax_pos::Span; @@ -198,17 +198,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let by_ref_binop = !op.node.is_by_value(); if is_assign == IsAssign::Yes || by_ref_binop { if let ty::TyRef(region, mt) = method.sig.inputs()[0].sty { - let mutbl = match mt.mutbl { - hir::MutImmutable => AutoBorrowMutability::Immutable, - hir::MutMutable => AutoBorrowMutability::Mutable { - // For initial two-phase borrow - // deployment, conservatively omit - // overloaded binary ops. - allow_two_phase_borrow: false, - } - }; let autoref = Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(region, mt.mutbl)), target: method.sig.inputs()[0] }; self.apply_adjustments(lhs_expr, vec![autoref]); @@ -216,17 +207,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } if by_ref_binop { if let ty::TyRef(region, mt) = method.sig.inputs()[1].sty { - let mutbl = match mt.mutbl { - hir::MutImmutable => AutoBorrowMutability::Immutable, - hir::MutMutable => AutoBorrowMutability::Mutable { - // For initial two-phase borrow - // deployment, conservatively omit - // overloaded binary ops. - allow_two_phase_borrow: false, - } - }; let autoref = Adjustment { - kind: Adjust::Borrow(AutoBorrow::Ref(region, mutbl)), + kind: Adjust::Borrow(AutoBorrow::Ref(region, mt.mutbl)), target: method.sig.inputs()[1] }; // HACK(eddyb) Bypass checks due to reborrows being in diff --git a/src/librustc_typeck/check/regionck.rs b/src/librustc_typeck/check/regionck.rs index b5bf59fef9afc..64063ec5beda9 100644 --- a/src/librustc_typeck/check/regionck.rs +++ b/src/librustc_typeck/check/regionck.rs @@ -1063,7 +1063,7 @@ impl<'a, 'gcx, 'tcx> RegionCtxt<'a, 'gcx, 'tcx> { match *autoref { adjustment::AutoBorrow::Ref(r, m) => { self.link_region(expr.span, r, - ty::BorrowKind::from_mutbl(m.into()), expr_cmt); + ty::BorrowKind::from_mutbl(m), expr_cmt); } adjustment::AutoBorrow::RawPtr(m) => { diff --git a/src/librustc_typeck/coherence/inherent_impls_overlap.rs b/src/librustc_typeck/coherence/inherent_impls_overlap.rs index 88a2dc817ae63..07d5f813cbbce 100644 --- a/src/librustc_typeck/coherence/inherent_impls_overlap.rs +++ b/src/librustc_typeck/coherence/inherent_impls_overlap.rs @@ -82,37 +82,29 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> { for (i, &impl1_def_id) in impls.iter().enumerate() { for &impl2_def_id in &impls[(i + 1)..] { - let used_to_be_allowed = traits::overlapping_impls( - self.tcx, - impl1_def_id, - impl2_def_id, - IntercrateMode::Issue43355, - |overlap| { + let used_to_be_allowed = self.tcx.infer_ctxt().enter(|infcx| { + if let Some(overlap) = + traits::overlapping_impls(&infcx, impl1_def_id, impl2_def_id, + IntercrateMode::Issue43355) + { self.check_for_common_items_in_impls( - impl1_def_id, - impl2_def_id, - overlap, - false, - ); + impl1_def_id, impl2_def_id, overlap, false); false - }, - || true, - ); + } else { + true + } + }); if used_to_be_allowed { - traits::overlapping_impls( - self.tcx, - impl1_def_id, - impl2_def_id, - IntercrateMode::Fixed, - |overlap| self.check_for_common_items_in_impls( - impl1_def_id, - impl2_def_id, - overlap, - true, - ), - || (), - ); + self.tcx.infer_ctxt().enter(|infcx| { + if let Some(overlap) = + traits::overlapping_impls(&infcx, impl1_def_id, impl2_def_id, + IntercrateMode::Fixed) + { + self.check_for_common_items_in_impls( + impl1_def_id, impl2_def_id, overlap, true); + } + }); } } } diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index d5328a18c2240..7a91827faef83 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -355,35 +355,41 @@ fn is_param<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } } -fn ensure_no_param_bounds(tcx: TyCtxt, - span: Span, - generics: &hir::Generics, - thing: &'static str) { +fn ensure_no_ty_param_bounds(tcx: TyCtxt, + span: Span, + generics: &hir::Generics, + thing: &'static str) { let mut warn = false; for ty_param in generics.ty_params() { - if !ty_param.bounds.is_empty() { - warn = true; + for bound in ty_param.bounds.iter() { + match *bound { + hir::TraitTyParamBound(..) => { + warn = true; + } + hir::RegionTyParamBound(..) => { } + } } } - for lft_param in generics.lifetimes() { - if !lft_param.bounds.is_empty() { - warn = true; + for predicate in generics.where_clause.predicates.iter() { + match *predicate { + hir::WherePredicate::BoundPredicate(..) => { + warn = true; + } + hir::WherePredicate::RegionPredicate(..) => { } + hir::WherePredicate::EqPredicate(..) => { } } } - if !generics.where_clause.predicates.is_empty() { - warn = true; - } - if warn { // According to accepted RFC #XXX, we should // eventually accept these, but it will not be // part of this PR. Still, convert to warning to // make bootstrapping easier. span_warn!(tcx.sess, span, E0122, - "generic bounds are ignored in {}", + "trait bounds are not (yet) enforced \ + in {} definitions", thing); } } @@ -449,7 +455,7 @@ fn convert_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: ast::NodeId) { } }, hir::ItemTy(_, ref generics) => { - ensure_no_param_bounds(tcx, it.span, generics, "type aliases"); + ensure_no_ty_param_bounds(tcx, it.span, generics, "type"); tcx.generics_of(def_id); tcx.type_of(def_id); tcx.predicates_of(def_id); diff --git a/src/librustc_typeck/diagnostics.rs b/src/librustc_typeck/diagnostics.rs index 1c0e084832ebc..0465a6a0f11bd 100644 --- a/src/librustc_typeck/diagnostics.rs +++ b/src/librustc_typeck/diagnostics.rs @@ -4374,7 +4374,7 @@ yet been inferred. Erroneous code example: -```compile_fail +```compile_fail,E0619 let mut x = vec![]; match x.pop() { Some(v) => { @@ -4699,55 +4699,6 @@ element type `T`. Also note that the error is conservatively reported even when the alignment of the zero-sized type is less than or equal to the data field's alignment. "##, - - -E0908: r##" -A method was called on a raw pointer whose inner type wasn't completely known. - -For example, you may have done something like: - -```compile_fail -# #![deny(warnings)] -let foo = &1; -let bar = foo as *const _; -if bar.is_null() { - // ... -} -``` - -Here, the type of `bar` isn't known; it could be a pointer to anything. Instead, -specify a type for the pointer (preferably something that makes sense for the -thing you're pointing to): - -``` -let foo = &1; -let bar = foo as *const i32; -if bar.is_null() { - // ... -} -``` - -Even though `is_null()` exists as a method on any raw pointer, Rust shows this -error because Rust allows for `self` to have arbitrary types (behind the -arbitrary_self_types feature flag). - -This means that someone can specify such a function: - -```ignore (cannot-doctest-feature-doesnt-exist-yet) -impl Foo { - fn is_null(self: *const Self) -> bool { - // do something else - } -} -``` - -and now when you call `.is_null()` on a raw pointer to `Foo`, there's ambiguity. - -Given that we don't know what type the pointer is, and there's potential -ambiguity for some types, we disallow calling methods on raw pointers when -the type is unknown. -"##, - } register_diagnostics! { diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 66b5f3b5ea366..0929b833c1965 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1051,10 +1051,6 @@ impl Clean for [ast::Attribute] { if UnstableFeatures::from_environment().is_nightly_build() { let dox = attrs.collapsed_doc_value().unwrap_or_else(String::new); for link in markdown_links(&dox, cx.render_type) { - // bail early for real links - if link.contains('/') { - continue; - } let (def, fragment) = { let mut kind = PathKind::Unknown; let path_str = if let Some(prefix) = @@ -2451,12 +2447,7 @@ impl Clean for hir::Ty { let def_id = cx.tcx.hir.body_owner_def_id(n); let param_env = cx.tcx.param_env(def_id); let substs = Substs::identity_for_item(cx.tcx, def_id); - let n = cx.tcx.const_eval(param_env.and((def_id, substs))).unwrap_or_else(|_| { - cx.tcx.mk_const(ty::Const { - val: ConstVal::Unevaluated(def_id, substs), - ty: cx.tcx.types.usize - }) - }); + let n = cx.tcx.const_eval(param_env.and((def_id, substs))).unwrap(); let n = if let ConstVal::Integral(ConstInt::Usize(n)) = n.val { n.to_string() } else if let ConstVal::Unevaluated(def_id, _) = n.val { @@ -2586,9 +2577,7 @@ impl<'tcx> Clean for Ty<'tcx> { let mut n = cx.tcx.lift(&n).unwrap(); if let ConstVal::Unevaluated(def_id, substs) = n.val { let param_env = cx.tcx.param_env(def_id); - if let Ok(new_n) = cx.tcx.const_eval(param_env.and((def_id, substs))) { - n = new_n; - } + n = cx.tcx.const_eval(param_env.and((def_id, substs))).unwrap() }; let n = if let ConstVal::Integral(ConstInt::Usize(n)) = n.val { n.to_string() diff --git a/src/librustdoc/clean/simplify.rs b/src/librustdoc/clean/simplify.rs index 0eb4f9ba7e581..63ebb16e5e009 100644 --- a/src/librustdoc/clean/simplify.rs +++ b/src/librustdoc/clean/simplify.rs @@ -106,9 +106,7 @@ pub fn where_clauses(cx: &DocContext, clauses: Vec) -> Vec { } PP::Parenthesized { ref mut output, .. } => { assert!(output.is_none()); - if *rhs != clean::Type::Tuple(Vec::new()) { - *output = Some(rhs.clone()); - } + *output = Some(rhs.clone()); } }; true diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 82ced00644da8..dce0c4b001a0d 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -872,7 +872,7 @@ pub fn render(w: &mut fmt::Formatter, let link_out = format!("{content}", link = link_buf, title = title.map_or(String::new(), - |t| format!(" title=\"{}\"", Escape(&t))), + |t| format!(" title=\"{}\"", t)), content = content.unwrap_or(String::new())); unsafe { hoedown_buffer_put(ob, link_out.as_ptr(), link_out.len()); } diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index f688be89beebc..0f9e7001c159b 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -47,8 +47,6 @@ // 2 for "In Return Types" var currentTab = 0; - var themesWidth = null; - function hasClass(elem, className) { if (elem && className && elem.className) { var elemClass = elem.className; @@ -123,9 +121,10 @@ sidebar.appendChild(div); } } - var themePicker = document.getElementsByClassName("theme-picker"); - if (themePicker && themePicker.length > 0) { - themePicker[0].style.display = "none"; + document.getElementsByTagName("body")[0].style.marginTop = '45px'; + var themePicker = document.getElementById("theme-picker"); + if (themePicker) { + themePicker.style.position = "fixed"; } } @@ -141,9 +140,9 @@ filler.remove(); } document.getElementsByTagName("body")[0].style.marginTop = ''; - var themePicker = document.getElementsByClassName("theme-picker"); - if (themePicker && themePicker.length > 0) { - themePicker[0].style.display = null; + var themePicker = document.getElementById("theme-picker"); + if (themePicker) { + themePicker.style.position = "absolute"; } } diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index cd4f2cfa678e6..d2eeb2e15b3dd 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -181,19 +181,15 @@ nav.sub { overflow: auto; } -.sidebar .block > ul > li { +.sidebar .current { margin-right: -20px; } -.content, nav { - max-width: 960px; -} +.content, nav { max-width: 960px; } /* Everything else */ -.js-only, .hidden { - display: none !important; -} +.js-only, .hidden { display: none !important; } .sidebar img { margin: 20px auto; @@ -222,9 +218,7 @@ nav.sub { border: none; } -.location a:first-child { - font-weight: 500; -} +.location a:first-child { font-weight: 500; } .block { padding: 0; @@ -305,9 +299,7 @@ nav.sub { -ms-user-select: none; user-select: none; } -.line-numbers span { - cursor: pointer; -} +.line-numbers span { cursor: pointer; } .docblock-short p { display: inline; @@ -325,9 +317,7 @@ nav.sub { text-overflow: ellipsis; margin: 0; } -.docblock-short code { - white-space: nowrap; -} +.docblock-short code { white-space: nowrap; } .docblock h1, .docblock h2, .docblock h3, .docblock h4, .docblock h5 { border-bottom: 1px solid; @@ -394,9 +384,7 @@ h4 > code, h3 > code, .invisible > code { display: inline-block; } -#main { - position: relative; -} +#main { position: relative; } #main > .since { top: inherit; font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif; @@ -440,9 +428,7 @@ h4 > code, h3 > code, .invisible > code { padding: 0; } -.content .item-list li { - margin-bottom: 1em; -} +.content .item-list li { margin-bottom: 1em; } .content .multi-column { -moz-column-count: 5; @@ -870,7 +856,6 @@ span.since { display: block; border-bottom: 1px solid; border-right: 1px solid; - height: 45px; } .sidebar-elems { @@ -890,19 +875,13 @@ span.since { } nav.sub { - width: calc(100% - 32px); - float: right; + margin: 0 auto; } .content { margin-left: 0px; } - #main { - margin-top: 45px; - padding: 0; - } - .content .in-band { width: 100%; } @@ -1049,24 +1028,6 @@ h4 > .important-traits { .show-it { display: block; - width: 246px; - } - - .show-it > .block.items { - margin: 8px 0; - } - - .show-it > .block.items > ul { - margin: 0; - } - - .show-it > .block.items > ul > li { - text-align: center; - margin: 2px 0; - } - - .show-it > .block.items > ul > li > a { - font-size: 21px; } /* Because of ios, we need to actually have a full height sidebar title so the @@ -1223,8 +1184,8 @@ kbd { @media (max-width: 700px) { .theme-picker { - left: 10px; - top: 54px; + left: 109px; + top: 7px; z-index: 1; } } diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index b45c3bf8e5f4e..4c6bcab72b7c9 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -112,13 +112,10 @@ pre { } .content .highlighted a, .content .highlighted span { color: #eee !important; } .content .highlighted.trait { background-color: #013191; } -.content .highlighted.mod, -.content .highlighted.externcrate { background-color: #afc6e4; } .content .highlighted.mod { background-color: #803a1b; } .content .highlighted.externcrate { background-color: #396bac; } .content .highlighted.enum { background-color: #5b4e68; } .content .highlighted.struct { background-color: #194e9f; } -.content .highlighted.union { background-color: #b7bd49; } .content .highlighted.fn, .content .highlighted.method, .content .highlighted.tymethod { background-color: #4950ed; } @@ -386,6 +383,6 @@ kbd { @media (max-width: 700px) { #theme-picker { - background: #f0f0f0; + background: #353535; } } diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index a72026c7d6b27..e39fe20310c28 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -91,7 +91,6 @@ pub mod plugins; pub mod visit_ast; pub mod visit_lib; pub mod test; -pub mod theme; use clean::AttributesExt; @@ -268,11 +267,6 @@ pub fn opts() -> Vec { "additional themes which will be added to the generated docs", "FILES") }), - unstable("theme-checker", |o| { - o.optmulti("", "theme-checker", - "check if given theme is valid", - "FILES") - }), ] } @@ -322,31 +316,6 @@ pub fn main_args(args: &[String]) -> isize { return 0; } - let to_check = matches.opt_strs("theme-checker"); - if !to_check.is_empty() { - let paths = theme::load_css_paths(include_bytes!("html/static/themes/main.css")); - let mut errors = 0; - - println!("rustdoc: [theme-checker] Starting tests!"); - for theme_file in to_check.iter() { - print!(" - Checking \"{}\"...", theme_file); - let (success, differences) = theme::test_theme_against(theme_file, &paths); - if !differences.is_empty() || !success { - println!(" FAILED"); - errors += 1; - if !differences.is_empty() { - println!("{}", differences.join("\n")); - } - } else { - println!(" OK"); - } - } - if errors != 0 { - return 1; - } - return 0; - } - if matches.free.is_empty() { print_error("missing file operand"); return 1; @@ -400,24 +369,12 @@ pub fn main_args(args: &[String]) -> isize { } let mut themes = Vec::new(); - if matches.opt_present("themes") { - let paths = theme::load_css_paths(include_bytes!("html/static/themes/main.css")); - - for (theme_file, theme_s) in matches.opt_strs("themes") - .iter() - .map(|s| (PathBuf::from(&s), s.to_owned())) { - if !theme_file.is_file() { - println!("rustdoc: option --themes arguments must all be files"); - return 1; - } - let (success, ret) = theme::test_theme_against(&theme_file, &paths); - if !success || !ret.is_empty() { - println!("rustdoc: invalid theme: \"{}\"", theme_s); - println!(" Check what's wrong with the \"theme-checker\" option"); - return 1; - } - themes.push(theme_file); + for theme in matches.opt_strs("themes").iter().map(|s| PathBuf::from(&s)) { + if !theme.is_file() { + eprintln!("rustdoc: option --themes arguments must all be files"); + return 1; } + themes.push(theme); } let external_html = match ExternalHtml::load( diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 087d88419bc84..d61b80c9aa03e 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -238,7 +238,6 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize, )); let emitter = errors::emitter::EmitterWriter::new(box Sink(data.clone()), Some(codemap.clone()), - false, false); let old = io::set_panic(Some(box Sink(data.clone()))); let _bomb = Bomb(data.clone(), old.unwrap_or(box io::stdout())); diff --git a/src/librustdoc/theme.rs b/src/librustdoc/theme.rs deleted file mode 100644 index 1e4f64f5c52c9..0000000000000 --- a/src/librustdoc/theme.rs +++ /dev/null @@ -1,379 +0,0 @@ -// Copyright 2012-2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::collections::HashSet; -use std::fs::File; -use std::hash::{Hash, Hasher}; -use std::io::Read; -use std::path::Path; - -macro_rules! try_something { - ($e:expr, $out:expr) => ({ - match $e { - Ok(c) => c, - Err(e) => { - eprintln!("rustdoc: got an error: {}", e); - return $out; - } - } - }) -} - -#[derive(Debug, Clone, Eq)] -pub struct CssPath { - pub name: String, - pub children: HashSet, -} - -// This PartialEq implementation IS NOT COMMUTATIVE!!! -// -// The order is very important: the second object must have all first's rules. -// However, the first doesn't require to have all second's rules. -impl PartialEq for CssPath { - fn eq(&self, other: &CssPath) -> bool { - if self.name != other.name { - false - } else { - for child in &self.children { - if !other.children.iter().any(|c| child == c) { - return false; - } - } - true - } - } -} - -impl Hash for CssPath { - fn hash(&self, state: &mut H) { - self.name.hash(state); - for x in &self.children { - x.hash(state); - } - } -} - -impl CssPath { - fn new(name: String) -> CssPath { - CssPath { - name, - children: HashSet::new(), - } - } -} - -/// All variants contain the position they occur. -#[derive(Debug, Clone, Copy)] -enum Events { - StartLineComment(usize), - StartComment(usize), - EndComment(usize), - InBlock(usize), - OutBlock(usize), -} - -impl Events { - fn get_pos(&self) -> usize { - match *self { - Events::StartLineComment(p) | - Events::StartComment(p) | - Events::EndComment(p) | - Events::InBlock(p) | - Events::OutBlock(p) => p, - } - } - - fn is_comment(&self) -> bool { - match *self { - Events::StartLineComment(_) | - Events::StartComment(_) | - Events::EndComment(_) => true, - _ => false, - } - } -} - -fn previous_is_line_comment(events: &[Events]) -> bool { - if let Some(&Events::StartLineComment(_)) = events.last() { - true - } else { - false - } -} - -fn is_line_comment(pos: usize, v: &[u8], events: &[Events]) -> bool { - if let Some(&Events::StartComment(_)) = events.last() { - return false; - } - pos + 1 < v.len() && v[pos + 1] == b'/' -} - -fn load_css_events(v: &[u8]) -> Vec { - let mut pos = 0; - let mut events = Vec::with_capacity(100); - - while pos < v.len() - 1 { - match v[pos] { - b'/' if pos + 1 < v.len() && v[pos + 1] == b'*' => { - events.push(Events::StartComment(pos)); - pos += 1; - } - b'/' if is_line_comment(pos, v, &events) => { - events.push(Events::StartLineComment(pos)); - pos += 1; - } - b'\n' if previous_is_line_comment(&events) => { - events.push(Events::EndComment(pos)); - } - b'*' if pos + 1 < v.len() && v[pos + 1] == b'/' => { - events.push(Events::EndComment(pos + 2)); - pos += 1; - } - b'{' if !previous_is_line_comment(&events) => { - if let Some(&Events::StartComment(_)) = events.last() { - pos += 1; - continue - } - events.push(Events::InBlock(pos + 1)); - } - b'}' if !previous_is_line_comment(&events) => { - if let Some(&Events::StartComment(_)) = events.last() { - pos += 1; - continue - } - events.push(Events::OutBlock(pos + 1)); - } - _ => {} - } - pos += 1; - } - events -} - -fn get_useful_next(events: &[Events], pos: &mut usize) -> Option { - while *pos < events.len() { - if !events[*pos].is_comment() { - return Some(events[*pos]); - } - *pos += 1; - } - None -} - -fn get_previous_positions(events: &[Events], mut pos: usize) -> Vec { - let mut ret = Vec::with_capacity(3); - - ret.push(events[pos].get_pos()); - if pos > 0 { - pos -= 1; - } - loop { - if pos < 1 || !events[pos].is_comment() { - let x = events[pos].get_pos(); - if *ret.last().unwrap() != x { - ret.push(x); - } else { - ret.push(0); - } - break - } - ret.push(events[pos].get_pos()); - pos -= 1; - } - if ret.len() & 1 != 0 && events[pos].is_comment() { - ret.push(0); - } - ret.iter().rev().cloned().collect() -} - -fn build_rule(v: &[u8], positions: &[usize]) -> String { - positions.chunks(2) - .map(|x| ::std::str::from_utf8(&v[x[0]..x[1]]).unwrap_or("")) - .collect::() - .trim() - .replace("\n", " ") - .replace("/", "") - .replace("\t", " ") - .replace("{", "") - .replace("}", "") - .split(" ") - .filter(|s| s.len() > 0) - .collect::>() - .join(" ") -} - -fn inner(v: &[u8], events: &[Events], pos: &mut usize) -> HashSet { - let mut paths = Vec::with_capacity(50); - - while *pos < events.len() { - if let Some(Events::OutBlock(_)) = get_useful_next(events, pos) { - *pos += 1; - break - } - if let Some(Events::InBlock(_)) = get_useful_next(events, pos) { - paths.push(CssPath::new(build_rule(v, &get_previous_positions(events, *pos)))); - *pos += 1; - } - while let Some(Events::InBlock(_)) = get_useful_next(events, pos) { - if let Some(ref mut path) = paths.last_mut() { - for entry in inner(v, events, pos).iter() { - path.children.insert(entry.clone()); - } - } - } - if let Some(Events::OutBlock(_)) = get_useful_next(events, pos) { - *pos += 1; - } - } - paths.iter().cloned().collect() -} - -pub fn load_css_paths(v: &[u8]) -> CssPath { - let events = load_css_events(v); - let mut pos = 0; - - let mut parent = CssPath::new("parent".to_owned()); - parent.children = inner(v, &events, &mut pos); - parent -} - -pub fn get_differences(against: &CssPath, other: &CssPath, v: &mut Vec) { - if against.name != other.name { - return - } else { - for child in &against.children { - let mut found = false; - let mut found_working = false; - let mut tmp = Vec::new(); - - for other_child in &other.children { - if child.name == other_child.name { - if child != other_child { - get_differences(child, other_child, &mut tmp); - } else { - found_working = true; - } - found = true; - break - } - } - if found == false { - v.push(format!(" Missing \"{}\" rule", child.name)); - } else if found_working == false { - v.extend(tmp.iter().cloned()); - } - } - } -} - -pub fn test_theme_against>(f: &P, against: &CssPath) -> (bool, Vec) { - let mut file = try_something!(File::open(f), (false, Vec::new())); - let mut data = Vec::with_capacity(1000); - - try_something!(file.read_to_end(&mut data), (false, Vec::new())); - let paths = load_css_paths(&data); - let mut ret = Vec::new(); - get_differences(against, &paths, &mut ret); - (true, ret) -} - -#[cfg(test)] -mod test { - use super::*; - - #[test] - fn test_comments_in_rules() { - let text = r#" -rule a {} - -rule b, c -// a line comment -{} - -rule d -// another line comment -e {} - -rule f/* a multine - -comment*/{} - -rule g/* another multine - -comment*/h - -i {} - -rule j/*commeeeeent - -you like things like "{}" in there? :) -*/ -end {}"#; - - let against = r#" -rule a {} - -rule b, c {} - -rule d e {} - -rule f {} - -rule gh i {} - -rule j end {} -"#; - - let mut ret = Vec::new(); - get_differences(&load_css_paths(against.as_bytes()), - &load_css_paths(text.as_bytes()), - &mut ret); - assert!(ret.is_empty()); - } - - #[test] - fn test_text() { - let text = r#" -a -/* sdfs -*/ b -c // sdf -d {} -"#; - let paths = load_css_paths(text.as_bytes()); - assert!(paths.children.contains(&CssPath::new("a b c d".to_owned()))); - } - - #[test] - fn test_comparison() { - let x = r#" -a { - b { - c {} - } -} -"#; - - let y = r#" -a { - b {} -} -"#; - - let against = load_css_paths(y.as_bytes()); - let other = load_css_paths(x.as_bytes()); - - let mut ret = Vec::new(); - get_differences(&against, &other, &mut ret); - assert!(ret.is_empty()); - get_differences(&other, &against, &mut ret); - assert_eq!(ret, vec![" Missing \"c\" rule".to_owned()]); - } -} diff --git a/src/libstd/Cargo.toml b/src/libstd/Cargo.toml index c1fe4a89d6ac0..3430ecabcbeae 100644 --- a/src/libstd/Cargo.toml +++ b/src/libstd/Cargo.toml @@ -48,4 +48,3 @@ jemalloc = ["alloc_jemalloc"] force_alloc_system = [] panic-unwind = ["panic_unwind"] profiler = ["profiler_builtins"] -wasm_syscall = [] diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 82a687ae5e493..b01420f36a0c3 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -1384,14 +1384,9 @@ impl<'a, K, Q: ?Sized, V, S> Index<&'a Q> for HashMap { type Output = V; - /// Returns a reference to the value corresponding to the supplied key. - /// - /// # Panics - /// - /// Panics if the key is not present in the `HashMap`. #[inline] - fn index(&self, key: &Q) -> &V { - self.get(key).expect("no entry found for key") + fn index(&self, index: &Q) -> &V { + self.get(index).expect("no entry found for key") } } diff --git a/src/libstd/f32.rs b/src/libstd/f32.rs index ecf68f29d6f1f..9810dede61821 100644 --- a/src/libstd/f32.rs +++ b/src/libstd/f32.rs @@ -1531,7 +1531,6 @@ mod tests { assert!(nan.to_degrees().is_nan()); assert_eq!(inf.to_degrees(), inf); assert_eq!(neg_inf.to_degrees(), neg_inf); - assert_eq!(1_f32.to_degrees(), 57.2957795130823208767981548141051703); } #[test] diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index e91d3a32a50cd..a19fe825f21fa 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -1026,9 +1026,9 @@ impl CStr { /// The returned slice will **not** contain the trailing nul terminator that this C /// string has. /// - /// > **Note**: This method is currently implemented as a constant-time - /// > cast, but it is planned to alter its definition in the future to - /// > perform the length calculation whenever this method is called. + /// > **Note**: This method is currently implemented as a 0-cost cast, but + /// > it is planned to alter its definition in the future to perform the + /// > length calculation whenever this method is called. /// /// # Examples /// @@ -1077,9 +1077,9 @@ impl CStr { /// it will return an error with details of where UTF-8 validation failed. /// /// > **Note**: This method is currently implemented to check for validity - /// > after a constant-time cast, but it is planned to alter its definition - /// > in the future to perform the length calculation in addition to the - /// > UTF-8 check whenever this method is called. + /// > after a 0-cost cast, but it is planned to alter its definition in the + /// > future to perform the length calculation in addition to the UTF-8 + /// > check whenever this method is called. /// /// [`&str`]: ../primitive.str.html /// @@ -1110,9 +1110,9 @@ impl CStr { /// with the result. /// /// > **Note**: This method is currently implemented to check for validity - /// > after a constant-time cast, but it is planned to alter its definition - /// > in the future to perform the length calculation in addition to the - /// > UTF-8 check whenever this method is called. + /// > after a 0-cost cast, but it is planned to alter its definition in the + /// > future to perform the length calculation in addition to the UTF-8 + /// > check whenever this method is called. /// /// [`Cow`]: ../borrow/enum.Cow.html /// [`Borrowed`]: ../borrow/enum.Cow.html#variant.Borrowed diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs index 5cea389531f94..d1f3ccbd2c6e0 100644 --- a/src/libstd/fs.rs +++ b/src/libstd/fs.rs @@ -482,42 +482,20 @@ impl File { self.inner.file_attr().map(Metadata) } - /// Create a new `File` instance that shares the same underlying file handle - /// as the existing `File` instance. Reads, writes, and seeks will affect - /// both `File` instances simultaneously. + /// Creates a new independently owned handle to the underlying file. /// - /// # Examples - /// - /// Create two handles for a file named `foo.txt`: - /// - /// ```no_run - /// use std::fs::File; + /// The returned `File` is a reference to the same state that this object + /// references. Both handles will read and write with the same cursor + /// position. /// - /// # fn foo() -> std::io::Result<()> { - /// let mut file = File::open("foo.txt")?; - /// let file_copy = file.try_clone()?; - /// # Ok(()) - /// # } - /// ``` - /// - /// Assuming there’s a file named `foo.txt` with contents `abcdef\n`, create - /// two handles, seek one of them, and read the remaining bytes from the - /// other handle: + /// # Examples /// /// ```no_run /// use std::fs::File; - /// use std::io::SeekFrom; - /// use std::io::prelude::*; /// /// # fn foo() -> std::io::Result<()> { - /// let mut file = File::open("foo.txt")?; - /// let mut file_copy = file.try_clone()?; - /// - /// file.seek(SeekFrom::Start(3))?; - /// - /// let mut contents = vec![]; - /// file_copy.read_to_end(&mut contents)?; - /// assert_eq!(contents, b"def\n"); + /// let mut f = File::open("foo.txt")?; + /// let file_copy = f.try_clone()?; /// # Ok(()) /// # } /// ``` @@ -1023,7 +1001,7 @@ impl Metadata { self.0.accessed().map(FromInner::from_inner) } - /// Returns the creation time listed in this metadata. + /// Returns the creation time listed in the this metadata. /// /// The returned value corresponds to the `birthtime` field of `stat` on /// Unix platforms and the `ftCreationTime` field on Windows platforms. diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs index bdd675e6e2b85..f0b41f30251e0 100644 --- a/src/libstd/io/error.rs +++ b/src/libstd/io/error.rs @@ -292,8 +292,8 @@ impl Error { /// # if cfg!(target_os = "linux") { /// use std::io; /// - /// let error = io::Error::from_raw_os_error(22); - /// assert_eq!(error.kind(), io::ErrorKind::InvalidInput); + /// let error = io::Error::from_raw_os_error(98); + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); /// # } /// ``` /// @@ -303,8 +303,8 @@ impl Error { /// # if cfg!(windows) { /// use std::io; /// - /// let error = io::Error::from_raw_os_error(10022); - /// assert_eq!(error.kind(), io::ErrorKind::InvalidInput); + /// let error = io::Error::from_raw_os_error(10048); + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); /// # } /// ``` #[stable(feature = "rust1", since = "1.0.0")] diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 642fa8775a479..a8049e676b3bb 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -260,7 +260,6 @@ #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] #![feature(exact_size_is_empty)] -#![feature(external_doc)] #![feature(fs_read_write)] #![feature(fixed_size_array)] #![feature(float_from_str_radix)] diff --git a/src/libstd/os/raw/mod.rs b/src/libstd/os/raw.rs similarity index 76% rename from src/libstd/os/raw/mod.rs rename to src/libstd/os/raw.rs index d5eeb5252f0f1..279caf8053a85 100644 --- a/src/libstd/os/raw/mod.rs +++ b/src/libstd/os/raw.rs @@ -8,19 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! Platform-specific types, as defined by C. -//! -//! Code that interacts via FFI will almost certainly be using the -//! base types provided by C, which aren't nearly as nicely defined -//! as Rust's primitive types. This module provides types which will -//! match those defined by C, so that code that interacts with C will -//! refer to the correct types. +//! Raw OS-specific types for the current platform/architecture #![stable(feature = "raw_os", since = "1.1.0")] use fmt; -#[doc(include = "os/raw/char.md")] #[cfg(any(all(target_os = "linux", any(target_arch = "aarch64", target_arch = "arm", target_arch = "powerpc", @@ -32,7 +25,6 @@ use fmt; all(target_os = "openbsd", target_arch = "aarch64"), all(target_os = "fuchsia", target_arch = "aarch64")))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = u8; -#[doc(include = "os/raw/char.md")] #[cfg(not(any(all(target_os = "linux", any(target_arch = "aarch64", target_arch = "arm", target_arch = "powerpc", @@ -44,50 +36,30 @@ use fmt; all(target_os = "openbsd", target_arch = "aarch64"), all(target_os = "fuchsia", target_arch = "aarch64"))))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_char = i8; -#[doc(include = "os/raw/schar.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_schar = i8; -#[doc(include = "os/raw/uchar.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_uchar = u8; -#[doc(include = "os/raw/short.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_short = i16; -#[doc(include = "os/raw/ushort.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_ushort = u16; -#[doc(include = "os/raw/int.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_int = i32; -#[doc(include = "os/raw/uint.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_uint = u32; -#[doc(include = "os/raw/long.md")] #[cfg(any(target_pointer_width = "32", windows))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_long = i32; -#[doc(include = "os/raw/ulong.md")] #[cfg(any(target_pointer_width = "32", windows))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_ulong = u32; -#[doc(include = "os/raw/long.md")] #[cfg(all(target_pointer_width = "64", not(windows)))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_long = i64; -#[doc(include = "os/raw/ulong.md")] #[cfg(all(target_pointer_width = "64", not(windows)))] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_ulong = u64; -#[doc(include = "os/raw/longlong.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_longlong = i64; -#[doc(include = "os/raw/ulonglong.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_ulonglong = u64; -#[doc(include = "os/raw/float.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_float = f32; -#[doc(include = "os/raw/double.md")] #[stable(feature = "raw_os", since = "1.1.0")] pub type c_double = f64; -/// Equivalent to C's `void` type when used as a [pointer]. +/// Type used to construct void pointers for use with C. /// -/// In essence, `*const c_void` is equivalent to C's `const void*` -/// and `*mut c_void` is equivalent to C's `void*`. That said, this is -/// *not* the same as C's `void` return type, which is Rust's `()` type. -/// -/// Ideally, this type would be equivalent to [`!`], but currently it may -/// be more ideal to use `c_void` for FFI purposes. -/// -/// [`!`]: ../../primitive.never.html -/// [pointer]: ../../primitive.pointer.html +/// This type is only useful as a pointer target. Do not use it as a +/// return type for FFI functions which have the `void` return type in +/// C. Use the unit type `()` or omit the return type instead. // NB: For LLVM to recognize the void pointer type and by extension // functions like malloc(), we need to have it represented as i8* in // LLVM bitcode. The enum used here ensures this and prevents misuse diff --git a/src/libstd/os/raw/char.md b/src/libstd/os/raw/char.md deleted file mode 100644 index 9a55767d965a6..0000000000000 --- a/src/libstd/os/raw/char.md +++ /dev/null @@ -1,11 +0,0 @@ -Equivalent to C's `char` type. - -[C's `char` type] is completely unlike [Rust's `char` type]; while Rust's type represents a unicode scalar value, C's `char` type is just an ordinary integer. This type will always be either [`i8`] or [`u8`], as the type is defined as being one byte long. - -C chars are most commonly used to make C strings. Unlike Rust, where the length of a string is included alongside the string, C strings mark the end of a string with the character `'\0'`. See [`CStr`] for more information. - -[C's `char` type]: https://en.wikipedia.org/wiki/C_data_types#Basic_types -[Rust's `char` type]: ../../primitive.char.html -[`CStr`]: ../../ffi/struct.CStr.html -[`i8`]: ../../primitive.i8.html -[`u8`]: ../../primitive.u8.html diff --git a/src/libstd/os/raw/double.md b/src/libstd/os/raw/double.md deleted file mode 100644 index 6818dada31793..0000000000000 --- a/src/libstd/os/raw/double.md +++ /dev/null @@ -1,7 +0,0 @@ -Equivalent to C's `double` type. - -This type will almost always be [`f64`], which is guaranteed to be an [IEEE-754 double-precision float] in Rust. That said, the standard technically only guarantees that it be a floating-point number with at least the precision of a [`float`], and it may be `f32` or something entirely different from the IEEE-754 standard. - -[IEEE-754 double-precision float]: https://en.wikipedia.org/wiki/IEEE_754 -[`float`]: type.c_float.html -[`f64`]: ../../primitive.f64.html diff --git a/src/libstd/os/raw/float.md b/src/libstd/os/raw/float.md deleted file mode 100644 index 57d1071d0da17..0000000000000 --- a/src/libstd/os/raw/float.md +++ /dev/null @@ -1,6 +0,0 @@ -Equivalent to C's `float` type. - -This type will almost always be [`f32`], which is guaranteed to be an [IEEE-754 single-precision float] in Rust. That said, the standard technically only guarantees that it be a floating-point number, and it may have less precision than `f32` or not follow the IEEE-754 standard at all. - -[IEEE-754 single-precision float]: https://en.wikipedia.org/wiki/IEEE_754 -[`f32`]: ../../primitive.f32.html diff --git a/src/libstd/os/raw/int.md b/src/libstd/os/raw/int.md deleted file mode 100644 index a0d25fd21d89f..0000000000000 --- a/src/libstd/os/raw/int.md +++ /dev/null @@ -1,7 +0,0 @@ -Equivalent to C's `signed int` (`int`) type. - -This type will almost always be [`i32`], but may differ on some esoteric systems. The C standard technically only requires that this type be a signed integer that is at least the size of a [`short`]; some systems define it as an [`i16`], for example. - -[`short`]: type.c_short.html -[`i32`]: ../../primitive.i32.html -[`i16`]: ../../primitive.i16.html diff --git a/src/libstd/os/raw/long.md b/src/libstd/os/raw/long.md deleted file mode 100644 index c620b402819fd..0000000000000 --- a/src/libstd/os/raw/long.md +++ /dev/null @@ -1,7 +0,0 @@ -Equivalent to C's `signed long` (`long`) type. - -This type will always be [`i32`] or [`i64`]. Most notably, many Linux-based systems assume an `i64`, but Windows assumes `i32`. The C standard technically only requires that this type be a signed integer that is at least 32 bits and at least the size of an [`int`], although in practice, no system would have a `long` that is neither an `i32` nor `i64`. - -[`int`]: type.c_int.html -[`i32`]: ../../primitive.i32.html -[`i64`]: ../../primitive.i64.html diff --git a/src/libstd/os/raw/longlong.md b/src/libstd/os/raw/longlong.md deleted file mode 100644 index ab3d6436568df..0000000000000 --- a/src/libstd/os/raw/longlong.md +++ /dev/null @@ -1,7 +0,0 @@ -Equivalent to C's `signed long long` (`long long`) type. - -This type will almost always be [`i64`], but may differ on some systems. The C standard technically only requires that this type be a signed integer that is at least 64 bits and at least the size of a [`long`], although in practice, no system would have a `long long` that is not an `i64`, as most systems do not have a standardised [`i128`] type. - -[`long`]: type.c_int.html -[`i64`]: ../../primitive.i64.html -[`i128`]: ../../primitive.i128.html diff --git a/src/libstd/os/raw/schar.md b/src/libstd/os/raw/schar.md deleted file mode 100644 index 6aa8b1211d808..0000000000000 --- a/src/libstd/os/raw/schar.md +++ /dev/null @@ -1,6 +0,0 @@ -Equivalent to C's `signed char` type. - -This type will always be [`i8`], but is included for completeness. It is defined as being a signed integer the same size as a C [`char`]. - -[`char`]: type.c_char.html -[`i8`]: ../../primitive.i8.html diff --git a/src/libstd/os/raw/short.md b/src/libstd/os/raw/short.md deleted file mode 100644 index be92c6c106d59..0000000000000 --- a/src/libstd/os/raw/short.md +++ /dev/null @@ -1,6 +0,0 @@ -Equivalent to C's `signed short` (`short`) type. - -This type will almost always be [`i16`], but may differ on some esoteric systems. The C standard technically only requires that this type be a signed integer with at least 16 bits; some systems may define it as `i32`, for example. - -[`char`]: type.c_char.html -[`i16`]: ../../primitive.i16.html diff --git a/src/libstd/os/raw/uchar.md b/src/libstd/os/raw/uchar.md deleted file mode 100644 index b6ca711f86934..0000000000000 --- a/src/libstd/os/raw/uchar.md +++ /dev/null @@ -1,6 +0,0 @@ -Equivalent to C's `unsigned char` type. - -This type will always be [`u8`], but is included for completeness. It is defined as being an unsigned integer the same size as a C [`char`]. - -[`char`]: type.c_char.html -[`u8`]: ../../primitive.u8.html diff --git a/src/libstd/os/raw/uint.md b/src/libstd/os/raw/uint.md deleted file mode 100644 index 6f7013a8ac18d..0000000000000 --- a/src/libstd/os/raw/uint.md +++ /dev/null @@ -1,7 +0,0 @@ -Equivalent to C's `unsigned int` type. - -This type will almost always be [`u32`], but may differ on some esoteric systems. The C standard technically only requires that this type be an unsigned integer with the same size as an [`int`]; some systems define it as a [`u16`], for example. - -[`int`]: type.c_int.html -[`u32`]: ../../primitive.u32.html -[`u16`]: ../../primitive.u16.html diff --git a/src/libstd/os/raw/ulong.md b/src/libstd/os/raw/ulong.md deleted file mode 100644 index c350395080e80..0000000000000 --- a/src/libstd/os/raw/ulong.md +++ /dev/null @@ -1,7 +0,0 @@ -Equivalent to C's `unsigned long` type. - -This type will always be [`u32`] or [`u64`]. Most notably, many Linux-based systems assume an `u64`, but Windows assumes `u32`. The C standard technically only requires that this type be an unsigned integer with the size of a [`long`], although in practice, no system would have a `ulong` that is neither a `u32` nor `u64`. - -[`long`]: type.c_long.html -[`u32`]: ../../primitive.u32.html -[`u64`]: ../../primitive.u64.html diff --git a/src/libstd/os/raw/ulonglong.md b/src/libstd/os/raw/ulonglong.md deleted file mode 100644 index c41faf74c5c68..0000000000000 --- a/src/libstd/os/raw/ulonglong.md +++ /dev/null @@ -1,7 +0,0 @@ -Equivalent to C's `unsigned long long` type. - -This type will almost always be [`u64`], but may differ on some systems. The C standard technically only requires that this type be an unsigned integer with the size of a [`long long`], although in practice, no system would have a `long long` that is not a `u64`, as most systems do not have a standardised [`u128`] type. - -[`long long`]: type.c_longlong.html -[`u64`]: ../../primitive.u64.html -[`u128`]: ../../primitive.u128.html diff --git a/src/libstd/os/raw/ushort.md b/src/libstd/os/raw/ushort.md deleted file mode 100644 index d364abb3c8e0c..0000000000000 --- a/src/libstd/os/raw/ushort.md +++ /dev/null @@ -1,6 +0,0 @@ -Equivalent to C's `unsigned short` type. - -This type will almost always be [`u16`], but may differ on some esoteric systems. The C standard technically only requires that this type be an unsigned integer with the same size as a [`short`]. - -[`short`]: type.c_short.html -[`u16`]: ../../primitive.u16.html diff --git a/src/libstd/panic.rs b/src/libstd/panic.rs index 112e110609310..560876006d3f3 100644 --- a/src/libstd/panic.rs +++ b/src/libstd/panic.rs @@ -198,7 +198,7 @@ impl UnwindSafe for *const T {} impl UnwindSafe for *mut T {} #[unstable(feature = "ptr_internals", issue = "0")] impl UnwindSafe for Unique {} -#[stable(feature = "nonnull", since = "1.25.0")] +#[stable(feature = "nonnull", since = "1.24.0")] impl UnwindSafe for NonNull {} #[stable(feature = "catch_unwind", since = "1.9.0")] impl UnwindSafe for Mutex {} diff --git a/src/libstd/process.rs b/src/libstd/process.rs index 9b2f815b71383..5c66ac6ddded8 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -1843,10 +1843,4 @@ mod tests { } assert!(events > 0); } - - #[test] - fn test_command_implements_send() { - fn take_send_type(_: T) {} - take_send_type(Command::new("")) - } } diff --git a/src/libstd/sys/cloudabi/thread.rs b/src/libstd/sys/cloudabi/thread.rs index 78a3b82546e3a..c980ae75261ca 100644 --- a/src/libstd/sys/cloudabi/thread.rs +++ b/src/libstd/sys/cloudabi/thread.rs @@ -111,11 +111,10 @@ impl Drop for Thread { #[cfg_attr(test, allow(dead_code))] pub mod guard { - pub type Guard = !; - pub unsafe fn current() -> Option { + pub unsafe fn current() -> Option { None } - pub unsafe fn init() -> Option { + pub unsafe fn init() -> Option { None } } diff --git a/src/libstd/sys/redox/thread.rs b/src/libstd/sys/redox/thread.rs index c4719a94c7e9d..c4aad8d86f8b1 100644 --- a/src/libstd/sys/redox/thread.rs +++ b/src/libstd/sys/redox/thread.rs @@ -88,7 +88,6 @@ impl Thread { } pub mod guard { - pub type Guard = !; - pub unsafe fn current() -> Option { None } - pub unsafe fn init() -> Option { None } + pub unsafe fn current() -> Option { None } + pub unsafe fn init() -> Option { None } } diff --git a/src/libstd/sys/unix/process/process_common.rs b/src/libstd/sys/unix/process/process_common.rs index 7e057401fab70..c53bcdbf8e36f 100644 --- a/src/libstd/sys/unix/process/process_common.rs +++ b/src/libstd/sys/unix/process/process_common.rs @@ -45,7 +45,7 @@ pub struct Command { // other keys. program: CString, args: Vec, - argv: Argv, + argv: Vec<*const c_char>, env: CommandEnv, cwd: Option, @@ -58,12 +58,6 @@ pub struct Command { stderr: Option, } -// Create a new type for argv, so that we can make it `Send` -struct Argv(Vec<*const c_char>); - -// It is safe to make Argv Send, because it contains pointers to memory owned by `Command.args` -unsafe impl Send for Argv {} - // passed back to std::process with the pipes connected to the child, if any // were requested pub struct StdioPipes { @@ -98,7 +92,7 @@ impl Command { let mut saw_nul = false; let program = os2c(program, &mut saw_nul); Command { - argv: Argv(vec![program.as_ptr(), ptr::null()]), + argv: vec![program.as_ptr(), ptr::null()], program, args: Vec::new(), env: Default::default(), @@ -117,8 +111,8 @@ impl Command { // Overwrite the trailing NULL pointer in `argv` and then add a new null // pointer. let arg = os2c(arg, &mut self.saw_nul); - self.argv.0[self.args.len() + 1] = arg.as_ptr(); - self.argv.0.push(ptr::null()); + self.argv[self.args.len() + 1] = arg.as_ptr(); + self.argv.push(ptr::null()); // Also make sure we keep track of the owned value to schedule a // destructor for this memory. @@ -139,7 +133,7 @@ impl Command { self.saw_nul } pub fn get_argv(&self) -> &Vec<*const c_char> { - &self.argv.0 + &self.argv } #[allow(dead_code)] diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs index 40453f9b8a15b..51adbc24ae047 100644 --- a/src/libstd/sys/unix/stack_overflow.rs +++ b/src/libstd/sys/unix/stack_overflow.rs @@ -57,6 +57,9 @@ mod imp { use sys_common::thread_info; + // This is initialized in init() and only read from after + static mut PAGE_SIZE: usize = 0; + #[cfg(any(target_os = "linux", target_os = "android"))] unsafe fn siginfo_si_addr(info: *mut libc::siginfo_t) -> usize { #[repr(C)] @@ -99,12 +102,12 @@ mod imp { _data: *mut libc::c_void) { use sys_common::util::report_overflow; - let guard = thread_info::stack_guard().unwrap_or(0..0); + let guard = thread_info::stack_guard().unwrap_or(0); let addr = siginfo_si_addr(info); // If the faulting address is within the guard page, then we print a // message saying so and abort. - if guard.start <= addr && addr < guard.end { + if guard != 0 && guard - PAGE_SIZE <= addr && addr < guard { report_overflow(); rtabort!("stack overflow"); } else { @@ -120,6 +123,8 @@ mod imp { static mut MAIN_ALTSTACK: *mut libc::c_void = ptr::null_mut(); pub unsafe fn init() { + PAGE_SIZE = ::sys::os::page_size(); + let mut action: sigaction = mem::zeroed(); action.sa_flags = SA_SIGINFO | SA_ONSTACK; action.sa_sigaction = signal_handler as sighandler_t; diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs index 72cdb9440b8e7..525882c1e1ebb 100644 --- a/src/libstd/sys/unix/thread.rs +++ b/src/libstd/sys/unix/thread.rs @@ -205,10 +205,8 @@ impl Drop for Thread { not(target_os = "solaris")))] #[cfg_attr(test, allow(dead_code))] pub mod guard { - use ops::Range; - pub type Guard = Range; - pub unsafe fn current() -> Option { None } - pub unsafe fn init() -> Option { None } + pub unsafe fn current() -> Option { None } + pub unsafe fn init() -> Option { None } } @@ -224,43 +222,14 @@ pub mod guard { use libc; use libc::mmap; use libc::{PROT_NONE, MAP_PRIVATE, MAP_ANON, MAP_FAILED, MAP_FIXED}; - use ops::Range; use sys::os; - // This is initialized in init() and only read from after - static mut PAGE_SIZE: usize = 0; - - pub type Guard = Range; - - #[cfg(target_os = "solaris")] - unsafe fn get_stack_start() -> Option<*mut libc::c_void> { - let mut current_stack: libc::stack_t = ::mem::zeroed(); - assert_eq!(libc::stack_getbounds(&mut current_stack), 0); - Some(current_stack.ss_sp) - } - - #[cfg(target_os = "macos")] - unsafe fn get_stack_start() -> Option<*mut libc::c_void> { - let stackaddr = libc::pthread_get_stackaddr_np(libc::pthread_self()) as usize - - libc::pthread_get_stacksize_np(libc::pthread_self()); - Some(stackaddr as *mut libc::c_void) - } - - #[cfg(any(target_os = "openbsd", target_os = "bitrig"))] + #[cfg(any(target_os = "macos", + target_os = "bitrig", + target_os = "openbsd", + target_os = "solaris"))] unsafe fn get_stack_start() -> Option<*mut libc::c_void> { - let mut current_stack: libc::stack_t = ::mem::zeroed(); - assert_eq!(libc::pthread_stackseg_np(libc::pthread_self(), - &mut current_stack), 0); - - let extra = if cfg!(target_os = "bitrig") {3} else {1} * PAGE_SIZE; - let stackaddr = if libc::pthread_main_np() == 1 { - // main thread - current_stack.ss_sp as usize - current_stack.ss_size + extra - } else { - // new thread - current_stack.ss_sp as usize - current_stack.ss_size - }; - Some(stackaddr as *mut libc::c_void) + current().map(|s| s as *mut libc::c_void) } #[cfg(any(target_os = "android", target_os = "freebsd", @@ -284,9 +253,8 @@ pub mod guard { ret } - pub unsafe fn init() -> Option { - PAGE_SIZE = os::page_size(); - + pub unsafe fn init() -> Option { + let psize = os::page_size(); let mut stackaddr = get_stack_start()?; // Ensure stackaddr is page aligned! A parent process might @@ -295,9 +263,9 @@ pub mod guard { // stackaddr < stackaddr + stacksize, so if stackaddr is not // page-aligned, calculate the fix such that stackaddr < // new_page_aligned_stackaddr < stackaddr + stacksize - let remainder = (stackaddr as usize) % PAGE_SIZE; + let remainder = (stackaddr as usize) % psize; if remainder != 0 { - stackaddr = ((stackaddr as usize) + PAGE_SIZE - remainder) + stackaddr = ((stackaddr as usize) + psize - remainder) as *mut libc::c_void; } @@ -312,42 +280,60 @@ pub mod guard { // Instead, we'll just note where we expect rlimit to start // faulting, so our handler can report "stack overflow", and // trust that the kernel's own stack guard will work. - let stackaddr = stackaddr as usize; - Some(stackaddr - PAGE_SIZE..stackaddr) + Some(stackaddr as usize) } else { // Reallocate the last page of the stack. // This ensures SIGBUS will be raised on // stack overflow. - let result = mmap(stackaddr, PAGE_SIZE, PROT_NONE, + let result = mmap(stackaddr, psize, PROT_NONE, MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0); if result != stackaddr || result == MAP_FAILED { panic!("failed to allocate a guard page"); } - let guardaddr = stackaddr as usize; let offset = if cfg!(target_os = "freebsd") { 2 } else { 1 }; - Some(guardaddr..guardaddr + offset * PAGE_SIZE) + Some(stackaddr as usize + offset * psize) } } - #[cfg(any(target_os = "macos", - target_os = "bitrig", - target_os = "openbsd", - target_os = "solaris"))] - pub unsafe fn current() -> Option { - let stackaddr = get_stack_start()? as usize; - Some(stackaddr - PAGE_SIZE..stackaddr) + #[cfg(target_os = "solaris")] + pub unsafe fn current() -> Option { + let mut current_stack: libc::stack_t = ::mem::zeroed(); + assert_eq!(libc::stack_getbounds(&mut current_stack), 0); + Some(current_stack.ss_sp as usize) + } + + #[cfg(target_os = "macos")] + pub unsafe fn current() -> Option { + Some(libc::pthread_get_stackaddr_np(libc::pthread_self()) as usize - + libc::pthread_get_stacksize_np(libc::pthread_self())) + } + + #[cfg(any(target_os = "openbsd", target_os = "bitrig"))] + pub unsafe fn current() -> Option { + let mut current_stack: libc::stack_t = ::mem::zeroed(); + assert_eq!(libc::pthread_stackseg_np(libc::pthread_self(), + &mut current_stack), 0); + + let extra = if cfg!(target_os = "bitrig") {3} else {1} * os::page_size(); + Some(if libc::pthread_main_np() == 1 { + // main thread + current_stack.ss_sp as usize - current_stack.ss_size + extra + } else { + // new thread + current_stack.ss_sp as usize - current_stack.ss_size + }) } #[cfg(any(target_os = "android", target_os = "freebsd", target_os = "linux", target_os = "netbsd", target_os = "l4re"))] - pub unsafe fn current() -> Option { + pub unsafe fn current() -> Option { let mut ret = None; let mut attr: libc::pthread_attr_t = ::mem::zeroed(); assert_eq!(libc::pthread_attr_init(&mut attr), 0); @@ -366,23 +352,12 @@ pub mod guard { assert_eq!(libc::pthread_attr_getstack(&attr, &mut stackaddr, &mut size), 0); - let stackaddr = stackaddr as usize; ret = if cfg!(target_os = "freebsd") { - // FIXME does freebsd really fault *below* the guard addr? - let guardaddr = stackaddr - guardsize; - Some(guardaddr - PAGE_SIZE..guardaddr) + Some(stackaddr as usize - guardsize) } else if cfg!(target_os = "netbsd") { - Some(stackaddr - guardsize..stackaddr) - } else if cfg!(all(target_os = "linux", target_env = "gnu")) { - // glibc used to include the guard area within the stack, as noted in the BUGS - // section of `man pthread_attr_getguardsize`. This has been corrected starting - // with glibc 2.27, and in some distro backports, so the guard is now placed at the - // end (below) the stack. There's no easy way for us to know which we have at - // runtime, so we'll just match any fault in the range right above or below the - // stack base to call that fault a stack overflow. - Some(stackaddr - guardsize..stackaddr + guardsize) + Some(stackaddr as usize) } else { - Some(stackaddr..stackaddr + guardsize) + Some(stackaddr as usize + guardsize) }; } assert_eq!(libc::pthread_attr_destroy(&mut attr), 0); diff --git a/src/libstd/sys/wasm/args.rs b/src/libstd/sys/wasm/args.rs index b3c6b671e8099..d2a4a7b19d548 100644 --- a/src/libstd/sys/wasm/args.rs +++ b/src/libstd/sys/wasm/args.rs @@ -10,8 +10,8 @@ use ffi::OsString; use marker::PhantomData; +use mem; use vec; -use sys::ArgsSysCall; pub unsafe fn init(_argc: isize, _argv: *const *const u8) { // On wasm these should always be null, so there's nothing for us to do here @@ -21,10 +21,38 @@ pub unsafe fn cleanup() { } pub fn args() -> Args { - let v = ArgsSysCall::perform(); - Args { - iter: v.into_iter(), - _dont_send_or_sync_me: PhantomData, + // When the runtime debugging is enabled we'll link to some extra runtime + // functions to actually implement this. These are for now just implemented + // in a node.js script but they're off by default as they're sort of weird + // in a web-wasm world. + if !super::DEBUG { + return Args { + iter: Vec::new().into_iter(), + _dont_send_or_sync_me: PhantomData, + } + } + + // You'll find the definitions of these in `src/etc/wasm32-shim.js`. These + // are just meant for debugging and should not be relied on. + extern { + fn rust_wasm_args_count() -> usize; + fn rust_wasm_args_arg_size(a: usize) -> usize; + fn rust_wasm_args_arg_fill(a: usize, ptr: *mut u8); + } + + unsafe { + let cnt = rust_wasm_args_count(); + let mut v = Vec::with_capacity(cnt); + for i in 0..cnt { + let n = rust_wasm_args_arg_size(i); + let mut data = vec![0; n]; + rust_wasm_args_arg_fill(i, data.as_mut_ptr()); + v.push(mem::transmute::, OsString>(data)); + } + Args { + iter: v.into_iter(), + _dont_send_or_sync_me: PhantomData, + } } } diff --git a/src/libstd/sys/wasm/mod.rs b/src/libstd/sys/wasm/mod.rs index c02e5e809c8bb..ba3d6a2813a45 100644 --- a/src/libstd/sys/wasm/mod.rs +++ b/src/libstd/sys/wasm/mod.rs @@ -26,11 +26,17 @@ use io; use os::raw::c_char; -use ptr; -use sys::os_str::Buf; -use sys_common::{AsInner, FromInner}; -use ffi::{OsString, OsStr}; -use time::Duration; + +// Right now the wasm backend doesn't even have the ability to print to the +// console by default. Wasm can't import anything from JS! (you have to +// explicitly provide it). +// +// Sometimes that's a real bummer, though, so this flag can be set to `true` to +// enable calling various shims defined in `src/etc/wasm32-shim.js` which should +// help receive debug output and see what's going on. In general this flag +// currently controls "will we call out to our own defined shims in node.js", +// and this flag should always be `false` for release builds. +const DEBUG: bool = false; pub mod args; #[cfg(feature = "backtrace")] @@ -86,7 +92,7 @@ pub unsafe fn strlen(mut s: *const c_char) -> usize { } pub unsafe fn abort_internal() -> ! { - ExitSysCall::perform(1) + ::intrinsics::abort(); } // We don't have randomness yet, but I totally used a random number generator to @@ -97,218 +103,3 @@ pub unsafe fn abort_internal() -> ! { pub fn hashmap_random_keys() -> (u64, u64) { (1, 2) } - -// Implement a minimal set of system calls to enable basic IO -pub enum SysCallIndex { - Read = 0, - Write = 1, - Exit = 2, - Args = 3, - GetEnv = 4, - SetEnv = 5, - Time = 6, -} - -#[repr(C)] -pub struct ReadSysCall { - fd: usize, - ptr: *mut u8, - len: usize, - result: usize, -} - -impl ReadSysCall { - pub fn perform(fd: usize, buffer: &mut [u8]) -> usize { - let mut call_record = ReadSysCall { - fd, - len: buffer.len(), - ptr: buffer.as_mut_ptr(), - result: 0 - }; - if unsafe { syscall(SysCallIndex::Read, &mut call_record) } { - call_record.result - } else { - 0 - } - } -} - -#[repr(C)] -pub struct WriteSysCall { - fd: usize, - ptr: *const u8, - len: usize, -} - -impl WriteSysCall { - pub fn perform(fd: usize, buffer: &[u8]) { - let mut call_record = WriteSysCall { - fd, - len: buffer.len(), - ptr: buffer.as_ptr() - }; - unsafe { syscall(SysCallIndex::Write, &mut call_record); } - } -} - -#[repr(C)] -pub struct ExitSysCall { - code: usize, -} - -impl ExitSysCall { - pub fn perform(code: usize) -> ! { - let mut call_record = ExitSysCall { - code - }; - unsafe { - syscall(SysCallIndex::Exit, &mut call_record); - ::intrinsics::abort(); - } - } -} - -fn receive_buffer Result>(estimate: usize, mut f: F) - -> Result, E> -{ - let mut buffer = vec![0; estimate]; - loop { - let result = f(&mut buffer)?; - if result <= buffer.len() { - buffer.truncate(result); - break; - } - buffer.resize(result, 0); - } - Ok(buffer) -} - -#[repr(C)] -pub struct ArgsSysCall { - ptr: *mut u8, - len: usize, - result: usize -} - -impl ArgsSysCall { - pub fn perform() -> Vec { - receive_buffer(1024, |buffer| -> Result { - let mut call_record = ArgsSysCall { - len: buffer.len(), - ptr: buffer.as_mut_ptr(), - result: 0 - }; - if unsafe { syscall(SysCallIndex::Args, &mut call_record) } { - Ok(call_record.result) - } else { - Ok(0) - } - }) - .unwrap() - .split(|b| *b == 0) - .map(|s| FromInner::from_inner(Buf { inner: s.to_owned() })) - .collect() - } -} - -#[repr(C)] -pub struct GetEnvSysCall { - key_ptr: *const u8, - key_len: usize, - value_ptr: *mut u8, - value_len: usize, - result: usize -} - -impl GetEnvSysCall { - pub fn perform(key: &OsStr) -> Option { - let key_buf = &AsInner::as_inner(key).inner; - receive_buffer(64, |buffer| { - let mut call_record = GetEnvSysCall { - key_len: key_buf.len(), - key_ptr: key_buf.as_ptr(), - value_len: buffer.len(), - value_ptr: buffer.as_mut_ptr(), - result: !0usize - }; - if unsafe { syscall(SysCallIndex::GetEnv, &mut call_record) } { - if call_record.result == !0usize { - Err(()) - } else { - Ok(call_record.result) - } - } else { - Err(()) - } - }).ok().map(|s| { - FromInner::from_inner(Buf { inner: s }) - }) - } -} - -#[repr(C)] -pub struct SetEnvSysCall { - key_ptr: *const u8, - key_len: usize, - value_ptr: *const u8, - value_len: usize -} - -impl SetEnvSysCall { - pub fn perform(key: &OsStr, value: Option<&OsStr>) { - let key_buf = &AsInner::as_inner(key).inner; - let value_buf = value.map(|v| &AsInner::as_inner(v).inner); - let mut call_record = SetEnvSysCall { - key_len: key_buf.len(), - key_ptr: key_buf.as_ptr(), - value_len: value_buf.map(|v| v.len()).unwrap_or(!0usize), - value_ptr: value_buf.map(|v| v.as_ptr()).unwrap_or(ptr::null()) - }; - unsafe { syscall(SysCallIndex::SetEnv, &mut call_record); } - } -} - -pub enum TimeClock { - Monotonic = 0, - System = 1, -} - -#[repr(C)] -pub struct TimeSysCall { - clock: usize, - secs_hi: usize, - secs_lo: usize, - nanos: usize -} - -impl TimeSysCall { - pub fn perform(clock: TimeClock) -> Duration { - let mut call_record = TimeSysCall { - clock: clock as usize, - secs_hi: 0, - secs_lo: 0, - nanos: 0 - }; - if unsafe { syscall(SysCallIndex::Time, &mut call_record) } { - Duration::new( - ((call_record.secs_hi as u64) << 32) | (call_record.secs_lo as u64), - call_record.nanos as u32 - ) - } else { - panic!("Time system call is not implemented by WebAssembly host"); - } - } -} - -unsafe fn syscall(index: SysCallIndex, data: &mut T) -> bool { - #[cfg(feature = "wasm_syscall")] - extern { - #[no_mangle] - fn rust_wasm_syscall(index: usize, data: *mut Void) -> usize; - } - - #[cfg(not(feature = "wasm_syscall"))] - unsafe fn rust_wasm_syscall(_index: usize, _data: *mut Void) -> usize { 0 } - - rust_wasm_syscall(index as usize, data as *mut T as *mut Void) != 0 -} diff --git a/src/libstd/sys/wasm/os.rs b/src/libstd/sys/wasm/os.rs index 23ca1754719be..c98030f7ebf53 100644 --- a/src/libstd/sys/wasm/os.rs +++ b/src/libstd/sys/wasm/os.rs @@ -8,13 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use core::intrinsics; + use error::Error as StdError; use ffi::{OsString, OsStr}; use fmt; use io; +use mem; use path::{self, PathBuf}; use str; -use sys::{unsupported, Void, ExitSysCall, GetEnvSysCall, SetEnvSysCall}; +use sys::{unsupported, Void}; pub fn errno() -> i32 { 0 @@ -84,15 +87,36 @@ pub fn env() -> Env { } pub fn getenv(k: &OsStr) -> io::Result> { - Ok(GetEnvSysCall::perform(k)) + // If we're debugging the runtime then we actually probe node.js to ask for + // the value of environment variables to help provide inputs to programs. + // The `extern` shims here are defined in `src/etc/wasm32-shim.js` and are + // intended for debugging only, you should not rely on them. + if !super::DEBUG { + return Ok(None) + } + + extern { + fn rust_wasm_getenv_len(k: *const u8, kl: usize) -> isize; + fn rust_wasm_getenv_data(k: *const u8, kl: usize, v: *mut u8); + } + unsafe { + let k: &[u8] = mem::transmute(k); + let n = rust_wasm_getenv_len(k.as_ptr(), k.len()); + if n == -1 { + return Ok(None) + } + let mut data = vec![0; n as usize]; + rust_wasm_getenv_data(k.as_ptr(), k.len(), data.as_mut_ptr()); + Ok(Some(mem::transmute(data))) + } } -pub fn setenv(k: &OsStr, v: &OsStr) -> io::Result<()> { - Ok(SetEnvSysCall::perform(k, Some(v))) +pub fn setenv(_k: &OsStr, _v: &OsStr) -> io::Result<()> { + unsupported() } -pub fn unsetenv(k: &OsStr) -> io::Result<()> { - Ok(SetEnvSysCall::perform(k, None)) +pub fn unsetenv(_n: &OsStr) -> io::Result<()> { + unsupported() } pub fn temp_dir() -> PathBuf { @@ -104,7 +128,7 @@ pub fn home_dir() -> Option { } pub fn exit(_code: i32) -> ! { - ExitSysCall::perform(_code as isize as usize) + unsafe { intrinsics::abort() } } pub fn getpid() -> u32 { diff --git a/src/libstd/sys/wasm/stdio.rs b/src/libstd/sys/wasm/stdio.rs index beb19c0ed2c1f..0f75f24025183 100644 --- a/src/libstd/sys/wasm/stdio.rs +++ b/src/libstd/sys/wasm/stdio.rs @@ -9,19 +9,19 @@ // except according to those terms. use io; -use sys::{ReadSysCall, WriteSysCall}; +use sys::{Void, unsupported}; -pub struct Stdin; +pub struct Stdin(Void); pub struct Stdout; pub struct Stderr; impl Stdin { pub fn new() -> io::Result { - Ok(Stdin) + unsupported() } - pub fn read(&self, data: &mut [u8]) -> io::Result { - Ok(ReadSysCall::perform(0, data)) + pub fn read(&self, _data: &mut [u8]) -> io::Result { + match self.0 {} } } @@ -31,7 +31,19 @@ impl Stdout { } pub fn write(&self, data: &[u8]) -> io::Result { - WriteSysCall::perform(1, data); + // If runtime debugging is enabled at compile time we'll invoke some + // runtime functions that are defined in our src/etc/wasm32-shim.js + // debugging script. Note that this ffi function call is intended + // *purely* for debugging only and should not be relied upon. + if !super::DEBUG { + return unsupported() + } + extern { + fn rust_wasm_write_stdout(data: *const u8, len: usize); + } + unsafe { + rust_wasm_write_stdout(data.as_ptr(), data.len()) + } Ok(data.len()) } @@ -46,7 +58,16 @@ impl Stderr { } pub fn write(&self, data: &[u8]) -> io::Result { - WriteSysCall::perform(2, data); + // See comments in stdout for what's going on here. + if !super::DEBUG { + return unsupported() + } + extern { + fn rust_wasm_write_stderr(data: *const u8, len: usize); + } + unsafe { + rust_wasm_write_stderr(data.as_ptr(), data.len()) + } Ok(data.len()) } diff --git a/src/libstd/sys/wasm/thread.rs b/src/libstd/sys/wasm/thread.rs index 6a066509b492a..13980e0cc19d1 100644 --- a/src/libstd/sys/wasm/thread.rs +++ b/src/libstd/sys/wasm/thread.rs @@ -43,7 +43,6 @@ impl Thread { } pub mod guard { - pub type Guard = !; - pub unsafe fn current() -> Option { None } - pub unsafe fn init() -> Option { None } + pub unsafe fn current() -> Option { None } + pub unsafe fn init() -> Option { None } } diff --git a/src/libstd/sys/wasm/time.rs b/src/libstd/sys/wasm/time.rs index e52435e63398f..c269def98f6ff 100644 --- a/src/libstd/sys/wasm/time.rs +++ b/src/libstd/sys/wasm/time.rs @@ -8,50 +8,56 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +use fmt; use time::Duration; -use sys::{TimeSysCall, TimeClock}; #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] -pub struct Instant(Duration); +pub struct Instant; -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] -pub struct SystemTime(Duration); +#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct SystemTime; -pub const UNIX_EPOCH: SystemTime = SystemTime(Duration::from_secs(0)); +pub const UNIX_EPOCH: SystemTime = SystemTime; impl Instant { pub fn now() -> Instant { - Instant(TimeSysCall::perform(TimeClock::Monotonic)) + panic!("not supported on web assembly"); } - pub fn sub_instant(&self, other: &Instant) -> Duration { - self.0 - other.0 + pub fn sub_instant(&self, _other: &Instant) -> Duration { + panic!("can't sub yet"); } - pub fn add_duration(&self, other: &Duration) -> Instant { - Instant(self.0 + *other) + pub fn add_duration(&self, _other: &Duration) -> Instant { + panic!("can't add yet"); } - pub fn sub_duration(&self, other: &Duration) -> Instant { - Instant(self.0 - *other) + pub fn sub_duration(&self, _other: &Duration) -> Instant { + panic!("can't sub yet"); } } impl SystemTime { pub fn now() -> SystemTime { - SystemTime(TimeSysCall::perform(TimeClock::System)) + panic!("not supported on web assembly"); } - pub fn sub_time(&self, other: &SystemTime) + pub fn sub_time(&self, _other: &SystemTime) -> Result { - self.0.checked_sub(other.0).ok_or_else(|| other.0 - self.0) + panic!() + } + + pub fn add_duration(&self, _other: &Duration) -> SystemTime { + panic!() } - pub fn add_duration(&self, other: &Duration) -> SystemTime { - SystemTime(self.0 + *other) + pub fn sub_duration(&self, _other: &Duration) -> SystemTime { + panic!() } +} - pub fn sub_duration(&self, other: &Duration) -> SystemTime { - SystemTime(self.0 - *other) +impl fmt::Debug for SystemTime { + fn fmt(&self, _f: &mut fmt::Formatter) -> fmt::Result { + panic!() } } diff --git a/src/libstd/sys/windows/thread.rs b/src/libstd/sys/windows/thread.rs index 43abfbb1f645e..74786d092855f 100644 --- a/src/libstd/sys/windows/thread.rs +++ b/src/libstd/sys/windows/thread.rs @@ -93,7 +93,6 @@ impl Thread { #[cfg_attr(test, allow(dead_code))] pub mod guard { - pub type Guard = !; - pub unsafe fn current() -> Option { None } - pub unsafe fn init() -> Option { None } + pub unsafe fn current() -> Option { None } + pub unsafe fn init() -> Option { None } } diff --git a/src/libstd/sys_common/thread_info.rs b/src/libstd/sys_common/thread_info.rs index 6a2b6742367a5..7970042b1d67d 100644 --- a/src/libstd/sys_common/thread_info.rs +++ b/src/libstd/sys_common/thread_info.rs @@ -11,11 +11,10 @@ #![allow(dead_code)] // stack_guard isn't used right now on all platforms use cell::RefCell; -use sys::thread::guard::Guard; use thread::Thread; struct ThreadInfo { - stack_guard: Option, + stack_guard: Option, thread: Thread, } @@ -39,11 +38,11 @@ pub fn current_thread() -> Option { ThreadInfo::with(|info| info.thread.clone()) } -pub fn stack_guard() -> Option { - ThreadInfo::with(|info| info.stack_guard.clone()).and_then(|o| o) +pub fn stack_guard() -> Option { + ThreadInfo::with(|info| info.stack_guard).and_then(|o| o) } -pub fn set(stack_guard: Option, thread: Thread) { +pub fn set(stack_guard: Option, thread: Thread) { THREAD_INFO.with(|c| assert!(c.borrow().is_none())); THREAD_INFO.with(move |c| *c.borrow_mut() = Some(ThreadInfo{ stack_guard, diff --git a/src/libcore/time.rs b/src/libstd/time/duration.rs similarity index 98% rename from src/libcore/time.rs rename to src/libstd/time/duration.rs index 1a0208d2f25b2..ee444830be450 100644 --- a/src/libcore/time.rs +++ b/src/libstd/time/duration.rs @@ -7,19 +7,6 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. -#![stable(feature = "duration_core", since = "1.24.0")] - -//! Temporal quantification. -//! -//! Example: -//! -//! ``` -//! use std::time::Duration; -//! -//! let five_seconds = Duration::new(5, 0); -//! // both declarations are equivalent -//! assert_eq!(Duration::new(5, 0), Duration::from_secs(5)); -//! ``` use iter::Sum; use ops::{Add, Sub, Mul, Div, AddAssign, SubAssign, MulAssign, DivAssign}; @@ -58,7 +45,7 @@ const MICROS_PER_SEC: u64 = 1_000_000; /// /// let ten_millis = Duration::from_millis(10); /// ``` -#[stable(feature = "duration_core", since = "1.24.0")] +#[stable(feature = "duration", since = "1.3.0")] #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Hash, Default)] pub struct Duration { secs: u64, diff --git a/src/libstd/time.rs b/src/libstd/time/mod.rs similarity index 99% rename from src/libstd/time.rs rename to src/libstd/time/mod.rs index 12f2a9bb85f83..6ce3b3e8a0031 100644 --- a/src/libstd/time.rs +++ b/src/libstd/time/mod.rs @@ -29,7 +29,9 @@ use sys::time; use sys_common::FromInner; #[stable(feature = "time", since = "1.3.0")] -pub use core::time::Duration; +pub use self::duration::Duration; + +mod duration; /// A measurement of a monotonically nondecreasing clock. /// Opaque and useful only with `Duration`. diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index c7ab6158256ba..73810b3fe81d7 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -883,6 +883,7 @@ pub struct Arm { pub pats: Vec>, pub guard: Option>, pub body: P, + pub beginning_vert: Option, // For RFC 1925 feature gate } #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 3601b9ba8a8c1..a6a7f9e20b3a9 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -593,30 +593,8 @@ impl CodeMap { } } - /// Given a `Span`, get a new `Span` covering the first token and all its trailing whitespace or - /// the original `Span`. - /// - /// If `sp` points to `"let mut x"`, then a span pointing at `"let "` will be returned. - pub fn span_until_non_whitespace(&self, sp: Span) -> Span { - if let Ok(snippet) = self.span_to_snippet(sp) { - let mut offset = 0; - // get the bytes width of all the non-whitespace characters - for c in snippet.chars().take_while(|c| !c.is_whitespace()) { - offset += c.len_utf8(); - } - // get the bytes width of all the whitespace characters after that - for c in snippet[offset..].chars().take_while(|c| c.is_whitespace()) { - offset += c.len_utf8(); - } - if offset > 1 { - return sp.with_hi(BytePos(sp.lo().0 + offset as u32)); - } - } - sp - } - - /// Given a `Span`, try to get a shorter span ending just after the first occurrence of `char` - /// `c`. + /// Given a `Span`, try to get a shorter span ending just after the first + /// occurrence of `char` `c`. pub fn span_through_char(&self, sp: Span, c: char) -> Span { if let Ok(snippet) = self.span_to_snippet(sp) { if let Some(offset) = snippet.find(c) { diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 2e6de96d65a6d..cf63592c2ece2 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -883,6 +883,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { pats, guard: None, body: expr, + beginning_vert: None, } } diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 0621f728e2a9d..3e3c1618fffb2 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -90,8 +90,8 @@ use codemap::Spanned; use errors::FatalError; use ext::tt::quoted::{self, TokenTree}; use parse::{Directory, ParseSess}; -use parse::parser::{Parser, PathStyle}; -use parse::token::{self, DocComment, Nonterminal, Token}; +use parse::parser::{PathStyle, Parser}; +use parse::token::{self, DocComment, Token, Nonterminal}; use print::pprust; use symbol::keywords; use tokenstream::TokenStream; @@ -100,12 +100,11 @@ use util::small_vector::SmallVector; use std::mem; use std::rc::Rc; use std::collections::HashMap; -use std::collections::hash_map::Entry::{Occupied, Vacant}; +use std::collections::hash_map::Entry::{Vacant, Occupied}; -// To avoid costly uniqueness checks, we require that `MatchSeq` always has a nonempty body. +// To avoid costly uniqueness checks, we require that `MatchSeq` always has +// a nonempty body. -/// Either a sequence of token trees or a single one. This is used as the representation of the -/// sequence of tokens that make up a matcher. #[derive(Clone)] enum TokenTreeOrTokenTreeVec { Tt(TokenTree), @@ -113,8 +112,6 @@ enum TokenTreeOrTokenTreeVec { } impl TokenTreeOrTokenTreeVec { - /// Returns the number of constituent top-level token trees of `self` (top-level in that it - /// will not recursively descend into subtrees). fn len(&self) -> usize { match *self { TtSeq(ref v) => v.len(), @@ -122,7 +119,6 @@ impl TokenTreeOrTokenTreeVec { } } - /// The the `index`-th token tree of `self`. fn get_tt(&self, index: usize) -> TokenTree { match *self { TtSeq(ref v) => v[index].clone(), @@ -131,98 +127,36 @@ impl TokenTreeOrTokenTreeVec { } } -/// An unzipping of `TokenTree`s... see the `stack` field of `MatcherPos`. -/// -/// This is used by `inner_parse_loop` to keep track of delimited submatchers that we have -/// descended into. +/// an unzipping of `TokenTree`s #[derive(Clone)] struct MatcherTtFrame { - /// The "parent" matcher that we are descending into. elts: TokenTreeOrTokenTreeVec, - /// The position of the "dot" in `elts` at the time we descended. idx: usize, } -/// Represents a single "position" (aka "matcher position", aka "item"), as described in the module -/// documentation. #[derive(Clone)] struct MatcherPos { - /// The token or sequence of tokens that make up the matcher + stack: Vec, top_elts: TokenTreeOrTokenTreeVec, - /// The position of the "dot" in this matcher + sep: Option, idx: usize, - /// The beginning position in the source that the beginning of this matcher corresponds to. In - /// other words, the token in the source at `sp_lo` is matched against the first token of the - /// matcher. - sp_lo: BytePos, - - /// For each named metavar in the matcher, we keep track of token trees matched against the - /// metavar by the black box parser. In particular, there may be more than one match per - /// metavar if we are in a repetition (each repetition matches each of the variables). - /// Moreover, matchers and repetitions can be nested; the `matches` field is shared (hence the - /// `Rc`) among all "nested" matchers. `match_lo`, `match_cur`, and `match_hi` keep track of - /// the current position of the `self` matcher position in the shared `matches` list. - /// - /// Also, note that while we are descending into a sequence, matchers are given their own - /// `matches` vector. Only once we reach the end of a full repetition of the sequence do we add - /// all bound matches from the submatcher into the shared top-level `matches` vector. If `sep` - /// and `up` are `Some`, then `matches` is _not_ the shared top-level list. Instead, if one - /// wants the shared `matches`, one should use `up.matches`. + up: Option>, matches: Vec>>, - /// The position in `matches` corresponding to the first metavar in this matcher's sequence of - /// token trees. In other words, the first metavar in the first token of `top_elts` corresponds - /// to `matches[match_lo]`. match_lo: usize, - /// The position in `matches` corresponding to the metavar we are currently trying to match - /// against the source token stream. `match_lo <= match_cur <= match_hi`. match_cur: usize, - /// Similar to `match_lo` except `match_hi` is the position in `matches` of the _last_ metavar - /// in this matcher. match_hi: usize, - - // Specifically used if we are matching a repetition. If we aren't both should be `None`. - /// The KleeneOp of this sequence if we are in a repetition. - seq_op: Option, - /// The separator if we are in a repetition - sep: Option, - /// The "parent" matcher position if we are in a repetition. That is, the matcher position just - /// before we enter the sequence. - up: Option>, - - // Specifically used to "unzip" token trees. By "unzip", we mean to unwrap the delimiters from - // a delimited token tree (e.g. something wrapped in `(` `)`) or to get the contents of a doc - // comment... - /// When matching against matchers with nested delimited submatchers (e.g. `pat ( pat ( .. ) - /// pat ) pat`), we need to keep track of the matchers we are descending into. This stack does - /// that where the bottom of the stack is the outermost matcher. - // Also, throughout the comments, this "descent" is often referred to as "unzipping"... - stack: Vec, + sp_lo: BytePos, } impl MatcherPos { - /// Add `m` as a named match for the `idx`-th metavar. fn push_match(&mut self, idx: usize, m: NamedMatch) { let matches = Rc::make_mut(&mut self.matches[idx]); matches.push(m); } } -/// Represents the possible results of an attempted parse. -pub enum ParseResult { - /// Parsed successfully. - Success(T), - /// Arm failed to match. If the second parameter is `token::Eof`, it indicates an unexpected - /// end of macro invocation. Otherwise, it indicates that no rules expected the given token. - Failure(syntax_pos::Span, Token), - /// Fatal error (malformed macro?). Abort compilation. - Error(syntax_pos::Span, String), -} - -/// A `ParseResult` where the `Success` variant contains a mapping of `Ident`s to `NamedMatch`es. -/// This represents the mapping of metavars to the token trees they bind to. pub type NamedParseResult = ParseResult>>; -/// Count how many metavars are named in the given matcher `ms`. pub fn count_names(ms: &[TokenTree]) -> usize { ms.iter().fold(0, |count, elt| { count + match *elt { @@ -235,39 +169,20 @@ pub fn count_names(ms: &[TokenTree]) -> usize { }) } -/// Initialize `len` empty shared `Vec`s to be used to store matches of metavars. -fn create_matches(len: usize) -> Vec>> { - (0..len).into_iter().map(|_| Rc::new(Vec::new())).collect() -} - -/// Generate the top-level matcher position in which the "dot" is before the first token of the -/// matcher `ms` and we are going to start matching at position `lo` in the source. fn initial_matcher_pos(ms: Vec, lo: BytePos) -> Box { let match_idx_hi = count_names(&ms[..]); let matches = create_matches(match_idx_hi); Box::new(MatcherPos { - // Start with the top level matcher given to us - top_elts: TtSeq(ms), // "elts" is an abbr. for "elements" - // The "dot" is before the first token of the matcher + stack: vec![], + top_elts: TtSeq(ms), + sep: None, idx: 0, - // We start matching with byte `lo` in the source code - sp_lo: lo, - - // Initialize `matches` to a bunch of empty `Vec`s -- one for each metavar in `top_elts`. - // `match_lo` for `top_elts` is 0 and `match_hi` is `matches.len()`. `match_cur` is 0 since - // we haven't actually matched anything yet. + up: None, matches, match_lo: 0, match_cur: 0, match_hi: match_idx_hi, - - // Haven't descended into any delimiters, so empty stack - stack: vec![], - - // Haven't descended into any sequences, so both of these are `None`. - seq_op: None, - sep: None, - up: None, + sp_lo: lo }) } @@ -287,36 +202,29 @@ fn initial_matcher_pos(ms: Vec, lo: BytePos) -> Box { /// token tree. The depth of the `NamedMatch` structure will therefore depend /// only on the nesting depth of `ast::TTSeq`s in the originating /// token tree it was derived from. + #[derive(Debug, Clone)] pub enum NamedMatch { MatchedSeq(Rc>, syntax_pos::Span), - MatchedNonterminal(Rc), + MatchedNonterminal(Rc) } -/// Takes a sequence of token trees `ms` representing a matcher which successfully matched input -/// and an iterator of items that matched input and produces a `NamedParseResult`. -fn nameize>( - sess: &ParseSess, - ms: &[TokenTree], - mut res: I, -) -> NamedParseResult { - // Recursively descend into each type of matcher (e.g. sequences, delimited, metavars) and make - // sure that each metavar has _exactly one_ binding. If a metavar does not have exactly one - // binding, then there is an error. If it does, then we insert the binding into the - // `NamedParseResult`. - fn n_rec>( - sess: &ParseSess, - m: &TokenTree, - res: &mut I, - ret_val: &mut HashMap>, - ) -> Result<(), (syntax_pos::Span, String)> { +fn nameize>(sess: &ParseSess, ms: &[TokenTree], mut res: I) + -> NamedParseResult { + fn n_rec>(sess: &ParseSess, m: &TokenTree, res: &mut I, + ret_val: &mut HashMap>) + -> Result<(), (syntax_pos::Span, String)> { match *m { - TokenTree::Sequence(_, ref seq) => for next_m in &seq.tts { - n_rec(sess, next_m, res.by_ref(), ret_val)? - }, - TokenTree::Delimited(_, ref delim) => for next_m in &delim.tts { - n_rec(sess, next_m, res.by_ref(), ret_val)?; - }, + TokenTree::Sequence(_, ref seq) => { + for next_m in &seq.tts { + n_rec(sess, next_m, res.by_ref(), ret_val)? + } + } + TokenTree::Delimited(_, ref delim) => { + for next_m in &delim.tts { + n_rec(sess, next_m, res.by_ref(), ret_val)?; + } + } TokenTree::MetaVarDecl(span, _, id) if id.name == keywords::Invalid.name() => { if sess.missing_fragment_specifiers.borrow_mut().remove(&span) { return Err((span, "missing fragment specifier".to_string())); @@ -342,7 +250,7 @@ fn nameize>( let mut ret_val = HashMap::new(); for m in ms { match n_rec(sess, m, res.by_ref(), &mut ret_val) { - Ok(_) => {} + Ok(_) => {}, Err((sp, msg)) => return Error(sp, msg), } } @@ -350,20 +258,25 @@ fn nameize>( Success(ret_val) } -/// Generate an appropriate parsing failure message. For EOF, this is "unexpected end...". For -/// other tokens, this is "unexpected token...". +pub enum ParseResult { + Success(T), + /// Arm failed to match. If the second parameter is `token::Eof`, it + /// indicates an unexpected end of macro invocation. Otherwise, it + /// indicates that no rules expected the given token. + Failure(syntax_pos::Span, Token), + /// Fatal error (malformed macro?). Abort compilation. + Error(syntax_pos::Span, String) +} + pub fn parse_failure_msg(tok: Token) -> String { match tok { token::Eof => "unexpected end of macro invocation".to_string(), - _ => format!( - "no rules expected the token `{}`", - pprust::token_to_string(&tok) - ), + _ => format!("no rules expected the token `{}`", pprust::token_to_string(&tok)), } } /// Perform a token equality check, ignoring syntax context (that is, an unhygienic comparison) -fn token_name_eq(t1: &Token, t2: &Token) -> bool { +fn token_name_eq(t1 : &Token, t2 : &Token) -> bool { if let (Some(id1), Some(id2)) = (t1.ident(), t2.ident()) { id1.name == id2.name } else if let (&token::Lifetime(id1), &token::Lifetime(id2)) = (t1, t2) { @@ -373,126 +286,80 @@ fn token_name_eq(t1: &Token, t2: &Token) -> bool { } } -/// Process the matcher positions of `cur_items` until it is empty. In the process, this will -/// produce more items in `next_items`, `eof_items`, and `bb_items`. -/// -/// For more info about the how this happens, see the module-level doc comments and the inline -/// comments of this function. -/// -/// # Parameters -/// -/// - `sess`: the parsing session into which errors are emitted. -/// - `cur_items`: the set of current items to be processed. This should be empty by the end of a -/// successful execution of this function. -/// - `next_items`: the set of newly generated items. These are used to replenish `cur_items` in -/// the function `parse`. -/// - `eof_items`: the set of items that would be valid if this was the EOF. -/// - `bb_items`: the set of items that are waiting for the black-box parser. -/// - `token`: the current token of the parser. -/// - `span`: the `Span` in the source code corresponding to the token trees we are trying to match -/// against the matcher positions in `cur_items`. -/// -/// # Returns -/// -/// A `ParseResult`. Note that matches are kept track of through the items generated. -fn inner_parse_loop( - sess: &ParseSess, - cur_items: &mut SmallVector>, - next_items: &mut Vec>, - eof_items: &mut SmallVector>, - bb_items: &mut SmallVector>, - token: &Token, - span: syntax_pos::Span, -) -> ParseResult<()> { - // Pop items from `cur_items` until it is empty. +fn create_matches(len: usize) -> Vec>> { + (0..len).into_iter().map(|_| Rc::new(Vec::new())).collect() +} + +fn inner_parse_loop(sess: &ParseSess, + cur_items: &mut SmallVector>, + next_items: &mut Vec>, + eof_items: &mut SmallVector>, + bb_items: &mut SmallVector>, + token: &Token, + span: syntax_pos::Span) + -> ParseResult<()> { while let Some(mut item) = cur_items.pop() { - // When unzipped trees end, remove them. This corresponds to backtracking out of a - // delimited submatcher into which we already descended. In backtracking out again, we need - // to advance the "dot" past the delimiters in the outer matcher. + // When unzipped trees end, remove them while item.idx >= item.top_elts.len() { match item.stack.pop() { Some(MatcherTtFrame { elts, idx }) => { item.top_elts = elts; item.idx = idx + 1; } - None => break, + None => break } } - // Get the current position of the "dot" (`idx`) in `item` and the number of token trees in - // the matcher (`len`). let idx = item.idx; let len = item.top_elts.len(); - // If `idx >= len`, then we are at or past the end of the matcher of `item`. + // at end of sequence if idx >= len { - // We are repeating iff there is a parent. If the matcher is inside of a repetition, - // then we could be at the end of a sequence or at the beginning of the next - // repetition. + // We are repeating iff there is a parent if item.up.is_some() { - // At this point, regardless of whether there is a separator, we should add all - // matches from the complete repetition of the sequence to the shared, top-level - // `matches` list (actually, `up.matches`, which could itself not be the top-level, - // but anyway...). Moreover, we add another item to `cur_items` in which the "dot" - // is at the end of the `up` matcher. This ensures that the "dot" in the `up` - // matcher is also advanced sufficiently. - // - // NOTE: removing the condition `idx == len` allows trailing separators. + // Disregarding the separator, add the "up" case to the tokens that should be + // examined. + // (remove this condition to make trailing seps ok) if idx == len { - // Get the `up` matcher let mut new_pos = item.up.clone().unwrap(); - // Add matches from this repetition to the `matches` of `up` + // update matches (the MBE "parse tree") by appending + // each tree as a subtree. + + // Only touch the binders we have actually bound for idx in item.match_lo..item.match_hi { let sub = item.matches[idx].clone(); let span = span.with_lo(item.sp_lo); new_pos.push_match(idx, MatchedSeq(sub, span)); } - // Move the "dot" past the repetition in `up` new_pos.match_cur = item.match_hi; new_pos.idx += 1; cur_items.push(new_pos); } - // Check if we need a separator. + // Check if we need a separator if idx == len && item.sep.is_some() { - // We have a separator, and it is the current token. We can advance past the - // separator token. - if item.sep - .as_ref() - .map(|sep| token_name_eq(token, sep)) - .unwrap_or(false) - { + // We have a separator, and it is the current token. + if item.sep.as_ref().map(|sep| token_name_eq(token, sep)).unwrap_or(false) { item.idx += 1; next_items.push(item); } - } - // We don't need a separator. Move the "dot" back to the beginning of the matcher - // and try to match again UNLESS we are only allowed to have _one_ repetition. - else if item.seq_op != Some(quoted::KleeneOp::ZeroOrOne) { + } else { // we don't need a separator item.match_cur = item.match_lo; item.idx = 0; cur_items.push(item); } - } - // If we are not in a repetition, then being at the end of a matcher means that we have - // reached the potential end of the input. - else { + } else { + // We aren't repeating, so we must be potentially at the end of the input. eof_items.push(item); } - } - // We are in the middle of a matcher. - else { - // Look at what token in the matcher we are trying to match the current token (`token`) - // against. Depending on that, we may generate new items. + } else { match item.top_elts.get_tt(idx) { - // Need to descend into a sequence + /* need to descend into sequence */ TokenTree::Sequence(sp, seq) => { - // Examine the case where there are 0 matches of this sequence - if seq.op == quoted::KleeneOp::ZeroOrMore - || seq.op == quoted::KleeneOp::ZeroOrOne - { + if seq.op == quoted::KleeneOp::ZeroOrMore { + // Examine the case where there are 0 matches of this sequence let mut new_item = item.clone(); new_item.match_cur += seq.num_captures; new_item.idx += 1; @@ -502,11 +369,11 @@ fn inner_parse_loop( cur_items.push(new_item); } + // Examine the case where there is at least one match of this sequence let matches = create_matches(item.matches.len()); cur_items.push(Box::new(MatcherPos { stack: vec![], sep: seq.separator.clone(), - seq_op: Some(seq.op), idx: 0, matches, match_lo: item.match_cur, @@ -517,16 +384,11 @@ fn inner_parse_loop( top_elts: Tt(TokenTree::Sequence(sp, seq)), })); } - - // We need to match a metavar (but the identifier is invalid)... this is an error TokenTree::MetaVarDecl(span, _, id) if id.name == keywords::Invalid.name() => { if sess.missing_fragment_specifiers.borrow_mut().remove(&span) { return Error(span, "missing fragment specifier".to_string()); } } - - // We need to match a metavar with a valid ident... call out to the black-box - // parser by adding an item to `bb_items`. TokenTree::MetaVarDecl(_, _, id) => { // Built-in nonterminals never start with these tokens, // so we can eliminate them from consideration. @@ -534,13 +396,6 @@ fn inner_parse_loop( bb_items.push(item); } } - - // We need to descend into a delimited submatcher or a doc comment. To do this, we - // push the current matcher onto a stack and push a new item containing the - // submatcher onto `cur_items`. - // - // At the beginning of the loop, if we reach the end of the delimited submatcher, - // we pop the stack to backtrack out of the descent. seq @ TokenTree::Delimited(..) | seq @ TokenTree::Token(_, DocComment(..)) => { let lower_elts = mem::replace(&mut item.top_elts, Tt(seq)); let idx = item.idx; @@ -551,76 +406,36 @@ fn inner_parse_loop( item.idx = 0; cur_items.push(item); } - - // We just matched a normal token. We can just advance the parser. TokenTree::Token(_, ref t) if token_name_eq(t, token) => { item.idx += 1; next_items.push(item); } - - // There was another token that was not `token`... This means we can't add any - // rules. NOTE that this is not necessarily an error unless _all_ items in - // `cur_items` end up doing this. There may still be some other matchers that do - // end up working out. TokenTree::Token(..) | TokenTree::MetaVar(..) => {} } } } - // Yay a successful parse (so far)! Success(()) } -/// Use the given sequence of token trees (`ms`) as a matcher. Match the given token stream `tts` -/// against it and return the match. -/// -/// # Parameters -/// -/// - `sess`: The session into which errors are emitted -/// - `tts`: The tokenstream we are matching against the pattern `ms` -/// - `ms`: A sequence of token trees representing a pattern against which we are matching -/// - `directory`: Information about the file locations (needed for the black-box parser) -/// - `recurse_into_modules`: Whether or not to recurse into modules (needed for the black-box -/// parser) -pub fn parse( - sess: &ParseSess, - tts: TokenStream, - ms: &[TokenTree], - directory: Option, - recurse_into_modules: bool, -) -> NamedParseResult { - // Create a parser that can be used for the "black box" parts. +pub fn parse(sess: &ParseSess, + tts: TokenStream, + ms: &[TokenTree], + directory: Option, + recurse_into_modules: bool) + -> NamedParseResult { let mut parser = Parser::new(sess, tts, directory, recurse_into_modules, true); - - // A queue of possible matcher positions. We initialize it with the matcher position in which - // the "dot" is before the first token of the first token tree in `ms`. `inner_parse_loop` then - // processes all of these possible matcher positions and produces posible next positions into - // `next_items`. After some post-processing, the contents of `next_items` replenish `cur_items` - // and we start over again. let mut cur_items = SmallVector::one(initial_matcher_pos(ms.to_owned(), parser.span.lo())); - let mut next_items = Vec::new(); + let mut next_items = Vec::new(); // or proceed normally loop { - // Matcher positions black-box parsed by parser.rs (`parser`) - let mut bb_items = SmallVector::new(); - - // Matcher positions that would be valid if the macro invocation was over now + let mut bb_items = SmallVector::new(); // black-box parsed by parser.rs let mut eof_items = SmallVector::new(); assert!(next_items.is_empty()); - // Process `cur_items` until either we have finished the input or we need to get some - // parsing from the black-box parser done. The result is that `next_items` will contain a - // bunch of possible next matcher positions in `next_items`. - match inner_parse_loop( - sess, - &mut cur_items, - &mut next_items, - &mut eof_items, - &mut bb_items, - &parser.token, - parser.span, - ) { - Success(_) => {} + match inner_parse_loop(sess, &mut cur_items, &mut next_items, &mut eof_items, &mut bb_items, + &parser.token, parser.span) { + Success(_) => {}, Failure(sp, tok) => return Failure(sp, tok), Error(sp, msg) => return Error(sp, msg), } @@ -628,75 +443,46 @@ pub fn parse( // inner parse loop handled all cur_items, so it's empty assert!(cur_items.is_empty()); - // We need to do some post processing after the `inner_parser_loop`. - // - // Error messages here could be improved with links to original rules. - - // If we reached the EOF, check that there is EXACTLY ONE possible matcher. Otherwise, - // either the parse is ambiguous (which should never happen) or their is a syntax error. + /* error messages here could be improved with links to orig. rules */ if token_name_eq(&parser.token, &token::Eof) { if eof_items.len() == 1 { - let matches = eof_items[0] - .matches - .iter_mut() - .map(|dv| Rc::make_mut(dv).pop().unwrap()); + let matches = eof_items[0].matches.iter_mut().map(|dv| { + Rc::make_mut(dv).pop().unwrap() + }); return nameize(sess, ms, matches); } else if eof_items.len() > 1 { - return Error( - parser.span, - "ambiguity: multiple successful parses".to_string(), - ); + return Error(parser.span, "ambiguity: multiple successful parses".to_string()); } else { return Failure(parser.span, token::Eof); } - } - // Another possibility is that we need to call out to parse some rust nonterminal - // (black-box) parser. However, if there is not EXACTLY ONE of these, something is wrong. - else if (!bb_items.is_empty() && !next_items.is_empty()) || bb_items.len() > 1 { - let nts = bb_items - .iter() - .map(|item| match item.top_elts.get_tt(item.idx) { - TokenTree::MetaVarDecl(_, bind, name) => format!("{} ('{}')", name, bind), - _ => panic!(), - }) - .collect::>() - .join(" or "); - - return Error( - parser.span, - format!( - "local ambiguity: multiple parsing options: {}", - match next_items.len() { - 0 => format!("built-in NTs {}.", nts), - 1 => format!("built-in NTs {} or 1 other option.", nts), - n => format!("built-in NTs {} or {} other options.", nts, n), - } - ), - ); - } - // If there are no posible next positions AND we aren't waiting for the black-box parser, - // then their is a syntax error. - else if bb_items.is_empty() && next_items.is_empty() { + } else if (!bb_items.is_empty() && !next_items.is_empty()) || bb_items.len() > 1 { + let nts = bb_items.iter().map(|item| match item.top_elts.get_tt(item.idx) { + TokenTree::MetaVarDecl(_, bind, name) => { + format!("{} ('{}')", name, bind) + } + _ => panic!() + }).collect::>().join(" or "); + + return Error(parser.span, format!( + "local ambiguity: multiple parsing options: {}", + match next_items.len() { + 0 => format!("built-in NTs {}.", nts), + 1 => format!("built-in NTs {} or 1 other option.", nts), + n => format!("built-in NTs {} or {} other options.", nts, n), + } + )); + } else if bb_items.is_empty() && next_items.is_empty() { return Failure(parser.span, parser.token); - } - // Dump all possible `next_items` into `cur_items` for the next iteration. - else if !next_items.is_empty() { - // Now process the next token + } else if !next_items.is_empty() { + /* Now process the next token */ cur_items.extend(next_items.drain(..)); parser.bump(); - } - // Finally, we have the case where we need to call the black-box parser to get some - // nonterminal. - else { - assert_eq!(bb_items.len(), 1); - + } else /* bb_items.len() == 1 */ { let mut item = bb_items.pop().unwrap(); if let TokenTree::MetaVarDecl(span, _, ident) = item.top_elts.get_tt(item.idx) { let match_cur = item.match_cur; - item.push_match( - match_cur, - MatchedNonterminal(Rc::new(parse_nt(&mut parser, span, &ident.name.as_str()))), - ); + item.push_match(match_cur, + MatchedNonterminal(Rc::new(parse_nt(&mut parser, span, &ident.name.as_str())))); item.idx += 1; item.match_cur += 1; } else { @@ -726,21 +512,20 @@ fn may_begin_with(name: &str, token: &Token) -> bool { "expr" => token.can_begin_expr(), "ty" => token.can_begin_type(), "ident" => token.is_ident(), - "vis" => match *token { - // The follow-set of :vis + "priv" keyword + interpolated + "vis" => match *token { // The follow-set of :vis + "priv" keyword + interpolated Token::Comma | Token::Ident(_) | Token::Interpolated(_) => true, _ => token.can_begin_type(), }, "block" => match *token { Token::OpenDelim(token::Brace) => true, Token::Interpolated(ref nt) => match nt.0 { - token::NtItem(_) - | token::NtPat(_) - | token::NtTy(_) - | token::NtIdent(_) - | token::NtMeta(_) - | token::NtPath(_) - | token::NtVis(_) => false, // none of these may start with '{'. + token::NtItem(_) | + token::NtPat(_) | + token::NtTy(_) | + token::NtIdent(_) | + token::NtMeta(_) | + token::NtPath(_) | + token::NtVis(_) => false, // none of these may start with '{'. _ => true, }, _ => false, @@ -777,18 +562,6 @@ fn may_begin_with(name: &str, token: &Token) -> bool { } } -/// A call to the "black-box" parser to parse some rust nonterminal. -/// -/// # Parameters -/// -/// - `p`: the "black-box" parser to use -/// - `sp`: the `Span` we want to parse -/// - `name`: the name of the metavar _matcher_ we want to match (e.g. `tt`, `ident`, `block`, -/// etc...) -/// -/// # Returns -/// -/// The parsed nonterminal. fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal { if name == "tt" { return token::NtTT(p.parse_token_tree()); @@ -818,15 +591,12 @@ fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal { "ident" => match p.token { token::Ident(sn) => { p.bump(); - token::NtIdent(Spanned:: { - node: sn, - span: p.prev_span, - }) + token::NtIdent(Spanned::{node: sn, span: p.prev_span}) } _ => { let token_str = pprust::token_to_string(&p.token); - p.fatal(&format!("expected ident, found {}", &token_str[..])) - .emit(); + p.fatal(&format!("expected ident, found {}", + &token_str[..])).emit(); FatalError.raise() } }, @@ -836,6 +606,6 @@ fn parse_nt<'a>(p: &mut Parser<'a>, sp: Span, name: &str) -> Nonterminal { "lifetime" => token::NtLifetime(p.expect_lifetime()), // this is not supposed to happen, since it has been checked // when compiling the macro. - _ => p.span_bug(sp, "invalid fragment specifier"), + _ => p.span_bug(sp, "invalid fragment specifier") } } diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 5254c751e6b62..9efb4faa63535 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -237,8 +237,7 @@ pub fn compile(sess: &ParseSess, features: &RefCell, def: &ast::Item) s.iter().map(|m| { if let MatchedNonterminal(ref nt) = *m { if let NtTT(ref tt) = **nt { - let tt = quoted::parse(tt.clone().into(), true, sess, features, &def.attrs) - .pop().unwrap(); + let tt = quoted::parse(tt.clone().into(), true, sess).pop().unwrap(); valid &= check_lhs_nt_follows(sess, features, &def.attrs, &tt); return tt; } @@ -254,8 +253,7 @@ pub fn compile(sess: &ParseSess, features: &RefCell, def: &ast::Item) s.iter().map(|m| { if let MatchedNonterminal(ref nt) = *m { if let NtTT(ref tt) = **nt { - return quoted::parse(tt.clone().into(), false, sess, features, &def.attrs) - .pop().unwrap(); + return quoted::parse(tt.clone().into(), false, sess).pop().unwrap(); } } sess.span_diagnostic.span_bug(def.span, "wrong-structured lhs") diff --git a/src/libsyntax/ext/tt/quoted.rs b/src/libsyntax/ext/tt/quoted.rs index 982b60b81e47e..0e21e3f6b0010 100644 --- a/src/libsyntax/ext/tt/quoted.rs +++ b/src/libsyntax/ext/tt/quoted.rs @@ -8,21 +8,16 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use {ast, attr}; +use ast; use ext::tt::macro_parser; -use feature_gate::{self, emit_feature_err, Features, GateIssue}; -use parse::{token, ParseSess}; +use parse::{ParseSess, token}; use print::pprust; use symbol::keywords; -use syntax_pos::{BytePos, Span, DUMMY_SP}; +use syntax_pos::{DUMMY_SP, Span, BytePos}; use tokenstream; -use std::cell::RefCell; -use std::iter::Peekable; use std::rc::Rc; -/// Contains the sub-token-trees of a "delimited" token tree, such as the contents of `(`. Note -/// that the delimiter itself might be `NoDelim`. #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)] pub struct Delimited { pub delim: token::DelimToken, @@ -30,17 +25,14 @@ pub struct Delimited { } impl Delimited { - /// Return the opening delimiter (possibly `NoDelim`). pub fn open_token(&self) -> token::Token { token::OpenDelim(self.delim) } - /// Return the closing delimiter (possibly `NoDelim`). pub fn close_token(&self) -> token::Token { token::CloseDelim(self.delim) } - /// Return a `self::TokenTree` with a `Span` corresponding to the opening delimiter. pub fn open_tt(&self, span: Span) -> TokenTree { let open_span = if span == DUMMY_SP { DUMMY_SP @@ -50,7 +42,6 @@ impl Delimited { TokenTree::Token(open_span, self.open_token()) } - /// Return a `self::TokenTree` with a `Span` corresponding to the closing delimiter. pub fn close_tt(&self, span: Span) -> TokenTree { let close_span = if span == DUMMY_SP { DUMMY_SP @@ -77,15 +68,12 @@ pub struct SequenceRepetition { /// for token sequences. #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, Copy)] pub enum KleeneOp { - /// Kleene star (`*`) for zero or more repetitions ZeroOrMore, - /// Kleene plus (`+`) for one or more repetitions OneOrMore, - ZeroOrOne, } /// Similar to `tokenstream::TokenTree`, except that `$i`, `$i:ident`, and `$(...)` -/// are "first-class" token trees. Useful for parsing macros. +/// are "first-class" token trees. #[derive(Debug, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)] pub enum TokenTree { Token(Span, token::Token), @@ -95,15 +83,10 @@ pub enum TokenTree { /// E.g. `$var` MetaVar(Span, ast::Ident), /// E.g. `$var:expr`. This is only used in the left hand side of MBE macros. - MetaVarDecl( - Span, - ast::Ident, /* name to bind */ - ast::Ident, /* kind of nonterminal */ - ), + MetaVarDecl(Span, ast::Ident /* name to bind */, ast::Ident /* kind of nonterminal */), } impl TokenTree { - /// Return the number of tokens in the tree. pub fn len(&self) -> usize { match *self { TokenTree::Delimited(_, ref delimed) => match delimed.delim { @@ -115,8 +98,6 @@ impl TokenTree { } } - /// Returns true if the given token tree contains no other tokens. This is vacuously true for - /// single tokens or metavar/decls, but may be false for delimited trees or sequences. pub fn is_empty(&self) -> bool { match *self { TokenTree::Delimited(_, ref delimed) => match delimed.delim { @@ -128,7 +109,6 @@ impl TokenTree { } } - /// Get the `index`-th sub-token-tree. This only makes sense for delimited trees and sequences. pub fn get_tt(&self, index: usize) -> TokenTree { match (self, index) { (&TokenTree::Delimited(_, ref delimed), _) if delimed.delim == token::NoDelim => { @@ -151,51 +131,21 @@ impl TokenTree { /// Retrieve the `TokenTree`'s span. pub fn span(&self) -> Span { match *self { - TokenTree::Token(sp, _) - | TokenTree::MetaVar(sp, _) - | TokenTree::MetaVarDecl(sp, _, _) - | TokenTree::Delimited(sp, _) - | TokenTree::Sequence(sp, _) => sp, + TokenTree::Token(sp, _) | + TokenTree::MetaVar(sp, _) | + TokenTree::MetaVarDecl(sp, _, _) | + TokenTree::Delimited(sp, _) | + TokenTree::Sequence(sp, _) => sp, } } } -/// Takes a `tokenstream::TokenStream` and returns a `Vec`. Specifically, this -/// takes a generic `TokenStream`, such as is used in the rest of the compiler, and returns a -/// collection of `TokenTree` for use in parsing a macro. -/// -/// # Parameters -/// -/// - `input`: a token stream to read from, the contents of which we are parsing. -/// - `expect_matchers`: `parse` can be used to parse either the "patterns" or the "body" of a -/// macro. Both take roughly the same form _except_ that in a pattern, metavars are declared with -/// their "matcher" type. For example `$var:expr` or `$id:ident`. In this example, `expr` and -/// `ident` are "matchers". They are not present in the body of a macro rule -- just in the -/// pattern, so we pass a parameter to indicate whether to expect them or not. -/// - `sess`: the parsing session. Any errors will be emitted to this session. -/// - `features`, `attrs`: language feature flags and attributes so that we know whether to use -/// unstable features or not. -/// -/// # Returns -/// -/// A collection of `self::TokenTree`. There may also be some errors emitted to `sess`. -pub fn parse( - input: tokenstream::TokenStream, - expect_matchers: bool, - sess: &ParseSess, - features: &RefCell, - attrs: &[ast::Attribute], -) -> Vec { - // Will contain the final collection of `self::TokenTree` +pub fn parse(input: tokenstream::TokenStream, expect_matchers: bool, sess: &ParseSess) + -> Vec { let mut result = Vec::new(); - - // For each token tree in `input`, parse the token into a `self::TokenTree`, consuming - // additional trees if need be. - let mut trees = input.trees().peekable(); + let mut trees = input.trees(); while let Some(tree) = trees.next() { - // Given the parsed tree, if there is a metavar and we are expecting matchers, actually - // parse out the matcher (i.e. in `$id:ident` this would parse the `:` and `ident`). - let tree = parse_tree(tree, &mut trees, expect_matchers, sess, features, attrs); + let tree = parse_tree(tree, &mut trees, expect_matchers, sess); match tree { TokenTree::MetaVar(start_sp, ident) if expect_matchers => { let span = match trees.next() { @@ -204,296 +154,101 @@ pub fn parse( Some(kind) => { let span = end_sp.with_lo(start_sp.lo()); result.push(TokenTree::MetaVarDecl(span, ident, kind)); - continue; + continue } _ => end_sp, }, - tree => tree.as_ref() - .map(tokenstream::TokenTree::span) - .unwrap_or(span), + tree => tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(span), }, - tree => tree.as_ref() - .map(tokenstream::TokenTree::span) - .unwrap_or(start_sp), + tree => tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(start_sp), }; sess.missing_fragment_specifiers.borrow_mut().insert(span); - result.push(TokenTree::MetaVarDecl( - span, - ident, - keywords::Invalid.ident(), - )); + result.push(TokenTree::MetaVarDecl(span, ident, keywords::Invalid.ident())); } - - // Not a metavar or no matchers allowed, so just return the tree _ => result.push(tree), } } result } -/// Takes a `tokenstream::TokenTree` and returns a `self::TokenTree`. Specifically, this takes a -/// generic `TokenTree`, such as is used in the rest of the compiler, and returns a `TokenTree` -/// for use in parsing a macro. -/// -/// Converting the given tree may involve reading more tokens. -/// -/// # Parameters -/// -/// - `tree`: the tree we wish to convert. -/// - `trees`: an iterator over trees. We may need to read more tokens from it in order to finish -/// converting `tree` -/// - `expect_matchers`: same as for `parse` (see above). -/// - `sess`: the parsing session. Any errors will be emitted to this session. -/// - `features`, `attrs`: language feature flags and attributes so that we know whether to use -/// unstable features or not. -fn parse_tree( - tree: tokenstream::TokenTree, - trees: &mut Peekable, - expect_matchers: bool, - sess: &ParseSess, - features: &RefCell, - attrs: &[ast::Attribute], -) -> TokenTree -where - I: Iterator, +fn parse_tree(tree: tokenstream::TokenTree, + trees: &mut I, + expect_matchers: bool, + sess: &ParseSess) + -> TokenTree + where I: Iterator, { - // Depending on what `tree` is, we could be parsing different parts of a macro match tree { - // `tree` is a `$` token. Look at the next token in `trees` tokenstream::TokenTree::Token(span, token::Dollar) => match trees.next() { - // `tree` is followed by a delimited set of token trees. This indicates the beginning - // of a repetition sequence in the macro (e.g. `$(pat)*`). Some(tokenstream::TokenTree::Delimited(span, delimited)) => { - // Must have `(` not `{` or `[` if delimited.delim != token::Paren { let tok = pprust::token_to_string(&token::OpenDelim(delimited.delim)); let msg = format!("expected `(`, found `{}`", tok); sess.span_diagnostic.span_err(span, &msg); } - // Parse the contents of the sequence itself - let sequence = parse(delimited.tts.into(), expect_matchers, sess, features, attrs); - // Get the Kleene operator and optional separator - let (separator, op) = parse_sep_and_kleene_op(trees, span, sess, features, attrs); - // Count the number of captured "names" (i.e. named metavars) + let sequence = parse(delimited.tts.into(), expect_matchers, sess); + let (separator, op) = parse_sep_and_kleene_op(trees, span, sess); let name_captures = macro_parser::count_names(&sequence); - TokenTree::Sequence( - span, - Rc::new(SequenceRepetition { - tts: sequence, - separator, - op, - num_captures: name_captures, - }), - ) + TokenTree::Sequence(span, Rc::new(SequenceRepetition { + tts: sequence, + separator, + op, + num_captures: name_captures, + })) } - - // `tree` is followed by an `ident`. This could be `$meta_var` or the `$crate` special - // metavariable that names the crate of the invokation. Some(tokenstream::TokenTree::Token(ident_span, ref token)) if token.is_ident() => { let ident = token.ident().unwrap(); let span = ident_span.with_lo(span.lo()); if ident.name == keywords::Crate.name() { - let ident = ast::Ident { - name: keywords::DollarCrate.name(), - ..ident - }; + let ident = ast::Ident { name: keywords::DollarCrate.name(), ..ident }; TokenTree::Token(span, token::Ident(ident)) } else { TokenTree::MetaVar(span, ident) } } - - // `tree` is followed by a random token. This is an error. Some(tokenstream::TokenTree::Token(span, tok)) => { - let msg = format!( - "expected identifier, found `{}`", - pprust::token_to_string(&tok) - ); + let msg = format!("expected identifier, found `{}`", pprust::token_to_string(&tok)); sess.span_diagnostic.span_err(span, &msg); TokenTree::MetaVar(span, keywords::Invalid.ident()) } - - // There are no more tokens. Just return the `$` we already have. None => TokenTree::Token(span, token::Dollar), }, - - // `tree` is an arbitrary token. Keep it. tokenstream::TokenTree::Token(span, tok) => TokenTree::Token(span, tok), - - // `tree` is the beginning of a delimited set of tokens (e.g. `(` or `{`). We need to - // descend into the delimited set and further parse it. - tokenstream::TokenTree::Delimited(span, delimited) => TokenTree::Delimited( - span, - Rc::new(Delimited { + tokenstream::TokenTree::Delimited(span, delimited) => { + TokenTree::Delimited(span, Rc::new(Delimited { delim: delimited.delim, - tts: parse(delimited.tts.into(), expect_matchers, sess, features, attrs), - }), - ), - } -} - -/// Takes a token and returns `Some(KleeneOp)` if the token is `+` `*` or `?`. Otherwise, return -/// `None`. -fn kleene_op(token: &token::Token) -> Option { - match *token { - token::BinOp(token::Star) => Some(KleeneOp::ZeroOrMore), - token::BinOp(token::Plus) => Some(KleeneOp::OneOrMore), - token::Question => Some(KleeneOp::ZeroOrOne), - _ => None, - } -} - -/// Parse the next token tree of the input looking for a KleeneOp. Returns -/// -/// - Ok(Ok(op)) if the next token tree is a KleeneOp -/// - Ok(Err(tok, span)) if the next token tree is a token but not a KleeneOp -/// - Err(span) if the next token tree is not a token -fn parse_kleene_op( - input: &mut I, - span: Span, -) -> Result, Span> -where - I: Iterator, -{ - match input.next() { - Some(tokenstream::TokenTree::Token(span, tok)) => match kleene_op(&tok) { - Some(op) => Ok(Ok(op)), - None => Ok(Err((tok, span))), - }, - tree => Err(tree.as_ref() - .map(tokenstream::TokenTree::span) - .unwrap_or(span)), + tts: parse(delimited.tts.into(), expect_matchers, sess), + })) + } } } -/// Attempt to parse a single Kleene star, possibly with a separator. -/// -/// For example, in a pattern such as `$(a),*`, `a` is the pattern to be repeated, `,` is the -/// separator, and `*` is the Kleene operator. This function is specifically concerned with parsing -/// the last two tokens of such a pattern: namely, the optional separator and the Kleene operator -/// itself. Note that here we are parsing the _macro_ itself, rather than trying to match some -/// stream of tokens in an invocation of a macro. -/// -/// This function will take some input iterator `input` corresponding to `span` and a parsing -/// session `sess`. If the next one (or possibly two) tokens in `input` correspond to a Kleene -/// operator and separator, then a tuple with `(separator, KleeneOp)` is returned. Otherwise, an -/// error with the appropriate span is emitted to `sess` and a dummy value is returned. -fn parse_sep_and_kleene_op( - input: &mut Peekable, - span: Span, - sess: &ParseSess, - features: &RefCell, - attrs: &[ast::Attribute], -) -> (Option, KleeneOp) -where - I: Iterator, +fn parse_sep_and_kleene_op(input: &mut I, span: Span, sess: &ParseSess) + -> (Option, KleeneOp) + where I: Iterator, { - // We basically look at two token trees here, denoted as #1 and #2 below - let span = match parse_kleene_op(input, span) { - // #1 is a `+` or `*` KleeneOp - // - // `?` is ambiguous: it could be a separator or a Kleene::ZeroOrOne, so we need to look - // ahead one more token to be sure. - Ok(Ok(op)) if op != KleeneOp::ZeroOrOne => return (None, op), - - // #1 is `?` token, but it could be a Kleene::ZeroOrOne without a separator or it could - // be a `?` separator followed by any Kleene operator. We need to look ahead 1 token to - // find out which. - Ok(Ok(op)) => { - assert_eq!(op, KleeneOp::ZeroOrOne); - - // Lookahead at #2. If it is a KleenOp, then #1 is a separator. - let is_1_sep = if let Some(&tokenstream::TokenTree::Token(_, ref tok2)) = input.peek() { - kleene_op(tok2).is_some() - } else { - false - }; - - if is_1_sep { - // #1 is a separator and #2 should be a KleepeOp::* - // (N.B. We need to advance the input iterator.) - match parse_kleene_op(input, span) { - // #2 is a KleeneOp (this is the only valid option) :) - Ok(Ok(op)) if op == KleeneOp::ZeroOrOne => { - if !features.borrow().macro_at_most_once_rep - && !attr::contains_name(attrs, "allow_internal_unstable") - { - let explain = feature_gate::EXPLAIN_MACRO_AT_MOST_ONCE_REP; - emit_feature_err( - sess, - "macro_at_most_once_rep", - span, - GateIssue::Language, - explain, - ); - } - return (Some(token::Question), op); - } - Ok(Ok(op)) => return (Some(token::Question), op), - - // #2 is a random token (this is an error) :( - Ok(Err((_, span))) => span, - - // #2 is not even a token at all :( - Err(span) => span, - } - } else { - if !features.borrow().macro_at_most_once_rep - && !attr::contains_name(attrs, "allow_internal_unstable") - { - let explain = feature_gate::EXPLAIN_MACRO_AT_MOST_ONCE_REP; - emit_feature_err( - sess, - "macro_at_most_once_rep", - span, - GateIssue::Language, - explain, - ); - } - - // #2 is a random tree and #1 is KleeneOp::ZeroOrOne - return (None, op); - } + fn kleene_op(token: &token::Token) -> Option { + match *token { + token::BinOp(token::Star) => Some(KleeneOp::ZeroOrMore), + token::BinOp(token::Plus) => Some(KleeneOp::OneOrMore), + _ => None, } + } - // #1 is a separator followed by #2, a KleeneOp - Ok(Err((tok, span))) => match parse_kleene_op(input, span) { - // #2 is a KleeneOp :D - Ok(Ok(op)) if op == KleeneOp::ZeroOrOne => { - if !features.borrow().macro_at_most_once_rep - && !attr::contains_name(attrs, "allow_internal_unstable") - { - let explain = feature_gate::EXPLAIN_MACRO_AT_MOST_ONCE_REP; - emit_feature_err( - sess, - "macro_at_most_once_rep", - span, - GateIssue::Language, - explain, - ); - } - return (Some(tok), op); + let span = match input.next() { + Some(tokenstream::TokenTree::Token(span, tok)) => match kleene_op(&tok) { + Some(op) => return (None, op), + None => match input.next() { + Some(tokenstream::TokenTree::Token(span, tok2)) => match kleene_op(&tok2) { + Some(op) => return (Some(tok), op), + None => span, + }, + tree => tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(span), } - Ok(Ok(op)) => return (Some(tok), op), - - // #2 is a random token :( - Ok(Err((_, span))) => span, - - // #2 is not a token at all :( - Err(span) => span, }, - - // #1 is not a token - Err(span) => span, + tree => tree.as_ref().map(tokenstream::TokenTree::span).unwrap_or(span), }; - if !features.borrow().macro_at_most_once_rep - && !attr::contains_name(attrs, "allow_internal_unstable") - { - sess.span_diagnostic - .span_err(span, "expected one of: `*`, `+`, or `?`"); - } else { - sess.span_diagnostic.span_err(span, "expected `*` or `+`"); - } + sess.span_diagnostic.span_err(span, "expected `*` or `+`"); (None, KleeneOp::ZeroOrMore) } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index ea916d5168c33..9a2560b04583d 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -386,6 +386,9 @@ declare_features! ( // allow `#[must_use]` on functions and comparison operators (RFC 1940) (active, fn_must_use, "1.21.0", Some(43302)), + // allow '|' at beginning of match arms (RFC 1925) + (active, match_beginning_vert, "1.21.0", Some(44101)), + // Future-proofing enums/structs with #[non_exhaustive] attribute (RFC 2008) (active, non_exhaustive, "1.22.0", Some(44109)), @@ -423,6 +426,9 @@ declare_features! ( // In-band lifetime bindings (e.g. `fn foo(x: &'a u8) -> &'a u8`) (active, in_band_lifetimes, "1.23.0", Some(44524)), + // Nested groups in `use` (RFC 2128) + (active, use_nested_groups, "1.23.0", Some(44494)), + // generic associated types (RFC 1598) (active, generic_associated_types, "1.23.0", Some(44265)), @@ -446,9 +452,6 @@ declare_features! ( // Allows `#[repr(transparent)]` attribute on newtype structs (active, repr_transparent, "1.25.0", Some(43036)), - - // Use `?` as the Kleene "at most one" operator - (active, macro_at_most_once_rep, "1.25.0", Some(48075)), ); declare_features! ( @@ -542,10 +545,6 @@ declare_features! ( (accepted, abi_sysv64, "1.24.0", Some(36167)), // Allows `repr(align(16))` struct attribute (RFC 1358) (accepted, repr_align, "1.24.0", Some(33626)), - // allow '|' at beginning of match arms (RFC 1925) - (accepted, match_beginning_vert, "1.25.0", Some(44101)), - // Nested groups in `use` (RFC 2128) - (accepted, use_nested_groups, "1.25.0", Some(44494)), ); // If you change this, please modify src/doc/unstable-book as well. You must @@ -789,11 +788,6 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG is just used for rustc unit tests \ and will never be stable", cfg_fn!(rustc_attrs))), - ("rustc_serialize_exclude_null", Normal, Gated(Stability::Unstable, - "rustc_attrs", - "the `#[rustc_serialize_exclude_null]` attribute \ - is an internal-only feature", - cfg_fn!(rustc_attrs))), ("rustc_synthetic", Whitelisted, Gated(Stability::Unstable, "rustc_attrs", "this attribute \ @@ -987,11 +981,6 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG "wasm_import_memory attribute is currently unstable", cfg_fn!(wasm_import_memory))), - ("rustc_args_required_const", Whitelisted, Gated(Stability::Unstable, - "rustc_attrs", - "never will be stable", - cfg_fn!(rustc_attrs))), - // Crate level attributes ("crate_name", CrateLevel, Ungated), ("crate_type", CrateLevel, Ungated), @@ -1261,9 +1250,6 @@ pub const EXPLAIN_PLACEMENT_IN: &'static str = pub const EXPLAIN_UNSIZED_TUPLE_COERCION: &'static str = "Unsized tuple coercion is not stable enough for use and is subject to change"; -pub const EXPLAIN_MACRO_AT_MOST_ONCE_REP: &'static str = - "Using the `?` macro Kleene operator for \"at most one\" repetition is unstable"; - struct PostExpansionVisitor<'a> { context: &'a Context<'a>, } @@ -1692,6 +1678,11 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { } fn visit_arm(&mut self, arm: &'a ast::Arm) { + if let Some(span) = arm.beginning_vert { + gate_feature_post!(&self, match_beginning_vert, + span, + "Use of a '|' at the beginning of a match arm is experimental") + } visit::walk_arm(self, arm) } @@ -1815,6 +1806,29 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { visit::walk_path(self, path); } + fn visit_use_tree(&mut self, use_tree: &'a ast::UseTree, id: NodeId, nested: bool) { + if nested { + match use_tree.kind { + ast::UseTreeKind::Simple(_) => { + if use_tree.prefix.segments.len() != 1 { + gate_feature_post!(&self, use_nested_groups, use_tree.span, + "paths in `use` groups are experimental"); + } + } + ast::UseTreeKind::Glob => { + gate_feature_post!(&self, use_nested_groups, use_tree.span, + "glob imports in `use` groups are experimental"); + } + ast::UseTreeKind::Nested(_) => { + gate_feature_post!(&self, use_nested_groups, use_tree.span, + "nested groups in `use` are experimental"); + } + } + } + + visit::walk_use_tree(self, use_tree, id); + } + fn visit_vis(&mut self, vis: &'a ast::Visibility) { if let ast::Visibility::Crate(span, ast::CrateSugar::JustCrate) = *vis { gate_feature_post!(&self, crate_visibility_modifier, span, diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 921ed3565a471..0f8fe57e380e5 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -340,13 +340,14 @@ pub fn fold_thin_attrs(attrs: ThinVec, fld: &mut T) -> Thi fold_attrs(attrs.into(), fld).into() } -pub fn noop_fold_arm(Arm {attrs, pats, guard, body}: Arm, +pub fn noop_fold_arm(Arm {attrs, pats, guard, body, beginning_vert}: Arm, fld: &mut T) -> Arm { Arm { attrs: fold_attrs(attrs, fld), pats: pats.move_map(|x| fld.fold_pat(x)), guard: guard.map(|x| fld.fold_expr(x)), body: fld.fold_expr(body), + beginning_vert, } } diff --git a/src/libsyntax/json.rs b/src/libsyntax/json.rs index 98d5fa8f797fa..54c726d84621f 100644 --- a/src/libsyntax/json.rs +++ b/src/libsyntax/json.rs @@ -38,41 +38,34 @@ pub struct JsonEmitter { registry: Option, cm: Rc, pretty: bool, - /// Whether "approximate suggestions" are enabled in the config - approximate_suggestions: bool, } impl JsonEmitter { pub fn stderr(registry: Option, code_map: Rc, - pretty: bool, - approximate_suggestions: bool) -> JsonEmitter { + pretty: bool) -> JsonEmitter { JsonEmitter { dst: Box::new(io::stderr()), registry, cm: code_map, pretty, - approximate_suggestions, } } pub fn basic(pretty: bool) -> JsonEmitter { let file_path_mapping = FilePathMapping::empty(); - JsonEmitter::stderr(None, Rc::new(CodeMap::new(file_path_mapping)), - pretty, false) + JsonEmitter::stderr(None, Rc::new(CodeMap::new(file_path_mapping)), pretty) } pub fn new(dst: Box, registry: Option, code_map: Rc, - pretty: bool, - approximate_suggestions: bool) -> JsonEmitter { + pretty: bool) -> JsonEmitter { JsonEmitter { dst, registry, cm: code_map, pretty, - approximate_suggestions, } } } @@ -108,7 +101,6 @@ struct Diagnostic { } #[derive(RustcEncodable)] -#[allow(unused_attributes)] struct DiagnosticSpan { file_name: String, byte_start: u32, @@ -129,9 +121,6 @@ struct DiagnosticSpan { /// If we are suggesting a replacement, this will contain text /// that should be sliced in atop this span. suggested_replacement: Option, - /// If the suggestion is approximate - #[rustc_serialize_exclude_null] - suggestion_approximate: Option, /// Macro invocations that created the code at this span, if any. expansion: Option>, } @@ -199,7 +188,7 @@ impl Diagnostic { } let buf = BufWriter::default(); let output = buf.clone(); - EmitterWriter::new(Box::new(buf), Some(je.cm.clone()), false, false).emit(db); + EmitterWriter::new(Box::new(buf), Some(je.cm.clone()), false).emit(db); let output = Arc::try_unwrap(output.0).unwrap().into_inner().unwrap(); let output = String::from_utf8(output).unwrap(); @@ -231,7 +220,7 @@ impl Diagnostic { impl DiagnosticSpan { fn from_span_label(span: SpanLabel, - suggestion: Option<(&String, bool)>, + suggestion: Option<&String>, je: &JsonEmitter) -> DiagnosticSpan { Self::from_span_etc(span.span, @@ -244,7 +233,7 @@ impl DiagnosticSpan { fn from_span_etc(span: Span, is_primary: bool, label: Option, - suggestion: Option<(&String, bool)>, + suggestion: Option<&String>, je: &JsonEmitter) -> DiagnosticSpan { // obtain the full backtrace from the `macro_backtrace` @@ -264,7 +253,7 @@ impl DiagnosticSpan { fn from_span_full(span: Span, is_primary: bool, label: Option, - suggestion: Option<(&String, bool)>, + suggestion: Option<&String>, mut backtrace: vec::IntoIter, je: &JsonEmitter) -> DiagnosticSpan { @@ -292,13 +281,6 @@ impl DiagnosticSpan { def_site_span, }) }); - - let suggestion_approximate = if je.approximate_suggestions { - suggestion.map(|x| x.1) - } else { - None - }; - DiagnosticSpan { file_name: start.file.name.to_string(), byte_start: span.lo().0 - start.file.start_pos.0, @@ -309,8 +291,7 @@ impl DiagnosticSpan { column_end: end.col.0 + 1, is_primary, text: DiagnosticSpanLine::from_span(span, je), - suggested_replacement: suggestion.map(|x| x.0.clone()), - suggestion_approximate, + suggested_replacement: suggestion.cloned(), expansion: backtrace_step, label, } @@ -328,15 +309,14 @@ impl DiagnosticSpan { suggestion.substitutions .iter() .flat_map(|substitution| { - substitution.parts.iter().map(move |suggestion_inner| { + substitution.parts.iter().map(move |suggestion| { let span_label = SpanLabel { - span: suggestion_inner.span, + span: suggestion.span, is_primary: true, label: None, }; DiagnosticSpan::from_span_label(span_label, - Some((&suggestion_inner.snippet, - suggestion.approximate)), + Some(&suggestion.snippet), je) }) }) diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 9181cca215c84..3b4c5da10f20b 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -25,7 +25,6 @@ #![feature(match_default_bindings)] #![feature(i128_type)] #![feature(const_atomic_usize_new)] -#![feature(rustc_attrs)] // See librustc_cratesio_shim/Cargo.toml for a comment explaining this. #[allow(unused_extern_crates)] diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 11ab84a572916..b95c91548d00b 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -246,27 +246,14 @@ impl<'a> StringReader<'a> { self.err_span(self.mk_sp(from_pos, to_pos), m) } - /// Pushes a character to a message string for error reporting - fn push_escaped_char_for_msg(m: &mut String, c: char) { - match c { - '\u{20}'...'\u{7e}' => { - // Don't escape \, ' or " for user-facing messages - m.push(c); - } - _ => { - for c in c.escape_default() { - m.push(c); - } - } - } - } - /// Report a lexical error spanning [`from_pos`, `to_pos`), appending an /// escaped character to the error message fn fatal_span_char(&self, from_pos: BytePos, to_pos: BytePos, m: &str, c: char) -> FatalError { let mut m = m.to_string(); m.push_str(": "); - Self::push_escaped_char_for_msg(&mut m, c); + for c in c.escape_default() { + m.push(c) + } self.fatal_span_(from_pos, to_pos, &m[..]) } fn struct_fatal_span_char(&self, @@ -277,7 +264,9 @@ impl<'a> StringReader<'a> { -> DiagnosticBuilder<'a> { let mut m = m.to_string(); m.push_str(": "); - Self::push_escaped_char_for_msg(&mut m, c); + for c in c.escape_default() { + m.push(c) + } self.sess.span_diagnostic.struct_span_fatal(self.mk_sp(from_pos, to_pos), &m[..]) } @@ -286,7 +275,9 @@ impl<'a> StringReader<'a> { fn err_span_char(&self, from_pos: BytePos, to_pos: BytePos, m: &str, c: char) { let mut m = m.to_string(); m.push_str(": "); - Self::push_escaped_char_for_msg(&mut m, c); + for c in c.escape_default() { + m.push(c) + } self.err_span_(from_pos, to_pos, &m[..]); } fn struct_err_span_char(&self, @@ -297,7 +288,9 @@ impl<'a> StringReader<'a> { -> DiagnosticBuilder<'a> { let mut m = m.to_string(); m.push_str(": "); - Self::push_escaped_char_for_msg(&mut m, c); + for c in c.escape_default() { + m.push(c) + } self.sess.span_diagnostic.struct_span_err(self.mk_sp(from_pos, to_pos), &m[..]) } @@ -1752,7 +1745,6 @@ mod tests { fn mk_sess(cm: Rc) -> ParseSess { let emitter = errors::emitter::EmitterWriter::new(Box::new(io::sink()), Some(cm.clone()), - false, false); ParseSess { span_diagnostic: errors::Handler::with_emitter(true, false, Box::new(emitter)), diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index dc3745fc4a3ee..b3c485a85c063 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -761,18 +761,6 @@ impl<'a> Parser<'a> { }) } - fn expected_ident_found(&self) -> DiagnosticBuilder<'a> { - let mut err = self.struct_span_err(self.span, - &format!("expected identifier, found {}", - self.this_token_descr())); - if let Some(token_descr) = self.token_descr() { - err.span_label(self.span, format!("expected identifier, found {}", token_descr)); - } else { - err.span_label(self.span, "expected identifier"); - } - err - } - pub fn parse_ident(&mut self) -> PResult<'a, ast::Ident> { self.parse_ident_common(true) } @@ -781,7 +769,15 @@ impl<'a> Parser<'a> { match self.token { token::Ident(i) => { if self.token.is_reserved_ident() { - let mut err = self.expected_ident_found(); + let mut err = self.struct_span_err(self.span, + &format!("expected identifier, found {}", + self.this_token_descr())); + if let Some(token_descr) = self.token_descr() { + err.span_label(self.span, format!("expected identifier, found {}", + token_descr)); + } else { + err.span_label(self.span, "expected identifier"); + } if recover { err.emit(); } else { @@ -795,7 +791,14 @@ impl<'a> Parser<'a> { Err(if self.prev_token_kind == PrevTokenKind::DocComment { self.span_fatal_err(self.prev_span, Error::UselessDocComment) } else { - let mut err = self.expected_ident_found(); + let mut err = self.fatal(&format!("expected identifier, found `{}`", + self.this_token_to_string())); + if let Some(token_descr) = self.token_descr() { + err.span_label(self.span, format!("expected identifier, found {}", + token_descr)); + } else { + err.span_label(self.span, "expected identifier"); + } if self.token == token::Underscore { err.note("`_` is a wildcard pattern, not an identifier"); } @@ -3395,7 +3398,11 @@ impl<'a> Parser<'a> { let attrs = self.parse_outer_attributes()?; // Allow a '|' before the pats (RFC 1925) - self.eat(&token::BinOp(token::Or)); + let beginning_vert = if self.eat(&token::BinOp(token::Or)) { + Some(self.prev_span) + } else { + None + }; let pats = self.parse_pats()?; let guard = if self.eat_keyword(keywords::If) { Some(self.parse_expr()?) @@ -3419,6 +3426,7 @@ impl<'a> Parser<'a> { pats, guard, body: expr, + beginning_vert, }) } diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 7fbe781e9a1f6..2be93c07d5ad7 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -112,7 +112,6 @@ fn ident_can_begin_expr(ident: ast::Ident) -> bool { keywords::Unsafe.name(), keywords::While.name(), keywords::Yield.name(), - keywords::Static.name(), ].contains(&ident.name) } diff --git a/src/libsyntax/test_snippet.rs b/src/libsyntax/test_snippet.rs index 3b4bba24d779b..5072f2e2793f1 100644 --- a/src/libsyntax/test_snippet.rs +++ b/src/libsyntax/test_snippet.rs @@ -62,7 +62,6 @@ fn test_harness(file_text: &str, span_labels: Vec, expected_output: & let emitter = EmitterWriter::new(Box::new(Shared { data: output.clone() }), Some(code_map.clone()), - false, false); let handler = Handler::with_emitter(true, false, Box::new(emitter)); handler.span_err(msp, "foo"); diff --git a/src/libsyntax_ext/asm.rs b/src/libsyntax_ext/asm.rs index d1de4dccd0043..3742fb8c804d7 100644 --- a/src/libsyntax_ext/asm.rs +++ b/src/libsyntax_ext/asm.rs @@ -239,12 +239,6 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, } } - // If there are no outputs, the inline assembly is executed just for its side effects, - // so ensure that it is volatile - if outputs.is_empty() { - volatile = true; - } - MacEager::expr(P(ast::Expr { id: ast::DUMMY_NODE_ID, node: ast::ExprKind::InlineAsm(P(ast::InlineAsm { diff --git a/src/libsyntax_ext/deriving/encodable.rs b/src/libsyntax_ext/deriving/encodable.rs index 743f22b6b3140..0e6e96438d817 100644 --- a/src/libsyntax_ext/deriving/encodable.rs +++ b/src/libsyntax_ext/deriving/encodable.rs @@ -190,7 +190,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, Struct(_, ref fields) => { let emit_struct_field = cx.ident_of("emit_struct_field"); let mut stmts = Vec::new(); - for (i, &FieldInfo { name, ref self_, span, attrs, .. }) in fields.iter().enumerate() { + for (i, &FieldInfo { name, ref self_, span, .. }) in fields.iter().enumerate() { let name = match name { Some(id) => id.name, None => Symbol::intern(&format!("_field{}", i)), @@ -212,19 +212,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, } else { cx.expr(span, ExprKind::Ret(Some(call))) }; - - // This exists for https://github.com/rust-lang/rust/pull/47540 - // - // If we decide to stabilize that flag this can be removed - let expr = if attrs.iter().any(|a| a.check_name("rustc_serialize_exclude_null")) { - let is_some = cx.ident_of("is_some"); - let condition = cx.expr_method_call(span, self_.clone(), is_some, vec![]); - cx.expr_if(span, condition, call, None) - } else { - call - }; - let stmt = cx.stmt_expr(expr); - stmts.push(stmt); + stmts.push(cx.stmt_expr(call)); } // unit structs have no fields and need to return Ok() diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index 294506625bc05..dd1ec7284f690 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -347,24 +347,13 @@ impl Span { /// Return a `Span` that would enclose both `self` and `end`. pub fn to(self, end: Span) -> Span { - let span_data = self.data(); - let end_data = end.data(); - // FIXME(jseyfried): self.ctxt should always equal end.ctxt here (c.f. issue #23480) - // Return the macro span on its own to avoid weird diagnostic output. It is preferable to - // have an incomplete span than a completely nonsensical one. - if span_data.ctxt != end_data.ctxt { - if span_data.ctxt == SyntaxContext::empty() { - return end; - } else if end_data.ctxt == SyntaxContext::empty() { - return self; - } - // both span fall within a macro - // FIXME(estebank) check if it is the *same* macro - } + let span = self.data(); + let end = end.data(); Span::new( - cmp::min(span_data.lo, end_data.lo), - cmp::max(span_data.hi, end_data.hi), - if span_data.ctxt == SyntaxContext::empty() { end_data.ctxt } else { span_data.ctxt }, + cmp::min(span.lo, end.lo), + cmp::max(span.hi, end.hi), + // FIXME(jseyfried): self.ctxt should always equal end.ctxt here (c.f. issue #23480) + if span.ctxt == SyntaxContext::empty() { end.ctxt } else { span.ctxt }, ) } diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 9ea5f39b71fee..ffa27688cf1a7 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -72,7 +72,6 @@ use std::sync::{Arc, Mutex}; use std::thread; use std::time::{Instant, Duration}; use std::borrow::Cow; -use std::process; const TEST_WARN_TIMEOUT_S: u64 = 60; const QUIET_MODE_MAX_COLUMN: usize = 100; // insert a '\n' after 100 tests in quiet mode @@ -267,27 +266,19 @@ impl Options { pub fn test_main(args: &[String], tests: Vec, options: Options) { let mut opts = match parse_opts(args) { Some(Ok(o)) => o, - Some(Err(msg)) => { - eprintln!("error: {}", msg); - process::exit(101); - }, + Some(Err(msg)) => panic!("{:?}", msg), None => return, }; - opts.options = options; if opts.list { if let Err(e) = list_tests_console(&opts, tests) { - eprintln!("error: io error when listing tests: {:?}", e); - process::exit(101); + panic!("io error when listing tests: {:?}", e); } } else { match run_tests_console(&opts, tests) { Ok(true) => {} - Ok(false) => process::exit(101), - Err(e) => { - eprintln!("error: io error when listing tests: {:?}", e); - process::exit(101); - }, + Ok(false) => std::process::exit(101), + Err(e) => panic!("io error when running tests: {:?}", e), } } } diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index 06d1301d70003..b2f1229891d26 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -836,10 +836,6 @@ struct LLVMRustThinLTOData { StringMap ImportLists; StringMap ExportLists; StringMap ModuleToDefinedGVSummaries; - -#if LLVM_VERSION_GE(7, 0) - LLVMRustThinLTOData() : Index(/* isPerformingAnalysis = */ false) {} -#endif }; // Just an argument to the `LLVMRustCreateThinLTOData` function below. @@ -922,14 +918,7 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, // // This is copied from `lib/LTO/ThinLTOCodeGenerator.cpp` #if LLVM_VERSION_GE(5, 0) -#if LLVM_VERSION_GE(7, 0) - auto deadIsPrevailing = [&](GlobalValue::GUID G) { - return PrevailingType::Unknown; - }; - computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols, deadIsPrevailing); -#else computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols); -#endif ComputeCrossModuleImport( Ret->Index, Ret->ModuleToDefinedGVSummaries, diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp index 4dfc4029d75dc..611d63f6a4d14 100644 --- a/src/rustllvm/RustWrapper.cpp +++ b/src/rustllvm/RustWrapper.cpp @@ -552,11 +552,9 @@ static unsigned fromRust(LLVMRustDIFlags Flags) { if (isSet(Flags & LLVMRustDIFlags::FlagRValueReference)) { Result |= DINode::DIFlags::FlagRValueReference; } -#if LLVM_VERSION_LE(4, 0) if (isSet(Flags & LLVMRustDIFlags::FlagExternalTypeRef)) { Result |= DINode::DIFlags::FlagExternalTypeRef; } -#endif if (isSet(Flags & LLVMRustDIFlags::FlagIntroducedVirtual)) { Result |= DINode::DIFlags::FlagIntroducedVirtual; } diff --git a/src/rustllvm/llvm-rebuild-trigger b/src/rustllvm/llvm-rebuild-trigger index 3cd044708cee2..2635ca73303e7 100644 --- a/src/rustllvm/llvm-rebuild-trigger +++ b/src/rustllvm/llvm-rebuild-trigger @@ -1,4 +1,4 @@ # If this file is modified, then llvm will be (optionally) cleaned and then rebuilt. # The actual contents of this file do not matter, but to trigger a change on the # build bots then the contents should be changed so git updates the mtime. -2018-02-09 +2018-01-25 diff --git a/src/test/codegen/function-arguments.rs b/src/test/codegen/function-arguments.rs index 0e98d3f9050a8..f8945a6ee8d93 100644 --- a/src/test/codegen/function-arguments.rs +++ b/src/test/codegen/function-arguments.rs @@ -122,13 +122,13 @@ pub fn unsafe_slice(_: &[UnsafeInner]) { pub fn str(_: &[u8]) { } -// CHECK: @trait_borrow({}* nonnull %arg0.0, {}* noalias nonnull readonly %arg0.1) +// CHECK: @trait_borrow(%"core::ops::drop::Drop"* nonnull %arg0.0, {}* noalias nonnull readonly %arg0.1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn trait_borrow(_: &Drop) { } -// CHECK: @trait_box({}* noalias nonnull, {}* noalias nonnull readonly) +// CHECK: @trait_box(%"core::ops::drop::Drop"* noalias nonnull, {}* noalias nonnull readonly) #[no_mangle] pub fn trait_box(_: Box) { } diff --git a/src/test/codegen/no-output-asm-is-volatile.rs b/src/test/codegen/no-output-asm-is-volatile.rs deleted file mode 100644 index 457d706a8ffef..0000000000000 --- a/src/test/codegen/no-output-asm-is-volatile.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -O - -// ignore-asmjs - -#![feature(asm)] -#![crate_type = "lib"] - -// Check that inline assembly expressions without any outputs -// are marked as having side effects / being volatile - -// CHECK-LABEL: @assembly -#[no_mangle] -pub fn assembly() { - unsafe { asm!("") } -// CHECK: tail call void asm sideeffect "", {{.*}} -} diff --git a/src/test/codegen/repeat-trusted-len.rs b/src/test/codegen/repeat-trusted-len.rs deleted file mode 100644 index 43872f15d51e2..0000000000000 --- a/src/test/codegen/repeat-trusted-len.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -O -// ignore-tidy-linelength - -#![crate_type = "lib"] - -use std::iter; - -// CHECK-LABEL: @repeat_take_collect -#[no_mangle] -pub fn repeat_take_collect() -> Vec { -// CHECK: call void @llvm.memset.p0i8 - iter::repeat(42).take(100000).collect() -} diff --git a/src/test/codegen/repr-transparent-sysv64.rs b/src/test/codegen/repr-transparent-sysv64.rs deleted file mode 100644 index 7a30983fdd338..0000000000000 --- a/src/test/codegen/repr-transparent-sysv64.rs +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// only-x86_64 - -// compile-flags: -C no-prepopulate-passes - -#![crate_type="lib"] -#![feature(repr_transparent)] - -#[repr(C)] -pub struct Rgb8 { r: u8, g: u8, b: u8 } - -#[repr(transparent)] -pub struct Rgb8Wrap(Rgb8); - -// CHECK: i24 @test_Rgb8Wrap(i24) -#[no_mangle] -pub extern "sysv64" fn test_Rgb8Wrap(_: Rgb8Wrap) -> Rgb8Wrap { loop {} } - -#[repr(C)] -pub union FloatBits { - float: f32, - bits: u32, -} - -#[repr(transparent)] -pub struct SmallUnion(FloatBits); - -// CHECK: i32 @test_SmallUnion(i32) -#[no_mangle] -pub extern "sysv64" fn test_SmallUnion(_: SmallUnion) -> SmallUnion { loop {} } diff --git a/src/test/codegen/repr-transparent.rs b/src/test/codegen/repr-transparent.rs index 087fa9b16b4ed..31020d8b94f80 100644 --- a/src/test/codegen/repr-transparent.rs +++ b/src/test/codegen/repr-transparent.rs @@ -123,13 +123,55 @@ pub struct StructWithProjection(::It); pub extern fn test_Projection(_: StructWithProjection) -> StructWithProjection { loop {} } -// All that remains to be tested are aggregates. They are tested in separate files called repr- -// transparent-*.rs with `only-*` or `ignore-*` directives, because the expected LLVM IR -// function signatures vary so much that it's not reasonably possible to cover all of them with a -// single CHECK line. +// The rest of this file tests newtypes around small aggregates on an ABI where small aggregates are +// packed into one register. This is ABI-dependent, so instead we focus on one ABI and supply a +// dummy definition for other ABIs to keep FileCheck happy. // -// You may be wondering why we don't just compare the return types and argument types for equality -// with FileCheck regex captures. Well, rustc doesn't perform newtype unwrapping on newtypes -// containing aggregates. This is OK on all ABIs we support, but because LLVM has not gotten rid of -// pointee types yet, the IR function signature will be syntactically different (%Foo* vs -// %FooWrapper*). +// Bigger aggregates are tested in separate files called repr-transparent-aggregate-*.rs because +// there, the expected LLVM IR function signatures vary so much that it's not reasonably possible to +// cover all of them with a single CHECK line. Instead we group ABIs by the general "shape" of the +// signature and have a separate test file for each bin. +// +// PS: You may be wondering why we don't just compare the return types and argument types for +// equality with FileCheck regex captures. Well, rustc doesn't perform newtype unwrapping on +// newtypes containing aggregates. This is OK on all ABIs we support, but because LLVM has not +// gotten rid of pointee types yet, the IR function signature will be syntactically different (%Foo* +// vs %FooWrapper*). + +#[repr(C)] +pub struct Rgb8 { r: u8, g: u8, b: u8 } + +#[repr(transparent)] +pub struct Rgb8Wrap(Rgb8); + +// NB: closing parenthesis is missing because sometimes the argument has a name and sometimes not +// CHECK: define i32 @test_Rgb8Wrap(i32 +#[no_mangle] +#[cfg(all(target_arch="x86_64", target_os="linux"))] +pub extern fn test_Rgb8Wrap(_: Rgb8Wrap) -> Rgb8Wrap { loop {} } + +#[cfg(not(all(target_arch="x86_64", target_os="linux")))] +#[no_mangle] +pub extern fn test_Rgb8Wrap(_: u32) -> u32 { loop {} } + +// Same as with the small struct above: ABI-dependent, we only test the interesting case +// (ABIs that pack the aggregate into a scalar) and stub it out on other ABIs + +#[repr(C)] +pub union FloatBits { + float: f32, + bits: u32, +} + +#[repr(transparent)] +pub struct SmallUnion(FloatBits); + +// NB: closing parenthesis is missing because sometimes the argument has a name and sometimes not +// CHECK: define i32 @test_SmallUnion(i32 +#[no_mangle] +#[cfg(all(target_arch="x86_64", target_os="linux"))] +pub extern fn test_SmallUnion(_: SmallUnion) -> SmallUnion { loop {} } + +#[cfg(not(all(target_arch="x86_64", target_os="linux")))] +#[no_mangle] +pub extern fn test_SmallUnion(_: u32) -> u32 { loop {} } diff --git a/src/test/codegen/stack-probes.rs b/src/test/codegen/stack-probes.rs index 4a489f1edb3b8..5b26dade9aff0 100644 --- a/src/test/codegen/stack-probes.rs +++ b/src/test/codegen/stack-probes.rs @@ -15,7 +15,7 @@ // ignore-wasm // ignore-emscripten // ignore-windows -// min-system-llvm-version 5.0 +// no-system-llvm // compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] diff --git a/src/test/ui/error-codes/E0001.rs b/src/test/compile-fail/E0001.rs similarity index 100% rename from src/test/ui/error-codes/E0001.rs rename to src/test/compile-fail/E0001.rs diff --git a/src/test/ui/error-codes/E0004-2.rs b/src/test/compile-fail/E0004-2.rs similarity index 100% rename from src/test/ui/error-codes/E0004-2.rs rename to src/test/compile-fail/E0004-2.rs diff --git a/src/test/ui/error-codes/E0004.rs b/src/test/compile-fail/E0004.rs similarity index 100% rename from src/test/ui/error-codes/E0004.rs rename to src/test/compile-fail/E0004.rs diff --git a/src/test/ui/error-codes/E0005.rs b/src/test/compile-fail/E0005.rs similarity index 100% rename from src/test/ui/error-codes/E0005.rs rename to src/test/compile-fail/E0005.rs diff --git a/src/test/ui/error-codes/E0007.rs b/src/test/compile-fail/E0007.rs similarity index 100% rename from src/test/ui/error-codes/E0007.rs rename to src/test/compile-fail/E0007.rs diff --git a/src/test/ui/error-codes/E0008.rs b/src/test/compile-fail/E0008.rs similarity index 100% rename from src/test/ui/error-codes/E0008.rs rename to src/test/compile-fail/E0008.rs diff --git a/src/test/ui/error-codes/E0009.rs b/src/test/compile-fail/E0009.rs similarity index 100% rename from src/test/ui/error-codes/E0009.rs rename to src/test/compile-fail/E0009.rs diff --git a/src/test/ui/error-codes/E0010.rs b/src/test/compile-fail/E0010.rs similarity index 100% rename from src/test/ui/error-codes/E0010.rs rename to src/test/compile-fail/E0010.rs diff --git a/src/test/ui/error-codes/E0017.rs b/src/test/compile-fail/E0017.rs similarity index 100% rename from src/test/ui/error-codes/E0017.rs rename to src/test/compile-fail/E0017.rs diff --git a/src/test/ui/error-codes/E0023.rs b/src/test/compile-fail/E0023.rs similarity index 100% rename from src/test/ui/error-codes/E0023.rs rename to src/test/compile-fail/E0023.rs diff --git a/src/test/ui/error-codes/E0025.rs b/src/test/compile-fail/E0025.rs similarity index 100% rename from src/test/ui/error-codes/E0025.rs rename to src/test/compile-fail/E0025.rs diff --git a/src/test/ui/error-codes/E0026.rs b/src/test/compile-fail/E0026.rs similarity index 100% rename from src/test/ui/error-codes/E0026.rs rename to src/test/compile-fail/E0026.rs diff --git a/src/test/ui/error-codes/E0027.rs b/src/test/compile-fail/E0027.rs similarity index 100% rename from src/test/ui/error-codes/E0027.rs rename to src/test/compile-fail/E0027.rs diff --git a/src/test/ui/error-codes/E0029.rs b/src/test/compile-fail/E0029.rs similarity index 100% rename from src/test/ui/error-codes/E0029.rs rename to src/test/compile-fail/E0029.rs diff --git a/src/test/ui/error-codes/E0030.rs b/src/test/compile-fail/E0030.rs similarity index 100% rename from src/test/ui/error-codes/E0030.rs rename to src/test/compile-fail/E0030.rs diff --git a/src/test/ui/error-codes/E0033.rs b/src/test/compile-fail/E0033.rs similarity index 100% rename from src/test/ui/error-codes/E0033.rs rename to src/test/compile-fail/E0033.rs diff --git a/src/test/ui/error-codes/E0034.rs b/src/test/compile-fail/E0034.rs similarity index 100% rename from src/test/ui/error-codes/E0034.rs rename to src/test/compile-fail/E0034.rs diff --git a/src/test/ui/error-codes/E0038.rs b/src/test/compile-fail/E0038.rs similarity index 100% rename from src/test/ui/error-codes/E0038.rs rename to src/test/compile-fail/E0038.rs diff --git a/src/test/ui/error-codes/E0040.rs b/src/test/compile-fail/E0040.rs similarity index 100% rename from src/test/ui/error-codes/E0040.rs rename to src/test/compile-fail/E0040.rs diff --git a/src/test/ui/error-codes/E0044.rs b/src/test/compile-fail/E0044.rs similarity index 100% rename from src/test/ui/error-codes/E0044.rs rename to src/test/compile-fail/E0044.rs diff --git a/src/test/ui/error-codes/E0045.rs b/src/test/compile-fail/E0045.rs similarity index 100% rename from src/test/ui/error-codes/E0045.rs rename to src/test/compile-fail/E0045.rs diff --git a/src/test/ui/error-codes/E0049.rs b/src/test/compile-fail/E0049.rs similarity index 100% rename from src/test/ui/error-codes/E0049.rs rename to src/test/compile-fail/E0049.rs diff --git a/src/test/ui/error-codes/E0050.rs b/src/test/compile-fail/E0050.rs similarity index 100% rename from src/test/ui/error-codes/E0050.rs rename to src/test/compile-fail/E0050.rs diff --git a/src/test/ui/error-codes/E0054.rs b/src/test/compile-fail/E0054.rs similarity index 100% rename from src/test/ui/error-codes/E0054.rs rename to src/test/compile-fail/E0054.rs diff --git a/src/test/ui/error-codes/E0055.rs b/src/test/compile-fail/E0055.rs similarity index 100% rename from src/test/ui/error-codes/E0055.rs rename to src/test/compile-fail/E0055.rs diff --git a/src/test/ui/error-codes/E0057.rs b/src/test/compile-fail/E0057.rs similarity index 100% rename from src/test/ui/error-codes/E0057.rs rename to src/test/compile-fail/E0057.rs diff --git a/src/test/ui/error-codes/E0059.rs b/src/test/compile-fail/E0059.rs similarity index 100% rename from src/test/ui/error-codes/E0059.rs rename to src/test/compile-fail/E0059.rs diff --git a/src/test/ui/error-codes/E0060.rs b/src/test/compile-fail/E0060.rs similarity index 100% rename from src/test/ui/error-codes/E0060.rs rename to src/test/compile-fail/E0060.rs diff --git a/src/test/ui/error-codes/E0061.rs b/src/test/compile-fail/E0061.rs similarity index 100% rename from src/test/ui/error-codes/E0061.rs rename to src/test/compile-fail/E0061.rs diff --git a/src/test/ui/error-codes/E0062.rs b/src/test/compile-fail/E0062.rs similarity index 100% rename from src/test/ui/error-codes/E0062.rs rename to src/test/compile-fail/E0062.rs diff --git a/src/test/ui/error-codes/E0063.rs b/src/test/compile-fail/E0063.rs similarity index 100% rename from src/test/ui/error-codes/E0063.rs rename to src/test/compile-fail/E0063.rs diff --git a/src/test/ui/error-codes/E0067.rs b/src/test/compile-fail/E0067.rs similarity index 100% rename from src/test/ui/error-codes/E0067.rs rename to src/test/compile-fail/E0067.rs diff --git a/src/test/ui/error-codes/E0069.rs b/src/test/compile-fail/E0069.rs similarity index 100% rename from src/test/ui/error-codes/E0069.rs rename to src/test/compile-fail/E0069.rs diff --git a/src/test/ui/error-codes/E0070.rs b/src/test/compile-fail/E0070.rs similarity index 100% rename from src/test/ui/error-codes/E0070.rs rename to src/test/compile-fail/E0070.rs diff --git a/src/test/ui/error-codes/E0071.rs b/src/test/compile-fail/E0071.rs similarity index 100% rename from src/test/ui/error-codes/E0071.rs rename to src/test/compile-fail/E0071.rs diff --git a/src/test/ui/error-codes/E0075.rs b/src/test/compile-fail/E0075.rs similarity index 100% rename from src/test/ui/error-codes/E0075.rs rename to src/test/compile-fail/E0075.rs diff --git a/src/test/ui/error-codes/E0076.rs b/src/test/compile-fail/E0076.rs similarity index 100% rename from src/test/ui/error-codes/E0076.rs rename to src/test/compile-fail/E0076.rs diff --git a/src/test/ui/error-codes/E0077.rs b/src/test/compile-fail/E0077.rs similarity index 100% rename from src/test/ui/error-codes/E0077.rs rename to src/test/compile-fail/E0077.rs diff --git a/src/test/ui/error-codes/E0080.rs b/src/test/compile-fail/E0080.rs similarity index 100% rename from src/test/ui/error-codes/E0080.rs rename to src/test/compile-fail/E0080.rs diff --git a/src/test/ui/error-codes/E0081.rs b/src/test/compile-fail/E0081.rs similarity index 100% rename from src/test/ui/error-codes/E0081.rs rename to src/test/compile-fail/E0081.rs diff --git a/src/test/ui/error-codes/E0084.rs b/src/test/compile-fail/E0084.rs similarity index 100% rename from src/test/ui/error-codes/E0084.rs rename to src/test/compile-fail/E0084.rs diff --git a/src/test/ui/error-codes/E0087.rs b/src/test/compile-fail/E0087.rs similarity index 100% rename from src/test/ui/error-codes/E0087.rs rename to src/test/compile-fail/E0087.rs diff --git a/src/test/ui/error-codes/E0088.rs b/src/test/compile-fail/E0088.rs similarity index 100% rename from src/test/ui/error-codes/E0088.rs rename to src/test/compile-fail/E0088.rs diff --git a/src/test/ui/error-codes/E0089.rs b/src/test/compile-fail/E0089.rs similarity index 100% rename from src/test/ui/error-codes/E0089.rs rename to src/test/compile-fail/E0089.rs diff --git a/src/test/ui/error-codes/E0090.rs b/src/test/compile-fail/E0090.rs similarity index 100% rename from src/test/ui/error-codes/E0090.rs rename to src/test/compile-fail/E0090.rs diff --git a/src/test/ui/error-codes/E0091.rs b/src/test/compile-fail/E0091.rs similarity index 100% rename from src/test/ui/error-codes/E0091.rs rename to src/test/compile-fail/E0091.rs diff --git a/src/test/ui/error-codes/E0092.rs b/src/test/compile-fail/E0092.rs similarity index 100% rename from src/test/ui/error-codes/E0092.rs rename to src/test/compile-fail/E0092.rs diff --git a/src/test/ui/error-codes/E0093.rs b/src/test/compile-fail/E0093.rs similarity index 100% rename from src/test/ui/error-codes/E0093.rs rename to src/test/compile-fail/E0093.rs diff --git a/src/test/ui/error-codes/E0094.rs b/src/test/compile-fail/E0094.rs similarity index 100% rename from src/test/ui/error-codes/E0094.rs rename to src/test/compile-fail/E0094.rs diff --git a/src/test/ui/error-codes/E0106.rs b/src/test/compile-fail/E0106.rs similarity index 100% rename from src/test/ui/error-codes/E0106.rs rename to src/test/compile-fail/E0106.rs diff --git a/src/test/ui/error-codes/E0107.rs b/src/test/compile-fail/E0107.rs similarity index 100% rename from src/test/ui/error-codes/E0107.rs rename to src/test/compile-fail/E0107.rs diff --git a/src/test/ui/error-codes/E0109.rs b/src/test/compile-fail/E0109.rs similarity index 100% rename from src/test/ui/error-codes/E0109.rs rename to src/test/compile-fail/E0109.rs diff --git a/src/test/ui/error-codes/E0110.rs b/src/test/compile-fail/E0110.rs similarity index 100% rename from src/test/ui/error-codes/E0110.rs rename to src/test/compile-fail/E0110.rs diff --git a/src/test/ui/error-codes/E0116.rs b/src/test/compile-fail/E0116.rs similarity index 100% rename from src/test/ui/error-codes/E0116.rs rename to src/test/compile-fail/E0116.rs diff --git a/src/test/ui/error-codes/E0117.rs b/src/test/compile-fail/E0117.rs similarity index 100% rename from src/test/ui/error-codes/E0117.rs rename to src/test/compile-fail/E0117.rs diff --git a/src/test/ui/error-codes/E0118.rs b/src/test/compile-fail/E0118.rs similarity index 100% rename from src/test/ui/error-codes/E0118.rs rename to src/test/compile-fail/E0118.rs diff --git a/src/test/ui/error-codes/E0119.rs b/src/test/compile-fail/E0119.rs similarity index 100% rename from src/test/ui/error-codes/E0119.rs rename to src/test/compile-fail/E0119.rs diff --git a/src/test/ui/error-codes/E0120.rs b/src/test/compile-fail/E0120.rs similarity index 100% rename from src/test/ui/error-codes/E0120.rs rename to src/test/compile-fail/E0120.rs diff --git a/src/test/ui/error-codes/E0121.rs b/src/test/compile-fail/E0121.rs similarity index 100% rename from src/test/ui/error-codes/E0121.rs rename to src/test/compile-fail/E0121.rs diff --git a/src/test/ui/error-codes/E0124.rs b/src/test/compile-fail/E0124.rs similarity index 100% rename from src/test/ui/error-codes/E0124.rs rename to src/test/compile-fail/E0124.rs diff --git a/src/test/ui/error-codes/E0128.rs b/src/test/compile-fail/E0128.rs similarity index 100% rename from src/test/ui/error-codes/E0128.rs rename to src/test/compile-fail/E0128.rs diff --git a/src/test/ui/error-codes/E0130.rs b/src/test/compile-fail/E0130.rs similarity index 100% rename from src/test/ui/error-codes/E0130.rs rename to src/test/compile-fail/E0130.rs diff --git a/src/test/ui/error-codes/E0131.rs b/src/test/compile-fail/E0131.rs similarity index 100% rename from src/test/ui/error-codes/E0131.rs rename to src/test/compile-fail/E0131.rs diff --git a/src/test/ui/error-codes/E0132.rs b/src/test/compile-fail/E0132.rs similarity index 100% rename from src/test/ui/error-codes/E0132.rs rename to src/test/compile-fail/E0132.rs diff --git a/src/test/ui/error-codes/E0133.rs b/src/test/compile-fail/E0133.rs similarity index 100% rename from src/test/ui/error-codes/E0133.rs rename to src/test/compile-fail/E0133.rs diff --git a/src/test/ui/error-codes/E0137.rs b/src/test/compile-fail/E0137.rs similarity index 100% rename from src/test/ui/error-codes/E0137.rs rename to src/test/compile-fail/E0137.rs diff --git a/src/test/ui/error-codes/E0138.rs b/src/test/compile-fail/E0138.rs similarity index 100% rename from src/test/ui/error-codes/E0138.rs rename to src/test/compile-fail/E0138.rs diff --git a/src/test/ui/error-codes/E0152.rs b/src/test/compile-fail/E0152.rs similarity index 100% rename from src/test/ui/error-codes/E0152.rs rename to src/test/compile-fail/E0152.rs diff --git a/src/test/ui/error-codes/E0161.rs b/src/test/compile-fail/E0161.rs similarity index 100% rename from src/test/ui/error-codes/E0161.rs rename to src/test/compile-fail/E0161.rs diff --git a/src/test/ui/error-codes/E0162.rs b/src/test/compile-fail/E0162.rs similarity index 100% rename from src/test/ui/error-codes/E0162.rs rename to src/test/compile-fail/E0162.rs diff --git a/src/test/ui/error-codes/E0164.rs b/src/test/compile-fail/E0164.rs similarity index 100% rename from src/test/ui/error-codes/E0164.rs rename to src/test/compile-fail/E0164.rs diff --git a/src/test/ui/error-codes/E0165.rs b/src/test/compile-fail/E0165.rs similarity index 100% rename from src/test/ui/error-codes/E0165.rs rename to src/test/compile-fail/E0165.rs diff --git a/src/test/ui/error-codes/E0184.rs b/src/test/compile-fail/E0184.rs similarity index 100% rename from src/test/ui/error-codes/E0184.rs rename to src/test/compile-fail/E0184.rs diff --git a/src/test/ui/error-codes/E0185.rs b/src/test/compile-fail/E0185.rs similarity index 100% rename from src/test/ui/error-codes/E0185.rs rename to src/test/compile-fail/E0185.rs diff --git a/src/test/ui/error-codes/E0186.rs b/src/test/compile-fail/E0186.rs similarity index 100% rename from src/test/ui/error-codes/E0186.rs rename to src/test/compile-fail/E0186.rs diff --git a/src/test/ui/error-codes/E0191.rs b/src/test/compile-fail/E0191.rs similarity index 100% rename from src/test/ui/error-codes/E0191.rs rename to src/test/compile-fail/E0191.rs diff --git a/src/test/ui/error-codes/E0192.rs b/src/test/compile-fail/E0192.rs similarity index 100% rename from src/test/ui/error-codes/E0192.rs rename to src/test/compile-fail/E0192.rs diff --git a/src/test/ui/error-codes/E0194.rs b/src/test/compile-fail/E0194.rs similarity index 100% rename from src/test/ui/error-codes/E0194.rs rename to src/test/compile-fail/E0194.rs diff --git a/src/test/ui/error-codes/E0195.rs b/src/test/compile-fail/E0195.rs similarity index 84% rename from src/test/ui/error-codes/E0195.rs rename to src/test/compile-fail/E0195.rs index 4f4d7ce0dba83..06dd903b23db8 100644 --- a/src/test/ui/error-codes/E0195.rs +++ b/src/test/compile-fail/E0195.rs @@ -10,14 +10,13 @@ trait Trait { fn bar<'a,'b:'a>(x: &'a str, y: &'b str); - //~^ NOTE lifetimes in impl do not match this method in trait } struct Foo; impl Trait for Foo { fn bar<'a,'b>(x: &'a str, y: &'b str) { //~ ERROR E0195 - //~^ NOTE lifetimes do not match method in trait + //~^ lifetimes do not match trait } } diff --git a/src/test/ui/error-codes/E0197.rs b/src/test/compile-fail/E0197.rs similarity index 100% rename from src/test/ui/error-codes/E0197.rs rename to src/test/compile-fail/E0197.rs diff --git a/src/test/ui/error-codes/E0198.rs b/src/test/compile-fail/E0198.rs similarity index 100% rename from src/test/ui/error-codes/E0198.rs rename to src/test/compile-fail/E0198.rs diff --git a/src/test/ui/error-codes/E0199.rs b/src/test/compile-fail/E0199.rs similarity index 100% rename from src/test/ui/error-codes/E0199.rs rename to src/test/compile-fail/E0199.rs diff --git a/src/test/ui/error-codes/E0200.rs b/src/test/compile-fail/E0200.rs similarity index 100% rename from src/test/ui/error-codes/E0200.rs rename to src/test/compile-fail/E0200.rs diff --git a/src/test/ui/error-codes/E0201.rs b/src/test/compile-fail/E0201.rs similarity index 100% rename from src/test/ui/error-codes/E0201.rs rename to src/test/compile-fail/E0201.rs diff --git a/src/test/ui/error-codes/E0206.rs b/src/test/compile-fail/E0206.rs similarity index 100% rename from src/test/ui/error-codes/E0206.rs rename to src/test/compile-fail/E0206.rs diff --git a/src/test/ui/error-codes/E0207.rs b/src/test/compile-fail/E0207.rs similarity index 100% rename from src/test/ui/error-codes/E0207.rs rename to src/test/compile-fail/E0207.rs diff --git a/src/test/ui/error-codes/E0214.rs b/src/test/compile-fail/E0214.rs similarity index 100% rename from src/test/ui/error-codes/E0214.rs rename to src/test/compile-fail/E0214.rs diff --git a/src/test/ui/error-codes/E0220.rs b/src/test/compile-fail/E0220.rs similarity index 100% rename from src/test/ui/error-codes/E0220.rs rename to src/test/compile-fail/E0220.rs diff --git a/src/test/ui/error-codes/E0221.rs b/src/test/compile-fail/E0221.rs similarity index 100% rename from src/test/ui/error-codes/E0221.rs rename to src/test/compile-fail/E0221.rs diff --git a/src/test/ui/error-codes/E0223.rs b/src/test/compile-fail/E0223.rs similarity index 100% rename from src/test/ui/error-codes/E0223.rs rename to src/test/compile-fail/E0223.rs diff --git a/src/test/ui/error-codes/E0225.rs b/src/test/compile-fail/E0225.rs similarity index 100% rename from src/test/ui/error-codes/E0225.rs rename to src/test/compile-fail/E0225.rs diff --git a/src/test/ui/error-codes/E0229.rs b/src/test/compile-fail/E0229.rs similarity index 100% rename from src/test/ui/error-codes/E0229.rs rename to src/test/compile-fail/E0229.rs diff --git a/src/test/ui/error-codes/E0232.rs b/src/test/compile-fail/E0232.rs similarity index 100% rename from src/test/ui/error-codes/E0232.rs rename to src/test/compile-fail/E0232.rs diff --git a/src/test/ui/error-codes/E0243.rs b/src/test/compile-fail/E0243.rs similarity index 100% rename from src/test/ui/error-codes/E0243.rs rename to src/test/compile-fail/E0243.rs diff --git a/src/test/ui/error-codes/E0244.rs b/src/test/compile-fail/E0244.rs similarity index 100% rename from src/test/ui/error-codes/E0244.rs rename to src/test/compile-fail/E0244.rs diff --git a/src/test/ui/error-codes/E0252.rs b/src/test/compile-fail/E0252.rs similarity index 100% rename from src/test/ui/error-codes/E0252.rs rename to src/test/compile-fail/E0252.rs diff --git a/src/test/ui/error-codes/E0253.rs b/src/test/compile-fail/E0253.rs similarity index 100% rename from src/test/ui/error-codes/E0253.rs rename to src/test/compile-fail/E0253.rs diff --git a/src/test/ui/error-codes/E0254.rs b/src/test/compile-fail/E0254.rs similarity index 100% rename from src/test/ui/error-codes/E0254.rs rename to src/test/compile-fail/E0254.rs diff --git a/src/test/ui/error-codes/E0255.rs b/src/test/compile-fail/E0255.rs similarity index 100% rename from src/test/ui/error-codes/E0255.rs rename to src/test/compile-fail/E0255.rs diff --git a/src/test/ui/error-codes/E0259.rs b/src/test/compile-fail/E0259.rs similarity index 100% rename from src/test/ui/error-codes/E0259.rs rename to src/test/compile-fail/E0259.rs diff --git a/src/test/ui/error-codes/E0260.rs b/src/test/compile-fail/E0260.rs similarity index 100% rename from src/test/ui/error-codes/E0260.rs rename to src/test/compile-fail/E0260.rs diff --git a/src/test/ui/error-codes/E0261.rs b/src/test/compile-fail/E0261.rs similarity index 100% rename from src/test/ui/error-codes/E0261.rs rename to src/test/compile-fail/E0261.rs diff --git a/src/test/ui/error-codes/E0262.rs b/src/test/compile-fail/E0262.rs similarity index 100% rename from src/test/ui/error-codes/E0262.rs rename to src/test/compile-fail/E0262.rs diff --git a/src/test/ui/error-codes/E0263.rs b/src/test/compile-fail/E0263.rs similarity index 100% rename from src/test/ui/error-codes/E0263.rs rename to src/test/compile-fail/E0263.rs diff --git a/src/test/ui/error-codes/E0264.rs b/src/test/compile-fail/E0264.rs similarity index 100% rename from src/test/ui/error-codes/E0264.rs rename to src/test/compile-fail/E0264.rs diff --git a/src/test/ui/error-codes/E0267.rs b/src/test/compile-fail/E0267.rs similarity index 100% rename from src/test/ui/error-codes/E0267.rs rename to src/test/compile-fail/E0267.rs diff --git a/src/test/ui/error-codes/E0268.rs b/src/test/compile-fail/E0268.rs similarity index 100% rename from src/test/ui/error-codes/E0268.rs rename to src/test/compile-fail/E0268.rs diff --git a/src/test/ui/error-codes/E0271.rs b/src/test/compile-fail/E0271.rs similarity index 100% rename from src/test/ui/error-codes/E0271.rs rename to src/test/compile-fail/E0271.rs diff --git a/src/test/ui/error-codes/E0275.rs b/src/test/compile-fail/E0275.rs similarity index 100% rename from src/test/ui/error-codes/E0275.rs rename to src/test/compile-fail/E0275.rs diff --git a/src/test/ui/error-codes/E0276.rs b/src/test/compile-fail/E0276.rs similarity index 100% rename from src/test/ui/error-codes/E0276.rs rename to src/test/compile-fail/E0276.rs diff --git a/src/test/ui/error-codes/E0277-2.rs b/src/test/compile-fail/E0277-2.rs similarity index 100% rename from src/test/ui/error-codes/E0277-2.rs rename to src/test/compile-fail/E0277-2.rs diff --git a/src/test/ui/error-codes/E0277.rs b/src/test/compile-fail/E0277.rs similarity index 100% rename from src/test/ui/error-codes/E0277.rs rename to src/test/compile-fail/E0277.rs diff --git a/src/test/ui/error-codes/E0282.rs b/src/test/compile-fail/E0282.rs similarity index 100% rename from src/test/ui/error-codes/E0282.rs rename to src/test/compile-fail/E0282.rs diff --git a/src/test/ui/error-codes/E0283.rs b/src/test/compile-fail/E0283.rs similarity index 100% rename from src/test/ui/error-codes/E0283.rs rename to src/test/compile-fail/E0283.rs diff --git a/src/test/ui/error-codes/E0296.rs b/src/test/compile-fail/E0296.rs similarity index 100% rename from src/test/ui/error-codes/E0296.rs rename to src/test/compile-fail/E0296.rs diff --git a/src/test/ui/error-codes/E0297.rs b/src/test/compile-fail/E0297.rs similarity index 100% rename from src/test/ui/error-codes/E0297.rs rename to src/test/compile-fail/E0297.rs diff --git a/src/test/ui/error-codes/E0301.rs b/src/test/compile-fail/E0301.rs similarity index 100% rename from src/test/ui/error-codes/E0301.rs rename to src/test/compile-fail/E0301.rs diff --git a/src/test/ui/error-codes/E0302.rs b/src/test/compile-fail/E0302.rs similarity index 100% rename from src/test/ui/error-codes/E0302.rs rename to src/test/compile-fail/E0302.rs diff --git a/src/test/ui/error-codes/E0303.rs b/src/test/compile-fail/E0303.rs similarity index 100% rename from src/test/ui/error-codes/E0303.rs rename to src/test/compile-fail/E0303.rs diff --git a/src/test/ui/error-codes/E0308-4.rs b/src/test/compile-fail/E0308-4.rs similarity index 100% rename from src/test/ui/error-codes/E0308-4.rs rename to src/test/compile-fail/E0308-4.rs diff --git a/src/test/ui/error-codes/E0308.rs b/src/test/compile-fail/E0308.rs similarity index 100% rename from src/test/ui/error-codes/E0308.rs rename to src/test/compile-fail/E0308.rs diff --git a/src/test/ui/error-codes/E0365.rs b/src/test/compile-fail/E0365.rs similarity index 100% rename from src/test/ui/error-codes/E0365.rs rename to src/test/compile-fail/E0365.rs diff --git a/src/test/ui/error-codes/E0370.rs b/src/test/compile-fail/E0370.rs similarity index 100% rename from src/test/ui/error-codes/E0370.rs rename to src/test/compile-fail/E0370.rs diff --git a/src/test/ui/error-codes/E0374.rs b/src/test/compile-fail/E0374.rs similarity index 100% rename from src/test/ui/error-codes/E0374.rs rename to src/test/compile-fail/E0374.rs diff --git a/src/test/ui/error-codes/E0375.rs b/src/test/compile-fail/E0375.rs similarity index 100% rename from src/test/ui/error-codes/E0375.rs rename to src/test/compile-fail/E0375.rs diff --git a/src/test/ui/error-codes/E0376.rs b/src/test/compile-fail/E0376.rs similarity index 100% rename from src/test/ui/error-codes/E0376.rs rename to src/test/compile-fail/E0376.rs diff --git a/src/test/ui/error-codes/E0388.rs b/src/test/compile-fail/E0388.rs similarity index 100% rename from src/test/ui/error-codes/E0388.rs rename to src/test/compile-fail/E0388.rs diff --git a/src/test/ui/error-codes/E0389.rs b/src/test/compile-fail/E0389.rs similarity index 100% rename from src/test/ui/error-codes/E0389.rs rename to src/test/compile-fail/E0389.rs diff --git a/src/test/ui/error-codes/E0390.rs b/src/test/compile-fail/E0390.rs similarity index 100% rename from src/test/ui/error-codes/E0390.rs rename to src/test/compile-fail/E0390.rs diff --git a/src/test/ui/error-codes/E0392.rs b/src/test/compile-fail/E0392.rs similarity index 100% rename from src/test/ui/error-codes/E0392.rs rename to src/test/compile-fail/E0392.rs diff --git a/src/test/ui/error-codes/E0393.rs b/src/test/compile-fail/E0393.rs similarity index 100% rename from src/test/ui/error-codes/E0393.rs rename to src/test/compile-fail/E0393.rs diff --git a/src/test/ui/error-codes/E0394.rs b/src/test/compile-fail/E0394.rs similarity index 100% rename from src/test/ui/error-codes/E0394.rs rename to src/test/compile-fail/E0394.rs diff --git a/src/test/ui/error-codes/E0395.rs b/src/test/compile-fail/E0395.rs similarity index 100% rename from src/test/ui/error-codes/E0395.rs rename to src/test/compile-fail/E0395.rs diff --git a/src/test/ui/error-codes/E0396.rs b/src/test/compile-fail/E0396.rs similarity index 100% rename from src/test/ui/error-codes/E0396.rs rename to src/test/compile-fail/E0396.rs diff --git a/src/test/ui/error-codes/E0401.rs b/src/test/compile-fail/E0401.rs similarity index 100% rename from src/test/ui/error-codes/E0401.rs rename to src/test/compile-fail/E0401.rs diff --git a/src/test/ui/error-codes/E0403.rs b/src/test/compile-fail/E0403.rs similarity index 100% rename from src/test/ui/error-codes/E0403.rs rename to src/test/compile-fail/E0403.rs diff --git a/src/test/ui/error-codes/E0404.rs b/src/test/compile-fail/E0404.rs similarity index 100% rename from src/test/ui/error-codes/E0404.rs rename to src/test/compile-fail/E0404.rs diff --git a/src/test/ui/error-codes/E0405.rs b/src/test/compile-fail/E0405.rs similarity index 100% rename from src/test/ui/error-codes/E0405.rs rename to src/test/compile-fail/E0405.rs diff --git a/src/test/ui/error-codes/E0407.rs b/src/test/compile-fail/E0407.rs similarity index 100% rename from src/test/ui/error-codes/E0407.rs rename to src/test/compile-fail/E0407.rs diff --git a/src/test/ui/error-codes/E0408.rs b/src/test/compile-fail/E0408.rs similarity index 100% rename from src/test/ui/error-codes/E0408.rs rename to src/test/compile-fail/E0408.rs diff --git a/src/test/ui/error-codes/E0411.rs b/src/test/compile-fail/E0411.rs similarity index 100% rename from src/test/ui/error-codes/E0411.rs rename to src/test/compile-fail/E0411.rs diff --git a/src/test/ui/error-codes/E0412.rs b/src/test/compile-fail/E0412.rs similarity index 100% rename from src/test/ui/error-codes/E0412.rs rename to src/test/compile-fail/E0412.rs diff --git a/src/test/ui/error-codes/E0415.rs b/src/test/compile-fail/E0415.rs similarity index 100% rename from src/test/ui/error-codes/E0415.rs rename to src/test/compile-fail/E0415.rs diff --git a/src/test/ui/error-codes/E0416.rs b/src/test/compile-fail/E0416.rs similarity index 100% rename from src/test/ui/error-codes/E0416.rs rename to src/test/compile-fail/E0416.rs diff --git a/src/test/ui/error-codes/E0423.rs b/src/test/compile-fail/E0423.rs similarity index 100% rename from src/test/ui/error-codes/E0423.rs rename to src/test/compile-fail/E0423.rs diff --git a/src/test/ui/error-codes/E0424.rs b/src/test/compile-fail/E0424.rs similarity index 100% rename from src/test/ui/error-codes/E0424.rs rename to src/test/compile-fail/E0424.rs diff --git a/src/test/ui/error-codes/E0425.rs b/src/test/compile-fail/E0425.rs similarity index 100% rename from src/test/ui/error-codes/E0425.rs rename to src/test/compile-fail/E0425.rs diff --git a/src/test/ui/error-codes/E0426.rs b/src/test/compile-fail/E0426.rs similarity index 100% rename from src/test/ui/error-codes/E0426.rs rename to src/test/compile-fail/E0426.rs diff --git a/src/test/ui/error-codes/E0428.rs b/src/test/compile-fail/E0428.rs similarity index 100% rename from src/test/ui/error-codes/E0428.rs rename to src/test/compile-fail/E0428.rs diff --git a/src/test/ui/error-codes/E0429.rs b/src/test/compile-fail/E0429.rs similarity index 100% rename from src/test/ui/error-codes/E0429.rs rename to src/test/compile-fail/E0429.rs diff --git a/src/test/ui/error-codes/E0430.rs b/src/test/compile-fail/E0430.rs similarity index 100% rename from src/test/ui/error-codes/E0430.rs rename to src/test/compile-fail/E0430.rs diff --git a/src/test/ui/error-codes/E0431.rs b/src/test/compile-fail/E0431.rs similarity index 100% rename from src/test/ui/error-codes/E0431.rs rename to src/test/compile-fail/E0431.rs diff --git a/src/test/ui/error-codes/E0432.rs b/src/test/compile-fail/E0432.rs similarity index 100% rename from src/test/ui/error-codes/E0432.rs rename to src/test/compile-fail/E0432.rs diff --git a/src/test/ui/error-codes/E0433.rs b/src/test/compile-fail/E0433.rs similarity index 100% rename from src/test/ui/error-codes/E0433.rs rename to src/test/compile-fail/E0433.rs diff --git a/src/test/ui/error-codes/E0434.rs b/src/test/compile-fail/E0434.rs similarity index 100% rename from src/test/ui/error-codes/E0434.rs rename to src/test/compile-fail/E0434.rs diff --git a/src/test/ui/error-codes/E0435.rs b/src/test/compile-fail/E0435.rs similarity index 100% rename from src/test/ui/error-codes/E0435.rs rename to src/test/compile-fail/E0435.rs diff --git a/src/test/ui/error-codes/E0437.rs b/src/test/compile-fail/E0437.rs similarity index 100% rename from src/test/ui/error-codes/E0437.rs rename to src/test/compile-fail/E0437.rs diff --git a/src/test/ui/error-codes/E0438.rs b/src/test/compile-fail/E0438.rs similarity index 100% rename from src/test/ui/error-codes/E0438.rs rename to src/test/compile-fail/E0438.rs diff --git a/src/test/ui/error-codes/E0439.rs b/src/test/compile-fail/E0439.rs similarity index 100% rename from src/test/ui/error-codes/E0439.rs rename to src/test/compile-fail/E0439.rs diff --git a/src/test/ui/error-codes/E0440.rs b/src/test/compile-fail/E0440.rs similarity index 100% rename from src/test/ui/error-codes/E0440.rs rename to src/test/compile-fail/E0440.rs diff --git a/src/test/ui/error-codes/E0441.rs b/src/test/compile-fail/E0441.rs similarity index 100% rename from src/test/ui/error-codes/E0441.rs rename to src/test/compile-fail/E0441.rs diff --git a/src/test/ui/error-codes/E0442.rs b/src/test/compile-fail/E0442.rs similarity index 100% rename from src/test/ui/error-codes/E0442.rs rename to src/test/compile-fail/E0442.rs diff --git a/src/test/ui/error-codes/E0443.rs b/src/test/compile-fail/E0443.rs similarity index 100% rename from src/test/ui/error-codes/E0443.rs rename to src/test/compile-fail/E0443.rs diff --git a/src/test/ui/error-codes/E0444.rs b/src/test/compile-fail/E0444.rs similarity index 100% rename from src/test/ui/error-codes/E0444.rs rename to src/test/compile-fail/E0444.rs diff --git a/src/test/ui/error-codes/E0445.rs b/src/test/compile-fail/E0445.rs similarity index 100% rename from src/test/ui/error-codes/E0445.rs rename to src/test/compile-fail/E0445.rs diff --git a/src/test/ui/error-codes/E0446.rs b/src/test/compile-fail/E0446.rs similarity index 100% rename from src/test/ui/error-codes/E0446.rs rename to src/test/compile-fail/E0446.rs diff --git a/src/test/ui/error-codes/E0449.rs b/src/test/compile-fail/E0449.rs similarity index 100% rename from src/test/ui/error-codes/E0449.rs rename to src/test/compile-fail/E0449.rs diff --git a/src/test/ui/error-codes/E0451.rs b/src/test/compile-fail/E0451.rs similarity index 100% rename from src/test/ui/error-codes/E0451.rs rename to src/test/compile-fail/E0451.rs diff --git a/src/test/ui/error-codes/E0452.rs b/src/test/compile-fail/E0452.rs similarity index 100% rename from src/test/ui/error-codes/E0452.rs rename to src/test/compile-fail/E0452.rs diff --git a/src/test/ui/error-codes/E0453.rs b/src/test/compile-fail/E0453.rs similarity index 100% rename from src/test/ui/error-codes/E0453.rs rename to src/test/compile-fail/E0453.rs diff --git a/src/test/ui/error-codes/E0454.rs b/src/test/compile-fail/E0454.rs similarity index 100% rename from src/test/ui/error-codes/E0454.rs rename to src/test/compile-fail/E0454.rs diff --git a/src/test/ui/error-codes/E0458.rs b/src/test/compile-fail/E0458.rs similarity index 100% rename from src/test/ui/error-codes/E0458.rs rename to src/test/compile-fail/E0458.rs diff --git a/src/test/ui/error-codes/E0459.rs b/src/test/compile-fail/E0459.rs similarity index 100% rename from src/test/ui/error-codes/E0459.rs rename to src/test/compile-fail/E0459.rs diff --git a/src/test/ui/error-codes/E0463.rs b/src/test/compile-fail/E0463.rs similarity index 100% rename from src/test/ui/error-codes/E0463.rs rename to src/test/compile-fail/E0463.rs diff --git a/src/test/ui/error-codes/E0478.rs b/src/test/compile-fail/E0478.rs similarity index 100% rename from src/test/ui/error-codes/E0478.rs rename to src/test/compile-fail/E0478.rs diff --git a/src/test/ui/error-codes/E0492.rs b/src/test/compile-fail/E0492.rs similarity index 100% rename from src/test/ui/error-codes/E0492.rs rename to src/test/compile-fail/E0492.rs diff --git a/src/test/ui/error-codes/E0494.rs b/src/test/compile-fail/E0494.rs similarity index 100% rename from src/test/ui/error-codes/E0494.rs rename to src/test/compile-fail/E0494.rs diff --git a/src/test/ui/error-codes/E0496.rs b/src/test/compile-fail/E0496.rs similarity index 100% rename from src/test/ui/error-codes/E0496.rs rename to src/test/compile-fail/E0496.rs diff --git a/src/test/ui/error-codes/E0499.rs b/src/test/compile-fail/E0499.rs similarity index 100% rename from src/test/ui/error-codes/E0499.rs rename to src/test/compile-fail/E0499.rs diff --git a/src/test/ui/error-codes/E0502.rs b/src/test/compile-fail/E0502.rs similarity index 100% rename from src/test/ui/error-codes/E0502.rs rename to src/test/compile-fail/E0502.rs diff --git a/src/test/ui/error-codes/E0503.rs b/src/test/compile-fail/E0503.rs similarity index 100% rename from src/test/ui/error-codes/E0503.rs rename to src/test/compile-fail/E0503.rs diff --git a/src/test/ui/error-codes/E0504.rs b/src/test/compile-fail/E0504.rs similarity index 100% rename from src/test/ui/error-codes/E0504.rs rename to src/test/compile-fail/E0504.rs diff --git a/src/test/ui/error-codes/E0505.rs b/src/test/compile-fail/E0505.rs similarity index 100% rename from src/test/ui/error-codes/E0505.rs rename to src/test/compile-fail/E0505.rs diff --git a/src/test/ui/error-codes/E0507.rs b/src/test/compile-fail/E0507.rs similarity index 100% rename from src/test/ui/error-codes/E0507.rs rename to src/test/compile-fail/E0507.rs diff --git a/src/test/ui/error-codes/E0509.rs b/src/test/compile-fail/E0509.rs similarity index 100% rename from src/test/ui/error-codes/E0509.rs rename to src/test/compile-fail/E0509.rs diff --git a/src/test/ui/error-codes/E0511.rs b/src/test/compile-fail/E0511.rs similarity index 100% rename from src/test/ui/error-codes/E0511.rs rename to src/test/compile-fail/E0511.rs diff --git a/src/test/ui/error-codes/E0512.rs b/src/test/compile-fail/E0512.rs similarity index 100% rename from src/test/ui/error-codes/E0512.rs rename to src/test/compile-fail/E0512.rs diff --git a/src/test/ui/error-codes/E0516.rs b/src/test/compile-fail/E0516.rs similarity index 100% rename from src/test/ui/error-codes/E0516.rs rename to src/test/compile-fail/E0516.rs diff --git a/src/test/ui/error-codes/E0517.rs b/src/test/compile-fail/E0517.rs similarity index 100% rename from src/test/ui/error-codes/E0517.rs rename to src/test/compile-fail/E0517.rs diff --git a/src/test/ui/error-codes/E0518.rs b/src/test/compile-fail/E0518.rs similarity index 100% rename from src/test/ui/error-codes/E0518.rs rename to src/test/compile-fail/E0518.rs diff --git a/src/test/ui/error-codes/E0520.rs b/src/test/compile-fail/E0520.rs similarity index 100% rename from src/test/ui/error-codes/E0520.rs rename to src/test/compile-fail/E0520.rs diff --git a/src/test/ui/error-codes/E0522.rs b/src/test/compile-fail/E0522.rs similarity index 100% rename from src/test/ui/error-codes/E0522.rs rename to src/test/compile-fail/E0522.rs diff --git a/src/test/ui/error-codes/E0527.rs b/src/test/compile-fail/E0527.rs similarity index 100% rename from src/test/ui/error-codes/E0527.rs rename to src/test/compile-fail/E0527.rs diff --git a/src/test/ui/error-codes/E0528.rs b/src/test/compile-fail/E0528.rs similarity index 100% rename from src/test/ui/error-codes/E0528.rs rename to src/test/compile-fail/E0528.rs diff --git a/src/test/ui/error-codes/E0529.rs b/src/test/compile-fail/E0529.rs similarity index 100% rename from src/test/ui/error-codes/E0529.rs rename to src/test/compile-fail/E0529.rs diff --git a/src/test/ui/error-codes/E0530.rs b/src/test/compile-fail/E0530.rs similarity index 100% rename from src/test/ui/error-codes/E0530.rs rename to src/test/compile-fail/E0530.rs diff --git a/src/test/ui/error-codes/E0532.rs b/src/test/compile-fail/E0532.rs similarity index 100% rename from src/test/ui/error-codes/E0532.rs rename to src/test/compile-fail/E0532.rs diff --git a/src/test/ui/error-codes/E0534.rs b/src/test/compile-fail/E0534.rs similarity index 100% rename from src/test/ui/error-codes/E0534.rs rename to src/test/compile-fail/E0534.rs diff --git a/src/test/ui/error-codes/E0558.rs b/src/test/compile-fail/E0558.rs similarity index 100% rename from src/test/ui/error-codes/E0558.rs rename to src/test/compile-fail/E0558.rs diff --git a/src/test/ui/error-codes/E0559.rs b/src/test/compile-fail/E0559.rs similarity index 100% rename from src/test/ui/error-codes/E0559.rs rename to src/test/compile-fail/E0559.rs diff --git a/src/test/ui/error-codes/E0560.rs b/src/test/compile-fail/E0560.rs similarity index 100% rename from src/test/ui/error-codes/E0560.rs rename to src/test/compile-fail/E0560.rs diff --git a/src/test/ui/error-codes/E0565-1.rs b/src/test/compile-fail/E0565-1.rs similarity index 100% rename from src/test/ui/error-codes/E0565-1.rs rename to src/test/compile-fail/E0565-1.rs diff --git a/src/test/ui/error-codes/E0565.rs b/src/test/compile-fail/E0565.rs similarity index 100% rename from src/test/ui/error-codes/E0565.rs rename to src/test/compile-fail/E0565.rs diff --git a/src/test/ui/error-codes/E0572.rs b/src/test/compile-fail/E0572.rs similarity index 100% rename from src/test/ui/error-codes/E0572.rs rename to src/test/compile-fail/E0572.rs diff --git a/src/test/ui/error-codes/E0582.rs b/src/test/compile-fail/E0582.rs similarity index 100% rename from src/test/ui/error-codes/E0582.rs rename to src/test/compile-fail/E0582.rs diff --git a/src/test/ui/error-codes/E0585.rs b/src/test/compile-fail/E0585.rs similarity index 100% rename from src/test/ui/error-codes/E0585.rs rename to src/test/compile-fail/E0585.rs diff --git a/src/test/ui/error-codes/E0586.rs b/src/test/compile-fail/E0586.rs similarity index 100% rename from src/test/ui/error-codes/E0586.rs rename to src/test/compile-fail/E0586.rs diff --git a/src/test/ui/error-codes/E0597.rs b/src/test/compile-fail/E0597.rs similarity index 100% rename from src/test/ui/error-codes/E0597.rs rename to src/test/compile-fail/E0597.rs diff --git a/src/test/ui/error-codes/E0599.rs b/src/test/compile-fail/E0599.rs similarity index 100% rename from src/test/ui/error-codes/E0599.rs rename to src/test/compile-fail/E0599.rs diff --git a/src/test/ui/error-codes/E0600.rs b/src/test/compile-fail/E0600.rs similarity index 100% rename from src/test/ui/error-codes/E0600.rs rename to src/test/compile-fail/E0600.rs diff --git a/src/test/ui/error-codes/E0602.rs b/src/test/compile-fail/E0602.rs similarity index 100% rename from src/test/ui/error-codes/E0602.rs rename to src/test/compile-fail/E0602.rs diff --git a/src/test/ui/error-codes/E0603.rs b/src/test/compile-fail/E0603.rs similarity index 100% rename from src/test/ui/error-codes/E0603.rs rename to src/test/compile-fail/E0603.rs diff --git a/src/test/ui/error-codes/E0604.rs b/src/test/compile-fail/E0604.rs similarity index 100% rename from src/test/ui/error-codes/E0604.rs rename to src/test/compile-fail/E0604.rs diff --git a/src/test/ui/error-codes/E0605.rs b/src/test/compile-fail/E0605.rs similarity index 100% rename from src/test/ui/error-codes/E0605.rs rename to src/test/compile-fail/E0605.rs diff --git a/src/test/ui/error-codes/E0606.rs b/src/test/compile-fail/E0606.rs similarity index 100% rename from src/test/ui/error-codes/E0606.rs rename to src/test/compile-fail/E0606.rs diff --git a/src/test/ui/error-codes/E0607.rs b/src/test/compile-fail/E0607.rs similarity index 100% rename from src/test/ui/error-codes/E0607.rs rename to src/test/compile-fail/E0607.rs diff --git a/src/test/ui/error-codes/E0608.rs b/src/test/compile-fail/E0608.rs similarity index 100% rename from src/test/ui/error-codes/E0608.rs rename to src/test/compile-fail/E0608.rs diff --git a/src/test/ui/error-codes/E0609.rs b/src/test/compile-fail/E0609.rs similarity index 100% rename from src/test/ui/error-codes/E0609.rs rename to src/test/compile-fail/E0609.rs diff --git a/src/test/ui/error-codes/E0610.rs b/src/test/compile-fail/E0610.rs similarity index 100% rename from src/test/ui/error-codes/E0610.rs rename to src/test/compile-fail/E0610.rs diff --git a/src/test/ui/error-codes/E0611.rs b/src/test/compile-fail/E0611.rs similarity index 100% rename from src/test/ui/error-codes/E0611.rs rename to src/test/compile-fail/E0611.rs diff --git a/src/test/ui/error-codes/E0612.rs b/src/test/compile-fail/E0612.rs similarity index 100% rename from src/test/ui/error-codes/E0612.rs rename to src/test/compile-fail/E0612.rs diff --git a/src/test/ui/error-codes/E0614.rs b/src/test/compile-fail/E0614.rs similarity index 100% rename from src/test/ui/error-codes/E0614.rs rename to src/test/compile-fail/E0614.rs diff --git a/src/test/ui/error-codes/E0615.rs b/src/test/compile-fail/E0615.rs similarity index 100% rename from src/test/ui/error-codes/E0615.rs rename to src/test/compile-fail/E0615.rs diff --git a/src/test/ui/error-codes/E0616.rs b/src/test/compile-fail/E0616.rs similarity index 100% rename from src/test/ui/error-codes/E0616.rs rename to src/test/compile-fail/E0616.rs diff --git a/src/test/ui/error-codes/E0617.rs b/src/test/compile-fail/E0617.rs similarity index 100% rename from src/test/ui/error-codes/E0617.rs rename to src/test/compile-fail/E0617.rs diff --git a/src/test/ui/error-codes/E0618.rs b/src/test/compile-fail/E0618.rs similarity index 100% rename from src/test/ui/error-codes/E0618.rs rename to src/test/compile-fail/E0618.rs diff --git a/src/test/ui/error-codes/E0620.rs b/src/test/compile-fail/E0620.rs similarity index 100% rename from src/test/ui/error-codes/E0620.rs rename to src/test/compile-fail/E0620.rs diff --git a/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.rs b/src/test/compile-fail/E0621-does-not-trigger-for-closures.rs similarity index 100% rename from src/test/ui/error-codes/E0621-does-not-trigger-for-closures.rs rename to src/test/compile-fail/E0621-does-not-trigger-for-closures.rs diff --git a/src/test/ui/error-codes/E0622.rs b/src/test/compile-fail/E0622.rs similarity index 100% rename from src/test/ui/error-codes/E0622.rs rename to src/test/compile-fail/E0622.rs diff --git a/src/test/ui/error-codes/E0624.rs b/src/test/compile-fail/E0624.rs similarity index 100% rename from src/test/ui/error-codes/E0624.rs rename to src/test/compile-fail/E0624.rs diff --git a/src/test/ui/error-codes/E0637.rs b/src/test/compile-fail/E0637.rs similarity index 100% rename from src/test/ui/error-codes/E0637.rs rename to src/test/compile-fail/E0637.rs diff --git a/src/test/ui/error-codes/E0657.rs b/src/test/compile-fail/E0657.rs similarity index 100% rename from src/test/ui/error-codes/E0657.rs rename to src/test/compile-fail/E0657.rs diff --git a/src/test/ui/error-codes/E0658.rs b/src/test/compile-fail/E0658.rs similarity index 100% rename from src/test/ui/error-codes/E0658.rs rename to src/test/compile-fail/E0658.rs diff --git a/src/test/ui/error-codes/E0659.rs b/src/test/compile-fail/E0659.rs similarity index 100% rename from src/test/ui/error-codes/E0659.rs rename to src/test/compile-fail/E0659.rs diff --git a/src/test/compile-fail/absolute-paths-in-nested-use-groups.rs b/src/test/compile-fail/absolute-paths-in-nested-use-groups.rs index fe052f2f47ffd..8e5ba489c565e 100644 --- a/src/test/compile-fail/absolute-paths-in-nested-use-groups.rs +++ b/src/test/compile-fail/absolute-paths-in-nested-use-groups.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(use_nested_groups)] #![allow(unused_imports)] mod foo {} diff --git a/src/test/compile-fail/associated-const-type-parameter-arms.rs b/src/test/compile-fail/associated-const-type-parameter-arms.rs index 630a234fa6641..52bb4a1b463b4 100644 --- a/src/test/compile-fail/associated-const-type-parameter-arms.rs +++ b/src/test/compile-fail/associated-const-type-parameter-arms.rs @@ -16,7 +16,6 @@ pub trait Foo { } struct Abc; - impl Foo for Abc { const X: EFoo = EFoo::B; } @@ -28,10 +27,8 @@ impl Foo for Def { pub fn test(arg: EFoo) { match arg { - A::X => println!("A::X"), - //~^ error: associated consts cannot be referenced in patterns [E0158] - B::X => println!("B::X"), - //~^ error: associated consts cannot be referenced in patterns [E0158] + A::X => println!("A::X"), //~ error: statics cannot be referenced in patterns [E0158] + B::X => println!("B::X"), //~ error: statics cannot be referenced in patterns [E0158] _ => (), } } diff --git a/src/test/compile-fail/borrowck/borrowck-describe-lvalue.rs b/src/test/compile-fail/borrowck/borrowck-describe-lvalue.rs index 1d08b80746582..062cc976a3dc1 100644 --- a/src/test/compile-fail/borrowck/borrowck-describe-lvalue.rs +++ b/src/test/compile-fail/borrowck/borrowck-describe-lvalue.rs @@ -72,7 +72,7 @@ fn main() { { let mut e = Baz::X(2); let _e0 = e.x(); - match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed + match e { Baz::X(value) => value //[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed //[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed @@ -110,7 +110,7 @@ fn main() { { let mut e = Box::new(Baz::X(3)); let _e0 = e.x(); - match *e { //[mir]~ ERROR cannot use `*e` because it was mutably borrowed + match *e { Baz::X(value) => value //[ast]~^ ERROR cannot use `e.0` because it was mutably borrowed //[mir]~^^ ERROR cannot use `e.0` because it was mutably borrowed @@ -127,25 +127,25 @@ fn main() { { let mut v = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let _v = &mut v; - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + match v { &[x, _, .., _, _] => println!("{}", x), //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + match v { &[_, x, .., _, _] => println!("{}", x), //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + match v { &[_, _, .., x, _] => println!("{}", x), //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + match v { &[_, _, .., _, x] => println!("{}", x), //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed @@ -156,25 +156,25 @@ fn main() { { let mut v = &[1, 2, 3, 4, 5]; let _v = &mut v; - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + match v { &[x..] => println!("{:?}", x), //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + match v { &[_, x..] => println!("{:?}", x), //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + match v { &[x.., _] => println!("{:?}", x), //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed _ => panic!("other case"), } - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + match v { &[_, x.., _] => println!("{:?}", x), //[ast]~^ ERROR cannot use `v[..]` because it was mutably borrowed //[mir]~^^ ERROR cannot use `v[..]` because it was mutably borrowed @@ -187,7 +187,7 @@ fn main() { let mut e = E::A(3); let _e = &mut e; - match e { //[mir]~ ERROR cannot use `e` because it was mutably borrowed + match e { E::A(ref ax) => //[ast]~^ ERROR cannot borrow `e.0` as immutable because `e` is also borrowed as mutable //[mir]~^^ ERROR cannot borrow `e.0` as immutable because it is also borrowed as mutable @@ -205,14 +205,14 @@ fn main() { struct S { x: F, y: (u32, u32), }; let mut s = S { x: F { x: 1, y: 2}, y: (999, 998) }; let _s = &mut s; - match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed + match s { S { y: (ref y0, _), .. } => //[ast]~^ ERROR cannot borrow `s.y.0` as immutable because `s` is also borrowed as mutable //[mir]~^^ ERROR cannot borrow `s.y.0` as immutable because it is also borrowed as mutable println!("y0: {:?}", y0), _ => panic!("other case"), } - match s { //[mir]~ ERROR cannot use `s` because it was mutably borrowed + match s { S { x: F { y: ref x0, .. }, .. } => //[ast]~^ ERROR cannot borrow `s.x.y` as immutable because `s` is also borrowed as mutable //[mir]~^^ ERROR cannot borrow `s.x.y` as immutable because it is also borrowed as mutable @@ -263,7 +263,7 @@ fn main() { struct F {x: u32, y: u32}; let mut v = &[F{x: 1, y: 2}, F{x: 3, y: 4}]; let _v = &mut v; - match v { //[mir]~ ERROR cannot use `v` because it was mutably borrowed + match v { &[_, F {x: ref xf, ..}] => println!("{}", xf), //[mir]~^ ERROR cannot borrow `v[..].x` as immutable because it is also borrowed as mutable // No errors in AST diff --git a/src/test/compile-fail/borrowck/borrowck-match-already-borrowed.rs b/src/test/compile-fail/borrowck/borrowck-match-already-borrowed.rs index 3e57ac0ca1910..4336812af9b58 100644 --- a/src/test/compile-fail/borrowck/borrowck-match-already-borrowed.rs +++ b/src/test/compile-fail/borrowck/borrowck-match-already-borrowed.rs @@ -19,7 +19,7 @@ enum Foo { fn match_enum() { let mut foo = Foo::B; let p = &mut foo; - let _ = match foo { //[mir]~ ERROR [E0503] + let _ = match foo { Foo::B => 1, //[mir]~ ERROR [E0503] _ => 2, Foo::A(x) => x //[ast]~ ERROR [E0503] @@ -31,7 +31,7 @@ fn match_enum() { fn main() { let mut x = 1; let _x = &mut x; - let _ = match x { //[mir]~ ERROR [E0503] + let _ = match x { x => x + 1, //[ast]~ ERROR [E0503] //[mir]~^ ERROR [E0503] y => y + 2, //[ast]~ ERROR [E0503] diff --git a/src/test/compile-fail/borrowck/two-phase-activation-sharing-interference.rs b/src/test/compile-fail/borrowck/two-phase-activation-sharing-interference.rs index 709c00ba8464a..a9797e4d215a5 100644 --- a/src/test/compile-fail/borrowck/two-phase-activation-sharing-interference.rs +++ b/src/test/compile-fail/borrowck/two-phase-activation-sharing-interference.rs @@ -8,13 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-tidy-linelength - -// revisions: lxl_beyond nll_beyond nll_target - -//[lxl_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref -//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref -Z nll -//[nll_target] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll +// revisions: lxl nll +//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows +//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll // This is an important corner case pointed out by Niko: one is // allowed to initiate a shared borrow during a reservation, but it @@ -22,14 +18,6 @@ // // FIXME: for clarity, diagnostics for these cases might be better off // if they specifically said "cannot activate mutable borrow of `x`" -// -// The convention for the listed revisions: "lxl" means lexical -// lifetimes (which can be easier to reason about). "nll" means -// non-lexical lifetimes. "nll_target" means the initial conservative -// two-phase borrows that only applies to autoref-introduced borrows. -// "nll_beyond" means the generalization of two-phase borrows to all -// `&mut`-borrows (doing so makes it easier to write code for specific -// corner cases). #![allow(dead_code)] @@ -39,7 +27,6 @@ fn ok() { let mut x = 3; let y = &mut x; { let z = &x; read(z); } - //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable *y += 1; } @@ -47,11 +34,9 @@ fn not_ok() { let mut x = 3; let y = &mut x; let z = &x; - //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable *y += 1; - //[lxl_beyond]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable - //[nll_beyond]~^^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable - //[nll_target]~^^^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable + //[lxl]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable + //[nll]~^^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable read(z); } @@ -59,21 +44,18 @@ fn should_be_ok_with_nll() { let mut x = 3; let y = &mut x; let z = &x; - //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable read(z); *y += 1; - //[lxl_beyond]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable - // (okay with (generalized) nll today) + //[lxl]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable + // (okay with nll today) } fn should_also_eventually_be_ok_with_nll() { let mut x = 3; let y = &mut x; let _z = &x; - //[nll_target]~^ ERROR cannot borrow `x` as immutable because it is also borrowed as mutable *y += 1; - //[lxl_beyond]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable - // (okay with (generalized) nll today) + //[lxl]~^ ERROR cannot borrow `x` as mutable because it is also borrowed as immutable } fn main() { } diff --git a/src/test/compile-fail/borrowck/two-phase-allow-access-during-reservation.rs b/src/test/compile-fail/borrowck/two-phase-allow-access-during-reservation.rs index dd174981fb1e2..7695bd3e4652c 100644 --- a/src/test/compile-fail/borrowck/two-phase-allow-access-during-reservation.rs +++ b/src/test/compile-fail/borrowck/two-phase-allow-access-during-reservation.rs @@ -8,12 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-tidy-linelength - -// revisions: lxl_beyond nll_beyond nll_target -//[lxl_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two_phase_beyond_autoref -//[nll_beyond] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two_phase_beyond_autoref -Z nll -//[nll_target] compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll +// revisions: lxl nll +//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows +//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll // This is the second counter-example from Niko's blog post // smallcultfollowing.com/babysteps/blog/2017/03/01/nested-method-calls-via-two-phase-borrowing/ @@ -21,14 +18,6 @@ // It is "artificial". It is meant to illustrate directly that we // should allow an aliasing access during reservation, but *not* while // the mutable borrow is active. -// -// The convention for the listed revisions: "lxl" means lexical -// lifetimes (which can be easier to reason about). "nll" means -// non-lexical lifetimes. "nll_target" means the initial conservative -// two-phase borrows that only applies to autoref-introduced borrows. -// "nll_beyond" means the generalization of two-phase borrows to all -// `&mut`-borrows (doing so makes it easier to write code for specific -// corner cases). fn main() { /*0*/ let mut i = 0; @@ -36,13 +25,11 @@ fn main() { /*1*/ let p = &mut i; // (reservation of `i` starts here) /*2*/ let j = i; // OK: `i` is only reserved here - //[nll_target]~^ ERROR cannot use `i` because it was mutably borrowed [E0503] /*3*/ *p += 1; // (mutable borrow of `i` starts here, since `p` is used) - /*4*/ let k = i; //[lxl_beyond]~ ERROR cannot use `i` because it was mutably borrowed [E0503] - //[nll_beyond]~^ ERROR cannot use `i` because it was mutably borrowed [E0503] - //[nll_target]~^^ ERROR cannot use `i` because it was mutably borrowed [E0503] + /*4*/ let k = i; //[lxl]~ ERROR cannot use `i` because it was mutably borrowed [E0503] + //[nll]~^ ERROR cannot use `i` because it was mutably borrowed [E0503] /*5*/ *p += 1; diff --git a/src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs b/src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs deleted file mode 100644 index 795d45a776db5..0000000000000 --- a/src/test/compile-fail/borrowck/two-phase-nonrecv-autoref.rs +++ /dev/null @@ -1,260 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// revisions: lxl nll g2p -//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows -//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll -//[g2p]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll -Z two-phase-beyond-autoref - -// This is a test checking that when we limit two-phase borrows to -// method receivers, we do not let other kinds of auto-ref to leak -// through. -// -// The g2p revision illustrates the "undesirable" behavior you would -// otherwise observe without limiting the phasing to autoref on method -// receivers (namely, in many cases demonstrated below, the error -// would not arise). - -// (If we revise the compiler or this test so that the g2p revision -// passes, turn the `rustc_attrs` feature back on and tag the `fn -// main` with `#[rustc_error]` so that this remains a valid -// compile-fail test.) -// -// #![feature(rustc_attrs)] - -use std::ops::{Index, IndexMut}; -use std::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign}; -use std::ops::{BitAndAssign, BitOrAssign, BitXorAssign, ShlAssign, ShrAssign}; - -// This is case outlined by Niko that we want to ensure we reject -// (at least initially). - -fn foo(x: &mut u32, y: u32) { - *x += y; -} - -fn deref_coercion(x: &mut u32) { - foo(x, *x); - //[lxl]~^ ERROR cannot use `*x` because it was mutably borrowed [E0503] - //[nll]~^^ ERROR cannot use `*x` because it was mutably borrowed [E0503] -} - -// While adding a flag to adjustments (indicating whether they -// should support two-phase borrows, here are the cases I -// encountered: -// -// - [x] Resolving overloaded_call_traits (call, call_mut, call_once) -// - [x] deref_coercion (shown above) -// - [x] coerce_unsized e.g. `&[T; n]`, `&mut [T; n] -> &[T]`, -// `&mut [T; n] -> &mut [T]`, `&Concrete -> &Trait` -// - [x] Method Call Receivers (the case we want to support!) -// - [x] ExprIndex and ExprUnary Deref; only need to handle coerce_index_op -// - [x] overloaded_binops - -fn overloaded_call_traits() { - // Regarding overloaded call traits, note that there is no - // scenario where adding two-phase borrows should "fix" these - // cases, because either we will resolve both invocations to - // `call_mut` (in which case the inner call requires a mutable - // borrow which will conflict with the outer reservation), or we - // will resolve both to `call` (which will just work, regardless - // of two-phase borrow support), or we will resolve both to - // `call_once` (in which case the inner call requires moving the - // receiver, invalidating the outer call). - - fn twice_ten_sm i32>(f: &mut F) { - f(f(10)); - //[lxl]~^ ERROR cannot borrow `*f` as mutable more than once at a time - //[lxl]~| ERROR cannot borrow `*f` as mutable more than once at a time - //[nll]~^^^ ERROR cannot borrow `*f` as mutable more than once at a time - //[nll]~| ERROR cannot borrow `*f` as mutable more than once at a time - //[g2p]~^^^^^ ERROR cannot borrow `*f` as mutable more than once at a time - } - fn twice_ten_si i32>(f: &mut F) { - f(f(10)); - } - fn twice_ten_so i32>(f: Box) { - f(f(10)); - //[lxl]~^ ERROR use of moved value: `*f` - //[nll]~^^ ERROR use of moved value: `*f` - //[g2p]~^^^ ERROR use of moved value: `*f` - } - - fn twice_ten_om(f: &mut FnMut(i32) -> i32) { - f(f(10)); - //[lxl]~^ ERROR cannot borrow `*f` as mutable more than once at a time - //[lxl]~| ERROR cannot borrow `*f` as mutable more than once at a time - //[nll]~^^^ ERROR cannot borrow `*f` as mutable more than once at a time - //[nll]~| ERROR cannot borrow `*f` as mutable more than once at a time - //[g2p]~^^^^^ ERROR cannot borrow `*f` as mutable more than once at a time - } - fn twice_ten_oi(f: &mut Fn(i32) -> i32) { - f(f(10)); - } - fn twice_ten_oo(f: Box i32>) { - f(f(10)); - //[lxl]~^ ERROR cannot move a value of type - //[lxl]~^^ ERROR cannot move a value of type - //[lxl]~^^^ ERROR use of moved value: `*f` - //[nll]~^^^^ ERROR cannot move a value of type - //[nll]~^^^^^ ERROR cannot move a value of type - //[nll]~^^^^^^ ERROR cannot move a value of type - //[nll]~^^^^^^^ ERROR cannot move a value of type - //[nll]~^^^^^^^^ ERROR use of moved value: `*f` - //[g2p]~^^^^^^^^^ ERROR cannot move a value of type - //[g2p]~^^^^^^^^^^ ERROR cannot move a value of type - //[g2p]~^^^^^^^^^^^ ERROR cannot move a value of type - //[g2p]~^^^^^^^^^^^^ ERROR cannot move a value of type - //[g2p]~^^^^^^^^^^^^^ ERROR use of moved value: `*f` - } - - twice_ten_sm(&mut |x| x + 1); - twice_ten_si(&mut |x| x + 1); - twice_ten_so(Box::new(|x| x + 1)); - twice_ten_om(&mut |x| x + 1); - twice_ten_oi(&mut |x| x + 1); - twice_ten_oo(Box::new(|x| x + 1)); -} - -trait TwoMethods { - fn m(&mut self, x: i32) -> i32 { x + 1 } - fn i(&self, x: i32) -> i32 { x + 1 } -} - -struct T; - -impl TwoMethods for T { } - -struct S; - -impl S { - fn m(&mut self, x: i32) -> i32 { x + 1 } - fn i(&self, x: i32) -> i32 { x + 1 } -} - -impl TwoMethods for [i32; 3] { } - -fn double_access(m: &mut [X], s: &[X]) { - m[0] = s[1]; -} - -fn coerce_unsized() { - let mut a = [1, 2, 3]; - - // This is not okay. - double_access(&mut a, &a); - //[lxl]~^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] - //[nll]~^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] - //[g2p]~^^^ ERROR cannot borrow `a` as immutable because it is also borrowed as mutable [E0502] - - // But this is okay. - a.m(a.i(10)); -} - -struct I(i32); - -impl Index for I { - type Output = i32; - fn index(&self, _: i32) -> &i32 { - &self.0 - } -} - -impl IndexMut for I { - fn index_mut(&mut self, _: i32) -> &mut i32 { - &mut self.0 - } -} - -fn coerce_index_op() { - let mut i = I(10); - i[i[3]] = 4; - //[lxl]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] - //[nll]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] - - i[3] = i[4]; - - i[i[3]] = i[4]; - //[lxl]~^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] - //[nll]~^^ ERROR cannot borrow `i` as immutable because it is also borrowed as mutable [E0502] -} - -struct A(i32); - -macro_rules! trivial_binop { - ($Trait:ident, $m:ident) => { - impl $Trait for A { fn $m(&mut self, rhs: i32) { self.0 = rhs; } } - } -} - -trivial_binop!(AddAssign, add_assign); -trivial_binop!(SubAssign, sub_assign); -trivial_binop!(MulAssign, mul_assign); -trivial_binop!(DivAssign, div_assign); -trivial_binop!(RemAssign, rem_assign); -trivial_binop!(BitAndAssign, bitand_assign); -trivial_binop!(BitOrAssign, bitor_assign); -trivial_binop!(BitXorAssign, bitxor_assign); -trivial_binop!(ShlAssign, shl_assign); -trivial_binop!(ShrAssign, shr_assign); - -fn overloaded_binops() { - let mut a = A(10); - a += a.0; - //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed - //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed - a -= a.0; - //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed - //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed - a *= a.0; - //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed - //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed - a /= a.0; - //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed - //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed - a &= a.0; - //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed - //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed - a |= a.0; - //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed - //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed - a ^= a.0; - //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed - //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed - a <<= a.0; - //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed - //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed - a >>= a.0; - //[lxl]~^ ERROR cannot use `a.0` because it was mutably borrowed - //[nll]~^^ ERROR cannot use `a.0` because it was mutably borrowed -} - -fn main() { - - // As a reminder, this is the basic case we want to ensure we handle. - let mut v = vec![1, 2, 3]; - v.push(v.len()); - - // (as a rule, pnkfelix does not like to write tests with dead code.) - - deref_coercion(&mut 5); - overloaded_call_traits(); - - - let mut s = S; - s.m(s.i(10)); - - let mut t = T; - t.m(t.i(10)); - - coerce_unsized(); - coerce_index_op(); - overloaded_binops(); -} diff --git a/src/test/compile-fail/borrowck/two-phase-reservation-sharing-interference.rs b/src/test/compile-fail/borrowck/two-phase-reservation-sharing-interference.rs index b5fda4985f23f..cc85315263a4f 100644 --- a/src/test/compile-fail/borrowck/two-phase-reservation-sharing-interference.rs +++ b/src/test/compile-fail/borrowck/two-phase-reservation-sharing-interference.rs @@ -8,13 +8,9 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-tidy-linelength - -// revisions: lxl_beyond nll_beyond nll_target - -//[lxl_beyond]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref -//[nll_beyond]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z two-phase-beyond-autoref -Z nll -//[nll_target]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll +// revisions: lxl nll +//[lxl]compile-flags: -Z borrowck=mir -Z two-phase-borrows +//[nll]compile-flags: -Z borrowck=mir -Z two-phase-borrows -Z nll // This is a corner case that the current implementation is (probably) // treating more conservatively than is necessary. But it also does @@ -23,18 +19,6 @@ // So this test is just making a note of the current behavior, with // the caveat that in the future, the rules may be loosened, at which // point this test might be thrown out. -// -// The convention for the listed revisions: "lxl" means lexical -// lifetimes (which can be easier to reason about). "nll" means -// non-lexical lifetimes. "nll_target" means the initial conservative -// two-phase borrows that only applies to autoref-introduced borrows. -// "nll_beyond" means the generalization of two-phase borrows to all -// `&mut`-borrows (doing so makes it easier to write code for specific -// corner cases). -// -// FIXME: in "nll_target", we currently see the same error reported -// twice. This is injected by `-Z two-phase-borrows`; not sure why as -// of yet. fn main() { let mut vec = vec![0, 1]; @@ -46,10 +30,8 @@ fn main() { // with the shared borrow. But in the current implementation, // its an error. delay = &mut vec; - //[lxl_beyond]~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable - //[nll_beyond]~^^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable - //[nll_target]~^^^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable - //[nll_target]~| ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable + //[lxl]~^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable + //[nll]~^^ ERROR cannot borrow `vec` as mutable because it is also borrowed as immutable shared[0]; } diff --git a/src/test/compile-fail/const-eval-overflow-4b.rs b/src/test/compile-fail/const-eval-overflow-4b.rs index 6028df1883967..02072e9a1a1f6 100644 --- a/src/test/compile-fail/const-eval-overflow-4b.rs +++ b/src/test/compile-fail/const-eval-overflow-4b.rs @@ -22,7 +22,7 @@ const A_I8_T : [u32; (i8::MAX as i8 + 1u8) as usize] //~^ ERROR mismatched types //~| expected i8, found u8 - //~| ERROR cannot add `u8` to `i8` + //~| ERROR the trait bound `i8: std::ops::Add` is not satisfied = [0; (i8::MAX as usize) + 1]; diff --git a/src/test/compile-fail/const-typeid-of.rs b/src/test/compile-fail/const-typeid-of.rs deleted file mode 100644 index 401125cef09d8..0000000000000 --- a/src/test/compile-fail/const-typeid-of.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::any::TypeId; - -struct A; - -fn main() { - const A_ID: TypeId = TypeId::of::(); - //~^ ERROR `std::any::TypeId::of` is not yet stable as a const fn -} diff --git a/src/test/compile-fail/dst-bad-assign-3.rs b/src/test/compile-fail/dst-bad-assign-3.rs index 759da7b2bde21..1c3bad5ba5643 100644 --- a/src/test/compile-fail/dst-bad-assign-3.rs +++ b/src/test/compile-fail/dst-bad-assign-3.rs @@ -13,7 +13,7 @@ #![feature(unsized_tuple_coercion)] type Fat = (isize, &'static str, T); -//~^ WARNING bounds are ignored +//~^ WARNING trait bounds are not (yet) enforced #[derive(PartialEq,Eq)] struct Bar; diff --git a/src/test/compile-fail/epoch-raw-pointer-method-2015.rs b/src/test/compile-fail/epoch-raw-pointer-method-2015.rs deleted file mode 100644 index a71db040b50e7..0000000000000 --- a/src/test/compile-fail/epoch-raw-pointer-method-2015.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength -// compile-flags: -Zepoch=2015 -Zunstable-options - -// tests that epochs work with the tyvar warning-turned-error - -#[deny(warnings)] -fn main() { - let x = 0; - let y = &x as *const _; - let _ = y.is_null(); - //~^ error: the type of this value must be known in this context [tyvar_behind_raw_pointer] - //~^^ warning: this was previously accepted -} diff --git a/src/test/compile-fail/epoch-raw-pointer-method-2018.rs b/src/test/compile-fail/epoch-raw-pointer-method-2018.rs deleted file mode 100644 index c4815de2306e9..0000000000000 --- a/src/test/compile-fail/epoch-raw-pointer-method-2018.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength -// compile-flags: -Zepoch=2018 -Zunstable-options - -// tests that epochs work with the tyvar warning-turned-error - -#[deny(warnings)] -fn main() { - let x = 0; - let y = &x as *const _; - let _ = y.is_null(); - //~^ error: the type of this value must be known to call a method on a raw pointer on it [E0908] -} diff --git a/src/test/compile-fail/issue-16048.rs b/src/test/compile-fail/issue-16048.rs index cda83fe54b09a..5012556dedddc 100644 --- a/src/test/compile-fail/issue-16048.rs +++ b/src/test/compile-fail/issue-16048.rs @@ -10,7 +10,6 @@ trait NoLifetime { fn get<'p, T : Test<'p>>(&self) -> T; - //~^ NOTE lifetimes in impl do not match this method in trait } trait Test<'p> { @@ -29,8 +28,8 @@ impl<'a> Test<'a> for Foo<'a> { impl<'a> NoLifetime for Foo<'a> { fn get<'p, T : Test<'a>>(&self) -> T { - //~^ ERROR E0195 - //~| NOTE lifetimes do not match method in trait +//~^ ERROR E0195 +//~| lifetimes do not match trait return *self as T; } } diff --git a/src/test/compile-fail/issue-39388.rs b/src/test/compile-fail/issue-39388.rs index 6da049374086a..15eef429eab97 100644 --- a/src/test/compile-fail/issue-39388.rs +++ b/src/test/compile-fail/issue-39388.rs @@ -11,7 +11,7 @@ #![allow(unused_macros)] macro_rules! assign { - (($($a:tt)*) = ($($b:tt))*) => { //~ ERROR expected one of: `*`, `+`, or `?` + (($($a:tt)*) = ($($b:tt))*) => { //~ ERROR expected `*` or `+` $($a)* = $($b)* } } diff --git a/src/test/compile-fail/issue-42344.rs b/src/test/compile-fail/issue-42344.rs deleted file mode 100644 index 2f11ff402beed..0000000000000 --- a/src/test/compile-fail/issue-42344.rs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -static TAB: [&mut [u8]; 0] = []; - -pub unsafe fn test() { - TAB[0].iter_mut(); //~ ERROR cannot borrow data mutably in a `&` reference [E0389] -} - -pub fn main() {} diff --git a/src/test/compile-fail/issue-44415.rs b/src/test/compile-fail/issue-44415.rs deleted file mode 100644 index 3b7089f497526..0000000000000 --- a/src/test/compile-fail/issue-44415.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(const_fn)] -#![feature(core_intrinsics)] - -use std::intrinsics; - -struct Foo { - bytes: [u8; unsafe { intrinsics::size_of::() }], - //~^ ERROR unsupported cyclic reference between types/traits detected - x: usize, -} - -fn main() {} diff --git a/src/test/compile-fail/issue-46036.rs b/src/test/compile-fail/issue-46036.rs deleted file mode 100644 index b5cdded4d304a..0000000000000 --- a/src/test/compile-fail/issue-46036.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Issue 46036: [NLL] false edges on infinite loops -// Infinite loops should create false edges to the cleanup block. -#![feature(nll)] - -struct Foo { x: &'static u32 } - -fn foo() { - let a = 3; - let foo = Foo { x: &a }; //~ ERROR E0597 - loop { } -} - -fn main() { } diff --git a/src/test/compile-fail/issue-46604.rs b/src/test/compile-fail/issue-46604.rs index dc14eca1e6734..06aa4c343fea3 100644 --- a/src/test/compile-fail/issue-46604.rs +++ b/src/test/compile-fail/issue-46604.rs @@ -17,6 +17,5 @@ fn write>(buffer: T) { } fn main() { write(&buf); - buf[0]=2; //[ast]~ ERROR E0389 - //[mir]~^ ERROR E0594 + buf[0]=2; //[mir]~ ERROR E0594 } diff --git a/src/test/compile-fail/issue-47412.rs b/src/test/compile-fail/issue-47412.rs deleted file mode 100644 index 7481befcb7952..0000000000000 --- a/src/test/compile-fail/issue-47412.rs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[derive(Copy, Clone)] -enum Void {} - -// Tests that we detect unsafe places (specifically, union fields and -// raw pointer dereferences), even when they're matched on while having -// an uninhabited type (equivalent to `std::intrinsics::unreachable()`). - -fn union_field() { - union Union { unit: (), void: Void } - let u = Union { unit: () }; - match u.void {} - //~^ ERROR access to union field requires unsafe function or block -} - -fn raw_ptr_deref() { - let ptr = std::ptr::null::(); - match *ptr {} - //~^ ERROR dereference of raw pointer requires unsafe function or block -} - -fn main() {} diff --git a/src/test/compile-fail/macro-at-most-once-rep-ambig.rs b/src/test/compile-fail/macro-at-most-once-rep-ambig.rs deleted file mode 100644 index a5660f8b41f8d..0000000000000 --- a/src/test/compile-fail/macro-at-most-once-rep-ambig.rs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// The logic for parsing Kleene operators in macros has a special case to disambiguate `?`. -// Specifically, `$(pat)?` is the ZeroOrOne operator whereas `$(pat)?+` or `$(pat)?*` are the -// ZeroOrMore and OneOrMore operators using `?` as a separator. These tests are intended to -// exercise that logic in the macro parser. -// -// Moreover, we also throw in some tests for using a separator with `?`, which is meaningless but -// included for consistency with `+` and `*`. -// -// This test focuses on error cases. - -#![feature(macro_at_most_once_rep)] - -macro_rules! foo { - ($(a)?) => {} -} - -macro_rules! baz { - ($(a),?) => {} // comma separator is meaningless for `?` -} - -macro_rules! barplus { - ($(a)?+) => {} -} - -macro_rules! barstar { - ($(a)?*) => {} -} - -pub fn main() { - foo!(a?a?a); //~ ERROR no rules expected the token `?` - foo!(a?a); //~ ERROR no rules expected the token `?` - foo!(a?); //~ ERROR no rules expected the token `?` - baz!(a?a?a); //~ ERROR no rules expected the token `?` - baz!(a?a); //~ ERROR no rules expected the token `?` - baz!(a?); //~ ERROR no rules expected the token `?` - baz!(a,); //~ ERROR unexpected end of macro invocation - baz!(a?a?a,); //~ ERROR no rules expected the token `?` - baz!(a?a,); //~ ERROR no rules expected the token `?` - baz!(a?,); //~ ERROR no rules expected the token `?` - barplus!(); //~ ERROR unexpected end of macro invocation - barplus!(a?); //~ ERROR unexpected end of macro invocation - barstar!(a?); //~ ERROR unexpected end of macro invocation -} diff --git a/src/test/compile-fail/nll/do-not-ignore-lifetime-bounds-in-copy.rs b/src/test/compile-fail/nll/do-not-ignore-lifetime-bounds-in-copy.rs deleted file mode 100644 index 2a4295fd90a26..0000000000000 --- a/src/test/compile-fail/nll/do-not-ignore-lifetime-bounds-in-copy.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that the 'static bound from the Copy impl is respected. Regression test for #29149. - -#![feature(nll)] - -#[derive(Clone)] struct Foo<'a>(&'a u32); -impl Copy for Foo<'static> {} - -fn main() { - let s = 2; - let a = Foo(&s); //~ ERROR `s` does not live long enough [E0597] - drop(a); - drop(a); -} diff --git a/src/test/compile-fail/nll/reference-carried-through-struct-field.rs b/src/test/compile-fail/nll/reference-carried-through-struct-field.rs index efa6cc273b6f4..1c1fc4799c3d1 100644 --- a/src/test/compile-fail/nll/reference-carried-through-struct-field.rs +++ b/src/test/compile-fail/nll/reference-carried-through-struct-field.rs @@ -19,7 +19,8 @@ fn foo() { let mut x = 22; let wrapper = Wrap { w: &mut x }; x += 1; //[ast]~ ERROR cannot assign to `x` because it is borrowed [E0506] - //[mir]~^ ERROR cannot use `x` because it was mutably borrowed [E0503] + //[mir]~^ ERROR cannot assign to `x` because it is borrowed [E0506] + //[mir]~^^ ERROR cannot use `x` because it was mutably borrowed [E0503] *wrapper.w += 1; } diff --git a/src/test/compile-fail/private-in-public-warn.rs b/src/test/compile-fail/private-in-public-warn.rs index aa91ce27c379a..dfcf4dc01b8ab 100644 --- a/src/test/compile-fail/private-in-public-warn.rs +++ b/src/test/compile-fail/private-in-public-warn.rs @@ -58,7 +58,7 @@ mod traits { pub trait PubTr {} pub type Alias = T; //~ ERROR private trait `traits::PrivTr` in public interface - //~^ WARN bounds are ignored in type aliases + //~^ WARN trait bounds are not (yet) enforced in type definitions //~| WARNING hard error pub trait Tr1: PrivTr {} //~ ERROR private trait `traits::PrivTr` in public interface //~^ WARNING hard error diff --git a/src/test/ui/borrowck/regions-bound-missing-bound-in-impl.rs b/src/test/compile-fail/regions-bound-missing-bound-in-impl.rs similarity index 100% rename from src/test/ui/borrowck/regions-bound-missing-bound-in-impl.rs rename to src/test/compile-fail/regions-bound-missing-bound-in-impl.rs diff --git a/src/test/compile-fail/rustc-args-required-const.rs b/src/test/compile-fail/rustc-args-required-const.rs deleted file mode 100644 index aac9299eaafb9..0000000000000 --- a/src/test/compile-fail/rustc-args-required-const.rs +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(attr_literals, rustc_attrs, const_fn)] - -#[rustc_args_required_const(0)] -fn foo(_a: i32) { -} - -#[rustc_args_required_const(1)] -fn bar(_a: i32, _b: i32) { -} - -const A: i32 = 3; - -const fn baz() -> i32 { - 3 -} - -fn main() { - foo(2); - foo(2 + 3); - foo(baz()); - let a = 4; - foo(A); - foo(a); //~ ERROR: argument 1 is required to be a constant - bar(a, 3); - bar(a, a); //~ ERROR: argument 2 is required to be a constant -} diff --git a/src/test/compile-fail/rustc-args-required-const2.rs b/src/test/compile-fail/rustc-args-required-const2.rs deleted file mode 100644 index aa63019307b5b..0000000000000 --- a/src/test/compile-fail/rustc-args-required-const2.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(attr_literals, rustc_attrs, const_fn)] - -#[rustc_args_required_const(0)] -fn foo(_a: i32) { -} - -fn main() { - let a = foo; //~ ERROR: this function can only be invoked directly - a(2); -} diff --git a/src/test/compile-fail/ufcs-qpath-self-mismatch.rs b/src/test/compile-fail/ufcs-qpath-self-mismatch.rs index caf510071bd68..94a98b1582af1 100644 --- a/src/test/compile-fail/ufcs-qpath-self-mismatch.rs +++ b/src/test/compile-fail/ufcs-qpath-self-mismatch.rs @@ -12,7 +12,7 @@ use std::ops::Add; fn main() { >::add(1, 2); - //~^ ERROR cannot add `u32` to `i32` + //~^ ERROR `i32: std::ops::Add` is not satisfied >::add(1u32, 2); //~^ ERROR mismatched types >::add(1, 2u32); diff --git a/src/test/incremental/hashes/loop_expressions.rs b/src/test/incremental/hashes/loop_expressions.rs index 8599f8d7f9a00..dcb937fd867ab 100644 --- a/src/test/incremental/hashes/loop_expressions.rs +++ b/src/test/incremental/hashes/loop_expressions.rs @@ -179,7 +179,7 @@ pub fn change_continue_label() { } #[cfg(not(cfail1))] -#[rustc_clean(cfg="cfail2", except="HirBody, MirValidated, TypeckTables")] +#[rustc_clean(cfg="cfail2", except="HirBody, TypeckTables")] #[rustc_clean(cfg="cfail3")] pub fn change_continue_label() { let mut _x = 0; diff --git a/src/test/mir-opt/end_region_2.rs b/src/test/mir-opt/end_region_2.rs index d6084d5a6da92..56c3e2a38a0ed 100644 --- a/src/test/mir-opt/end_region_2.rs +++ b/src/test/mir-opt/end_region_2.rs @@ -40,21 +40,15 @@ fn main() { // goto -> bb1; // } // bb1: { -// falseUnwind -> [real: bb2, cleanup: bb3]; -// } -// bb2: { // StorageLive(_2); // _2 = const true; // StorageLive(_3); // _3 = &'23_1rs _2; // StorageLive(_5); // _5 = _2; -// switchInt(move _5) -> [0u8: bb5, otherwise: bb4]; -// } -// bb3: { -// ... +// switchInt(move _5) -> [0u8: bb3, otherwise: bb2]; // } -// bb4: { +// bb2: { // _0 = (); // StorageDead(_5); // EndRegion('23_1rs); @@ -62,7 +56,7 @@ fn main() { // StorageDead(_2); // return; // } -// bb5: { +// bb3: { // _4 = (); // StorageDead(_5); // StorageLive(_7); diff --git a/src/test/mir-opt/end_region_3.rs b/src/test/mir-opt/end_region_3.rs index 46548f1cce978..8c0d56eba7828 100644 --- a/src/test/mir-opt/end_region_3.rs +++ b/src/test/mir-opt/end_region_3.rs @@ -43,20 +43,14 @@ fn main() { // goto -> bb1; // } // bb1: { -// falseUnwind -> [real: bb2, cleanup: bb3]; -// } -// bb2: { // _1 = const true; // StorageLive(_3); // _3 = &'26_1rs _1; // StorageLive(_5); // _5 = _1; -// switchInt(move _5) -> [0u8: bb5, otherwise: bb4]; -// } -// bb3: { -// ... +// switchInt(move _5) -> [0u8: bb3, otherwise: bb2]; // } -// bb4: { +// bb2: { // _0 = (); // StorageDead(_5); // EndRegion('26_1rs); @@ -64,7 +58,7 @@ fn main() { // StorageDead(_1); // return; // } -// bb5: { +// bb3: { // _4 = (); // StorageDead(_5); // StorageLive(_7); diff --git a/src/test/mir-opt/end_region_9.rs b/src/test/mir-opt/end_region_9.rs index 0f1d714cc6fd2..b313e296ac99c 100644 --- a/src/test/mir-opt/end_region_9.rs +++ b/src/test/mir-opt/end_region_9.rs @@ -57,24 +57,16 @@ fn main() { // _1 = const false; // StorageLive(_2); // _2 = const 3i32; -// falseUnwind -> [real: bb2, cleanup: bb1]; -// } -// bb1: { -// ... -// } -// bb2: { // StorageLive(_4); -// goto -> bb3; -// } -// bb3: { -// falseUnwind -> [real: bb4, cleanup: bb1]; +// goto -> bb1; // } -// bb4: { +// +// bb1: { // StorageLive(_7); // _7 = _1; -// switchInt(move _7) -> [0u8: bb6, otherwise: bb5]; +// switchInt(move _7) -> [0u8: bb3, otherwise: bb2]; // } -// bb5: { +// bb2: { // _0 = (); // StorageDead(_7); // EndRegion('33_0rs); @@ -83,13 +75,13 @@ fn main() { // StorageDead(_1); // return; // } -// bb6: { +// bb3: { // _4 = &'33_0rs _2; // _6 = (); // StorageDead(_7); // _1 = const true; // _3 = (); -// goto -> bb3; +// goto -> bb1; // } // } // END rustc.main.SimplifyCfg-qualify-consts.after.mir diff --git a/src/test/mir-opt/end_region_cyclic.rs b/src/test/mir-opt/end_region_cyclic.rs index 2a82e2675b67d..37a6229febabb 100644 --- a/src/test/mir-opt/end_region_cyclic.rs +++ b/src/test/mir-opt/end_region_cyclic.rs @@ -67,19 +67,16 @@ fn query() -> bool { true } // goto -> bb1; // } // bb1: { -// falseUnwind -> [real: bb2, cleanup: bb3]; -// } -// bb2: { // StorageLive(_2); // StorageLive(_3); // StorageLive(_4); // _4 = std::option::Option<&'35_0rs S<'35_0rs>>::None; -// _3 = const >::new(move _4) -> [return: bb4, unwind: bb3]; +// _3 = const >::new(move _4) -> [return: bb3, unwind: bb2]; // } -// bb3: { +// bb2: { // resume; // } -// bb4: { +// bb3: { // StorageDead(_4); // _2 = S<'35_0rs> { r: move _3 }; // StorageDead(_3); @@ -92,27 +89,27 @@ fn query() -> bool { true } // _8 = &'35_0rs (*_9); // _7 = std::option::Option<&'35_0rs S<'35_0rs>>::Some(move _8,); // StorageDead(_8); -// _5 = const >::set(move _6, move _7) -> [return: bb5, unwind: bb3]; +// _5 = const >::set(move _6, move _7) -> [return: bb4, unwind: bb2]; // } -// bb5: { +// bb4: { // EndRegion('16s); // StorageDead(_7); // StorageDead(_6); // StorageDead(_9); // StorageLive(_11); -// _11 = const query() -> [return: bb6, unwind: bb3]; +// _11 = const query() -> [return: bb5, unwind: bb2]; // } -// bb6: { -// switchInt(move _11) -> [0u8: bb8, otherwise: bb7]; +// bb5: { +// switchInt(move _11) -> [0u8: bb7, otherwise: bb6]; // } -// bb7: { +// bb6: { // _0 = (); // StorageDead(_11); // EndRegion('35_0rs); // StorageDead(_2); // return; // } -// bb8: { +// bb7: { // _10 = (); // StorageDead(_11); // StorageLive(_14); @@ -124,9 +121,9 @@ fn query() -> bool { true } // _16 = &'35_0rs (*_17); // _15 = std::option::Option<&'35_0rs S<'35_0rs>>::Some(move _16,); // StorageDead(_16); -// _13 = const >::set(move _14, move _15) -> [return: bb9, unwind: bb3]; +// _13 = const >::set(move _14, move _15) -> [return: bb8, unwind: bb2]; // } -// bb9: { +// bb8: { // EndRegion('33s); // StorageDead(_15); // StorageDead(_14); diff --git a/src/test/mir-opt/issue-38669.rs b/src/test/mir-opt/issue-38669.rs index 3151c0643079c..b5c188cf834a9 100644 --- a/src/test/mir-opt/issue-38669.rs +++ b/src/test/mir-opt/issue-38669.rs @@ -25,30 +25,27 @@ fn main() { // bb0: { // StorageLive(_1); // _1 = const false; -// goto -> bb2; +// goto -> bb1; // } +// // bb1: { -// resume; -// } -// bb2: { -// falseUnwind -> [real: bb3, cleanup: bb1]; -// } -// bb3: { // StorageLive(_4); // _4 = _1; -// switchInt(move _4) -> [0u8: bb5, otherwise: bb4]; +// switchInt(move _4) -> [0u8: bb3, otherwise: bb2]; // } -// bb4: { +// +// bb2: { // _0 = (); // StorageDead(_4); // StorageDead(_1); // return; // } -// bb5: { +// +// bb3: { // _3 = (); // StorageDead(_4); // _1 = const true; // _2 = (); -// goto -> bb2; +// goto -> bb1; // } // END rustc.main.SimplifyCfg-initial.after.mir diff --git a/src/test/mir-opt/loop_test.rs b/src/test/mir-opt/loop_test.rs deleted file mode 100644 index d36d890809497..0000000000000 --- a/src/test/mir-opt/loop_test.rs +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z identify_regions -Z emit-end-regions - -// Tests to make sure we correctly generate falseUnwind edges in loops - -fn main() { - // Exit early at runtime. Since only care about the generated MIR - // and not the runtime behavior (which is exercised by other tests) - // we just bail early. Without this the test just loops infinitely. - if true { - return; - } - loop { - let x = 1; - continue; - } -} - -// END RUST SOURCE -// START rustc.main.SimplifyCfg-qualify-consts.after.mir -// ... -// bb1: { // The cleanup block -// resume; -// } -// ... -// bb3: { // Entry into the loop -// _1 = (); -// goto -> bb4; -// } -// bb4: { // The loop_block -// falseUnwind -> [real: bb5, cleanup: bb1]; -// } -// bb5: { // The loop body (body_block) -// StorageLive(_5); -// _5 = const 1i32; -// StorageDead(_5); -// goto -> bb4; -// } -// ... -// END rustc.main.SimplifyCfg-qualify-consts.after.mir diff --git a/src/test/mir-opt/match_false_edges.rs b/src/test/mir-opt/match_false_edges.rs index ba1b54d59f69a..1f892b0f9587a 100644 --- a/src/test/mir-opt/match_false_edges.rs +++ b/src/test/mir-opt/match_false_edges.rs @@ -53,18 +53,17 @@ fn main() { // bb0: { // ... // _2 = std::option::Option::Some(const 42i32,); -// _3 = discriminant(_2); -// _6 = discriminant(_2); -// switchInt(move _6) -> [0isize: bb6, 1isize: bb4, otherwise: bb8]; +// _5 = discriminant(_2); +// switchInt(move _5) -> [0isize: bb6, 1isize: bb4, otherwise: bb8]; // } // bb1: { // resume; // } // bb2: { // arm1 -// StorageLive(_8); -// _8 = _4; -// _1 = (const 1i32, move _8); -// StorageDead(_8); +// StorageLive(_7); +// _7 = _3; +// _1 = (const 1i32, move _7); +// StorageDead(_7); // goto -> bb13; // } // bb3: { // binding3(empty) and arm3 @@ -87,24 +86,24 @@ fn main() { // unreachable; // } // bb9: { // binding1 and guard -// StorageLive(_4); -// _4 = ((_2 as Some).0: i32); -// StorageLive(_7); -// _7 = const guard() -> [return: bb10, unwind: bb1]; +// StorageLive(_3); +// _3 = ((_2 as Some).0: i32); +// StorageLive(_6); +// _6 = const guard() -> [return: bb10, unwind: bb1]; // } // bb10: { // end of guard -// switchInt(move _7) -> [0u8: bb11, otherwise: bb2]; +// switchInt(move _6) -> [0u8: bb11, otherwise: bb2]; // } // bb11: { // to pre_binding2 // falseEdges -> [real: bb5, imaginary: bb5]; // } // bb12: { // bindingNoLandingPads.before.mir2 and arm2 -// StorageLive(_5); -// _5 = ((_2 as Some).0: i32); -// StorageLive(_9); -// _9 = _5; -// _1 = (const 2i32, move _9); -// StorageDead(_9); +// StorageLive(_4); +// _4 = ((_2 as Some).0: i32); +// StorageLive(_8); +// _8 = _4; +// _1 = (const 2i32, move _8); +// StorageDead(_8); // goto -> bb13; // } // bb13: { @@ -117,18 +116,17 @@ fn main() { // bb0: { // ... // _2 = std::option::Option::Some(const 42i32,); -// _3 = discriminant(_2); -// _6 = discriminant(_2); -// switchInt(move _6) -> [0isize: bb5, 1isize: bb4, otherwise: bb8]; +// _5 = discriminant(_2); +// switchInt(move _5) -> [0isize: bb5, 1isize: bb4, otherwise: bb8]; // } // bb1: { // resume; // } // bb2: { // arm1 -// StorageLive(_8); -// _8 = _4; -// _1 = (const 1i32, move _8); -// StorageDead(_8); +// StorageLive(_7); +// _7 = _3; +// _1 = (const 1i32, move _7); +// StorageDead(_7); // goto -> bb13; // } // bb3: { // binding3(empty) and arm3 @@ -151,24 +149,24 @@ fn main() { // unreachable; // } // bb9: { // binding1 and guard -// StorageLive(_4); -// _4 = ((_2 as Some).0: i32); -// StorageLive(_7); -// _7 = const guard() -> [return: bb10, unwind: bb1]; +// StorageLive(_3); +// _3 = ((_2 as Some).0: i32); +// StorageLive(_6); +// _6 = const guard() -> [return: bb10, unwind: bb1]; // } // bb10: { // end of guard -// switchInt(move _7) -> [0u8: bb11, otherwise: bb2]; +// switchInt(move _6) -> [0u8: bb11, otherwise: bb2]; // } // bb11: { // to pre_binding2 // falseEdges -> [real: bb6, imaginary: bb5]; // } // bb12: { // binding2 and arm2 -// StorageLive(_5); -// _5 = ((_2 as Some).0: i32); -// StorageLive(_9); -// _9 = _5; -// _1 = (const 2i32, move _9); -// StorageDead(_9); +// StorageLive(_4); +// _4 = ((_2 as Some).0: i32); +// StorageLive(_8); +// _8 = _4; +// _1 = (const 2i32, move _8); +// StorageDead(_8); // goto -> bb13; // } // bb13: { @@ -181,9 +179,8 @@ fn main() { // bb0: { // ... // _2 = std::option::Option::Some(const 1i32,); -// _3 = discriminant(_2); -// _8 = discriminant(_2); -// switchInt(move _8) -> [1isize: bb4, otherwise: bb5]; +// _7 = discriminant(_2); +// switchInt(move _7) -> [1isize: bb4, otherwise: bb5]; // } // bb1: { // resume; @@ -213,41 +210,41 @@ fn main() { // unreachable; // } // bb9: { // binding1: Some(w) if guard() -// StorageLive(_4); -// _4 = ((_2 as Some).0: i32); -// StorageLive(_9); -// _9 = const guard() -> [return: bb10, unwind: bb1]; +// StorageLive(_3); +// _3 = ((_2 as Some).0: i32); +// StorageLive(_8); +// _8 = const guard() -> [return: bb10, unwind: bb1]; // } // bb10: { //end of guard -// switchInt(move _9) -> [0u8: bb11, otherwise: bb2]; +// switchInt(move _8) -> [0u8: bb11, otherwise: bb2]; // } // bb11: { // to pre_binding2 // falseEdges -> [real: bb5, imaginary: bb5]; // } // bb12: { // binding2 & arm2 -// StorageLive(_5); -// _5 = _2; +// StorageLive(_4); +// _4 = _2; // _1 = const 2i32; // goto -> bb17; // } // bb13: { // binding3: Some(y) if guard2(y) -// StorageLive(_6); -// _6 = ((_2 as Some).0: i32); +// StorageLive(_5); +// _5 = ((_2 as Some).0: i32); +// StorageLive(_10); // StorageLive(_11); -// StorageLive(_12); -// _12 = _6; -// _11 = const guard2(move _12) -> [return: bb14, unwind: bb1]; +// _11 = _5; +// _10 = const guard2(move _11) -> [return: bb14, unwind: bb1]; // } // bb14: { // end of guard2 -// StorageDead(_12); -// switchInt(move _11) -> [0u8: bb15, otherwise: bb3]; +// StorageDead(_11); +// switchInt(move _10) -> [0u8: bb15, otherwise: bb3]; // } // bb15: { // to pre_binding4 // falseEdges -> [real: bb7, imaginary: bb7]; // } // bb16: { // binding4 & arm4 -// StorageLive(_7); -// _7 = _2; +// StorageLive(_6); +// _6 = _2; // _1 = const 4i32; // goto -> bb17; // } diff --git a/src/test/mir-opt/nll/liveness-drop-intra-block.rs b/src/test/mir-opt/nll/liveness-drop-intra-block.rs index 64ffc7446062c..b060222a95f17 100644 --- a/src/test/mir-opt/nll/liveness-drop-intra-block.rs +++ b/src/test/mir-opt/nll/liveness-drop-intra-block.rs @@ -25,17 +25,17 @@ fn main() { // END RUST SOURCE // START rustc.main.nll.0.mir -// | Live variables on entry to bb3: [] -// bb3: { -// | Live variables on entry to bb3[0]: [] +// | Live variables on entry to bb2: [] +// bb2: { +// | Live variables on entry to bb2[0]: [] // _1 = const 55usize; -// | Live variables on entry to bb3[1]: [_1] +// | Live variables on entry to bb2[1]: [_1] // StorageLive(_3); -// | Live variables on entry to bb3[2]: [_1] +// | Live variables on entry to bb2[2]: [_1] // StorageLive(_4); -// | Live variables on entry to bb3[3]: [_1] +// | Live variables on entry to bb2[3]: [_1] // _4 = _1; -// | Live variables on entry to bb3[4]: [_4] -// _3 = const use_x(move _4) -> [return: bb4, unwind: bb1]; +// | Live variables on entry to bb2[4]: [_4] +// _3 = const use_x(move _4) -> [return: bb3, unwind: bb1]; // } // END rustc.main.nll.0.mir diff --git a/src/test/mir-opt/validate_5.rs b/src/test/mir-opt/validate_5.rs index d8d83fb5b4537..c9408c1f2f88b 100644 --- a/src/test/mir-opt/validate_5.rs +++ b/src/test/mir-opt/validate_5.rs @@ -52,15 +52,12 @@ fn main() { // Validate(Acquire, [_1: &ReFree(DefId(0/1:9 ~ validate_5[317d]::main[0]::{{closure}}[0]), BrEnv) [closure@NodeId(46)], _2: &ReFree(DefId(0/1:9 ~ validate_5[317d]::main[0]::{{closure}}[0]), BrAnon(0)) mut i32]); // StorageLive(_3); // StorageLive(_4); -// StorageLive(_5); // Validate(Suspend(ReScope(Node(ItemLocalId(9)))), [(*_2): i32]); -// _5 = &ReErased mut (*_2); -// Validate(Acquire, [(*_5): i32/ReScope(Node(ItemLocalId(9)))]); -// _4 = move _5 as *mut i32 (Misc); -// _3 = move _4; +// _4 = &ReErased mut (*_2); +// Validate(Acquire, [(*_4): i32/ReScope(Node(ItemLocalId(9)))]); +// _3 = move _4 as *mut i32 (Misc); // EndRegion(ReScope(Node(ItemLocalId(9)))); // StorageDead(_4); -// StorageDead(_5); // Validate(Release, [_0: bool, _3: *mut i32]); // _0 = const write_42(move _3) -> bb1; // } diff --git a/src/test/parse-fail/bad-char-literals.rs b/src/test/parse-fail/bad-char-literals.rs index 821015ece7712..96311d6de176c 100644 --- a/src/test/parse-fail/bad-char-literals.rs +++ b/src/test/parse-fail/bad-char-literals.rs @@ -15,7 +15,7 @@ fn main() { // these literals are just silly. '''; - //~^ ERROR: character constant must be escaped: ' + //~^ ERROR: character constant must be escaped: \' // note that this is a literal "\n" byte ' diff --git a/src/test/parse-fail/issue-33569.rs b/src/test/parse-fail/issue-33569.rs index af90d0a83c926..15d491719a6d5 100644 --- a/src/test/parse-fail/issue-33569.rs +++ b/src/test/parse-fail/issue-33569.rs @@ -13,7 +13,7 @@ macro_rules! foo { { $+ } => { //~ ERROR expected identifier, found `+` //~^ ERROR missing fragment specifier - $(x)(y) //~ ERROR expected one of: `*`, `+`, or `?` + $(x)(y) //~ ERROR expected `*` or `+` } } diff --git a/src/test/parse-fail/lex-stray-backslash.rs b/src/test/parse-fail/lex-stray-backslash.rs deleted file mode 100644 index b6042bbdc1a26..0000000000000 --- a/src/test/parse-fail/lex-stray-backslash.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z parse-only - -\ //~ ERROR: unknown start of token: \ diff --git a/src/test/run-make/output-filename-conflicts-with-directory/Makefile b/src/test/run-make/output-filename-conflicts-with-directory/Makefile deleted file mode 100644 index 74e5dcfcf36c2..0000000000000 --- a/src/test/run-make/output-filename-conflicts-with-directory/Makefile +++ /dev/null @@ -1,7 +0,0 @@ --include ../tools.mk - -all: - cp foo.rs $(TMPDIR)/foo.rs - mkdir $(TMPDIR)/foo - $(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo 2>&1 \ - | $(CGREP) -e "the generated executable for the input file \".*foo\.rs\" conflicts with the existing directory \".*foo\"" diff --git a/src/test/run-make/output-filename-conflicts-with-directory/foo.rs b/src/test/run-make/output-filename-conflicts-with-directory/foo.rs deleted file mode 100644 index 3f07b46791d22..0000000000000 --- a/src/test/run-make/output-filename-conflicts-with-directory/foo.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() {} diff --git a/src/test/run-make/output-filename-overwrites-input/Makefile b/src/test/run-make/output-filename-overwrites-input/Makefile index 6377038b7be74..0554627d67753 100644 --- a/src/test/run-make/output-filename-overwrites-input/Makefile +++ b/src/test/run-make/output-filename-overwrites-input/Makefile @@ -2,11 +2,8 @@ all: cp foo.rs $(TMPDIR)/foo - $(RUSTC) $(TMPDIR)/foo -o $(TMPDIR)/foo 2>&1 \ + $(RUSTC) $(TMPDIR)/foo 2>&1 \ | $(CGREP) -e "the input file \".*foo\" would be overwritten by the generated executable" - cp bar.rs $(TMPDIR)/bar.rlib - $(RUSTC) $(TMPDIR)/bar.rlib -o $(TMPDIR)/bar.rlib 2>&1 \ - | $(CGREP) -e "the input file \".*bar.rlib\" would be overwritten by the generated executable" $(RUSTC) foo.rs 2>&1 && $(RUSTC) -Z ls $(TMPDIR)/foo 2>&1 cp foo.rs $(TMPDIR)/foo.rs $(RUSTC) $(TMPDIR)/foo.rs -o $(TMPDIR)/foo.rs 2>&1 \ diff --git a/src/test/run-make/output-filename-overwrites-input/bar.rs b/src/test/run-make/output-filename-overwrites-input/bar.rs deleted file mode 100644 index 8e4e35fdee66e..0000000000000 --- a/src/test/run-make/output-filename-overwrites-input/bar.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "lib"] diff --git a/src/test/run-make/output-filename-overwrites-input/foo.rs b/src/test/run-make/output-filename-overwrites-input/foo.rs index 3f07b46791d22..046d27a9f0fe5 100644 --- a/src/test/run-make/output-filename-overwrites-input/foo.rs +++ b/src/test/run-make/output-filename-overwrites-input/foo.rs @@ -1,4 +1,4 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // diff --git a/src/test/run-make/save-analysis-fail/foo.rs b/src/test/run-make/save-analysis-fail/foo.rs index 07322d8bbc325..8a1b579398946 100644 --- a/src/test/run-make/save-analysis-fail/foo.rs +++ b/src/test/run-make/save-analysis-fail/foo.rs @@ -451,11 +451,3 @@ extern { static EXTERN_FOO: u8; fn extern_foo(a: u8, b: i32) -> String; } - -struct Rls699 { - f: u32, -} - -fn new(f: u32) -> Rls699 { - Rls699 { fs } -} diff --git a/src/test/run-make/save-analysis/extra-docs.md b/src/test/run-make/save-analysis/extra-docs.md deleted file mode 100644 index 0605ca517ff3b..0000000000000 --- a/src/test/run-make/save-analysis/extra-docs.md +++ /dev/null @@ -1 +0,0 @@ -Extra docs for this struct. diff --git a/src/test/run-make/save-analysis/foo.rs b/src/test/run-make/save-analysis/foo.rs index 5b4e4802957af..834a7554a555d 100644 --- a/src/test/run-make/save-analysis/foo.rs +++ b/src/test/run-make/save-analysis/foo.rs @@ -12,7 +12,6 @@ #![feature(box_syntax)] #![feature(rustc_private)] #![feature(associated_type_defaults)] -#![feature(external_doc)] extern crate graphviz; // A simple rust project @@ -462,6 +461,3 @@ impl Iterator for SilenceGenerator { trait Foo { type Bar = FrameBuffer; } - -#[doc(include="extra-docs.md")] -struct StructWithDocs; diff --git a/src/test/run-make/stdin-non-utf8/Makefile b/src/test/run-make/stdin-non-utf8/Makefile deleted file mode 100644 index 7948c442616e3..0000000000000 --- a/src/test/run-make/stdin-non-utf8/Makefile +++ /dev/null @@ -1,6 +0,0 @@ --include ../tools.mk - -all: - cp non-utf8 $(TMPDIR)/non-utf.rs - cat $(TMPDIR)/non-utf.rs | $(RUSTC) - 2>&1 \ - | $(CGREP) "error: couldn't read from stdin, as it did not contain valid UTF-8" diff --git a/src/test/run-make/stdin-non-utf8/non-utf8 b/src/test/run-make/stdin-non-utf8/non-utf8 deleted file mode 100644 index bc87051a85299..0000000000000 --- a/src/test/run-make/stdin-non-utf8/non-utf8 +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs b/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs index 9ebc438ad5a00..b5d6ff595afd5 100644 --- a/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs +++ b/src/test/run-pass-fulldeps/auxiliary/procedural_mbe_matching.rs @@ -18,7 +18,6 @@ extern crate syntax_pos; extern crate rustc; extern crate rustc_plugin; -use syntax::feature_gate::Features; use syntax::parse::token::{NtExpr, NtPat}; use syntax::ast::{Ident, Pat}; use syntax::tokenstream::{TokenTree}; @@ -32,17 +31,11 @@ use syntax::ptr::P; use syntax_pos::Span; use rustc_plugin::Registry; -use std::cell::RefCell; - fn expand_mbe_matches(cx: &mut ExtCtxt, _: Span, args: &[TokenTree]) -> Box { let mbe_matcher = quote_tokens!(cx, $$matched:expr, $$($$pat:pat)|+); - let mbe_matcher = quoted::parse(mbe_matcher.into_iter().collect(), - true, - cx.parse_sess, - &RefCell::new(Features::new()), - &[]); + let mbe_matcher = quoted::parse(mbe_matcher.into_iter().collect(), true, cx.parse_sess); let map = match TokenTree::parse(cx, &mbe_matcher, args.iter().cloned().collect()) { Success(map) => map, Failure(_, tok) => { diff --git a/src/test/run-pass/backtrace-debuginfo.rs b/src/test/run-pass/backtrace-debuginfo.rs index 2b82a8943636e..e8b5f3490e50e 100644 --- a/src/test/run-pass/backtrace-debuginfo.rs +++ b/src/test/run-pass/backtrace-debuginfo.rs @@ -15,14 +15,11 @@ // Unfortunately, LLVM has no "disable" option for this, so we have to set // "enable" to 0 instead. -// compile-flags:-g -Cllvm-args=-enable-tail-merge=0 -Cllvm-args=-opt-bisect-limit=0 +// compile-flags:-g -Cllvm-args=-enable-tail-merge=0 // ignore-pretty issue #37195 // ignore-cloudabi spawning processes is not supported // ignore-emscripten spawning processes is not supported -// note that above `-opt-bisect-limit=0` is used to basically disable -// optimizations - use std::env; #[path = "backtrace-debuginfo-aux.rs"] mod aux; @@ -117,26 +114,18 @@ fn outer(mut counter: i32, main_pos: Pos) { inner_inlined(&mut counter, main_pos, pos!()); } -fn check_trace(output: &str, error: &str) -> Result<(), String> { +fn check_trace(output: &str, error: &str) { // reverse the position list so we can start with the last item (which was the first line) let mut remaining: Vec<&str> = output.lines().map(|s| s.trim()).rev().collect(); - if !error.contains("stack backtrace") { - return Err(format!("no backtrace found in stderr:\n{}", error)) - } + assert!(error.contains("stack backtrace"), "no backtrace in the error: {}", error); for line in error.lines() { if !remaining.is_empty() && line.contains(remaining.last().unwrap()) { remaining.pop(); } } - if !remaining.is_empty() { - return Err(format!("trace does not match position list\n\ - still need to find {:?}\n\n\ - --- stdout\n{}\n\ - --- stderr\n{}", - remaining, output, error)) - } - Ok(()) + assert!(remaining.is_empty(), + "trace does not match position list: {}\n---\n{}", error, output); } fn run_test(me: &str) { @@ -144,7 +133,6 @@ fn run_test(me: &str) { use std::process::Command; let mut i = 0; - let mut errors = Vec::new(); loop { let out = Command::new(me) .env("RUST_BACKTRACE", "full") @@ -155,20 +143,10 @@ fn run_test(me: &str) { assert!(output.contains("done."), "bad output for successful run: {}", output); break; } else { - if let Err(e) = check_trace(output, error) { - errors.push(e); - } + check_trace(output, error); } i += 1; } - if errors.len() > 0 { - for error in errors { - println!("---------------------------------------"); - println!("{}", error); - } - - panic!("found some errors"); - } } #[inline(never)] diff --git a/src/test/run-pass/const-typeid-of.rs b/src/test/run-pass/const-typeid-of.rs deleted file mode 100644 index ce29e55c6d720..0000000000000 --- a/src/test/run-pass/const-typeid-of.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(core_intrinsics)] -#![feature(const_type_id)] - -use std::any::TypeId; - -struct A; - -static ID_ISIZE: TypeId = TypeId::of::(); - -pub fn main() { - assert_eq!(ID_ISIZE, TypeId::of::()); - - // sanity test of TypeId - const T: (TypeId, TypeId, TypeId) = (TypeId::of::(), - TypeId::of::<&'static str>(), - TypeId::of::()); - let (d, e, f) = (TypeId::of::(), TypeId::of::<&'static str>(), - TypeId::of::()); - - assert!(T.0 != T.1); - assert!(T.0 != T.2); - assert!(T.1 != T.2); - - assert_eq!(T.0, d); - assert_eq!(T.1, e); - assert_eq!(T.2, f); - - // Check fn pointer against collisions - const F: (TypeId, TypeId) = (TypeId::of:: A) -> A>(), - TypeId::of:: A, A) -> A>()); - - assert!(F.0 != F.1); -} diff --git a/src/test/run-pass/env-home-dir.rs b/src/test/run-pass/env-home-dir.rs index 9bbff1eeb81f3..22e440c6ffa51 100644 --- a/src/test/run-pass/env-home-dir.rs +++ b/src/test/run-pass/env-home-dir.rs @@ -27,10 +27,7 @@ fn main() { if cfg!(target_os = "android") { assert!(home_dir().is_none()); } else { - // When HOME is not set, some platforms return `None`, - // but others return `Some` with a default. - // Just check that it is not "/home/MountainView". - assert_ne!(home_dir(), Some(PathBuf::from("/home/MountainView"))); + assert!(home_dir().is_some()); } } diff --git a/src/test/run-pass/generator/too-live-local-in-immovable-gen.rs b/src/test/run-pass/generator/too-live-local-in-immovable-gen.rs deleted file mode 100644 index 2314533a68153..0000000000000 --- a/src/test/run-pass/generator/too-live-local-in-immovable-gen.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(generators)] - -fn main() { - unsafe { - static move || { - // Tests that the generator transformation finds out that `a` is not live - // during the yield expression. Type checking will also compute liveness - // and it should also find out that `a` is not live. - // The compiler will panic if the generator transformation finds that - // `a` is live and type checking finds it dead. - let a = { - yield (); - 4i32 - }; - &a; - }; - } -} diff --git a/src/test/run-pass/issue-47139-1.rs b/src/test/run-pass/issue-47139-1.rs deleted file mode 100644 index cb87991a491db..0000000000000 --- a/src/test/run-pass/issue-47139-1.rs +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Regression test for issue #47139: -// -// Coherence was encountering an (unnecessary) overflow trying to -// decide if the two impls of dummy overlap. -// -// The overflow went something like: -// -// - `&'a ?T: Insertable` ? -// - let ?T = Option ? -// - `Option: Insertable` ? -// - `Option<&'a ?U>: Insertable` ? -// - `&'a ?U: Insertable` ? -// -// While somewhere in the middle, a projection would occur, which -// broke cycle detection. -// -// It turned out that this cycle was being kicked off due to some -// extended diagnostic attempts in coherence, so removing those -// sidestepped the issue for now. - -#![allow(dead_code)] - -pub trait Insertable { - type Values; - - fn values(self) -> Self::Values; -} - -impl Insertable for Option - where - T: Insertable, - T::Values: Default, -{ - type Values = T::Values; - - fn values(self) -> Self::Values { - self.map(Insertable::values).unwrap_or_default() - } -} - -impl<'a, T> Insertable for &'a Option - where - Option<&'a T>: Insertable, -{ - type Values = as Insertable>::Values; - - fn values(self) -> Self::Values { - self.as_ref().values() - } -} - -impl<'a, T> Insertable for &'a [T] -{ - type Values = Self; - - fn values(self) -> Self::Values { - self - } -} - -trait Unimplemented { } - -trait Dummy { } - -struct Foo { t: T } - -impl<'a, U> Dummy for Foo<&'a U> - where &'a U: Insertable -{ -} - -impl Dummy for T - where T: Unimplemented -{ } - -fn main() { -} diff --git a/src/test/run-pass/issue-47139-2.rs b/src/test/run-pass/issue-47139-2.rs deleted file mode 100644 index 08eaee5acd730..0000000000000 --- a/src/test/run-pass/issue-47139-2.rs +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Regression test for issue #47139: -// -// Same as issue-47139-1.rs, but the impls of dummy are in the -// opposite order. This influenced the way that coherence ran and in -// some cases caused the overflow to occur when it wouldn't otherwise. -// In an effort to make the regr test more robust, I am including both -// orderings. - -#![allow(dead_code)] - -pub trait Insertable { - type Values; - - fn values(self) -> Self::Values; -} - -impl Insertable for Option - where - T: Insertable, - T::Values: Default, -{ - type Values = T::Values; - - fn values(self) -> Self::Values { - self.map(Insertable::values).unwrap_or_default() - } -} - -impl<'a, T> Insertable for &'a Option - where - Option<&'a T>: Insertable, -{ - type Values = as Insertable>::Values; - - fn values(self) -> Self::Values { - self.as_ref().values() - } -} - -impl<'a, T> Insertable for &'a [T] -{ - type Values = Self; - - fn values(self) -> Self::Values { - self - } -} - -trait Unimplemented { } - -trait Dummy { } - -struct Foo { t: T } - -impl Dummy for T - where T: Unimplemented -{ } - -impl<'a, U> Dummy for Foo<&'a U> - where &'a U: Insertable -{ -} - -fn main() { -} diff --git a/src/test/run-pass/issue-47638.rs b/src/test/run-pass/issue-47638.rs deleted file mode 100644 index 6f627b2a3c137..0000000000000 --- a/src/test/run-pass/issue-47638.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn id<'c, 'b>(f: &'c &'b Fn(&i32)) -> &'c &'b Fn(&'static i32) { - f -} - -fn main() { - let f: &Fn(&i32) = &|x| {}; - id(&f); -} diff --git a/src/test/run-pass/issue-47673.rs b/src/test/run-pass/issue-47673.rs index 22f7f169e2988..92f54a44f63c9 100644 --- a/src/test/run-pass/issue-47673.rs +++ b/src/test/run-pass/issue-47673.rs @@ -8,6 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(use_nested_groups)] #![allow(unused_import)] use {{}, {}}; diff --git a/src/test/run-pass/issue-47722.rs b/src/test/run-pass/issue-47722.rs deleted file mode 100644 index 3b5d808e1f546..0000000000000 --- a/src/test/run-pass/issue-47722.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// -// Tests that automatic coercions from &mut T to *mut T -// allow borrows of T to expire immediately - essentially, that -// they work identically to 'foo as *mut T' -#![feature(nll)] - -struct SelfReference { - self_reference: *mut SelfReference, -} - -impl SelfReference { - fn set_self_ref(&mut self) { - self.self_reference = self; - } -} - -fn main() {} diff --git a/src/test/run-pass/issue-47789.rs b/src/test/run-pass/issue-47789.rs deleted file mode 100644 index 3148939992caf..0000000000000 --- a/src/test/run-pass/issue-47789.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - - -#![feature(nll)] - -static mut x: &'static u32 = &0; - -fn foo() { - unsafe { x = &1; } -} - -fn main() { } diff --git a/src/test/run-pass/macro-at-most-once-rep.rs b/src/test/run-pass/macro-at-most-once-rep.rs deleted file mode 100644 index b7e942f938321..0000000000000 --- a/src/test/run-pass/macro-at-most-once-rep.rs +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// The logic for parsing Kleene operators in macros has a special case to disambiguate `?`. -// Specifically, `$(pat)?` is the ZeroOrOne operator whereas `$(pat)?+` or `$(pat)?*` are the -// ZeroOrMore and OneOrMore operators using `?` as a separator. These tests are intended to -// exercise that logic in the macro parser. -// -// Moreover, we also throw in some tests for using a separator with `?`, which is meaningless but -// included for consistency with `+` and `*`. -// -// This test focuses on non-error cases and making sure the correct number of repetitions happen. - -#![feature(macro_at_most_once_rep)] - -macro_rules! foo { - ($($a:ident)? ; $num:expr) => { { - let mut x = 0; - - $( - x += $a; - )? - - assert_eq!(x, $num); - } } -} - -macro_rules! baz { - ($($a:ident),? ; $num:expr) => { { // comma separator is meaningless for `?` - let mut x = 0; - - $( - x += $a; - )? - - assert_eq!(x, $num); - } } -} - -macro_rules! barplus { - ($($a:ident)?+ ; $num:expr) => { { - let mut x = 0; - - $( - x += $a; - )+ - - assert_eq!(x, $num); - } } -} - -macro_rules! barstar { - ($($a:ident)?* ; $num:expr) => { { - let mut x = 0; - - $( - x += $a; - )* - - assert_eq!(x, $num); - } } -} - -pub fn main() { - let a = 1; - - // accept 0 or 1 repetitions - foo!( ; 0); - foo!(a ; 1); - baz!( ; 0); - baz!(a ; 1); - - // Make sure using ? as a separator works as before - barplus!(a ; 1); - barplus!(a?a ; 2); - barplus!(a?a?a ; 3); - barstar!( ; 0); - barstar!(a ; 1); - barstar!(a?a ; 2); - barstar!(a?a?a ; 3); -} diff --git a/src/test/run-pass/match-beginning-vert.rs b/src/test/run-pass/match-beginning-vert.rs deleted file mode 100644 index cdacfb2f05729..0000000000000 --- a/src/test/run-pass/match-beginning-vert.rs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -enum Foo { - A, - B, - C, - D, - E, -} -use Foo::*; - -fn main() { - for foo in &[A, B, C, D, E] { - match *foo { - | A => println!("A"), - | B | C if 1 < 2 => println!("BC!"), - | _ => {}, - } - } -} diff --git a/src/test/run-pass/nll/issue-47589.rs b/src/test/run-pass/nll/issue-47589.rs deleted file mode 100644 index 393c18efad0ad..0000000000000 --- a/src/test/run-pass/nll/issue-47589.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(nll)] - -pub struct DescriptorSet<'a> { - pub slots: Vec> -} - -pub trait ResourcesTrait<'r>: Sized { - type DescriptorSet: 'r; -} - -pub struct Resources; - -impl<'a> ResourcesTrait<'a> for Resources { - type DescriptorSet = DescriptorSet<'a>; -} - -pub enum AttachInfo<'a, R: ResourcesTrait<'a>> { - NextDescriptorSet(Box) -} - -fn main() { - let _x = DescriptorSet {slots: Vec::new()}; -} diff --git a/src/test/run-pass/sse2.rs b/src/test/run-pass/sse2.rs index 22469b2fde058..c2414e5ff5d96 100644 --- a/src/test/run-pass/sse2.rs +++ b/src/test/run-pass/sse2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// no-system-llvm -- needs MCSubtargetInfo::getFeatureTable() +// min-llvm-version 4.0 // ignore-cloudabi no std::env #![feature(cfg_target_feature)] diff --git a/src/test/run-pass/stack-probes-lto.rs b/src/test/run-pass/stack-probes-lto.rs index 4deced1297bd1..22555c8d6a779 100644 --- a/src/test/run-pass/stack-probes-lto.rs +++ b/src/test/run-pass/stack-probes-lto.rs @@ -15,7 +15,7 @@ // ignore-emscripten no processes // ignore-musl FIXME #31506 // ignore-pretty -// min-system-llvm-version 5.0 +// no-system-llvm // compile-flags: -C lto // no-prefer-dynamic diff --git a/src/test/run-pass/stack-probes.rs b/src/test/run-pass/stack-probes.rs index 4224a65ffd7c7..248ad7019261d 100644 --- a/src/test/run-pass/stack-probes.rs +++ b/src/test/run-pass/stack-probes.rs @@ -14,7 +14,7 @@ // ignore-cloudabi no processes // ignore-emscripten no processes // ignore-musl FIXME #31506 -// min-system-llvm-version 5.0 +// no-system-llvm use std::mem; use std::process::Command; diff --git a/src/test/run-pass/use-nested-groups.rs b/src/test/run-pass/use-nested-groups.rs index be06e463e3b37..74a82afd462b8 100644 --- a/src/test/run-pass/use-nested-groups.rs +++ b/src/test/run-pass/use-nested-groups.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +#![feature(use_nested_groups)] + mod a { pub enum B {} @@ -22,19 +24,12 @@ mod a { } } -// Test every possible part of the syntax use a::{B, d::{self, *, g::H}}; -// Test a more common use case -use std::sync::{Arc, atomic::{AtomicBool, Ordering}}; - fn main() { let _: B; let _: E; let _: F; let _: H; let _: d::g::I; - - let _: Arc; - let _: Ordering; } diff --git a/src/test/rustdoc/auxiliary/unit-return.rs b/src/test/rustdoc/auxiliary/unit-return.rs deleted file mode 100644 index 1b30a6a43282f..0000000000000 --- a/src/test/rustdoc/auxiliary/unit-return.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -pub fn f2(f: F) {} - -pub fn f3 () + Clone>(f: F) {} diff --git a/src/test/rustdoc/const-evalutation-ice.rs b/src/test/rustdoc/const-evalutation-ice.rs deleted file mode 100644 index 9fed67ee583d2..0000000000000 --- a/src/test/rustdoc/const-evalutation-ice.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Just check if we don't get an ICE for the _S type. - -#![feature(const_size_of)] - -use std::cell::Cell; -use std::mem; - -pub struct S { - s: Cell -} - -pub type _S = [usize; 0 - (mem::size_of::() != 4) as usize]; diff --git a/src/test/rustdoc/issue-47639.rs b/src/test/rustdoc/issue-47639.rs deleted file mode 100644 index 167c3aaec4ab6..0000000000000 --- a/src/test/rustdoc/issue-47639.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// This should not ICE -pub fn test() { - macro_rules! foo { - () => () - } -} diff --git a/src/test/rustdoc/link-title-escape.rs b/src/test/rustdoc/link-title-escape.rs deleted file mode 100644 index eb53c3c2cb52d..0000000000000 --- a/src/test/rustdoc/link-title-escape.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z unstable-options --disable-commonmark - -#![crate_name = "foo"] - -//! hello [foo] -//! -//! [foo]: url 'title & & "things"' - -// @has 'foo/index.html' 'title & <stuff> & "things"' diff --git a/src/test/rustdoc/unit-return.rs b/src/test/rustdoc/unit-return.rs deleted file mode 100644 index 757e8979edd4f..0000000000000 --- a/src/test/rustdoc/unit-return.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:unit-return.rs - -#![crate_name = "foo"] - -extern crate unit_return; - -// @has 'foo/fn.f0.html' '//*[@class="rust fn"]' 'F: FnMut(u8) + Clone' -pub fn f0(f: F) {} - -// @has 'foo/fn.f1.html' '//*[@class="rust fn"]' 'F: FnMut(u16) + Clone' -pub fn f1 () + Clone>(f: F) {} - -// @has 'foo/fn.f2.html' '//*[@class="rust fn"]' 'F: FnMut(u32) + Clone' -pub use unit_return::f2; - -// @has 'foo/fn.f3.html' '//*[@class="rust fn"]' 'F: FnMut(u64) + Clone' -pub use unit_return::f3; diff --git a/src/test/ui/associated-const-impl-wrong-lifetime.stderr b/src/test/ui/associated-const-impl-wrong-lifetime.stderr index ab0e1003a9e10..a7aee9b19f1a1 100644 --- a/src/test/ui/associated-const-impl-wrong-lifetime.stderr +++ b/src/test/ui/associated-const-impl-wrong-lifetime.stderr @@ -9,8 +9,11 @@ error[E0308]: mismatched types note: the lifetime 'a as defined on the impl at 17:1... --> $DIR/associated-const-impl-wrong-lifetime.rs:17:1 | -17 | impl<'a> Foo for &'a () { - | ^^^^^^^^^^^^^^^^^^^^^^^ +17 | / impl<'a> Foo for &'a () { +18 | | const NAME: &'a str = "unit"; +19 | | //~^ ERROR mismatched types [E0308] +20 | | } + | |_^ = note: ...does not necessarily outlive the static lifetime error: aborting due to previous error diff --git a/src/test/ui/blind-item-item-shadow.stderr b/src/test/ui/blind-item-item-shadow.stderr index d3588be266975..855b3799eb5db 100644 --- a/src/test/ui/blind-item-item-shadow.stderr +++ b/src/test/ui/blind-item-item-shadow.stderr @@ -10,8 +10,8 @@ error[E0255]: the name `foo` is defined multiple times = note: `foo` must be defined only once in the type namespace of this module help: You can use `as` to change the binding name of the import | -13 | use foo::foo as other_foo; - | ^^^^^^^^^^^^^^^^^^^^^ +13 | use foo::foo as Otherfoo; + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/borrowck/issue-41962.rs b/src/test/ui/borrowck/issue-41962.rs index f7c33691ad072..d592be11335e0 100644 --- a/src/test/ui/borrowck/issue-41962.rs +++ b/src/test/ui/borrowck/issue-41962.rs @@ -18,7 +18,6 @@ pub fn main(){ //~^ ERROR use of partially moved value: `maybe` (Ast) [E0382] //~| ERROR use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) [E0382] //~| ERROR use of moved value: `maybe` (Mir) [E0382] - //~| ERROR use of moved value: `maybe` (Mir) [E0382] //~| ERROR use of moved value: `maybe.0` (Mir) [E0382] } } diff --git a/src/test/ui/borrowck/issue-41962.stderr b/src/test/ui/borrowck/issue-41962.stderr index 13305fd965626..50d51c4d907fd 100644 --- a/src/test/ui/borrowck/issue-41962.stderr +++ b/src/test/ui/borrowck/issue-41962.stderr @@ -16,23 +16,6 @@ error[E0382]: use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) | = note: move occurs because the value has type `std::vec::Vec`, which does not implement the `Copy` trait -error[E0382]: use of moved value: `maybe` (Mir) - --> $DIR/issue-41962.rs:17:9 - | -17 | if let Some(thing) = maybe { - | ^ ----- value moved here - | _________| - | | -18 | | //~^ ERROR use of partially moved value: `maybe` (Ast) [E0382] -19 | | //~| ERROR use of moved value: `(maybe as std::prelude::v1::Some).0` (Ast) [E0382] -20 | | //~| ERROR use of moved value: `maybe` (Mir) [E0382] -21 | | //~| ERROR use of moved value: `maybe` (Mir) [E0382] -22 | | //~| ERROR use of moved value: `maybe.0` (Mir) [E0382] -23 | | } - | |_________^ value used here after move - | - = note: move occurs because `maybe` has type `std::option::Option>`, which does not implement the `Copy` trait - error[E0382]: use of moved value: `maybe` (Mir) --> $DIR/issue-41962.rs:17:16 | @@ -52,5 +35,5 @@ error[E0382]: use of moved value: `maybe.0` (Mir) | = note: move occurs because `maybe.0` has type `std::vec::Vec`, which does not implement the `Copy` trait -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors diff --git a/src/test/ui/borrowck/regions-bound-missing-bound-in-impl.stderr b/src/test/ui/borrowck/regions-bound-missing-bound-in-impl.stderr deleted file mode 100644 index e8323247af997..0000000000000 --- a/src/test/ui/borrowck/regions-bound-missing-bound-in-impl.stderr +++ /dev/null @@ -1,48 +0,0 @@ -error[E0195]: lifetime parameters or bounds on method `no_bound` do not match the trait declaration - --> $DIR/regions-bound-missing-bound-in-impl.rs:28:5 - | -20 | fn no_bound<'b>(self, b: Inv<'b>); - | ---------------------------------- lifetimes in impl do not match this method in trait -... -28 | fn no_bound<'b:'a>(self, b: Inv<'b>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetimes do not match method in trait - -error[E0195]: lifetime parameters or bounds on method `has_bound` do not match the trait declaration - --> $DIR/regions-bound-missing-bound-in-impl.rs:32:5 - | -21 | fn has_bound<'b:'a>(self, b: Inv<'b>); - | -------------------------------------- lifetimes in impl do not match this method in trait -... -32 | fn has_bound<'b>(self, b: Inv<'b>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetimes do not match method in trait - -error[E0308]: method not compatible with trait - --> $DIR/regions-bound-missing-bound-in-impl.rs:36:5 - | -36 | fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch - | - = note: expected type `fn(&'a isize, Inv<'c>, Inv<'c>, Inv<'d>)` - found type `fn(&'a isize, Inv<'_>, Inv<'c>, Inv<'d>)` -note: the lifetime 'c as defined on the method body at 36:5... - --> $DIR/regions-bound-missing-bound-in-impl.rs:36:5 - | -36 | fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...does not necessarily outlive the lifetime 'c as defined on the method body at 36:5 - --> $DIR/regions-bound-missing-bound-in-impl.rs:36:5 - | -36 | fn wrong_bound1<'b,'c,'d:'a+'c>(self, b: Inv<'b>, c: Inv<'c>, d: Inv<'d>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0276]: impl has stricter requirements than trait - --> $DIR/regions-bound-missing-bound-in-impl.rs:53:5 - | -24 | fn another_bound<'x: 'a>(self, x: Inv<'x>, y: Inv<'t>); - | ------------------------------------------------------- definition of `another_bound` from trait -... -53 | fn another_bound<'x: 't>(self, x: Inv<'x>, y: Inv<'t>) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `'x: 't` - -error: aborting due to 4 previous errors - diff --git a/src/test/ui/closure-expected-type/expect-region-supply-region.stderr b/src/test/ui/closure-expected-type/expect-region-supply-region.stderr index 5c612522d9a31..ebb1e561e57ab 100644 --- a/src/test/ui/closure-expected-type/expect-region-supply-region.stderr +++ b/src/test/ui/closure-expected-type/expect-region-supply-region.stderr @@ -41,8 +41,14 @@ note: the anonymous lifetime #2 defined on the body at 47:29... note: ...does not necessarily outlive the lifetime 'x as defined on the function body at 42:1 --> $DIR/expect-region-supply-region.rs:42:1 | -42 | fn expect_bound_supply_named<'x>() { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +42 | / fn expect_bound_supply_named<'x>() { +43 | | let mut f: Option<&u32> = None; +44 | | +45 | | // Here we give a type annotation that `x` should be free. We get +... | +54 | | }); +55 | | } + | |_^ error[E0308]: mismatched types --> $DIR/expect-region-supply-region.rs:47:33 @@ -55,8 +61,14 @@ error[E0308]: mismatched types note: the lifetime 'x as defined on the function body at 42:1... --> $DIR/expect-region-supply-region.rs:42:1 | -42 | fn expect_bound_supply_named<'x>() { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +42 | / fn expect_bound_supply_named<'x>() { +43 | | let mut f: Option<&u32> = None; +44 | | +45 | | // Here we give a type annotation that `x` should be free. We get +... | +54 | | }); +55 | | } + | |_^ note: ...does not necessarily outlive the anonymous lifetime #2 defined on the body at 47:29 --> $DIR/expect-region-supply-region.rs:47:29 | diff --git a/src/test/ui/cross-file-errors/main.rs b/src/test/ui/cross-file-errors/main.rs deleted file mode 100644 index 8eae79a21a983..0000000000000 --- a/src/test/ui/cross-file-errors/main.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#[macro_use] -mod underscore; - -fn main() { - underscore!(); -} diff --git a/src/test/ui/cross-file-errors/main.stderr b/src/test/ui/cross-file-errors/main.stderr deleted file mode 100644 index a1cdae10edfcd..0000000000000 --- a/src/test/ui/cross-file-errors/main.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error: expected expression, found `_` - --> $DIR/underscore.rs:18:9 - | -18 | _ - | ^ - | - ::: $DIR/main.rs:15:5 - | -15 | underscore!(); - | -------------- in this macro invocation - diff --git a/src/test/ui/cross-file-errors/underscore.rs b/src/test/ui/cross-file-errors/underscore.rs deleted file mode 100644 index 312b3b8f4ddd5..0000000000000 --- a/src/test/ui/cross-file-errors/underscore.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// We want this file only so we can test cross-file error -// messages, but we don't want it in an external crate. -// ignore-test -#![crate_type = "lib"] - -macro_rules! underscore { - () => ( - _ - ) -} diff --git a/src/test/ui/double-import.stderr b/src/test/ui/double-import.stderr index 2a0f9ee34f2be..fcd3f2696f200 100644 --- a/src/test/ui/double-import.stderr +++ b/src/test/ui/double-import.stderr @@ -9,8 +9,8 @@ error[E0252]: the name `foo` is defined multiple times = note: `foo` must be defined only once in the value namespace of this module help: You can use `as` to change the binding name of the import | -23 | use sub2::foo as other_foo; //~ ERROR the name `foo` is defined multiple times - | ^^^^^^^^^^^^^^^^^^^^^^ +23 | use sub2::foo as Otherfoo; //~ ERROR the name `foo` is defined multiple times + | ^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/error-codes/E0001.stderr b/src/test/ui/error-codes/E0001.stderr deleted file mode 100644 index d7d67af1492c6..0000000000000 --- a/src/test/ui/error-codes/E0001.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: unreachable pattern - --> $DIR/E0001.rs:18:9 - | -18 | _ => {/* ... */} //~ ERROR unreachable pattern - | ^ - | -note: lint level defined here - --> $DIR/E0001.rs:11:9 - | -11 | #![deny(unreachable_patterns)] - | ^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0004-2.stderr b/src/test/ui/error-codes/E0004-2.stderr deleted file mode 100644 index 2f4d26e2f327c..0000000000000 --- a/src/test/ui/error-codes/E0004-2.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0004]: non-exhaustive patterns: type std::option::Option is non-empty - --> $DIR/E0004-2.rs:14:11 - | -14 | match x { } //~ ERROR E0004 - | ^ - | -help: Please ensure that all possible cases are being handled; possibly adding wildcards or more match arms. - --> $DIR/E0004-2.rs:14:11 - | -14 | match x { } //~ ERROR E0004 - | ^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0004.stderr b/src/test/ui/error-codes/E0004.stderr deleted file mode 100644 index 836afaf05ba9f..0000000000000 --- a/src/test/ui/error-codes/E0004.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0004]: non-exhaustive patterns: `HastaLaVistaBaby` not covered - --> $DIR/E0004.rs:19:11 - | -19 | match x { //~ ERROR E0004 - | ^ pattern `HastaLaVistaBaby` not covered - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0005.stderr b/src/test/ui/error-codes/E0005.stderr deleted file mode 100644 index d052c12e9fe9d..0000000000000 --- a/src/test/ui/error-codes/E0005.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0005]: refutable pattern in local binding: `None` not covered - --> $DIR/E0005.rs:13:9 - | -13 | let Some(y) = x; //~ ERROR E0005 - | ^^^^^^^ pattern `None` not covered - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0007.stderr b/src/test/ui/error-codes/E0007.stderr deleted file mode 100644 index 1370cacd7cbfa..0000000000000 --- a/src/test/ui/error-codes/E0007.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0007]: cannot bind by-move with sub-bindings - --> $DIR/E0007.rs:14:9 - | -14 | op_string @ Some(s) => {}, - | ^^^^^^^^^^^^^^^^^^^ binds an already bound by-move value by moving it - -error[E0303]: pattern bindings are not allowed after an `@` - --> $DIR/E0007.rs:14:26 - | -14 | op_string @ Some(s) => {}, - | ^ not allowed after `@` - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0008.stderr b/src/test/ui/error-codes/E0008.stderr deleted file mode 100644 index 6ae4506a6e390..0000000000000 --- a/src/test/ui/error-codes/E0008.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0008]: cannot bind by-move into a pattern guard - --> $DIR/E0008.rs:13:14 - | -13 | Some(s) if s.len() == 0 => {}, - | ^ moves value into pattern guard - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0009.stderr b/src/test/ui/error-codes/E0009.stderr deleted file mode 100644 index 31db957621d21..0000000000000 --- a/src/test/ui/error-codes/E0009.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0009]: cannot bind by-move and by-ref in the same pattern - --> $DIR/E0009.rs:15:15 - | -15 | Some((y, ref z)) => {}, - | ^ ----- both by-ref and by-move used - | | - | by-move pattern here - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0010-teach.rs b/src/test/ui/error-codes/E0010-teach.rs deleted file mode 100644 index e5ccf32af1473..0000000000000 --- a/src/test/ui/error-codes/E0010-teach.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z teach - -#![feature(box_syntax)] -#![allow(warnings)] - -const CON : Box = box 0; //~ ERROR E0010 - -fn main() {} diff --git a/src/test/ui/error-codes/E0010-teach.stderr b/src/test/ui/error-codes/E0010-teach.stderr deleted file mode 100644 index 46f8101ca65ad..0000000000000 --- a/src/test/ui/error-codes/E0010-teach.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0010]: allocations are not allowed in constants - --> $DIR/E0010-teach.rs:16:24 - | -16 | const CON : Box = box 0; //~ ERROR E0010 - | ^^^^^ allocation not allowed in constants - | - = note: The value of statics and constants must be known at compile time, and they live for the entire lifetime of a program. Creating a boxed value allocates memory on the heap at runtime, and therefore cannot be done at compile time. - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0010.stderr b/src/test/ui/error-codes/E0010.stderr deleted file mode 100644 index 5cef631e05ed6..0000000000000 --- a/src/test/ui/error-codes/E0010.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0010]: allocations are not allowed in constants - --> $DIR/E0010.rs:14:24 - | -14 | const CON : Box = box 0; //~ ERROR E0010 - | ^^^^^ allocation not allowed in constants - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0017.stderr b/src/test/ui/error-codes/E0017.stderr deleted file mode 100644 index f1fe1e58b34d7..0000000000000 --- a/src/test/ui/error-codes/E0017.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0017]: references in constants may only refer to immutable values - --> $DIR/E0017.rs:14:30 - | -14 | const CR: &'static mut i32 = &mut C; //~ ERROR E0017 - | ^^^^^^ constants require immutable values - -error[E0017]: references in statics may only refer to immutable values - --> $DIR/E0017.rs:15:39 - | -15 | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 - | ^^^^^^ statics require immutable values - -error[E0596]: cannot borrow immutable static item as mutable - --> $DIR/E0017.rs:15:44 - | -15 | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 - | ^ - -error[E0017]: references in statics may only refer to immutable values - --> $DIR/E0017.rs:17:38 - | -17 | static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017 - | ^^^^^^ statics require immutable values - -error: aborting due to 4 previous errors - diff --git a/src/test/ui/error-codes/E0023.stderr b/src/test/ui/error-codes/E0023.stderr deleted file mode 100644 index 582dffeb19ce2..0000000000000 --- a/src/test/ui/error-codes/E0023.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields - --> $DIR/E0023.rs:20:9 - | -20 | Fruit::Apple(a) => {}, //~ ERROR E0023 - | ^^^^^^^^^^^^^^^ expected 2 fields, found 1 - -error[E0023]: this pattern has 3 fields, but the corresponding tuple variant has 2 fields - --> $DIR/E0023.rs:21:9 - | -21 | Fruit::Apple(a, b, c) => {}, //~ ERROR E0023 - | ^^^^^^^^^^^^^^^^^^^^^ expected 2 fields, found 3 - -error[E0023]: this pattern has 2 fields, but the corresponding tuple variant has 1 field - --> $DIR/E0023.rs:22:9 - | -22 | Fruit::Pear(1, 2) => {}, //~ ERROR E0023 - | ^^^^^^^^^^^^^^^^^ expected 1 field, found 2 - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/error-codes/E0025.stderr b/src/test/ui/error-codes/E0025.stderr deleted file mode 100644 index 480cd2a5cc8a9..0000000000000 --- a/src/test/ui/error-codes/E0025.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0025]: field `a` bound multiple times in the pattern - --> $DIR/E0025.rs:18:21 - | -18 | let Foo { a: x, a: y, b: 0 } = x; - | ---- ^^^^ multiple uses of `a` in pattern - | | - | first use of `a` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0026-teach.rs b/src/test/ui/error-codes/E0026-teach.rs deleted file mode 100644 index e0ce44a8b6f5f..0000000000000 --- a/src/test/ui/error-codes/E0026-teach.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z teach - -struct Thing { - x: u32, - y: u32 -} - -fn main() { - let thing = Thing { x: 0, y: 0 }; - match thing { - Thing { x, y, z } => {} - //~^ ERROR struct `Thing` does not have a field named `z` [E0026] - } -} diff --git a/src/test/ui/error-codes/E0026-teach.stderr b/src/test/ui/error-codes/E0026-teach.stderr deleted file mode 100644 index ee83cfb353515..0000000000000 --- a/src/test/ui/error-codes/E0026-teach.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0026]: struct `Thing` does not have a field named `z` - --> $DIR/E0026-teach.rs:21:23 - | -21 | Thing { x, y, z } => {} - | ^ struct `Thing` does not have field `z` - | - = note: This error indicates that a struct pattern attempted to extract a non-existent field from a struct. Struct fields are identified by the name used before the colon : so struct patterns should resemble the declaration of the struct type being matched. - - If you are using shorthand field patterns but want to refer to the struct field by a different name, you should rename it explicitly. - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0026.stderr b/src/test/ui/error-codes/E0026.stderr deleted file mode 100644 index c9819df3f9fbd..0000000000000 --- a/src/test/ui/error-codes/E0026.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0026]: struct `Thing` does not have a field named `z` - --> $DIR/E0026.rs:19:23 - | -19 | Thing { x, y, z } => {} - | ^ struct `Thing` does not have field `z` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0027-teach.rs b/src/test/ui/error-codes/E0027-teach.rs deleted file mode 100644 index 17e045bb8b086..0000000000000 --- a/src/test/ui/error-codes/E0027-teach.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z teach - -struct Dog { - name: String, - age: u32, -} - -fn main() { - let d = Dog { name: "Rusty".to_string(), age: 8 }; - - match d { - Dog { age: x } => {} - //~^ ERROR pattern does not mention field `name` - } -} diff --git a/src/test/ui/error-codes/E0027-teach.stderr b/src/test/ui/error-codes/E0027-teach.stderr deleted file mode 100644 index e9f9e4ba766f2..0000000000000 --- a/src/test/ui/error-codes/E0027-teach.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0027]: pattern does not mention field `name` - --> $DIR/E0027-teach.rs:22:9 - | -22 | Dog { age: x } => {} - | ^^^^^^^^^^^^^^ missing field `name` - | - = note: This error indicates that a pattern for a struct fails to specify a sub-pattern for every one of the struct's fields. Ensure that each field from the struct's definition is mentioned in the pattern, or use `..` to ignore unwanted fields. - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0027.stderr b/src/test/ui/error-codes/E0027.stderr deleted file mode 100644 index 0f93a776b9ef1..0000000000000 --- a/src/test/ui/error-codes/E0027.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0027]: pattern does not mention field `name` - --> $DIR/E0027.rs:20:9 - | -20 | Dog { age: x } => {} - | ^^^^^^^^^^^^^^ missing field `name` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0029-teach.rs b/src/test/ui/error-codes/E0029-teach.rs deleted file mode 100644 index ca85f58133ccd..0000000000000 --- a/src/test/ui/error-codes/E0029-teach.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z teach - -fn main() { - let s = "hoho"; - - match s { - "hello" ... "world" => {} - //~^ ERROR only char and numeric types are allowed in range patterns - //~| ERROR non-reference pattern used to match a reference - _ => {} - } -} diff --git a/src/test/ui/error-codes/E0029-teach.stderr b/src/test/ui/error-codes/E0029-teach.stderr deleted file mode 100644 index dbb8d972f5c22..0000000000000 --- a/src/test/ui/error-codes/E0029-teach.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0658]: non-reference pattern used to match a reference (see issue #42640) - --> $DIR/E0029-teach.rs:17:9 - | -17 | "hello" ... "world" => {} - | ^^^^^^^^^^^^^^^^^^^ help: consider using a reference: `&"hello" ... "world"` - | - = help: add #![feature(match_default_bindings)] to the crate attributes to enable - -error[E0029]: only char and numeric types are allowed in range patterns - --> $DIR/E0029-teach.rs:17:9 - | -17 | "hello" ... "world" => {} - | ^^^^^^^^^^^^^^^^^^^ ranges require char or numeric types - | - = note: start type: &'static str - = note: end type: &'static str - = note: In a match expression, only numbers and characters can be matched against a range. This is because the compiler checks that the range is non-empty at compile-time, and is unable to evaluate arbitrary comparison functions. If you want to capture values of an orderable type between two end-points, you can use a guard. - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0029.stderr b/src/test/ui/error-codes/E0029.stderr deleted file mode 100644 index 02fbd20386f2d..0000000000000 --- a/src/test/ui/error-codes/E0029.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0658]: non-reference pattern used to match a reference (see issue #42640) - --> $DIR/E0029.rs:15:9 - | -15 | "hello" ... "world" => {} - | ^^^^^^^^^^^^^^^^^^^ help: consider using a reference: `&"hello" ... "world"` - | - = help: add #![feature(match_default_bindings)] to the crate attributes to enable - -error[E0029]: only char and numeric types are allowed in range patterns - --> $DIR/E0029.rs:15:9 - | -15 | "hello" ... "world" => {} - | ^^^^^^^^^^^^^^^^^^^ ranges require char or numeric types - | - = note: start type: &'static str - = note: end type: &'static str - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0030-teach.rs b/src/test/ui/error-codes/E0030-teach.rs deleted file mode 100644 index 2af32eda62be9..0000000000000 --- a/src/test/ui/error-codes/E0030-teach.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z teach - -fn main() { - match 5u32 { - 1000 ... 5 => {} - //~^ ERROR lower range bound must be less than or equal to upper - } -} diff --git a/src/test/ui/error-codes/E0030-teach.stderr b/src/test/ui/error-codes/E0030-teach.stderr deleted file mode 100644 index 40b3d790e1245..0000000000000 --- a/src/test/ui/error-codes/E0030-teach.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0030]: lower range bound must be less than or equal to upper - --> $DIR/E0030-teach.rs:15:9 - | -15 | 1000 ... 5 => {} - | ^^^^ lower bound larger than upper bound - | - = note: When matching against a range, the compiler verifies that the range is non-empty. Range patterns include both end-points, so this is equivalent to requiring the start of the range to be less than or equal to the end of the range. - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0030.stderr b/src/test/ui/error-codes/E0030.stderr deleted file mode 100644 index 7bdecd0028e74..0000000000000 --- a/src/test/ui/error-codes/E0030.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0030]: lower range bound must be less than or equal to upper - --> $DIR/E0030.rs:14:9 - | -14 | 1000 ... 5 => {} - | ^^^^ lower bound larger than upper bound - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0033-teach.rs b/src/test/ui/error-codes/E0033-teach.rs deleted file mode 100644 index 51a1390bf79d1..0000000000000 --- a/src/test/ui/error-codes/E0033-teach.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// compile-flags: -Z teach - -trait SomeTrait { - fn foo(); -} - -fn main() { - let trait_obj: &SomeTrait = SomeTrait; - //~^ ERROR expected value, found trait `SomeTrait` - //~| ERROR E0038 - //~| method `foo` has no receiver - - let &invalid = trait_obj; - //~^ ERROR E0033 -} diff --git a/src/test/ui/error-codes/E0033-teach.stderr b/src/test/ui/error-codes/E0033-teach.stderr deleted file mode 100644 index ea60fcb6ccf1c..0000000000000 --- a/src/test/ui/error-codes/E0033-teach.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0423]: expected value, found trait `SomeTrait` - --> $DIR/E0033-teach.rs:18:33 - | -18 | let trait_obj: &SomeTrait = SomeTrait; - | ^^^^^^^^^ not a value - -error[E0038]: the trait `SomeTrait` cannot be made into an object - --> $DIR/E0033-teach.rs:18:20 - | -18 | let trait_obj: &SomeTrait = SomeTrait; - | ^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object - | - = note: method `foo` has no receiver - -error[E0033]: type `&SomeTrait` cannot be dereferenced - --> $DIR/E0033-teach.rs:23:9 - | -23 | let &invalid = trait_obj; - | ^^^^^^^^ type `&SomeTrait` cannot be dereferenced - | - = note: This error indicates that a pointer to a trait type cannot be implicitly dereferenced by a pattern. Every trait defines a type, but because the size of trait implementors isn't fixed, this type has no compile-time size. Therefore, all accesses to trait types must be through pointers. If you encounter this error you should try to avoid dereferencing the pointer. - - You can read more about trait objects in the Trait Objects section of the Reference: https://doc.rust-lang.org/reference/types.html#trait-objects - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/error-codes/E0033.stderr b/src/test/ui/error-codes/E0033.stderr deleted file mode 100644 index abc535ee2a647..0000000000000 --- a/src/test/ui/error-codes/E0033.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0423]: expected value, found trait `SomeTrait` - --> $DIR/E0033.rs:16:33 - | -16 | let trait_obj: &SomeTrait = SomeTrait; - | ^^^^^^^^^ not a value - -error[E0038]: the trait `SomeTrait` cannot be made into an object - --> $DIR/E0033.rs:16:20 - | -16 | let trait_obj: &SomeTrait = SomeTrait; - | ^^^^^^^^^^ the trait `SomeTrait` cannot be made into an object - | - = note: method `foo` has no receiver - -error[E0033]: type `&SomeTrait` cannot be dereferenced - --> $DIR/E0033.rs:21:9 - | -21 | let &invalid = trait_obj; - | ^^^^^^^^ type `&SomeTrait` cannot be dereferenced - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/error-codes/E0034.stderr b/src/test/ui/error-codes/E0034.stderr deleted file mode 100644 index 238fd0d67a080..0000000000000 --- a/src/test/ui/error-codes/E0034.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0034]: multiple applicable items in scope - --> $DIR/E0034.rs:30:5 - | -30 | Test::foo() //~ ERROR multiple applicable items in scope - | ^^^^^^^^^ multiple `foo` found - | -note: candidate #1 is defined in an impl of the trait `Trait1` for the type `Test` - --> $DIR/E0034.rs:22:5 - | -22 | fn foo() {} - | ^^^^^^^^ -note: candidate #2 is defined in an impl of the trait `Trait2` for the type `Test` - --> $DIR/E0034.rs:26:5 - | -26 | fn foo() {} - | ^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0038.stderr b/src/test/ui/error-codes/E0038.stderr deleted file mode 100644 index e9423561f3775..0000000000000 --- a/src/test/ui/error-codes/E0038.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0038]: the trait `Trait` cannot be made into an object - --> $DIR/E0038.rs:15:1 - | -15 | fn call_foo(x: Box) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` cannot be made into an object - | - = note: method `foo` references the `Self` type in its arguments or return type - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0040.stderr b/src/test/ui/error-codes/E0040.stderr deleted file mode 100644 index 73cb49fbf9878..0000000000000 --- a/src/test/ui/error-codes/E0040.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0040]: explicit use of destructor method - --> $DIR/E0040.rs:23:7 - | -23 | x.drop(); - | ^^^^ explicit destructor calls not allowed - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0044.stderr b/src/test/ui/error-codes/E0044.stderr deleted file mode 100644 index 65a429c1fcacd..0000000000000 --- a/src/test/ui/error-codes/E0044.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0044]: foreign items may not have type parameters - --> $DIR/E0044.rs:11:10 - | -11 | extern { fn some_func(x: T); } //~ ERROR E0044 - | ^^^^^^^^^^^^^^^^^^^^^^ - | -help: consider using specialization instead of type parameters - --> $DIR/E0044.rs:11:10 - | -11 | extern { fn some_func(x: T); } //~ ERROR E0044 - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0045.stderr b/src/test/ui/error-codes/E0045.stderr deleted file mode 100644 index cd400564669f5..0000000000000 --- a/src/test/ui/error-codes/E0045.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0045]: variadic function must have C or cdecl calling convention - --> $DIR/E0045.rs:11:17 - | -11 | extern "Rust" { fn foo(x: u8, ...); } //~ ERROR E0045 - | ^^^^^^^^^^^^^^^^^^^ variadics require C or cdecl calling convention - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0049.stderr b/src/test/ui/error-codes/E0049.stderr deleted file mode 100644 index e6f72bab50ad4..0000000000000 --- a/src/test/ui/error-codes/E0049.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0049]: method `foo` has 0 type parameters but its trait declaration has 1 type parameter - --> $DIR/E0049.rs:18:5 - | -12 | fn foo(x: T) -> Self; - | --------------------------------- expected 1 type parameter -... -18 | fn foo(x: bool) -> Self { Bar } //~ ERROR E0049 - | ^^^^^^^^^^^^^^^^^^^^^^^ found 0 type parameters - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0050.stderr b/src/test/ui/error-codes/E0050.stderr deleted file mode 100644 index d95a2005b1876..0000000000000 --- a/src/test/ui/error-codes/E0050.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0050]: method `foo` has 1 parameter but the declaration in trait `Foo::foo` has 2 - --> $DIR/E0050.rs:20:12 - | -12 | fn foo(&self, x: u8) -> bool; - | -- trait requires 2 parameters -... -20 | fn foo(&self) -> bool { true } //~ ERROR E0050 - | ^^^^^ expected 2 parameters, found 1 - -error[E0050]: method `bar` has 1 parameter but the declaration in trait `Foo::bar` has 4 - --> $DIR/E0050.rs:21:12 - | -13 | fn bar(&self, x: u8, y: u8, z: u8); - | -- trait requires 4 parameters -... -21 | fn bar(&self) { } //~ ERROR E0050 - | ^^^^^ expected 4 parameters, found 1 - -error[E0050]: method `less` has 4 parameters but the declaration in trait `Foo::less` has 1 - --> $DIR/E0050.rs:22:37 - | -14 | fn less(&self); - | ----- trait requires 1 parameter -... -22 | fn less(&self, x: u8, y: u8, z: u8) { } //~ ERROR E0050 - | ^^ expected 1 parameter, found 4 - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/error-codes/E0054.stderr b/src/test/ui/error-codes/E0054.stderr deleted file mode 100644 index fc331579ef5f5..0000000000000 --- a/src/test/ui/error-codes/E0054.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0054]: cannot cast as `bool` - --> $DIR/E0054.rs:13:24 - | -13 | let x_is_nonzero = x as bool; //~ ERROR E0054 - | ^^^^^^^^^ unsupported cast - | - = help: compare with zero instead - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0055.stderr b/src/test/ui/error-codes/E0055.stderr deleted file mode 100644 index 001178e97c065..0000000000000 --- a/src/test/ui/error-codes/E0055.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0055]: reached the recursion limit while auto-dereferencing Foo - --> $DIR/E0055.rs:21:13 - | -21 | ref_foo.foo(); - | ^^^ deref recursion limit reached - | - = help: consider adding a `#![recursion_limit="4"]` attribute to your crate - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0057.stderr b/src/test/ui/error-codes/E0057.stderr deleted file mode 100644 index 450c87ca0322b..0000000000000 --- a/src/test/ui/error-codes/E0057.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0057]: this function takes 1 parameter but 0 parameters were supplied - --> $DIR/E0057.rs:13:13 - | -13 | let a = f(); //~ ERROR E0057 - | ^^^ expected 1 parameter - -error[E0057]: this function takes 1 parameter but 2 parameters were supplied - --> $DIR/E0057.rs:15:13 - | -15 | let c = f(2, 3); //~ ERROR E0057 - | ^^^^^^^ expected 1 parameter - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0059.stderr b/src/test/ui/error-codes/E0059.stderr deleted file mode 100644 index aca4b8881e28f..0000000000000 --- a/src/test/ui/error-codes/E0059.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0059]: cannot use call notation; the first type parameter for the function trait is neither a tuple nor unit - --> $DIR/E0059.rs:13:41 - | -13 | fn foo>(f: F) -> F::Output { f(3) } //~ ERROR E0059 - | ^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0060.stderr b/src/test/ui/error-codes/E0060.stderr deleted file mode 100644 index 8207220ba72c5..0000000000000 --- a/src/test/ui/error-codes/E0060.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0060]: this function takes at least 1 parameter but 0 parameters were supplied - --> $DIR/E0060.rs:16:14 - | -12 | fn printf(_: *const u8, ...) -> u32; - | ------------------------------------ defined here -... -16 | unsafe { printf(); } - | ^^^^^^^^ expected at least 1 parameter - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0061.stderr b/src/test/ui/error-codes/E0061.stderr deleted file mode 100644 index 89d81b5acd76c..0000000000000 --- a/src/test/ui/error-codes/E0061.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0061]: this function takes 2 parameters but 1 parameter was supplied - --> $DIR/E0061.rs:16:5 - | -11 | fn f(a: u16, b: &str) {} - | --------------------- defined here -... -16 | f(0); - | ^^^^ expected 2 parameters - -error[E0061]: this function takes 1 parameter but 0 parameters were supplied - --> $DIR/E0061.rs:20:5 - | -13 | fn f2(a: u16) {} - | ------------- defined here -... -20 | f2(); - | ^^^^ expected 1 parameter - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0062.stderr b/src/test/ui/error-codes/E0062.stderr deleted file mode 100644 index 6c5ecf48045b1..0000000000000 --- a/src/test/ui/error-codes/E0062.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0062]: field `x` specified more than once - --> $DIR/E0062.rs:18:9 - | -17 | x: 0, - | ---- first use of `x` -18 | x: 0, - | ^^ used more than once - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0063.stderr b/src/test/ui/error-codes/E0063.stderr deleted file mode 100644 index 023819cc778d0..0000000000000 --- a/src/test/ui/error-codes/E0063.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0063]: missing field `x` in initializer of `SingleFoo` - --> $DIR/E0063.rs:42:13 - | -42 | let w = SingleFoo { }; - | ^^^^^^^^^ missing `x` - -error[E0063]: missing fields `y`, `z` in initializer of `PluralFoo` - --> $DIR/E0063.rs:44:13 - | -44 | let x = PluralFoo {x: 1}; - | ^^^^^^^^^ missing `y`, `z` - -error[E0063]: missing fields `a`, `b`, `y` and 1 other field in initializer of `TruncatedFoo` - --> $DIR/E0063.rs:46:13 - | -46 | let y = TruncatedFoo{x:1}; - | ^^^^^^^^^^^^ missing `a`, `b`, `y` and 1 other field - -error[E0063]: missing fields `a`, `b`, `c` and 2 other fields in initializer of `TruncatedPluralFoo` - --> $DIR/E0063.rs:48:13 - | -48 | let z = TruncatedPluralFoo{x:1}; - | ^^^^^^^^^^^^^^^^^^ missing `a`, `b`, `c` and 2 other fields - -error: aborting due to 4 previous errors - diff --git a/src/test/ui/error-codes/E0067.stderr b/src/test/ui/error-codes/E0067.stderr deleted file mode 100644 index a4e15619e8ba8..0000000000000 --- a/src/test/ui/error-codes/E0067.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0368]: binary assignment operation `+=` cannot be applied to type `std::collections::LinkedList<_>` - --> $DIR/E0067.rs:14:5 - | -14 | LinkedList::new() += 1; //~ ERROR E0368 - | -----------------^^^^^ - | | - | cannot use `+=` on type `std::collections::LinkedList<_>` - -error[E0067]: invalid left-hand side expression - --> $DIR/E0067.rs:14:5 - | -14 | LinkedList::new() += 1; //~ ERROR E0368 - | ^^^^^^^^^^^^^^^^^ invalid expression for left-hand side - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0069.stderr b/src/test/ui/error-codes/E0069.stderr deleted file mode 100644 index 8424531889f0f..0000000000000 --- a/src/test/ui/error-codes/E0069.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0069]: `return;` in a function whose return type is not `()` - --> $DIR/E0069.rs:12:5 - | -12 | return; - | ^^^^^^ return type is not () - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0070.stderr b/src/test/ui/error-codes/E0070.stderr deleted file mode 100644 index e1316e2e1306c..0000000000000 --- a/src/test/ui/error-codes/E0070.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0070]: invalid left-hand side expression - --> $DIR/E0070.rs:16:5 - | -16 | SOME_CONST = 14; //~ ERROR E0070 - | ^^^^^^^^^^^^^^^ left-hand of expression not valid - -error[E0070]: invalid left-hand side expression - --> $DIR/E0070.rs:17:5 - | -17 | 1 = 3; //~ ERROR E0070 - | ^^^^^ left-hand of expression not valid - -error[E0308]: mismatched types - --> $DIR/E0070.rs:18:25 - | -18 | some_other_func() = 4; //~ ERROR E0070 - | ^ expected (), found integral variable - | - = note: expected type `()` - found type `{integer}` - -error[E0070]: invalid left-hand side expression - --> $DIR/E0070.rs:18:5 - | -18 | some_other_func() = 4; //~ ERROR E0070 - | ^^^^^^^^^^^^^^^^^^^^^ left-hand of expression not valid - -error: aborting due to 4 previous errors - diff --git a/src/test/ui/error-codes/E0071.stderr b/src/test/ui/error-codes/E0071.stderr deleted file mode 100644 index 020dad3ac9f8e..0000000000000 --- a/src/test/ui/error-codes/E0071.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0071]: expected struct, variant or union type, found enum `Foo` - --> $DIR/E0071.rs:15:13 - | -15 | let u = FooAlias { value: 0 }; - | ^^^^^^^^ not a struct - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0075.stderr b/src/test/ui/error-codes/E0075.stderr deleted file mode 100644 index 39d27d6f7e462..0000000000000 --- a/src/test/ui/error-codes/E0075.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0075]: SIMD vector cannot be empty - --> $DIR/E0075.rs:14:1 - | -14 | struct Bad; //~ ERROR E0075 - | ^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0076.stderr b/src/test/ui/error-codes/E0076.stderr deleted file mode 100644 index 02ce47977c8a2..0000000000000 --- a/src/test/ui/error-codes/E0076.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0076]: SIMD vector should be homogeneous - --> $DIR/E0076.rs:14:1 - | -14 | struct Bad(u16, u32, u32); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ SIMD elements must have the same type - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0077.stderr b/src/test/ui/error-codes/E0077.stderr deleted file mode 100644 index 7e7b55f9b7e77..0000000000000 --- a/src/test/ui/error-codes/E0077.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0077]: SIMD vector element type should be machine type - --> $DIR/E0077.rs:14:1 - | -14 | struct Bad(String); //~ ERROR E0077 - | ^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0080.stderr b/src/test/ui/error-codes/E0080.stderr deleted file mode 100644 index 2ec2ad31b53bb..0000000000000 --- a/src/test/ui/error-codes/E0080.stderr +++ /dev/null @@ -1,28 +0,0 @@ -warning: constant evaluation error: attempt to shift left with overflow - --> $DIR/E0080.rs:12:9 - | -12 | X = (1 << 500), //~ ERROR E0080 - | ^^^^^^^^^^ - | - = note: #[warn(const_err)] on by default - -error[E0080]: constant evaluation error - --> $DIR/E0080.rs:12:9 - | -12 | X = (1 << 500), //~ ERROR E0080 - | ^^^^^^^^^^ attempt to shift left with overflow - -warning: constant evaluation error: attempt to divide by zero - --> $DIR/E0080.rs:14:9 - | -14 | Y = (1 / 0) //~ ERROR E0080 - | ^^^^^^^ - -error[E0080]: constant evaluation error - --> $DIR/E0080.rs:14:9 - | -14 | Y = (1 / 0) //~ ERROR E0080 - | ^^^^^^^ attempt to divide by zero - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0081.stderr b/src/test/ui/error-codes/E0081.stderr deleted file mode 100644 index 035638b2f31df..0000000000000 --- a/src/test/ui/error-codes/E0081.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0081]: discriminant value `3isize` already exists - --> $DIR/E0081.rs:13:9 - | -12 | P = 3, - | - first use of `3isize` -13 | X = 3, - | ^ enum already has `3isize` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0084.stderr b/src/test/ui/error-codes/E0084.stderr deleted file mode 100644 index b39a129ba162e..0000000000000 --- a/src/test/ui/error-codes/E0084.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0084]: unsupported representation for zero-variant enum - --> $DIR/E0084.rs:11:1 - | -11 | #[repr(i32)] //~ ERROR: E0084 - | ^^^^^^^^^^^^ -12 | enum Foo {} - | ----------- zero-variant enum - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0087.stderr b/src/test/ui/error-codes/E0087.stderr deleted file mode 100644 index 20c8cd45dfada..0000000000000 --- a/src/test/ui/error-codes/E0087.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0087]: too many type parameters provided: expected at most 0 type parameters, found 1 type parameter - --> $DIR/E0087.rs:15:11 - | -15 | foo::(); //~ ERROR expected at most 0 type parameters, found 1 type parameter [E0087] - | ^^^ expected 0 type parameters - -error[E0087]: too many type parameters provided: expected at most 1 type parameter, found 2 type parameters - --> $DIR/E0087.rs:17:16 - | -17 | bar::(); //~ ERROR expected at most 1 type parameter, found 2 type parameters [E0087] - | ^^^ expected 1 type parameter - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0088.stderr b/src/test/ui/error-codes/E0088.stderr deleted file mode 100644 index 615df88f1bb2e..0000000000000 --- a/src/test/ui/error-codes/E0088.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0088]: too many lifetime parameters provided: expected at most 0 lifetime parameters, found 1 lifetime parameter - --> $DIR/E0088.rs:15:9 - | -15 | f::<'static>(); //~ ERROR E0088 - | ^^^^^^^ expected 0 lifetime parameters - -error[E0088]: too many lifetime parameters provided: expected at most 1 lifetime parameter, found 2 lifetime parameters - --> $DIR/E0088.rs:16:18 - | -16 | g::<'static, 'static>(); //~ ERROR E0088 - | ^^^^^^^ expected 1 lifetime parameter - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0089.stderr b/src/test/ui/error-codes/E0089.stderr deleted file mode 100644 index 38b45e27fa796..0000000000000 --- a/src/test/ui/error-codes/E0089.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0089]: too few type parameters provided: expected 2 type parameters, found 1 type parameter - --> $DIR/E0089.rs:14:5 - | -14 | foo::(); //~ ERROR expected 2 type parameters, found 1 type parameter [E0089] - | ^^^^^^^^^^ expected 2 type parameters - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0090.stderr b/src/test/ui/error-codes/E0090.stderr deleted file mode 100644 index 050082d84df58..0000000000000 --- a/src/test/ui/error-codes/E0090.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0090]: too few lifetime parameters provided: expected 2 lifetime parameters, found 1 lifetime parameter - --> $DIR/E0090.rs:14:5 - | -14 | foo::<'static>(); //~ ERROR expected 2 lifetime parameters, found 1 lifetime parameter [E0090] - | ^^^^^^^^^^^^^^ expected 2 lifetime parameters - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0091.stderr b/src/test/ui/error-codes/E0091.stderr deleted file mode 100644 index 7d951dd6dfd19..0000000000000 --- a/src/test/ui/error-codes/E0091.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0091]: type parameter `T` is unused - --> $DIR/E0091.rs:11:10 - | -11 | type Foo = u32; //~ ERROR E0091 - | ^ unused type parameter - -error[E0091]: type parameter `B` is unused - --> $DIR/E0091.rs:12:14 - | -12 | type Foo2 = Box; //~ ERROR E0091 - | ^ unused type parameter - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0092.stderr b/src/test/ui/error-codes/E0092.stderr deleted file mode 100644 index 788f89944110a..0000000000000 --- a/src/test/ui/error-codes/E0092.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0092]: unrecognized atomic operation function: `foo` - --> $DIR/E0092.rs:13:5 - | -13 | fn atomic_foo(); //~ ERROR E0092 - | ^^^^^^^^^^^^^^^^ unrecognized atomic operation - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0093.stderr b/src/test/ui/error-codes/E0093.stderr deleted file mode 100644 index 959d64af433f5..0000000000000 --- a/src/test/ui/error-codes/E0093.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0093]: unrecognized intrinsic function: `foo` - --> $DIR/E0093.rs:13:5 - | -13 | fn foo(); - | ^^^^^^^^^ unrecognized intrinsic - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0094.stderr b/src/test/ui/error-codes/E0094.stderr deleted file mode 100644 index fdef3d8877bcf..0000000000000 --- a/src/test/ui/error-codes/E0094.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0094]: intrinsic has wrong number of type parameters: found 2, expected 1 - --> $DIR/E0094.rs:13:15 - | -13 | fn size_of() -> usize; //~ ERROR E0094 - | ^^^^^^ expected 1 type parameter - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0106.stderr b/src/test/ui/error-codes/E0106.stderr deleted file mode 100644 index 98442804708ea..0000000000000 --- a/src/test/ui/error-codes/E0106.stderr +++ /dev/null @@ -1,32 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/E0106.rs:12:8 - | -12 | x: &bool, - | ^ expected lifetime parameter - -error[E0106]: missing lifetime specifier - --> $DIR/E0106.rs:17:7 - | -17 | B(&bool), - | ^ expected lifetime parameter - -error[E0106]: missing lifetime specifier - --> $DIR/E0106.rs:20:14 - | -20 | type MyStr = &str; - | ^ expected lifetime parameter - -error[E0106]: missing lifetime specifier - --> $DIR/E0106.rs:27:10 - | -27 | baz: Baz, - | ^^^ expected lifetime parameter - -error[E0106]: missing lifetime specifiers - --> $DIR/E0106.rs:30:11 - | -30 | buzz: Buzz, - | ^^^^ expected 2 lifetime parameters - -error: aborting due to 5 previous errors - diff --git a/src/test/ui/error-codes/E0107.stderr b/src/test/ui/error-codes/E0107.stderr deleted file mode 100644 index 6283486039c8d..0000000000000 --- a/src/test/ui/error-codes/E0107.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0107]: wrong number of lifetime parameters: expected 2, found 1 - --> $DIR/E0107.rs:21:11 - | -21 | buzz: Buzz<'a>, - | ^^^^^^^^ expected 2 lifetime parameters - -error[E0107]: wrong number of lifetime parameters: expected 0, found 1 - --> $DIR/E0107.rs:24:10 - | -24 | bar: Bar<'a>, - | ^^^^^^^ unexpected lifetime parameter - -error[E0107]: wrong number of lifetime parameters: expected 1, found 3 - --> $DIR/E0107.rs:27:11 - | -27 | foo2: Foo<'a, 'b, 'c>, - | ^^^^^^^^^^^^^^^ 2 unexpected lifetime parameters - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/error-codes/E0109.stderr b/src/test/ui/error-codes/E0109.stderr deleted file mode 100644 index 59da11140b1e7..0000000000000 --- a/src/test/ui/error-codes/E0109.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0109]: type parameters are not allowed on this type - --> $DIR/E0109.rs:11:14 - | -11 | type X = u32; //~ ERROR E0109 - | ^^^ type parameter not allowed - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0110.stderr b/src/test/ui/error-codes/E0110.stderr deleted file mode 100644 index 7417351c16d2c..0000000000000 --- a/src/test/ui/error-codes/E0110.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0110]: lifetime parameters are not allowed on this type - --> $DIR/E0110.rs:11:14 - | -11 | type X = u32<'static>; //~ ERROR E0110 - | ^^^^^^^ lifetime parameter not allowed on this type - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0116.stderr b/src/test/ui/error-codes/E0116.stderr deleted file mode 100644 index c090060e7d67d..0000000000000 --- a/src/test/ui/error-codes/E0116.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0116]: cannot define inherent `impl` for a type outside of the crate where the type is defined - --> $DIR/E0116.rs:11:1 - | -11 | impl Vec {} - | ^^^^^^^^^^^^^^^ impl for type defined outside of crate. - | - = note: define and implement a trait or new type instead - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0117.stderr b/src/test/ui/error-codes/E0117.stderr deleted file mode 100644 index 9856692659a50..0000000000000 --- a/src/test/ui/error-codes/E0117.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0120]: the Drop trait may only be implemented on structures - --> $DIR/E0117.rs:11:15 - | -11 | impl Drop for u32 {} //~ ERROR E0117 - | ^^^ implementing Drop requires a struct - -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/E0117.rs:11:1 - | -11 | impl Drop for u32 {} //~ ERROR E0117 - | ^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0118.stderr b/src/test/ui/error-codes/E0118.stderr deleted file mode 100644 index 8c78890b88acc..0000000000000 --- a/src/test/ui/error-codes/E0118.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0118]: no base type found for inherent implementation - --> $DIR/E0118.rs:11:6 - | -11 | impl (u8, u8) { //~ ERROR E0118 - | ^^^^^^^^ impl requires a base type - | - = note: either implement a trait on it or create a newtype to wrap it instead - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0119.stderr b/src/test/ui/error-codes/E0119.stderr deleted file mode 100644 index 91bb74a10d67d..0000000000000 --- a/src/test/ui/error-codes/E0119.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0119]: conflicting implementations of trait `MyTrait` for type `Foo`: - --> $DIR/E0119.rs:23:1 - | -15 | impl MyTrait for T { - | --------------------- first implementation here -... -23 | impl MyTrait for Foo { //~ ERROR E0119 - | ^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Foo` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0120.stderr b/src/test/ui/error-codes/E0120.stderr deleted file mode 100644 index 7c666d9fd0a6d..0000000000000 --- a/src/test/ui/error-codes/E0120.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0120]: the Drop trait may only be implemented on structures - --> $DIR/E0120.rs:13:15 - | -13 | impl Drop for MyTrait { - | ^^^^^^^ implementing Drop requires a struct - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0121.stderr b/src/test/ui/error-codes/E0121.stderr deleted file mode 100644 index fa54d67856318..0000000000000 --- a/src/test/ui/error-codes/E0121.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/E0121.rs:11:13 - | -11 | fn foo() -> _ { 5 } //~ ERROR E0121 - | ^ not allowed in type signatures - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/E0121.rs:13:13 - | -13 | static BAR: _ = "test"; //~ ERROR E0121 - | ^ not allowed in type signatures - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0124.stderr b/src/test/ui/error-codes/E0124.stderr deleted file mode 100644 index 8e1ec51ea1cb7..0000000000000 --- a/src/test/ui/error-codes/E0124.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0124]: field `field1` is already declared - --> $DIR/E0124.rs:13:5 - | -12 | field1: i32, - | ----------- `field1` first declared here -13 | field1: i32, - | ^^^^^^^^^^^ field already declared - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0128.stderr b/src/test/ui/error-codes/E0128.stderr deleted file mode 100644 index fad2d0db8abdf..0000000000000 --- a/src/test/ui/error-codes/E0128.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0128]: type parameters with a default cannot use forward declared identifiers - --> $DIR/E0128.rs:11:14 - | -11 | struct Foo { //~ ERROR E0128 - | ^ defaulted type parameters cannot be forward declared - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0130.stderr b/src/test/ui/error-codes/E0130.stderr deleted file mode 100644 index 02aebe0362a13..0000000000000 --- a/src/test/ui/error-codes/E0130.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0130]: patterns aren't allowed in foreign function declarations - --> $DIR/E0130.rs:12:12 - | -12 | fn foo((a, b): (u32, u32)); - | ^^^^^^ pattern not allowed in foreign function - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0131.stderr b/src/test/ui/error-codes/E0131.stderr deleted file mode 100644 index d97e00fb82df1..0000000000000 --- a/src/test/ui/error-codes/E0131.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0131]: main function is not allowed to have type parameters - --> $DIR/E0131.rs:11:8 - | -11 | fn main() { - | ^^^ main cannot have type parameters - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0132.stderr b/src/test/ui/error-codes/E0132.stderr deleted file mode 100644 index 5c66d67b907b3..0000000000000 --- a/src/test/ui/error-codes/E0132.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0132]: start function is not allowed to have type parameters - --> $DIR/E0132.rs:14:5 - | -14 | fn f< T >() {} //~ ERROR E0132 - | ^^^^^ start function cannot have type parameters - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0133.stderr b/src/test/ui/error-codes/E0133.stderr deleted file mode 100644 index 4d2ebd111ddf6..0000000000000 --- a/src/test/ui/error-codes/E0133.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0133]: call to unsafe function requires unsafe function or block - --> $DIR/E0133.rs:14:5 - | -14 | f(); - | ^^^ call to unsafe function - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0137.stderr b/src/test/ui/error-codes/E0137.stderr deleted file mode 100644 index bc6bbffb18e72..0000000000000 --- a/src/test/ui/error-codes/E0137.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0137]: multiple functions with a #[main] attribute - --> $DIR/E0137.rs:17:1 - | -14 | fn foo() {} - | ----------- first #[main] function -... -17 | fn f() {} - | ^^^^^^^^^ additional #[main] function - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0138.stderr b/src/test/ui/error-codes/E0138.stderr deleted file mode 100644 index cee7cc5d90629..0000000000000 --- a/src/test/ui/error-codes/E0138.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0138]: multiple 'start' functions - --> $DIR/E0138.rs:17:1 - | -14 | fn foo(argc: isize, argv: *const *const u8) -> isize { 0 } - | ---------------------------------------------------------- previous `start` function here -... -17 | fn f(argc: isize, argv: *const *const u8) -> isize { 0 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ multiple `start` functions - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0152.stderr b/src/test/ui/error-codes/E0152.stderr deleted file mode 100644 index a1d5597f031f6..0000000000000 --- a/src/test/ui/error-codes/E0152.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0152]: duplicate lang item found: `panic_fmt`. - --> $DIR/E0152.rs:14:1 - | -14 | struct Foo; //~ ERROR E0152 - | ^^^^^^^^^^^ - | - = note: first defined in crate `std`. - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0161.stderr b/src/test/ui/error-codes/E0161.stderr deleted file mode 100644 index 9914fdd2d6155..0000000000000 --- a/src/test/ui/error-codes/E0161.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0161]: cannot move a value of type str: the size of str cannot be statically determined - --> $DIR/E0161.rs:14:28 - | -14 | let _x: Box = box *"hello"; //~ ERROR E0161 - | ^^^^^^^^ - -error[E0507]: cannot move out of borrowed content - --> $DIR/E0161.rs:14:28 - | -14 | let _x: Box = box *"hello"; //~ ERROR E0161 - | ^^^^^^^^ cannot move out of borrowed content - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0162.stderr b/src/test/ui/error-codes/E0162.stderr deleted file mode 100644 index 318a023d30213..0000000000000 --- a/src/test/ui/error-codes/E0162.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0162]: irrefutable if-let pattern - --> $DIR/E0162.rs:15:12 - | -15 | if let Irrefutable(x) = irr { //~ ERROR E0162 - | ^^^^^^^^^^^^^^ irrefutable pattern - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0164.stderr b/src/test/ui/error-codes/E0164.stderr deleted file mode 100644 index a515c83d14b2d..0000000000000 --- a/src/test/ui/error-codes/E0164.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0164]: expected tuple struct/variant, found associated constant `::B` - --> $DIR/E0164.rs:20:9 - | -20 | Foo::B(i) => i, //~ ERROR E0164 - | ^^^^^^^^^ not a tuple variant or struct - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0165.stderr b/src/test/ui/error-codes/E0165.stderr deleted file mode 100644 index 3c90f19a0dc7c..0000000000000 --- a/src/test/ui/error-codes/E0165.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0165]: irrefutable while-let pattern - --> $DIR/E0165.rs:15:15 - | -15 | while let Irrefutable(x) = irr { //~ ERROR E0165 - | ^^^^^^^^^^^^^^ irrefutable pattern - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0184.stderr b/src/test/ui/error-codes/E0184.stderr deleted file mode 100644 index 53bda3bb57591..0000000000000 --- a/src/test/ui/error-codes/E0184.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0184]: the trait `Copy` may not be implemented for this type; the type has a destructor - --> $DIR/E0184.rs:11:10 - | -11 | #[derive(Copy)] //~ ERROR E0184 - | ^^^^ Copy not allowed on types with destructors - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0185.stderr b/src/test/ui/error-codes/E0185.stderr deleted file mode 100644 index 0d24a3712d558..0000000000000 --- a/src/test/ui/error-codes/E0185.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0185]: method `foo` has a `&self` declaration in the impl, but not in the trait - --> $DIR/E0185.rs:19:5 - | -12 | fn foo(); - | --------- trait method declared without `&self` -... -19 | fn foo(&self) {} - | ^^^^^^^^^^^^^ `&self` used in impl - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0186.stderr b/src/test/ui/error-codes/E0186.stderr deleted file mode 100644 index 598057db3a662..0000000000000 --- a/src/test/ui/error-codes/E0186.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0186]: method `foo` has a `&self` declaration in the trait, but not in the impl - --> $DIR/E0186.rs:18:5 - | -12 | fn foo(&self); //~ `&self` used in trait - | -------------- `&self` used in trait -... -18 | fn foo() {} //~ ERROR E0186 - | ^^^^^^^^ expected `&self` in impl - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0191.stderr b/src/test/ui/error-codes/E0191.stderr deleted file mode 100644 index 8f99a6ecffb99..0000000000000 --- a/src/test/ui/error-codes/E0191.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0191]: the value of the associated type `Bar` (from the trait `Trait`) must be specified - --> $DIR/E0191.rs:15:12 - | -15 | type Foo = Trait; //~ ERROR E0191 - | ^^^^^ missing associated type `Bar` value - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0192.stderr b/src/test/ui/error-codes/E0192.stderr deleted file mode 100644 index b592c87efa7a0..0000000000000 --- a/src/test/ui/error-codes/E0192.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0192]: negative impls are only allowed for auto traits (e.g., `Send` and `Sync`) - --> $DIR/E0192.rs:19:1 - | -19 | impl !Trait for Foo { } //~ ERROR E0192 - | ^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0194.stderr b/src/test/ui/error-codes/E0194.stderr deleted file mode 100644 index 360e8c08a3c97..0000000000000 --- a/src/test/ui/error-codes/E0194.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0194]: type parameter `T` shadows another type parameter of the same name - --> $DIR/E0194.rs:13:26 - | -11 | trait Foo { - | - first `T` declared here -12 | fn do_something(&self) -> T; -13 | fn do_something_else(&self, bar: T); - | ^ shadows another type parameter - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0195.stderr b/src/test/ui/error-codes/E0195.stderr deleted file mode 100644 index 3cce3d0799416..0000000000000 --- a/src/test/ui/error-codes/E0195.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0195]: lifetime parameters or bounds on method `bar` do not match the trait declaration - --> $DIR/E0195.rs:19:5 - | -12 | fn bar<'a,'b:'a>(x: &'a str, y: &'b str); - | ----------------------------------------- lifetimes in impl do not match this method in trait -... -19 | fn bar<'a,'b>(x: &'a str, y: &'b str) { //~ ERROR E0195 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetimes do not match method in trait - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0197.stderr b/src/test/ui/error-codes/E0197.stderr deleted file mode 100644 index 277f523e497aa..0000000000000 --- a/src/test/ui/error-codes/E0197.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0197]: inherent impls cannot be unsafe - --> $DIR/E0197.rs:13:1 - | -13 | unsafe impl Foo { } //~ ERROR E0197 - | ^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0198.stderr b/src/test/ui/error-codes/E0198.stderr deleted file mode 100644 index a85419e9a1397..0000000000000 --- a/src/test/ui/error-codes/E0198.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0198]: negative impls cannot be unsafe - --> $DIR/E0198.rs:15:1 - | -15 | unsafe impl !Send for Foo { } //~ ERROR E0198 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0199.stderr b/src/test/ui/error-codes/E0199.stderr deleted file mode 100644 index efbe066e52e7e..0000000000000 --- a/src/test/ui/error-codes/E0199.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0199]: implementing the trait `Bar` is not unsafe - --> $DIR/E0199.rs:16:1 - | -16 | unsafe impl Bar for Foo { } //~ ERROR implementing the trait `Bar` is not unsafe [E0199] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0200.stderr b/src/test/ui/error-codes/E0200.stderr deleted file mode 100644 index fb71da23677bd..0000000000000 --- a/src/test/ui/error-codes/E0200.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0200]: the trait `Bar` requires an `unsafe impl` declaration - --> $DIR/E0200.rs:15:1 - | -15 | impl Bar for Foo { } //~ ERROR E0200 - | ^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0201.stderr b/src/test/ui/error-codes/E0201.stderr deleted file mode 100644 index 01dbee6e09236..0000000000000 --- a/src/test/ui/error-codes/E0201.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0201]: duplicate definitions with name `bar`: - --> $DIR/E0201.rs:15:5 - | -14 | fn bar(&self) -> bool { self.0 > 5 } - | ------------------------------------ previous definition of `bar` here -15 | fn bar() {} //~ ERROR E0201 - | ^^^^^^^^^^^ duplicate definition - -error[E0201]: duplicate definitions with name `baz`: - --> $DIR/E0201.rs:27:5 - | -26 | fn baz(&self) -> bool { true } - | ------------------------------ previous definition of `baz` here -27 | fn baz(&self) -> bool { self.0 > 5 } //~ ERROR E0201 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ duplicate definition - -error[E0201]: duplicate definitions with name `Quux`: - --> $DIR/E0201.rs:28:5 - | -24 | type Quux = u32; - | ---------------- previous definition of `Quux` here -... -28 | type Quux = u32; //~ ERROR E0201 - | ^^^^^^^^^^^^^^^^ duplicate definition - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/error-codes/E0206.stderr b/src/test/ui/error-codes/E0206.stderr deleted file mode 100644 index 8eeb94a42f4b8..0000000000000 --- a/src/test/ui/error-codes/E0206.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0206]: the trait `Copy` may not be implemented for this type - --> $DIR/E0206.rs:13:15 - | -13 | impl Copy for Foo { } - | ^^^ type is not a structure or enumeration - -error[E0206]: the trait `Copy` may not be implemented for this type - --> $DIR/E0206.rs:20:15 - | -20 | impl Copy for &'static Bar { } - | ^^^^^^^^^^^^ type is not a structure or enumeration - -error[E0117]: only traits defined in the current crate can be implemented for arbitrary types - --> $DIR/E0206.rs:13:1 - | -13 | impl Copy for Foo { } - | ^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate - | - = note: the impl does not reference any types defined in this crate - = note: define and implement a trait or new type instead - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/error-codes/E0207.stderr b/src/test/ui/error-codes/E0207.stderr deleted file mode 100644 index 35f9109fe99ed..0000000000000 --- a/src/test/ui/error-codes/E0207.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates - --> $DIR/E0207.rs:13:6 - | -13 | impl Foo { //~ ERROR E0207 - | ^ unconstrained type parameter - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0214.stderr b/src/test/ui/error-codes/E0214.stderr deleted file mode 100644 index 30f5b960a364e..0000000000000 --- a/src/test/ui/error-codes/E0214.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0214]: parenthesized parameters may only be used with a trait - --> $DIR/E0214.rs:12:15 - | -12 | let v: Vec(&str) = vec!["foo"]; - | ^^^^^^ only traits may use parentheses - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0220.stderr b/src/test/ui/error-codes/E0220.stderr deleted file mode 100644 index 70b017b782f2d..0000000000000 --- a/src/test/ui/error-codes/E0220.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0220]: associated type `F` not found for `Trait` - --> $DIR/E0220.rs:15:18 - | -15 | type Foo = Trait; //~ ERROR E0220 - | ^^^^^ associated type `F` not found - -error[E0191]: the value of the associated type `Bar` (from the trait `Trait`) must be specified - --> $DIR/E0220.rs:15:12 - | -15 | type Foo = Trait; //~ ERROR E0220 - | ^^^^^^^^^^^^ missing associated type `Bar` value - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0221.stderr b/src/test/ui/error-codes/E0221.stderr deleted file mode 100644 index 3dd9393d6b32a..0000000000000 --- a/src/test/ui/error-codes/E0221.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0221]: ambiguous associated type `A` in bounds of `Self` - --> $DIR/E0221.rs:21:16 - | -15 | type A: T1; - | ----------- ambiguous `A` from `Foo` -... -19 | type A: T2; - | ----------- ambiguous `A` from `Bar` -20 | fn do_something() { -21 | let _: Self::A; - | ^^^^^^^ ambiguous associated type `A` - -error[E0221]: ambiguous associated type `Err` in bounds of `Self` - --> $DIR/E0221.rs:31:16 - | -29 | type Err: T3; - | ------------- ambiguous `Err` from `My` -30 | fn test() { -31 | let _: Self::Err; - | ^^^^^^^^^ ambiguous associated type `Err` - | -note: associated type `Self` could derive from `std::str::FromStr` - --> $DIR/E0221.rs:31:16 - | -31 | let _: Self::Err; - | ^^^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0223.stderr b/src/test/ui/error-codes/E0223.stderr deleted file mode 100644 index efd0d7806581c..0000000000000 --- a/src/test/ui/error-codes/E0223.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0223]: ambiguous associated type - --> $DIR/E0223.rs:14:14 - | -14 | let foo: MyTrait::X; - | ^^^^^^^^^^ ambiguous associated type - | - = note: specify the type using the syntax `::X` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0225.stderr b/src/test/ui/error-codes/E0225.stderr deleted file mode 100644 index 35d40cb1017d1..0000000000000 --- a/src/test/ui/error-codes/E0225.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0225]: only auto traits can be used as additional traits in a trait object - --> $DIR/E0225.rs:12:32 - | -12 | let _: Box; - | ^^^^^^^^^^^^^^ non-auto additional trait - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0229.stderr b/src/test/ui/error-codes/E0229.stderr deleted file mode 100644 index 6d88ef88bffc3..0000000000000 --- a/src/test/ui/error-codes/E0229.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0229]: associated type bindings are not allowed here - --> $DIR/E0229.rs:23:25 - | -23 | fn baz(x: &>::A) {} - | ^^^^^ associated type not allowed here - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0232.stderr b/src/test/ui/error-codes/E0232.stderr deleted file mode 100644 index e13ba62b073ce..0000000000000 --- a/src/test/ui/error-codes/E0232.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0232]: `#[rustc_on_unimplemented]` requires a value - --> $DIR/E0232.rs:13:1 - | -13 | #[rustc_on_unimplemented] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ value required here - | - = note: eg `#[rustc_on_unimplemented = "foo"]` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0243.stderr b/src/test/ui/error-codes/E0243.stderr deleted file mode 100644 index 82a90fff34208..0000000000000 --- a/src/test/ui/error-codes/E0243.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0243]: wrong number of type arguments: expected 1, found 0 - --> $DIR/E0243.rs:12:17 - | -12 | struct Bar { x: Foo } - | ^^^ expected 1 type argument - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0244.stderr b/src/test/ui/error-codes/E0244.stderr deleted file mode 100644 index d873fbe9819f8..0000000000000 --- a/src/test/ui/error-codes/E0244.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0244]: wrong number of type arguments: expected 0, found 2 - --> $DIR/E0244.rs:12:23 - | -12 | struct Bar { x: Foo } - | ^^^^^^^^^ expected no type arguments - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0252.stderr b/src/test/ui/error-codes/E0252.stderr deleted file mode 100644 index f63597d697086..0000000000000 --- a/src/test/ui/error-codes/E0252.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0252]: the name `baz` is defined multiple times - --> $DIR/E0252.rs:12:5 - | -11 | use foo::baz; - | -------- previous import of the type `baz` here -12 | use bar::baz; //~ ERROR E0252 - | ^^^^^^^^ `baz` reimported here - | - = note: `baz` must be defined only once in the type namespace of this module -help: You can use `as` to change the binding name of the import - | -12 | use bar::baz as other_baz; //~ ERROR E0252 - | ^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0253.stderr b/src/test/ui/error-codes/E0253.stderr deleted file mode 100644 index e5a311537810d..0000000000000 --- a/src/test/ui/error-codes/E0253.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0253]: `do_something` is not directly importable - --> $DIR/E0253.rs:17:5 - | -17 | use foo::MyTrait::do_something; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be imported directly - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0254.stderr b/src/test/ui/error-codes/E0254.stderr deleted file mode 100644 index 4181c7b1f7fb0..0000000000000 --- a/src/test/ui/error-codes/E0254.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0254]: the name `alloc` is defined multiple times - --> $DIR/E0254.rs:22:5 - | -14 | extern crate alloc; - | ------------------- previous import of the extern crate `alloc` here -... -22 | use foo::alloc; - | ^^^^^^^^^^ `alloc` reimported here - | - = note: `alloc` must be defined only once in the type namespace of this module -help: You can use `as` to change the binding name of the import - | -22 | use foo::alloc as other_alloc; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0255.stderr b/src/test/ui/error-codes/E0255.stderr deleted file mode 100644 index 924ac49695c63..0000000000000 --- a/src/test/ui/error-codes/E0255.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0255]: the name `foo` is defined multiple times - --> $DIR/E0255.rs:13:1 - | -11 | use bar::foo; - | -------- previous import of the value `foo` here -12 | -13 | fn foo() {} //~ ERROR E0255 - | ^^^^^^^^ `foo` redefined here - | - = note: `foo` must be defined only once in the value namespace of this module -help: You can use `as` to change the binding name of the import - | -11 | use bar::foo as other_foo; - | ^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0259.stderr b/src/test/ui/error-codes/E0259.stderr deleted file mode 100644 index e05e4e1cac74e..0000000000000 --- a/src/test/ui/error-codes/E0259.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0259]: the name `alloc` is defined multiple times - --> $DIR/E0259.rs:16:1 - | -14 | extern crate alloc; - | ------------------- previous import of the extern crate `alloc` here -15 | -16 | extern crate libc as alloc; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | | - | `alloc` reimported here - | You can use `as` to change the binding name of the import - | - = note: `alloc` must be defined only once in the type namespace of this module - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0260.stderr b/src/test/ui/error-codes/E0260.stderr deleted file mode 100644 index 3d899e636ee38..0000000000000 --- a/src/test/ui/error-codes/E0260.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0260]: the name `alloc` is defined multiple times - --> $DIR/E0260.rs:16:1 - | -14 | extern crate alloc; - | ------------------- previous import of the extern crate `alloc` here -15 | -16 | mod alloc { - | ^^^^^^^^^ `alloc` redefined here - | - = note: `alloc` must be defined only once in the type namespace of this module -help: You can use `as` to change the binding name of the import - | -14 | extern crate alloc as other_alloc; - | - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0261.stderr b/src/test/ui/error-codes/E0261.stderr deleted file mode 100644 index c8dd08211ecb0..0000000000000 --- a/src/test/ui/error-codes/E0261.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/E0261.rs:11:12 - | -11 | fn foo(x: &'a str) { } //~ ERROR E0261 - | ^^ undeclared lifetime - -error[E0261]: use of undeclared lifetime name `'a` - --> $DIR/E0261.rs:15:9 - | -15 | x: &'a str, //~ ERROR E0261 - | ^^ undeclared lifetime - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0262.stderr b/src/test/ui/error-codes/E0262.stderr deleted file mode 100644 index 0910009d2c0dc..0000000000000 --- a/src/test/ui/error-codes/E0262.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0262]: invalid lifetime parameter name: `'static` - --> $DIR/E0262.rs:11:8 - | -11 | fn foo<'static>(x: &'static str) { } //~ ERROR E0262 - | ^^^^^^^ 'static is a reserved lifetime name - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0263.stderr b/src/test/ui/error-codes/E0263.stderr deleted file mode 100644 index 942718d50f727..0000000000000 --- a/src/test/ui/error-codes/E0263.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0263]: lifetime name `'a` declared twice in the same scope - --> $DIR/E0263.rs:11:16 - | -11 | fn foo<'a, 'b, 'a>(x: &'a str, y: &'b str) { - | -- ^^ declared twice - | | - | previous declaration here - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0264.stderr b/src/test/ui/error-codes/E0264.stderr deleted file mode 100644 index b10494633edf3..0000000000000 --- a/src/test/ui/error-codes/E0264.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0264]: unknown external lang item: `cake` - --> $DIR/E0264.rs:15:5 - | -15 | fn cake(); //~ ERROR E0264 - | ^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0267.stderr b/src/test/ui/error-codes/E0267.stderr deleted file mode 100644 index 2f6d9c72eeb1a..0000000000000 --- a/src/test/ui/error-codes/E0267.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0267]: `break` inside of a closure - --> $DIR/E0267.rs:12:18 - | -12 | let w = || { break; }; //~ ERROR E0267 - | ^^^^^ cannot break inside of a closure - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0268.stderr b/src/test/ui/error-codes/E0268.stderr deleted file mode 100644 index cf89e46af047e..0000000000000 --- a/src/test/ui/error-codes/E0268.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0268]: `break` outside of loop - --> $DIR/E0268.rs:12:5 - | -12 | break; //~ ERROR E0268 - | ^^^^^ cannot break outside of a loop - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0271.stderr b/src/test/ui/error-codes/E0271.stderr deleted file mode 100644 index c596b560ea7f8..0000000000000 --- a/src/test/ui/error-codes/E0271.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0271]: type mismatch resolving `::AssociatedType == u32` - --> $DIR/E0271.rs:20:5 - | -20 | foo(3_i8); //~ ERROR E0271 - | ^^^ expected reference, found u32 - | - = note: expected type `&'static str` - found type `u32` -note: required by `foo` - --> $DIR/E0271.rs:13:1 - | -13 | fn foo(t: T) where T: Trait { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0275.stderr b/src/test/ui/error-codes/E0275.stderr deleted file mode 100644 index 2dbe5be215546..0000000000000 --- a/src/test/ui/error-codes/E0275.stderr +++ /dev/null @@ -1,79 +0,0 @@ -error[E0275]: overflow evaluating the requirement `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: std::marker::Sized` - --> $DIR/E0275.rs:15:1 - | -15 | impl Foo for T where Bar: Foo {} //~ ERROR E0275 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: consider adding a `#![recursion_limit="128"]` attribute to your crate - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>>` - = note: required because of the requirements on the impl of `Foo` for `Bar>` - = note: required because of the requirements on the impl of `Foo` for `Bar` -note: required by `Foo` - --> $DIR/E0275.rs:11:1 - | -11 | trait Foo {} - | ^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0276.stderr b/src/test/ui/error-codes/E0276.stderr deleted file mode 100644 index bcbe81ac11a05..0000000000000 --- a/src/test/ui/error-codes/E0276.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0276]: impl has stricter requirements than trait - --> $DIR/E0276.rs:16:5 - | -12 | fn foo(x: T); - | ---------------- definition of `foo` from trait -... -16 | fn foo(x: T) where T: Copy {} //~ ERROR E0276 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl has extra requirement `T: std::marker::Copy` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0277-2.stderr b/src/test/ui/error-codes/E0277-2.stderr deleted file mode 100644 index 6a0f21ef14438..0000000000000 --- a/src/test/ui/error-codes/E0277-2.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: the trait bound `*const u8: std::marker::Send` is not satisfied in `Foo` - --> $DIR/E0277-2.rs:26:5 - | -26 | is_send::(); - | ^^^^^^^^^^^^^^ `*const u8` cannot be sent between threads safely - | - = help: within `Foo`, the trait `std::marker::Send` is not implemented for `*const u8` - = note: required because it appears within the type `Baz` - = note: required because it appears within the type `Bar` - = note: required because it appears within the type `Foo` -note: required by `is_send` - --> $DIR/E0277-2.rs:23:1 - | -23 | fn is_send() { } - | ^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0277.stderr b/src/test/ui/error-codes/E0277.stderr deleted file mode 100644 index 38d14ed7bce25..0000000000000 --- a/src/test/ui/error-codes/E0277.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0277]: the trait bound `[u8]: std::marker::Sized` is not satisfied in `std::path::Path` - --> $DIR/E0277.rs:23:6 - | -23 | fn f(p: Path) { } - | ^ `[u8]` does not have a constant size known at compile-time - | - = help: within `std::path::Path`, the trait `std::marker::Sized` is not implemented for `[u8]` - = note: required because it appears within the type `std::path::Path` - = note: all local variables must have a statically known size - -error[E0277]: the trait bound `i32: Foo` is not satisfied - --> $DIR/E0277.rs:27:5 - | -27 | some_func(5i32); - | ^^^^^^^^^ the trait `Foo` is not implemented for `i32` - | -note: required by `some_func` - --> $DIR/E0277.rs:19:1 - | -19 | fn some_func(foo: T) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0282.stderr b/src/test/ui/error-codes/E0282.stderr deleted file mode 100644 index 835162740da90..0000000000000 --- a/src/test/ui/error-codes/E0282.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0282]: type annotations needed - --> $DIR/E0282.rs:12:9 - | -12 | let x = "hello".chars().rev().collect(); //~ ERROR E0282 - | ^ - | | - | cannot infer type for `_` - | consider giving `x` a type - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0283.stderr b/src/test/ui/error-codes/E0283.stderr deleted file mode 100644 index 9fdb6b178c4d7..0000000000000 --- a/src/test/ui/error-codes/E0283.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0283]: type annotations required: cannot resolve `_: Generator` - --> $DIR/E0283.rs:28:21 - | -28 | let cont: u32 = Generator::create(); //~ ERROR E0283 - | ^^^^^^^^^^^^^^^^^ - | -note: required by `Generator::create` - --> $DIR/E0283.rs:12:5 - | -12 | fn create() -> u32; - | ^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0296.stderr b/src/test/ui/error-codes/E0296.stderr deleted file mode 100644 index f6a2adc0ad3f7..0000000000000 --- a/src/test/ui/error-codes/E0296.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0296]: malformed recursion limit attribute, expected #![recursion_limit="N"] - --> $DIR/E0296.rs:11:1 - | -11 | #![recursion_limit] //~ ERROR E0296 - | ^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0297.stderr b/src/test/ui/error-codes/E0297.stderr deleted file mode 100644 index 2dfed66ecaca6..0000000000000 --- a/src/test/ui/error-codes/E0297.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0005]: refutable pattern in `for` loop binding: `None` not covered - --> $DIR/E0297.rs:14:9 - | -14 | for Some(x) in xs {} - | ^^^^^^^ pattern `None` not covered - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0301.stderr b/src/test/ui/error-codes/E0301.stderr deleted file mode 100644 index ff4ee32d47b09..0000000000000 --- a/src/test/ui/error-codes/E0301.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0301]: cannot mutably borrow in a pattern guard - --> $DIR/E0301.rs:14:19 - | -14 | option if option.take().is_none() => {}, //~ ERROR E0301 - | ^^^^^^ borrowed mutably in pattern guard - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0302.stderr b/src/test/ui/error-codes/E0302.stderr deleted file mode 100644 index c7b33a490d1c9..0000000000000 --- a/src/test/ui/error-codes/E0302.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0302]: cannot assign in a pattern guard - --> $DIR/E0302.rs:14:21 - | -14 | option if { option = None; false } => { }, //~ ERROR E0302 - | ^^^^^^^^^^^^^ assignment in pattern guard - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0303.stderr b/src/test/ui/error-codes/E0303.stderr deleted file mode 100644 index 6528c97a560df..0000000000000 --- a/src/test/ui/error-codes/E0303.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0009]: cannot bind by-move and by-ref in the same pattern - --> $DIR/E0303.rs:13:34 - | -13 | ref op_string_ref @ Some(s) => {}, - | -------------------------^- - | | | - | | by-move pattern here - | both by-ref and by-move used - -error[E0303]: pattern bindings are not allowed after an `@` - --> $DIR/E0303.rs:13:34 - | -13 | ref op_string_ref @ Some(s) => {}, - | ^ not allowed after `@` - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0308-4.stderr b/src/test/ui/error-codes/E0308-4.stderr deleted file mode 100644 index 1e4beeae17691..0000000000000 --- a/src/test/ui/error-codes/E0308-4.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/E0308-4.rs:14:9 - | -14 | 0u8...3i8 => (), //~ ERROR E0308 - | ^^^^^^^^^ expected u8, found i8 - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0308.stderr b/src/test/ui/error-codes/E0308.stderr deleted file mode 100644 index 905b0210abfbf..0000000000000 --- a/src/test/ui/error-codes/E0308.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0308]: intrinsic has wrong type - --> $DIR/E0308.rs:14:5 - | -14 | fn size_of(); //~ ERROR E0308 - | ^^^^^^^^^^^^^^^^ expected (), found usize - | - = note: expected type `unsafe extern "rust-intrinsic" fn()` - found type `unsafe extern "rust-intrinsic" fn() -> usize` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0365.stderr b/src/test/ui/error-codes/E0365.stderr deleted file mode 100644 index ccb13856df9e1..0000000000000 --- a/src/test/ui/error-codes/E0365.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0365]: `foo` is private, and cannot be re-exported - --> $DIR/E0365.rs:15:9 - | -15 | pub use foo as foo2; - | ^^^^^^^^^^^ re-export of private `foo` - | - = note: consider declaring type or module `foo` with `pub` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0370.stderr b/src/test/ui/error-codes/E0370.stderr deleted file mode 100644 index 1f248f4ed2c21..0000000000000 --- a/src/test/ui/error-codes/E0370.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0370]: enum discriminant overflowed - --> $DIR/E0370.rs:17:5 - | -17 | Y, //~ ERROR E0370 - | ^ overflowed on value after 9223372036854775807i64 - | - = note: explicitly set `Y = -9223372036854775808i64` if that is desired outcome - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0374.stderr b/src/test/ui/error-codes/E0374.stderr deleted file mode 100644 index edd463d705c19..0000000000000 --- a/src/test/ui/error-codes/E0374.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0374]: the trait `CoerceUnsized` may only be implemented for a coercion between structures with one field being coerced, none found - --> $DIR/E0374.rs:18:1 - | -18 | / impl CoerceUnsized> for Foo //~ ERROR E0374 -19 | | where T: CoerceUnsized {} - | |________________________________^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0375.stderr b/src/test/ui/error-codes/E0375.stderr deleted file mode 100644 index a37591521c8ca..0000000000000 --- a/src/test/ui/error-codes/E0375.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0375]: implementing the trait `CoerceUnsized` requires multiple coercions - --> $DIR/E0375.rs:22:12 - | -22 | impl CoerceUnsized> for Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ requires multiple coercions - | - = note: `CoerceUnsized` may only be implemented for a coercion between structures with one field being coerced - = note: currently, 2 fields need coercions: b (T to U), c (U to T) - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0376.stderr b/src/test/ui/error-codes/E0376.stderr deleted file mode 100644 index d036adb4e2950..0000000000000 --- a/src/test/ui/error-codes/E0376.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0376]: the trait `CoerceUnsized` may only be implemented for a coercion between structures - --> $DIR/E0376.rs:18:1 - | -18 | impl CoerceUnsized for Foo {} //~ ERROR E0376 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0388.stderr b/src/test/ui/error-codes/E0388.stderr deleted file mode 100644 index ec210294cdbd4..0000000000000 --- a/src/test/ui/error-codes/E0388.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0017]: references in constants may only refer to immutable values - --> $DIR/E0388.rs:14:30 - | -14 | const CR: &'static mut i32 = &mut C; //~ ERROR E0017 - | ^^^^^^ constants require immutable values - -error[E0017]: references in statics may only refer to immutable values - --> $DIR/E0388.rs:15:39 - | -15 | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 - | ^^^^^^ statics require immutable values - -error[E0596]: cannot borrow immutable static item as mutable - --> $DIR/E0388.rs:15:44 - | -15 | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017 - | ^ - -error[E0017]: references in statics may only refer to immutable values - --> $DIR/E0388.rs:17:38 - | -17 | static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017 - | ^^^^^^ statics require immutable values - -error: aborting due to 4 previous errors - diff --git a/src/test/ui/error-codes/E0389.stderr b/src/test/ui/error-codes/E0389.stderr deleted file mode 100644 index e085329bac508..0000000000000 --- a/src/test/ui/error-codes/E0389.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0389]: cannot assign to data in a `&` reference - --> $DIR/E0389.rs:18:5 - | -18 | fancy_ref.num = 6; //~ ERROR E0389 - | ^^^^^^^^^^^^^^^^^ assignment into an immutable reference - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0390.stderr b/src/test/ui/error-codes/E0390.stderr deleted file mode 100644 index a10b0b87f37bd..0000000000000 --- a/src/test/ui/error-codes/E0390.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0390]: only a single inherent implementation marked with `#[lang = "mut_ptr"]` is allowed for the `*mut T` primitive - --> $DIR/E0390.rs:15:1 - | -15 | impl *mut Foo {} //~ ERROR E0390 - | ^^^^^^^^^^^^^^^^ - | -help: consider using a trait to implement these methods - --> $DIR/E0390.rs:15:1 - | -15 | impl *mut Foo {} //~ ERROR E0390 - | ^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0392.stderr b/src/test/ui/error-codes/E0392.stderr deleted file mode 100644 index 6c466cbb52e38..0000000000000 --- a/src/test/ui/error-codes/E0392.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0392]: parameter `T` is never used - --> $DIR/E0392.rs:11:10 - | -11 | enum Foo { Bar } //~ ERROR E0392 - | ^ unused type parameter - | - = help: consider removing `T` or using a marker such as `std::marker::PhantomData` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0393.stderr b/src/test/ui/error-codes/E0393.stderr deleted file mode 100644 index 10728e21901cd..0000000000000 --- a/src/test/ui/error-codes/E0393.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0393]: the type parameter `T` must be explicitly specified - --> $DIR/E0393.rs:13:43 - | -13 | fn together_we_will_rule_the_galaxy(son: &A) {} - | ^ missing reference to `T` - | - = note: because of the default `Self` reference, type parameters must be specified on object types - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0394.stderr b/src/test/ui/error-codes/E0394.stderr deleted file mode 100644 index 728cec1032558..0000000000000 --- a/src/test/ui/error-codes/E0394.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0394]: cannot refer to other statics by value, use the address-of operator or a constant instead - --> $DIR/E0394.rs:14:17 - | -14 | static B: u32 = A; - | ^ referring to another static by value - | - = note: use the address-of operator or a constant instead - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0395.stderr b/src/test/ui/error-codes/E0395.stderr deleted file mode 100644 index e6d76a696d3cf..0000000000000 --- a/src/test/ui/error-codes/E0395.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0395]: raw pointers cannot be compared in statics - --> $DIR/E0395.rs:14:22 - | -14 | static BAZ: bool = { (&FOO as *const i32) == (&BAR as *const i32) }; //~ ERROR E0395 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comparing raw pointers in static - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0396.stderr b/src/test/ui/error-codes/E0396.stderr deleted file mode 100644 index 5c5c01cb98854..0000000000000 --- a/src/test/ui/error-codes/E0396.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0396]: raw pointers cannot be dereferenced in constants - --> $DIR/E0396.rs:13:28 - | -13 | const VALUE: u8 = unsafe { *REG_ADDR }; //~ ERROR E0396 - | ^^^^^^^^^ dereference of raw pointer in constant - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0401.stderr b/src/test/ui/error-codes/E0401.stderr deleted file mode 100644 index d63aa378eee7d..0000000000000 --- a/src/test/ui/error-codes/E0401.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0401]: can't use type parameters from outer function; try using a local type parameter instead - --> $DIR/E0401.rs:12:15 - | -12 | fn bar(y: T) { //~ ERROR E0401 - | ^ use of type variable from outer function - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0403.stderr b/src/test/ui/error-codes/E0403.stderr deleted file mode 100644 index 125af35cb5798..0000000000000 --- a/src/test/ui/error-codes/E0403.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0403]: the name `T` is already used for a type parameter in this type parameter list - --> $DIR/E0403.rs:11:11 - | -11 | fn foo(s: T, u: T) {} //~ ERROR E0403 - | - ^ already used - | | - | first use of `T` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0404.stderr b/src/test/ui/error-codes/E0404.stderr deleted file mode 100644 index c30d8c00b80e2..0000000000000 --- a/src/test/ui/error-codes/E0404.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0404]: expected trait, found struct `Foo` - --> $DIR/E0404.rs:14:6 - | -14 | impl Foo for Bar {} //~ ERROR E0404 - | ^^^ not a trait - -error: cannot continue compilation due to previous error - diff --git a/src/test/ui/error-codes/E0405.stderr b/src/test/ui/error-codes/E0405.stderr deleted file mode 100644 index 29bab3f6dd99a..0000000000000 --- a/src/test/ui/error-codes/E0405.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0405]: cannot find trait `SomeTrait` in this scope - --> $DIR/E0405.rs:13:6 - | -13 | impl SomeTrait for Foo {} //~ ERROR E0405 - | ^^^^^^^^^ not found in this scope - -error: cannot continue compilation due to previous error - diff --git a/src/test/ui/error-codes/E0407.stderr b/src/test/ui/error-codes/E0407.stderr deleted file mode 100644 index f71437cd6b07c..0000000000000 --- a/src/test/ui/error-codes/E0407.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0407]: method `b` is not a member of trait `Foo` - --> $DIR/E0407.rs:19:5 - | -19 | fn b() {} - | ^^^^^^^^^ not a member of trait `Foo` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0408.stderr b/src/test/ui/error-codes/E0408.stderr deleted file mode 100644 index 1c66bb0e5f07b..0000000000000 --- a/src/test/ui/error-codes/E0408.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0408]: variable `y` is not bound in all patterns - --> $DIR/E0408.rs:15:19 - | -15 | Some(y) | None => {} //~ ERROR variable `y` is not bound in all patterns - | - ^^^^ pattern doesn't bind `y` - | | - | variable not in all patterns - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0411.stderr b/src/test/ui/error-codes/E0411.stderr deleted file mode 100644 index dda922b5b6891..0000000000000 --- a/src/test/ui/error-codes/E0411.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0411]: cannot find type `Self` in this scope - --> $DIR/E0411.rs:12:6 - | -12 | ::foo; //~ ERROR E0411 - | ^^^^ `Self` is only available in traits and impls - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0412.stderr b/src/test/ui/error-codes/E0412.stderr deleted file mode 100644 index 6ee2125af04e8..0000000000000 --- a/src/test/ui/error-codes/E0412.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0412]: cannot find type `Something` in this scope - --> $DIR/E0412.rs:11:6 - | -11 | impl Something {} //~ ERROR E0412 - | ^^^^^^^^^ not found in this scope - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0415.stderr b/src/test/ui/error-codes/E0415.stderr deleted file mode 100644 index 5e5cfe16e5038..0000000000000 --- a/src/test/ui/error-codes/E0415.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0415]: identifier `f` is bound more than once in this parameter list - --> $DIR/E0415.rs:11:16 - | -11 | fn foo(f: i32, f: i32) {} //~ ERROR E0415 - | ^ used as parameter more than once - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0416.stderr b/src/test/ui/error-codes/E0416.stderr deleted file mode 100644 index a48a3ade5c9a4..0000000000000 --- a/src/test/ui/error-codes/E0416.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0416]: identifier `x` is bound more than once in the same pattern - --> $DIR/E0416.rs:13:13 - | -13 | (x, x) => {} //~ ERROR E0416 - | ^ used in a pattern more than once - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0423.stderr b/src/test/ui/error-codes/E0423.stderr deleted file mode 100644 index aee398efeddee..0000000000000 --- a/src/test/ui/error-codes/E0423.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0423]: expected function, found struct `Foo` - --> $DIR/E0423.rs:14:13 - | -14 | let f = Foo(); //~ ERROR E0423 - | ^^^ did you mean `Foo { /* fields */ }`? - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0424.stderr b/src/test/ui/error-codes/E0424.stderr deleted file mode 100644 index d1fd432f4f032..0000000000000 --- a/src/test/ui/error-codes/E0424.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0424]: expected value, found module `self` - --> $DIR/E0424.rs:17:9 - | -17 | self.bar(); //~ ERROR E0424 - | ^^^^ `self` value is only available in methods with `self` parameter - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0425.stderr b/src/test/ui/error-codes/E0425.stderr deleted file mode 100644 index 250ecaeb368ee..0000000000000 --- a/src/test/ui/error-codes/E0425.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0425]: cannot find value `elf` in this scope - --> $DIR/E0425.rs:13:9 - | -13 | elf; //~ ERROR E0425 - | ^^^ not found in this scope - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0426.stderr b/src/test/ui/error-codes/E0426.stderr deleted file mode 100644 index bb05effd732cd..0000000000000 --- a/src/test/ui/error-codes/E0426.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0426]: use of undeclared label `'a` - --> $DIR/E0426.rs:13:15 - | -13 | break 'a; - | ^^ undeclared label `'a` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0428.stderr b/src/test/ui/error-codes/E0428.stderr deleted file mode 100644 index c739536c0ab55..0000000000000 --- a/src/test/ui/error-codes/E0428.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0428]: the name `Bar` is defined multiple times - --> $DIR/E0428.rs:12:1 - | -11 | struct Bar; //~ previous definition of the type `Bar` here - | ----------- previous definition of the type `Bar` here -12 | struct Bar; //~ ERROR E0428 - | ^^^^^^^^^^^ `Bar` redefined here - | - = note: `Bar` must be defined only once in the type namespace of this module - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0429.stderr b/src/test/ui/error-codes/E0429.stderr deleted file mode 100644 index 96cf50500fdb4..0000000000000 --- a/src/test/ui/error-codes/E0429.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0429]: `self` imports are only allowed within a { } list - --> $DIR/E0429.rs:11:5 - | -11 | use std::fmt::self; //~ ERROR E0429 - | ^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0430.stderr b/src/test/ui/error-codes/E0430.stderr deleted file mode 100644 index b5c80aa23f62d..0000000000000 --- a/src/test/ui/error-codes/E0430.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0430]: `self` import can only appear once in an import list - --> $DIR/E0430.rs:11:16 - | -11 | use std::fmt::{self, self}; //~ ERROR E0430 - | ^^^^ ---- another `self` import appears here - | | - | can only appear once in an import list - -error[E0252]: the name `fmt` is defined multiple times - --> $DIR/E0430.rs:11:22 - | -11 | use std::fmt::{self, self}; //~ ERROR E0430 - | ---- ^^^^ `fmt` reimported here - | | - | previous import of the module `fmt` here - | - = note: `fmt` must be defined only once in the type namespace of this module -help: You can use `as` to change the binding name of the import - | -11 | use std::fmt::{self, self as other_fmt}; //~ ERROR E0430 - | ^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0431.stderr b/src/test/ui/error-codes/E0431.stderr deleted file mode 100644 index c7a786b7402d2..0000000000000 --- a/src/test/ui/error-codes/E0431.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0431]: `self` import can only appear in an import list with a non-empty prefix - --> $DIR/E0431.rs:11:6 - | -11 | use {self}; //~ ERROR E0431 - | ^^^^ can only appear in an import list with a non-empty prefix - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0432.stderr b/src/test/ui/error-codes/E0432.stderr deleted file mode 100644 index 6d808f038a333..0000000000000 --- a/src/test/ui/error-codes/E0432.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0432]: unresolved import `something` - --> $DIR/E0432.rs:11:5 - | -11 | use something::Foo; //~ ERROR E0432 - | ^^^^^^^^^ Maybe a missing `extern crate something;`? - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0433.stderr b/src/test/ui/error-codes/E0433.stderr deleted file mode 100644 index 691c5922f8fbc..0000000000000 --- a/src/test/ui/error-codes/E0433.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0433]: failed to resolve. Use of undeclared type or module `HashMap` - --> $DIR/E0433.rs:12:15 - | -12 | let map = HashMap::new(); //~ ERROR E0433 - | ^^^^^^^ Use of undeclared type or module `HashMap` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0434.stderr b/src/test/ui/error-codes/E0434.stderr deleted file mode 100644 index 06880acdb3573..0000000000000 --- a/src/test/ui/error-codes/E0434.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0434]: can't capture dynamic environment in a fn item - --> $DIR/E0434.rs:14:9 - | -14 | y //~ ERROR E0434 - | ^ - | - = help: use the `|| { ... }` closure form instead - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0435.stderr b/src/test/ui/error-codes/E0435.stderr deleted file mode 100644 index 855903b7ec35e..0000000000000 --- a/src/test/ui/error-codes/E0435.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/E0435.rs:13:17 - | -13 | let _: [u8; foo]; //~ ERROR E0435 - | ^^^ non-constant value - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0437.stderr b/src/test/ui/error-codes/E0437.stderr deleted file mode 100644 index ffad571d06125..0000000000000 --- a/src/test/ui/error-codes/E0437.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0437]: type `Bar` is not a member of trait `Foo` - --> $DIR/E0437.rs:14:5 - | -14 | type Bar = bool; //~ ERROR E0437 - | ^^^^^^^^^^^^^^^^ not a member of trait `Foo` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0438.stderr b/src/test/ui/error-codes/E0438.stderr deleted file mode 100644 index df587395356f1..0000000000000 --- a/src/test/ui/error-codes/E0438.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0438]: const `BAR` is not a member of trait `Bar` - --> $DIR/E0438.rs:15:5 - | -15 | const BAR: bool = true; //~ ERROR E0438 - | ^^^^^^^^^^^^^^^^^^^^^^^ not a member of trait `Bar` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0439.stderr b/src/test/ui/error-codes/E0439.stderr deleted file mode 100644 index 77930d5e08d94..0000000000000 --- a/src/test/ui/error-codes/E0439.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0439]: invalid `simd_shuffle`, needs length: `simd_shuffle` - --> $DIR/E0439.rs:14:5 - | -14 | fn simd_shuffle(a: A, b: A, c: [u32; 8]) -> B; //~ ERROR E0439 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0440.stderr b/src/test/ui/error-codes/E0440.stderr deleted file mode 100644 index 83210a996e0e1..0000000000000 --- a/src/test/ui/error-codes/E0440.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0440]: platform-specific intrinsic has wrong number of type parameters: found 1, expected 0 - --> $DIR/E0440.rs:18:5 - | -18 | fn x86_mm_movemask_pd(x: f64x2) -> i32; //~ ERROR E0440 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0441.stderr b/src/test/ui/error-codes/E0441.stderr deleted file mode 100644 index 34a387e64597a..0000000000000 --- a/src/test/ui/error-codes/E0441.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0441]: unrecognized platform-specific intrinsic function: `x86_mm_adds_ep16` - --> $DIR/E0441.rs:18:5 - | -18 | fn x86_mm_adds_ep16(x: i16x8, y: i16x8) -> i16x8; //~ ERROR E0441 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0442.stderr b/src/test/ui/error-codes/E0442.stderr deleted file mode 100644 index 6f19fd17eb2df..0000000000000 --- a/src/test/ui/error-codes/E0442.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0442]: intrinsic argument 1 has wrong type: found vector with length 16, expected length 8 - --> $DIR/E0442.rs:23:5 - | -23 | fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0442]: intrinsic argument 2 has wrong type: found vector with length 4, expected length 8 - --> $DIR/E0442.rs:23:5 - | -23 | fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0442]: intrinsic return value has wrong type: found vector with length 2, expected length 8 - --> $DIR/E0442.rs:23:5 - | -23 | fn x86_mm_adds_epi16(x: i8x16, y: i32x4) -> i64x2; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/error-codes/E0443.stderr b/src/test/ui/error-codes/E0443.stderr deleted file mode 100644 index ebf8ef5ccf102..0000000000000 --- a/src/test/ui/error-codes/E0443.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0443]: intrinsic return value has wrong type: found `i64x8`, expected `i16x8` which was used for this vector type previously in this signature - --> $DIR/E0443.rs:20:5 - | -20 | fn x86_mm_adds_epi16(x: i16x8, y: i16x8) -> i64x8; //~ ERROR E0443 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0444.stderr b/src/test/ui/error-codes/E0444.stderr deleted file mode 100644 index e44d9457045c4..0000000000000 --- a/src/test/ui/error-codes/E0444.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0444]: platform-specific intrinsic has invalid number of arguments: found 3, expected 1 - --> $DIR/E0444.rs:18:5 - | -18 | fn x86_mm_movemask_pd(x: f64x2, y: f64x2, z: f64x2) -> i32; //~ ERROR E0444 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0445.stderr b/src/test/ui/error-codes/E0445.stderr deleted file mode 100644 index 7b599543e00c6..0000000000000 --- a/src/test/ui/error-codes/E0445.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0445]: private trait `Foo` in public interface - --> $DIR/E0445.rs:15:1 - | -15 | pub trait Bar : Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait - -error[E0445]: private trait `Foo` in public interface - --> $DIR/E0445.rs:18:1 - | -18 | pub struct Bar2(pub T); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait - -error[E0445]: private trait `Foo` in public interface - --> $DIR/E0445.rs:21:1 - | -21 | pub fn foo (t: T) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private trait - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/error-codes/E0446.stderr b/src/test/ui/error-codes/E0446.stderr deleted file mode 100644 index 1b61ca9b1773b..0000000000000 --- a/src/test/ui/error-codes/E0446.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0446]: private type `Foo::Bar` in public interface - --> $DIR/E0446.rs:14:5 - | -14 | / pub fn bar() -> Bar { //~ ERROR E0446 -15 | | Bar(0) -16 | | } - | |_____^ can't leak private type - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0449.stderr b/src/test/ui/error-codes/E0449.stderr deleted file mode 100644 index 2270167303a80..0000000000000 --- a/src/test/ui/error-codes/E0449.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0449]: unnecessary visibility qualifier - --> $DIR/E0449.rs:17:1 - | -17 | pub impl Bar {} //~ ERROR E0449 - | ^^^^^^^^^^^^^^^ `pub` not needed here - | - = note: place qualifiers on individual impl items instead - -error[E0449]: unnecessary visibility qualifier - --> $DIR/E0449.rs:19:1 - | -19 | / pub impl Foo for Bar { //~ ERROR E0449 -20 | | pub fn foo() {} //~ ERROR E0449 -21 | | } - | |_^ `pub` not needed here - -error[E0449]: unnecessary visibility qualifier - --> $DIR/E0449.rs:20:5 - | -20 | pub fn foo() {} //~ ERROR E0449 - | ^^^^^^^^^^^^^^^ `pub` not needed here - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/error-codes/E0451.stderr b/src/test/ui/error-codes/E0451.stderr deleted file mode 100644 index 0c29bee849b3b..0000000000000 --- a/src/test/ui/error-codes/E0451.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0451]: field `b` of struct `Bar::Foo` is private - --> $DIR/E0451.rs:24:23 - | -24 | let Bar::Foo{a:a, b:b} = foo; //~ ERROR E0451 - | ^^^ field `b` is private - -error[E0451]: field `b` of struct `Bar::Foo` is private - --> $DIR/E0451.rs:28:29 - | -28 | let f = Bar::Foo{ a: 0, b: 0 }; //~ ERROR E0451 - | ^^^^ field `b` is private - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0452.stderr b/src/test/ui/error-codes/E0452.stderr deleted file mode 100644 index d63d0edc2c60c..0000000000000 --- a/src/test/ui/error-codes/E0452.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0452]: malformed lint attribute - --> $DIR/E0452.rs:11:10 - | -11 | #![allow(foo = "")] //~ ERROR E0452 - | ^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0453.stderr b/src/test/ui/error-codes/E0453.stderr deleted file mode 100644 index 467784f336745..0000000000000 --- a/src/test/ui/error-codes/E0453.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0453]: allow(non_snake_case) overruled by outer forbid(non_snake_case) - --> $DIR/E0453.rs:13:9 - | -11 | #![forbid(non_snake_case)] - | -------------- `forbid` level set here -12 | -13 | #[allow(non_snake_case)] - | ^^^^^^^^^^^^^^ overruled by previous forbid - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0454.stderr b/src/test/ui/error-codes/E0454.stderr deleted file mode 100644 index aee8b53e39dd5..0000000000000 --- a/src/test/ui/error-codes/E0454.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0454]: #[link(name = "")] given with empty name - --> $DIR/E0454.rs:11:1 - | -11 | #[link(name = "")] extern {} - | ^^^^^^^^^^^^^^^^^^ empty name given - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0458.stderr b/src/test/ui/error-codes/E0458.stderr deleted file mode 100644 index 9cdd0d5f3003a..0000000000000 --- a/src/test/ui/error-codes/E0458.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0458]: unknown kind: `wonderful_unicorn` - --> $DIR/E0458.rs:11:1 - | -11 | #[link(kind = "wonderful_unicorn")] extern {} //~ ERROR E0458 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unknown kind - -error[E0459]: #[link(...)] specified without `name = "foo"` - --> $DIR/E0458.rs:11:1 - | -11 | #[link(kind = "wonderful_unicorn")] extern {} //~ ERROR E0458 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `name` argument - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0459.stderr b/src/test/ui/error-codes/E0459.stderr deleted file mode 100644 index 512788e1948a7..0000000000000 --- a/src/test/ui/error-codes/E0459.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0459]: #[link(...)] specified without `name = "foo"` - --> $DIR/E0459.rs:11:1 - | -11 | #[link(kind = "dylib")] extern {} //~ ERROR E0459 - | ^^^^^^^^^^^^^^^^^^^^^^^ missing `name` argument - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0463.stderr b/src/test/ui/error-codes/E0463.stderr deleted file mode 100644 index 208c00cc7c977..0000000000000 --- a/src/test/ui/error-codes/E0463.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0463]: can't find crate for `cookie_monster` - --> $DIR/E0463.rs:12:11 - | -12 | #![plugin(cookie_monster)] - | ^^^^^^^^^^^^^^ can't find crate - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0478.stderr b/src/test/ui/error-codes/E0478.stderr deleted file mode 100644 index f909fa48c2769..0000000000000 --- a/src/test/ui/error-codes/E0478.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0478]: lifetime bound not satisfied - --> $DIR/E0478.rs:14:5 - | -14 | child: Box + 'SnowWhite>, //~ ERROR E0478 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: lifetime parameter instantiated with the lifetime 'SnowWhite as defined on the struct at 13:1 - --> $DIR/E0478.rs:13:1 - | -13 | struct Prince<'kiss, 'SnowWhite> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: but lifetime parameter must outlive the lifetime 'kiss as defined on the struct at 13:1 - --> $DIR/E0478.rs:13:1 - | -13 | struct Prince<'kiss, 'SnowWhite> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0492.stderr b/src/test/ui/error-codes/E0492.stderr deleted file mode 100644 index c19896623128f..0000000000000 --- a/src/test/ui/error-codes/E0492.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead - --> $DIR/E0492.rs:14:34 - | -14 | static B: &'static AtomicUsize = &A; //~ ERROR E0492 - | ^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0494.stderr b/src/test/ui/error-codes/E0494.stderr deleted file mode 100644 index 1d5ded5bd9aa1..0000000000000 --- a/src/test/ui/error-codes/E0494.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0494]: cannot refer to the interior of another static, use a constant instead - --> $DIR/E0494.rs:16:27 - | -16 | static A : &'static u32 = &S.a; //~ ERROR E0494 - | ^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0496.stderr b/src/test/ui/error-codes/E0496.stderr deleted file mode 100644 index ab9a08a534897..0000000000000 --- a/src/test/ui/error-codes/E0496.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0496]: lifetime name `'a` shadows a lifetime name that is already in scope - --> $DIR/E0496.rs:16:10 - | -15 | impl<'a> Foo<'a> { - | -- first declared here -16 | fn f<'a>(x: &'a i32) { //~ ERROR E0496 - | ^^ lifetime 'a already in scope - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0499.stderr b/src/test/ui/error-codes/E0499.stderr deleted file mode 100644 index c3057d9b558d7..0000000000000 --- a/src/test/ui/error-codes/E0499.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0499]: cannot borrow `i` as mutable more than once at a time - --> $DIR/E0499.rs:14:22 - | -13 | let mut x = &mut i; - | - first mutable borrow occurs here -14 | let mut a = &mut i; //~ ERROR E0499 - | ^ second mutable borrow occurs here -15 | } - | - first borrow ends here - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0502.stderr b/src/test/ui/error-codes/E0502.stderr deleted file mode 100644 index e578cffe56463..0000000000000 --- a/src/test/ui/error-codes/E0502.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0502]: cannot borrow `*a` as mutable because `a` is also borrowed as immutable - --> $DIR/E0502.rs:14:9 - | -13 | let ref y = a; - | ----- immutable borrow occurs here -14 | bar(a); //~ ERROR E0502 - | ^ mutable borrow occurs here -15 | } - | - immutable borrow ends here - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0503.stderr b/src/test/ui/error-codes/E0503.stderr deleted file mode 100644 index 112e2c477802e..0000000000000 --- a/src/test/ui/error-codes/E0503.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0503]: cannot use `value` because it was mutably borrowed - --> $DIR/E0503.rs:14:16 - | -13 | let _borrow = &mut value; - | ----- borrow of `value` occurs here -14 | let _sum = value + 1; //~ ERROR E0503 - | ^^^^^ use of borrowed `value` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0504.stderr b/src/test/ui/error-codes/E0504.stderr deleted file mode 100644 index 0f1b183dba92f..0000000000000 --- a/src/test/ui/error-codes/E0504.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0504]: cannot move `fancy_num` into closure because it is borrowed - --> $DIR/E0504.rs:20:40 - | -17 | let fancy_ref = &fancy_num; - | --------- borrow of `fancy_num` occurs here -... -20 | println!("child function: {}", fancy_num.num); //~ ERROR E0504 - | ^^^^^^^^^ move into closure occurs here - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0505.stderr b/src/test/ui/error-codes/E0505.stderr deleted file mode 100644 index dfb327d48eaa5..0000000000000 --- a/src/test/ui/error-codes/E0505.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/E0505.rs:19:13 - | -18 | let _ref_to_val: &Value = &x; - | - borrow of `x` occurs here -19 | eat(x); //~ ERROR E0505 - | ^ move out of `x` occurs here - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0507.stderr b/src/test/ui/error-codes/E0507.stderr deleted file mode 100644 index 407ebb8fc7be5..0000000000000 --- a/src/test/ui/error-codes/E0507.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0507]: cannot move out of borrowed content - --> $DIR/E0507.rs:22:5 - | -22 | x.borrow().nothing_is_true(); //~ ERROR E0507 - | ^^^^^^^^^^ cannot move out of borrowed content - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0509.stderr b/src/test/ui/error-codes/E0509.stderr deleted file mode 100644 index 6da0fdbeb34e1..0000000000000 --- a/src/test/ui/error-codes/E0509.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0509]: cannot move out of type `DropStruct`, which implements the `Drop` trait - --> $DIR/E0509.rs:26:23 - | -26 | let fancy_field = drop_struct.fancy; //~ ERROR E0509 - | ^^^^^^^^^^^^^^^^^ - | | - | cannot move out of here - | help: consider using a reference instead: `&drop_struct.fancy` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0511.stderr b/src/test/ui/error-codes/E0511.stderr deleted file mode 100644 index b714350393b6a..0000000000000 --- a/src/test/ui/error-codes/E0511.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/E0511.rs:18:14 - | -18 | unsafe { simd_add(0, 1); } //~ ERROR E0511 - | ^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0512.stderr b/src/test/ui/error-codes/E0512.stderr deleted file mode 100644 index ad25bb216a390..0000000000000 --- a/src/test/ui/error-codes/E0512.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0512]: transmute called with types of different sizes - --> $DIR/E0512.rs:14:23 - | -14 | unsafe { takes_u8(::std::mem::transmute(0u16)); } //~ ERROR E0512 - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: source type: u16 (16 bits) - = note: target type: u8 (8 bits) - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0516.stderr b/src/test/ui/error-codes/E0516.stderr deleted file mode 100644 index 620929653f665..0000000000000 --- a/src/test/ui/error-codes/E0516.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0516]: `typeof` is a reserved keyword but unimplemented - --> $DIR/E0516.rs:12:12 - | -12 | let x: typeof(92) = 92; //~ ERROR E0516 - | ^^^^^^^^^^ reserved keyword - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0517.stderr b/src/test/ui/error-codes/E0517.stderr deleted file mode 100644 index 968c47fa7a26f..0000000000000 --- a/src/test/ui/error-codes/E0517.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error[E0517]: attribute should be applied to struct, enum or union - --> $DIR/E0517.rs:11:8 - | -11 | #[repr(C)] //~ ERROR: E0517 - | ^ -12 | type Foo = u8; - | -------------- not a struct, enum or union - -error[E0517]: attribute should be applied to struct or union - --> $DIR/E0517.rs:14:8 - | -14 | #[repr(packed)] //~ ERROR: E0517 - | ^^^^^^ -15 | enum Foo2 {Bar, Baz} - | -------------------- not a struct or union - -error[E0517]: attribute should be applied to enum - --> $DIR/E0517.rs:17:8 - | -17 | #[repr(u8)] //~ ERROR: E0517 - | ^^ -18 | struct Foo3 {bar: bool, baz: bool} - | ---------------------------------- not an enum - -error[E0517]: attribute should be applied to struct, enum or union - --> $DIR/E0517.rs:20:8 - | -20 | #[repr(C)] //~ ERROR: E0517 - | ^ -21 | / impl Foo3 { -22 | | } - | |_- not a struct, enum or union - -error: aborting due to 4 previous errors - diff --git a/src/test/ui/error-codes/E0518.stderr b/src/test/ui/error-codes/E0518.stderr deleted file mode 100644 index 99a4a63cc9f2e..0000000000000 --- a/src/test/ui/error-codes/E0518.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0518]: attribute should be applied to function - --> $DIR/E0518.rs:11:1 - | -11 | #[inline(always)] //~ ERROR: E0518 - | ^^^^^^^^^^^^^^^^^ -12 | struct Foo; - | ----------- not a function - -error[E0518]: attribute should be applied to function - --> $DIR/E0518.rs:14:1 - | -14 | #[inline(never)] //~ ERROR: E0518 - | ^^^^^^^^^^^^^^^^ -15 | / impl Foo { -16 | | } - | |_- not a function - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0520.stderr b/src/test/ui/error-codes/E0520.stderr deleted file mode 100644 index 272c38859ab0a..0000000000000 --- a/src/test/ui/error-codes/E0520.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0520]: `fly` specializes an item from a parent `impl`, but that item is not marked `default` - --> $DIR/E0520.rs:26:5 - | -21 | / impl SpaceLlama for T { -22 | | fn fly(&self) {} -23 | | } - | |_- parent `impl` is here -... -26 | default fn fly(&self) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ cannot specialize default item `fly` - | - = note: to specialize, `fly` in the parent `impl` must be marked `default` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0522.stderr b/src/test/ui/error-codes/E0522.stderr deleted file mode 100644 index 819fab0088f55..0000000000000 --- a/src/test/ui/error-codes/E0522.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0601]: main function not found - -error[E0522]: definition of an unknown language item: `cookie` - --> $DIR/E0522.rs:13:1 - | -13 | #[lang = "cookie"] - | ^^^^^^^^^^^^^^^^^^ definition of unknown language item `cookie` - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0527.stderr b/src/test/ui/error-codes/E0527.stderr deleted file mode 100644 index 7cd705e6d0b9d..0000000000000 --- a/src/test/ui/error-codes/E0527.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0527]: pattern requires 2 elements but array has 4 - --> $DIR/E0527.rs:16:10 - | -16 | &[a, b] => { - | ^^^^^^ expected 4 elements - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0528.stderr b/src/test/ui/error-codes/E0528.stderr deleted file mode 100644 index ff75b07ced602..0000000000000 --- a/src/test/ui/error-codes/E0528.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0528]: pattern requires at least 3 elements but array has 2 - --> $DIR/E0528.rs:16:10 - | -16 | &[a, b, c, rest..] => { - | ^^^^^^^^^^^^^^^^^ pattern cannot match array of 2 elements - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0529.stderr b/src/test/ui/error-codes/E0529.stderr deleted file mode 100644 index be9039be2b668..0000000000000 --- a/src/test/ui/error-codes/E0529.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0529]: expected an array or slice, found `f32` - --> $DIR/E0529.rs:16:9 - | -16 | [a, b] => { - | ^^^^^^ pattern cannot match with input type `f32` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0530.stderr b/src/test/ui/error-codes/E0530.stderr deleted file mode 100644 index 7c0306cc772fa..0000000000000 --- a/src/test/ui/error-codes/E0530.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0530]: match bindings cannot shadow statics - --> $DIR/E0530.rs:16:9 - | -12 | static TEST: i32 = 0; - | --------------------- a static `TEST` is defined here -... -16 | TEST => {} //~ ERROR E0530 - | ^^^^ cannot be named the same as a static - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0532.stderr b/src/test/ui/error-codes/E0532.stderr deleted file mode 100644 index 4eb91ce35d44a..0000000000000 --- a/src/test/ui/error-codes/E0532.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0532]: expected tuple struct/variant, found constant `StructConst1` - --> $DIR/E0532.rs:15:9 - | -15 | StructConst1(_) => { }, - | ^^^^^^^^^^^^ not a tuple struct/variant - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0534.stderr b/src/test/ui/error-codes/E0534.stderr deleted file mode 100644 index fe7a5483e59df..0000000000000 --- a/src/test/ui/error-codes/E0534.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0534]: expected one argument - --> $DIR/E0534.rs:11:1 - | -11 | #[inline()] //~ ERROR E0534 - | ^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0558.stderr b/src/test/ui/error-codes/E0558.stderr deleted file mode 100644 index c116201794d47..0000000000000 --- a/src/test/ui/error-codes/E0558.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0558]: export_name attribute has invalid format - --> $DIR/E0558.rs:11:1 - | -11 | #[export_name] - | ^^^^^^^^^^^^^^ did you mean #[export_name="*"]? - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0559.stderr b/src/test/ui/error-codes/E0559.stderr deleted file mode 100644 index 5d145a9518095..0000000000000 --- a/src/test/ui/error-codes/E0559.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0559]: variant `Field::Fool` has no field named `joke` - --> $DIR/E0559.rs:16:27 - | -16 | let s = Field::Fool { joke: 0 }; - | ^^^^^ `Field::Fool` does not have this field - | - = note: available fields are: `x` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0560.stderr b/src/test/ui/error-codes/E0560.stderr deleted file mode 100644 index a0185aa8af64b..0000000000000 --- a/src/test/ui/error-codes/E0560.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0560]: struct `Simba` has no field named `father` - --> $DIR/E0560.rs:16:32 - | -16 | let s = Simba { mother: 1, father: 0 }; - | ^^^^^^^ `Simba` does not have this field - | - = note: available fields are: `mother` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0565-1.stderr b/src/test/ui/error-codes/E0565-1.stderr deleted file mode 100644 index 65b917ad4bd32..0000000000000 --- a/src/test/ui/error-codes/E0565-1.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0565]: unsupported literal - --> $DIR/E0565-1.rs:14:14 - | -14 | #[deprecated("since")] //~ ERROR E0565 - | ^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0565.stderr b/src/test/ui/error-codes/E0565.stderr deleted file mode 100644 index 0041b7689a671..0000000000000 --- a/src/test/ui/error-codes/E0565.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0565]: unsupported literal - --> $DIR/E0565.rs:14:8 - | -14 | #[repr("C")] //~ ERROR E0565 - | ^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0572.stderr b/src/test/ui/error-codes/E0572.stderr deleted file mode 100644 index cad313b90a613..0000000000000 --- a/src/test/ui/error-codes/E0572.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0572]: return statement outside of function body - --> $DIR/E0572.rs:11:18 - | -11 | const FOO: u32 = return 0; //~ ERROR E0572 - | ^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0582.stderr b/src/test/ui/error-codes/E0582.stderr deleted file mode 100644 index ac20683402302..0000000000000 --- a/src/test/ui/error-codes/E0582.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0582]: binding for associated type `Output` references lifetime `'a`, which does not appear in the trait input types - --> $DIR/E0582.rs:38:30 - | -38 | where F: for<'a> Fn() -> Option<&'a i32> - | ^^^^^^^^^^^^^^^ - -error[E0582]: binding for associated type `Item` references lifetime `'a`, which does not appear in the trait input types - --> $DIR/E0582.rs:46:31 - | -46 | where F: for<'a> Iterator - | ^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0585.stderr b/src/test/ui/error-codes/E0585.stderr deleted file mode 100644 index 49967f4ad81d5..0000000000000 --- a/src/test/ui/error-codes/E0585.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0585]: found a documentation comment that doesn't document anything - --> $DIR/E0585.rs:12:5 - | -12 | /// Hello! I'm useless... - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: doc comments must come before what they document, maybe a comment was intended with `//`? - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0586.stderr b/src/test/ui/error-codes/E0586.stderr deleted file mode 100644 index 3cf16bdc3c318..0000000000000 --- a/src/test/ui/error-codes/E0586.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0586]: inclusive range with no end - --> $DIR/E0586.rs:13:22 - | -13 | let x = &tmp[1..=]; //~ ERROR E0586 - | ^ - | - = help: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0597.stderr b/src/test/ui/error-codes/E0597.stderr deleted file mode 100644 index 7316ee6475f18..0000000000000 --- a/src/test/ui/error-codes/E0597.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0597]: `y` does not live long enough - --> $DIR/E0597.rs:18:17 - | -18 | x.x = Some(&y); - | ^ borrowed value does not live long enough -19 | //~^ `y` does not live long enough [E0597] -20 | } - | - `y` dropped here while still borrowed - | - = note: values in a scope are dropped in the opposite order they are created - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0599.stderr b/src/test/ui/error-codes/E0599.stderr deleted file mode 100644 index 0274506926f8d..0000000000000 --- a/src/test/ui/error-codes/E0599.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0599]: no associated item named `NotEvenReal` found for type `Foo` in the current scope - --> $DIR/E0599.rs:14:15 - | -11 | struct Foo; - | ----------- associated item `NotEvenReal` not found for this -... -14 | || if let Foo::NotEvenReal() = Foo {}; //~ ERROR E0599 - | ^^^^^^^^^^^^^^^^^^ associated item not found in `Foo` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0600.stderr b/src/test/ui/error-codes/E0600.stderr deleted file mode 100644 index fec5f4169196e..0000000000000 --- a/src/test/ui/error-codes/E0600.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0600]: cannot apply unary operator `!` to type `&'static str` - --> $DIR/E0600.rs:12:5 - | -12 | !"a"; //~ ERROR E0600 - | ^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0602.stderr b/src/test/ui/error-codes/E0602.stderr deleted file mode 100644 index cb6c05326e230..0000000000000 --- a/src/test/ui/error-codes/E0602.stderr +++ /dev/null @@ -1,6 +0,0 @@ -error[E0602]: unknown lint: `bogus` - | - = note: requested on the command line with `-D bogus` - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0603.stderr b/src/test/ui/error-codes/E0603.stderr deleted file mode 100644 index 1d8e2fa9340e3..0000000000000 --- a/src/test/ui/error-codes/E0603.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0603]: constant `PRIVATE` is private - --> $DIR/E0603.rs:16:5 - | -16 | SomeModule::PRIVATE; //~ ERROR E0603 - | ^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0604.stderr b/src/test/ui/error-codes/E0604.stderr deleted file mode 100644 index 78d1c4dd47654..0000000000000 --- a/src/test/ui/error-codes/E0604.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0604]: only `u8` can be cast as `char`, not `u32` - --> $DIR/E0604.rs:12:5 - | -12 | 1u32 as char; //~ ERROR E0604 - | ^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0605.stderr b/src/test/ui/error-codes/E0605.stderr deleted file mode 100644 index 0b44de25fb5cd..0000000000000 --- a/src/test/ui/error-codes/E0605.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0605]: non-primitive cast: `u8` as `std::vec::Vec` - --> $DIR/E0605.rs:13:5 - | -13 | x as Vec; //~ ERROR E0605 - | ^^^^^^^^^^^^ - | - = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait - -error[E0605]: non-primitive cast: `*const u8` as `&u8` - --> $DIR/E0605.rs:16:5 - | -16 | v as &u8; //~ ERROR E0605 - | ^^^^^^^^ - | - = note: an `as` expression can only be used to convert between primitive types. Consider using the `From` trait - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0606.stderr b/src/test/ui/error-codes/E0606.stderr deleted file mode 100644 index 17051da1319d9..0000000000000 --- a/src/test/ui/error-codes/E0606.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0606]: casting `&u8` as `u8` is invalid - --> $DIR/E0606.rs:12:5 - | -12 | &0u8 as u8; //~ ERROR E0606 - | ^^^^^^^^^^ cannot cast `&u8` as `u8` - | -help: did you mean `*&0u8`? - --> $DIR/E0606.rs:12:5 - | -12 | &0u8 as u8; //~ ERROR E0606 - | ^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0607.stderr b/src/test/ui/error-codes/E0607.stderr deleted file mode 100644 index 5dfe6ad59b879..0000000000000 --- a/src/test/ui/error-codes/E0607.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0607]: cannot cast thin pointer `*const u8` to fat pointer `*const [u8]` - --> $DIR/E0607.rs:13:5 - | -13 | v as *const [u8]; //~ ERROR E0607 - | ^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0608.stderr b/src/test/ui/error-codes/E0608.stderr deleted file mode 100644 index ab75fe82af350..0000000000000 --- a/src/test/ui/error-codes/E0608.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0608]: cannot index into a value of type `u8` - --> $DIR/E0608.rs:12:5 - | -12 | 0u8[2]; //~ ERROR E0608 - | ^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0609.stderr b/src/test/ui/error-codes/E0609.stderr deleted file mode 100644 index 561164cd277dc..0000000000000 --- a/src/test/ui/error-codes/E0609.stderr +++ /dev/null @@ -1,16 +0,0 @@ -error[E0609]: no field `foo` on type `Foo` - --> $DIR/E0609.rs:18:15 - | -18 | let _ = x.foo; //~ ERROR E0609 - | ^^^ unknown field - | - = note: available fields are: `x` - -error[E0609]: no field `1` on type `Bar` - --> $DIR/E0609.rs:21:5 - | -21 | y.1; //~ ERROR E0609 - | ^^^ - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0610.stderr b/src/test/ui/error-codes/E0610.stderr deleted file mode 100644 index 351e9208e95bd..0000000000000 --- a/src/test/ui/error-codes/E0610.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0610]: `{integer}` is a primitive type and therefore doesn't have fields - --> $DIR/E0610.rs:13:15 - | -13 | let _ = x.foo; //~ ERROR E0610 - | ^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0611.stderr b/src/test/ui/error-codes/E0611.stderr deleted file mode 100644 index 33fe78bc18c60..0000000000000 --- a/src/test/ui/error-codes/E0611.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0611]: field `0` of tuple-struct `a::Foo` is private - --> $DIR/E0611.rs:21:4 - | -21 | y.0; //~ ERROR E0611 - | ^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0612.stderr b/src/test/ui/error-codes/E0612.stderr deleted file mode 100644 index 21fdaf84dc94d..0000000000000 --- a/src/test/ui/error-codes/E0612.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0612]: attempted out-of-bounds tuple index `1` on type `Foo` - --> $DIR/E0612.rs:15:4 - | -15 | y.1; //~ ERROR E0612 - | ^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0614.stderr b/src/test/ui/error-codes/E0614.stderr deleted file mode 100644 index 242cc36f0b9a1..0000000000000 --- a/src/test/ui/error-codes/E0614.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0614]: type `u32` cannot be dereferenced - --> $DIR/E0614.rs:13:5 - | -13 | *y; //~ ERROR E0614 - | ^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0615.stderr b/src/test/ui/error-codes/E0615.stderr deleted file mode 100644 index fb3f9269f7c2b..0000000000000 --- a/src/test/ui/error-codes/E0615.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0615]: attempted to take value of method `method` on type `Foo` - --> $DIR/E0615.rs:21:7 - | -21 | f.method; //~ ERROR E0615 - | ^^^^^^ - | - = help: maybe a `()` to call it is missing? - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0616.stderr b/src/test/ui/error-codes/E0616.stderr deleted file mode 100644 index 1dccd06b376d9..0000000000000 --- a/src/test/ui/error-codes/E0616.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0616]: field `x` of struct `a::Foo` is private - --> $DIR/E0616.rs:23:5 - | -23 | f.x; //~ ERROR E0616 - | ^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0617.stderr b/src/test/ui/error-codes/E0617.stderr deleted file mode 100644 index 49d63538624e6..0000000000000 --- a/src/test/ui/error-codes/E0617.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error[E0617]: can't pass `f32` to variadic function - --> $DIR/E0617.rs:19:36 - | -19 | printf(::std::ptr::null(), 0f32); - | ^^^^ help: cast the value to `c_double`: `0f32 as c_double` - -error[E0617]: can't pass `i8` to variadic function - --> $DIR/E0617.rs:22:36 - | -22 | printf(::std::ptr::null(), 0i8); - | ^^^ help: cast the value to `c_int`: `0i8 as c_int` - -error[E0617]: can't pass `i16` to variadic function - --> $DIR/E0617.rs:25:36 - | -25 | printf(::std::ptr::null(), 0i16); - | ^^^^ help: cast the value to `c_int`: `0i16 as c_int` - -error[E0617]: can't pass `u8` to variadic function - --> $DIR/E0617.rs:28:36 - | -28 | printf(::std::ptr::null(), 0u8); - | ^^^ help: cast the value to `c_uint`: `0u8 as c_uint` - -error[E0617]: can't pass `u16` to variadic function - --> $DIR/E0617.rs:31:36 - | -31 | printf(::std::ptr::null(), 0u16); - | ^^^^ help: cast the value to `c_uint`: `0u16 as c_uint` - -error[E0617]: can't pass `unsafe extern "C" fn(*const i8, ...) {printf}` to variadic function - --> $DIR/E0617.rs:34:36 - | -34 | printf(::std::ptr::null(), printf); - | ^^^^^^ -help: cast the value to `unsafe extern "C" fn(*const i8, ...)` - | -34 | printf(::std::ptr::null(), printf as unsafe extern "C" fn(*const i8, ...)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 6 previous errors - diff --git a/src/test/ui/error-codes/E0618.stderr b/src/test/ui/error-codes/E0618.stderr deleted file mode 100644 index 8702437659693..0000000000000 --- a/src/test/ui/error-codes/E0618.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0618]: expected function, found enum variant `X::Entry` - --> $DIR/E0618.rs:16:5 - | -12 | Entry, - | ----- `X::Entry` defined here -... -16 | X::Entry(); - | ^^^^^^^^^^ not a function -help: `X::Entry` is a unit variant, you need to write it without the parenthesis - | -16 | X::Entry; - | ^^^^^^^^ - -error[E0618]: expected function, found `i32` - --> $DIR/E0618.rs:19:5 - | -18 | let x = 0i32; - | - `i32` defined here -19 | x(); - | ^^^ not a function - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0619.stderr b/src/test/ui/error-codes/E0619.stderr deleted file mode 100644 index cec336cfcec66..0000000000000 --- a/src/test/ui/error-codes/E0619.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0619]: the type of this value must be known in this context - --> $DIR/E0619.rs:15:9 - | -15 | (..) => {} //~ ERROR E0619 - | ^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0620.stderr b/src/test/ui/error-codes/E0620.stderr deleted file mode 100644 index 564a9472ac9a2..0000000000000 --- a/src/test/ui/error-codes/E0620.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0620]: cast to unsized type: `&[usize; 2]` as `[usize]` - --> $DIR/E0620.rs:12:16 - | -12 | let _foo = &[1_usize, 2] as [usize]; //~ ERROR E0620 - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: consider using an implicit coercion to `&[usize]` instead - --> $DIR/E0620.rs:12:16 - | -12 | let _foo = &[1_usize, 2] as [usize]; //~ ERROR E0620 - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.stderr b/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.stderr deleted file mode 100644 index c529a838bf739..0000000000000 --- a/src/test/ui/error-codes/E0621-does-not-trigger-for-closures.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0495]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/E0621-does-not-trigger-for-closures.rs:25:5 - | -25 | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495 - | ^^^^^^ - | -note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the body at 25:16... - --> $DIR/E0621-does-not-trigger-for-closures.rs:25:16 - | -25 | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...so that reference does not outlive borrowed content - --> $DIR/E0621-does-not-trigger-for-closures.rs:25:45 - | -25 | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495 - | ^ -note: but, the lifetime must be valid for the call at 25:5... - --> $DIR/E0621-does-not-trigger-for-closures.rs:25:5 - | -25 | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...so type `&i32` of expression is valid during the expression - --> $DIR/E0621-does-not-trigger-for-closures.rs:25:5 - | -25 | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0622.stderr b/src/test/ui/error-codes/E0622.stderr deleted file mode 100644 index 977f44a9c9781..0000000000000 --- a/src/test/ui/error-codes/E0622.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0622]: intrinsic must be a function - --> $DIR/E0622.rs:13:5 - | -13 | pub static breakpoint : unsafe extern "rust-intrinsic" fn(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected a function - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0624.stderr b/src/test/ui/error-codes/E0624.stderr deleted file mode 100644 index 0afb05a8a5e81..0000000000000 --- a/src/test/ui/error-codes/E0624.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0624]: method `method` is private - --> $DIR/E0624.rs:21:9 - | -21 | foo.method(); //~ ERROR method `method` is private [E0624] - | ^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0637.stderr b/src/test/ui/error-codes/E0637.stderr deleted file mode 100644 index e314afd221e40..0000000000000 --- a/src/test/ui/error-codes/E0637.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0637]: invalid lifetime bound name: `'_` - --> $DIR/E0637.rs:12:16 - | -12 | struct Foo<'a: '_>(&'a u8); //~ ERROR invalid lifetime bound name: `'_` - | ^^ `'_` is a reserved lifetime name - -error[E0637]: invalid lifetime bound name: `'_` - --> $DIR/E0637.rs:13:12 - | -13 | fn foo<'a: '_>(_: &'a u8) {} //~ ERROR invalid lifetime bound name: `'_` - | ^^ `'_` is a reserved lifetime name - -error[E0637]: invalid lifetime bound name: `'_` - --> $DIR/E0637.rs:16:10 - | -16 | impl<'a: '_> Bar<'a> { //~ ERROR invalid lifetime bound name: `'_` - | ^^ `'_` is a reserved lifetime name - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/error-codes/E0657.stderr b/src/test/ui/error-codes/E0657.stderr deleted file mode 100644 index d3b53d37a30a0..0000000000000 --- a/src/test/ui/error-codes/E0657.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl level - --> $DIR/E0657.rs:20:32 - | -20 | -> impl for<'a> Id> - | ^^ - -error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl level - --> $DIR/E0657.rs:29:36 - | -29 | -> impl for<'a> Id> - | ^^ - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/error-codes/E0658.stderr b/src/test/ui/error-codes/E0658.stderr deleted file mode 100644 index c18d8090233d4..0000000000000 --- a/src/test/ui/error-codes/E0658.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0658]: use of unstable library feature 'i128' (see issue #35118) - --> $DIR/E0658.rs:12:13 - | -12 | let _ = ::std::u128::MAX; //~ ERROR E0658 - | ^^^^^^^^^^^^^^^^ - | - = help: add #![feature(i128)] to the crate attributes to enable - -error: aborting due to previous error - diff --git a/src/test/ui/error-codes/E0659.stderr b/src/test/ui/error-codes/E0659.stderr deleted file mode 100644 index c2410e2f733bc..0000000000000 --- a/src/test/ui/error-codes/E0659.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0659]: `foo` is ambiguous - --> $DIR/E0659.rs:25:5 - | -25 | collider::foo(); //~ ERROR E0659 - | ^^^^^^^^^^^^^ - | -note: `foo` could refer to the name imported here - --> $DIR/E0659.rs:20:13 - | -20 | pub use moon::*; - | ^^^^^^^ -note: `foo` could also refer to the name imported here - --> $DIR/E0659.rs:21:13 - | -21 | pub use earth::*; - | ^^^^^^^^ - = note: consider adding an explicit import of `foo` to disambiguate - -error: aborting due to previous error - diff --git a/src/test/ui/feature-gate-macro_at_most_once_rep.rs b/src/test/ui/feature-gate-macro_at_most_once_rep.rs deleted file mode 100644 index 19f5aca5730e1..0000000000000 --- a/src/test/ui/feature-gate-macro_at_most_once_rep.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that `?` macro Kleene operator can not be used when the `macro_at_most_once_rep` feature -// gate is not used. - -macro_rules! m { ($(a)?) => {} } -//~^ ERROR Using the `?` macro Kleene operator for "at most one" repetition is unstable - -fn main() { - m!(); -} diff --git a/src/test/ui/feature-gate-macro_at_most_once_rep.stderr b/src/test/ui/feature-gate-macro_at_most_once_rep.stderr deleted file mode 100644 index 02dbab07bdecc..0000000000000 --- a/src/test/ui/feature-gate-macro_at_most_once_rep.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0658]: Using the `?` macro Kleene operator for "at most one" repetition is unstable (see issue #48075) - --> $DIR/feature-gate-macro_at_most_once_rep.rs:14:20 - | -14 | macro_rules! m { ($(a)?) => {} } - | ^^^ - | - = help: add #![feature(macro_at_most_once_rep)] to the crate attributes to enable - -error: aborting due to previous error - diff --git a/src/test/ui/feature-gate-match_beginning_vert.rs b/src/test/ui/feature-gate-match_beginning_vert.rs new file mode 100644 index 0000000000000..9085563c99d6d --- /dev/null +++ b/src/test/ui/feature-gate-match_beginning_vert.rs @@ -0,0 +1,36 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#[allow(dead_code)] +enum Foo { + A, + B, + C, + D, + E, +} +use Foo::*; + +fn main() { + let x = Foo::A; + match x { + | A => println!("A"), + //~^ ERROR: Use of a '|' at the beginning of a match arm is experimental (see issue #44101) + | B | C => println!("BC!"), + //~^ ERROR: Use of a '|' at the beginning of a match arm is experimental (see issue #44101) + | _ => {}, + //~^ ERROR: Use of a '|' at the beginning of a match arm is experimental (see issue #44101) + }; + match x { + A | B | C => println!("ABC!"), + _ => {}, + }; +} + diff --git a/src/test/ui/feature-gate-match_beginning_vert.stderr b/src/test/ui/feature-gate-match_beginning_vert.stderr new file mode 100644 index 0000000000000..1d45dedb4971c --- /dev/null +++ b/src/test/ui/feature-gate-match_beginning_vert.stderr @@ -0,0 +1,26 @@ +error[E0658]: Use of a '|' at the beginning of a match arm is experimental (see issue #44101) + --> $DIR/feature-gate-match_beginning_vert.rs:24:9 + | +24 | | A => println!("A"), + | ^ + | + = help: add #![feature(match_beginning_vert)] to the crate attributes to enable + +error[E0658]: Use of a '|' at the beginning of a match arm is experimental (see issue #44101) + --> $DIR/feature-gate-match_beginning_vert.rs:26:9 + | +26 | | B | C => println!("BC!"), + | ^ + | + = help: add #![feature(match_beginning_vert)] to the crate attributes to enable + +error[E0658]: Use of a '|' at the beginning of a match arm is experimental (see issue #44101) + --> $DIR/feature-gate-match_beginning_vert.rs:28:9 + | +28 | | _ => {}, + | ^ + | + = help: add #![feature(match_beginning_vert)] to the crate attributes to enable + +error: aborting due to 3 previous errors + diff --git a/src/test/codegen/abi-x86_64_sysv.rs b/src/test/ui/feature-gate-use_nested_groups.rs similarity index 51% rename from src/test/codegen/abi-x86_64_sysv.rs rename to src/test/ui/feature-gate-use_nested_groups.rs index 88666e9c1fd47..56413a999d7f7 100644 --- a/src/test/codegen/abi-x86_64_sysv.rs +++ b/src/test/ui/feature-gate-use_nested_groups.rs @@ -8,32 +8,24 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// only-x86_64 +#![allow(unused_imports, dead_code)] -// compile-flags: -C no-prepopulate-passes +mod a { + pub enum B {} + pub enum C {} -#![crate_type = "lib"] + pub mod d { + pub enum E {} + pub enum F {} -pub struct S24 { - a: i8, - b: i8, - c: i8, + pub mod g { + pub enum H {} + } + } } -pub struct S48 { - a: i16, - b: i16, - c: i8, -} - -// CHECK: i24 @struct_24_bits(i24 -#[no_mangle] -pub extern "sysv64" fn struct_24_bits(a: S24) -> S24 { - a -} +use a::{B, d::{*, g::H}}; //~ ERROR glob imports in `use` groups are experimental + //~^ ERROR nested groups in `use` are experimental + //~^^ ERROR paths in `use` groups are experimental -// CHECK: i48 @struct_48_bits(i48 -#[no_mangle] -pub extern "sysv64" fn struct_48_bits(a: S48) -> S48 { - a -} +fn main() {} diff --git a/src/test/ui/feature-gate-use_nested_groups.stderr b/src/test/ui/feature-gate-use_nested_groups.stderr new file mode 100644 index 0000000000000..6ae691c384be8 --- /dev/null +++ b/src/test/ui/feature-gate-use_nested_groups.stderr @@ -0,0 +1,26 @@ +error[E0658]: nested groups in `use` are experimental (see issue #44494) + --> $DIR/feature-gate-use_nested_groups.rs:27:12 + | +27 | use a::{B, d::{*, g::H}}; //~ ERROR glob imports in `use` groups are experimental + | ^^^^^^^^^^^^ + | + = help: add #![feature(use_nested_groups)] to the crate attributes to enable + +error[E0658]: glob imports in `use` groups are experimental (see issue #44494) + --> $DIR/feature-gate-use_nested_groups.rs:27:16 + | +27 | use a::{B, d::{*, g::H}}; //~ ERROR glob imports in `use` groups are experimental + | ^ + | + = help: add #![feature(use_nested_groups)] to the crate attributes to enable + +error[E0658]: paths in `use` groups are experimental (see issue #44494) + --> $DIR/feature-gate-use_nested_groups.rs:27:19 + | +27 | use a::{B, d::{*, g::H}}; //~ ERROR glob imports in `use` groups are experimental + | ^^^^ + | + = help: add #![feature(use_nested_groups)] to the crate attributes to enable + +error: aborting due to 3 previous errors + diff --git a/src/test/ui/generator/generator-with-nll.stderr b/src/test/ui/generator/generator-with-nll.stderr index 0f7d2e540d80a..0a52a928f69d4 100644 --- a/src/test/ui/generator/generator-with-nll.stderr +++ b/src/test/ui/generator/generator-with-nll.stderr @@ -1,3 +1,12 @@ +error[E0626]: borrow may still be in use when generator yields (Mir) + --> $DIR/generator-with-nll.rs:20:17 + | +20 | let b = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast) + | ^^^^^^^^^ +21 | //~^ borrow may still be in use when generator yields (Mir) +22 | yield (); + | -------- possible yield occurs here + error[E0626]: borrow may still be in use when generator yields (Ast) --> $DIR/generator-with-nll.rs:19:23 | @@ -16,14 +25,5 @@ error[E0626]: borrow may still be in use when generator yields (Ast) 22 | yield (); | -------- possible yield occurs here -error[E0626]: borrow may still be in use when generator yields (Mir) - --> $DIR/generator-with-nll.rs:20:17 - | -20 | let b = &mut true; //~ ERROR borrow may still be in use when generator yields (Ast) - | ^^^^^^^^^ -21 | //~^ borrow may still be in use when generator yields (Mir) -22 | yield (); - | -------- possible yield occurs here - error: aborting due to 3 previous errors diff --git a/src/test/ui/generator/issue-48048.rs b/src/test/ui/generator/issue-48048.rs deleted file mode 100644 index 89739bd591cc8..0000000000000 --- a/src/test/ui/generator/issue-48048.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(generators)] - -fn main() { - let x = (|_| {},); - - || { - let x = x; - - x.0({ //~ ERROR borrow may still be in use when generator yields - yield; - }); - }; -} diff --git a/src/test/ui/generator/issue-48048.stderr b/src/test/ui/generator/issue-48048.stderr deleted file mode 100644 index fd1667128ab60..0000000000000 --- a/src/test/ui/generator/issue-48048.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/issue-48048.rs:19:9 - | -19 | x.0({ //~ ERROR borrow may still be in use when generator yields - | ^^^ -20 | yield; - | ----- possible yield occurs here - -error: aborting due to previous error - diff --git a/src/test/ui/generator/pattern-borrow.rs b/src/test/ui/generator/pattern-borrow.rs deleted file mode 100644 index 557a5e62f7e46..0000000000000 --- a/src/test/ui/generator/pattern-borrow.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(generators)] - -enum Test { A(i32), B, } - -fn main() { } - -fn fun(test: Test) { - move || { - if let Test::A(ref _a) = test { //~ ERROR borrow may still be in use when generator yields - yield (); - } - }; -} diff --git a/src/test/ui/generator/pattern-borrow.stderr b/src/test/ui/generator/pattern-borrow.stderr deleted file mode 100644 index 6b39b272d0e42..0000000000000 --- a/src/test/ui/generator/pattern-borrow.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error[E0626]: borrow may still be in use when generator yields - --> $DIR/pattern-borrow.rs:19:24 - | -19 | if let Test::A(ref _a) = test { //~ ERROR borrow may still be in use when generator yields - | ^^^^^^ -20 | yield (); - | -------- possible yield occurs here - -error: aborting due to previous error - diff --git a/src/test/ui/generator/sized-yield.rs b/src/test/ui/generator/sized-yield.rs deleted file mode 100644 index f38ebf8b94636..0000000000000 --- a/src/test/ui/generator/sized-yield.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![feature(generators, generator_trait)] - -use std::ops::Generator; - -fn main() { - let s = String::from("foo"); - let mut gen = move || { //~ ERROR the trait bound `str: std::marker::Sized` is not satisfied - yield s[..]; - }; - gen.resume(); //~ ERROR the trait bound `str: std::marker::Sized` is not satisfied -} diff --git a/src/test/ui/generator/sized-yield.stderr b/src/test/ui/generator/sized-yield.stderr deleted file mode 100644 index 7adb2cc5598dc..0000000000000 --- a/src/test/ui/generator/sized-yield.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied - --> $DIR/sized-yield.rs:17:26 - | -17 | let mut gen = move || { //~ ERROR the trait bound `str: std::marker::Sized` is not satisfied - | __________________________^ -18 | | yield s[..]; -19 | | }; - | |____^ `str` does not have a constant size known at compile-time - | - = help: the trait `std::marker::Sized` is not implemented for `str` - = note: the yield type of a generator must have a statically known size - -error[E0277]: the trait bound `str: std::marker::Sized` is not satisfied - --> $DIR/sized-yield.rs:20:8 - | -20 | gen.resume(); //~ ERROR the trait bound `str: std::marker::Sized` is not satisfied - | ^^^^^^ `str` does not have a constant size known at compile-time - | - = help: the trait `std::marker::Sized` is not implemented for `str` - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/generator/yield-while-local-borrowed.stderr b/src/test/ui/generator/yield-while-local-borrowed.stderr index 114fe8ffcab0e..7961dd9744136 100644 --- a/src/test/ui/generator/yield-while-local-borrowed.stderr +++ b/src/test/ui/generator/yield-while-local-borrowed.stderr @@ -1,3 +1,12 @@ +error[E0626]: borrow may still be in use when generator yields (Mir) + --> $DIR/yield-while-local-borrowed.rs:24:17 + | +24 | let a = &mut 3; + | ^^^^^^ +... +27 | yield(); + | ------- possible yield occurs here + error[E0626]: borrow may still be in use when generator yields (Ast) --> $DIR/yield-while-local-borrowed.rs:24:22 | @@ -16,15 +25,6 @@ error[E0626]: borrow may still be in use when generator yields (Ast) 55 | yield(); | ------- possible yield occurs here -error[E0626]: borrow may still be in use when generator yields (Mir) - --> $DIR/yield-while-local-borrowed.rs:24:17 - | -24 | let a = &mut 3; - | ^^^^^^ -... -27 | yield(); - | ------- possible yield occurs here - error[E0626]: borrow may still be in use when generator yields (Mir) --> $DIR/yield-while-local-borrowed.rs:52:21 | diff --git a/src/test/ui/impl-trait/equality.rs b/src/test/ui/impl-trait/equality.rs index 9d9d4cef3119a..36df4f0eb4d46 100644 --- a/src/test/ui/impl-trait/equality.rs +++ b/src/test/ui/impl-trait/equality.rs @@ -32,7 +32,7 @@ fn sum_to(n: u32) -> impl Foo { 0 } else { n + sum_to(n - 1) - //~^ ERROR cannot add `impl Foo` to `u32` + //~^ ERROR the trait bound `u32: std::ops::Add` is not satisfied } } diff --git a/src/test/ui/impl-trait/equality.stderr b/src/test/ui/impl-trait/equality.stderr index 8ec819038031b..3fc08a0900fb9 100644 --- a/src/test/ui/impl-trait/equality.stderr +++ b/src/test/ui/impl-trait/equality.stderr @@ -7,7 +7,7 @@ error[E0308]: mismatched types = note: expected type `i32` found type `u32` -error[E0277]: cannot add `impl Foo` to `u32` +error[E0277]: the trait bound `u32: std::ops::Add` is not satisfied --> $DIR/equality.rs:34:11 | 34 | n + sum_to(n - 1) diff --git a/src/test/ui/impl-trait/trait_type.stderr b/src/test/ui/impl-trait/trait_type.stderr index 1417c71ca1244..7a0d01a8ec215 100644 --- a/src/test/ui/impl-trait/trait_type.stderr +++ b/src/test/ui/impl-trait/trait_type.stderr @@ -2,7 +2,7 @@ error[E0053]: method `fmt` has an incompatible type for trait --> $DIR/trait_type.rs:17:4 | 17 | fn fmt(&self, x: &str) -> () { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ in mutability + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ in mutability | = note: expected type `fn(&MyType, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>` found type `fn(&MyType, &str)` @@ -19,7 +19,7 @@ error[E0186]: method `fmt` has a `&self` declaration in the trait, but not in th --> $DIR/trait_type.rs:27:4 | 27 | fn fmt() -> () { } - | ^^^^^^^^^^^^^^ expected `&self` in impl + | ^^^^^^^^^^^^^^^^^^ expected `&self` in impl | = note: `fmt` from trait: `fn(&Self, &mut std::fmt::Formatter<'_>) -> std::result::Result<(), std::fmt::Error>` diff --git a/src/test/ui/imports/duplicate.stderr b/src/test/ui/imports/duplicate.stderr index 6e5b91a11c900..a74401314a18c 100644 --- a/src/test/ui/imports/duplicate.stderr +++ b/src/test/ui/imports/duplicate.stderr @@ -9,8 +9,8 @@ error[E0252]: the name `foo` is defined multiple times = note: `foo` must be defined only once in the value namespace of this module help: You can use `as` to change the binding name of the import | -25 | use a::foo as other_foo; //~ ERROR the name `foo` is defined multiple times - | ^^^^^^^^^^^^^^^^^^^ +25 | use a::foo as Otherfoo; //~ ERROR the name `foo` is defined multiple times + | ^^^^^^^^^^^^^^^^^^ error[E0659]: `foo` is ambiguous --> $DIR/duplicate.rs:56:9 diff --git a/src/test/ui/in-band-lifetimes/ellided-lifetimes.rs b/src/test/ui/in-band-lifetimes/ellided-lifetimes.rs deleted file mode 100644 index 5151abd68232c..0000000000000 --- a/src/test/ui/in-band-lifetimes/ellided-lifetimes.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -#![allow(warnings)] -#![allow(unused_variables, dead_code, unused, bad_style)] -#![deny(elided_lifetime_in_path)] - -struct Foo<'a> { x: &'a u32 } -fn foo(x: &Foo) { - //~^ ERROR: hidden lifetime parameters are deprecated, try `Foo<'_>` -} - -fn main() {} diff --git a/src/test/ui/in-band-lifetimes/ellided-lifetimes.stderr b/src/test/ui/in-band-lifetimes/ellided-lifetimes.stderr deleted file mode 100644 index 613a7be6ed2c1..0000000000000 --- a/src/test/ui/in-band-lifetimes/ellided-lifetimes.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: hidden lifetime parameters are deprecated, try `Foo<'_>` - --> $DIR/ellided-lifetimes.rs:15:12 - | -15 | fn foo(x: &Foo) { - | ^^^ - | -note: lint level defined here - --> $DIR/ellided-lifetimes.rs:12:9 - | -12 | #![deny(elided_lifetime_in_path)] - | ^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs b/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs deleted file mode 100644 index f845762cefd8b..0000000000000 --- a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::ops::Deref; -trait Trait {} - -struct Struct; - -impl Deref for Struct { - type Target = Trait; - fn deref(&self) -> &Trait { - unimplemented!(); - } -} -//~^^^^ ERROR cannot infer an appropriate lifetime for lifetime parameter diff --git a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr b/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr deleted file mode 100644 index 7aab31eb909d0..0000000000000 --- a/src/test/ui/in-band-lifetimes/mismatched_trait_impl-2.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0601]: main function not found - -error[E0495]: cannot infer an appropriate lifetime for lifetime parameter in generic type due to conflicting requirements - --> $DIR/mismatched_trait_impl-2.rs:18:5 - | -18 | fn deref(&self) -> &Trait { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: first, the lifetime cannot outlive the anonymous lifetime #1 defined on the method body at 18:5... - --> $DIR/mismatched_trait_impl-2.rs:18:5 - | -18 | / fn deref(&self) -> &Trait { -19 | | unimplemented!(); -20 | | } - | |_____^ - = note: ...but the lifetime must also be valid for the static lifetime... - = note: ...so that the method type is compatible with trait: - expected fn(&Struct) -> &Trait + 'static - found fn(&Struct) -> &Trait - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/in-band-lifetimes/mismatched_trait_impl.stderr b/src/test/ui/in-band-lifetimes/mismatched_trait_impl.stderr index fd6be01da9f46..e96f7181a6dae 100644 --- a/src/test/ui/in-band-lifetimes/mismatched_trait_impl.stderr +++ b/src/test/ui/in-band-lifetimes/mismatched_trait_impl.stderr @@ -1,8 +1,10 @@ error[E0495]: cannot infer an appropriate lifetime for lifetime parameter 'a in generic type due to conflicting requirements --> $DIR/mismatched_trait_impl.rs:19:5 | -19 | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +19 | / fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer +20 | | x +21 | | } + | |_____^ | note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on the method body at 19:5... --> $DIR/mismatched_trait_impl.rs:19:5 @@ -11,14 +13,27 @@ note: first, the lifetime cannot outlive the anonymous lifetime #2 defined on th 20 | | x 21 | | } | |_____^ -note: ...but the lifetime must also be valid for the lifetime 'a as defined on the method body at 19:5... +note: ...so that method type is compatible with trait (expected fn(&i32, &'a u32, &u32) -> &'a u32, found fn(&i32, &u32, &u32) -> &u32) + --> $DIR/mismatched_trait_impl.rs:19:5 + | +19 | / fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer +20 | | x +21 | | } + | |_____^ +note: but, the lifetime must be valid for the lifetime 'a as defined on the method body at 19:5... --> $DIR/mismatched_trait_impl.rs:19:5 | -19 | fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...so that the method type is compatible with trait: - expected fn(&i32, &'a u32, &u32) -> &'a u32 - found fn(&i32, &u32, &u32) -> &u32 +19 | / fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer +20 | | x +21 | | } + | |_____^ +note: ...so that method type is compatible with trait (expected fn(&i32, &'a u32, &u32) -> &'a u32, found fn(&i32, &u32, &u32) -> &u32) + --> $DIR/mismatched_trait_impl.rs:19:5 + | +19 | / fn foo(&self, x: &u32, y: &'a u32) -> &'a u32 { //~ ERROR cannot infer +20 | | x +21 | | } + | |_____^ error: aborting due to previous error diff --git a/src/test/ui/issue-26886.stderr b/src/test/ui/issue-26886.stderr index e6424e535ee32..cb2eca87068f8 100644 --- a/src/test/ui/issue-26886.stderr +++ b/src/test/ui/issue-26886.stderr @@ -24,8 +24,8 @@ error[E0252]: the name `sync` is defined multiple times = note: `sync` must be defined only once in the type namespace of this module help: You can use `as` to change the binding name of the import | -14 | use std::sync as other_sync; //~ ERROR the name `sync` is defined multiple times - | ^^^^^^^^^^^^^^^^^^^^^^^ +14 | use std::sync as Othersync; //~ ERROR the name `sync` is defined multiple times + | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/src/test/ui/issue-27942.stderr b/src/test/ui/issue-27942.stderr index b24544743d87d..b580b8e73137b 100644 --- a/src/test/ui/issue-27942.stderr +++ b/src/test/ui/issue-27942.stderr @@ -14,8 +14,14 @@ note: the anonymous lifetime #1 defined on the method body at 15:5... note: ...does not necessarily outlive the lifetime 'a as defined on the trait at 13:1 --> $DIR/issue-27942.rs:13:1 | -13 | pub trait Buffer<'a, R: Resources<'a>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +13 | / pub trait Buffer<'a, R: Resources<'a>> { +14 | | +15 | | fn select(&self) -> BufferViewHandle; +16 | | //~^ ERROR mismatched types +... | +19 | | //~| lifetime mismatch +20 | | } + | |_^ error[E0308]: mismatched types --> $DIR/issue-27942.rs:15:5 @@ -28,8 +34,14 @@ error[E0308]: mismatched types note: the lifetime 'a as defined on the trait at 13:1... --> $DIR/issue-27942.rs:13:1 | -13 | pub trait Buffer<'a, R: Resources<'a>> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +13 | / pub trait Buffer<'a, R: Resources<'a>> { +14 | | +15 | | fn select(&self) -> BufferViewHandle; +16 | | //~^ ERROR mismatched types +... | +19 | | //~| lifetime mismatch +20 | | } + | |_^ note: ...does not necessarily outlive the anonymous lifetime #1 defined on the method body at 15:5 --> $DIR/issue-27942.rs:15:5 | diff --git a/src/test/ui/issue-37884.stderr b/src/test/ui/issue-37884.stderr index c4ad232ae7eba..439b123975f82 100644 --- a/src/test/ui/issue-37884.stderr +++ b/src/test/ui/issue-37884.stderr @@ -24,8 +24,14 @@ note: the anonymous lifetime #1 defined on the method body at 16:5... note: ...does not necessarily outlive the lifetime 'a as defined on the impl at 13:1 --> $DIR/issue-37884.rs:13:1 | -13 | impl<'a, T: 'a> Iterator for RepeatMut<'a, T> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +13 | / impl<'a, T: 'a> Iterator for RepeatMut<'a, T> { +14 | | +15 | | type Item = &'a mut T; +16 | | fn next(&'a mut self) -> Option +... | +21 | | } +22 | | } + | |_^ error: aborting due to previous error diff --git a/src/test/ui/issue-45697-1.rs b/src/test/ui/issue-45697-1.rs deleted file mode 100644 index 7734b14b2ab7b..0000000000000 --- a/src/test/ui/issue-45697-1.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that assignments to an `&mut` pointer which is found in a -// borrowed (but otherwise non-aliasable) location is illegal. - -// compile-flags: -Z emit-end-regions -Z borrowck=compare -C overflow-checks=on - -struct S<'a> { - pointer: &'a mut isize -} - -fn copy_borrowed_ptr<'a>(p: &'a mut S<'a>) -> S<'a> { - S { pointer: &mut *p.pointer } -} - -fn main() { - let mut x = 1; - - { - let mut y = S { pointer: &mut x }; - let z = copy_borrowed_ptr(&mut y); - *y.pointer += 1; - //~^ ERROR cannot assign to `*y.pointer` because it is borrowed (Ast) [E0506] - //~| ERROR cannot use `*y.pointer` because it was mutably borrowed (Mir) [E0503] - *z.pointer += 1; - } -} diff --git a/src/test/ui/issue-45697-1.stderr b/src/test/ui/issue-45697-1.stderr deleted file mode 100644 index 09f32b93acc1c..0000000000000 --- a/src/test/ui/issue-45697-1.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast) - --> $DIR/issue-45697-1.rs:30:9 - | -29 | let z = copy_borrowed_ptr(&mut y); - | - borrow of `*y.pointer` occurs here -30 | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here - -error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir) - --> $DIR/issue-45697-1.rs:30:9 - | -29 | let z = copy_borrowed_ptr(&mut y); - | ------ borrow of `y` occurs here -30 | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ use of borrowed `y` - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/issue-45697.rs b/src/test/ui/issue-45697.rs deleted file mode 100644 index 4e93eccd6f649..0000000000000 --- a/src/test/ui/issue-45697.rs +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test that assignments to an `&mut` pointer which is found in a -// borrowed (but otherwise non-aliasable) location is illegal. - -// compile-flags: -Z emit-end-regions -Z borrowck=compare -C overflow-checks=off - -struct S<'a> { - pointer: &'a mut isize -} - -fn copy_borrowed_ptr<'a>(p: &'a mut S<'a>) -> S<'a> { - S { pointer: &mut *p.pointer } -} - -fn main() { - let mut x = 1; - - { - let mut y = S { pointer: &mut x }; - let z = copy_borrowed_ptr(&mut y); - *y.pointer += 1; - //~^ ERROR cannot assign to `*y.pointer` because it is borrowed (Ast) [E0506] - //~| ERROR cannot use `*y.pointer` because it was mutably borrowed (Mir) [E0503] - *z.pointer += 1; - } -} diff --git a/src/test/ui/issue-45697.stderr b/src/test/ui/issue-45697.stderr deleted file mode 100644 index e9b723d57b507..0000000000000 --- a/src/test/ui/issue-45697.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast) - --> $DIR/issue-45697.rs:30:9 - | -29 | let z = copy_borrowed_ptr(&mut y); - | - borrow of `*y.pointer` occurs here -30 | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here - -error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir) - --> $DIR/issue-45697.rs:30:9 - | -29 | let z = copy_borrowed_ptr(&mut y); - | ------ borrow of `y` occurs here -30 | *y.pointer += 1; - | ^^^^^^^^^^^^^^^ use of borrowed `y` - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/issue-46472.stderr b/src/test/ui/issue-46472.stderr index 7b5cce218e9f2..2f332a7a55850 100644 --- a/src/test/ui/issue-46472.stderr +++ b/src/test/ui/issue-46472.stderr @@ -10,8 +10,12 @@ error[E0597]: borrowed value does not live long enough (Ast) note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:1... --> $DIR/issue-46472.rs:13:1 | -13 | fn bar<'a>() -> &'a mut u32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +13 | / fn bar<'a>() -> &'a mut u32 { +14 | | &mut 4 +15 | | //~^ ERROR borrowed value does not live long enough (Ast) [E0597] +16 | | //~| ERROR borrowed value does not live long enough (Mir) [E0597] +17 | | } + | |_^ error[E0597]: borrowed value does not live long enough (Mir) --> $DIR/issue-46472.rs:14:10 @@ -25,8 +29,12 @@ error[E0597]: borrowed value does not live long enough (Mir) note: borrowed value must be valid for the lifetime 'a as defined on the function body at 13:1... --> $DIR/issue-46472.rs:13:1 | -13 | fn bar<'a>() -> &'a mut u32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +13 | / fn bar<'a>() -> &'a mut u32 { +14 | | &mut 4 +15 | | //~^ ERROR borrowed value does not live long enough (Ast) [E0597] +16 | | //~| ERROR borrowed value does not live long enough (Mir) [E0597] +17 | | } + | |_^ error: aborting due to 2 previous errors diff --git a/src/test/ui/issue-47706-trait.rs b/src/test/ui/issue-47706-trait.rs deleted file mode 100644 index 86a9da49a054a..0000000000000 --- a/src/test/ui/issue-47706-trait.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -trait T { - fn f(&self, _: ()) { - None::<()>.map(Self::f); - } - //~^^ ERROR function is expected to take a single 0-tuple as argument -} diff --git a/src/test/ui/issue-47706-trait.stderr b/src/test/ui/issue-47706-trait.stderr deleted file mode 100644 index 320e98dee4acf..0000000000000 --- a/src/test/ui/issue-47706-trait.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0601]: main function not found - -error[E0593]: function is expected to take a single 0-tuple as argument, but it takes 2 distinct arguments - --> $DIR/issue-47706-trait.rs:13:20 - | -12 | fn f(&self, _: ()) { - | ------------------ takes 2 distinct arguments -13 | None::<()>.map(Self::f); - | ^^^ expected function that takes a single 0-tuple as argument - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs b/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs deleted file mode 100644 index a68b4f7635292..0000000000000 --- a/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// must-compile-successfully - -#![warn(unused)] // UI tests pass `-A unused` (#43896) - -struct SoulHistory { - corridors_of_light: usize, - hours_are_suns: bool, - endless_and_singing: bool -} - -fn main() { - let i_think_continually = 2; - let who_from_the_womb_remembered = SoulHistory { - corridors_of_light: 5, - hours_are_suns: true, - endless_and_singing: true - }; - - if let SoulHistory { corridors_of_light, - mut hours_are_suns, - endless_and_singing: true } = who_from_the_womb_remembered { - hours_are_suns = false; - } -} diff --git a/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.stderr b/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.stderr deleted file mode 100644 index 694fe69e01648..0000000000000 --- a/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.stderr +++ /dev/null @@ -1,40 +0,0 @@ -warning: unused variable: `i_think_continually` - --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:22:9 - | -22 | let i_think_continually = 2; - | ^^^^^^^^^^^^^^^^^^^ help: consider using `_i_think_continually` instead - | -note: lint level defined here - --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:13:9 - | -13 | #![warn(unused)] // UI tests pass `-A unused` (#43896) - | ^^^^^^ - = note: #[warn(unused_variables)] implied by #[warn(unused)] - -warning: unused variable: `corridors_of_light` - --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:29:26 - | -29 | if let SoulHistory { corridors_of_light, - | ^^^^^^^^^^^^^^^^^^ help: try ignoring the field: `corridors_of_light: _` - -warning: variable `hours_are_suns` is assigned to, but never used - --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:30:26 - | -30 | mut hours_are_suns, - | ^^^^^^^^^^^^^^^^^^ - | - = note: consider using `_hours_are_suns` instead - -warning: value assigned to `hours_are_suns` is never read - --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:32:9 - | -32 | hours_are_suns = false; - | ^^^^^^^^^^^^^^ - | -note: lint level defined here - --> $DIR/issue-47390-unused-variable-in-struct-pattern.rs:13:9 - | -13 | #![warn(unused)] // UI tests pass `-A unused` (#43896) - | ^^^^^^ - = note: #[warn(unused_assignments)] implied by #[warn(unused)] - diff --git a/src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.rs b/src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.rs deleted file mode 100644 index b4e6c5074e3d3..0000000000000 --- a/src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// must-compile-successfully - -#![warn(unused_parens)] - -macro_rules! the_worship_the_heart_lifts_above { - ( @as_expr, $e:expr) => { $e }; - ( @generate_fn, $name:tt) => { - #[allow(dead_code)] fn the_moth_for_the_star<'a>() -> Option<&'a str> { - Some(the_worship_the_heart_lifts_above!( @as_expr, $name )) - } - }; - ( $name:ident ) => { the_worship_the_heart_lifts_above!( @generate_fn, (stringify!($name))); } - // ↑ Notably, this does 𝘯𝘰𝘵 warn: we're declining to lint unused parens in - // function/method arguments inside of nested macros because of situations - // like those reported in Issue #47775 -} - -macro_rules! and_the_heavens_reject_not { - () => { - // ↓ But let's test that we still lint for unused parens around - // function args inside of simple, one-deep macros. - #[allow(dead_code)] fn the_night_for_the_morrow() -> Option { Some((2)) } - //~^ WARN unnecessary parentheses around function argument - } -} - -the_worship_the_heart_lifts_above!(rah); -and_the_heavens_reject_not!(); - -fn main() {} diff --git a/src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.stderr b/src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.stderr deleted file mode 100644 index 097ec1b1c8010..0000000000000 --- a/src/test/ui/lint/issue-47775-nested-macro-unnecessary-parens-arg.stderr +++ /dev/null @@ -1,15 +0,0 @@ -warning: unnecessary parentheses around function argument - --> $DIR/issue-47775-nested-macro-unnecessary-parens-arg.rs:32:83 - | -32 | #[allow(dead_code)] fn the_night_for_the_morrow() -> Option { Some((2)) } - | ^^^ help: remove these parentheses -... -38 | and_the_heavens_reject_not!(); - | ------------------------------ in this macro invocation - | -note: lint level defined here - --> $DIR/issue-47775-nested-macro-unnecessary-parens-arg.rs:13:9 - | -13 | #![warn(unused_parens)] - | ^^^^^^^^^^^^^ - diff --git a/src/test/ui/lint/suggestions.rs b/src/test/ui/lint/suggestions.rs index e35675eacd835..dfcaede1402da 100644 --- a/src/test/ui/lint/suggestions.rs +++ b/src/test/ui/lint/suggestions.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-tidy-tab - #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896 #![feature(no_debug)] @@ -48,15 +46,11 @@ fn main() { let mut a = (1); // should suggest no `mut`, no parens //~^ WARN does not need to be mutable //~| WARN unnecessary parentheses - // the line after `mut` has a `\t` at the beginning, this is on purpose - let mut - b = 1; - //~^^ WARN does not need to be mutable let d = Equinox { warp_factor: 9.975 }; match d { Equinox { warp_factor: warp_factor } => {} // should suggest shorthand //~^ WARN this pattern is redundant } - println!("{} {}", a, b); + println!("{}", a); } } diff --git a/src/test/ui/lint/suggestions.stderr b/src/test/ui/lint/suggestions.stderr index 90d6bd312e419..8b30f552d3771 100644 --- a/src/test/ui/lint/suggestions.stderr +++ b/src/test/ui/lint/suggestions.stderr @@ -1,53 +1,41 @@ warning: unnecessary parentheses around assigned value - --> $DIR/suggestions.rs:48:21 + --> $DIR/suggestions.rs:46:21 | -48 | let mut a = (1); // should suggest no `mut`, no parens +46 | let mut a = (1); // should suggest no `mut`, no parens | ^^^ help: remove these parentheses | note: lint level defined here - --> $DIR/suggestions.rs:13:21 + --> $DIR/suggestions.rs:11:21 | -13 | #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896 +11 | #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896 | ^^^^^^^^^^^^^ warning: use of deprecated attribute `no_debug`: the `#[no_debug]` attribute was an experimental feature that has been deprecated due to lack of demand. See https://github.com/rust-lang/rust/issues/29721 - --> $DIR/suggestions.rs:43:1 + --> $DIR/suggestions.rs:41:1 | -43 | #[no_debug] // should suggest removal of deprecated attribute +41 | #[no_debug] // should suggest removal of deprecated attribute | ^^^^^^^^^^^ help: remove this attribute | = note: #[warn(deprecated)] on by default warning: variable does not need to be mutable - --> $DIR/suggestions.rs:48:13 + --> $DIR/suggestions.rs:46:13 | -48 | let mut a = (1); // should suggest no `mut`, no parens - | ----^ +46 | let mut a = (1); // should suggest no `mut`, no parens + | ---^^ | | | help: remove this `mut` | note: lint level defined here - --> $DIR/suggestions.rs:13:9 + --> $DIR/suggestions.rs:11:9 | -13 | #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896 +11 | #![warn(unused_mut, unused_parens)] // UI tests pass `-A unused`—see Issue #43896 | ^^^^^^^^^^ -warning: variable does not need to be mutable - --> $DIR/suggestions.rs:52:13 - | -52 | let mut - | _____________^ - | |_____________| - | || -53 | || b = 1; - | ||____________-^ - | |____________| - | help: remove this `mut` - warning: static is marked #[no_mangle], but not exported - --> $DIR/suggestions.rs:16:14 + --> $DIR/suggestions.rs:14:14 | -16 | #[no_mangle] static SHENZHOU: usize = 1; // should suggest `pub` +14 | #[no_mangle] static SHENZHOU: usize = 1; // should suggest `pub` | -^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | help: try making it public: `pub` @@ -55,9 +43,9 @@ warning: static is marked #[no_mangle], but not exported = note: #[warn(private_no_mangle_statics)] on by default error: const items should never be #[no_mangle] - --> $DIR/suggestions.rs:18:14 + --> $DIR/suggestions.rs:16:14 | -18 | #[no_mangle] const DISCOVERY: usize = 1; // should suggest `pub static` rather than `const` +16 | #[no_mangle] const DISCOVERY: usize = 1; // should suggest `pub static` rather than `const` | -----^^^^^^^^^^^^^^^^^^^^^^ | | | help: try a static value: `pub static` @@ -65,19 +53,19 @@ error: const items should never be #[no_mangle] = note: #[deny(no_mangle_const_items)] on by default warning: functions generic over types must be mangled - --> $DIR/suggestions.rs:22:1 + --> $DIR/suggestions.rs:20:1 | -21 | #[no_mangle] // should suggest removal (generics can't be no-mangle) +19 | #[no_mangle] // should suggest removal (generics can't be no-mangle) | ------------ help: remove this attribute -22 | pub fn defiant(_t: T) {} +20 | pub fn defiant(_t: T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: #[warn(no_mangle_generic_items)] on by default warning: function is marked #[no_mangle], but not exported - --> $DIR/suggestions.rs:26:1 + --> $DIR/suggestions.rs:24:1 | -26 | fn rio_grande() {} // should suggest `pub` +24 | fn rio_grande() {} // should suggest `pub` | -^^^^^^^^^^^^^^^^^ | | | help: try making it public: `pub` @@ -85,29 +73,29 @@ warning: function is marked #[no_mangle], but not exported = note: #[warn(private_no_mangle_fns)] on by default warning: static is marked #[no_mangle], but not exported - --> $DIR/suggestions.rs:33:18 + --> $DIR/suggestions.rs:31:18 | -33 | #[no_mangle] pub static DAUNTLESS: bool = true; +31 | #[no_mangle] pub static DAUNTLESS: bool = true; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: function is marked #[no_mangle], but not exported - --> $DIR/suggestions.rs:35:18 + --> $DIR/suggestions.rs:33:18 | -35 | #[no_mangle] pub fn val_jean() {} +33 | #[no_mangle] pub fn val_jean() {} | ^^^^^^^^^^^^^^^^^^^^ warning: denote infinite loops with `loop { ... }` - --> $DIR/suggestions.rs:46:5 + --> $DIR/suggestions.rs:44:5 | -46 | while true { // should suggest `loop` +44 | while true { // should suggest `loop` | ^^^^^^^^^^ help: use `loop` | = note: #[warn(while_true)] on by default warning: the `warp_factor:` in this pattern is redundant - --> $DIR/suggestions.rs:57:23 + --> $DIR/suggestions.rs:51:23 | -57 | Equinox { warp_factor: warp_factor } => {} // should suggest shorthand +51 | Equinox { warp_factor: warp_factor } => {} // should suggest shorthand | ------------^^^^^^^^^^^^ | | | help: remove this diff --git a/src/test/ui/loop-break-value-no-repeat.stderr b/src/test/ui/loop-break-value-no-repeat.stderr index 982de00b4fa7c..296b3b191e319 100644 --- a/src/test/ui/loop-break-value-no-repeat.stderr +++ b/src/test/ui/loop-break-value-no-repeat.stderr @@ -3,10 +3,6 @@ error[E0571]: `break` with value from a `for` loop | 22 | break 22 //~ ERROR `break` with value from a `for` loop | ^^^^^^^^ can only break with a value inside `loop` -help: instead, use `break` on its own without a value inside this `for` loop - | -22 | break //~ ERROR `break` with value from a `for` loop - | ^^^^^ error: aborting due to previous error diff --git a/src/test/ui/macro_backtrace/main.stderr b/src/test/ui/macro_backtrace/main.stderr index 48138ee711b3f..5990f71b3ca0a 100644 --- a/src/test/ui/macro_backtrace/main.stderr +++ b/src/test/ui/macro_backtrace/main.stderr @@ -22,7 +22,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found 27 | ping!(); | -------- in this macro invocation | - ::: :1:1 + ::: | 1 | ( ) => { pong ! ( ) ; } | ------------------------- @@ -42,7 +42,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found 28 | deep!(); | -------- in this macro invocation (#1) | - ::: :1:1 + ::: | 1 | ( ) => { foo ! ( ) ; } | ------------------------ @@ -50,7 +50,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found | | in this macro invocation (#2) | in this expansion of `deep!` (#1) | - ::: :1:1 + ::: | 1 | ( ) => { bar ! ( ) ; } | ------------------------ @@ -58,7 +58,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found | | in this macro invocation (#3) | in this expansion of `foo!` (#2) | - ::: :1:1 + ::: | 1 | ( ) => { ping ! ( ) ; } | ------------------------- @@ -66,7 +66,7 @@ error: expected one of `!`, `.`, `::`, `;`, `?`, `{`, `}`, or an operator, found | | in this macro invocation (#4) | in this expansion of `bar!` (#3) | - ::: :1:1 + ::: | 1 | ( ) => { pong ! ( ) ; } | ------------------------- diff --git a/src/test/ui/macros/span-covering-argument-1.rs b/src/test/ui/macros/span-covering-argument-1.rs deleted file mode 100644 index bfc137fc7b26d..0000000000000 --- a/src/test/ui/macros/span-covering-argument-1.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -macro_rules! bad { - ($s:ident whatever) => { - { - let $s = 0; - *&mut $s = 0; - //~^ ERROR cannot borrow immutable local variable `foo` as mutable [E0596] - } - } -} - -fn main() { - bad!(foo whatever); -} diff --git a/src/test/ui/macros/span-covering-argument-1.stderr b/src/test/ui/macros/span-covering-argument-1.stderr deleted file mode 100644 index 677d2f10fd6c9..0000000000000 --- a/src/test/ui/macros/span-covering-argument-1.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0596]: cannot borrow immutable local variable `foo` as mutable - --> $DIR/span-covering-argument-1.rs:15:19 - | -14 | let $s = 0; - | -- consider changing this to `mut $s` -15 | *&mut $s = 0; - | ^^ cannot borrow mutably -... -22 | bad!(foo whatever); - | ------------------- in this macro invocation - -error: aborting due to previous error - diff --git a/src/test/ui/mismatched_types/binops.rs b/src/test/ui/mismatched_types/binops.rs index 3f2cb59b11dee..e45616cd67a81 100644 --- a/src/test/ui/mismatched_types/binops.rs +++ b/src/test/ui/mismatched_types/binops.rs @@ -9,10 +9,10 @@ // except according to those terms. fn main() { - 1 + Some(1); //~ ERROR cannot add `std::option::Option<{integer}>` to `{integer}` - 2 as usize - Some(1); //~ ERROR cannot subtract `std::option::Option<{integer}>` from `usize` - 3 * (); //~ ERROR cannot multiply `()` to `{integer}` - 4 / ""; //~ ERROR cannot divide `{integer}` by `&str` + 1 + Some(1); //~ ERROR is not satisfied + 2 as usize - Some(1); //~ ERROR is not satisfied + 3 * (); //~ ERROR is not satisfied + 4 / ""; //~ ERROR is not satisfied 5 < String::new(); //~ ERROR is not satisfied 6 == Ok(1); //~ ERROR is not satisfied } diff --git a/src/test/ui/mismatched_types/binops.stderr b/src/test/ui/mismatched_types/binops.stderr index 828cf636951ed..8541ad52e0177 100644 --- a/src/test/ui/mismatched_types/binops.stderr +++ b/src/test/ui/mismatched_types/binops.stderr @@ -1,31 +1,31 @@ -error[E0277]: cannot add `std::option::Option<{integer}>` to `{integer}` +error[E0277]: the trait bound `{integer}: std::ops::Add>` is not satisfied --> $DIR/binops.rs:12:7 | -12 | 1 + Some(1); //~ ERROR cannot add `std::option::Option<{integer}>` to `{integer}` +12 | 1 + Some(1); //~ ERROR is not satisfied | ^ no implementation for `{integer} + std::option::Option<{integer}>` | = help: the trait `std::ops::Add>` is not implemented for `{integer}` -error[E0277]: cannot subtract `std::option::Option<{integer}>` from `usize` +error[E0277]: the trait bound `usize: std::ops::Sub>` is not satisfied --> $DIR/binops.rs:13:16 | -13 | 2 as usize - Some(1); //~ ERROR cannot subtract `std::option::Option<{integer}>` from `usize` +13 | 2 as usize - Some(1); //~ ERROR is not satisfied | ^ no implementation for `usize - std::option::Option<{integer}>` | = help: the trait `std::ops::Sub>` is not implemented for `usize` -error[E0277]: cannot multiply `()` to `{integer}` +error[E0277]: the trait bound `{integer}: std::ops::Mul<()>` is not satisfied --> $DIR/binops.rs:14:7 | -14 | 3 * (); //~ ERROR cannot multiply `()` to `{integer}` +14 | 3 * (); //~ ERROR is not satisfied | ^ no implementation for `{integer} * ()` | = help: the trait `std::ops::Mul<()>` is not implemented for `{integer}` -error[E0277]: cannot divide `{integer}` by `&str` +error[E0277]: the trait bound `{integer}: std::ops::Div<&str>` is not satisfied --> $DIR/binops.rs:15:7 | -15 | 4 / ""; //~ ERROR cannot divide `{integer}` by `&str` +15 | 4 / ""; //~ ERROR is not satisfied | ^ no implementation for `{integer} / &str` | = help: the trait `std::ops::Div<&str>` is not implemented for `{integer}` diff --git a/src/test/ui/mismatched_types/closure-arg-count.rs b/src/test/ui/mismatched_types/closure-arg-count.rs index 34232e81cbdee..96e5201716c71 100644 --- a/src/test/ui/mismatched_types/closure-arg-count.rs +++ b/src/test/ui/mismatched_types/closure-arg-count.rs @@ -36,9 +36,6 @@ fn main() { //~^ ERROR closure is expected to take let _it = vec![1, 2, 3].into_iter().enumerate().map(qux); //~^ ERROR function is expected to take - - let _it = vec![1, 2, 3].into_iter().map(usize::checked_add); - //~^ ERROR function is expected to take } fn foo() {} diff --git a/src/test/ui/mismatched_types/closure-arg-count.stderr b/src/test/ui/mismatched_types/closure-arg-count.stderr index d2a6d6da814ca..be00ee4d74e7e 100644 --- a/src/test/ui/mismatched_types/closure-arg-count.stderr +++ b/src/test/ui/mismatched_types/closure-arg-count.stderr @@ -90,7 +90,7 @@ error[E0593]: function is expected to take a single 2-tuple as argument, but it 32 | let _it = vec![1, 2, 3].into_iter().enumerate().map(foo); | ^^^ expected function that takes a single 2-tuple as argument ... -44 | fn foo() {} +41 | fn foo() {} | -------- takes 0 arguments error[E0593]: closure is expected to take a single 2-tuple as argument, but it takes 3 distinct arguments @@ -107,14 +107,8 @@ error[E0593]: function is expected to take a single 2-tuple as argument, but it 37 | let _it = vec![1, 2, 3].into_iter().enumerate().map(qux); | ^^^ expected function that takes a single 2-tuple as argument ... -45 | fn qux(x: usize, y: usize) {} +42 | fn qux(x: usize, y: usize) {} | -------------------------- takes 2 distinct arguments -error[E0593]: function is expected to take 1 argument, but it takes 2 arguments - --> $DIR/closure-arg-count.rs:40:41 - | -40 | let _it = vec![1, 2, 3].into_iter().map(usize::checked_add); - | ^^^ expected function that takes 1 argument - -error: aborting due to 12 previous errors +error: aborting due to 11 previous errors diff --git a/src/test/ui/nll/borrowed-match-issue-45045.rs b/src/test/ui/nll/borrowed-match-issue-45045.rs index 4b95bbd5a052b..8688bfa86dc6f 100644 --- a/src/test/ui/nll/borrowed-match-issue-45045.rs +++ b/src/test/ui/nll/borrowed-match-issue-45045.rs @@ -21,7 +21,7 @@ fn main() { let mut e = Xyz::A; let f = &mut e; let g = f; - match e { //~ cannot use `e` because it was mutably borrowed [E0503] + match e { Xyz::A => println!("a"), //~^ cannot use `e` because it was mutably borrowed [E0503] Xyz::B => println!("b"), diff --git a/src/test/ui/nll/borrowed-match-issue-45045.stderr b/src/test/ui/nll/borrowed-match-issue-45045.stderr index f5271b99c4be3..15ca30010a55d 100644 --- a/src/test/ui/nll/borrowed-match-issue-45045.stderr +++ b/src/test/ui/nll/borrowed-match-issue-45045.stderr @@ -1,16 +1,3 @@ -error[E0503]: cannot use `e` because it was mutably borrowed - --> $DIR/borrowed-match-issue-45045.rs:24:5 - | -22 | let f = &mut e; - | ------ borrow of `e` occurs here -23 | let g = f; -24 | / match e { //~ cannot use `e` because it was mutably borrowed [E0503] -25 | | Xyz::A => println!("a"), -26 | | //~^ cannot use `e` because it was mutably borrowed [E0503] -27 | | Xyz::B => println!("b"), -28 | | }; - | |_____^ use of borrowed `e` - error[E0503]: cannot use `e` because it was mutably borrowed --> $DIR/borrowed-match-issue-45045.rs:25:9 | @@ -20,5 +7,5 @@ error[E0503]: cannot use `e` because it was mutably borrowed 25 | Xyz::A => println!("a"), | ^^^^^^ use of borrowed `e` -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/src/test/ui/nll/trait-associated-constant.rs b/src/test/ui/nll/trait-associated-constant.rs deleted file mode 100644 index b0f5fbf7160d1..0000000000000 --- a/src/test/ui/nll/trait-associated-constant.rs +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Test cases where we put various lifetime constraints on trait -// associated constants. - -#![feature(rustc_attrs)] - -use std::option::Option; - -trait Anything<'a: 'b, 'b> { - const AC: Option<&'b str>; -} - -struct OKStruct { } - -impl<'a: 'b, 'b> Anything<'a, 'b> for OKStruct { - const AC: Option<&'b str> = None; -} - -struct FailStruct1 { } - -impl<'a: 'b, 'b, 'c> Anything<'a, 'b> for FailStruct1 { - const AC: Option<&'c str> = None; - //~^ ERROR: mismatched types -} - -struct FailStruct2 { } - -impl<'a: 'b, 'b> Anything<'a, 'b> for FailStruct2 { - const AC: Option<&'a str> = None; - //~^ ERROR: mismatched types -} - -fn main() {} diff --git a/src/test/ui/nll/trait-associated-constant.stderr b/src/test/ui/nll/trait-associated-constant.stderr deleted file mode 100644 index 21c1a6ded93c2..0000000000000 --- a/src/test/ui/nll/trait-associated-constant.stderr +++ /dev/null @@ -1,40 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/trait-associated-constant.rs:31:5 - | -31 | const AC: Option<&'c str> = None; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch - | - = note: expected type `std::option::Option<&'b str>` - found type `std::option::Option<&'c str>` -note: the lifetime 'c as defined on the impl at 30:1... - --> $DIR/trait-associated-constant.rs:30:1 - | -30 | impl<'a: 'b, 'b, 'c> Anything<'a, 'b> for FailStruct1 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...does not necessarily outlive the lifetime 'b as defined on the impl at 30:1 - --> $DIR/trait-associated-constant.rs:30:1 - | -30 | impl<'a: 'b, 'b, 'c> Anything<'a, 'b> for FailStruct1 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0308]: mismatched types - --> $DIR/trait-associated-constant.rs:38:5 - | -38 | const AC: Option<&'a str> = None; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime mismatch - | - = note: expected type `std::option::Option<&'b str>` - found type `std::option::Option<&'a str>` -note: the lifetime 'a as defined on the impl at 37:1... - --> $DIR/trait-associated-constant.rs:37:1 - | -37 | impl<'a: 'b, 'b> Anything<'a, 'b> for FailStruct2 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...does not necessarily outlive the lifetime 'b as defined on the impl at 37:1 - --> $DIR/trait-associated-constant.rs:37:1 - | -37 | impl<'a: 'b, 'b> Anything<'a, 'b> for FailStruct2 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/on-unimplemented/auxiliary/no_debug.rs b/src/test/ui/on-unimplemented/auxiliary/no_debug.rs deleted file mode 100644 index 0f833c6263722..0000000000000 --- a/src/test/ui/on-unimplemented/auxiliary/no_debug.rs +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. -// ignore-tidy-linelength - -#![crate_type = "lib"] - -pub struct Bar; diff --git a/src/test/ui/on-unimplemented/no-debug.rs b/src/test/ui/on-unimplemented/no-debug.rs deleted file mode 100644 index fff6122c6b34b..0000000000000 --- a/src/test/ui/on-unimplemented/no-debug.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// aux-build:no_debug.rs - -extern crate no_debug; - -use no_debug::Bar; - -struct Foo; - -fn main() { - println!("{:?} {:?}", Foo, Bar); - println!("{} {}", Foo, Bar); -} -//~^^^ ERROR `Foo` doesn't implement `std::fmt::Debug` -//~| ERROR `no_debug::Bar` doesn't implement `std::fmt::Debug` -//~^^^^ ERROR `Foo` doesn't implement `std::fmt::Display` -//~| ERROR `no_debug::Bar` doesn't implement `std::fmt::Display` - diff --git a/src/test/ui/on-unimplemented/no-debug.stderr b/src/test/ui/on-unimplemented/no-debug.stderr deleted file mode 100644 index af5b1e91211fb..0000000000000 --- a/src/test/ui/on-unimplemented/no-debug.stderr +++ /dev/null @@ -1,38 +0,0 @@ -error[E0277]: `Foo` doesn't implement `std::fmt::Debug` - --> $DIR/no-debug.rs:20:27 - | -20 | println!("{:?} {:?}", Foo, Bar); - | ^^^ `Foo` cannot be formatted using `:?`; add `#[derive(Debug)]` or manually implement `std::fmt::Debug` - | - = help: the trait `std::fmt::Debug` is not implemented for `Foo` - = note: required by `std::fmt::Debug::fmt` - -error[E0277]: `no_debug::Bar` doesn't implement `std::fmt::Debug` - --> $DIR/no-debug.rs:20:32 - | -20 | println!("{:?} {:?}", Foo, Bar); - | ^^^ `no_debug::Bar` cannot be formatted using `:?` because it doesn't implement `std::fmt::Debug` - | - = help: the trait `std::fmt::Debug` is not implemented for `no_debug::Bar` - = note: required by `std::fmt::Debug::fmt` - -error[E0277]: `Foo` doesn't implement `std::fmt::Display` - --> $DIR/no-debug.rs:21:23 - | -21 | println!("{} {}", Foo, Bar); - | ^^^ `Foo` cannot be formatted with the default formatter; try using `:?` instead if you are using a format string - | - = help: the trait `std::fmt::Display` is not implemented for `Foo` - = note: required by `std::fmt::Display::fmt` - -error[E0277]: `no_debug::Bar` doesn't implement `std::fmt::Display` - --> $DIR/no-debug.rs:21:28 - | -21 | println!("{} {}", Foo, Bar); - | ^^^ `no_debug::Bar` cannot be formatted with the default formatter; try using `:?` instead if you are using a format string - | - = help: the trait `std::fmt::Display` is not implemented for `no_debug::Bar` - = note: required by `std::fmt::Display::fmt` - -error: aborting due to 4 previous errors - diff --git a/src/test/ui/param-bounds-ignored.rs b/src/test/ui/param-bounds-ignored.rs deleted file mode 100644 index 9e09102f2d439..0000000000000 --- a/src/test/ui/param-bounds-ignored.rs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// must-compile-successfully - -use std::rc::Rc; - -type SVec = Vec; -type VVec<'b, 'a: 'b> = Vec<&'a i32>; -type WVec<'b, T: 'b> = Vec; - -fn foo<'a>(y: &'a i32) { - // If the bounds above would matter, the code below would be rejected. - let mut x : SVec<_> = Vec::new(); - x.push(Rc::new(42)); - - let mut x : VVec<'static, 'a> = Vec::new(); - x.push(y); - - let mut x : WVec<'static, & 'a i32> = Vec::new(); - x.push(y); -} - -fn main() { - foo(&42); -} diff --git a/src/test/ui/param-bounds-ignored.stderr b/src/test/ui/param-bounds-ignored.stderr deleted file mode 100644 index 19aa9c5d6e562..0000000000000 --- a/src/test/ui/param-bounds-ignored.stderr +++ /dev/null @@ -1,18 +0,0 @@ -warning[E0122]: generic bounds are ignored in type aliases - --> $DIR/param-bounds-ignored.rs:15:1 - | -15 | type SVec = Vec; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning[E0122]: generic bounds are ignored in type aliases - --> $DIR/param-bounds-ignored.rs:16:1 - | -16 | type VVec<'b, 'a: 'b> = Vec<&'a i32>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning[E0122]: generic bounds are ignored in type aliases - --> $DIR/param-bounds-ignored.rs:17:1 - | -17 | type WVec<'b, T: 'b> = Vec; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - diff --git a/src/test/ui/recursive-requirements.rs b/src/test/ui/recursive-requirements.rs deleted file mode 100644 index 2c0f0338b2d15..0000000000000 --- a/src/test/ui/recursive-requirements.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::marker::PhantomData; - -struct AssertSync(PhantomData); - -pub struct Foo { - bar: *const Bar, - phantom: PhantomData, -} - -pub struct Bar { - foo: *const Foo, - phantom: PhantomData, -} - -fn main() { - let _: AssertSync = unimplemented!(); //~ ERROR E0275 -} diff --git a/src/test/ui/recursive-requirements.stderr b/src/test/ui/recursive-requirements.stderr deleted file mode 100644 index 8cf2c65b1e25c..0000000000000 --- a/src/test/ui/recursive-requirements.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0275]: overflow evaluating the requirement `Foo: std::marker::Sync` - --> $DIR/recursive-requirements.rs:26:12 - | -26 | let _: AssertSync = unimplemented!(); //~ ERROR E0275 - | ^^^^^^^^^^^^^^^ - | - = help: consider adding a `#![recursion_limit="128"]` attribute to your crate - = note: required because it appears within the type `std::marker::PhantomData` - = note: required because it appears within the type `Bar` - = note: required because it appears within the type `std::marker::PhantomData` - = note: required because it appears within the type `Foo` - -error: aborting due to previous error - diff --git a/src/test/ui/resolve-conflict-item-vs-import.stderr b/src/test/ui/resolve-conflict-item-vs-import.stderr index e2245b8a8b10a..03ef66681e440 100644 --- a/src/test/ui/resolve-conflict-item-vs-import.stderr +++ b/src/test/ui/resolve-conflict-item-vs-import.stderr @@ -10,8 +10,8 @@ error[E0255]: the name `transmute` is defined multiple times = note: `transmute` must be defined only once in the value namespace of this module help: You can use `as` to change the binding name of the import | -11 | use std::mem::transmute as other_transmute; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +11 | use std::mem::transmute as Othertransmute; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/span/issue-24690.stderr b/src/test/ui/span/issue-24690.stderr index 31728dbf08db2..7e19c7492ce0b 100644 --- a/src/test/ui/span/issue-24690.stderr +++ b/src/test/ui/span/issue-24690.stderr @@ -2,7 +2,7 @@ warning: unused variable: `theOtherTwo` --> $DIR/issue-24690.rs:23:9 | 23 | let theOtherTwo = 2; //~ WARN should have a snake case name - | ^^^^^^^^^^^ help: consider using `_theOtherTwo` instead + | ^^^^^^^^^^^ | note: lint level defined here --> $DIR/issue-24690.rs:18:9 @@ -10,6 +10,7 @@ note: lint level defined here 18 | #![warn(unused)] | ^^^^^^ = note: #[warn(unused_variables)] implied by #[warn(unused)] + = note: to avoid this warning, consider using `_theOtherTwo` instead warning: variable `theTwo` should have a snake case name such as `the_two` --> $DIR/issue-24690.rs:22:9 diff --git a/src/test/ui/span/issue-42234-unknown-receiver-type.rs b/src/test/ui/span/issue-42234-unknown-receiver-type.rs deleted file mode 100644 index 2d910b520ff9f..0000000000000 --- a/src/test/ui/span/issue-42234-unknown-receiver-type.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// When the type of a method call's receiver is unknown, the span should point -// to the receiver (and not the entire call, as was previously the case before -// the fix of which this tests). - -fn shines_a_beacon_through_the_darkness() { - let x: Option<_> = None; - x.unwrap().method_that_could_exist_on_some_type(); - //~^ ERROR 17:5: 17:15: type annotations needed [E0282] -} - -fn courier_to_des_moines_and_points_west(data: &[u32]) -> String { - data.iter() //~ ERROR 22:5: 23:20: type annotations needed [E0282] - .sum::<_>() - .to_string() -} - -fn main() {} diff --git a/src/test/ui/span/issue-42234-unknown-receiver-type.stderr b/src/test/ui/span/issue-42234-unknown-receiver-type.stderr deleted file mode 100644 index ed756cdc553ce..0000000000000 --- a/src/test/ui/span/issue-42234-unknown-receiver-type.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0619]: the type of this value must be known in this context - --> $DIR/issue-42234-unknown-receiver-type.rs:17:5 - | -17 | x.unwrap().method_that_could_exist_on_some_type(); - | ^^^^^^^^^^ - -error[E0619]: the type of this value must be known in this context - --> $DIR/issue-42234-unknown-receiver-type.rs:22:5 - | -22 | / data.iter() //~ ERROR 22:5: 23:20: the type of this value must be known in this context -23 | | .sum::<_>() - | |___________________^ - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/span/macro-span-replacement.stderr b/src/test/ui/span/macro-span-replacement.stderr index 728cd12e2c685..2a0e71e192c62 100644 --- a/src/test/ui/span/macro-span-replacement.stderr +++ b/src/test/ui/span/macro-span-replacement.stderr @@ -1,8 +1,8 @@ warning: struct is never used: `S` - --> $DIR/macro-span-replacement.rs:17:14 + --> $DIR/macro-span-replacement.rs:17:9 | 17 | $b $a; //~ WARN struct is never used - | ^ + | ^^^^^^ ... 22 | m!(S struct); | ------------- in this macro invocation diff --git a/src/test/ui/span/multiline-span-simple.rs b/src/test/ui/span/multiline-span-simple.rs index dd09534480e10..f8e4cbcbf191f 100644 --- a/src/test/ui/span/multiline-span-simple.rs +++ b/src/test/ui/span/multiline-span-simple.rs @@ -20,7 +20,7 @@ fn main() { let x = 1; let y = 2; let z = 3; - foo(1 as u32 + //~ ERROR cannot add `()` to `u32` + foo(1 as u32 + //~ ERROR not satisfied bar(x, diff --git a/src/test/ui/span/multiline-span-simple.stderr b/src/test/ui/span/multiline-span-simple.stderr index a18dfeb31d9ef..b068798630ed8 100644 --- a/src/test/ui/span/multiline-span-simple.stderr +++ b/src/test/ui/span/multiline-span-simple.stderr @@ -1,7 +1,7 @@ -error[E0277]: cannot add `()` to `u32` +error[E0277]: the trait bound `u32: std::ops::Add<()>` is not satisfied --> $DIR/multiline-span-simple.rs:23:18 | -23 | foo(1 as u32 + //~ ERROR cannot add `()` to `u32` +23 | foo(1 as u32 + //~ ERROR not satisfied | ^ no implementation for `u32 + ()` | = help: the trait `std::ops::Add<()>` is not implemented for `u32` diff --git a/src/test/ui/static-lifetime.stderr b/src/test/ui/static-lifetime.stderr index 24ba27b27ad36..a99dbf21e54e2 100644 --- a/src/test/ui/static-lifetime.stderr +++ b/src/test/ui/static-lifetime.stderr @@ -8,7 +8,7 @@ note: lifetime parameter instantiated with the lifetime 'a as defined on the imp --> $DIR/static-lifetime.rs:13:1 | 13 | impl<'a, A: Clone> Arbitrary for ::std::borrow::Cow<'a, A> {} //~ ERROR lifetime bound - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: but lifetime parameter must outlive the static lifetime error: aborting due to previous error diff --git a/src/test/ui/suggestions/for-c-in-str.stderr b/src/test/ui/suggestions/for-c-in-str.stderr index 88a7b1b49d62d..7a6dc9a504029 100644 --- a/src/test/ui/suggestions/for-c-in-str.stderr +++ b/src/test/ui/suggestions/for-c-in-str.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `&str: std::iter::Iterator` is not satisfied --> $DIR/for-c-in-str.rs:14:14 | 14 | for c in "asdf" { - | ^^^^^^ `&str` is not an iterator; try calling `.chars()` or `.bytes()` + | ^^^^^^ `&str` is not an iterator; maybe try calling `.iter()` or a similar method | = help: the trait `std::iter::Iterator` is not implemented for `&str` = note: required by `std::iter::IntoIterator::into_iter` diff --git a/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr b/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr index 01dba62a8511d..d2ac15f7ffcb3 100644 --- a/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr +++ b/src/test/ui/suggestions/issue-45799-bad-extern-crate-rename-suggestion-formatting.stderr @@ -7,7 +7,7 @@ error[E0259]: the name `std` is defined multiple times = note: `std` must be defined only once in the type namespace of this module help: You can use `as` to change the binding name of the import | -11 | extern crate std as other_std; +11 | extern crate std as Otherstd; | error: aborting due to previous error diff --git a/src/test/ui/use-mod.stderr b/src/test/ui/use-mod.stderr index 1c9f306f493db..bb64909e64a0c 100644 --- a/src/test/ui/use-mod.stderr +++ b/src/test/ui/use-mod.stderr @@ -25,7 +25,7 @@ error[E0252]: the name `bar` is defined multiple times = note: `bar` must be defined only once in the type namespace of this module help: You can use `as` to change the binding name of the import | -15 | self as other_bar +15 | self as Otherbar | error: aborting due to 3 previous errors diff --git a/src/test/ui/use-nested-groups-error.rs b/src/test/ui/use-nested-groups-error.rs deleted file mode 100644 index 0a68d34ade9fa..0000000000000 --- a/src/test/ui/use-nested-groups-error.rs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -mod a { - pub mod b1 { - pub enum C2 {} - } - - pub enum B2 {} -} - -use a::{b1::{C1, C2}, B2}; -//~^ ERROR unresolved import `a::b1::C1` - -fn main() { - let _: C2; - let _: B2; -} diff --git a/src/test/ui/use-nested-groups-error.stderr b/src/test/ui/use-nested-groups-error.stderr deleted file mode 100644 index c4edb626be0bb..0000000000000 --- a/src/test/ui/use-nested-groups-error.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error[E0432]: unresolved import `a::b1::C1` - --> $DIR/use-nested-groups-error.rs:19:14 - | -19 | use a::{b1::{C1, C2}, B2}; - | ^^ no `C1` in `a::b1`. Did you mean to use `C2`? - -error: aborting due to previous error - diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 80750f9a3fee0..ff662736bdd1b 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -167,7 +167,7 @@ impl EarlyProps { .expect("Malformed llvm version directive"); // Ignore if using system LLVM and actual version // is smaller the minimum required version - config.system_llvm && &actual_version[..] < min_version + !(config.system_llvm && &actual_version[..] < min_version) } else { false } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index a87809dd7bcfd..bf5fc00428df2 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -79,7 +79,7 @@ pub fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec { if lines_since_mismatch >= context_size && lines_since_mismatch > 0 { @@ -91,8 +91,7 @@ pub fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec { @@ -105,7 +104,8 @@ pub fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec { @@ -1343,7 +1343,7 @@ impl<'test> TestCx<'test> { fn exec_compiled_test(&self) -> ProcRes { let env = &self.props.exec_env; - let proc_res = match &*self.config.target { + match &*self.config.target { // This is pretty similar to below, we're transforming: // // program arg1 arg2 @@ -1398,19 +1398,11 @@ impl<'test> TestCx<'test> { None, ) } - }; - - if proc_res.status.success() { - // delete the executable after running it to save space. - // it is ok if the deletion failed. - let _ = fs::remove_file(self.make_exe_name()); } - - proc_res } /// For each `aux-build: foo/bar` annotation, we check to find the - /// file in a `auxiliary` directory relative to the test itself. + /// file in a `aux` directory relative to the test itself. fn compute_aux_test_paths(&self, rel_ab: &str) -> TestPaths { let test_ab = self.testpaths .file diff --git a/src/tools/rustbook/Cargo.toml b/src/tools/rustbook/Cargo.toml index 539b434e9eca5..bc35cbe9fbba6 100644 --- a/src/tools/rustbook/Cargo.toml +++ b/src/tools/rustbook/Cargo.toml @@ -8,5 +8,5 @@ license = "MIT/Apache-2.0" clap = "2.25.0" [dependencies.mdbook] -version = "0.1.2" +version = "0.0.28" default-features = false diff --git a/src/tools/rustbook/src/main.rs b/src/tools/rustbook/src/main.rs index 87a63a34cb642..50f4364e448f7 100644 --- a/src/tools/rustbook/src/main.rs +++ b/src/tools/rustbook/src/main.rs @@ -13,6 +13,7 @@ extern crate mdbook; extern crate clap; use std::env; +use std::io::{self, Write}; use std::path::{Path, PathBuf}; use clap::{App, ArgMatches, SubCommand, AppSettings}; @@ -44,19 +45,14 @@ fn main() { }; if let Err(e) = res { - eprintln!("Error: {}", e); - - for cause in e.iter().skip(1) { - eprintln!("\tCaused By: {}", cause); - } - + writeln!(&mut io::stderr(), "An error occured:\n{}", e).ok(); ::std::process::exit(101); } } // Build command implementation pub fn build(args: &ArgMatches) -> Result<()> { let book_dir = get_book_dir(args); - let mut book = MDBook::load(&book_dir)?; + let mut book = MDBook::new(&book_dir).read_config()?; // Set this to allow us to catch bugs in advance. book.config.build.create_missing = false; diff --git a/src/tools/rustdoc-themes/Cargo.toml b/src/tools/rustdoc-themes/Cargo.toml deleted file mode 100644 index c0e2f527301be..0000000000000 --- a/src/tools/rustdoc-themes/Cargo.toml +++ /dev/null @@ -1,8 +0,0 @@ -[package] -name = "rustdoc-themes" -version = "0.1.0" -authors = ["Guillaume Gomez "] - -[[bin]] -name = "rustdoc-themes" -path = "main.rs" diff --git a/src/tools/rustdoc-themes/main.rs b/src/tools/rustdoc-themes/main.rs deleted file mode 100644 index 4028cb4e8b6ed..0000000000000 --- a/src/tools/rustdoc-themes/main.rs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2018 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::env::args; -use std::fs::read_dir; -use std::path::Path; -use std::process::{Command, exit}; - -const FILES_TO_IGNORE: &[&str] = &["main.css"]; - -fn get_folders>(folder_path: P) -> Vec { - let mut ret = Vec::with_capacity(10); - - for entry in read_dir(folder_path.as_ref()).expect("read_dir failed") { - let entry = entry.expect("Couldn't unwrap entry"); - let path = entry.path(); - - if !path.is_file() { - continue - } - let filename = path.file_name().expect("file_name failed"); - if FILES_TO_IGNORE.iter().any(|x| x == &filename) { - continue - } - ret.push(format!("{}", path.display())); - } - ret -} - -fn main() { - let argv: Vec = args().collect(); - - if argv.len() < 3 { - eprintln!("Needs rustdoc binary path"); - exit(1); - } - let rustdoc_bin = &argv[1]; - let themes_folder = &argv[2]; - let themes = get_folders(&themes_folder); - if themes.is_empty() { - eprintln!("No theme found in \"{}\"...", themes_folder); - exit(1); - } - let status = Command::new(rustdoc_bin) - .args(&["-Z", "unstable-options", "--theme-checker"]) - .args(&themes) - .status() - .expect("failed to execute child"); - if !status.success() { - exit(1); - } -} diff --git a/src/tools/tidy/src/deps.rs b/src/tools/tidy/src/deps.rs index 159c9e035b7a2..bc2767c7bcc5d 100644 --- a/src/tools/tidy/src/deps.rs +++ b/src/tools/tidy/src/deps.rs @@ -33,8 +33,6 @@ static EXCEPTIONS: &'static [&'static str] = &[ "openssl", // BSD+advertising clause, cargo, mdbook "pest", // MPL2, mdbook via handlebars "thread-id", // Apache-2.0, mdbook - "toml-query", // MPL-2.0, mdbook - "is-match", // MPL-2.0, mdbook "cssparser", // MPL-2.0, rustdoc "smallvec", // MPL-2.0, rustdoc "fuchsia-zircon-sys", // BSD-3-Clause, rustdoc, rustc, cargo