diff --git a/RELEASES.md b/RELEASES.md index 819c918436..70a7dab722 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,144 @@ +Version 1.30.0 (2018-10-25) +========================== + +Language +-------- +- [Procedural macros are now available.][52081] These kinds of macros allow for + more powerful code generation. There is a [new chapter available][proc-macros] + in the Rust Programming Language book that goes further in depth. +- [You can now use keywords as identifiers using the raw identifiers + syntax (`r#`),][53236] e.g. `let r#for = true;` +- [Using anonymous parameters in traits is now deprecated with a warning and + will be a hard error in the 2018 edition.][53272] +- [You can now use `crate` in paths.][54404] This allows you to refer to the + crate root in the path, e.g. `use crate::foo;` refers to `foo` in `src/lib.rs`. +- [Using a external crate no longer requires being prefixed with `::`.][54404] + Previously, using a external crate in a module without a use statement + required `let json = ::serde_json::from_str(foo);` but can now be written + as `let json = serde_json::from_str(foo);`. +- [You can now apply the `#[used]` attribute to static items to prevent the + compiler from optimising them away, even if they appear to be unused,][51363] + e.g. `#[used] static FOO: u32 = 1;` +- [You can now import and reexport macros from other crates with the `use` + syntax.][50911] Macros exported with `#[macro_export]` are now placed into + the root module of the crate. If your macro relies on calling other local + macros, it is recommended to export with the + `#[macro_export(local_inner_macros)]` attribute so users won't have to import + those macros. +- [You can now catch visibility keywords (e.g. `pub`, `pub(crate)`) in macros + using the `vis` specifier.][53370] +- [Non-macro attributes now allow all forms of literals, not just + strings.][53044] Previously, you would write `#[attr("true")]`, and you can now + write `#[attr(true)]`. +- [You can now specify a function to handle a panic in the Rust runtime with the + `#[panic_handler]` attribute.][51366] + +Compiler +-------- +- [Added the `riscv32imc-unknown-none-elf` target.][53822] +- [Added the `aarch64-unknown-netbsd` target][53165] + +Libraries +--------- +- [`ManuallyDrop` now allows the inner type to be unsized.][53033] + +Stabilized APIs +--------------- +- [`Ipv4Addr::BROADCAST`] +- [`Ipv4Addr::LOCALHOST`] +- [`Ipv4Addr::UNSPECIFIED`] +- [`Ipv6Addr::LOCALHOST`] +- [`Ipv6Addr::UNSPECIFIED`] +- [`Iterator::find_map`] + + The following methods are replacement methods for `trim_left`, `trim_right`, + `trim_left_matches`, and `trim_right_matches`, which will be deprecated + in 1.33.0: +- [`str::trim_end_matches`] +- [`str::trim_end`] +- [`str::trim_start_matches`] +- [`str::trim_start`] + +Cargo +---- +- [`cargo run` doesn't require specifying a package in workspaces.][cargo/5877] +- [`cargo doc` now supports `--message-format=json`.][cargo/5878] This is + equivalent to calling `rustdoc --error-format=json`. +- [You can specify which edition to create a project in cargo + with `cargo new --edition`.][cargo/5984] Currently only `2015` is a + valid option. +- [Cargo will now provide a progress bar for builds.][cargo/5995] + +Misc +---- +- [`rustdoc` allows you to specify what edition to treat your code as with the + `--edition` option.][54057] +- [`rustdoc` now has the `--color` (specify whether to output color) and + `--error-format` (specify error format, e.g. `json`) options.][53003] +- [We now distribute a `rust-gdbgui` script that invokes `gdbgui` with Rust + debug symbols.][53774] +- [Attributes from Rust tools such as `rustfmt` or `clippy` are now + available,][53459] e.g. `#[rustfmt::skip]` will skip formatting the next item. + +[50911]: https://github.com/rust-lang/rust/pull/50911/ +[51363]: https://github.com/rust-lang/rust/pull/51363/ +[51366]: https://github.com/rust-lang/rust/pull/51366/ +[52081]: https://github.com/rust-lang/rust/pull/52081/ +[53003]: https://github.com/rust-lang/rust/pull/53003/ +[53033]: https://github.com/rust-lang/rust/pull/53033/ +[53044]: https://github.com/rust-lang/rust/pull/53044/ +[53165]: https://github.com/rust-lang/rust/pull/53165/ +[53213]: https://github.com/rust-lang/rust/pull/53213/ +[53236]: https://github.com/rust-lang/rust/pull/53236/ +[53272]: https://github.com/rust-lang/rust/pull/53272/ +[53370]: https://github.com/rust-lang/rust/pull/53370/ +[53459]: https://github.com/rust-lang/rust/pull/53459/ +[53774]: https://github.com/rust-lang/rust/pull/53774/ +[53822]: https://github.com/rust-lang/rust/pull/53822/ +[54057]: https://github.com/rust-lang/rust/pull/54057/ +[54146]: https://github.com/rust-lang/rust/pull/54146/ +[54404]: https://github.com/rust-lang/rust/pull/54404/ +[cargo/5877]: https://github.com/rust-lang/cargo/pull/5877/ +[cargo/5878]: https://github.com/rust-lang/cargo/pull/5878/ +[cargo/5984]: https://github.com/rust-lang/cargo/pull/5984/ +[cargo/5995]: https://github.com/rust-lang/cargo/pull/5995/ +[proc-macros]: https://doc.rust-lang.org/book/2018-edition/ch19-06-macros.html + +[`Ipv4Addr::BROADCAST`]: https://doc.rust-lang.org/nightly/std/net/struct.Ipv4Addr.html#associatedconstant.BROADCAST +[`Ipv4Addr::LOCALHOST`]: https://doc.rust-lang.org/nightly/std/net/struct.Ipv4Addr.html#associatedconstant.LOCALHOST +[`Ipv4Addr::UNSPECIFIED`]: https://doc.rust-lang.org/nightly/std/net/struct.Ipv4Addr.html#associatedconstant.UNSPECIFIED +[`Ipv6Addr::LOCALHOST`]: https://doc.rust-lang.org/nightly/std/net/struct.Ipv6Addr.html#associatedconstant.LOCALHOST +[`Ipv6Addr::UNSPECIFIED`]: https://doc.rust-lang.org/nightly/std/net/struct.Ipv6Addr.html#associatedconstant.UNSPECIFIED +[`Iterator::find_map`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.find_map +[`str::trim_end_matches`]: https://doc.rust-lang.org/nightly/std/primitive.str.html#method.trim_end_matches +[`str::trim_end`]: https://doc.rust-lang.org/nightly/std/primitive.str.html#method.trim_end +[`str::trim_start_matches`]: https://doc.rust-lang.org/nightly/std/primitive.str.html#method.trim_start_matches +[`str::trim_start`]: https://doc.rust-lang.org/nightly/std/primitive.str.html#method.trim_start + + +Version 1.29.2 (2018-10-11) +=========================== + +- [Workaround for an aliasing-related LLVM bug, which caused miscompilation.][54639] +- The `rls-preview` component on the windows-gnu targets has been restored. + +[54639]: https://github.com/rust-lang/rust/pull/54639 + + +Version 1.29.1 (2018-09-25) +=========================== + +Security Notes +-------------- + +- The standard library's `str::repeat` function contained an out of bounds write + caused by an integer overflow. This has been fixed by deterministically + panicking when an overflow happens. + + Thank you to Scott McMurray for responsibily disclosing this vulnerability to + us. + + Version 1.29.0 (2018-09-13) ========================== @@ -9,7 +150,7 @@ Compiler Libraries --------- -- [`Once::call_once` now no longer requires `Once` to be `'static`.][52239] +- [`Once::call_once` no longer requires `Once` to be `'static`.][52239] - [`BuildHasherDefault` now implements `PartialEq` and `Eq`.][52402] - [`Box`, `Box`, and `Box` now implement `Clone`.][51912] - [Implemented `PartialEq<&str>` for `OsString` and `PartialEq` @@ -25,10 +166,10 @@ Stabilized APIs Cargo ----- -- [Cargo can silently fix some bad lockfiles ][cargo/5831] You can use - `--locked` to disable this behaviour. +- [Cargo can silently fix some bad lockfiles.][cargo/5831] You can use + `--locked` to disable this behavior. - [`cargo-install` will now allow you to cross compile an install - using `--target`][cargo/5614] + using `--target`.][cargo/5614] - [Added the `cargo-fix` subcommand to automatically move project code from 2015 edition to 2018.][cargo/5723] - [`cargo doc` can now optionally document private types using the @@ -40,19 +181,22 @@ Misc the specified level to that level.][52354] For example `--cap-lints warn` will demote `deny` and `forbid` lints to `warn`. - [`rustc` and `rustdoc` will now have the exit code of `1` if compilation - fails, and `101` if there is a panic.][52197] + fails and `101` if there is a panic.][52197] - [A preview of clippy has been made available through rustup.][51122] - You can install the preview with `rustup component add clippy-preview` + You can install the preview with `rustup component add clippy-preview`. Compatibility Notes ------------------- - [`str::{slice_unchecked, slice_unchecked_mut}` are now deprecated.][51807] Use `str::get_unchecked(begin..end)` instead. -- [`std::env::home_dir` is now deprecated for its unintuitive behaviour.][51656] +- [`std::env::home_dir` is now deprecated for its unintuitive behavior.][51656] Consider using the `home_dir` function from https://crates.io/crates/dirs instead. - [`rustc` will no longer silently ignore invalid data in target spec.][52330] +- [`cfg` attributes and `--cfg` command line flags are now more + strictly validated.][53893] +[53893]: https://github.com/rust-lang/rust/pull/53893/ [52861]: https://github.com/rust-lang/rust/pull/52861/ [52656]: https://github.com/rust-lang/rust/pull/52656/ [52239]: https://github.com/rust-lang/rust/pull/52239/ @@ -285,7 +429,7 @@ Language be used as an identifier. - [The dyn syntax is now available.][49968] This syntax is equivalent to the bare `Trait` syntax, and should make it clearer when being used in tandem with - `impl Trait`. Since it is equivalent to the following syntax: + `impl Trait` because it is equivalent to the following syntax: `&Trait == &dyn Trait`, `&mut Trait == &mut dyn Trait`, and `Box == Box`. - [Attributes on generic parameters such as types and lifetimes are @@ -348,10 +492,10 @@ Cargo a different directory than `target` for placing compilation artifacts. - [Cargo will be adding automatic target inference for binaries, benchmarks, examples, and tests in the Rust 2018 edition.][cargo/5335] If your project specifies - specific targets e.g. using `[[bin]]` and have other binaries in locations + specific targets, e.g. using `[[bin]]`, and have other binaries in locations where cargo would infer a binary, Cargo will produce a warning. You can - disable this feature ahead of time by setting any of the following `autobins`, - `autobenches`, `autoexamples`, `autotests` to false. + disable this feature ahead of time by setting any of the following to false: + `autobins`, `autobenches`, `autoexamples`, `autotests`. - [Cargo will now cache compiler information.][cargo/5359] This can be disabled by setting `CARGO_CACHE_RUSTC_INFO=0` in your environment. @@ -367,8 +511,8 @@ Compatibility Notes work.][49896] e.g. `::core::prelude::v1::StrExt::is_empty("")` will not compile, `"".is_empty()` will still compile. - [`Debug` output on `atomic::{AtomicBool, AtomicIsize, AtomicPtr, AtomicUsize}` - will only print the inner type.][48553] e.g. - `print!("{:?}", AtomicBool::new(true))` will print `true` + will only print the inner type.][48553] E.g. + `print!("{:?}", AtomicBool::new(true))` will print `true`, not `AtomicBool(true)`. - [The maximum number for `repr(align(N))` is now 2²⁹.][50378] Previously you could enter higher numbers but they were not supported by LLVM. Up to 512MB @@ -431,7 +575,7 @@ Version 1.26.2 (2018-06-05) Compatibility Notes ------------------- -- [The borrow checker was fixed to avoid unsoundness when using match ergonomics][51117] +- [The borrow checker was fixed to avoid unsoundness when using match ergonomics.][51117] [51117]: https://github.com/rust-lang/rust/issues/51117 @@ -442,18 +586,18 @@ Version 1.26.1 (2018-05-29) Tools ----- -- [RLS now works on Windows][50646] -- [Rustfmt stopped badly formatting text in some cases][rustfmt/2695] +- [RLS now works on Windows.][50646] +- [Rustfmt stopped badly formatting text in some cases.][rustfmt/2695] Compatibility Notes -------- - [`fn main() -> impl Trait` no longer works for non-Termination - trait][50656] + trait.][50656] This reverts an accidental stabilization. -- [`NaN > NaN` no longer returns true in const-fn contexts][50812] -- [Prohibit using turbofish for `impl Trait` in method arguments][50950] +- [`NaN > NaN` no longer returns true in const-fn contexts.][50812] +- [Prohibit using turbofish for `impl Trait` in method arguments.][50950] [50646]: https://github.com/rust-lang/rust/issues/50646 [50656]: https://github.com/rust-lang/rust/pull/50656 @@ -469,18 +613,18 @@ Language - [Closures now implement `Copy` and/or `Clone` if all captured variables implement either or both traits.][49299] - [The inclusive range syntax e.g. `for x in 0..=10` is now stable.][47813] -- [The `'_` lifetime is now stable. The underscore lifetime can be used anywhere where a +- [The `'_` lifetime is now stable. The underscore lifetime can be used anywhere a lifetime can be elided.][49458] - [`impl Trait` is now stable allowing you to have abstract types in returns - or in function parameters.][49255] e.g. `fn foo() -> impl Iterator` or + or in function parameters.][49255] E.g. `fn foo() -> impl Iterator` or `fn open(path: impl AsRef)`. - [Pattern matching will now automatically apply dereferences.][49394] - [128-bit integers in the form of `u128` and `i128` are now stable.][49101] - [`main` can now return `Result<(), E: Debug>`][49162] in addition to `()`. - [A lot of operations are now available in a const context.][46882] E.g. You can now index into constant arrays, reference and dereference into constants, - and use Tuple struct constructors. -- [Fixed entry slice patterns are now stable.][48516] e.g. + and use tuple struct constructors. +- [Fixed entry slice patterns are now stable.][48516] E.g. ```rust let points = [1, 2, 3, 4]; match points { @@ -905,7 +1049,7 @@ Language Compiler -------- - [Enabled `TrapUnreachable` in LLVM which should mitigate the impact of - undefined behaviour.][45920] + undefined behavior.][45920] - [rustc now suggests renaming import if names clash.][45660] - [Display errors/warnings correctly when there are zero-width or wide characters.][45711] diff --git a/git-commit-hash b/git-commit-hash index 4c97a81ef5..92715c5caf 100644 --- a/git-commit-hash +++ b/git-commit-hash @@ -1 +1 @@ -0ebb250883d63faae833070c11287fc6e7305517 \ No newline at end of file +da5f414c2c0bfe5198934493f04c676e2b23ff2e \ No newline at end of file diff --git a/src/ci/run.sh b/src/ci/run.sh index a965c44031..7b89ab5a9f 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -51,7 +51,7 @@ fi # # FIXME: need a scheme for changing this `nightly` value to `beta` and `stable` # either automatically or manually. -export RUST_RELEASE_CHANNEL=beta +export RUST_RELEASE_CHANNEL=stable 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" diff --git a/src/doc/rustdoc/src/command-line-arguments.md b/src/doc/rustdoc/src/command-line-arguments.md index aba485f752..417608cc5c 100644 --- a/src/doc/rustdoc/src/command-line-arguments.md +++ b/src/doc/rustdoc/src/command-line-arguments.md @@ -345,17 +345,3 @@ $ rustdoc src/lib.rs --sysroot /path/to/sysroot Similar to `rustc --sysroot`, this lets you change the sysroot `rustdoc` uses when compiling your code. - -### `--edition`: control the edition of docs and doctests - -Using this flag looks like this: - -```bash -$ rustdoc src/lib.rs --edition 2018 -$ rustdoc --test src/lib.rs --edition 2018 -``` - -This flag allows rustdoc to treat your rust code as the given edition. It will compile doctests with -the given edition as well. As with `rustc`, the default edition that `rustdoc` will use is `2015` -(the first edition). - diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 071575b1fc..32fb8c2f7d 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -346,6 +346,19 @@ details. [issue-display-warnings]: https://github.com/rust-lang/rust/issues/41574 +### `--edition`: control the edition of docs and doctests + +Using this flag looks like this: + +```bash +$ rustdoc src/lib.rs -Z unstable-options --edition 2018 +$ rustdoc --test src/lib.rs -Z unstable-options --edition 2018 +``` + +This flag allows rustdoc to treat your rust code as the given edition. It will compile doctests with +the given edition as well. As with `rustc`, the default edition that `rustdoc` will use is `2015` +(the first edition). + ### `--extern-html-root-url`: control how rustdoc links to non-local crates Using this flag looks like this: diff --git a/src/doc/unstable-book/src/language-features/infer-outlives-requirements.md b/src/doc/unstable-book/src/language-features/infer-outlives-requirements.md new file mode 100644 index 0000000000..fe82f8555d --- /dev/null +++ b/src/doc/unstable-book/src/language-features/infer-outlives-requirements.md @@ -0,0 +1,67 @@ +# `infer_outlives_requirements` + +The tracking issue for this feature is: [#44493] + +[#44493]: https://github.com/rust-lang/rust/issues/44493 + +------------------------ +The `infer_outlives_requirements` feature indicates that certain +outlives requirements can be inferred by the compiler rather than +stating them explicitly. + +For example, currently generic struct definitions that contain +references, require where-clauses of the form T: 'a. By using +this feature the outlives predicates will be inferred, although +they may still be written explicitly. + +```rust,ignore (pseudo-Rust) +struct Foo<'a, T> + where T: 'a // <-- currently required + { + bar: &'a T, + } +``` + + +## Examples: + + +```rust,ignore (pseudo-Rust) +#![feature(infer_outlives_requirements)] + +// Implicitly infer T: 'a +struct Foo<'a, T> { + bar: &'a T, +} +``` + +```rust,ignore (pseudo-Rust) +#![feature(infer_outlives_requirements)] + +// Implicitly infer `U: 'b` +struct Foo<'b, U> { + bar: Bar<'b, U> +} + +struct Bar<'a, T> where T: 'a { + x: &'a (), + y: T, +} +``` + +```rust,ignore (pseudo-Rust) +#![feature(infer_outlives_requirements)] + +// Implicitly infer `b': 'a` +struct Foo<'a, 'b, T> { + x: &'a &'b T +} +``` + +```rust,ignore (pseudo-Rust) +#![feature(infer_outlives_requirements)] + +// Implicitly infer `::Item : 'a` +struct Foo<'a, T: Iterator> { + bar: &'a T::Item +``` diff --git a/src/liballoc/collections/vec_deque.rs b/src/liballoc/collections/vec_deque.rs index c53549ab85..571f35a203 100644 --- a/src/liballoc/collections/vec_deque.rs +++ b/src/liballoc/collections/vec_deque.rs @@ -19,7 +19,6 @@ use core::cmp::Ordering; use core::fmt; -use core::isize; use core::iter::{repeat, FromIterator, FusedIterator}; use core::mem; use core::ops::Bound::{Excluded, Included, Unbounded}; @@ -203,33 +202,6 @@ impl VecDeque { len); } - /// Copies all values from `src` to the back of `self`, wrapping around if needed. - /// - /// # Safety - /// - /// The capacity must be sufficient to hold self.len() + src.len() elements. - /// If so, this function never panics. - #[inline] - unsafe fn copy_slice(&mut self, src: &[T]) { - /// This is guaranteed by `RawVec`. - debug_assert!(self.capacity() <= isize::MAX as usize); - - let expected_new_len = self.len() + src.len(); - debug_assert!(self.capacity() >= expected_new_len); - - let dst_high_ptr = self.ptr().add(self.head); - let dst_high_len = self.cap() - self.head; - - let split = cmp::min(src.len(), dst_high_len); - let (src_high, src_low) = src.split_at(split); - - ptr::copy_nonoverlapping(src_high.as_ptr(), dst_high_ptr, src_high.len()); - ptr::copy_nonoverlapping(src_low.as_ptr(), self.ptr(), src_low.len()); - - self.head = self.wrap_add(self.head, src.len()); - debug_assert!(self.len() == expected_new_len); - } - /// Copies a potentially wrapping block of memory len long from src to dest. /// (abs(dst - src) + len) must be no larger than cap() (There must be at /// most one continuous overlapping region between src and dest). @@ -1052,7 +1024,7 @@ impl VecDeque { iter: Iter { tail: drain_tail, head: drain_head, - ring: unsafe { self.buffer_as_slice() }, + ring: unsafe { self.buffer_as_mut_slice() }, }, } } @@ -1862,22 +1834,8 @@ impl VecDeque { #[inline] #[stable(feature = "append", since = "1.4.0")] pub fn append(&mut self, other: &mut Self) { - unsafe { - // Guarantees there is space in `self` for `other`. - self.reserve(other.len()); - - { - let (src_high, src_low) = other.as_slices(); - - // This is only safe because copy_slice never panics when capacity is sufficient. - self.copy_slice(src_low); - self.copy_slice(src_high); - } - - // Some values now exist in both `other` and `self` but are made inaccessible - // in`other`. - other.tail = other.head; - } + // naive impl + self.extend(other.drain(..)); } /// Retains only the elements specified by the predicate. @@ -2635,8 +2593,8 @@ impl From> for Vec { let mut right_offset = 0; for i in left_edge..right_edge { right_offset = (i - left_edge) % (cap - right_edge); - let src = right_edge + right_offset; - ptr::swap(buf.add(i), buf.add(src)); + let src: isize = (right_edge + right_offset) as isize; + ptr::swap(buf.add(i), buf.offset(src)); } let n_ops = right_edge - left_edge; left_edge += n_ops; diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 2d271fd0dc..452d2b1472 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -77,6 +77,7 @@ #![cfg_attr(not(test), feature(fn_traits))] #![cfg_attr(not(test), feature(generator_trait))] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![cfg_attr(test, feature(test))] #![feature(allocator_api)] diff --git a/src/liballoc_jemalloc/lib.rs b/src/liballoc_jemalloc/lib.rs index bdf0e37a2e..3d2348f3e4 100644 --- a/src/liballoc_jemalloc/lib.rs +++ b/src/liballoc_jemalloc/lib.rs @@ -17,6 +17,7 @@ #![feature(libc)] #![feature(linkage)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(staged_api)] #![feature(rustc_attrs)] #![cfg_attr(dummy_jemalloc, allow(dead_code, unused_extern_crates))] diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs index 65204ebf71..8848be5903 100644 --- a/src/liballoc_system/lib.rs +++ b/src/liballoc_system/lib.rs @@ -18,6 +18,7 @@ #![feature(allocator_api)] #![feature(core_intrinsics)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(staged_api)] #![feature(rustc_attrs)] #![cfg_attr(any(unix, target_os = "cloudabi", target_os = "redox"), feature(libc))] diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 6ad703180c..5cb8975e9c 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -27,6 +27,7 @@ #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(raw_vec_internals)] #![cfg_attr(test, feature(test))] diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 675e73e952..1c803f896a 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -92,6 +92,7 @@ #![feature(link_llvm_intrinsics)] #![feature(never_type)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(exhaustive_patterns)] #![feature(macro_at_most_once_rep)] #![feature(no_core)] diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 1bac6d22d3..3720100700 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -21,6 +21,7 @@ test(attr(deny(warnings))))] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] pub use self::Piece::*; pub use self::Position::*; diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index 9fa48adebd..5a0c983b52 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -289,6 +289,7 @@ test(attr(allow(unused_variables), deny(warnings))))] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(str_escape)] use self::LabelText::*; diff --git a/src/libpanic_abort/lib.rs b/src/libpanic_abort/lib.rs index 14221f3d79..4da88d8522 100644 --- a/src/libpanic_abort/lib.rs +++ b/src/libpanic_abort/lib.rs @@ -25,6 +25,7 @@ #![feature(core_intrinsics)] #![feature(libc)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(panic_runtime)] #![feature(staged_api)] #![feature(rustc_attrs)] diff --git a/src/libpanic_unwind/lib.rs b/src/libpanic_unwind/lib.rs index 9c3fc76c30..3368790b3f 100644 --- a/src/libpanic_unwind/lib.rs +++ b/src/libpanic_unwind/lib.rs @@ -35,6 +35,7 @@ #![feature(lang_items)] #![feature(libc)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(panic_unwind)] #![feature(raw)] #![feature(staged_api)] diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 1a0dde3ccd..31c4e79211 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -28,6 +28,7 @@ test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(rustc_private)] #![feature(staged_api)] #![feature(lang_items)] diff --git a/src/libprofiler_builtins/lib.rs b/src/libprofiler_builtins/lib.rs index a85593253b..00dd87022c 100644 --- a/src/libprofiler_builtins/lib.rs +++ b/src/libprofiler_builtins/lib.rs @@ -16,4 +16,5 @@ issue = "0")] #![allow(unused_features)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(staged_api)] diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index 3318bbd8c8..a3c0688dcc 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -1232,54 +1232,41 @@ let x: i32 = "I am not a number!"; "##, E0309: r##" -The type definition contains some field whose type -requires an outlives annotation. Outlives annotations -(e.g., `T: 'a`) are used to guarantee that all the data in T is valid -for at least the lifetime `'a`. This scenario most commonly -arises when the type contains an associated type reference -like `>::Output`, as shown in this example: +Types in type definitions have lifetimes associated with them that represent +how long the data stored within them is guaranteed to be live. This lifetime +must be as long as the data needs to be alive, and missing the constraint that +denotes this will cause this error. ```compile_fail,E0309 -// This won't compile because the applicable impl of -// `SomeTrait` (below) requires that `T: 'a`, but the struct does -// not have a matching where-clause. +// This won't compile because T is not constrained, meaning the data +// stored in it is not guaranteed to last as long as the reference struct Foo<'a, T> { - foo: >::Output, -} - -trait SomeTrait<'a> { - type Output; -} - -impl<'a, T> SomeTrait<'a> for T -where - T: 'a, -{ - type Output = u32; + foo: &'a T } ``` -Here, the where clause `T: 'a` that appears on the impl is not known to be -satisfied on the struct. To make this example compile, you have to add -a where-clause like `T: 'a` to the struct definition: +This will compile, because it has the constraint on the type parameter: ``` -struct Foo<'a, T> -where - T: 'a, -{ - foo: >::Output +struct Foo<'a, T: 'a> { + foo: &'a T +} +``` + +To see why this is important, consider the case where `T` is itself a reference +(e.g., `T = &str`). If we don't include the restriction that `T: 'a`, the +following code would be perfectly legal: + +```compile_fail,E0309 +struct Foo<'a, T> { + foo: &'a T } -trait SomeTrait<'a> { - type Output; -} - -impl<'a, T> SomeTrait<'a> for T -where - T: 'a, -{ - type Output = u32; +fn main() { + let v = "42".to_string(); + let f = Foo{foo: &v}; + drop(v); + println!("{}", f.foo); // but we've already dropped v! } ``` "##, @@ -1478,31 +1465,30 @@ A reference has a longer lifetime than the data it references. Erroneous code example: ```compile_fail,E0491 -trait SomeTrait<'a> { - type Output; +// struct containing a reference requires a lifetime parameter, +// because the data the reference points to must outlive the struct (see E0106) +struct Struct<'a> { + ref_i32: &'a i32, } -impl<'a, T> SomeTrait<'a> for T { - type Output = &'a T; // compile error E0491 +// However, a nested struct like this, the signature itself does not tell +// whether 'a outlives 'b or the other way around. +// So it could be possible that 'b of reference outlives 'a of the data. +struct Nested<'a, 'b> { + ref_struct: &'b Struct<'a>, // compile error E0491 } ``` -Here, the problem is that a reference type like `&'a T` is only valid -if all the data in T outlives the lifetime `'a`. But this impl as written -is applicable to any lifetime `'a` and any type `T` -- we have no guarantee -that `T` outlives `'a`. To fix this, you can add a where clause like -`where T: 'a`. +To fix this issue, you can specify a bound to the lifetime like below: ``` -trait SomeTrait<'a> { - type Output; +struct Struct<'a> { + ref_i32: &'a i32, } -impl<'a, T> SomeTrait<'a> for T -where - T: 'a, -{ - type Output = &'a T; // compile error E0491 +// 'a: 'b means 'a outlives 'b +struct Nested<'a: 'b, 'b> { + ref_struct: &'b Struct<'a>, } ``` "##, diff --git a/src/librustc/hir/map/definitions.rs b/src/librustc/hir/map/definitions.rs index c85cee7366..fa4bf1511b 100644 --- a/src/librustc/hir/map/definitions.rs +++ b/src/librustc/hir/map/definitions.rs @@ -287,6 +287,31 @@ impl DefPath { s } + /// Return filename friendly string of the DefPah with the + /// crate-prefix. + pub fn to_string_friendly(&self, crate_imported_name: F) -> String + where F: FnOnce(CrateNum) -> Symbol + { + let crate_name_str = crate_imported_name(self.krate).as_str(); + let mut s = String::with_capacity(crate_name_str.len() + self.data.len() * 16); + + write!(s, "::{}", crate_name_str).unwrap(); + + for component in &self.data { + if component.disambiguator == 0 { + write!(s, "::{}", component.data.as_interned_str()).unwrap(); + } else { + write!(s, + "{}[{}]", + component.data.as_interned_str(), + component.disambiguator) + .unwrap(); + } + } + + s + } + /// Return filename friendly string of the DefPah without /// the crate-prefix. This method is useful if you don't have /// a TyCtxt available. diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index 2eaf1eebb3..3570e65584 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -52,6 +52,7 @@ #![feature(exhaustive_patterns)] #![feature(extern_types)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(non_exhaustive)] #![feature(proc_macro_internals)] #![feature(quote)] diff --git a/src/librustc/lint/levels.rs b/src/librustc/lint/levels.rs index 336ebe79d3..e430aec8d0 100644 --- a/src/librustc/lint/levels.rs +++ b/src/librustc/lint/levels.rs @@ -299,7 +299,7 @@ impl<'a> LintLevelsBuilder<'a> { "change it to", new_lint_name.to_string(), Applicability::MachineApplicable, - ).emit(); + ).cancel(); let src = LintSource::Node(Symbol::intern(&new_lint_name), li.span); for id in ids { diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index d320173f9f..e9e8fc5cf2 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -395,7 +395,13 @@ fn create_and_seed_worklist<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, krate: &hir::Crate) -> Vec { - let worklist = access_levels.map.iter().map(|(&id, _)| id).chain( + let worklist = access_levels.map.iter().filter_map(|(&id, level)| { + if level >= &privacy::AccessLevel::Reachable { + Some(id) + } else { + None + } + }).chain( // Seed entry point tcx.sess.entry_fn.borrow().map(|(id, _, _)| id) ).collect::>(); diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 4c0eeba744..da3d0d5ed3 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -646,7 +646,6 @@ impl Options { match self.debugging_opts.share_generics { Some(setting) => setting, None => { - self.incremental.is_some() || match self.optimize { OptLevel::No | OptLevel::Less | diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 6738267b5b..5acbf9b424 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -927,8 +927,8 @@ pub struct GlobalCtxt<'tcx> { freevars: FxHashMap>>, maybe_unused_trait_imports: FxHashSet, - maybe_unused_extern_crates: Vec<(DefId, Span)>, + pub extern_prelude: FxHashSet, // Internal cache for metadata decoding. No need to track deps on this. pub rcache: Lock>>, @@ -1245,6 +1245,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { .into_iter() .map(|(id, sp)| (hir.local_def_id(id), sp)) .collect(), + extern_prelude: resolutions.extern_prelude, hir, def_path_hash_to_def_id, queries: query::Queries::new( diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index d9e3bdaf26..bfbd91cdae 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -36,7 +36,7 @@ use ty::subst::{Subst, Substs}; use ty::util::{IntTypeExt, Discr}; use ty::walk::TypeWalker; use util::captures::Captures; -use util::nodemap::{NodeSet, DefIdMap, FxHashMap}; +use util::nodemap::{NodeSet, DefIdMap, FxHashMap, FxHashSet}; use arena::SyncDroplessArena; use session::DataTypeKind; @@ -139,6 +139,7 @@ pub struct Resolutions { pub maybe_unused_trait_imports: NodeSet, pub maybe_unused_extern_crates: Vec<(NodeId, Span)>, pub export_map: ExportMap, + pub extern_prelude: FxHashSet, } #[derive(Clone, Copy, PartialEq, Eq, Debug)] diff --git a/src/librustc/ty/query/on_disk_cache.rs b/src/librustc/ty/query/on_disk_cache.rs index 0e4d2f1f64..296602e21b 100644 --- a/src/librustc/ty/query/on_disk_cache.rs +++ b/src/librustc/ty/query/on_disk_cache.rs @@ -606,6 +606,7 @@ impl<'a, 'tcx, 'x> SpecializedDecoder for CacheDecoder<'a, ' alloc_decoding_session.decode_alloc_id(self) } } + impl<'a, 'tcx, 'x> SpecializedDecoder for CacheDecoder<'a, 'tcx, 'x> { fn specialized_decode(&mut self) -> Result { let tag: u8 = Decodable::decode(self)?; diff --git a/src/librustc_allocator/lib.rs b/src/librustc_allocator/lib.rs index 2a3404ee83..44fbcade6b 100644 --- a/src/librustc_allocator/lib.rs +++ b/src/librustc_allocator/lib.rs @@ -9,6 +9,7 @@ // except according to those terms. #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(rustc_private)] #[macro_use] extern crate log; diff --git a/src/librustc_apfloat/lib.rs b/src/librustc_apfloat/lib.rs index d6e821d427..c3c32ba7d5 100644 --- a/src/librustc_apfloat/lib.rs +++ b/src/librustc_apfloat/lib.rs @@ -46,6 +46,7 @@ #![forbid(unsafe_code)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(try_from)] // See librustc_cratesio_shim/Cargo.toml for a comment explaining this. #[allow(unused_extern_crates)] diff --git a/src/librustc_asan/lib.rs b/src/librustc_asan/lib.rs index b3ba86ad8a..ed8fd30597 100644 --- a/src/librustc_asan/lib.rs +++ b/src/librustc_asan/lib.rs @@ -11,6 +11,7 @@ #![sanitizer_runtime] #![feature(alloc_system)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] diff --git a/src/librustc_borrowck/lib.rs b/src/librustc_borrowck/lib.rs index 16da8c8a3b..edd837e940 100644 --- a/src/librustc_borrowck/lib.rs +++ b/src/librustc_borrowck/lib.rs @@ -15,6 +15,7 @@ #![allow(non_camel_case_types)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(quote)] #![recursion_limit="256"] diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index 9cb233122c..dcdd8c1f6e 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -27,6 +27,7 @@ #![allow(unused_attributes)] #![feature(libc)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(quote)] #![feature(range_contains)] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc_codegen_llvm/type_of.rs b/src/librustc_codegen_llvm/type_of.rs index 6eec0b0b68..765708aeaf 100644 --- a/src/librustc_codegen_llvm/type_of.rs +++ b/src/librustc_codegen_llvm/type_of.rs @@ -10,11 +10,9 @@ use abi::{FnType, FnTypeExt}; use common::*; -use llvm; use rustc::hir; use rustc::ty::{self, Ty, TypeFoldable}; use rustc::ty::layout::{self, Align, LayoutOf, Size, TyLayout}; -use rustc_target::spec::PanicStrategy; use rustc_target::abi::FloatTy; use rustc_mir::monomorphize::item::DefPathBasedNames; use type_::Type; @@ -433,12 +431,19 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> { PointerKind::Shared }, hir::MutMutable => { - // Only emit noalias annotations for LLVM >= 6 or in panic=abort - // mode, as prior versions had many bugs in conjunction with - // unwinding. See also issue #31681. + // Previously we would only emit noalias annotations for LLVM >= 6 or in + // panic=abort mode. That was deemed right, as prior versions had many bugs + // in conjunction with unwinding, but later versions didn’t seem to have + // said issues. See issue #31681. + // + // Alas, later on we encountered a case where noalias would generate wrong + // code altogether even with recent versions of LLVM in *safe* code with no + // unwinding involved. See #54462. + // + // For now, do not enable mutable_noalias by default at all, while the + // issue is being figured out. let mutable_noalias = cx.tcx.sess.opts.debugging_opts.mutable_noalias - .unwrap_or(unsafe { llvm::LLVMRustVersionMajor() >= 6 } - || cx.tcx.sess.panic_strategy() == PanicStrategy::Abort); + .unwrap_or(false); if mutable_noalias { PointerKind::UniqueBorrowed } else { diff --git a/src/librustc_codegen_utils/lib.rs b/src/librustc_codegen_utils/lib.rs index 635819e94e..45db22ec6d 100644 --- a/src/librustc_codegen_utils/lib.rs +++ b/src/librustc_codegen_utils/lib.rs @@ -20,6 +20,7 @@ #![feature(box_syntax)] #![feature(custom_attribute)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![allow(unused_attributes)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc_cratesio_shim/src/lib.rs b/src/librustc_cratesio_shim/src/lib.rs index 55dec45a09..ebceb00cca 100644 --- a/src/librustc_cratesio_shim/src/lib.rs +++ b/src/librustc_cratesio_shim/src/lib.rs @@ -12,6 +12,7 @@ #![allow(unused_extern_crates)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] extern crate bitflags; extern crate log; diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index 9435cb3184..1fdcab5f7a 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -29,6 +29,7 @@ #![feature(optin_builtin_traits)] #![cfg_attr(stage0, feature(macro_vis_matcher))] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(allow_internal_unstable)] #![feature(vec_resize_with)] diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 7fb66ea97f..3b0acfd6f8 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -790,6 +790,7 @@ where trait_map: resolver.trait_map, maybe_unused_trait_imports: resolver.maybe_unused_trait_imports, maybe_unused_extern_crates: resolver.maybe_unused_extern_crates, + extern_prelude: resolver.extern_prelude, }, analysis: ty::CrateAnalysis { diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index a96c277d4b..13e1df6e53 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -21,6 +21,7 @@ #![feature(box_syntax)] #![cfg_attr(unix, feature(libc))] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(option_replace)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index 3582c2359c..d31db4b2d0 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -17,6 +17,7 @@ #![feature(range_contains)] #![cfg_attr(unix, feature(libc))] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(optin_builtin_traits)] extern crate atty; diff --git a/src/librustc_incremental/lib.rs b/src/librustc_incremental/lib.rs index acdcf2b459..4ffd726c1d 100644 --- a/src/librustc_incremental/lib.rs +++ b/src/librustc_incremental/lib.rs @@ -15,6 +15,7 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(specialization)] #![recursion_limit="256"] diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 9ed69a2dc9..7e5f449d07 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -28,6 +28,7 @@ #![feature(box_syntax)] #![cfg_attr(stage0, feature(macro_vis_matcher))] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(quote)] #![feature(rustc_diagnostic_macros)] #![feature(macro_at_most_once_rep)] @@ -312,7 +313,7 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) { }, FutureIncompatibleInfo { id: LintId::of(ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE), - reference: "issue TBD", + reference: "issue #53130 ", edition: Some(Edition::Edition2018), }, FutureIncompatibleInfo { diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index 387660473a..13605e993a 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -9,6 +9,7 @@ // except according to those terms. #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(static_nobundle)] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/librustc_lsan/lib.rs b/src/librustc_lsan/lib.rs index b3ba86ad8a..ed8fd30597 100644 --- a/src/librustc_lsan/lib.rs +++ b/src/librustc_lsan/lib.rs @@ -11,6 +11,7 @@ #![sanitizer_runtime] #![feature(alloc_system)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 6eef2397f9..fa2debf2c0 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -256,6 +256,7 @@ impl<'a> CrateLoader<'a> { let cmeta = cstore::CrateMetadata { name: crate_root.name, + imported_name: ident, extern_crate: Lock::new(None), def_path_table: Lrc::new(def_path_table), trait_impls, diff --git a/src/librustc_metadata/cstore.rs b/src/librustc_metadata/cstore.rs index aad632f891..ec48a4a4c6 100644 --- a/src/librustc_metadata/cstore.rs +++ b/src/librustc_metadata/cstore.rs @@ -53,8 +53,13 @@ pub struct ImportedSourceFile { } pub struct CrateMetadata { + /// Original name of the crate. pub name: Symbol, + /// Name of the crate as imported. I.e. if imported with + /// `extern crate foo as bar;` this will be `bar`. + pub imported_name: Symbol, + /// Information about the extern crate that caused this crate to /// be loaded. If this is `None`, then the crate was injected /// (e.g., by the allocator) diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 4382a3c12c..4bea8558ff 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -441,8 +441,7 @@ impl cstore::CStore { let data = self.get_crate_data(id.krate); if let Some(ref proc_macros) = data.proc_macros { return LoadedMacro::ProcMacro(proc_macros[id.index.to_proc_macro_index()].1.clone()); - } else if data.name == "proc_macro" && - self.get_crate_data(id.krate).item_name(id.index) == "quote" { + } else if data.name == "proc_macro" && data.item_name(id.index) == "quote" { use syntax::ext::base::SyntaxExtension; use syntax_ext::proc_macro_impl::BangProcMacro; @@ -454,8 +453,9 @@ impl cstore::CStore { return LoadedMacro::ProcMacro(Lrc::new(ext)); } - let (name, def) = data.get_macro(id.index); - let source_name = FileName::Macros(name.to_string()); + let def = data.get_macro(id.index); + let macro_full_name = data.def_path(id.index).to_string_friendly(|_| data.imported_name); + let source_name = FileName::Macros(macro_full_name); let source_file = sess.parse_sess.source_map().new_source_file(source_name, def.body); let local_span = Span::new(source_file.start_pos, source_file.end_pos, NO_EXPANSION); diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 43b03cb863..044d23270a 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -1101,10 +1101,10 @@ impl<'a, 'tcx> CrateMetadata { } } - pub fn get_macro(&self, id: DefIndex) -> (InternedString, MacroDef) { + pub fn get_macro(&self, id: DefIndex) -> MacroDef { let entry = self.entry(id); match entry.kind { - EntryKind::MacroDef(macro_def) => (self.item_name(id), macro_def.decode(self)), + EntryKind::MacroDef(macro_def) => macro_def.decode(self), _ => bug!(), } } diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index 09a8bea094..107245488a 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -16,6 +16,7 @@ #![feature(libc)] #![feature(macro_at_most_once_rep)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(proc_macro_internals)] #![feature(proc_macro_quote)] #![feature(quote)] diff --git a/src/librustc_mir/const_eval.rs b/src/librustc_mir/const_eval.rs index 82cc1b7f66..dd6f5fc044 100644 --- a/src/librustc_mir/const_eval.rs +++ b/src/librustc_mir/const_eval.rs @@ -17,7 +17,7 @@ use rustc::hir::{self, def_id::DefId}; use rustc::mir::interpret::ConstEvalErr; use rustc::mir; use rustc::ty::{self, TyCtxt, Instance, query::TyCtxtAt}; -use rustc::ty::layout::{LayoutOf, TyLayout}; +use rustc::ty::layout::{self, LayoutOf, TyLayout}; use rustc::ty::subst::Subst; use rustc_data_structures::indexed_vec::IndexVec; @@ -90,8 +90,18 @@ pub fn eval_promoted<'a, 'mir, 'tcx>( pub fn op_to_const<'tcx>( ecx: &EvalContext<'_, '_, 'tcx, CompileTimeEvaluator>, op: OpTy<'tcx>, - normalize: bool, + may_normalize: bool, ) -> EvalResult<'tcx, &'tcx ty::Const<'tcx>> { + // We do not normalize just any data. Only scalar layout and fat pointers. + let normalize = may_normalize + && match op.layout.abi { + layout::Abi::Scalar(..) => true, + layout::Abi::ScalarPair(..) => { + // Must be a fat pointer + op.layout.ty.builtin_deref(true).is_some() + }, + _ => false, + }; let normalized_op = if normalize { ecx.try_read_value(op)? } else { diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index 1594755b4a..073e806fe0 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -15,6 +15,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment! */ #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(in_band_lifetimes)] #![feature(impl_header_lifetime_elision)] #![feature(slice_patterns)] diff --git a/src/librustc_msan/lib.rs b/src/librustc_msan/lib.rs index b3ba86ad8a..ed8fd30597 100644 --- a/src/librustc_msan/lib.rs +++ b/src/librustc_msan/lib.rs @@ -11,6 +11,7 @@ #![sanitizer_runtime] #![feature(alloc_system)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs index d62cb00923..94ea229cbd 100644 --- a/src/librustc_passes/lib.rs +++ b/src/librustc_passes/lib.rs @@ -19,6 +19,7 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(rustc_diagnostic_macros)] #[macro_use] diff --git a/src/librustc_platform_intrinsics/lib.rs b/src/librustc_platform_intrinsics/lib.rs index fa7008be73..f093d67249 100644 --- a/src/librustc_platform_intrinsics/lib.rs +++ b/src/librustc_platform_intrinsics/lib.rs @@ -11,6 +11,7 @@ #![allow(nonstandard_style)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] pub struct Intrinsic { pub inputs: &'static [&'static Type], diff --git a/src/librustc_plugin/lib.rs b/src/librustc_plugin/lib.rs index 67f53a6731..5b56266638 100644 --- a/src/librustc_plugin/lib.rs +++ b/src/librustc_plugin/lib.rs @@ -65,6 +65,7 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(rustc_diagnostic_macros)] #[macro_use] extern crate syntax; diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index 47e8588857..fe66110120 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -13,6 +13,7 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(rustc_diagnostic_macros)] #![recursion_limit="256"] @@ -1380,13 +1381,7 @@ impl<'a, 'tcx: 'a> SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> { } fn predicates(&mut self) -> &mut Self { - // NB: We use `explicit_predicates_of` and not `predicates_of` - // because we don't want to report privacy errors due to where - // clauses that the compiler inferred. We only want to - // consider the ones that the user wrote. This is important - // for the inferred outlives rules; see - // `src/test/ui/rfc-2093-infer-outlives/privacy.rs`. - let predicates = self.tcx.explicit_predicates_of(self.item_def_id); + let predicates = self.tcx.predicates_of(self.item_def_id); for predicate in &predicates.predicates { predicate.visit_with(self); match predicate { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 168603d417..5101b7fcaa 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -14,6 +14,7 @@ #![feature(crate_visibility_modifier)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(rustc_diagnostic_macros)] #![feature(slice_sort_by_cached_key)] @@ -71,11 +72,10 @@ use syntax_pos::{Span, DUMMY_SP, MultiSpan}; use errors::{Applicability, DiagnosticBuilder, DiagnosticId}; use std::cell::{Cell, RefCell}; -use std::cmp; +use std::{cmp, fmt, iter, ptr}; use std::collections::BTreeSet; -use std::fmt; -use std::iter; use std::mem::replace; +use rustc_data_structures::ptr_key::PtrKey; use rustc_data_structures::sync::Lrc; use resolve_imports::{ImportDirective, ImportDirectiveSubclass, NameResolution, ImportResolver}; @@ -1113,6 +1113,17 @@ impl<'a> ModuleData<'a> { fn nearest_item_scope(&'a self) -> Module<'a> { if self.is_trait() { self.parent.unwrap() } else { self } } + + fn is_ancestor_of(&self, mut other: &Self) -> bool { + while !ptr::eq(self, other) { + if let Some(parent) = other.parent { + other = parent; + } else { + return false; + } + } + true + } } impl<'a> fmt::Debug for ModuleData<'a> { @@ -1350,7 +1361,7 @@ pub struct Resolver<'a, 'b: 'a> { graph_root: Module<'a>, prelude: Option>, - extern_prelude: FxHashSet, + pub extern_prelude: FxHashSet, /// n.b. This is used only for better diagnostics, not name resolution itself. has_self: FxHashSet, @@ -1408,6 +1419,7 @@ pub struct Resolver<'a, 'b: 'a> { block_map: NodeMap>, module_map: FxHashMap>, extern_module_map: FxHashMap<(DefId, bool /* MacrosOnly? */), Module<'a>>, + binding_parent_modules: FxHashMap>, Module<'a>>, pub make_glob_map: bool, /// Maps imports to the names of items actually imported (this actually maps @@ -1666,13 +1678,15 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { let mut extern_prelude: FxHashSet = session.opts.externs.iter().map(|kv| Symbol::intern(kv.0)).collect(); - // HACK(eddyb) this ignore the `no_{core,std}` attributes. - // FIXME(eddyb) warn (elsewhere) if core/std is used with `no_{core,std}`. - // if !attr::contains_name(&krate.attrs, "no_core") { - // if !attr::contains_name(&krate.attrs, "no_std") { - extern_prelude.insert(Symbol::intern("core")); - extern_prelude.insert(Symbol::intern("std")); - extern_prelude.insert(Symbol::intern("meta")); + if !attr::contains_name(&krate.attrs, "no_core") { + extern_prelude.insert(Symbol::intern("core")); + if !attr::contains_name(&krate.attrs, "no_std") { + extern_prelude.insert(Symbol::intern("std")); + if session.rust_2018() { + extern_prelude.insert(Symbol::intern("meta")); + } + } + } let mut invocations = FxHashMap(); invocations.insert(Mark::root(), @@ -1722,6 +1736,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { module_map, block_map: NodeMap(), extern_module_map: FxHashMap(), + binding_parent_modules: FxHashMap(), make_glob_map: make_glob_map == MakeGlobMap::Yes, glob_map: NodeMap(), @@ -1962,9 +1977,15 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { } if !module.no_implicit_prelude { - // `record_used` means that we don't try to load crates during speculative resolution - if record_used && ns == TypeNS && self.extern_prelude.contains(&ident.name) { - let crate_id = self.crate_loader.process_path_extern(ident.name, ident.span); + if ns == TypeNS && self.extern_prelude.contains(&ident.name) { + let crate_id = if record_used { + self.crate_loader.process_path_extern(ident.name, ident.span) + } else if let Some(crate_id) = + self.crate_loader.maybe_process_path_extern(ident.name, ident.span) { + crate_id + } else { + return None; + }; let crate_root = self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX }); self.populate_module_if_necessary(&crate_root); @@ -4540,6 +4561,31 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { vis.is_accessible_from(module.normal_ancestor_id, self) } + fn set_binding_parent_module(&mut self, binding: &'a NameBinding<'a>, module: Module<'a>) { + if let Some(old_module) = self.binding_parent_modules.insert(PtrKey(binding), module) { + if !ptr::eq(module, old_module) { + span_bug!(binding.span, "parent module is reset for binding"); + } + } + } + + fn disambiguate_legacy_vs_modern( + &self, + legacy: &'a NameBinding<'a>, + modern: &'a NameBinding<'a>, + ) -> bool { + // Some non-controversial subset of ambiguities "modern macro name" vs "macro_rules" + // is disambiguated to mitigate regressions from macro modularization. + // Scoping for `macro_rules` behaves like scoping for `let` at module level, in general. + match (self.binding_parent_modules.get(&PtrKey(legacy)), + self.binding_parent_modules.get(&PtrKey(modern))) { + (Some(legacy), Some(modern)) => + legacy.normal_ancestor_id == modern.normal_ancestor_id && + modern.is_ancestor_of(legacy), + _ => false, + } + } + fn report_ambiguity_error(&self, ident: Ident, b1: &NameBinding, b2: &NameBinding) { let participle = |is_import: bool| if is_import { "imported" } else { "defined" }; let msg1 = diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs index 35d96b9302..349ddcd9a4 100644 --- a/src/librustc_resolve/macros.rs +++ b/src/librustc_resolve/macros.rs @@ -575,6 +575,13 @@ impl<'a, 'cl> Resolver<'a, 'cl> { // 5. Standard library prelude (de-facto closed, controlled). // 6. Language prelude (closed, controlled). // (Macro NS) + // 0. Derive helpers (open, not controlled). All ambiguities with other names + // are currently reported as errors. They should be higher in priority than preludes + // and probably even names in modules according to the "general principles" above. They + // also should be subject to restricted shadowing because are effectively produced by + // derives (you need to resolve the derive first to add helpers into scope), but they + // should be available before the derive is expanded for compatibility. + // It's mess in general, so we are being conservative for now. // 1. Names in modules (both normal `mod`ules and blocks), loop through hygienic parents // (open, not controlled). // 2. `macro_use` prelude (open, the open part is from macro expansions, not controlled). @@ -583,13 +590,6 @@ impl<'a, 'cl> Resolver<'a, 'cl> { // 2b. Standard library prelude is currently implemented as `macro-use` (closed, controlled) // 3. Language prelude: builtin macros (closed, controlled, except for legacy plugins). // 4. Language prelude: builtin attributes (closed, controlled). - // N (unordered). Derive helpers (open, not controlled). All ambiguities with other names - // are currently reported as errors. They should be higher in priority than preludes - // and maybe even names in modules according to the "general principles" above. They - // also should be subject to restricted shadowing because are effectively produced by - // derives (you need to resolve the derive first to add helpers into scope), but they - // should be available before the derive is expanded for compatibility. - // It's mess in general, so we are being conservative for now. assert!(ns == TypeNS || ns == MacroNS); assert!(force || !record_used); // `record_used` implies `force` @@ -621,7 +621,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> { } // Go through all the scopes and try to resolve the name. - let mut where_to_resolve = WhereToResolve::Module(parent_scope.module); + let mut where_to_resolve = WhereToResolve::DeriveHelpers; let mut use_prelude = !parent_scope.module.no_implicit_prelude; loop { let result = match where_to_resolve { @@ -751,8 +751,8 @@ impl<'a, 'cl> Resolver<'a, 'cl> { } WhereToResolve::MacroUsePrelude => WhereToResolve::BuiltinMacros, WhereToResolve::BuiltinMacros => WhereToResolve::BuiltinAttrs, - WhereToResolve::BuiltinAttrs => WhereToResolve::DeriveHelpers, - WhereToResolve::DeriveHelpers => break, // nowhere else to search + WhereToResolve::BuiltinAttrs => break, // nowhere else to search + WhereToResolve::DeriveHelpers => WhereToResolve::Module(parent_scope.module), WhereToResolve::ExternPrelude => WhereToResolve::ToolPrelude, WhereToResolve::ToolPrelude => WhereToResolve::StdLibPrelude, WhereToResolve::StdLibPrelude => WhereToResolve::BuiltinTypes, @@ -956,11 +956,13 @@ impl<'a, 'cl> Resolver<'a, 'cl> { }, (Some(legacy_binding), Ok((binding, FromPrelude(from_prelude)))) if legacy_binding.def() != binding.def_ignoring_ambiguity() && - (!from_prelude || + (!from_prelude && + !self.disambiguate_legacy_vs_modern(legacy_binding, binding) || legacy_binding.may_appear_after(parent_scope.expansion, binding)) => { self.report_ambiguity_error(ident, legacy_binding, binding); }, // OK, non-macro-expanded legacy wins over prelude even if defs are different + // Also, non-macro-expanded legacy wins over modern from the same module // Also, legacy and modern can co-exist if their defs are same (Some(legacy_binding), Ok(_)) | // OK, unambiguous resolution @@ -1096,6 +1098,7 @@ impl<'a, 'cl> Resolver<'a, 'cl> { let def = Def::Macro(def_id, MacroKind::Bang); let vis = ty::Visibility::Invisible; // Doesn't matter for legacy bindings let binding = (def, vis, item.span, expansion).to_name_binding(self.arenas); + self.set_binding_parent_module(binding, self.current_module); let legacy_binding = self.arenas.alloc_legacy_binding(LegacyBinding { parent_legacy_scope: *current_legacy_scope, binding, ident }); diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index dc4a76db69..2628772745 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -478,6 +478,7 @@ impl<'a, 'crateloader> Resolver<'a, 'crateloader> { binding: &'a NameBinding<'a>) -> Result<(), &'a NameBinding<'a>> { self.check_reserved_macro_name(ident, ns); + self.set_binding_parent_module(binding, module); self.update_resolution(module, ident, ns, |this, resolution| { if let Some(old_binding) = resolution.binding { if binding.is_glob_import() { diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index c9bae29703..30cf24d2ba 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -13,6 +13,7 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(custom_attribute)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![allow(unused_attributes)] #![recursion_limit="256"] diff --git a/src/librustc_target/lib.rs b/src/librustc_target/lib.rs index c198b19ce6..e4d958e3b6 100644 --- a/src/librustc_target/lib.rs +++ b/src/librustc_target/lib.rs @@ -25,6 +25,7 @@ #![cfg_attr(stage0, feature(const_fn))] #![cfg_attr(not(stage0), feature(min_const_fn))] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(slice_patterns)] #[macro_use] diff --git a/src/librustc_traits/lib.rs b/src/librustc_traits/lib.rs index a6618efebb..00d0d147fe 100644 --- a/src/librustc_traits/lib.rs +++ b/src/librustc_traits/lib.rs @@ -16,6 +16,7 @@ #![cfg_attr(stage0, feature(extern_prelude))] #![feature(in_band_lifetimes)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![recursion_limit="256"] diff --git a/src/librustc_tsan/lib.rs b/src/librustc_tsan/lib.rs index b3ba86ad8a..ed8fd30597 100644 --- a/src/librustc_tsan/lib.rs +++ b/src/librustc_tsan/lib.rs @@ -11,6 +11,7 @@ #![sanitizer_runtime] #![feature(alloc_system)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] diff --git a/src/librustc_typeck/check_unused.rs b/src/librustc_typeck/check_unused.rs index 5967bd1ba3..9d62afa232 100644 --- a/src/librustc_typeck/check_unused.rs +++ b/src/librustc_typeck/check_unused.rs @@ -130,15 +130,13 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) { }); for extern_crate in &crates_to_lint { - assert!(extern_crate.def_id.is_local()); + let id = tcx.hir.as_local_node_id(extern_crate.def_id).unwrap(); + let item = tcx.hir.expect_item(id); // If the crate is fully unused, we suggest removing it altogether. // We do this in any edition. if extern_crate.warn_if_unused { if let Some(&span) = unused_extern_crates.get(&extern_crate.def_id) { - assert_eq!(extern_crate.def_id.krate, LOCAL_CRATE); - let hir_id = tcx.hir.definitions().def_index_to_hir_id(extern_crate.def_id.index); - let id = tcx.hir.hir_to_node_id(hir_id); let msg = "unused extern crate"; tcx.struct_span_lint_node(lint, id, span, msg) .span_suggestion_short_with_applicability( @@ -157,6 +155,13 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) { continue; } + // If the extern crate isn't in the extern prelude, + // there is no way it can be written as an `use`. + let orig_name = extern_crate.orig_name.unwrap_or(item.name); + if !tcx.extern_prelude.contains(&orig_name) { + continue; + } + // If the extern crate has any attributes, they may have funky // semantics we can't faithfully represent using `use` (most // notably `#[macro_use]`). Ignore it. @@ -165,9 +170,6 @@ fn unused_crates_lint<'tcx>(tcx: TyCtxt<'_, 'tcx, 'tcx>) { } // Otherwise, we can convert it into a `use` of some kind. - let hir_id = tcx.hir.definitions().def_index_to_hir_id(extern_crate.def_id.index); - let id = tcx.hir.hir_to_node_id(hir_id); - let item = tcx.hir.expect_item(id); let msg = "`extern crate` is not idiomatic in the new edition"; let help = format!( "convert it to a `{}`", diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 5309be2176..cc83c24e51 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1578,10 +1578,14 @@ fn predicates_defined_on<'a, 'tcx>( def_id: DefId, ) -> ty::GenericPredicates<'tcx> { let explicit = tcx.explicit_predicates_of(def_id); - let predicates = [ - &explicit.predicates[..], - &tcx.inferred_outlives_of(def_id)[..], - ].concat(); + let predicates = if tcx.sess.features_untracked().infer_outlives_requirements { + [ + &explicit.predicates[..], + &tcx.inferred_outlives_of(def_id)[..], + ].concat() + } else { + explicit.predicates + }; ty::GenericPredicates { parent: explicit.parent, diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index c9aa0339dd..13ea2fdd89 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -76,6 +76,7 @@ This API is completely unstable and subject to change. #![feature(crate_visibility_modifier)] #![feature(exhaustive_patterns)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(quote)] #![feature(refcell_replace_swap)] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc_typeck/outlives/implicit_infer.rs b/src/librustc_typeck/outlives/implicit_infer.rs index 254146c0ef..092e4d62e2 100644 --- a/src/librustc_typeck/outlives/implicit_infer.rs +++ b/src/librustc_typeck/outlives/implicit_infer.rs @@ -66,8 +66,7 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> { debug!("InferVisitor::visit_item(item={:?})", item_did); - let node_id = self - .tcx + let node_id = self.tcx .hir .as_local_node_id(item_did) .expect("expected local def-id"); @@ -109,8 +108,7 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> { // Therefore mark `predicates_added` as true and which will ensure // we walk the crates again and re-calculate predicates for all // items. - let item_predicates_len: usize = self - .global_inferred_outlives + let item_predicates_len: usize = self.global_inferred_outlives .get(&item_did) .map(|p| p.len()) .unwrap_or(0); diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index ee0c6ee005..7b46b632b1 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -457,6 +457,7 @@ pub fn run_core(search_paths: SearchPaths, trait_map: resolver.trait_map.clone(), maybe_unused_trait_imports: resolver.maybe_unused_trait_imports.clone(), maybe_unused_extern_crates: resolver.maybe_unused_extern_crates.clone(), + extern_prelude: resolver.extern_prelude.clone(), }; let analysis = ty::CrateAnalysis { access_levels: Lrc::new(AccessLevels::default()), diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 73057b1901..3a70c55e17 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -17,6 +17,7 @@ #![feature(box_patterns)] #![feature(box_syntax)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(set_stdio)] #![feature(slice_sort_by_cached_key)] #![feature(test)] @@ -285,7 +286,7 @@ fn opts() -> Vec { \"light-suffix.css\"", "PATH") }), - stable("edition", |o| { + unstable("edition", |o| { o.optopt("", "edition", "edition to use when compiling rust code (default: 2015)", "EDITION") diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index 3b07a2ccdd..0d9fae37c0 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -220,7 +220,6 @@ fn run_test(test: &str, cratename: &str, filename: &FileName, line: usize, output_types: outputs, externs, cg: config::CodegenOptions { - prefer_dynamic: true, linker, ..cg }, diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index 1f6ee3d867..e87c2793ee 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -25,6 +25,7 @@ Core encoding and decoding interfaces. #![feature(specialization)] #![feature(never_type)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![cfg_attr(test, feature(test))] pub use self::serialize::{Decoder, Encoder, Decodable, Encodable}; diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 17f6923eae..5c9e88dc57 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -274,6 +274,7 @@ #![feature(needs_panic_runtime)] #![feature(never_type)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(exhaustive_patterns)] #![feature(on_unimplemented)] #![feature(optin_builtin_traits)] diff --git a/src/libsyntax/config.rs b/src/libsyntax/config.rs index 63b70b1224..bc4b7385d8 100644 --- a/src/libsyntax/config.rs +++ b/src/libsyntax/config.rs @@ -89,6 +89,7 @@ impl<'a> StripUnconfigured<'a> { parser.expect(&token::Comma)?; let lo = parser.span.lo(); let (path, tokens) = parser.parse_meta_item_unrestricted()?; + parser.eat(&token::Comma); // Optional trailing comma parser.expect(&token::CloseDelim(token::Paren))?; Ok((cfg, path, tokens, parser.prev_span.with_lo(lo))) }) { diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index fa4346ee70..26067304f9 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -37,7 +37,7 @@ use visit::{self, FnKind, Visitor}; use parse::ParseSess; use symbol::{keywords, Symbol}; -use std::{env}; +use std::{env, path}; macro_rules! set { // The const_fn feature also enables the min_const_fn feature, because `min_const_fn` allows @@ -403,9 +403,15 @@ declare_features! ( // `extern` in paths (active, extern_in_paths, "1.23.0", Some(44660), None), + // `foo.rs` as an alternative to `foo/mod.rs` + (active, non_modrs_mods, "1.24.0", Some(44660), Some(Edition::Edition2018)), + // Use `?` as the Kleene "at most one" operator (active, macro_at_most_once_rep, "1.25.0", Some(48075), None), + // Infer outlives requirements; RFC 2093 + (active, infer_outlives_requirements, "1.26.0", Some(44493), None), + // Infer static outlives requirements; RFC 2093 (active, infer_static_outlives_requirements, "1.26.0", Some(44493), None), @@ -648,8 +654,6 @@ declare_features! ( (accepted, repr_transparent, "1.28.0", Some(43036), None), // Defining procedural macros in `proc-macro` crates (accepted, proc_macro, "1.29.0", Some(38356), None), - // `foo.rs` as an alternative to `foo/mod.rs` - (accepted, non_modrs_mods, "1.30.0", Some(44660), None), // Allows use of the :vis macro fragment specifier (accepted, macro_vis_matcher, "1.30.0", Some(41022), None), // Allows importing and reexporting macros with `use`, @@ -663,8 +667,6 @@ declare_features! ( (accepted, proc_macro_path_invoc, "1.30.0", Some(38356), None), // Allows all literals in attribute lists and values of key-value pairs. (accepted, attr_literals, "1.30.0", Some(34981), None), - // Infer outlives requirements; RFC 2093 - (accepted, infer_outlives_requirements, "1.30.0", Some(44493), None), (accepted, panic_handler, "1.30.0", Some(44489), None), // Used to preserve symbols (see llvm.used) (accepted, used, "1.30.0", Some(40289), None), @@ -1126,6 +1128,12 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG "never will be stable", cfg_fn!(rustc_attrs))), + // RFC #2093 + ("infer_outlives_requirements", Normal, Gated(Stability::Unstable, + "infer_outlives_requirements", + "infer outlives requirements is an experimental feature", + cfg_fn!(infer_outlives_requirements))), + // RFC #2093 ("infer_static_outlives_requirements", Normal, Gated(Stability::Unstable, "infer_static_outlives_requirements", @@ -1493,6 +1501,31 @@ impl<'a> PostExpansionVisitor<'a> { } } +impl<'a> PostExpansionVisitor<'a> { + fn whole_crate_feature_gates(&mut self, _krate: &ast::Crate) { + for &(ident, span) in &*self.context.parse_sess.non_modrs_mods.borrow() { + if !span.allows_unstable() { + let cx = &self.context; + let level = GateStrength::Hard; + let has_feature = cx.features.non_modrs_mods; + let name = "non_modrs_mods"; + debug!("gate_feature(feature = {:?}, span = {:?}); has? {}", + name, span, has_feature); + + if !has_feature && !span.allows_unstable() { + leveled_feature_err( + cx.parse_sess, name, span, GateIssue::Language, + "mod statements in non-mod.rs files are unstable", level + ) + .help(&format!("on stable builds, rename this file to {}{}mod.rs", + ident, path::MAIN_SEPARATOR)) + .emit(); + } + } + } + } +} + impl<'a> Visitor<'a> for PostExpansionVisitor<'a> { fn visit_attribute(&mut self, attr: &ast::Attribute) { if !attr.span.allows_unstable() { @@ -2059,6 +2092,7 @@ pub fn check_crate(krate: &ast::Crate, }; let visitor = &mut PostExpansionVisitor { context: &ctx }; + visitor.whole_crate_feature_gates(krate); visit::walk_crate(visitor, krate); } diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 2aaab6aaa1..c8ec273a03 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -22,6 +22,7 @@ #![feature(crate_visibility_modifier)] #![feature(macro_at_most_once_rep)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(rustc_attrs)] #![feature(rustc_diagnostic_macros)] #![feature(slice_sort_by_cached_key)] diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs index 31089c9ff8..88af4a73a1 100644 --- a/src/libsyntax_ext/lib.rs +++ b/src/libsyntax_ext/lib.rs @@ -17,6 +17,7 @@ #![feature(proc_macro_internals)] #![feature(decl_macro)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(str_escape)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] diff --git a/src/libsyntax_pos/edition.rs b/src/libsyntax_pos/edition.rs index 7709db72a0..fce8fc3db4 100644 --- a/src/libsyntax_pos/edition.rs +++ b/src/libsyntax_pos/edition.rs @@ -65,7 +65,7 @@ impl Edition { pub fn is_stable(&self) -> bool { match *self { Edition::Edition2015 => true, - Edition::Edition2018 => true, + Edition::Edition2018 => false, } } } diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index bd70344b01..e7310dbfd3 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -22,6 +22,7 @@ #![feature(crate_visibility_modifier)] #![feature(custom_attribute)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(non_exhaustive)] #![feature(optin_builtin_traits)] #![feature(specialization)] @@ -87,7 +88,7 @@ scoped_thread_local!(pub static GLOBALS: Globals); #[derive(Debug, Eq, PartialEq, Clone, Ord, PartialOrd, Hash, RustcDecodable, RustcEncodable)] pub enum FileName { Real(PathBuf), - /// e.g. "std" macros + /// A macro. This includes the full name of the macro, so that there are no clashes. Macros(String), /// call to `quote!` QuoteExpansion, diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index a49fd67639..df90be6393 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -51,6 +51,7 @@ // Handle rustfmt skips #![feature(custom_attribute)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![allow(unused_attributes)] use std::io::prelude::*; diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index 6ffa6e9be9..bf3cb7c537 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -36,6 +36,7 @@ #![feature(fnbox)] #![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc))] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(set_stdio)] #![feature(panic_unwind)] #![feature(staged_api)] diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs index 424a7e3d00..3b94dc238d 100644 --- a/src/libunwind/lib.rs +++ b/src/libunwind/lib.rs @@ -14,6 +14,7 @@ #![feature(cfg_target_vendor)] #![feature(link_cfg)] #![cfg_attr(not(stage0), feature(nll))] +#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(staged_api)] #![feature(unwind_attributes)] #![feature(static_nobundle)] diff --git a/src/stage0.txt b/src/stage0.txt index b791a07f48..46089135e3 100644 --- a/src/stage0.txt +++ b/src/stage0.txt @@ -12,8 +12,8 @@ # source tarball for a stable release you'll likely see `1.x.0` for rustc and # `0.x.0` for Cargo where they were released on `date`. -date: 2018-09-13 -rustc: 1.29.0 +date: 2018-10-12 +rustc: 1.29.2 cargo: 0.30.0 # When making a stable release the process currently looks like: diff --git a/src/test/codegen/function-arguments.rs b/src/test/codegen/function-arguments.rs index 0bd021f8ae..5061d9a915 100644 --- a/src/test/codegen/function-arguments.rs +++ b/src/test/codegen/function-arguments.rs @@ -53,13 +53,13 @@ pub fn named_borrow<'r>(_: &'r i32) { pub fn unsafe_borrow(_: &UnsafeInner) { } -// CHECK: @mutable_unsafe_borrow(i16* noalias dereferenceable(2) %arg0) +// CHECK: @mutable_unsafe_borrow(i16* dereferenceable(2) %arg0) // ... unless this is a mutable borrow, those never alias #[no_mangle] pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) { } -// CHECK: @mutable_borrow(i32* noalias dereferenceable(4) %arg0) +// CHECK: @mutable_borrow(i32* dereferenceable(4) %arg0) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn mutable_borrow(_: &mut i32) { @@ -102,7 +102,7 @@ pub fn helper(_: usize) { pub fn slice(_: &[u8]) { } -// CHECK: @mutable_slice([0 x i8]* noalias nonnull %arg0.0, [[USIZE]] %arg0.1) +// CHECK: @mutable_slice([0 x i8]* nonnull %arg0.0, [[USIZE]] %arg0.1) // FIXME #25759 This should also have `nocapture` #[no_mangle] pub fn mutable_slice(_: &mut [u8]) { diff --git a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs b/src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs index 83bbb7c13c..d0aed8b162 100644 --- a/src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/proc-macro-attributes.rs @@ -11,13 +11,11 @@ // aux-build:derive-b.rs // ignore-stage1 -#![allow(warnings)] - #[macro_use] extern crate derive_b; -#[B] //~ ERROR `B` is a derive mode -#[C] +#[B] +#[C] //~ ERROR attribute `C` is currently unknown to the compiler #[B(D)] #[B(E = "foo")] #[B(arbitrary tokens)] diff --git a/src/test/incremental/issue-51409.rs b/src/test/incremental/issue-51409.rs index 8aa75e6315..d7aff5afe4 100644 --- a/src/test/incremental/issue-51409.rs +++ b/src/test/incremental/issue-51409.rs @@ -13,6 +13,8 @@ // Regression test that `infer_outlives_predicates` can be // used with incremental without an ICE. +#![feature(infer_outlives_requirements)] + struct Foo<'a, T> { x: &'a T } diff --git a/src/test/run-pass/async-await.rs b/src/test/run-pass/async-await.rs index f692f57abb..2c634f3449 100644 --- a/src/test/run-pass/async-await.rs +++ b/src/test/run-pass/async-await.rs @@ -183,6 +183,7 @@ fn main() { async_closure, async_fn, async_fn_with_internal_borrow, + Foo::async_method, |x| { async move { unsafe { await!(unsafe_async_fn(x)) } diff --git a/src/test/run-pass/impl-trait/existential-minimal.stderr b/src/test/run-pass/impl-trait/existential-minimal.stderr new file mode 100644 index 0000000000..dd1f749788 --- /dev/null +++ b/src/test/run-pass/impl-trait/existential-minimal.stderr @@ -0,0 +1,8 @@ +warning: function is never used: `foo` + --> $DIR/existential-minimal.rs:15:1 + | +LL | fn foo() -> impl std::fmt::Debug { "cake" } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: #[warn(dead_code)] on by default + diff --git a/src/test/run-pass/impl-trait/issue-42479.stderr b/src/test/run-pass/impl-trait/issue-42479.stderr new file mode 100644 index 0000000000..5a6a3031d0 --- /dev/null +++ b/src/test/run-pass/impl-trait/issue-42479.stderr @@ -0,0 +1,14 @@ +warning: struct is never constructed: `Foo` + --> $DIR/issue-42479.rs:15:1 + | +LL | struct Foo { + | ^^^^^^^^^^ + | + = note: #[warn(dead_code)] on by default + +warning: method is never used: `inside` + --> $DIR/issue-42479.rs:20:5 + | +LL | fn inside(&self) -> impl Iterator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/src/test/run-pass/impl-trait/issue-49376.stderr b/src/test/run-pass/impl-trait/issue-49376.stderr new file mode 100644 index 0000000000..f5f36002b4 --- /dev/null +++ b/src/test/run-pass/impl-trait/issue-49376.stderr @@ -0,0 +1,32 @@ +warning: function is never used: `gen` + --> $DIR/issue-49376.rs:18:1 + | +LL | fn gen() -> impl PartialOrd + PartialEq + Debug { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: #[warn(dead_code)] on by default + +warning: struct is never constructed: `Bar` + --> $DIR/issue-49376.rs:20:1 + | +LL | struct Bar {} + | ^^^^^^^^^^ + +warning: function is never used: `foo` + --> $DIR/issue-49376.rs:24:1 + | +LL | fn foo() -> impl Foo { + | ^^^^^^^^^^^^^^^^^^^^ + +warning: function is never used: `test_impl_ops` + --> $DIR/issue-49376.rs:28:1 + | +LL | fn test_impl_ops() -> impl Add + Sub + Mul + Div { 1 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: function is never used: `test_impl_assign_ops` + --> $DIR/issue-49376.rs:29:1 + | +LL | fn test_impl_assign_ops() -> impl AddAssign + SubAssign + MulAssign + DivAssign { 1 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + diff --git a/src/test/run-pass/issue-54462-mutable-noalias-correctness.rs b/src/test/run-pass/issue-54462-mutable-noalias-correctness.rs new file mode 100644 index 0000000000..f0e52b2928 --- /dev/null +++ b/src/test/run-pass/issue-54462-mutable-noalias-correctness.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. +// +// compile-flags: -Ccodegen-units=1 -O + +fn linidx(row: usize, col: usize) -> usize { + row * 1 + col * 3 +} + +fn main() { + let mut mat = [1.0f32, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0]; + + for i in 0..2 { + for j in i+1..3 { + if mat[linidx(j, 3)] > mat[linidx(i, 3)] { + for k in 0..4 { + let (x, rest) = mat.split_at_mut(linidx(i, k) + 1); + let a = x.last_mut().unwrap(); + let b = rest.get_mut(linidx(j, k) - linidx(i, k) - 1).unwrap(); + ::std::mem::swap(a, b); + } + } + } + } + assert_eq!([9.0, 5.0, 1.0, 10.0, 6.0, 2.0, 11.0, 7.0, 3.0, 12.0, 8.0, 4.0], mat); +} diff --git a/src/test/run-pass/issue-54467.rs b/src/test/run-pass/issue-54467.rs new file mode 100644 index 0000000000..033925a4c0 --- /dev/null +++ b/src/test/run-pass/issue-54467.rs @@ -0,0 +1,54 @@ +// 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 trait Stream { + type Item; + type Error; +} + +pub trait ParseError { + type Output; +} + +impl ParseError for u32 { + type Output = (); +} + +impl Stream for () { + type Item = char; + type Error = u32; +} + +pub struct Lex<'a, I> + where I: Stream, + I::Error: ParseError, + <::Error as ParseError>::Output: 'a +{ + x: &'a >::Output +} + +pub struct Reserved<'a, I> where + I: Stream + 'a, + I::Error: ParseError, +// <::Error as ParseError>::Output: 'a // comment this to compile + +{ + x: Lex<'a, I> +} + +fn main() { + let r: Reserved<()> = Reserved { + x: Lex { + x: &() + } + }; + + let _v = r.x.x; +} diff --git a/src/test/run-pass/issues/issue-49556.stderr b/src/test/run-pass/issues/issue-49556.stderr new file mode 100644 index 0000000000..8657d4ac2f --- /dev/null +++ b/src/test/run-pass/issues/issue-49556.stderr @@ -0,0 +1,8 @@ +warning: function is never used: `iter` + --> $DIR/issue-49556.rs:12:1 + | +LL | fn iter<'a>(data: &'a [usize]) -> impl Iterator + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: #[warn(dead_code)] on by default + diff --git a/src/test/run-pass/traits/conservative_impl_trait.stderr b/src/test/run-pass/traits/conservative_impl_trait.stderr new file mode 100644 index 0000000000..26c29bf2bb --- /dev/null +++ b/src/test/run-pass/traits/conservative_impl_trait.stderr @@ -0,0 +1,8 @@ +warning: function is never used: `batches` + --> $DIR/conservative_impl_trait.rs:14:1 + | +LL | fn batches(n: &u32) -> impl Iterator { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: #[warn(dead_code)] on by default + diff --git a/src/test/rustdoc-ui/failed-doctest-output.stdout b/src/test/rustdoc-ui/failed-doctest-output.stdout index dbc65569af..cf417f8d41 100644 --- a/src/test/rustdoc-ui/failed-doctest-output.stdout +++ b/src/test/rustdoc-ui/failed-doctest-output.stdout @@ -12,7 +12,7 @@ error[E0425]: cannot find value `no` in this scope 3 | no | ^^ not found in this scope -thread '$DIR/failed-doctest-output.rs - OtherStruct (line 26)' panicked at 'couldn't compile the test', librustdoc/test.rs:333:13 +thread '$DIR/failed-doctest-output.rs - OtherStruct (line 26)' panicked at 'couldn't compile the test', librustdoc/test.rs:332:13 note: Run with `RUST_BACKTRACE=1` for a backtrace. ---- $DIR/failed-doctest-output.rs - SomeStruct (line 20) stdout ---- @@ -21,7 +21,7 @@ thread '$DIR/failed-doctest-output.rs - SomeStruct (line 20)' panicked at 'test thread 'main' panicked at 'oh no', $DIR/failed-doctest-output.rs:3:1 note: Run with `RUST_BACKTRACE=1` for a backtrace. -', librustdoc/test.rs:368:17 +', librustdoc/test.rs:367:17 failures: diff --git a/src/test/ui-fulldeps/custom-derive/auxiliary/plugin.rs b/src/test/ui-fulldeps/custom-derive/auxiliary/plugin.rs index 7be909c3c9..124bc05b7a 100644 --- a/src/test/ui-fulldeps/custom-derive/auxiliary/plugin.rs +++ b/src/test/ui-fulldeps/custom-derive/auxiliary/plugin.rs @@ -25,3 +25,13 @@ pub fn derive_foo(input: TokenStream) -> TokenStream { pub fn derive_bar(input: TokenStream) -> TokenStream { panic!("lolnope"); } + +#[proc_macro_derive(WithHelper, attributes(helper))] +pub fn with_helper(input: TokenStream) -> TokenStream { + TokenStream::new() +} + +#[proc_macro_attribute] +pub fn helper(_: TokenStream, input: TokenStream) -> TokenStream { + input +} diff --git a/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.rs b/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.rs new file mode 100644 index 0000000000..b750a8bb0d --- /dev/null +++ b/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.rs @@ -0,0 +1,13 @@ +// aux-build:plugin.rs +// ignore-stage1 + +#[macro_use(WithHelper)] +extern crate plugin; + +use plugin::helper; + +#[derive(WithHelper)] +#[helper] //~ ERROR `helper` is ambiguous +struct S; + +fn main() {} diff --git a/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.stderr b/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.stderr new file mode 100644 index 0000000000..059629c0b6 --- /dev/null +++ b/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import-ambig.stderr @@ -0,0 +1,20 @@ +error[E0659]: `helper` is ambiguous + --> $DIR/helper-attr-blocked-by-import-ambig.rs:10:3 + | +LL | #[helper] //~ ERROR `helper` is ambiguous + | ^^^^^^ ambiguous name + | +note: `helper` could refer to the name defined here + --> $DIR/helper-attr-blocked-by-import-ambig.rs:9:10 + | +LL | #[derive(WithHelper)] + | ^^^^^^^^^^ +note: `helper` could also refer to the name imported here + --> $DIR/helper-attr-blocked-by-import-ambig.rs:7:5 + | +LL | use plugin::helper; + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0659`. diff --git a/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import.rs b/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import.rs new file mode 100644 index 0000000000..03b774f6c6 --- /dev/null +++ b/src/test/ui-fulldeps/custom-derive/helper-attr-blocked-by-import.rs @@ -0,0 +1,29 @@ +// compile-pass +// aux-build:plugin.rs +// ignore-stage1 + +#[macro_use(WithHelper)] +extern crate plugin; + +use self::one::*; +use self::two::*; + +mod helper {} + +mod one { + use helper; + + #[derive(WithHelper)] + #[helper] + struct One; +} + +mod two { + use helper; + + #[derive(WithHelper)] + #[helper] + struct Two; +} + +fn main() {} diff --git a/src/test/ui-fulldeps/lint_tool_test.rs b/src/test/ui-fulldeps/lint_tool_test.rs deleted file mode 100644 index ebe10b3714..0000000000 --- a/src/test/ui-fulldeps/lint_tool_test.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. - -// aux-build:lint_tool_test.rs -// ignore-stage1 -// compile-flags: --cfg foo -#![feature(plugin)] -#![feature(tool_lints)] -#![plugin(lint_tool_test)] -#![allow(dead_code)] -#![cfg_attr(foo, warn(test_lint))] -//~^ WARNING lint name `test_lint` is deprecated and may not have an effect in the future -//~^^ WARNING lint name `test_lint` is deprecated and may not have an effect in the future -#![deny(clippy_group)] -//~^ WARNING lint name `clippy_group` is deprecated and may not have an effect in the future - -fn lintme() { } //~ ERROR item is named 'lintme' - -#[allow(clippy::group)] -fn lintmetoo() {} - -#[allow(clippy::test_lint)] -pub fn main() { - fn lintme() { } - fn lintmetoo() { } //~ ERROR item is named 'lintmetoo' -} - -#[allow(test_group)] -//~^ WARNING lint name `test_group` is deprecated and may not have an effect in the future -#[deny(this_lint_does_not_exist)] //~ WARNING unknown lint: `this_lint_does_not_exist` -fn hello() { - fn lintmetoo() { } -} diff --git a/src/test/ui-fulldeps/lint_tool_test.stderr b/src/test/ui-fulldeps/lint_tool_test.stderr deleted file mode 100644 index ab0c317e1c..0000000000 --- a/src/test/ui-fulldeps/lint_tool_test.stderr +++ /dev/null @@ -1,62 +0,0 @@ -warning: lint name `test_lint` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore - --> $DIR/lint_tool_test.rs:18:23 - | -LL | #![cfg_attr(foo, warn(test_lint))] - | ^^^^^^^^^ help: change it to: `clippy::test_lint` - | - = note: #[warn(renamed_and_removed_lints)] on by default - -warning: lint name `clippy_group` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore - --> $DIR/lint_tool_test.rs:21:9 - | -LL | #![deny(clippy_group)] - | ^^^^^^^^^^^^ help: change it to: `clippy::group` - -warning: lint name `test_group` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore - --> $DIR/lint_tool_test.rs:35:9 - | -LL | #[allow(test_group)] - | ^^^^^^^^^^ help: change it to: `clippy::test_group` - -warning: unknown lint: `this_lint_does_not_exist` - --> $DIR/lint_tool_test.rs:37:8 - | -LL | #[deny(this_lint_does_not_exist)] //~ WARNING unknown lint: `this_lint_does_not_exist` - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: #[warn(unknown_lints)] on by default - -warning: lint name `test_lint` is deprecated and may not have an effect in the future. Also `cfg_attr(cargo-clippy)` won't be necessary anymore - --> $DIR/lint_tool_test.rs:18:23 - | -LL | #![cfg_attr(foo, warn(test_lint))] - | ^^^^^^^^^ help: change it to: `clippy::test_lint` - -error: item is named 'lintme' - --> $DIR/lint_tool_test.rs:24:1 - | -LL | fn lintme() { } //~ ERROR item is named 'lintme' - | ^^^^^^^^^^^^^^^ - | -note: lint level defined here - --> $DIR/lint_tool_test.rs:21:9 - | -LL | #![deny(clippy_group)] - | ^^^^^^^^^^^^ - = note: #[deny(clippy::test_lint)] implied by #[deny(clippy::group)] - -error: item is named 'lintmetoo' - --> $DIR/lint_tool_test.rs:32:5 - | -LL | fn lintmetoo() { } //~ ERROR item is named 'lintmetoo' - | ^^^^^^^^^^^^^^^^^^ - | -note: lint level defined here - --> $DIR/lint_tool_test.rs:21:9 - | -LL | #![deny(clippy_group)] - | ^^^^^^^^^^^^ - = note: #[deny(clippy::test_group)] implied by #[deny(clippy::group)] - -error: aborting due to 2 previous errors - diff --git a/src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.stderr b/src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.stderr index cdfecb3d10..e0aeae4ba6 100644 --- a/src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.stderr +++ b/src/test/ui-fulldeps/proc-macro/derive-helper-shadowing.stderr @@ -4,17 +4,16 @@ error[E0659]: `my_attr` is ambiguous LL | #[my_attr] //~ ERROR `my_attr` is ambiguous | ^^^^^^^ ambiguous name | -note: `my_attr` could refer to the name imported here - --> $DIR/derive-helper-shadowing.rs:4:5 - | -LL | use derive_helper_shadowing::*; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: `my_attr` could also refer to the name defined here +note: `my_attr` could refer to the name defined here --> $DIR/derive-helper-shadowing.rs:7:10 | LL | #[derive(MyTrait)] | ^^^^^^^ - = note: consider adding an explicit import of `my_attr` to disambiguate +note: `my_attr` could also refer to the name imported here + --> $DIR/derive-helper-shadowing.rs:4:5 + | +LL | use derive_helper_shadowing::*; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.stderr b/src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.stderr index 76dc139b58..415733a346 100644 --- a/src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.stderr +++ b/src/test/ui-fulldeps/rust-2018/suggestions-not-always-applicable.stderr @@ -11,7 +11,7 @@ LL | #![warn(rust_2018_compatibility)] | ^^^^^^^^^^^^^^^^^^^^^^^ = note: #[warn(absolute_paths_not_starting_with_crate)] implied by #[warn(rust_2018_compatibility)] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue TBD + = note: for more information, see issue #53130 warning: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition --> $DIR/suggestions-not-always-applicable.rs:27:5 @@ -20,5 +20,5 @@ LL | #[foo] //~ WARN: absolute paths must start with | ^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue TBD + = note: for more information, see issue #53130 diff --git a/src/test/ui-fulldeps/unnecessary-extern-crate.rs b/src/test/ui-fulldeps/unnecessary-extern-crate.rs index df723ddf59..1cdc9229d0 100644 --- a/src/test/ui-fulldeps/unnecessary-extern-crate.rs +++ b/src/test/ui-fulldeps/unnecessary-extern-crate.rs @@ -20,33 +20,23 @@ extern crate alloc as x; //~^ ERROR unused extern crate //~| HELP remove +extern crate proc_macro; + #[macro_use] extern crate test; pub extern crate test as y; -//~^ ERROR `extern crate` is not idiomatic in the new edition -//~| HELP convert it to a `pub use` pub extern crate libc; -//~^ ERROR `extern crate` is not idiomatic in the new edition -//~| HELP convert it to a `pub use` pub(crate) extern crate libc as a; -//~^ ERROR `extern crate` is not idiomatic in the new edition -//~| HELP convert it to a `pub(crate) use` crate extern crate libc as b; -//~^ ERROR `extern crate` is not idiomatic in the new edition -//~| HELP convert it to a `crate use` mod foo { pub(in crate::foo) extern crate libc as c; - //~^ ERROR `extern crate` is not idiomatic in the new edition - //~| HELP convert it to a `pub(in crate::foo) use` pub(super) extern crate libc as d; - //~^ ERROR `extern crate` is not idiomatic in the new edition - //~| HELP convert it to a `pub(super) use` extern crate alloc; //~^ ERROR unused extern crate @@ -57,12 +47,8 @@ mod foo { //~| HELP remove pub extern crate test; - //~^ ERROR `extern crate` is not idiomatic in the new edition - //~| HELP convert it pub extern crate test as y; - //~^ ERROR `extern crate` is not idiomatic in the new edition - //~| HELP convert it mod bar { extern crate alloc; @@ -74,8 +60,6 @@ mod foo { //~| HELP remove pub(in crate::foo::bar) extern crate libc as e; - //~^ ERROR `extern crate` is not idiomatic in the new edition - //~| HELP convert it to a `pub(in crate::foo::bar) use` fn dummy() { unsafe { @@ -96,4 +80,6 @@ mod foo { fn main() { unsafe { a::getpid(); } unsafe { b::getpid(); } + + proc_macro::TokenStream::new(); } diff --git a/src/test/ui-fulldeps/unnecessary-extern-crate.stderr b/src/test/ui-fulldeps/unnecessary-extern-crate.stderr index a430711215..58ec590158 100644 --- a/src/test/ui-fulldeps/unnecessary-extern-crate.stderr +++ b/src/test/ui-fulldeps/unnecessary-extern-crate.stderr @@ -16,83 +16,29 @@ error: unused extern crate LL | extern crate alloc as x; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it -error: `extern crate` is not idiomatic in the new edition - --> $DIR/unnecessary-extern-crate.rs:26:1 - | -LL | pub extern crate test as y; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `pub use` - -error: `extern crate` is not idiomatic in the new edition - --> $DIR/unnecessary-extern-crate.rs:30:1 - | -LL | pub extern crate libc; - | ^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `pub use` - -error: `extern crate` is not idiomatic in the new edition - --> $DIR/unnecessary-extern-crate.rs:34:1 - | -LL | pub(crate) extern crate libc as a; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `pub(crate) use` - -error: `extern crate` is not idiomatic in the new edition - --> $DIR/unnecessary-extern-crate.rs:38:1 - | -LL | crate extern crate libc as b; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `crate use` - -error: `extern crate` is not idiomatic in the new edition - --> $DIR/unnecessary-extern-crate.rs:43:5 - | -LL | pub(in crate::foo) extern crate libc as c; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `pub(in crate::foo) use` - -error: `extern crate` is not idiomatic in the new edition - --> $DIR/unnecessary-extern-crate.rs:47:5 - | -LL | pub(super) extern crate libc as d; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `pub(super) use` - error: unused extern crate - --> $DIR/unnecessary-extern-crate.rs:51:5 + --> $DIR/unnecessary-extern-crate.rs:41:5 | LL | extern crate alloc; | ^^^^^^^^^^^^^^^^^^^ help: remove it error: unused extern crate - --> $DIR/unnecessary-extern-crate.rs:55:5 + --> $DIR/unnecessary-extern-crate.rs:45:5 | LL | extern crate alloc as x; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it -error: `extern crate` is not idiomatic in the new edition - --> $DIR/unnecessary-extern-crate.rs:59:5 - | -LL | pub extern crate test; - | ^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `pub use` - -error: `extern crate` is not idiomatic in the new edition - --> $DIR/unnecessary-extern-crate.rs:63:5 - | -LL | pub extern crate test as y; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `pub use` - error: unused extern crate - --> $DIR/unnecessary-extern-crate.rs:68:9 + --> $DIR/unnecessary-extern-crate.rs:54:9 | LL | extern crate alloc; | ^^^^^^^^^^^^^^^^^^^ help: remove it error: unused extern crate - --> $DIR/unnecessary-extern-crate.rs:72:9 + --> $DIR/unnecessary-extern-crate.rs:58:9 | LL | extern crate alloc as x; | ^^^^^^^^^^^^^^^^^^^^^^^^ help: remove it -error: `extern crate` is not idiomatic in the new edition - --> $DIR/unnecessary-extern-crate.rs:76:9 - | -LL | pub(in crate::foo::bar) extern crate libc as e; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `pub(in crate::foo::bar) use` - -error: aborting due to 15 previous errors +error: aborting due to 6 previous errors diff --git a/src/test/ui/cfg-attr-trailing-comma.rs b/src/test/ui/cfg-attr-trailing-comma.rs new file mode 100644 index 0000000000..21e00544ca --- /dev/null +++ b/src/test/ui/cfg-attr-trailing-comma.rs @@ -0,0 +1,13 @@ +// compile-flags: --cfg TRUE + +#[cfg_attr(TRUE, inline,)] // OK +fn f() {} + +#[cfg_attr(FALSE, inline,)] // OK +fn g() {} + +#[cfg_attr(TRUE, inline,,)] //~ ERROR expected `)`, found `,` +fn h() {} + +#[cfg_attr(FALSE, inline,,)] //~ ERROR expected `)`, found `,` +fn i() {} diff --git a/src/test/ui/cfg-attr-trailing-comma.stderr b/src/test/ui/cfg-attr-trailing-comma.stderr new file mode 100644 index 0000000000..76a470417e --- /dev/null +++ b/src/test/ui/cfg-attr-trailing-comma.stderr @@ -0,0 +1,14 @@ +error: expected `)`, found `,` + --> $DIR/cfg-attr-trailing-comma.rs:9:25 + | +LL | #[cfg_attr(TRUE, inline,,)] //~ ERROR expected `)`, found `,` + | ^ expected `)` + +error: expected `)`, found `,` + --> $DIR/cfg-attr-trailing-comma.rs:12:26 + | +LL | #[cfg_attr(FALSE, inline,,)] //~ ERROR expected `)`, found `,` + | ^ expected `)` + +error: aborting due to 2 previous errors + diff --git a/src/test/ui/consts/const-eval/union-ice.rs b/src/test/ui/consts/const-eval/union-ice.rs index 0cdb78c978..5d50004e55 100644 --- a/src/test/ui/consts/const-eval/union-ice.rs +++ b/src/test/ui/consts/const-eval/union-ice.rs @@ -22,7 +22,7 @@ const UNION: DummyUnion = DummyUnion { field1: 1065353216 }; const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR this constant cannot be used -const FIELD_PATH: Struct = Struct { //~ ERROR this constant cannot be used +const FIELD_PATH: Struct = Struct { //~ ERROR this constant likely exhibits undefined behavior a: 42, b: unsafe { UNION.field3 }, }; diff --git a/src/test/ui/consts/const-eval/union-ice.stderr b/src/test/ui/consts/const-eval/union-ice.stderr index e8a7b2f500..ec51802681 100644 --- a/src/test/ui/consts/const-eval/union-ice.stderr +++ b/src/test/ui/consts/const-eval/union-ice.stderr @@ -6,14 +6,16 @@ LL | const FIELD3: Field3 = unsafe { UNION.field3 }; //~ ERROR this constant can | = note: #[deny(const_err)] on by default -error: this constant cannot be used +error[E0080]: this constant likely exhibits undefined behavior --> $DIR/union-ice.rs:25:1 | -LL | / const FIELD_PATH: Struct = Struct { //~ ERROR this constant cannot be used +LL | / const FIELD_PATH: Struct = Struct { //~ ERROR this constant likely exhibits undefined behavior LL | | a: 42, LL | | b: unsafe { UNION.field3 }, LL | | }; - | |__^ attempted to read undefined bytes + | |__^ type validation failed: encountered undefined bytes at .b + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior error[E0080]: this constant likely exhibits undefined behavior --> $DIR/union-ice.rs:35:1 diff --git a/src/test/ui/dep-graph/dep-graph-struct-signature.rs b/src/test/ui/dep-graph/dep-graph-struct-signature.rs index 6343dc201c..647605ae43 100644 --- a/src/test/ui/dep-graph/dep-graph-struct-signature.rs +++ b/src/test/ui/dep-graph/dep-graph-struct-signature.rs @@ -88,6 +88,7 @@ mod invalid_signatures { } #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path + #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path fn b(x: WontChange) { } #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path from `WillChange` diff --git a/src/test/ui/dep-graph/dep-graph-struct-signature.stderr b/src/test/ui/dep-graph/dep-graph-struct-signature.stderr index 0d75bf5a9a..cbb695d0cf 100644 --- a/src/test/ui/dep-graph/dep-graph-struct-signature.stderr +++ b/src/test/ui/dep-graph/dep-graph-struct-signature.stderr @@ -82,14 +82,20 @@ error: no path from `WillChange` to `FnSignature` LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: no path from `WillChange` to `TypeckTables` + --> $DIR/dep-graph-struct-signature.rs:91:5 + | +LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: no path from `WillChange` to `FnSignature` - --> $DIR/dep-graph-struct-signature.rs:93:5 + --> $DIR/dep-graph-struct-signature.rs:94:5 | LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path from `WillChange` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: no path from `WillChange` to `TypeckTables` - --> $DIR/dep-graph-struct-signature.rs:94:5 + --> $DIR/dep-graph-struct-signature.rs:95:5 | LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path from `WillChange` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -130,5 +136,5 @@ error: OK LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 22 previous errors +error: aborting due to 23 previous errors diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs b/src/test/ui/directory_ownership/mod_file_not_owning.rs similarity index 52% rename from src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs rename to src/test/ui/directory_ownership/mod_file_not_owning.rs index bdd708197b..ff93fddf9b 100644 --- a/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs +++ b/src/test/ui/directory_ownership/mod_file_not_owning.rs @@ -8,31 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// Various examples of structs whose fields are not well-formed. +// error-pattern: mod statements in non-mod.rs files are unstable -#![allow(dead_code)] +mod mod_file_not_owning_aux1; -trait Trait<'a, T> { - type Out; -} -trait Trait1<'a, 'b, T> { - type Out; -} - -impl<'a, T> Trait<'a, T> for usize { - type Out = &'a T; -} - -struct RefOk<'a, T:'a> { - field: &'a T -} - -impl<'a, T> Trait<'a, T> for u32 { - type Out = RefOk<'a, T>; -} - -impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { - type Out = &'a &'b T; -} - -fn main() { } +fn main() {} diff --git a/src/test/ui/directory_ownership/mod_file_not_owning.stderr b/src/test/ui/directory_ownership/mod_file_not_owning.stderr new file mode 100644 index 0000000000..e293757399 --- /dev/null +++ b/src/test/ui/directory_ownership/mod_file_not_owning.stderr @@ -0,0 +1,15 @@ +error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660) + --> $DIR/mod_file_not_owning_aux1.rs:14:17 + | +LL | () => { mod mod_file_not_owning_aux2; } + | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | } +LL | m!(); + | ----- in this macro invocation + | + = help: add #![feature(non_modrs_mods)] to the crate attributes to enable + = help: on stable builds, rename this file to mod_file_not_owning_aux1/mod.rs + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/directory_ownership/unowned_mod_with_path.rs b/src/test/ui/directory_ownership/unowned_mod_with_path.rs new file mode 100644 index 0000000000..0cffb7cc9e --- /dev/null +++ b/src/test/ui/directory_ownership/unowned_mod_with_path.rs @@ -0,0 +1,15 @@ +// 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. + +// error-pattern: mod statements in non-mod.rs files are unstable + +// This is not a directory owner since the file name is not "mod.rs". +#[path = "mod_file_not_owning_aux1.rs"] +mod foo; diff --git a/src/test/ui/directory_ownership/unowned_mod_with_path.stderr b/src/test/ui/directory_ownership/unowned_mod_with_path.stderr new file mode 100644 index 0000000000..0c0b428143 --- /dev/null +++ b/src/test/ui/directory_ownership/unowned_mod_with_path.stderr @@ -0,0 +1,15 @@ +error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660) + --> $DIR/mod_file_not_owning_aux1.rs:14:17 + | +LL | () => { mod mod_file_not_owning_aux2; } + | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | } +LL | m!(); + | ----- in this macro invocation + | + = help: add #![feature(non_modrs_mods)] to the crate attributes to enable + = help: on stable builds, rename this file to foo/mod.rs + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr b/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr index 02e7d5b7cd..5955410aa1 100644 --- a/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2018-2015-parsing.stderr @@ -23,7 +23,7 @@ LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the t | ^^^^^ error: expected one of `move`, `|`, or `||`, found `` - --> :1:22 + --> <::edition_kw_macro_2015::passes_ident macros>:1:22 | LL | ( $ i : ident ) => ( $ i ) | ^^^ expected one of `move`, `|`, or `||` here diff --git a/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr b/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr index 435e395c29..6ea736828f 100644 --- a/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr +++ b/src/test/ui/editions/edition-keywords-2018-2018-parsing.stderr @@ -23,7 +23,7 @@ LL | r#async = consumes_async_raw!(async); //~ ERROR no rules expected the t | ^^^^^ error: expected one of `move`, `|`, or `||`, found `` - --> :1:22 + --> <::edition_kw_macro_2018::passes_ident macros>:1:22 | LL | ( $ i : ident ) => ( $ i ) | ^^^ expected one of `move`, `|`, or `||` here diff --git a/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.rs b/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.rs new file mode 100644 index 0000000000..01ccc50a13 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.rs @@ -0,0 +1,18 @@ +// Copyright 2015 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Needs an explicit where clause stating outlives condition. (RFC 2093) + +// Type T needs to outlive lifetime 'a. +struct Foo<'a, T> { + bar: &'a [T] //~ ERROR the parameter type `T` may not live long enough [E0309] +} + +fn main() { } diff --git a/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.stderr b/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.stderr new file mode 100644 index 0000000000..560e494b58 --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.stderr @@ -0,0 +1,17 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/feature-gate-infer_outlives_requirements.rs:15:5 + | +LL | struct Foo<'a, T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | bar: &'a [T] //~ ERROR the parameter type `T` may not live long enough [E0309] + | ^^^^^^^^^^^^ + | +note: ...so that the reference type `&'a [T]` does not outlive the data it points at + --> $DIR/feature-gate-infer_outlives_requirements.rs:15:5 + | +LL | bar: &'a [T] //~ ERROR the parameter type `T` may not live long enough [E0309] + | ^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/impl-trait/auxiliary/extra-item.rs b/src/test/ui/impl-trait/auxiliary/extra-item.rs new file mode 100644 index 0000000000..8eaeafa520 --- /dev/null +++ b/src/test/ui/impl-trait/auxiliary/extra-item.rs @@ -0,0 +1 @@ +pub trait MyTrait {} diff --git a/src/test/ui/impl-trait/extra-item.rs b/src/test/ui/impl-trait/extra-item.rs new file mode 100644 index 0000000000..d82237ccec --- /dev/null +++ b/src/test/ui/impl-trait/extra-item.rs @@ -0,0 +1,10 @@ +// aux-build:extra-item.rs +// compile-flags:--extern extra_item + +struct S; + +impl extra_item::MyTrait for S { + fn extra() {} //~ ERROR method `extra` is not a member of trait `extra_item::MyTrait` +} + +fn main() {} diff --git a/src/test/ui/impl-trait/extra-item.stderr b/src/test/ui/impl-trait/extra-item.stderr new file mode 100644 index 0000000000..de3c7ba5d3 --- /dev/null +++ b/src/test/ui/impl-trait/extra-item.stderr @@ -0,0 +1,9 @@ +error[E0407]: method `extra` is not a member of trait `extra_item::MyTrait` + --> $DIR/extra-item.rs:7:5 + | +LL | fn extra() {} //~ ERROR method `extra` is not a member of trait `extra_item::MyTrait` + | ^^^^^^^^^^^^^ not a member of trait `extra_item::MyTrait` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0407`. diff --git a/src/test/ui/imports/local-modularized-tricky-fail-1.stderr b/src/test/ui/imports/local-modularized-tricky-fail-1.stderr index cce1fd30f1..9c475451ce 100644 --- a/src/test/ui/imports/local-modularized-tricky-fail-1.stderr +++ b/src/test/ui/imports/local-modularized-tricky-fail-1.stderr @@ -60,7 +60,7 @@ LL | define_panic!(); = note: macro-expanded macros do not shadow error[E0659]: `panic` is ambiguous - --> :1:13 + --> <::std::macros::panic macros>:1:13 | LL | ( ) => ( { panic ! ( "explicit panic" ) } ) ; ( $ msg : expr ) => ( | ^^^^^ ambiguous name diff --git a/src/test/ui/imports/macros.rs b/src/test/ui/imports/macros.rs index 47ab8fc6c2..f7dc7ac9ea 100644 --- a/src/test/ui/imports/macros.rs +++ b/src/test/ui/imports/macros.rs @@ -45,7 +45,7 @@ mod m3 { mod m4 { macro_rules! m { () => {} } use two_macros::m; - m!(); //~ ERROR ambiguous + m!(); } fn main() {} diff --git a/src/test/ui/imports/macros.stderr b/src/test/ui/imports/macros.stderr index c54101fc6e..209d449dfd 100644 --- a/src/test/ui/imports/macros.stderr +++ b/src/test/ui/imports/macros.stderr @@ -1,20 +1,3 @@ -error[E0659]: `m` is ambiguous - --> $DIR/macros.rs:48:5 - | -LL | m!(); //~ ERROR ambiguous - | ^ ambiguous name - | -note: `m` could refer to the name defined here - --> $DIR/macros.rs:46:5 - | -LL | macro_rules! m { () => {} } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: `m` could also refer to the name imported here - --> $DIR/macros.rs:47:9 - | -LL | use two_macros::m; - | ^^^^^^^^^^^^^ - error[E0659]: `m` is ambiguous --> $DIR/macros.rs:26:5 | @@ -51,6 +34,6 @@ LL | use two_macros::m; | ^^^^^^^^^^^^^ = note: macro-expanded macro imports do not shadow -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0659`. diff --git a/src/test/ui/issue-53419.rs b/src/test/ui/issue-53419.rs index 0dd5a85128..e4ade1b632 100644 --- a/src/test/ui/issue-53419.rs +++ b/src/test/ui/issue-53419.rs @@ -10,6 +10,8 @@ //compile-pass +#![feature(infer_outlives_requirements)] + struct Foo { bar: for<'r> Fn(usize, &'r FnMut()) } diff --git a/src/test/ui/issues/issue-37323.rs b/src/test/ui/issues/issue-37323.rs index 24ed7ce92b..98806cdd1b 100644 --- a/src/test/ui/issues/issue-37323.rs +++ b/src/test/ui/issues/issue-37323.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// compile-pass - #![feature(rustc_attrs)] #![allow(warnings)] @@ -19,6 +17,7 @@ struct Point { struct NestedA<'a, 'b> { x: &'a NestedB<'b> + //~^ ERROR E0491 } struct NestedB<'a> { diff --git a/src/test/ui/issues/issue-37323.stderr b/src/test/ui/issues/issue-37323.stderr new file mode 100644 index 0000000000..a83923a591 --- /dev/null +++ b/src/test/ui/issues/issue-37323.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a NestedB<'b>`, reference has a longer lifetime than the data it references + --> $DIR/issue-37323.rs:19:5 + | +LL | x: &'a NestedB<'b> + | ^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the struct at 18:16 + --> $DIR/issue-37323.rs:18:16 + | +LL | struct NestedA<'a, 'b> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 18:20 + --> $DIR/issue-37323.rs:18:20 + | +LL | struct NestedA<'a, 'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/issues/issue-54387.rs b/src/test/ui/issues/issue-54387.rs new file mode 100644 index 0000000000..ac1033add0 --- /dev/null +++ b/src/test/ui/issues/issue-54387.rs @@ -0,0 +1,12 @@ +// compile-pass + +pub struct GstRc { + _obj: *const (), + _borrowed: bool, +} + +const FOO: Option = None; + +fn main() { + let _meh = FOO; +} diff --git a/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs index 7bc83fd750..0099a8bc10 100644 --- a/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs +++ b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs @@ -14,9 +14,9 @@ trait ListItem<'a> { trait Collection { fn len(&self) -> usize; } -// is now well formed. RFC 2093 struct List<'a, T: ListItem<'a>> { slice: &'a [T] + //~^ ERROR may not live long enough } impl<'a, T: ListItem<'a>> Collection for List<'a, T> { diff --git a/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr index db8d57bb19..ea79990bbb 100644 --- a/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr +++ b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr @@ -1,3 +1,17 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/lifetime-doesnt-live-long-enough.rs:18:5 + | +LL | struct List<'a, T: ListItem<'a>> { + | -- help: consider adding an explicit lifetime bound `T: 'a`... +LL | slice: &'a [T] + | ^^^^^^^^^^^^^^ + | +note: ...so that the reference type `&'a [T]` does not outlive the data it points at + --> $DIR/lifetime-doesnt-live-long-enough.rs:18:5 + | +LL | slice: &'a [T] + | ^^^^^^^^^^^^^^ + error[E0310]: the parameter type `T` may not live long enough --> $DIR/lifetime-doesnt-live-long-enough.rs:29:5 | @@ -95,7 +109,7 @@ LL | | //~^ ERROR may not live long enough LL | | } | |_____^ -error: aborting due to 6 previous errors +error: aborting due to 7 previous errors Some errors occurred: E0309, E0310. For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/lint/lint-ctypes.rs b/src/test/ui/lint/lint-ctypes.rs index e09aabaf69..b8b1a675c5 100644 --- a/src/test/ui/lint/lint-ctypes.rs +++ b/src/test/ui/lint/lint-ctypes.rs @@ -11,8 +11,6 @@ #![deny(improper_ctypes)] #![feature(libc)] -#![allow(private_in_public)] - extern crate libc; use std::marker::PhantomData; diff --git a/src/test/ui/lint/lint-ctypes.stderr b/src/test/ui/lint/lint-ctypes.stderr index b243c49316..b97e466266 100644 --- a/src/test/ui/lint/lint-ctypes.stderr +++ b/src/test/ui/lint/lint-ctypes.stderr @@ -1,5 +1,5 @@ error: `extern` block uses type `Foo` which is not FFI-safe: this struct has unspecified layout - --> $DIR/lint-ctypes.rs:56:28 + --> $DIR/lint-ctypes.rs:54:28 | LL | pub fn ptr_type1(size: *const Foo); //~ ERROR: uses type `Foo` | ^^^^^^^^^^ @@ -11,26 +11,26 @@ LL | #![deny(improper_ctypes)] | ^^^^^^^^^^^^^^^ = help: consider adding a #[repr(C)] or #[repr(transparent)] attribute to this struct note: type defined here - --> $DIR/lint-ctypes.rs:34:1 + --> $DIR/lint-ctypes.rs:32:1 | LL | pub struct Foo; | ^^^^^^^^^^^^^^^ error: `extern` block uses type `Foo` which is not FFI-safe: this struct has unspecified layout - --> $DIR/lint-ctypes.rs:57:28 + --> $DIR/lint-ctypes.rs:55:28 | LL | pub fn ptr_type2(size: *const Foo); //~ ERROR: uses type `Foo` | ^^^^^^^^^^ | = help: consider adding a #[repr(C)] or #[repr(transparent)] attribute to this struct note: type defined here - --> $DIR/lint-ctypes.rs:34:1 + --> $DIR/lint-ctypes.rs:32:1 | LL | pub struct Foo; | ^^^^^^^^^^^^^^^ error: `extern` block uses type `[u32]` which is not FFI-safe: slices have no C equivalent - --> $DIR/lint-ctypes.rs:58:26 + --> $DIR/lint-ctypes.rs:56:26 | LL | pub fn slice_type(p: &[u32]); //~ ERROR: uses type `[u32]` | ^^^^^^ @@ -38,7 +38,7 @@ LL | pub fn slice_type(p: &[u32]); //~ ERROR: uses type `[u32]` = help: consider using a raw pointer instead error: `extern` block uses type `str` which is not FFI-safe: string slices have no C equivalent - --> $DIR/lint-ctypes.rs:59:24 + --> $DIR/lint-ctypes.rs:57:24 | LL | pub fn str_type(p: &str); //~ ERROR: uses type `str` | ^^^^ @@ -46,7 +46,7 @@ LL | pub fn str_type(p: &str); //~ ERROR: uses type `str` = help: consider using `*const u8` and a length instead error: `extern` block uses type `std::boxed::Box` which is not FFI-safe: this struct has unspecified layout - --> $DIR/lint-ctypes.rs:60:24 + --> $DIR/lint-ctypes.rs:58:24 | LL | pub fn box_type(p: Box); //~ ERROR uses type `std::boxed::Box` | ^^^^^^^^ @@ -54,7 +54,7 @@ LL | pub fn box_type(p: Box); //~ ERROR uses type `std::boxed::Box = help: consider adding a #[repr(C)] or #[repr(transparent)] attribute to this struct error: `extern` block uses type `char` which is not FFI-safe: the `char` type has no C equivalent - --> $DIR/lint-ctypes.rs:61:25 + --> $DIR/lint-ctypes.rs:59:25 | LL | pub fn char_type(p: char); //~ ERROR uses type `char` | ^^^^ @@ -62,25 +62,25 @@ LL | pub fn char_type(p: char); //~ ERROR uses type `char` = help: consider using `u32` or `libc::wchar_t` instead error: `extern` block uses type `i128` which is not FFI-safe: 128-bit integers don't currently have a known stable ABI - --> $DIR/lint-ctypes.rs:62:25 + --> $DIR/lint-ctypes.rs:60:25 | LL | pub fn i128_type(p: i128); //~ ERROR uses type `i128` | ^^^^ error: `extern` block uses type `u128` which is not FFI-safe: 128-bit integers don't currently have a known stable ABI - --> $DIR/lint-ctypes.rs:63:25 + --> $DIR/lint-ctypes.rs:61:25 | LL | pub fn u128_type(p: u128); //~ ERROR uses type `u128` | ^^^^ error: `extern` block uses type `dyn std::clone::Clone` which is not FFI-safe: trait objects have no C equivalent - --> $DIR/lint-ctypes.rs:64:26 + --> $DIR/lint-ctypes.rs:62:26 | LL | pub fn trait_type(p: &Clone); //~ ERROR uses type `dyn std::clone::Clone` | ^^^^^^ error: `extern` block uses type `(i32, i32)` which is not FFI-safe: tuples have unspecified layout - --> $DIR/lint-ctypes.rs:65:26 + --> $DIR/lint-ctypes.rs:63:26 | LL | pub fn tuple_type(p: (i32, i32)); //~ ERROR uses type `(i32, i32)` | ^^^^^^^^^^ @@ -88,7 +88,7 @@ LL | pub fn tuple_type(p: (i32, i32)); //~ ERROR uses type `(i32, i32)` = help: consider using a struct instead error: `extern` block uses type `(i32, i32)` which is not FFI-safe: tuples have unspecified layout - --> $DIR/lint-ctypes.rs:66:27 + --> $DIR/lint-ctypes.rs:64:27 | LL | pub fn tuple_type2(p: I32Pair); //~ ERROR uses type `(i32, i32)` | ^^^^^^^ @@ -96,32 +96,32 @@ LL | pub fn tuple_type2(p: I32Pair); //~ ERROR uses type `(i32, i32)` = help: consider using a struct instead error: `extern` block uses type `ZeroSize` which is not FFI-safe: this struct has no fields - --> $DIR/lint-ctypes.rs:67:25 + --> $DIR/lint-ctypes.rs:65:25 | LL | pub fn zero_size(p: ZeroSize); //~ ERROR struct has no fields | ^^^^^^^^ | = help: consider adding a member to this struct note: type defined here - --> $DIR/lint-ctypes.rs:30:1 + --> $DIR/lint-ctypes.rs:28:1 | LL | pub struct ZeroSize; | ^^^^^^^^^^^^^^^^^^^^ error: `extern` block uses type `ZeroSizeWithPhantomData` which is not FFI-safe: composed only of PhantomData - --> $DIR/lint-ctypes.rs:68:33 + --> $DIR/lint-ctypes.rs:66:33 | LL | pub fn zero_size_phantom(p: ZeroSizeWithPhantomData); //~ ERROR composed only of PhantomData | ^^^^^^^^^^^^^^^^^^^^^^^ error: `extern` block uses type `std::marker::PhantomData` which is not FFI-safe: composed only of PhantomData - --> $DIR/lint-ctypes.rs:70:12 + --> $DIR/lint-ctypes.rs:68:12 | LL | -> ::std::marker::PhantomData; //~ ERROR: composed only of PhantomData | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `extern` block uses type `fn()` which is not FFI-safe: this function pointer has Rust-specific calling convention - --> $DIR/lint-ctypes.rs:71:23 + --> $DIR/lint-ctypes.rs:69:23 | LL | pub fn fn_type(p: RustFn); //~ ERROR function pointer has Rust-specific | ^^^^^^ @@ -129,7 +129,7 @@ LL | pub fn fn_type(p: RustFn); //~ ERROR function pointer has Rust-specific = help: consider using an `extern fn(...) -> ...` function pointer instead error: `extern` block uses type `fn()` which is not FFI-safe: this function pointer has Rust-specific calling convention - --> $DIR/lint-ctypes.rs:72:24 + --> $DIR/lint-ctypes.rs:70:24 | LL | pub fn fn_type2(p: fn()); //~ ERROR function pointer has Rust-specific | ^^^^ @@ -137,7 +137,7 @@ LL | pub fn fn_type2(p: fn()); //~ ERROR function pointer has Rust-specific = help: consider using an `extern fn(...) -> ...` function pointer instead error: `extern` block uses type `std::boxed::Box` which is not FFI-safe: this struct has unspecified layout - --> $DIR/lint-ctypes.rs:73:28 + --> $DIR/lint-ctypes.rs:71:28 | LL | pub fn fn_contained(p: RustBadRet); //~ ERROR: uses type `std::boxed::Box` | ^^^^^^^^^^ @@ -145,13 +145,13 @@ LL | pub fn fn_contained(p: RustBadRet); //~ ERROR: uses type `std::boxed::B = help: consider adding a #[repr(C)] or #[repr(transparent)] attribute to this struct error: `extern` block uses type `i128` which is not FFI-safe: 128-bit integers don't currently have a known stable ABI - --> $DIR/lint-ctypes.rs:74:32 + --> $DIR/lint-ctypes.rs:72:32 | LL | pub fn transparent_i128(p: TransparentI128); //~ ERROR: uses type `i128` | ^^^^^^^^^^^^^^^ error: `extern` block uses type `str` which is not FFI-safe: string slices have no C equivalent - --> $DIR/lint-ctypes.rs:75:31 + --> $DIR/lint-ctypes.rs:73:31 | LL | pub fn transparent_str(p: TransparentStr); //~ ERROR: uses type `str` | ^^^^^^^^^^^^^^ @@ -159,7 +159,7 @@ LL | pub fn transparent_str(p: TransparentStr); //~ ERROR: uses type `str` = help: consider using `*const u8` and a length instead error: `extern` block uses type `std::boxed::Box` which is not FFI-safe: this struct has unspecified layout - --> $DIR/lint-ctypes.rs:76:30 + --> $DIR/lint-ctypes.rs:74:30 | LL | pub fn transparent_fn(p: TransparentBadFn); //~ ERROR: uses type `std::boxed::Box` | ^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/lint/lint-dead-code-1.rs b/src/test/ui/lint/lint-dead-code-1.rs index 2fe72365ba..944d57b5ba 100644 --- a/src/test/ui/lint/lint-dead-code-1.rs +++ b/src/test/ui/lint/lint-dead-code-1.rs @@ -109,6 +109,10 @@ fn bar() { //~ ERROR: function is never used foo(); } +fn baz() -> impl Copy { //~ ERROR: function is never used + "I'm unused, too" +} + // Code with #[allow(dead_code)] should be marked live (and thus anything it // calls is marked live) #[allow(dead_code)] diff --git a/src/test/ui/lint/lint-dead-code-1.stderr b/src/test/ui/lint/lint-dead-code-1.stderr index 9802b7e8f3..9d8e44c25d 100644 --- a/src/test/ui/lint/lint-dead-code-1.stderr +++ b/src/test/ui/lint/lint-dead-code-1.stderr @@ -58,5 +58,11 @@ error: function is never used: `bar` LL | fn bar() { //~ ERROR: function is never used | ^^^^^^^^ -error: aborting due to 9 previous errors +error: function is never used: `baz` + --> $DIR/lint-dead-code-1.rs:112:1 + | +LL | fn baz() -> impl Copy { //~ ERROR: function is never used + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 10 previous errors diff --git a/src/test/ui/macro_backtrace/main.stderr b/src/test/ui/macro_backtrace/main.stderr index 10eabca635..8cecef508a 100644 --- a/src/test/ui/macro_backtrace/main.stderr +++ b/src/test/ui/macro_backtrace/main.stderr @@ -22,7 +22,7 @@ LL | | } LL | ping!(); | -------- in this macro invocation | - ::: :1:1 + ::: <::ping::ping macros>:1:1 | LL | ( ) => { pong ! ( ) ; } | ------------------------- @@ -42,7 +42,7 @@ LL | | } LL | deep!(); | -------- in this macro invocation (#1) | - ::: :1:1 + ::: <::ping::deep macros>:1:1 | LL | ( ) => { foo ! ( ) ; } | ------------------------ @@ -50,7 +50,7 @@ LL | ( ) => { foo ! ( ) ; } | | in this macro invocation (#2) | in this expansion of `deep!` (#1) | - ::: :1:1 + ::: <::ping::foo macros>:1:1 | LL | ( ) => { bar ! ( ) ; } | ------------------------ @@ -58,7 +58,7 @@ LL | ( ) => { bar ! ( ) ; } | | in this macro invocation (#3) | in this expansion of `foo!` (#2) | - ::: :1:1 + ::: <::ping::bar macros>:1:1 | LL | ( ) => { ping ! ( ) ; } | ------------------------- @@ -66,7 +66,7 @@ LL | ( ) => { ping ! ( ) ; } | | in this macro invocation (#4) | in this expansion of `bar!` (#3) | - ::: :1:1 + ::: <::ping::ping macros>:1:1 | LL | ( ) => { pong ! ( ) ; } | ------------------------- diff --git a/src/test/ui/macros/ambiguity-legacy-vs-modern.rs b/src/test/ui/macros/ambiguity-legacy-vs-modern.rs new file mode 100644 index 0000000000..216b9dd052 --- /dev/null +++ b/src/test/ui/macros/ambiguity-legacy-vs-modern.rs @@ -0,0 +1,46 @@ +// Some non-controversial subset of ambiguities "modern macro name" vs "macro_rules" +// is disambiguated to mitigate regressions from macro modularization. +// Scoping for `macro_rules` behaves like scoping for `let` at module level, in general. + +#![feature(decl_macro)] + +fn same_unnamed_mod() { + macro m() { 0 } + + macro_rules! m { () => (()) } + + m!() // OK +} + +fn nested_unnamed_mod() { + macro m() { 0 } + + { + macro_rules! m { () => (()) } + + m!() // OK + } +} + +fn nested_unnamed_mod_fail() { + macro_rules! m { () => (()) } + + { + macro m() { 0 } + + m!() //~ ERROR `m` is ambiguous + } +} + +fn nexted_named_mod_fail() { + macro m() { 0 } + + #[macro_use] + mod inner { + macro_rules! m { () => (()) } + } + + m!() //~ ERROR `m` is ambiguous +} + +fn main() {} diff --git a/src/test/ui/macros/ambiguity-legacy-vs-modern.stderr b/src/test/ui/macros/ambiguity-legacy-vs-modern.stderr new file mode 100644 index 0000000000..b5e1e75173 --- /dev/null +++ b/src/test/ui/macros/ambiguity-legacy-vs-modern.stderr @@ -0,0 +1,37 @@ +error[E0659]: `m` is ambiguous + --> $DIR/ambiguity-legacy-vs-modern.rs:31:9 + | +LL | m!() //~ ERROR `m` is ambiguous + | ^ ambiguous name + | +note: `m` could refer to the name defined here + --> $DIR/ambiguity-legacy-vs-modern.rs:26:5 + | +LL | macro_rules! m { () => (()) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: `m` could also refer to the name defined here + --> $DIR/ambiguity-legacy-vs-modern.rs:29:9 + | +LL | macro m() { 0 } + | ^^^^^^^^^^^^^^^ + +error[E0659]: `m` is ambiguous + --> $DIR/ambiguity-legacy-vs-modern.rs:43:5 + | +LL | m!() //~ ERROR `m` is ambiguous + | ^ ambiguous name + | +note: `m` could refer to the name defined here + --> $DIR/ambiguity-legacy-vs-modern.rs:40:9 + | +LL | macro_rules! m { () => (()) } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: `m` could also refer to the name defined here + --> $DIR/ambiguity-legacy-vs-modern.rs:36:5 + | +LL | macro m() { 0 } + | ^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0659`. diff --git a/src/test/ui/no_owned_box_lang_item.rs b/src/test/ui/no_owned_box_lang_item.rs index 34d1075f9b..1c2bf1573d 100644 --- a/src/test/ui/no_owned_box_lang_item.rs +++ b/src/test/ui/no_owned_box_lang_item.rs @@ -15,12 +15,10 @@ #![feature(lang_items, box_syntax)] #![no_std] -use core::panic::PanicInfo; - fn main() { let x = box 1i32; } #[lang = "eh_personality"] extern fn eh_personality() {} #[lang = "eh_unwind_resume"] extern fn eh_unwind_resume() {} -#[lang = "panic_impl"] fn panic_impl(panic: &PanicInfo) -> ! { loop {} } +#[lang = "panic_impl"] fn panic_impl() -> ! { loop {} } diff --git a/src/test/ui/non_modrs_mods/non_modrs_mods.rs b/src/test/ui/non_modrs_mods/non_modrs_mods.rs new file mode 100644 index 0000000000..9dc85f4d3f --- /dev/null +++ b/src/test/ui/non_modrs_mods/non_modrs_mods.rs @@ -0,0 +1,28 @@ +// 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. +// +// Tests the formatting of the feature-gate errors for non_modrs_mods +// +// gate-test-non_modrs_mods +// ignore-windows +// ignore-pretty issue #37195 +pub mod modrs_mod; +pub mod foors_mod; + +#[path = "some_crazy_attr_mod_dir/arbitrary_name.rs"] +pub mod attr_mod; + +pub fn main() { + modrs_mod::inner_modrs_mod::innest::foo(); + modrs_mod::inner_foors_mod::innest::foo(); + foors_mod::inner_modrs_mod::innest::foo(); + foors_mod::inner_foors_mod::innest::foo(); + attr_mod::inner_modrs_mod::innest::foo(); +} diff --git a/src/test/ui/non_modrs_mods/non_modrs_mods.stderr b/src/test/ui/non_modrs_mods/non_modrs_mods.stderr new file mode 100644 index 0000000000..c45ab734fd --- /dev/null +++ b/src/test/ui/non_modrs_mods/non_modrs_mods.stderr @@ -0,0 +1,39 @@ +error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660) + --> $DIR/modrs_mod/inner_foors_mod.rs:11:9 + | +LL | pub mod innest; + | ^^^^^^ + | + = help: add #![feature(non_modrs_mods)] to the crate attributes to enable + = help: on stable builds, rename this file to inner_foors_mod/mod.rs + +error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660) + --> $DIR/foors_mod.rs:13:9 + | +LL | pub mod inner_modrs_mod; + | ^^^^^^^^^^^^^^^ + | + = help: add #![feature(non_modrs_mods)] to the crate attributes to enable + = help: on stable builds, rename this file to foors_mod/mod.rs + +error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660) + --> $DIR/foors_mod.rs:14:9 + | +LL | pub mod inner_foors_mod; + | ^^^^^^^^^^^^^^^ + | + = help: add #![feature(non_modrs_mods)] to the crate attributes to enable + = help: on stable builds, rename this file to foors_mod/mod.rs + +error[E0658]: mod statements in non-mod.rs files are unstable (see issue #44660) + --> $DIR/foors_mod/inner_foors_mod.rs:11:9 + | +LL | pub mod innest; + | ^^^^^^ + | + = help: add #![feature(non_modrs_mods)] to the crate attributes to enable + = help: on stable builds, rename this file to inner_foors_mod/mod.rs + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/src/test/ui/regions/regions-enum-not-wf.rs b/src/test/ui/regions/regions-enum-not-wf.rs index a2d3cf6779..e21f92bc9b 100644 --- a/src/test/ui/regions/regions-enum-not-wf.rs +++ b/src/test/ui/regions/regions-enum-not-wf.rs @@ -8,43 +8,31 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// ignore-tidy-linelength - // Various examples of structs whose fields are not well-formed. #![allow(dead_code)] -trait Dummy<'a> { - type Out; -} -impl<'a, T> Dummy<'a> for T -where T: 'a -{ - type Out = (); -} -type RequireOutlives<'a, T> = >::Out; - enum Ref1<'a, T> { - Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough + Ref1Variant1(&'a T) //~ ERROR the parameter type `T` may not live long enough } enum Ref2<'a, T> { Ref2Variant1, - Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough + Ref2Variant2(isize, &'a T), //~ ERROR the parameter type `T` may not live long enough } enum RefOk<'a, T:'a> { RefOkVariant1(&'a T) } -// This is now well formed. RFC 2093 enum RefIndirect<'a, T> { RefIndirectVariant1(isize, RefOk<'a,T>) + //~^ ERROR the parameter type `T` may not live long enough } -enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] - RefDoubleVariant1(&'a RequireOutlives<'b, T>) - //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309] +enum RefDouble<'a, 'b, T> { + RefDoubleVariant1(&'a &'b T) + //~^ ERROR reference has a longer lifetime than the data } fn main() { } diff --git a/src/test/ui/regions/regions-enum-not-wf.stderr b/src/test/ui/regions/regions-enum-not-wf.stderr index 923ea17622..381a8aada5 100644 --- a/src/test/ui/regions/regions-enum-not-wf.stderr +++ b/src/test/ui/regions/regions-enum-not-wf.stderr @@ -1,67 +1,64 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-enum-not-wf.rs:28:18 + --> $DIR/regions-enum-not-wf.rs:16:18 | LL | enum Ref1<'a, T> { | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | Ref1Variant1(&'a T) //~ ERROR the parameter type `T` may not live long enough + | ^^^^^ | -note: ...so that the type `T` will meet its required lifetime bounds - --> $DIR/regions-enum-not-wf.rs:28:18 +note: ...so that the reference type `&'a T` does not outlive the data it points at + --> $DIR/regions-enum-not-wf.rs:16:18 | -LL | Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | Ref1Variant1(&'a T) //~ ERROR the parameter type `T` may not live long enough + | ^^^^^ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-enum-not-wf.rs:33:25 + --> $DIR/regions-enum-not-wf.rs:21:25 | LL | enum Ref2<'a, T> { | - help: consider adding an explicit lifetime bound `T: 'a`... LL | Ref2Variant1, -LL | Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | Ref2Variant2(isize, &'a T), //~ ERROR the parameter type `T` may not live long enough + | ^^^^^ | -note: ...so that the type `T` will meet its required lifetime bounds - --> $DIR/regions-enum-not-wf.rs:33:25 +note: ...so that the reference type `&'a T` does not outlive the data it points at + --> $DIR/regions-enum-not-wf.rs:21:25 | -LL | Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | Ref2Variant2(isize, &'a T), //~ ERROR the parameter type `T` may not live long enough + | ^^^^^ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-enum-not-wf.rs:45:1 + --> $DIR/regions-enum-not-wf.rs:29:32 | -LL | enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] - | ^ - help: consider adding an explicit lifetime bound `T: 'b`... - | _| - | | -LL | | RefDoubleVariant1(&'a RequireOutlives<'b, T>) -LL | | //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309] -LL | | } - | |_^ +LL | enum RefIndirect<'a, T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | RefIndirectVariant1(isize, RefOk<'a,T>) + | ^^^^^^^^^^^ | note: ...so that the type `T` will meet its required lifetime bounds - --> $DIR/regions-enum-not-wf.rs:45:1 + --> $DIR/regions-enum-not-wf.rs:29:32 | -LL | / enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] -LL | | RefDoubleVariant1(&'a RequireOutlives<'b, T>) -LL | | //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309] -LL | | } - | |_^ +LL | RefIndirectVariant1(isize, RefOk<'a,T>) + | ^^^^^^^^^^^ -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-enum-not-wf.rs:46:23 +error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references + --> $DIR/regions-enum-not-wf.rs:34:23 | -LL | enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] - | - help: consider adding an explicit lifetime bound `T: 'b`... -LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | RefDoubleVariant1(&'a &'b T) + | ^^^^^^^^^ | -note: ...so that the type `T` will meet its required lifetime bounds - --> $DIR/regions-enum-not-wf.rs:46:23 +note: the pointer is valid for the lifetime 'a as defined on the enum at 33:16 + --> $DIR/regions-enum-not-wf.rs:33:16 | -LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | enum RefDouble<'a, 'b, T> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 33:20 + --> $DIR/regions-enum-not-wf.rs:33:20 + | +LL | enum RefDouble<'a, 'b, T> { + | ^^ error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0309`. +Some errors occurred: E0309, E0491. +For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.rs b/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.rs index 7a2be8c0d9..db25a0698f 100644 --- a/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.rs +++ b/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.rs @@ -13,8 +13,6 @@ // // Rule OutlivesNominalType from RFC 1214. -// compile-pass - #![feature(rustc_attrs)] #![allow(dead_code)] @@ -23,8 +21,9 @@ mod rev_variant_struct_region { x: fn(&'a i32), } enum Bar<'a,'b> { - V(&'a Foo<'b>) + V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime } } +#[rustc_error] fn main() { } diff --git a/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.stderr b/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.stderr new file mode 100644 index 0000000000..5084097e30 --- /dev/null +++ b/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a rev_variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-enum-region-rev.rs:24:11 + | +LL | V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the enum at 23:14 + --> $DIR/regions-outlives-nominal-type-enum-region-rev.rs:23:14 + | +LL | enum Bar<'a,'b> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 23:17 + --> $DIR/regions-outlives-nominal-type-enum-region-rev.rs:23:17 + | +LL | enum Bar<'a,'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-outlives-nominal-type-enum-region.rs b/src/test/ui/regions/regions-outlives-nominal-type-enum-region.rs index 07127263bf..403757042d 100644 --- a/src/test/ui/regions/regions-outlives-nominal-type-enum-region.rs +++ b/src/test/ui/regions/regions-outlives-nominal-type-enum-region.rs @@ -13,8 +13,6 @@ // // Rule OutlivesNominalType from RFC 1214. -// compile-pass - #![feature(rustc_attrs)] #![allow(dead_code)] @@ -23,8 +21,9 @@ mod variant_struct_region { x: &'a i32, } enum Bar<'a,'b> { - V(&'a Foo<'b>) + V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime } } +#[rustc_error] fn main() { } diff --git a/src/test/ui/regions/regions-outlives-nominal-type-enum-region.stderr b/src/test/ui/regions/regions-outlives-nominal-type-enum-region.stderr new file mode 100644 index 0000000000..ce187eddfa --- /dev/null +++ b/src/test/ui/regions/regions-outlives-nominal-type-enum-region.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-enum-region.rs:24:11 + | +LL | V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the enum at 23:14 + --> $DIR/regions-outlives-nominal-type-enum-region.rs:23:14 + | +LL | enum Bar<'a,'b> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 23:17 + --> $DIR/regions-outlives-nominal-type-enum-region.rs:23:17 + | +LL | enum Bar<'a,'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.rs b/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.rs index 4941b568fc..cc294651db 100644 --- a/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.rs +++ b/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.rs @@ -13,18 +13,17 @@ // // Rule OutlivesNominalType from RFC 1214. -//compile-pass - #![feature(rustc_attrs)] #![allow(dead_code)] -mod variant_struct_type { +mod rev_variant_struct_type { struct Foo { x: fn(T) } enum Bar<'a,'b> { - V(&'a Foo<&'b i32>) + V(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime } } +#[rustc_error] fn main() { } diff --git a/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.stderr b/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.stderr new file mode 100644 index 0000000000..8636b89b71 --- /dev/null +++ b/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a rev_variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-enum-type-rev.rs:24:11 + | +LL | V(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the enum at 23:14 + --> $DIR/regions-outlives-nominal-type-enum-type-rev.rs:23:14 + | +LL | enum Bar<'a,'b> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 23:17 + --> $DIR/regions-outlives-nominal-type-enum-type-rev.rs:23:17 + | +LL | enum Bar<'a,'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-outlives-nominal-type-enum-type.rs b/src/test/ui/regions/regions-outlives-nominal-type-enum-type.rs index 38eb0c97a4..e269767cc1 100644 --- a/src/test/ui/regions/regions-outlives-nominal-type-enum-type.rs +++ b/src/test/ui/regions/regions-outlives-nominal-type-enum-type.rs @@ -13,8 +13,6 @@ // // Rule OutlivesNominalType from RFC 1214. -// compile-pass - #![feature(rustc_attrs)] #![allow(dead_code)] @@ -23,8 +21,9 @@ mod variant_struct_type { x: T } enum Bar<'a,'b> { - V(&'a Foo<&'b i32>) + F(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime } } +#[rustc_error] fn main() { } diff --git a/src/test/ui/regions/regions-outlives-nominal-type-enum-type.stderr b/src/test/ui/regions/regions-outlives-nominal-type-enum-type.stderr new file mode 100644 index 0000000000..c209547e20 --- /dev/null +++ b/src/test/ui/regions/regions-outlives-nominal-type-enum-type.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-enum-type.rs:24:11 + | +LL | F(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the enum at 23:14 + --> $DIR/regions-outlives-nominal-type-enum-type.rs:23:14 + | +LL | enum Bar<'a,'b> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 23:17 + --> $DIR/regions-outlives-nominal-type-enum-type.rs:23:17 + | +LL | enum Bar<'a,'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.rs b/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.rs index 50febdd457..c7e6ace8b9 100644 --- a/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.rs +++ b/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.rs @@ -13,8 +13,6 @@ // // Rule OutlivesNominalType from RFC 1214. -// compile-pass - #![feature(rustc_attrs)] #![allow(dead_code)] @@ -23,8 +21,9 @@ mod rev_variant_struct_region { x: fn(&'a i32), } struct Bar<'a,'b> { - f: &'a Foo<'b> + f: &'a Foo<'b> //~ ERROR reference has a longer lifetime } } +#[rustc_error] fn main() { } diff --git a/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.stderr b/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.stderr new file mode 100644 index 0000000000..48980bdf83 --- /dev/null +++ b/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a rev_variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-struct-region-rev.rs:24:9 + | +LL | f: &'a Foo<'b> //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the struct at 23:16 + --> $DIR/regions-outlives-nominal-type-struct-region-rev.rs:23:16 + | +LL | struct Bar<'a,'b> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 23:19 + --> $DIR/regions-outlives-nominal-type-struct-region-rev.rs:23:19 + | +LL | struct Bar<'a,'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-outlives-nominal-type-struct-region.rs b/src/test/ui/regions/regions-outlives-nominal-type-struct-region.rs index ea07fb4104..2fe6444c33 100644 --- a/src/test/ui/regions/regions-outlives-nominal-type-struct-region.rs +++ b/src/test/ui/regions/regions-outlives-nominal-type-struct-region.rs @@ -13,8 +13,6 @@ // // Rule OutlivesNominalType from RFC 1214. -// compile-pass - #![feature(rustc_attrs)] #![allow(dead_code)] @@ -27,4 +25,5 @@ mod variant_struct_region { } } +#[rustc_error] fn main() { } diff --git a/src/test/ui/regions/regions-outlives-nominal-type-struct-region.stderr b/src/test/ui/regions/regions-outlives-nominal-type-struct-region.stderr new file mode 100644 index 0000000000..e2b328886b --- /dev/null +++ b/src/test/ui/regions/regions-outlives-nominal-type-struct-region.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-struct-region.rs:24:9 + | +LL | f: &'a Foo<'b> //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the struct at 23:16 + --> $DIR/regions-outlives-nominal-type-struct-region.rs:23:16 + | +LL | struct Bar<'a,'b> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 23:19 + --> $DIR/regions-outlives-nominal-type-struct-region.rs:23:19 + | +LL | struct Bar<'a,'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.rs b/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.rs index 735037ac2f..c4b631bce9 100644 --- a/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.rs +++ b/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.rs @@ -13,8 +13,6 @@ // // Rule OutlivesNominalType from RFC 1214. -// compile-pass - #![feature(rustc_attrs)] #![allow(dead_code)] @@ -27,4 +25,5 @@ mod rev_variant_struct_type { } } +#[rustc_error] fn main() { } diff --git a/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.stderr b/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.stderr new file mode 100644 index 0000000000..2bf04ffa64 --- /dev/null +++ b/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a rev_variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-struct-type-rev.rs:24:9 + | +LL | f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the struct at 23:16 + --> $DIR/regions-outlives-nominal-type-struct-type-rev.rs:23:16 + | +LL | struct Bar<'a,'b> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 23:19 + --> $DIR/regions-outlives-nominal-type-struct-type-rev.rs:23:19 + | +LL | struct Bar<'a,'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-outlives-nominal-type-struct-type.rs b/src/test/ui/regions/regions-outlives-nominal-type-struct-type.rs index dfd3583ce6..1c9489444a 100644 --- a/src/test/ui/regions/regions-outlives-nominal-type-struct-type.rs +++ b/src/test/ui/regions/regions-outlives-nominal-type-struct-type.rs @@ -13,8 +13,6 @@ // // Rule OutlivesNominalType from RFC 1214. -// compile-pass - #![feature(rustc_attrs)] #![allow(dead_code)] @@ -27,4 +25,5 @@ mod variant_struct_type { } } +#[rustc_error] fn main() { } diff --git a/src/test/ui/regions/regions-outlives-nominal-type-struct-type.stderr b/src/test/ui/regions/regions-outlives-nominal-type-struct-type.stderr new file mode 100644 index 0000000000..af9f1d3722 --- /dev/null +++ b/src/test/ui/regions/regions-outlives-nominal-type-struct-type.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-struct-type.rs:24:9 + | +LL | f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the struct at 23:16 + --> $DIR/regions-outlives-nominal-type-struct-type.rs:23:16 + | +LL | struct Bar<'a,'b> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 23:19 + --> $DIR/regions-outlives-nominal-type-struct-type.rs:23:19 + | +LL | struct Bar<'a,'b> { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-struct-not-wf.lexical.stderr b/src/test/ui/regions/regions-struct-not-wf.lexical.stderr new file mode 100644 index 0000000000..9433b8b195 --- /dev/null +++ b/src/test/ui/regions/regions-struct-not-wf.lexical.stderr @@ -0,0 +1,49 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-struct-not-wf.rs:19:5 + | +LL | struct Ref<'a, T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | field: &'a T + | ^^^^^^^^^^^^ + | +note: ...so that the reference type `&'a T` does not outlive the data it points at + --> $DIR/regions-struct-not-wf.rs:19:5 + | +LL | field: &'a T + | ^^^^^^^^^^^^ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-struct-not-wf.rs:29:5 + | +LL | struct RefIndirect<'a, T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | field: RefOk<'a, T> + | ^^^^^^^^^^^^^^^^^^^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-struct-not-wf.rs:29:5 + | +LL | field: RefOk<'a, T> + | ^^^^^^^^^^^^^^^^^^^ + +error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references + --> $DIR/regions-struct-not-wf.rs:35:5 + | +LL | field: &'a &'b T + | ^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the struct at 34:18 + --> $DIR/regions-struct-not-wf.rs:34:18 + | +LL | struct DoubleRef<'a, 'b, T> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 34:22 + --> $DIR/regions-struct-not-wf.rs:34:22 + | +LL | struct DoubleRef<'a, 'b, T> { + | ^^ + +error: aborting due to 3 previous errors + +Some errors occurred: E0309, E0491. +For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/regions/regions-struct-not-wf.nll.stderr b/src/test/ui/regions/regions-struct-not-wf.nll.stderr new file mode 100644 index 0000000000..9433b8b195 --- /dev/null +++ b/src/test/ui/regions/regions-struct-not-wf.nll.stderr @@ -0,0 +1,49 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-struct-not-wf.rs:19:5 + | +LL | struct Ref<'a, T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | field: &'a T + | ^^^^^^^^^^^^ + | +note: ...so that the reference type `&'a T` does not outlive the data it points at + --> $DIR/regions-struct-not-wf.rs:19:5 + | +LL | field: &'a T + | ^^^^^^^^^^^^ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-struct-not-wf.rs:29:5 + | +LL | struct RefIndirect<'a, T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | field: RefOk<'a, T> + | ^^^^^^^^^^^^^^^^^^^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-struct-not-wf.rs:29:5 + | +LL | field: RefOk<'a, T> + | ^^^^^^^^^^^^^^^^^^^ + +error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references + --> $DIR/regions-struct-not-wf.rs:35:5 + | +LL | field: &'a &'b T + | ^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the struct at 34:18 + --> $DIR/regions-struct-not-wf.rs:34:18 + | +LL | struct DoubleRef<'a, 'b, T> { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 34:22 + --> $DIR/regions-struct-not-wf.rs:34:22 + | +LL | struct DoubleRef<'a, 'b, T> { + | ^^ + +error: aborting due to 3 previous errors + +Some errors occurred: E0309, E0491. +For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/regions/regions-struct-not-wf.rs b/src/test/ui/regions/regions-struct-not-wf.rs index bdd708197b..9106f1f0ba 100644 --- a/src/test/ui/regions/regions-struct-not-wf.rs +++ b/src/test/ui/regions/regions-struct-not-wf.rs @@ -10,29 +10,31 @@ // Various examples of structs whose fields are not well-formed. +// revisions:lexical nll + #![allow(dead_code)] +#![cfg_attr(nll, feature(nll))] -trait Trait<'a, T> { - type Out; -} -trait Trait1<'a, 'b, T> { - type Out; -} - -impl<'a, T> Trait<'a, T> for usize { - type Out = &'a T; +struct Ref<'a, T> { + field: &'a T + //[lexical]~^ ERROR the parameter type `T` may not live long enough + //[nll]~^^ ERROR the parameter type `T` may not live long enough } struct RefOk<'a, T:'a> { field: &'a T } -impl<'a, T> Trait<'a, T> for u32 { - type Out = RefOk<'a, T>; +struct RefIndirect<'a, T> { + field: RefOk<'a, T> + //[lexical]~^ ERROR the parameter type `T` may not live long enough + //[nll]~^^ ERROR the parameter type `T` may not live long enough } -impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { - type Out = &'a &'b T; +struct DoubleRef<'a, 'b, T> { + field: &'a &'b T + //[lexical]~^ ERROR reference has a longer lifetime than the data it references + //[nll]~^^ ERROR reference has a longer lifetime than the data it references } fn main() { } diff --git a/src/test/ui/regions/regions-struct-not-wf.stderr b/src/test/ui/regions/regions-struct-not-wf.stderr deleted file mode 100644 index d8c8b6c3cc..0000000000 --- a/src/test/ui/regions/regions-struct-not-wf.stderr +++ /dev/null @@ -1,49 +0,0 @@ -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-struct-not-wf.rs:23:5 - | -LL | impl<'a, T> Trait<'a, T> for usize { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | type Out = &'a T; - | ^^^^^^^^^^^^^^^^^ - | -note: ...so that the reference type `&'a T` does not outlive the data it points at - --> $DIR/regions-struct-not-wf.rs:23:5 - | -LL | type Out = &'a T; - | ^^^^^^^^^^^^^^^^^ - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-struct-not-wf.rs:31:5 - | -LL | impl<'a, T> Trait<'a, T> for u32 { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | type Out = RefOk<'a, T>; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: ...so that the type `T` will meet its required lifetime bounds - --> $DIR/regions-struct-not-wf.rs:31:5 - | -LL | type Out = RefOk<'a, T>; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references - --> $DIR/regions-struct-not-wf.rs:35:5 - | -LL | type Out = &'a &'b T; - | ^^^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the impl at 34:6 - --> $DIR/regions-struct-not-wf.rs:34:6 - | -LL | impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the impl at 34:10 - --> $DIR/regions-struct-not-wf.rs:34:10 - | -LL | impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { - | ^^ - -error: aborting due to 3 previous errors - -Some errors occurred: E0309, E0491. -For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/rfc-2093-infer-outlives/cross-crate.rs b/src/test/ui/rfc-2093-infer-outlives/cross-crate.rs index cc659cd14b..0167399788 100644 --- a/src/test/ui/rfc-2093-infer-outlives/cross-crate.rs +++ b/src/test/ui/rfc-2093-infer-outlives/cross-crate.rs @@ -9,9 +9,10 @@ // except according to those terms. #![feature(rustc_attrs)] +#![feature(infer_outlives_requirements)] #[rustc_outlives] -struct Foo<'a, T> { //~ ERROR 14:1: 16:2: rustc_outlives +struct Foo<'a, T> { //~ ERROR 15:1: 17:2: rustc_outlives bar: std::slice::IterMut<'a, T> } diff --git a/src/test/ui/rfc-2093-infer-outlives/cross-crate.stderr b/src/test/ui/rfc-2093-infer-outlives/cross-crate.stderr index dd00c14ea1..a90643ae89 100644 --- a/src/test/ui/rfc-2093-infer-outlives/cross-crate.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/cross-crate.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/cross-crate.rs:14:1 + --> $DIR/cross-crate.rs:15:1 | -LL | / struct Foo<'a, T> { //~ ERROR 14:1: 16:2: rustc_outlives +LL | / struct Foo<'a, T> { //~ ERROR 15:1: 17:2: rustc_outlives LL | | bar: std::slice::IterMut<'a, T> LL | | } | |_^ diff --git a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs index 47dc5dfdc9..72d5127c29 100644 --- a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs +++ b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs @@ -10,6 +10,8 @@ // ignore-tidy-linelength +#![feature(infer_outlives_requirements)] + /* * We don't infer `T: 'static` outlives relationships by default. * Instead an additional feature gate `infer_static_outlives_requirements` @@ -17,7 +19,7 @@ */ struct Foo { - bar: Bar //~ ERROR 20:5: 20:16: the parameter type `U` may not live long enough [E0310] + bar: Bar //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310] } struct Bar { x: T, diff --git a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr index 5d8cf0aa32..775ac215e1 100644 --- a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr @@ -1,15 +1,15 @@ error[E0310]: the parameter type `U` may not live long enough - --> $DIR/dont-infer-static.rs:20:5 + --> $DIR/dont-infer-static.rs:22:5 | LL | struct Foo { | - help: consider adding an explicit lifetime bound `U: 'static`... -LL | bar: Bar //~ ERROR 20:5: 20:16: the parameter type `U` may not live long enough [E0310] +LL | bar: Bar //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310] | ^^^^^^^^^^^ | note: ...so that the type `U` will meet its required lifetime bounds - --> $DIR/dont-infer-static.rs:20:5 + --> $DIR/dont-infer-static.rs:22:5 | -LL | bar: Bar //~ ERROR 20:5: 20:16: the parameter type `U` may not live long enough [E0310] +LL | bar: Bar //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310] | ^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/rfc-2093-infer-outlives/enum.rs b/src/test/ui/rfc-2093-infer-outlives/enum.rs index b2c18b274c..5071465b5f 100644 --- a/src/test/ui/rfc-2093-infer-outlives/enum.rs +++ b/src/test/ui/rfc-2093-infer-outlives/enum.rs @@ -10,26 +10,24 @@ // ignore-tidy-linelength -#![feature(rustc_attrs)] - // Needs an explicit where clause stating outlives condition. (RFC 2093) // Type T needs to outlive lifetime 'a. -#[rustc_outlives] -enum Foo<'a, T> { //~ ERROR rustc_outlives +enum Foo<'a, T> { + One(Bar<'a, T>) } // Type U needs to outlive lifetime 'b -#[rustc_outlives] -struct Bar<'b, U> { //~ ERROR rustc_outlives - field2: &'b U +struct Bar<'b, U> { + field2: &'b U //~ ERROR the parameter type `U` may not live long enough [E0309] } + + // Type K needs to outlive lifetime 'c. -#[rustc_outlives] -enum Ying<'c, K> { //~ ERROR rustc_outlives - One(&'c Yang) +enum Ying<'c, K> { + One(&'c Yang) //~ ERROR the parameter type `K` may not live long enough [E0309] } struct Yang { diff --git a/src/test/ui/rfc-2093-infer-outlives/enum.stderr b/src/test/ui/rfc-2093-infer-outlives/enum.stderr index e621c435ee..604dd0b43c 100644 --- a/src/test/ui/rfc-2093-infer-outlives/enum.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/enum.stderr @@ -1,32 +1,31 @@ -error: rustc_outlives - --> $DIR/enum.rs:19:1 +error[E0309]: the parameter type `U` may not live long enough + --> $DIR/enum.rs:23:5 | -LL | / enum Foo<'a, T> { //~ ERROR rustc_outlives -LL | | One(Bar<'a, T>) -LL | | } - | |_^ +LL | struct Bar<'b, U> { + | - help: consider adding an explicit lifetime bound `U: 'b`... +LL | field2: &'b U //~ ERROR the parameter type `U` may not live long enough [E0309] + | ^^^^^^^^^^^^^ | - = note: T : 'a +note: ...so that the reference type `&'b U` does not outlive the data it points at + --> $DIR/enum.rs:23:5 + | +LL | field2: &'b U //~ ERROR the parameter type `U` may not live long enough [E0309] + | ^^^^^^^^^^^^^ -error: rustc_outlives - --> $DIR/enum.rs:25:1 +error[E0309]: the parameter type `K` may not live long enough + --> $DIR/enum.rs:30:9 | -LL | / struct Bar<'b, U> { //~ ERROR rustc_outlives -LL | | field2: &'b U -LL | | } - | |_^ +LL | enum Ying<'c, K> { + | - help: consider adding an explicit lifetime bound `K: 'c`... +LL | One(&'c Yang) //~ ERROR the parameter type `K` may not live long enough [E0309] + | ^^^^^^^^^^^ | - = note: U : 'b +note: ...so that the reference type `&'c Yang` does not outlive the data it points at + --> $DIR/enum.rs:30:9 + | +LL | One(&'c Yang) //~ ERROR the parameter type `K` may not live long enough [E0309] + | ^^^^^^^^^^^ -error: rustc_outlives - --> $DIR/enum.rs:31:1 - | -LL | / enum Ying<'c, K> { //~ ERROR rustc_outlives -LL | | One(&'c Yang) -LL | | } - | |_^ - | - = note: K : 'c - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.rs b/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.rs index 9264259520..445c246a12 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.rs +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.rs @@ -10,12 +10,13 @@ #![feature(dyn_trait)] #![feature(rustc_attrs)] +#![feature(infer_outlives_requirements)] trait Trait<'x, T> where T: 'x { } #[rustc_outlives] -struct Foo<'a, A> //~ ERROR 18:1: 21:2: rustc_outlives +struct Foo<'a, A> //~ ERROR 19:1: 22:2: rustc_outlives { foo: Box> } diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.stderr b/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.stderr index 5d16749330..4bb5d90e96 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/explicit-dyn.rs:18:1 + --> $DIR/explicit-dyn.rs:19:1 | -LL | / struct Foo<'a, A> //~ ERROR 18:1: 21:2: rustc_outlives +LL | / struct Foo<'a, A> //~ ERROR 19:1: 22:2: rustc_outlives LL | | { LL | | foo: Box> LL | | } diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-enum.rs b/src/test/ui/rfc-2093-infer-outlives/explicit-enum.rs index 0ac75fc255..e85b49bb0b 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-enum.rs +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-enum.rs @@ -9,9 +9,10 @@ // except according to those terms. #![feature(rustc_attrs)] +#![feature(infer_outlives_requirements)] #[rustc_outlives] -enum Foo<'a, U> { //~ ERROR 14:1: 16:2: rustc_outlives +enum Foo<'a, U> { //~ ERROR 15:1: 17:2: rustc_outlives One(Bar<'a, U>) } diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-enum.stderr b/src/test/ui/rfc-2093-infer-outlives/explicit-enum.stderr index 33ef4b7e6a..d7438758d7 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-enum.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-enum.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/explicit-enum.rs:14:1 + --> $DIR/explicit-enum.rs:15:1 | -LL | / enum Foo<'a, U> { //~ ERROR 14:1: 16:2: rustc_outlives +LL | / enum Foo<'a, U> { //~ ERROR 15:1: 17:2: rustc_outlives LL | | One(Bar<'a, U>) LL | | } | |_^ diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-projection.rs b/src/test/ui/rfc-2093-infer-outlives/explicit-projection.rs index 02c171627e..2662043c36 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-projection.rs +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-projection.rs @@ -9,6 +9,7 @@ // except according to those terms. #![feature(rustc_attrs)] +#![feature(infer_outlives_requirements)] trait Trait<'x, T> where T: 'x { type Type; diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-projection.stderr b/src/test/ui/rfc-2093-infer-outlives/explicit-projection.stderr index 5480130c2d..43ab02d01e 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-projection.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-projection.stderr @@ -1,5 +1,5 @@ error: rustc_outlives - --> $DIR/explicit-projection.rs:18:1 + --> $DIR/explicit-projection.rs:19:1 | LL | / struct Foo<'a, A, B> where A: Trait<'a, B> //~ ERROR rustc_outlives LL | | { diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-struct.rs b/src/test/ui/rfc-2093-infer-outlives/explicit-struct.rs index 4dc01a5221..d42c9160e1 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-struct.rs +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-struct.rs @@ -9,9 +9,10 @@ // except according to those terms. #![feature(rustc_attrs)] +#![feature(infer_outlives_requirements)] #[rustc_outlives] -struct Foo<'b, U> { //~ ERROR 14:1: 16:2: rustc_outlives +struct Foo<'b, U> { //~ ERROR 15:1: 17:2: rustc_outlives bar: Bar<'b, U> } diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-struct.stderr b/src/test/ui/rfc-2093-infer-outlives/explicit-struct.stderr index 7655dec5cb..0223f707e8 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-struct.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-struct.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/explicit-struct.rs:14:1 + --> $DIR/explicit-struct.rs:15:1 | -LL | / struct Foo<'b, U> { //~ ERROR 14:1: 16:2: rustc_outlives +LL | / struct Foo<'b, U> { //~ ERROR 15:1: 17:2: rustc_outlives LL | | bar: Bar<'b, U> LL | | } | |_^ diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-union.rs b/src/test/ui/rfc-2093-infer-outlives/explicit-union.rs index ae4b9b15f6..e548b24719 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-union.rs +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-union.rs @@ -9,11 +9,13 @@ // except according to those terms. #![feature(rustc_attrs)] +#![feature(infer_outlives_requirements)] #![feature(untagged_unions)] #![allow(unions_with_drop_fields)] + #[rustc_outlives] -union Foo<'b, U> { //~ ERROR 16:1: 18:2: rustc_outlives +union Foo<'b, U> { //~ ERROR 18:1: 20:2: rustc_outlives bar: Bar<'b, U> } diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-union.stderr b/src/test/ui/rfc-2093-infer-outlives/explicit-union.stderr index c01c7532c8..8622ae12aa 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-union.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-union.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/explicit-union.rs:16:1 + --> $DIR/explicit-union.rs:18:1 | -LL | / union Foo<'b, U> { //~ ERROR 16:1: 18:2: rustc_outlives +LL | / union Foo<'b, U> { //~ ERROR 18:1: 20:2: rustc_outlives LL | | bar: Bar<'b, U> LL | | } | |_^ diff --git a/src/test/ui/rfc-2093-infer-outlives/infer-static.rs b/src/test/ui/rfc-2093-infer-outlives/infer-static.rs index c4407b8b89..aeca18c24b 100644 --- a/src/test/ui/rfc-2093-infer-outlives/infer-static.rs +++ b/src/test/ui/rfc-2093-infer-outlives/infer-static.rs @@ -9,10 +9,11 @@ // except according to those terms. #![feature(rustc_attrs)] +#![feature(infer_outlives_requirements)] #![feature(infer_static_outlives_requirements)] #[rustc_outlives] -struct Foo { //~ ERROR 15:1: 17:2: rustc_outlives +struct Foo { //~ ERROR 16:1: 18:2: rustc_outlives bar: Bar } struct Bar { diff --git a/src/test/ui/rfc-2093-infer-outlives/infer-static.stderr b/src/test/ui/rfc-2093-infer-outlives/infer-static.stderr index 0cb4f3faa3..f167e522df 100644 --- a/src/test/ui/rfc-2093-infer-outlives/infer-static.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/infer-static.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/infer-static.rs:15:1 + --> $DIR/infer-static.rs:16:1 | -LL | / struct Foo { //~ ERROR 15:1: 17:2: rustc_outlives +LL | / struct Foo { //~ ERROR 16:1: 18:2: rustc_outlives LL | | bar: Bar LL | | } | |_^ diff --git a/src/test/ui/rfc-2093-infer-outlives/nested-enum.rs b/src/test/ui/rfc-2093-infer-outlives/nested-enum.rs index 5cb365b7a7..85f381ea51 100644 --- a/src/test/ui/rfc-2093-infer-outlives/nested-enum.rs +++ b/src/test/ui/rfc-2093-infer-outlives/nested-enum.rs @@ -9,9 +9,11 @@ // except according to those terms. #![feature(rustc_attrs)] +#![feature(infer_outlives_requirements)] + #[rustc_outlives] -enum Foo<'a, T> { //~ ERROR 14:1: 17:2: rustc_outlives +enum Foo<'a, T> { //~ ERROR 16:1: 19:2: rustc_outlives One(Bar<'a, T>) } diff --git a/src/test/ui/rfc-2093-infer-outlives/nested-enum.stderr b/src/test/ui/rfc-2093-infer-outlives/nested-enum.stderr index f0a6905d14..54a886a92f 100644 --- a/src/test/ui/rfc-2093-infer-outlives/nested-enum.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/nested-enum.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/nested-enum.rs:14:1 + --> $DIR/nested-enum.rs:16:1 | -LL | / enum Foo<'a, T> { //~ ERROR 14:1: 17:2: rustc_outlives +LL | / enum Foo<'a, T> { //~ ERROR 16:1: 19:2: rustc_outlives LL | | LL | | One(Bar<'a, T>) LL | | } diff --git a/src/test/ui/rfc-2093-infer-outlives/nested-regions.rs b/src/test/ui/rfc-2093-infer-outlives/nested-regions.rs index e56d7d7a05..792d2a0296 100644 --- a/src/test/ui/rfc-2093-infer-outlives/nested-regions.rs +++ b/src/test/ui/rfc-2093-infer-outlives/nested-regions.rs @@ -9,9 +9,10 @@ // except according to those terms. #![feature(rustc_attrs)] +#![feature(infer_outlives_requirements)] #[rustc_outlives] -struct Foo<'a, 'b, T> { //~ ERROR 14:1: 16:2: rustc_outlives +struct Foo<'a, 'b, T> { //~ ERROR 15:1: 17:2: rustc_outlives x: &'a &'b T } diff --git a/src/test/ui/rfc-2093-infer-outlives/nested-regions.stderr b/src/test/ui/rfc-2093-infer-outlives/nested-regions.stderr index 978fe352bc..04fe4814a0 100644 --- a/src/test/ui/rfc-2093-infer-outlives/nested-regions.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/nested-regions.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/nested-regions.rs:14:1 + --> $DIR/nested-regions.rs:15:1 | -LL | / struct Foo<'a, 'b, T> { //~ ERROR 14:1: 16:2: rustc_outlives +LL | / struct Foo<'a, 'b, T> { //~ ERROR 15:1: 17:2: rustc_outlives LL | | x: &'a &'b T LL | | } | |_^ diff --git a/src/test/ui/rfc-2093-infer-outlives/nested-structs.rs b/src/test/ui/rfc-2093-infer-outlives/nested-structs.rs index 84d1b88188..71a36dfb34 100644 --- a/src/test/ui/rfc-2093-infer-outlives/nested-structs.rs +++ b/src/test/ui/rfc-2093-infer-outlives/nested-structs.rs @@ -9,9 +9,10 @@ // except according to those terms. #![feature(rustc_attrs)] +#![feature(infer_outlives_requirements)] #[rustc_outlives] -struct Foo<'a, T> { //~ ERROR 14:1: 16:2: rustc_outlives +struct Foo<'a, T> { //~ ERROR 15:1: 17:2: rustc_outlives field1: Bar<'a, T> } diff --git a/src/test/ui/rfc-2093-infer-outlives/nested-structs.stderr b/src/test/ui/rfc-2093-infer-outlives/nested-structs.stderr index db02232b91..abea71f2d1 100644 --- a/src/test/ui/rfc-2093-infer-outlives/nested-structs.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/nested-structs.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/nested-structs.rs:14:1 + --> $DIR/nested-structs.rs:15:1 | -LL | / struct Foo<'a, T> { //~ ERROR 14:1: 16:2: rustc_outlives +LL | / struct Foo<'a, T> { //~ ERROR 15:1: 17:2: rustc_outlives LL | | field1: Bar<'a, T> LL | | } | |_^ diff --git a/src/test/ui/rfc-2093-infer-outlives/nested-union.rs b/src/test/ui/rfc-2093-infer-outlives/nested-union.rs index 974675f51c..0720e581e2 100644 --- a/src/test/ui/rfc-2093-infer-outlives/nested-union.rs +++ b/src/test/ui/rfc-2093-infer-outlives/nested-union.rs @@ -9,11 +9,13 @@ // except according to those terms. #![feature(rustc_attrs)] +#![feature(infer_outlives_requirements)] #![feature(untagged_unions)] #![allow(unions_with_drop_fields)] + #[rustc_outlives] -union Foo<'a, T> { //~ ERROR 16:1: 18:2: rustc_outlives +union Foo<'a, T> { //~ ERROR 18:1: 20:2: rustc_outlives field1: Bar<'a, T> } diff --git a/src/test/ui/rfc-2093-infer-outlives/nested-union.stderr b/src/test/ui/rfc-2093-infer-outlives/nested-union.stderr index 2704a1d2de..b7b50c1506 100644 --- a/src/test/ui/rfc-2093-infer-outlives/nested-union.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/nested-union.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/nested-union.rs:16:1 + --> $DIR/nested-union.rs:18:1 | -LL | / union Foo<'a, T> { //~ ERROR 16:1: 18:2: rustc_outlives +LL | / union Foo<'a, T> { //~ ERROR 18:1: 20:2: rustc_outlives LL | | field1: Bar<'a, T> LL | | } | |_^ diff --git a/src/test/ui/rfc-2093-infer-outlives/privacy.rs b/src/test/ui/rfc-2093-infer-outlives/privacy.rs deleted file mode 100644 index 180f5ac6cd..0000000000 --- a/src/test/ui/rfc-2093-infer-outlives/privacy.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Test that we do not get a privacy error here. Initially, we did, -// because we inferred an outlives predciate of ` as -// Private>::Out: 'a`, but the private trait is -- well -- private, -// and hence it was not something that a pub trait could refer to. -// -// run-pass - -#![allow(dead_code)] - -pub struct Foo<'a> { - field: Option<&'a as Private>::Out> -} - -trait Private { - type Out: ?Sized; -} - -impl Private for T { type Out = Self; } - -fn main() { } diff --git a/src/test/ui/rfc-2093-infer-outlives/projection.rs b/src/test/ui/rfc-2093-infer-outlives/projection.rs index 7693d0e940..3abce873b2 100644 --- a/src/test/ui/rfc-2093-infer-outlives/projection.rs +++ b/src/test/ui/rfc-2093-infer-outlives/projection.rs @@ -9,6 +9,7 @@ // except according to those terms. #![feature(rustc_attrs)] +#![feature(infer_outlives_requirements)] #[rustc_outlives] struct Foo<'a, T: Iterator> { //~ ERROR rustc_outlives diff --git a/src/test/ui/rfc-2093-infer-outlives/projection.stderr b/src/test/ui/rfc-2093-infer-outlives/projection.stderr index fb4835ae2d..dfaf7793a5 100644 --- a/src/test/ui/rfc-2093-infer-outlives/projection.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/projection.stderr @@ -1,5 +1,5 @@ error: rustc_outlives - --> $DIR/projection.rs:14:1 + --> $DIR/projection.rs:15:1 | LL | / struct Foo<'a, T: Iterator> { //~ ERROR rustc_outlives LL | | bar: &'a T::Item diff --git a/src/test/ui/rfc-2093-infer-outlives/reference.rs b/src/test/ui/rfc-2093-infer-outlives/reference.rs index 760d9889bb..56b1bc3c7d 100644 --- a/src/test/ui/rfc-2093-infer-outlives/reference.rs +++ b/src/test/ui/rfc-2093-infer-outlives/reference.rs @@ -9,6 +9,7 @@ // except according to those terms. #![feature(rustc_attrs)] +#![feature(infer_outlives_requirements)] #[rustc_outlives] struct Foo<'a, T> { //~ ERROR rustc_outlives diff --git a/src/test/ui/rfc-2093-infer-outlives/reference.stderr b/src/test/ui/rfc-2093-infer-outlives/reference.stderr index fdd312f9b8..785d76e8f2 100644 --- a/src/test/ui/rfc-2093-infer-outlives/reference.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/reference.stderr @@ -1,5 +1,5 @@ error: rustc_outlives - --> $DIR/reference.rs:14:1 + --> $DIR/reference.rs:15:1 | LL | / struct Foo<'a, T> { //~ ERROR rustc_outlives LL | | bar: &'a T, diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs b/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs deleted file mode 100644 index a2d3cf6779..0000000000 --- a/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs +++ /dev/null @@ -1,50 +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. - -// ignore-tidy-linelength - -// Various examples of structs whose fields are not well-formed. - -#![allow(dead_code)] - -trait Dummy<'a> { - type Out; -} -impl<'a, T> Dummy<'a> for T -where T: 'a -{ - type Out = (); -} -type RequireOutlives<'a, T> = >::Out; - -enum Ref1<'a, T> { - Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough -} - -enum Ref2<'a, T> { - Ref2Variant1, - Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough -} - -enum RefOk<'a, T:'a> { - RefOkVariant1(&'a T) -} - -// This is now well formed. RFC 2093 -enum RefIndirect<'a, T> { - RefIndirectVariant1(isize, RefOk<'a,T>) -} - -enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] - RefDoubleVariant1(&'a RequireOutlives<'b, T>) - //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309] -} - -fn main() { } diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr deleted file mode 100644 index 923ea17622..0000000000 --- a/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr +++ /dev/null @@ -1,67 +0,0 @@ -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-enum-not-wf.rs:28:18 - | -LL | enum Ref1<'a, T> { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^ - | -note: ...so that the type `T` will meet its required lifetime bounds - --> $DIR/regions-enum-not-wf.rs:28:18 - | -LL | Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^ - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-enum-not-wf.rs:33:25 - | -LL | enum Ref2<'a, T> { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | Ref2Variant1, -LL | Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^ - | -note: ...so that the type `T` will meet its required lifetime bounds - --> $DIR/regions-enum-not-wf.rs:33:25 - | -LL | Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough - | ^^^^^^^^^^^^^^^^^^^^^^ - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-enum-not-wf.rs:45:1 - | -LL | enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] - | ^ - help: consider adding an explicit lifetime bound `T: 'b`... - | _| - | | -LL | | RefDoubleVariant1(&'a RequireOutlives<'b, T>) -LL | | //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309] -LL | | } - | |_^ - | -note: ...so that the type `T` will meet its required lifetime bounds - --> $DIR/regions-enum-not-wf.rs:45:1 - | -LL | / enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] -LL | | RefDoubleVariant1(&'a RequireOutlives<'b, T>) -LL | | //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309] -LL | | } - | |_^ - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-enum-not-wf.rs:46:23 - | -LL | enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] - | - help: consider adding an explicit lifetime bound `T: 'b`... -LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: ...so that the type `T` will meet its required lifetime bounds - --> $DIR/regions-enum-not-wf.rs:46:23 - | -LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs deleted file mode 100644 index 44af621ef2..0000000000 --- a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs +++ /dev/null @@ -1,32 +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. - -// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its -// arguments (like `'a`) outlive `'b`. -// -// Rule OutlivesNominalType from RFC 1214. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -mod rev_variant_struct_region { - struct Foo<'a> { - x: fn(&'a i32), - } - trait Trait<'a, 'b> { - type Out; - } - impl<'a, 'b> Trait<'a, 'b> for usize { - type Out = &'a Foo<'b>; //~ ERROR reference has a longer lifetime - } -} - -#[rustc_error] -fn main() { } diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr deleted file mode 100644 index bd4682f0ac..0000000000 --- a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a rev_variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-region-rev.rs:27:9 - | -LL | type Out = &'a Foo<'b>; //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the impl at 26:10 - --> $DIR/regions-outlives-nominal-type-region-rev.rs:26:10 - | -LL | impl<'a, 'b> Trait<'a, 'b> for usize { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the impl at 26:14 - --> $DIR/regions-outlives-nominal-type-region-rev.rs:26:14 - | -LL | impl<'a, 'b> Trait<'a, 'b> for usize { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs deleted file mode 100644 index 93f16350a7..0000000000 --- a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs +++ /dev/null @@ -1,32 +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. - -// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its -// arguments (like `'a`) outlive `'b`. -// -// Rule OutlivesNominalType from RFC 1214. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -mod variant_struct_region { - struct Foo<'a> { - x: &'a i32, - } - trait Trait<'a, 'b> { - type Out; - } - impl<'a, 'b> Trait<'a, 'b> for usize { - type Out = &'a Foo<'b>; //~ ERROR reference has a longer lifetime - } -} - -#[rustc_error] -fn main() { } diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr deleted file mode 100644 index 3fdfb673b3..0000000000 --- a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-region.rs:27:9 - | -LL | type Out = &'a Foo<'b>; //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the impl at 26:10 - --> $DIR/regions-outlives-nominal-type-region.rs:26:10 - | -LL | impl<'a, 'b> Trait<'a, 'b> for usize { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the impl at 26:14 - --> $DIR/regions-outlives-nominal-type-region.rs:26:14 - | -LL | impl<'a, 'b> Trait<'a, 'b> for usize { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs deleted file mode 100644 index e44e049a9e..0000000000 --- a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs +++ /dev/null @@ -1,32 +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. - -// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its -// arguments (like `'a`) outlive `'b`. -// -// Rule OutlivesNominalType from RFC 1214. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -mod variant_struct_type { - struct Foo { - x: fn(T) - } - trait Trait<'a, 'b> { - type Out; - } - impl<'a, 'b> Trait<'a, 'b> for usize { - type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime - } -} - -#[rustc_error] -fn main() { } diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr deleted file mode 100644 index 166e95cded..0000000000 --- a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-type-rev.rs:27:9 - | -LL | type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the impl at 26:10 - --> $DIR/regions-outlives-nominal-type-type-rev.rs:26:10 - | -LL | impl<'a, 'b> Trait<'a, 'b> for usize { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the impl at 26:14 - --> $DIR/regions-outlives-nominal-type-type-rev.rs:26:14 - | -LL | impl<'a, 'b> Trait<'a, 'b> for usize { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs deleted file mode 100644 index 1293e6c234..0000000000 --- a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs +++ /dev/null @@ -1,32 +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. - -// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its -// arguments (like `'a`) outlive `'b`. -// -// Rule OutlivesNominalType from RFC 1214. - -#![feature(rustc_attrs)] -#![allow(dead_code)] - -mod variant_struct_type { - struct Foo { - x: T - } - trait Trait<'a, 'b> { - type Out; - } - impl<'a, 'b> Trait<'a, 'b> for usize { - type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime - } -} - -#[rustc_error] -fn main() { } diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr deleted file mode 100644 index 54952ec167..0000000000 --- a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-type.rs:27:9 - | -LL | type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the impl at 26:10 - --> $DIR/regions-outlives-nominal-type-type.rs:26:10 - | -LL | impl<'a, 'b> Trait<'a, 'b> for usize { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the impl at 26:14 - --> $DIR/regions-outlives-nominal-type-type.rs:26:14 - | -LL | impl<'a, 'b> Trait<'a, 'b> for usize { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr deleted file mode 100644 index d8c8b6c3cc..0000000000 --- a/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr +++ /dev/null @@ -1,49 +0,0 @@ -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-struct-not-wf.rs:23:5 - | -LL | impl<'a, T> Trait<'a, T> for usize { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | type Out = &'a T; - | ^^^^^^^^^^^^^^^^^ - | -note: ...so that the reference type `&'a T` does not outlive the data it points at - --> $DIR/regions-struct-not-wf.rs:23:5 - | -LL | type Out = &'a T; - | ^^^^^^^^^^^^^^^^^ - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-struct-not-wf.rs:31:5 - | -LL | impl<'a, T> Trait<'a, T> for u32 { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | type Out = RefOk<'a, T>; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: ...so that the type `T` will meet its required lifetime bounds - --> $DIR/regions-struct-not-wf.rs:31:5 - | -LL | type Out = RefOk<'a, T>; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references - --> $DIR/regions-struct-not-wf.rs:35:5 - | -LL | type Out = &'a &'b T; - | ^^^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the impl at 34:6 - --> $DIR/regions-struct-not-wf.rs:34:6 - | -LL | impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the impl at 34:10 - --> $DIR/regions-struct-not-wf.rs:34:10 - | -LL | impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { - | ^^ - -error: aborting due to 3 previous errors - -Some errors occurred: E0309, E0491. -For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/rfc-2093-infer-outlives/self-dyn.rs b/src/test/ui/rfc-2093-infer-outlives/self-dyn.rs index 37c468f2f8..a19bcf8aff 100644 --- a/src/test/ui/rfc-2093-infer-outlives/self-dyn.rs +++ b/src/test/ui/rfc-2093-infer-outlives/self-dyn.rs @@ -10,13 +10,14 @@ #![feature(dyn_trait)] #![feature(rustc_attrs)] +#![feature(infer_outlives_requirements)] trait Trait<'x, 's, T> where T: 'x, 's: { } #[rustc_outlives] -struct Foo<'a, 'b, A> //~ ERROR 19:1: 22:2: rustc_outlives +struct Foo<'a, 'b, A> //~ ERROR 20:1: 23:2: rustc_outlives { foo: Box> } diff --git a/src/test/ui/rfc-2093-infer-outlives/self-dyn.stderr b/src/test/ui/rfc-2093-infer-outlives/self-dyn.stderr index 8c69307ddf..546ba9db64 100644 --- a/src/test/ui/rfc-2093-infer-outlives/self-dyn.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/self-dyn.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/self-dyn.rs:19:1 + --> $DIR/self-dyn.rs:20:1 | -LL | / struct Foo<'a, 'b, A> //~ ERROR 19:1: 22:2: rustc_outlives +LL | / struct Foo<'a, 'b, A> //~ ERROR 20:1: 23:2: rustc_outlives LL | | { LL | | foo: Box> LL | | } diff --git a/src/test/ui/rfc-2093-infer-outlives/self-structs.rs b/src/test/ui/rfc-2093-infer-outlives/self-structs.rs index 82d13d9179..c4f8f83bdc 100644 --- a/src/test/ui/rfc-2093-infer-outlives/self-structs.rs +++ b/src/test/ui/rfc-2093-infer-outlives/self-structs.rs @@ -9,9 +9,10 @@ // except according to those terms. #![feature(rustc_attrs)] +#![feature(infer_outlives_requirements)] #[rustc_outlives] -struct Foo<'a, 'b, T> { //~ ERROR 14:1: 16:2: rustc_outlives +struct Foo<'a, 'b, T> { //~ ERROR 15:1: 17:2: rustc_outlives field1: Bar<'a, 'b, T> } diff --git a/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr b/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr index 541e282f23..04284577a0 100644 --- a/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/self-structs.rs:14:1 + --> $DIR/self-structs.rs:15:1 | -LL | / struct Foo<'a, 'b, T> { //~ ERROR 14:1: 16:2: rustc_outlives +LL | / struct Foo<'a, 'b, T> { //~ ERROR 15:1: 17:2: rustc_outlives LL | | field1: Bar<'a, 'b, T> LL | | } | |_^ diff --git a/src/test/ui/run-pass/extern/extern-prelude-no-speculative.rs b/src/test/ui/run-pass/extern/extern-prelude-no-speculative.rs index 8d4219ccf4..8667f0c687 100644 --- a/src/test/ui/run-pass/extern/extern-prelude-no-speculative.rs +++ b/src/test/ui/run-pass/extern/extern-prelude-no-speculative.rs @@ -9,7 +9,7 @@ // except according to those terms. // run-pass -// compile-flags: --extern LooksLikeExternCrate=/path/to/nowhere +// compile-flags: --extern LooksLikeExternCrate mod m { pub struct LooksLikeExternCrate; diff --git a/src/test/ui/run-pass/non_modrs_mods/non_modrs_mods.rs b/src/test/ui/run-pass/non_modrs_mods/non_modrs_mods.rs new file mode 100644 index 0000000000..a9b240be80 --- /dev/null +++ b/src/test/ui/run-pass/non_modrs_mods/non_modrs_mods.rs @@ -0,0 +1,28 @@ +// 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. + +// run-pass +// +// ignore-pretty issue #37195 +#![feature(non_modrs_mods)] + +pub mod modrs_mod; +pub mod foors_mod; + +#[path = "some_crazy_attr_mod_dir/arbitrary_name.rs"] +pub mod attr_mod; + +pub fn main() { + modrs_mod::inner_modrs_mod::innest::foo(); + modrs_mod::inner_foors_mod::innest::foo(); + foors_mod::inner_modrs_mod::innest::foo(); + foors_mod::inner_foors_mod::innest::foo(); + attr_mod::inner_modrs_mod::innest::foo(); +} diff --git a/src/test/ui/rust-2018/edition-lint-fully-qualified-paths.stderr b/src/test/ui/rust-2018/edition-lint-fully-qualified-paths.stderr index 9b893f9f15..5d8e84bb82 100644 --- a/src/test/ui/rust-2018/edition-lint-fully-qualified-paths.stderr +++ b/src/test/ui/rust-2018/edition-lint-fully-qualified-paths.stderr @@ -10,7 +10,7 @@ note: lint level defined here LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue TBD + = note: for more information, see issue #53130 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition --> $DIR/edition-lint-fully-qualified-paths.rs:34:13 @@ -19,7 +19,7 @@ LL | let _: <::foo::Baz as foo::Foo>::Bar = (); | ^^^^^^^^^^ help: use `crate`: `crate::foo::Baz` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue TBD + = note: for more information, see issue #53130 error: aborting due to 2 previous errors diff --git a/src/test/ui/rust-2018/edition-lint-nested-empty-paths.stderr b/src/test/ui/rust-2018/edition-lint-nested-empty-paths.stderr index 439db84045..5503a0a8f4 100644 --- a/src/test/ui/rust-2018/edition-lint-nested-empty-paths.stderr +++ b/src/test/ui/rust-2018/edition-lint-nested-empty-paths.stderr @@ -10,7 +10,7 @@ note: lint level defined here LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue TBD + = note: for more information, see issue #53130 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition --> $DIR/edition-lint-nested-empty-paths.rs:31:5 @@ -19,7 +19,7 @@ LL | use foo::{bar::{XX, baz::{}}}; | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{XX, baz::{}}}` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue TBD + = note: for more information, see issue #53130 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition --> $DIR/edition-lint-nested-empty-paths.rs:35:5 @@ -28,7 +28,7 @@ LL | use foo::{bar::{baz::{}, baz1::{}}}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{bar::{baz::{}, baz1::{}}}` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue TBD + = note: for more information, see issue #53130 error: aborting due to 3 previous errors diff --git a/src/test/ui/rust-2018/edition-lint-nested-paths.stderr b/src/test/ui/rust-2018/edition-lint-nested-paths.stderr index 333d27c381..0f8c77aef1 100644 --- a/src/test/ui/rust-2018/edition-lint-nested-paths.stderr +++ b/src/test/ui/rust-2018/edition-lint-nested-paths.stderr @@ -10,7 +10,7 @@ note: lint level defined here LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue TBD + = note: for more information, see issue #53130 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition --> $DIR/edition-lint-nested-paths.rs:31:13 @@ -19,7 +19,7 @@ LL | use foo::{self as x, c}; | ^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::{self as x, c}` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue TBD + = note: for more information, see issue #53130 error: aborting due to 2 previous errors diff --git a/src/test/ui/rust-2018/edition-lint-paths.stderr b/src/test/ui/rust-2018/edition-lint-paths.stderr index 37c9041b72..9429c946ba 100644 --- a/src/test/ui/rust-2018/edition-lint-paths.stderr +++ b/src/test/ui/rust-2018/edition-lint-paths.stderr @@ -10,7 +10,7 @@ note: lint level defined here LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue TBD + = note: for more information, see issue #53130 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition --> $DIR/edition-lint-paths.rs:28:9 @@ -19,7 +19,7 @@ LL | use bar; | ^^^ help: use `crate`: `crate::bar` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue TBD + = note: for more information, see issue #53130 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition --> $DIR/edition-lint-paths.rs:33:9 @@ -28,7 +28,7 @@ LL | use {Bar as SomethingElse, main}; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `crate`: `crate::{Bar as SomethingElse, main}` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue TBD + = note: for more information, see issue #53130 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition --> $DIR/edition-lint-paths.rs:45:5 @@ -37,7 +37,7 @@ LL | use bar::Bar; | ^^^^^^^^ help: use `crate`: `crate::bar::Bar` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue TBD + = note: for more information, see issue #53130 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition --> $DIR/edition-lint-paths.rs:57:9 @@ -46,7 +46,7 @@ LL | use *; | ^ help: use `crate`: `crate::*` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue TBD + = note: for more information, see issue #53130 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition --> $DIR/edition-lint-paths.rs:62:6 @@ -55,7 +55,7 @@ LL | impl ::foo::SomeTrait for u32 { } | ^^^^^^^^^^^^^^^^ help: use `crate`: `crate::foo::SomeTrait` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue TBD + = note: for more information, see issue #53130 error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition --> $DIR/edition-lint-paths.rs:67:13 @@ -64,7 +64,7 @@ LL | let x = ::bar::Bar; | ^^^^^^^^^^ help: use `crate`: `crate::bar::Bar` | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue TBD + = note: for more information, see issue #53130 error: aborting due to 7 previous errors diff --git a/src/test/ui/rust-2018/extern-crate-rename.stderr b/src/test/ui/rust-2018/extern-crate-rename.stderr index d739ad360e..0004880e76 100644 --- a/src/test/ui/rust-2018/extern-crate-rename.stderr +++ b/src/test/ui/rust-2018/extern-crate-rename.stderr @@ -10,7 +10,7 @@ note: lint level defined here LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue TBD + = note: for more information, see issue #53130 error: aborting due to previous error diff --git a/src/test/ui/rust-2018/extern-crate-submod.stderr b/src/test/ui/rust-2018/extern-crate-submod.stderr index 17da9feaea..4a4652c907 100644 --- a/src/test/ui/rust-2018/extern-crate-submod.stderr +++ b/src/test/ui/rust-2018/extern-crate-submod.stderr @@ -10,7 +10,7 @@ note: lint level defined here LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in the 2018 edition! - = note: for more information, see issue TBD + = note: for more information, see issue #53130 error: aborting due to previous error diff --git a/src/test/ui/rust-2018/remove-extern-crate.fixed b/src/test/ui/rust-2018/remove-extern-crate.fixed index cdae815b20..34c7266b63 100644 --- a/src/test/ui/rust-2018/remove-extern-crate.fixed +++ b/src/test/ui/rust-2018/remove-extern-crate.fixed @@ -14,6 +14,7 @@ // aux-build:remove-extern-crate.rs // compile-flags:--extern remove_extern_crate +#![feature(alloc)] #![warn(rust_2018_idioms)] @@ -22,11 +23,16 @@ use remove_extern_crate; #[macro_use] extern crate remove_extern_crate as something_else; +// Shouldn't suggest changing to `use`, as the `alloc` +// crate is not in the extern prelude - see #54381. +extern crate alloc; + fn main() { another_name::mem::drop(3); another::foo(); remove_extern_crate::foo!(); bar!(); + alloc::vec![5]; } mod another { diff --git a/src/test/ui/rust-2018/remove-extern-crate.rs b/src/test/ui/rust-2018/remove-extern-crate.rs index 4984da802c..570bbb02f7 100644 --- a/src/test/ui/rust-2018/remove-extern-crate.rs +++ b/src/test/ui/rust-2018/remove-extern-crate.rs @@ -14,6 +14,7 @@ // aux-build:remove-extern-crate.rs // compile-flags:--extern remove_extern_crate +#![feature(alloc)] #![warn(rust_2018_idioms)] extern crate core; @@ -22,11 +23,16 @@ use remove_extern_crate; #[macro_use] extern crate remove_extern_crate as something_else; +// Shouldn't suggest changing to `use`, as the `alloc` +// crate is not in the extern prelude - see #54381. +extern crate alloc; + fn main() { another_name::mem::drop(3); another::foo(); remove_extern_crate::foo!(); bar!(); + alloc::vec![5]; } mod another { diff --git a/src/test/ui/rust-2018/remove-extern-crate.stderr b/src/test/ui/rust-2018/remove-extern-crate.stderr index 064a853625..847ba5f354 100644 --- a/src/test/ui/rust-2018/remove-extern-crate.stderr +++ b/src/test/ui/rust-2018/remove-extern-crate.stderr @@ -1,24 +1,24 @@ warning: unused extern crate - --> $DIR/remove-extern-crate.rs:19:1 + --> $DIR/remove-extern-crate.rs:20:1 | LL | extern crate core; | ^^^^^^^^^^^^^^^^^^ help: remove it | note: lint level defined here - --> $DIR/remove-extern-crate.rs:17:9 + --> $DIR/remove-extern-crate.rs:18:9 | LL | #![warn(rust_2018_idioms)] | ^^^^^^^^^^^^^^^^ = note: #[warn(unused_extern_crates)] implied by #[warn(rust_2018_idioms)] warning: `extern crate` is not idiomatic in the new edition - --> $DIR/remove-extern-crate.rs:20:1 + --> $DIR/remove-extern-crate.rs:21:1 | LL | extern crate core as another_name; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: convert it to a `use` warning: `extern crate` is not idiomatic in the new edition - --> $DIR/remove-extern-crate.rs:33:5 + --> $DIR/remove-extern-crate.rs:39:5 | LL | extern crate core; | ^^^^^^^^^^^^^^^^^^ help: convert it to a `use` diff --git a/src/test/ui/typeck/typeck_type_placeholder_item.stderr b/src/test/ui/typeck/typeck_type_placeholder_item.stderr index 598f18bf8d..3f81408595 100644 --- a/src/test/ui/typeck/typeck_type_placeholder_item.stderr +++ b/src/test/ui/typeck/typeck_type_placeholder_item.stderr @@ -76,24 +76,6 @@ error[E0121]: the type placeholder `_` is not allowed within types on item signa LL | b: (_, _), | ^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:112:12 - | -LL | a: _, - | ^ not allowed in type signatures - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:114:13 - | -LL | b: (_, _), - | ^ not allowed in type signatures - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:114:16 - | -LL | b: (_, _), - | ^ not allowed in type signatures - error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:67:21 | @@ -154,6 +136,24 @@ error[E0121]: the type placeholder `_` is not allowed within types on item signa LL | fn fn_test8(_f: fn() -> _) { } | ^ not allowed in type signatures +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/typeck_type_placeholder_item.rs:112:12 + | +LL | a: _, + | ^ not allowed in type signatures + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/typeck_type_placeholder_item.rs:114:13 + | +LL | b: (_, _), + | ^ not allowed in type signatures + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/typeck_type_placeholder_item.rs:114:16 + | +LL | b: (_, _), + | ^ not allowed in type signatures + error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:43:24 | diff --git a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs index afdf59d1e5..c11b2e4c54 100644 --- a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs +++ b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs @@ -8,26 +8,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// Test that an appearance of `T` in fn args or in a trait object must +// still meet the outlives bounds. Since this is a new requirement, +// this is currently only a warning, not a hard error. + #![feature(rustc_attrs)] #![allow(dead_code)] -trait Trait<'a, T> { - type Out; -} - -impl<'a, T> Trait<'a, T> for usize { - type Out = &'a fn(T); -} +trait Trait { } struct Foo<'a,T> { f: &'a fn(T), + //~^ ERROR E0309 } -trait Baz { } - -impl<'a, T> Trait<'a, T> for u32 { - type Out = &'a Baz; +struct Bar<'a,T> { + f: &'a Trait, + //~^ ERROR E0309 } +#[rustc_error] fn main() { } diff --git a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr index 26a2138c9f..9a8c63126f 100644 --- a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr +++ b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr @@ -1,30 +1,30 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:19:5 + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:21:5 | -LL | impl<'a, T> Trait<'a, T> for usize { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | type Out = &'a fn(T); - | ^^^^^^^^^^^^^^^^^^^^^ +LL | struct Foo<'a,T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | f: &'a fn(T), + | ^^^^^^^^^^^^ | note: ...so that the reference type `&'a fn(T)` does not outlive the data it points at - --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:19:5 + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:21:5 | -LL | type Out = &'a fn(T); - | ^^^^^^^^^^^^^^^^^^^^^ +LL | f: &'a fn(T), + | ^^^^^^^^^^^^ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:29:5 + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:26:5 | -LL | impl<'a, T> Trait<'a, T> for u32 { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | type Out = &'a Baz; - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | struct Bar<'a,T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | f: &'a Trait, + | ^^^^^^^^^^^^^^^ | -note: ...so that the reference type `&'a (dyn Baz + 'a)` does not outlive the data it points at - --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:29:5 +note: ...so that the reference type `&'a (dyn Trait + 'a)` does not outlive the data it points at + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:26:5 | -LL | type Out = &'a Baz; - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | f: &'a Trait, + | ^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors diff --git a/version b/version index 18cb564a4d..f6b262bdda 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.30.0-beta.7 (0ebb25088 2018-09-22) \ No newline at end of file +1.30.0 (da5f414c2 2018-10-24) \ No newline at end of file