+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)
==========================
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<CStr>`, `Box<OsStr>`, and `Box<Path>` now implement `Clone`.][51912]
- [Implemented `PartialEq<&str>` for `OsString` and `PartialEq<OsString>`
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
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/
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<Trait> == Box<dyn Trait>`.
- [Attributes on generic parameters such as types and lifetimes are
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.
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
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
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
- [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<Item=u8>` or
+ or in function parameters.][49255] E.g. `fn foo() -> impl Iterator<Item=u8>` or
`fn open(path: impl AsRef<Path>)`.
- [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 {
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]
-0ebb250883d63faae833070c11287fc6e7305517
\ No newline at end of file
+da5f414c2c0bfe5198934493f04c676e2b23ff2e
\ No newline at end of file
#
# 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"
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).
-
[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:
--- /dev/null
+# `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 `<T as std::iter::Iterator>::Item : 'a`
+struct Foo<'a, T: Iterator> {
+ bar: &'a T::Item
+```
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};
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).
iter: Iter {
tail: drain_tail,
head: drain_head,
- ring: unsafe { self.buffer_as_slice() },
+ ring: unsafe { self.buffer_as_mut_slice() },
},
}
}
#[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.
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;
#![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)]
#![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))]
#![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))]
#![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))]
#![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)]
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::*;
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::*;
#![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)]
#![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)]
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)]
issue = "0")]
#![allow(unused_features)]
#![cfg_attr(not(stage0), feature(nll))]
+#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(staged_api)]
"##,
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 `<T as SomeTrait<'a>>::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: <T as SomeTrait<'a>>::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: <T as SomeTrait<'a>>::Output
+struct Foo<'a, T: 'a> {
+ foo: &'a T
}
+```
-trait SomeTrait<'a> {
- type Output;
+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
}
-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!
}
```
"##,
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>,
}
```
"##,
s
}
+ /// Return filename friendly string of the DefPah with the
+ /// crate-prefix.
+ pub fn to_string_friendly<F>(&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.
#![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)]
"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 {
krate: &hir::Crate)
-> Vec<ast::NodeId>
{
- 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::<Vec<_>>();
match self.debugging_opts.share_generics {
Some(setting) => setting,
None => {
- self.incremental.is_some() ||
match self.optimize {
OptLevel::No |
OptLevel::Less |
freevars: FxHashMap<DefId, Lrc<Vec<hir::Freevar>>>,
maybe_unused_trait_imports: FxHashSet<DefId>,
-
maybe_unused_extern_crates: Vec<(DefId, Span)>,
+ pub extern_prelude: FxHashSet<ast::Name>,
// Internal cache for metadata decoding. No need to track deps on this.
pub rcache: Lock<FxHashMap<ty::CReaderCacheKey, Ty<'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(
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;
pub maybe_unused_trait_imports: NodeSet,
pub maybe_unused_extern_crates: Vec<(NodeId, Span)>,
pub export_map: ExportMap,
+ pub extern_prelude: FxHashSet<Name>,
}
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
alloc_decoding_session.decode_alloc_id(self)
}
}
+
impl<'a, 'tcx, 'x> SpecializedDecoder<Span> for CacheDecoder<'a, 'tcx, 'x> {
fn specialized_decode(&mut self) -> Result<Span, Self::Error> {
let tag: u8 = Decodable::decode(self)?;
// 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;
#![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)]
#![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]
#![allow(non_camel_case_types)]
#![cfg_attr(not(stage0), feature(nll))]
+#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(quote)]
#![recursion_limit="256"]
#![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)]
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;
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 {
#![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)]
#![allow(unused_extern_crates)]
#![cfg_attr(not(stage0), feature(nll))]
+#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
extern crate bitflags;
extern crate log;
#![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)]
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 {
#![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)]
#![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;
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"]
#![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)]
},
FutureIncompatibleInfo {
id: LintId::of(ABSOLUTE_PATHS_NOT_STARTING_WITH_CRATE),
- reference: "issue TBD",
+ reference: "issue #53130 <https://github.com/rust-lang/rust/issues/53130>",
edition: Some(Edition::Edition2018),
},
FutureIncompatibleInfo {
// 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",
#![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]
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,
}
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)
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;
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);
}
}
- 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!(),
}
}
#![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)]
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;
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 {
*/
#![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)]
#![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]
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]
#![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],
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;
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"]
}
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 {
#![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)]
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};
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> {
graph_root: Module<'a>,
prelude: Option<Module<'a>>,
- extern_prelude: FxHashSet<Name>,
+ pub extern_prelude: FxHashSet<Name>,
/// n.b. This is used only for better diagnostics, not name resolution itself.
has_self: FxHashSet<DefId>,
block_map: NodeMap<Module<'a>>,
module_map: FxHashMap<DefId, Module<'a>>,
extern_module_map: FxHashMap<(DefId, bool /* MacrosOnly? */), Module<'a>>,
+ binding_parent_modules: FxHashMap<PtrKey<'a, NameBinding<'a>>, Module<'a>>,
pub make_glob_map: bool,
/// Maps imports to the names of items actually imported (this actually maps
let mut extern_prelude: FxHashSet<Name> =
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(),
module_map,
block_map: NodeMap(),
extern_module_map: FxHashMap(),
+ binding_parent_modules: FxHashMap(),
make_glob_map: make_glob_map == MakeGlobMap::Yes,
glob_map: NodeMap(),
}
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);
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 =
// 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).
// 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`
}
// 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 {
}
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,
},
(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
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
});
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() {
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"]
#![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]
#![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"]
#![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]
});
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(
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.
}
// 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 `{}`",
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,
#![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)]
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");
// 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);
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()),
#![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)]
\"light-suffix.css\"",
"PATH")
}),
- stable("edition", |o| {
+ unstable("edition", |o| {
o.optopt("", "edition",
"edition to use when compiling rust code (default: 2015)",
"EDITION")
output_types: outputs,
externs,
cg: config::CodegenOptions {
- prefer_dynamic: true,
linker,
..cg
},
#![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};
#![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)]
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)))
}) {
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
// `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),
(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`,
(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),
"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",
}
}
+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() {
};
let visitor = &mut PostExpansionVisitor { context: &ctx };
+ visitor.whole_crate_feature_gates(krate);
visit::walk_crate(visitor, krate);
}
#![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)]
#![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)]
pub fn is_stable(&self) -> bool {
match *self {
Edition::Edition2015 => true,
- Edition::Edition2018 => true,
+ Edition::Edition2018 => false,
}
}
}
#![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)]
#[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,
// 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::*;
#![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)]
#![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)]
# 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:
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) {
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]) {
// 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)]
// 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
}
async_closure,
async_fn,
async_fn_with_internal_borrow,
+ Foo::async_method,
|x| {
async move {
unsafe { await!(unsafe_async_fn(x)) }
--- /dev/null
+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
+
--- /dev/null
+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<Item = &i32> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
--- /dev/null
+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 }
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
--- /dev/null
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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);
+}
--- /dev/null
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<I> {
+ type Output;
+}
+
+impl ParseError<char> for u32 {
+ type Output = ();
+}
+
+impl Stream for () {
+ type Item = char;
+ type Error = u32;
+}
+
+pub struct Lex<'a, I>
+ where I: Stream,
+ I::Error: ParseError<char>,
+ <<I as Stream>::Error as ParseError<char>>::Output: 'a
+{
+ x: &'a <I::Error as ParseError<char>>::Output
+}
+
+pub struct Reserved<'a, I> where
+ I: Stream<Item=char> + 'a,
+ I::Error: ParseError<I::Item>,
+// <<I as Stream>::Error as ParseError<char>>::Output: 'a // comment this to compile
+
+{
+ x: Lex<'a, I>
+}
+
+fn main() {
+ let r: Reserved<()> = Reserved {
+ x: Lex {
+ x: &()
+ }
+ };
+
+ let _v = r.x.x;
+}
--- /dev/null
+warning: function is never used: `iter`
+ --> $DIR/issue-49556.rs:12:1
+ |
+LL | fn iter<'a>(data: &'a [usize]) -> impl Iterator<Item = usize> + 'a {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: #[warn(dead_code)] on by default
+
--- /dev/null
+warning: function is never used: `batches`
+ --> $DIR/conservative_impl_trait.rs:14:1
+ |
+LL | fn batches(n: &u32) -> impl Iterator<Item=&u32> {
+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ |
+ = note: #[warn(dead_code)] on by default
+
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 ----
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:
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
+}
--- /dev/null
+// 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() {}
--- /dev/null
+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`.
--- /dev/null
+// 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() {}
+++ /dev/null
-// 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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() { }
-}
+++ /dev/null
-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
-
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
| ^^^^^^^^^^^^^^^^^^^^^^^
= 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 <https://github.com/rust-lang/rust/issues/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
| ^^^^^^
|
= 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 <https://github.com/rust-lang/rust/issues/53130>
//~^ 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
//~| 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;
//~| 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 {
fn main() {
unsafe { a::getpid(); }
unsafe { b::getpid(); }
+
+ proc_macro::TokenStream::new();
}
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
--- /dev/null
+// 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() {}
--- /dev/null
+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
+
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 },
};
|
= 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
}
#[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`
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`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-error: aborting due to 22 previous errors
+error: aborting due to 23 previous errors
--- /dev/null
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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
+
+mod mod_file_not_owning_aux1;
+
+fn main() {}
--- /dev/null
+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`.
--- /dev/null
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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;
--- /dev/null
+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`.
| ^^^^^
error: expected one of `move`, `|`, or `||`, found `<eof>`
- --> <passes_ident macros>:1:22
+ --> <::edition_kw_macro_2015::passes_ident macros>:1:22
|
LL | ( $ i : ident ) => ( $ i )
| ^^^ expected one of `move`, `|`, or `||` here
| ^^^^^
error: expected one of `move`, `|`, or `||`, found `<eof>`
- --> <passes_ident macros>:1:22
+ --> <::edition_kw_macro_2018::passes_ident macros>:1:22
|
LL | ( $ i : ident ) => ( $ i )
| ^^^ expected one of `move`, `|`, or `||` here
--- /dev/null
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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() { }
--- /dev/null
+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`.
--- /dev/null
+pub trait MyTrait {}
--- /dev/null
+// 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() {}
--- /dev/null
+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`.
= note: macro-expanded macros do not shadow
error[E0659]: `panic` is ambiguous
- --> <panic macros>:1:13
+ --> <::std::macros::panic macros>:1:13
|
LL | ( ) => ( { panic ! ( "explicit panic" ) } ) ; ( $ msg : expr ) => (
| ^^^^^ ambiguous name
mod m4 {
macro_rules! m { () => {} }
use two_macros::m;
- m!(); //~ ERROR ambiguous
+ m!();
}
fn main() {}
-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
|
| ^^^^^^^^^^^^^
= 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`.
//compile-pass
+#![feature(infer_outlives_requirements)]
+
struct Foo {
bar: for<'r> Fn(usize, &'r FnMut())
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-// compile-pass
-
#![feature(rustc_attrs)]
#![allow(warnings)]
struct NestedA<'a, 'b> {
x: &'a NestedB<'b>
+ //~^ ERROR E0491
}
struct NestedB<'a> {
--- /dev/null
+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`.
--- /dev/null
+// compile-pass
+
+pub struct GstRc {
+ _obj: *const (),
+ _borrowed: bool,
+}
+
+const FOO: Option<GstRc> = None;
+
+fn main() {
+ let _meh = FOO;
+}
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> {
+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
|
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`.
#![deny(improper_ctypes)]
#![feature(libc)]
-#![allow(private_in_public)]
-
extern crate libc;
use std::marker::PhantomData;
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`
| ^^^^^^^^^^
| ^^^^^^^^^^^^^^^
= 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]`
| ^^^^^^
= 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`
| ^^^^
= help: consider using `*const u8` and a length instead
error: `extern` block uses type `std::boxed::Box<u32>` 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<u32>); //~ ERROR uses type `std::boxed::Box<u32>`
| ^^^^^^^^
= 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`
| ^^^^
= 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)`
| ^^^^^^^^^^
= 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)`
| ^^^^^^^
= 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<bool>` 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<bool>; //~ 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
| ^^^^^^
= 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
| ^^^^
= help: consider using an `extern fn(...) -> ...` function pointer instead
error: `extern` block uses type `std::boxed::Box<u32>` 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<u32>`
| ^^^^^^^^^^
= 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`
| ^^^^^^^^^^^^^^
= help: consider using `*const u8` and a length instead
error: `extern` block uses type `std::boxed::Box<u32>` 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<u32>`
| ^^^^^^^^^^^^^^^^
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)]
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
LL | ping!();
| -------- in this macro invocation
|
- ::: <ping macros>:1:1
+ ::: <::ping::ping macros>:1:1
|
LL | ( ) => { pong ! ( ) ; }
| -------------------------
LL | deep!();
| -------- in this macro invocation (#1)
|
- ::: <deep macros>:1:1
+ ::: <::ping::deep macros>:1:1
|
LL | ( ) => { foo ! ( ) ; }
| ------------------------
| | in this macro invocation (#2)
| in this expansion of `deep!` (#1)
|
- ::: <foo macros>:1:1
+ ::: <::ping::foo macros>:1:1
|
LL | ( ) => { bar ! ( ) ; }
| ------------------------
| | in this macro invocation (#3)
| in this expansion of `foo!` (#2)
|
- ::: <bar macros>:1:1
+ ::: <::ping::bar macros>:1:1
|
LL | ( ) => { ping ! ( ) ; }
| -------------------------
| | in this macro invocation (#4)
| in this expansion of `bar!` (#3)
|
- ::: <ping macros>:1:1
+ ::: <::ping::ping macros>:1:1
|
LL | ( ) => { pong ! ( ) ; }
| -------------------------
--- /dev/null
+// 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() {}
--- /dev/null
+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`.
#![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 {} }
--- /dev/null
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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();
+}
--- /dev/null
+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`.
// 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> = <T as Dummy<'a>>::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() { }
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 | 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 | RefDoubleVariant1(&'a RequireOutlives<'b, T>)
- | ^^^^^^^^^^^^^^^^^^^^^^^^^^
+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`.
//
// Rule OutlivesNominalType from RFC 1214.
-// compile-pass
-
#![feature(rustc_attrs)]
#![allow(dead_code)]
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() { }
--- /dev/null
+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`.
//
// Rule OutlivesNominalType from RFC 1214.
-// compile-pass
-
#![feature(rustc_attrs)]
#![allow(dead_code)]
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() { }
--- /dev/null
+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`.
//
// Rule OutlivesNominalType from RFC 1214.
-//compile-pass
-
#![feature(rustc_attrs)]
#![allow(dead_code)]
-mod variant_struct_type {
+mod rev_variant_struct_type {
struct Foo<T> {
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() { }
--- /dev/null
+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`.
//
// Rule OutlivesNominalType from RFC 1214.
-// compile-pass
-
#![feature(rustc_attrs)]
#![allow(dead_code)]
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() { }
--- /dev/null
+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`.
//
// Rule OutlivesNominalType from RFC 1214.
-// compile-pass
-
#![feature(rustc_attrs)]
#![allow(dead_code)]
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() { }
--- /dev/null
+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`.
//
// Rule OutlivesNominalType from RFC 1214.
-// compile-pass
-
#![feature(rustc_attrs)]
#![allow(dead_code)]
}
}
+#[rustc_error]
fn main() { }
--- /dev/null
+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`.
//
// Rule OutlivesNominalType from RFC 1214.
-// compile-pass
-
#![feature(rustc_attrs)]
#![allow(dead_code)]
}
}
+#[rustc_error]
fn main() { }
--- /dev/null
+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`.
//
// Rule OutlivesNominalType from RFC 1214.
-// compile-pass
-
#![feature(rustc_attrs)]
#![allow(dead_code)]
}
}
+#[rustc_error]
fn main() { }
--- /dev/null
+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`.
--- /dev/null
+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`.
--- /dev/null
+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`.
// Various examples of structs whose fields are not well-formed.
-#![allow(dead_code)]
+// revisions:lexical nll
-trait Trait<'a, T> {
- type Out;
-}
-trait Trait1<'a, 'b, T> {
- type Out;
-}
+#![allow(dead_code)]
+#![cfg_attr(nll, feature(nll))]
-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() { }
+++ /dev/null
-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`.
// 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>
}
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 | | }
| |_^
// 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`
*/
struct Foo<U> {
- bar: Bar<U> //~ ERROR 20:5: 20:16: the parameter type `U` may not live long enough [E0310]
+ bar: Bar<U> //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310]
}
struct Bar<T: 'static> {
x: T,
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<U> {
| - help: consider adding an explicit lifetime bound `U: 'static`...
-LL | bar: Bar<U> //~ ERROR 20:5: 20:16: the parameter type `U` may not live long enough [E0310]
+LL | bar: Bar<U> //~ 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<U> //~ ERROR 20:5: 20:16: the parameter type `U` may not live long enough [E0310]
+LL | bar: Bar<U> //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310]
| ^^^^^^^^^^^
error: aborting due to previous error
// 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<K>)
+enum Ying<'c, K> {
+ One(&'c Yang<K>) //~ ERROR the parameter type `K` may not live long enough [E0309]
}
struct Yang<V> {
-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
-
-error: rustc_outlives
- --> $DIR/enum.rs:25:1
- |
-LL | / struct Bar<'b, U> { //~ ERROR rustc_outlives
-LL | | field2: &'b U
-LL | | }
- | |_^
+note: ...so that the reference type `&'b U` does not outlive the data it points at
+ --> $DIR/enum.rs:23:5
|
- = note: U : 'b
+LL | field2: &'b U //~ ERROR the parameter type `U` may not live long enough [E0309]
+ | ^^^^^^^^^^^^^
-error: rustc_outlives
- --> $DIR/enum.rs:31:1
+error[E0309]: the parameter type `K` may not live long enough
+ --> $DIR/enum.rs:30:9
+ |
+LL | enum Ying<'c, K> {
+ | - help: consider adding an explicit lifetime bound `K: 'c`...
+LL | One(&'c Yang<K>) //~ ERROR the parameter type `K` may not live long enough [E0309]
+ | ^^^^^^^^^^^
|
-LL | / enum Ying<'c, K> { //~ ERROR rustc_outlives
-LL | | One(&'c Yang<K>)
-LL | | }
- | |_^
+note: ...so that the reference type `&'c Yang<K>` does not outlive the data it points at
+ --> $DIR/enum.rs:30:9
|
- = note: K : 'c
+LL | One(&'c Yang<K>) //~ ERROR the parameter type `K` may not live long enough [E0309]
+ | ^^^^^^^^^^^
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
+For more information about this error, try `rustc --explain E0309`.
#![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<dyn Trait<'a, A>>
}
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<dyn Trait<'a, A>>
LL | | }
// 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>)
}
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 | | }
| |_^
// except according to those terms.
#![feature(rustc_attrs)]
+#![feature(infer_outlives_requirements)]
trait Trait<'x, T> where T: 'x {
type Type;
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 | | {
// 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>
}
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 | | }
| |_^
// 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>
}
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 | | }
| |_^
// except according to those terms.
#![feature(rustc_attrs)]
+#![feature(infer_outlives_requirements)]
#![feature(infer_static_outlives_requirements)]
#[rustc_outlives]
-struct Foo<U> { //~ ERROR 15:1: 17:2: rustc_outlives
+struct Foo<U> { //~ ERROR 16:1: 18:2: rustc_outlives
bar: Bar<U>
}
struct Bar<T: 'static> {
error: rustc_outlives
- --> $DIR/infer-static.rs:15:1
+ --> $DIR/infer-static.rs:16:1
|
-LL | / struct Foo<U> { //~ ERROR 15:1: 17:2: rustc_outlives
+LL | / struct Foo<U> { //~ ERROR 16:1: 18:2: rustc_outlives
LL | | bar: Bar<U>
LL | | }
| |_^
// 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>)
}
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 | | }
// 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
}
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 | | }
| |_^
// 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>
}
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 | | }
| |_^
// 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>
}
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 | | }
| |_^
+++ /dev/null
-// Test that we do not get a privacy error here. Initially, we did,
-// because we inferred an outlives predciate of `<Foo<'a> 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 <Foo<'a> as Private>::Out>
-}
-
-trait Private {
- type Out: ?Sized;
-}
-
-impl<T: ?Sized> Private for T { type Out = Self; }
-
-fn main() { }
// except according to those terms.
#![feature(rustc_attrs)]
+#![feature(infer_outlives_requirements)]
#[rustc_outlives]
struct Foo<'a, T: Iterator> { //~ ERROR rustc_outlives
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
// except according to those terms.
#![feature(rustc_attrs)]
+#![feature(infer_outlives_requirements)]
#[rustc_outlives]
struct Foo<'a, T> { //~ ERROR rustc_outlives
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,
+++ /dev/null
-// 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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> = <T as Dummy<'a>>::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() { }
+++ /dev/null
-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`.
+++ /dev/null
-// 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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() { }
+++ /dev/null
-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`.
+++ /dev/null
-// 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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() { }
+++ /dev/null
-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`.
+++ /dev/null
-// 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T> {
- 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() { }
+++ /dev/null
-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`.
+++ /dev/null
-// 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T> {
- 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() { }
+++ /dev/null
-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`.
+++ /dev/null
-// 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 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// 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.
-
-#![allow(dead_code)]
-
-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() { }
+++ /dev/null
-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`.
#![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<dyn Trait<'a, 'b, A>>
}
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<dyn Trait<'a, 'b, A>>
LL | | }
// 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>
}
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 | | }
| |_^
// except according to those terms.
// run-pass
-// compile-flags: --extern LooksLikeExternCrate=/path/to/nowhere
+// compile-flags: --extern LooksLikeExternCrate
mod m {
pub struct LooksLikeExternCrate;
--- /dev/null
+// 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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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();
+}
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 <https://github.com/rust-lang/rust/issues/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
| ^^^^^^^^^^ 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 <https://github.com/rust-lang/rust/issues/53130>
error: aborting due to 2 previous errors
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 <https://github.com/rust-lang/rust/issues/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
| ^^^^^^^^^^^^^^^^^^^^^^^^^ 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 <https://github.com/rust-lang/rust/issues/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
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 <https://github.com/rust-lang/rust/issues/53130>
error: aborting due to 3 previous errors
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 <https://github.com/rust-lang/rust/issues/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
| ^^^^^^^^^^^^^^^^^^^ 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 <https://github.com/rust-lang/rust/issues/53130>
error: aborting due to 2 previous errors
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 <https://github.com/rust-lang/rust/issues/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
| ^^^ 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 <https://github.com/rust-lang/rust/issues/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
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 <https://github.com/rust-lang/rust/issues/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
| ^^^^^^^^ 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 <https://github.com/rust-lang/rust/issues/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
| ^ 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 <https://github.com/rust-lang/rust/issues/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
| ^^^^^^^^^^^^^^^^ 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 <https://github.com/rust-lang/rust/issues/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
| ^^^^^^^^^^ 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 <https://github.com/rust-lang/rust/issues/53130>
error: aborting due to 7 previous errors
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 <https://github.com/rust-lang/rust/issues/53130>
error: aborting due to previous error
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 <https://github.com/rust-lang/rust/issues/53130>
error: aborting due to previous error
// aux-build:remove-extern-crate.rs
// compile-flags:--extern remove_extern_crate
+#![feature(alloc)]
#![warn(rust_2018_idioms)]
#[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 {
// aux-build:remove-extern-crate.rs
// compile-flags:--extern remove_extern_crate
+#![feature(alloc)]
#![warn(rust_2018_idioms)]
extern crate core;
#[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 {
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`
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
|
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
|
// 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<T> { }
struct Foo<'a,T> {
f: &'a fn(T),
+ //~^ ERROR E0309
}
-trait Baz<T> { }
-
-impl<'a, T> Trait<'a, T> for u32 {
- type Out = &'a Baz<T>;
+struct Bar<'a,T> {
+ f: &'a Trait<T>,
+ //~^ ERROR E0309
}
+#[rustc_error]
fn main() { }
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<T>;
- | ^^^^^^^^^^^^^^^^^^^^^^
+LL | struct Bar<'a,T> {
+ | - help: consider adding an explicit lifetime bound `T: 'a`...
+LL | f: &'a Trait<T>,
+ | ^^^^^^^^^^^^^^^
|
-note: ...so that the reference type `&'a (dyn Baz<T> + '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<T> + '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<T>;
- | ^^^^^^^^^^^^^^^^^^^^^^
+LL | f: &'a Trait<T>,
+ | ^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
-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