1
Fork 0

stabalize infer outlives requirements (RFC 2093).

Co-authored-by: nikomatsakis
This commit is contained in:
toidiu 2018-08-28 00:46:08 -04:00
parent 7ee72070bd
commit 731f4efae5
138 changed files with 809 additions and 760 deletions

View file

@ -1,67 +0,0 @@
# `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
```

View file

@ -77,7 +77,6 @@
#![cfg_attr(not(test), feature(fn_traits))] #![cfg_attr(not(test), feature(fn_traits))]
#![cfg_attr(not(test), feature(generator_trait))] #![cfg_attr(not(test), feature(generator_trait))]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![cfg_attr(test, feature(test))] #![cfg_attr(test, feature(test))]
#![feature(allocator_api)] #![feature(allocator_api)]

View file

@ -17,7 +17,6 @@
#![feature(libc)] #![feature(libc)]
#![feature(linkage)] #![feature(linkage)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![cfg_attr(dummy_jemalloc, allow(dead_code, unused_extern_crates))] #![cfg_attr(dummy_jemalloc, allow(dead_code, unused_extern_crates))]

View file

@ -18,7 +18,6 @@
#![feature(allocator_api)] #![feature(allocator_api)]
#![feature(core_intrinsics)] #![feature(core_intrinsics)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![cfg_attr(any(unix, target_os = "cloudabi", target_os = "redox"), feature(libc))] #![cfg_attr(any(unix, target_os = "cloudabi", target_os = "redox"), feature(libc))]

View file

@ -27,7 +27,6 @@
#![feature(core_intrinsics)] #![feature(core_intrinsics)]
#![feature(dropck_eyepatch)] #![feature(dropck_eyepatch)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(raw_vec_internals)] #![feature(raw_vec_internals)]
#![cfg_attr(test, feature(test))] #![cfg_attr(test, feature(test))]

View file

@ -92,7 +92,6 @@
#![feature(link_llvm_intrinsics)] #![feature(link_llvm_intrinsics)]
#![feature(never_type)] #![feature(never_type)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(exhaustive_patterns)] #![feature(exhaustive_patterns)]
#![feature(macro_at_most_once_rep)] #![feature(macro_at_most_once_rep)]
#![feature(no_core)] #![feature(no_core)]

View file

@ -21,7 +21,6 @@
test(attr(deny(warnings))))] test(attr(deny(warnings))))]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
pub use self::Piece::*; pub use self::Piece::*;
pub use self::Position::*; pub use self::Position::*;

View file

@ -289,7 +289,6 @@
test(attr(allow(unused_variables), deny(warnings))))] test(attr(allow(unused_variables), deny(warnings))))]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(str_escape)] #![feature(str_escape)]
use self::LabelText::*; use self::LabelText::*;

View file

@ -25,7 +25,6 @@
#![feature(core_intrinsics)] #![feature(core_intrinsics)]
#![feature(libc)] #![feature(libc)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(panic_runtime)] #![feature(panic_runtime)]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]

View file

@ -35,7 +35,6 @@
#![feature(lang_items)] #![feature(lang_items)]
#![feature(libc)] #![feature(libc)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(panic_unwind)] #![feature(panic_unwind)]
#![feature(raw)] #![feature(raw)]
#![feature(staged_api)] #![feature(staged_api)]

View file

@ -32,7 +32,6 @@
test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))] test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(rustc_private)] #![feature(rustc_private)]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(lang_items)] #![feature(lang_items)]

View file

@ -16,5 +16,4 @@
issue = "0")] issue = "0")]
#![allow(unused_features)] #![allow(unused_features)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(staged_api)] #![feature(staged_api)]

View file

@ -1232,41 +1232,54 @@ let x: i32 = "I am not a number!";
"##, "##,
E0309: r##" E0309: r##"
Types in type definitions have lifetimes associated with them that represent The type definition contains some field whose type
how long the data stored within them is guaranteed to be live. This lifetime requires an outlives annotation. Outlives annotations
must be as long as the data needs to be alive, and missing the constraint that (e.g., `T: 'a`) are used to guarantee that all the data in T is valid
denotes this will cause this error. 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:
```compile_fail,E0309 ```compile_fail,E0309
// This won't compile because T is not constrained, meaning the data // This won't compile because the applicable impl of
// stored in it is not guaranteed to last as long as the reference // `SomeTrait` (below) requires that `T: 'a`, but the struct does
// not have a matching where-clause.
struct Foo<'a, T> { struct Foo<'a, T> {
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;
} }
``` ```
This will compile, because it has the constraint on the type parameter: 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:
``` ```
struct Foo<'a, T: 'a> { struct Foo<'a, T>
foo: &'a T where
} T: 'a,
``` {
foo: <T as SomeTrait<'a>>::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
} }
fn main() { trait SomeTrait<'a> {
let v = "42".to_string(); type Output;
let f = Foo{foo: &v}; }
drop(v);
println!("{}", f.foo); // but we've already dropped v! impl<'a, T> SomeTrait<'a> for T
where
T: 'a,
{
type Output = u32;
} }
``` ```
"##, "##,
@ -1465,30 +1478,31 @@ A reference has a longer lifetime than the data it references.
Erroneous code example: Erroneous code example:
```compile_fail,E0491 ```compile_fail,E0491
// struct containing a reference requires a lifetime parameter, trait SomeTrait<'a> {
// because the data the reference points to must outlive the struct (see E0106) type Output;
struct Struct<'a> {
ref_i32: &'a i32,
} }
// However, a nested struct like this, the signature itself does not tell impl<'a, T> SomeTrait<'a> for T {
// whether 'a outlives 'b or the other way around. type Output = &'a T; // compile error E0491
// 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
} }
``` ```
To fix this issue, you can specify a bound to the lifetime like below: 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`.
``` ```
struct Struct<'a> { trait SomeTrait<'a> {
ref_i32: &'a i32, type Output;
} }
// 'a: 'b means 'a outlives 'b impl<'a, T> SomeTrait<'a> for T
struct Nested<'a: 'b, 'b> { where
ref_struct: &'b Struct<'a>, T: 'a,
{
type Output = &'a T; // compile error E0491
} }
``` ```
"##, "##,

View file

@ -52,7 +52,6 @@
#![feature(exhaustive_patterns)] #![feature(exhaustive_patterns)]
#![feature(extern_types)] #![feature(extern_types)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(non_exhaustive)] #![feature(non_exhaustive)]
#![feature(proc_macro_internals)] #![feature(proc_macro_internals)]
#![feature(quote)] #![feature(quote)]

View file

@ -9,7 +9,6 @@
// except according to those terms. // except according to those terms.
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(rustc_private)] #![feature(rustc_private)]
#[macro_use] extern crate log; #[macro_use] extern crate log;

View file

@ -46,7 +46,6 @@
#![forbid(unsafe_code)] #![forbid(unsafe_code)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(try_from)] #![feature(try_from)]
// See librustc_cratesio_shim/Cargo.toml for a comment explaining this. // See librustc_cratesio_shim/Cargo.toml for a comment explaining this.
#[allow(unused_extern_crates)] #[allow(unused_extern_crates)]

View file

@ -11,7 +11,6 @@
#![sanitizer_runtime] #![sanitizer_runtime]
#![feature(alloc_system)] #![feature(alloc_system)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(sanitizer_runtime)] #![feature(sanitizer_runtime)]
#![feature(staged_api)] #![feature(staged_api)]
#![no_std] #![no_std]

View file

@ -15,7 +15,6 @@
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(quote)] #![feature(quote)]
#![recursion_limit="256"] #![recursion_limit="256"]

View file

@ -27,7 +27,6 @@
#![allow(unused_attributes)] #![allow(unused_attributes)]
#![feature(libc)] #![feature(libc)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(quote)] #![feature(quote)]
#![feature(range_contains)] #![feature(range_contains)]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]

View file

@ -20,7 +20,6 @@
#![feature(box_syntax)] #![feature(box_syntax)]
#![feature(custom_attribute)] #![feature(custom_attribute)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![allow(unused_attributes)] #![allow(unused_attributes)]
#![feature(quote)] #![feature(quote)]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]

View file

@ -12,7 +12,6 @@
#![allow(unused_extern_crates)] #![allow(unused_extern_crates)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
extern crate bitflags; extern crate bitflags;
extern crate log; extern crate log;

View file

@ -29,7 +29,6 @@
#![feature(optin_builtin_traits)] #![feature(optin_builtin_traits)]
#![cfg_attr(stage0, feature(macro_vis_matcher))] #![cfg_attr(stage0, feature(macro_vis_matcher))]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(allow_internal_unstable)] #![feature(allow_internal_unstable)]
#![feature(vec_resize_with)] #![feature(vec_resize_with)]

View file

@ -21,7 +21,6 @@
#![feature(box_syntax)] #![feature(box_syntax)]
#![cfg_attr(unix, feature(libc))] #![cfg_attr(unix, feature(libc))]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(option_replace)] #![feature(option_replace)]
#![feature(quote)] #![feature(quote)]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]

View file

@ -17,7 +17,6 @@
#![feature(range_contains)] #![feature(range_contains)]
#![cfg_attr(unix, feature(libc))] #![cfg_attr(unix, feature(libc))]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(optin_builtin_traits)] #![feature(optin_builtin_traits)]
extern crate atty; extern crate atty;

View file

@ -15,7 +15,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(specialization)] #![feature(specialization)]
#![recursion_limit="256"] #![recursion_limit="256"]

View file

@ -28,7 +28,6 @@
#![feature(box_syntax)] #![feature(box_syntax)]
#![cfg_attr(stage0, feature(macro_vis_matcher))] #![cfg_attr(stage0, feature(macro_vis_matcher))]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(quote)] #![feature(quote)]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]
#![feature(macro_at_most_once_rep)] #![feature(macro_at_most_once_rep)]

View file

@ -9,7 +9,6 @@
// except according to those terms. // except according to those terms.
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(static_nobundle)] #![feature(static_nobundle)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",

View file

@ -11,7 +11,6 @@
#![sanitizer_runtime] #![sanitizer_runtime]
#![feature(alloc_system)] #![feature(alloc_system)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(sanitizer_runtime)] #![feature(sanitizer_runtime)]
#![feature(staged_api)] #![feature(staged_api)]
#![no_std] #![no_std]

View file

@ -16,7 +16,6 @@
#![feature(libc)] #![feature(libc)]
#![feature(macro_at_most_once_rep)] #![feature(macro_at_most_once_rep)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(proc_macro_internals)] #![feature(proc_macro_internals)]
#![feature(proc_macro_quote)] #![feature(proc_macro_quote)]
#![feature(quote)] #![feature(quote)]

View file

@ -15,7 +15,6 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
*/ */
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(in_band_lifetimes)] #![feature(in_band_lifetimes)]
#![feature(impl_header_lifetime_elision)] #![feature(impl_header_lifetime_elision)]
#![feature(slice_patterns)] #![feature(slice_patterns)]

View file

@ -11,7 +11,6 @@
#![sanitizer_runtime] #![sanitizer_runtime]
#![feature(alloc_system)] #![feature(alloc_system)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(sanitizer_runtime)] #![feature(sanitizer_runtime)]
#![feature(staged_api)] #![feature(staged_api)]
#![no_std] #![no_std]

View file

@ -19,7 +19,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]
#[macro_use] #[macro_use]

View file

@ -11,7 +11,6 @@
#![allow(nonstandard_style)] #![allow(nonstandard_style)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
pub struct Intrinsic { pub struct Intrinsic {
pub inputs: &'static [&'static Type], pub inputs: &'static [&'static Type],

View file

@ -65,7 +65,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]
#[macro_use] extern crate syntax; #[macro_use] extern crate syntax;

View file

@ -13,7 +13,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]
#![recursion_limit="256"] #![recursion_limit="256"]
@ -1381,7 +1380,13 @@ impl<'a, 'tcx: 'a> SearchInterfaceForPrivateItemsVisitor<'a, 'tcx> {
} }
fn predicates(&mut self) -> &mut Self { fn predicates(&mut self) -> &mut Self {
let predicates = self.tcx.predicates_of(self.item_def_id); // 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);
for predicate in &predicates.predicates { for predicate in &predicates.predicates {
predicate.visit_with(self); predicate.visit_with(self);
match predicate { match predicate {

View file

@ -14,7 +14,6 @@
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]
#![feature(slice_sort_by_cached_key)] #![feature(slice_sort_by_cached_key)]

View file

@ -13,7 +13,6 @@
html_root_url = "https://doc.rust-lang.org/nightly/")] html_root_url = "https://doc.rust-lang.org/nightly/")]
#![feature(custom_attribute)] #![feature(custom_attribute)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![allow(unused_attributes)] #![allow(unused_attributes)]
#![recursion_limit="256"] #![recursion_limit="256"]

View file

@ -25,7 +25,6 @@
#![cfg_attr(stage0, feature(const_fn))] #![cfg_attr(stage0, feature(const_fn))]
#![cfg_attr(not(stage0), feature(min_const_fn))] #![cfg_attr(not(stage0), feature(min_const_fn))]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(slice_patterns)] #![feature(slice_patterns)]
#[macro_use] #[macro_use]

View file

@ -16,7 +16,6 @@
#![feature(extern_prelude)] #![feature(extern_prelude)]
#![feature(in_band_lifetimes)] #![feature(in_band_lifetimes)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![recursion_limit="256"] #![recursion_limit="256"]

View file

@ -11,7 +11,6 @@
#![sanitizer_runtime] #![sanitizer_runtime]
#![feature(alloc_system)] #![feature(alloc_system)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(sanitizer_runtime)] #![feature(sanitizer_runtime)]
#![feature(staged_api)] #![feature(staged_api)]
#![no_std] #![no_std]

View file

@ -1578,14 +1578,10 @@ fn predicates_defined_on<'a, 'tcx>(
def_id: DefId, def_id: DefId,
) -> ty::GenericPredicates<'tcx> { ) -> ty::GenericPredicates<'tcx> {
let explicit = tcx.explicit_predicates_of(def_id); let explicit = tcx.explicit_predicates_of(def_id);
let predicates = if tcx.sess.features_untracked().infer_outlives_requirements { let predicates = [
[
&explicit.predicates[..], &explicit.predicates[..],
&tcx.inferred_outlives_of(def_id)[..], &tcx.inferred_outlives_of(def_id)[..],
].concat() ].concat();
} else {
explicit.predicates
};
ty::GenericPredicates { ty::GenericPredicates {
parent: explicit.parent, parent: explicit.parent,

View file

@ -76,7 +76,6 @@ This API is completely unstable and subject to change.
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]
#![feature(exhaustive_patterns)] #![feature(exhaustive_patterns)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(quote)] #![feature(quote)]
#![feature(refcell_replace_swap)] #![feature(refcell_replace_swap)]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]

View file

@ -66,7 +66,8 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> {
debug!("InferVisitor::visit_item(item={:?})", item_did); debug!("InferVisitor::visit_item(item={:?})", item_did);
let node_id = self.tcx let node_id = self
.tcx
.hir .hir
.as_local_node_id(item_did) .as_local_node_id(item_did)
.expect("expected local def-id"); .expect("expected local def-id");
@ -108,7 +109,8 @@ impl<'cx, 'tcx> ItemLikeVisitor<'tcx> for InferVisitor<'cx, 'tcx> {
// Therefore mark `predicates_added` as true and which will ensure // Therefore mark `predicates_added` as true and which will ensure
// we walk the crates again and re-calculate predicates for all // we walk the crates again and re-calculate predicates for all
// items. // items.
let item_predicates_len: usize = self.global_inferred_outlives let item_predicates_len: usize = self
.global_inferred_outlives
.get(&item_did) .get(&item_did)
.map(|p| p.len()) .map(|p| p.len())
.unwrap_or(0); .unwrap_or(0);

View file

@ -17,7 +17,6 @@
#![feature(box_patterns)] #![feature(box_patterns)]
#![feature(box_syntax)] #![feature(box_syntax)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(set_stdio)] #![feature(set_stdio)]
#![feature(slice_sort_by_cached_key)] #![feature(slice_sort_by_cached_key)]
#![feature(test)] #![feature(test)]

View file

@ -25,7 +25,6 @@ Core encoding and decoding interfaces.
#![feature(specialization)] #![feature(specialization)]
#![feature(never_type)] #![feature(never_type)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![cfg_attr(test, feature(test))] #![cfg_attr(test, feature(test))]
pub use self::serialize::{Decoder, Encoder, Decodable, Encodable}; pub use self::serialize::{Decoder, Encoder, Decodable, Encodable};

View file

@ -274,7 +274,6 @@
#![feature(needs_panic_runtime)] #![feature(needs_panic_runtime)]
#![feature(never_type)] #![feature(never_type)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(exhaustive_patterns)] #![feature(exhaustive_patterns)]
#![feature(on_unimplemented)] #![feature(on_unimplemented)]
#![feature(optin_builtin_traits)] #![feature(optin_builtin_traits)]

View file

@ -415,9 +415,6 @@ declare_features! (
// Use `?` as the Kleene "at most one" operator // Use `?` as the Kleene "at most one" operator
(active, macro_at_most_once_rep, "1.25.0", Some(48075), None), (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 // Infer static outlives requirements; RFC 2093
(active, infer_static_outlives_requirements, "1.26.0", Some(44493), None), (active, infer_static_outlives_requirements, "1.26.0", Some(44493), None),
@ -673,6 +670,8 @@ declare_features! (
(accepted, proc_macro_path_invoc, "1.30.0", Some(38356), None), (accepted, proc_macro_path_invoc, "1.30.0", Some(38356), None),
// Allows all literals in attribute lists and values of key-value pairs. // Allows all literals in attribute lists and values of key-value pairs.
(accepted, attr_literals, "1.30.0", Some(34981), None), (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), (accepted, panic_handler, "1.30.0", Some(44489), None),
// Used to preserve symbols (see llvm.used) // Used to preserve symbols (see llvm.used)
(accepted, used, "1.30.0", Some(40289), None), (accepted, used, "1.30.0", Some(40289), None),
@ -1125,12 +1124,6 @@ pub const BUILTIN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeG
"never will be stable", "never will be stable",
cfg_fn!(rustc_attrs))), 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 // RFC #2093
("infer_static_outlives_requirements", Normal, Gated(Stability::Unstable, ("infer_static_outlives_requirements", Normal, Gated(Stability::Unstable,
"infer_static_outlives_requirements", "infer_static_outlives_requirements",

View file

@ -22,7 +22,6 @@
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]
#![feature(macro_at_most_once_rep)] #![feature(macro_at_most_once_rep)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]
#![feature(slice_sort_by_cached_key)] #![feature(slice_sort_by_cached_key)]

View file

@ -17,7 +17,6 @@
#![feature(proc_macro_internals)] #![feature(proc_macro_internals)]
#![feature(decl_macro)] #![feature(decl_macro)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(str_escape)] #![feature(str_escape)]
#![feature(quote)] #![feature(quote)]
#![feature(rustc_diagnostic_macros)] #![feature(rustc_diagnostic_macros)]

View file

@ -22,7 +22,6 @@
#![feature(crate_visibility_modifier)] #![feature(crate_visibility_modifier)]
#![feature(custom_attribute)] #![feature(custom_attribute)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(non_exhaustive)] #![feature(non_exhaustive)]
#![feature(optin_builtin_traits)] #![feature(optin_builtin_traits)]
#![feature(specialization)] #![feature(specialization)]

View file

@ -51,7 +51,6 @@
// Handle rustfmt skips // Handle rustfmt skips
#![feature(custom_attribute)] #![feature(custom_attribute)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![allow(unused_attributes)] #![allow(unused_attributes)]
use std::io::prelude::*; use std::io::prelude::*;

View file

@ -36,7 +36,6 @@
#![feature(fnbox)] #![feature(fnbox)]
#![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc))] #![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc))]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(set_stdio)] #![feature(set_stdio)]
#![feature(panic_unwind)] #![feature(panic_unwind)]
#![feature(staged_api)] #![feature(staged_api)]

View file

@ -14,7 +14,6 @@
#![feature(cfg_target_vendor)] #![feature(cfg_target_vendor)]
#![feature(link_cfg)] #![feature(link_cfg)]
#![cfg_attr(not(stage0), feature(nll))] #![cfg_attr(not(stage0), feature(nll))]
#![cfg_attr(not(stage0), feature(infer_outlives_requirements))]
#![feature(staged_api)] #![feature(staged_api)]
#![feature(unwind_attributes)] #![feature(unwind_attributes)]
#![feature(static_nobundle)] #![feature(static_nobundle)]

View file

@ -13,8 +13,6 @@
// Regression test that `infer_outlives_predicates` can be // Regression test that `infer_outlives_predicates` can be
// used with incremental without an ICE. // used with incremental without an ICE.
#![feature(infer_outlives_requirements)]
struct Foo<'a, T> { struct Foo<'a, T> {
x: &'a T x: &'a T
} }

View file

@ -88,7 +88,6 @@ mod invalid_signatures {
} }
#[rustc_then_this_would_need(FnSignature)] //~ ERROR no path #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path
#[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path
fn b(x: WontChange) { } fn b(x: WontChange) { }
#[rustc_then_this_would_need(FnSignature)] //~ ERROR no path from `WillChange` #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path from `WillChange`

View file

@ -82,20 +82,14 @@ error: no path from `WillChange` to `FnSignature`
LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path 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` error: no path from `WillChange` to `FnSignature`
--> $DIR/dep-graph-struct-signature.rs:94:5 --> $DIR/dep-graph-struct-signature.rs:93:5
| |
LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path from `WillChange` LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path from `WillChange`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: no path from `WillChange` to `TypeckTables` error: no path from `WillChange` to `TypeckTables`
--> $DIR/dep-graph-struct-signature.rs:95:5 --> $DIR/dep-graph-struct-signature.rs:94:5
| |
LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path from `WillChange` LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path from `WillChange`
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -136,5 +130,5 @@ error: OK
LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR OK
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 23 previous errors error: aborting due to 22 previous errors

View file

@ -1,18 +0,0 @@
// 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() { }

View file

@ -1,17 +0,0 @@
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`.

View file

@ -10,8 +10,6 @@
//compile-pass //compile-pass
#![feature(infer_outlives_requirements)]
struct Foo { struct Foo {
bar: for<'r> Fn(usize, &'r FnMut()) bar: for<'r> Fn(usize, &'r FnMut())
} }

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// compile-pass
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![allow(warnings)] #![allow(warnings)]
@ -17,7 +19,6 @@ struct Point {
struct NestedA<'a, 'b> { struct NestedA<'a, 'b> {
x: &'a NestedB<'b> x: &'a NestedB<'b>
//~^ ERROR E0491
} }
struct NestedB<'a> { struct NestedB<'a> {

View file

@ -1,20 +0,0 @@
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`.

View file

@ -14,9 +14,9 @@ trait ListItem<'a> {
trait Collection { fn len(&self) -> usize; } trait Collection { fn len(&self) -> usize; }
// is now well formed. RFC 2093
struct List<'a, T: ListItem<'a>> { struct List<'a, T: ListItem<'a>> {
slice: &'a [T] slice: &'a [T]
//~^ ERROR may not live long enough
} }
impl<'a, T: ListItem<'a>> Collection for List<'a, T> { impl<'a, T: ListItem<'a>> Collection for List<'a, T> {

View file

@ -1,17 +1,3 @@
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 error[E0310]: the parameter type `T` may not live long enough
--> $DIR/lifetime-doesnt-live-long-enough.rs:29:5 --> $DIR/lifetime-doesnt-live-long-enough.rs:29:5
| |
@ -109,7 +95,7 @@ LL | | //~^ ERROR may not live long enough
LL | | } LL | | }
| |_____^ | |_____^
error: aborting due to 7 previous errors error: aborting due to 6 previous errors
Some errors occurred: E0309, E0310. Some errors occurred: E0309, E0310.
For more information about an error, try `rustc --explain E0309`. For more information about an error, try `rustc --explain E0309`.

View file

@ -11,6 +11,8 @@
#![deny(improper_ctypes)] #![deny(improper_ctypes)]
#![feature(libc)] #![feature(libc)]
#![allow(private_in_public)]
extern crate libc; extern crate libc;
use std::marker::PhantomData; use std::marker::PhantomData;

View file

@ -1,5 +1,5 @@
error: `extern` block uses type `Foo` which is not FFI-safe: this struct has unspecified layout error: `extern` block uses type `Foo` which is not FFI-safe: this struct has unspecified layout
--> $DIR/lint-ctypes.rs:54:28 --> $DIR/lint-ctypes.rs:56:28
| |
LL | pub fn ptr_type1(size: *const Foo); //~ ERROR: uses type `Foo` LL | pub fn ptr_type1(size: *const Foo); //~ ERROR: uses type `Foo`
| ^^^^^^^^^^ | ^^^^^^^^^^
@ -11,26 +11,26 @@ LL | #![deny(improper_ctypes)]
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
= help: consider adding a #[repr(C)] or #[repr(transparent)] attribute to this struct = help: consider adding a #[repr(C)] or #[repr(transparent)] attribute to this struct
note: type defined here note: type defined here
--> $DIR/lint-ctypes.rs:32:1 --> $DIR/lint-ctypes.rs:34:1
| |
LL | pub struct Foo; LL | pub struct Foo;
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
error: `extern` block uses type `Foo` which is not FFI-safe: this struct has unspecified layout error: `extern` block uses type `Foo` which is not FFI-safe: this struct has unspecified layout
--> $DIR/lint-ctypes.rs:55:28 --> $DIR/lint-ctypes.rs:57:28
| |
LL | pub fn ptr_type2(size: *const Foo); //~ ERROR: uses type `Foo` 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 = help: consider adding a #[repr(C)] or #[repr(transparent)] attribute to this struct
note: type defined here note: type defined here
--> $DIR/lint-ctypes.rs:32:1 --> $DIR/lint-ctypes.rs:34:1
| |
LL | pub struct Foo; LL | pub struct Foo;
| ^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^
error: `extern` block uses type `[u32]` which is not FFI-safe: slices have no C equivalent error: `extern` block uses type `[u32]` which is not FFI-safe: slices have no C equivalent
--> $DIR/lint-ctypes.rs:56:26 --> $DIR/lint-ctypes.rs:58:26
| |
LL | pub fn slice_type(p: &[u32]); //~ ERROR: uses type `[u32]` LL | pub fn slice_type(p: &[u32]); //~ ERROR: uses type `[u32]`
| ^^^^^^ | ^^^^^^
@ -38,7 +38,7 @@ LL | pub fn slice_type(p: &[u32]); //~ ERROR: uses type `[u32]`
= help: consider using a raw pointer instead = help: consider using a raw pointer instead
error: `extern` block uses type `str` which is not FFI-safe: string slices have no C equivalent error: `extern` block uses type `str` which is not FFI-safe: string slices have no C equivalent
--> $DIR/lint-ctypes.rs:57:24 --> $DIR/lint-ctypes.rs:59:24
| |
LL | pub fn str_type(p: &str); //~ ERROR: uses type `str` LL | pub fn str_type(p: &str); //~ ERROR: uses type `str`
| ^^^^ | ^^^^
@ -46,7 +46,7 @@ LL | pub fn str_type(p: &str); //~ ERROR: uses type `str`
= help: consider using `*const u8` and a length instead = 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 error: `extern` block uses type `std::boxed::Box<u32>` which is not FFI-safe: this struct has unspecified layout
--> $DIR/lint-ctypes.rs:58:24 --> $DIR/lint-ctypes.rs:60:24
| |
LL | pub fn box_type(p: Box<u32>); //~ ERROR uses type `std::boxed::Box<u32>` LL | pub fn box_type(p: Box<u32>); //~ ERROR uses type `std::boxed::Box<u32>`
| ^^^^^^^^ | ^^^^^^^^
@ -54,7 +54,7 @@ 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 = 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 error: `extern` block uses type `char` which is not FFI-safe: the `char` type has no C equivalent
--> $DIR/lint-ctypes.rs:59:25 --> $DIR/lint-ctypes.rs:61:25
| |
LL | pub fn char_type(p: char); //~ ERROR uses type `char` LL | pub fn char_type(p: char); //~ ERROR uses type `char`
| ^^^^ | ^^^^
@ -62,25 +62,25 @@ LL | pub fn char_type(p: char); //~ ERROR uses type `char`
= help: consider using `u32` or `libc::wchar_t` instead = 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 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:60:25 --> $DIR/lint-ctypes.rs:62:25
| |
LL | pub fn i128_type(p: i128); //~ ERROR uses type `i128` 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 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:61:25 --> $DIR/lint-ctypes.rs:63:25
| |
LL | pub fn u128_type(p: u128); //~ ERROR uses type `u128` 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 error: `extern` block uses type `dyn std::clone::Clone` which is not FFI-safe: trait objects have no C equivalent
--> $DIR/lint-ctypes.rs:62:26 --> $DIR/lint-ctypes.rs:64:26
| |
LL | pub fn trait_type(p: &Clone); //~ ERROR uses type `dyn std::clone::Clone` 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 error: `extern` block uses type `(i32, i32)` which is not FFI-safe: tuples have unspecified layout
--> $DIR/lint-ctypes.rs:63:26 --> $DIR/lint-ctypes.rs:65:26
| |
LL | pub fn tuple_type(p: (i32, i32)); //~ ERROR uses type `(i32, i32)` LL | pub fn tuple_type(p: (i32, i32)); //~ ERROR uses type `(i32, i32)`
| ^^^^^^^^^^ | ^^^^^^^^^^
@ -88,7 +88,7 @@ LL | pub fn tuple_type(p: (i32, i32)); //~ ERROR uses type `(i32, i32)`
= help: consider using a struct instead = help: consider using a struct instead
error: `extern` block uses type `(i32, i32)` which is not FFI-safe: tuples have unspecified layout error: `extern` block uses type `(i32, i32)` which is not FFI-safe: tuples have unspecified layout
--> $DIR/lint-ctypes.rs:64:27 --> $DIR/lint-ctypes.rs:66:27
| |
LL | pub fn tuple_type2(p: I32Pair); //~ ERROR uses type `(i32, i32)` LL | pub fn tuple_type2(p: I32Pair); //~ ERROR uses type `(i32, i32)`
| ^^^^^^^ | ^^^^^^^
@ -96,32 +96,32 @@ LL | pub fn tuple_type2(p: I32Pair); //~ ERROR uses type `(i32, i32)`
= help: consider using a struct instead = help: consider using a struct instead
error: `extern` block uses type `ZeroSize` which is not FFI-safe: this struct has no fields error: `extern` block uses type `ZeroSize` which is not FFI-safe: this struct has no fields
--> $DIR/lint-ctypes.rs:65:25 --> $DIR/lint-ctypes.rs:67:25
| |
LL | pub fn zero_size(p: ZeroSize); //~ ERROR struct has no fields LL | pub fn zero_size(p: ZeroSize); //~ ERROR struct has no fields
| ^^^^^^^^ | ^^^^^^^^
| |
= help: consider adding a member to this struct = help: consider adding a member to this struct
note: type defined here note: type defined here
--> $DIR/lint-ctypes.rs:28:1 --> $DIR/lint-ctypes.rs:30:1
| |
LL | pub struct ZeroSize; LL | pub struct ZeroSize;
| ^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^
error: `extern` block uses type `ZeroSizeWithPhantomData` which is not FFI-safe: composed only of PhantomData error: `extern` block uses type `ZeroSizeWithPhantomData` which is not FFI-safe: composed only of PhantomData
--> $DIR/lint-ctypes.rs:66:33 --> $DIR/lint-ctypes.rs:68:33
| |
LL | pub fn zero_size_phantom(p: ZeroSizeWithPhantomData); //~ ERROR composed only of PhantomData 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 error: `extern` block uses type `std::marker::PhantomData<bool>` which is not FFI-safe: composed only of PhantomData
--> $DIR/lint-ctypes.rs:68:12 --> $DIR/lint-ctypes.rs:70:12
| |
LL | -> ::std::marker::PhantomData<bool>; //~ ERROR: composed only of PhantomData 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 error: `extern` block uses type `fn()` which is not FFI-safe: this function pointer has Rust-specific calling convention
--> $DIR/lint-ctypes.rs:69:23 --> $DIR/lint-ctypes.rs:71:23
| |
LL | pub fn fn_type(p: RustFn); //~ ERROR function pointer has Rust-specific LL | pub fn fn_type(p: RustFn); //~ ERROR function pointer has Rust-specific
| ^^^^^^ | ^^^^^^
@ -129,7 +129,7 @@ LL | pub fn fn_type(p: RustFn); //~ ERROR function pointer has Rust-specific
= help: consider using an `extern fn(...) -> ...` function pointer instead = 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 error: `extern` block uses type `fn()` which is not FFI-safe: this function pointer has Rust-specific calling convention
--> $DIR/lint-ctypes.rs:70:24 --> $DIR/lint-ctypes.rs:72:24
| |
LL | pub fn fn_type2(p: fn()); //~ ERROR function pointer has Rust-specific LL | pub fn fn_type2(p: fn()); //~ ERROR function pointer has Rust-specific
| ^^^^ | ^^^^
@ -137,7 +137,7 @@ LL | pub fn fn_type2(p: fn()); //~ ERROR function pointer has Rust-specific
= help: consider using an `extern fn(...) -> ...` function pointer instead = 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 error: `extern` block uses type `std::boxed::Box<u32>` which is not FFI-safe: this struct has unspecified layout
--> $DIR/lint-ctypes.rs:71:28 --> $DIR/lint-ctypes.rs:73:28
| |
LL | pub fn fn_contained(p: RustBadRet); //~ ERROR: uses type `std::boxed::Box<u32>` LL | pub fn fn_contained(p: RustBadRet); //~ ERROR: uses type `std::boxed::Box<u32>`
| ^^^^^^^^^^ | ^^^^^^^^^^
@ -145,13 +145,13 @@ LL | pub fn fn_contained(p: RustBadRet); //~ ERROR: uses type `std::boxed::B
= help: consider adding a #[repr(C)] or #[repr(transparent)] attribute to this struct = 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 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:72:32 --> $DIR/lint-ctypes.rs:74:32
| |
LL | pub fn transparent_i128(p: TransparentI128); //~ ERROR: uses type `i128` 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 error: `extern` block uses type `str` which is not FFI-safe: string slices have no C equivalent
--> $DIR/lint-ctypes.rs:73:31 --> $DIR/lint-ctypes.rs:75:31
| |
LL | pub fn transparent_str(p: TransparentStr); //~ ERROR: uses type `str` LL | pub fn transparent_str(p: TransparentStr); //~ ERROR: uses type `str`
| ^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^
@ -159,7 +159,7 @@ LL | pub fn transparent_str(p: TransparentStr); //~ ERROR: uses type `str`
= help: consider using `*const u8` and a length instead = 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 error: `extern` block uses type `std::boxed::Box<u32>` which is not FFI-safe: this struct has unspecified layout
--> $DIR/lint-ctypes.rs:74:30 --> $DIR/lint-ctypes.rs:76:30
| |
LL | pub fn transparent_fn(p: TransparentBadFn); //~ ERROR: uses type `std::boxed::Box<u32>` LL | pub fn transparent_fn(p: TransparentBadFn); //~ ERROR: uses type `std::boxed::Box<u32>`
| ^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^

View file

@ -15,10 +15,12 @@
#![feature(lang_items, box_syntax)] #![feature(lang_items, box_syntax)]
#![no_std] #![no_std]
use core::panic::PanicInfo;
fn main() { fn main() {
let x = box 1i32; let x = box 1i32;
} }
#[lang = "eh_personality"] extern fn eh_personality() {} #[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "eh_unwind_resume"] extern fn eh_unwind_resume() {} #[lang = "eh_unwind_resume"] extern fn eh_unwind_resume() {}
#[lang = "panic_impl"] fn panic_impl() -> ! { loop {} } #[lang = "panic_impl"] fn panic_impl(panic: &PanicInfo) -> ! { loop {} }

View file

@ -8,31 +8,43 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
// ignore-tidy-linelength
// Various examples of structs whose fields are not well-formed. // Various examples of structs whose fields are not well-formed.
#![allow(dead_code)] #![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> { enum Ref1<'a, T> {
Ref1Variant1(&'a T) //~ ERROR the parameter type `T` may not live long enough Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough
} }
enum Ref2<'a, T> { enum Ref2<'a, T> {
Ref2Variant1, Ref2Variant1,
Ref2Variant2(isize, &'a T), //~ ERROR the parameter type `T` may not live long enough Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough
} }
enum RefOk<'a, T:'a> { enum RefOk<'a, T:'a> {
RefOkVariant1(&'a T) RefOkVariant1(&'a T)
} }
// This is now well formed. RFC 2093
enum RefIndirect<'a, T> { enum RefIndirect<'a, T> {
RefIndirectVariant1(isize, RefOk<'a,T>) RefIndirectVariant1(isize, RefOk<'a,T>)
//~^ ERROR the parameter type `T` may not live long enough
} }
enum RefDouble<'a, 'b, T> { enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309]
RefDoubleVariant1(&'a &'b T) RefDoubleVariant1(&'a RequireOutlives<'b, T>)
//~^ ERROR reference has a longer lifetime than the data //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309]
} }
fn main() { } fn main() { }

View file

@ -1,64 +1,67 @@
error[E0309]: 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:16:18 --> $DIR/regions-enum-not-wf.rs:28:18
| |
LL | enum Ref1<'a, T> { LL | enum Ref1<'a, T> {
| - help: consider adding an explicit lifetime bound `T: 'a`... | - help: consider adding an explicit lifetime bound `T: 'a`...
LL | Ref1Variant1(&'a T) //~ ERROR the parameter type `T` may not live long enough LL | Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough
| ^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
| |
note: ...so that the reference type `&'a T` does not outlive the data it points at note: ...so that the type `T` will meet its required lifetime bounds
--> $DIR/regions-enum-not-wf.rs:16:18 --> $DIR/regions-enum-not-wf.rs:28:18
| |
LL | Ref1Variant1(&'a T) //~ ERROR the parameter type `T` may not live long enough 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 error[E0309]: the parameter type `T` may not live long enough
--> $DIR/regions-enum-not-wf.rs:21:25 --> $DIR/regions-enum-not-wf.rs:33:25
| |
LL | enum Ref2<'a, T> { LL | enum Ref2<'a, T> {
| - help: consider adding an explicit lifetime bound `T: 'a`... | - help: consider adding an explicit lifetime bound `T: 'a`...
LL | Ref2Variant1, LL | Ref2Variant1,
LL | Ref2Variant2(isize, &'a T), //~ ERROR the parameter type `T` may not live long enough LL | Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough
| ^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
|
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, &'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:29:32
|
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 note: ...so that the type `T` will meet its required lifetime bounds
--> $DIR/regions-enum-not-wf.rs:29:32 --> $DIR/regions-enum-not-wf.rs:33:25
| |
LL | RefIndirectVariant1(isize, RefOk<'a,T>) LL | Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough
| ^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^
error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references error[E0309]: the parameter type `T` may not live long enough
--> $DIR/regions-enum-not-wf.rs:34:23 --> $DIR/regions-enum-not-wf.rs:45:1
| |
LL | RefDoubleVariant1(&'a &'b T) 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: the pointer is valid for the lifetime 'a as defined on the enum at 33:16 note: ...so that the type `T` will meet its required lifetime bounds
--> $DIR/regions-enum-not-wf.rs:33:16 --> $DIR/regions-enum-not-wf.rs:45:1
| |
LL | enum RefDouble<'a, 'b, T> { 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>)
note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 33:20 LL | | //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309]
--> $DIR/regions-enum-not-wf.rs:33:20 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> { 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 error: aborting due to 4 previous errors
Some errors occurred: E0309, E0491. For more information about this error, try `rustc --explain E0309`.
For more information about an error, try `rustc --explain E0309`.

View file

@ -13,6 +13,8 @@
// //
// Rule OutlivesNominalType from RFC 1214. // Rule OutlivesNominalType from RFC 1214.
// compile-pass
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![allow(dead_code)] #![allow(dead_code)]
@ -21,9 +23,8 @@ mod rev_variant_struct_region {
x: fn(&'a i32), x: fn(&'a i32),
} }
enum Bar<'a,'b> { enum Bar<'a,'b> {
V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime V(&'a Foo<'b>)
} }
} }
#[rustc_error]
fn main() { } fn main() { }

View file

@ -1,20 +0,0 @@
error[E0491]: in type `&'a rev_variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references
--> $DIR/regions-outlives-nominal-type-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`.

View file

@ -13,6 +13,8 @@
// //
// Rule OutlivesNominalType from RFC 1214. // Rule OutlivesNominalType from RFC 1214.
// compile-pass
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![allow(dead_code)] #![allow(dead_code)]
@ -21,9 +23,8 @@ mod variant_struct_region {
x: &'a i32, x: &'a i32,
} }
enum Bar<'a,'b> { enum Bar<'a,'b> {
V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime V(&'a Foo<'b>)
} }
} }
#[rustc_error]
fn main() { } fn main() { }

View file

@ -1,20 +0,0 @@
error[E0491]: in type `&'a variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references
--> $DIR/regions-outlives-nominal-type-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`.

View file

@ -13,17 +13,18 @@
// //
// Rule OutlivesNominalType from RFC 1214. // Rule OutlivesNominalType from RFC 1214.
//compile-pass
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![allow(dead_code)] #![allow(dead_code)]
mod rev_variant_struct_type { mod variant_struct_type {
struct Foo<T> { struct Foo<T> {
x: fn(T) x: fn(T)
} }
enum Bar<'a,'b> { enum Bar<'a,'b> {
V(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime V(&'a Foo<&'b i32>)
} }
} }
#[rustc_error]
fn main() { } fn main() { }

View file

@ -1,20 +0,0 @@
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`.

View file

@ -13,6 +13,8 @@
// //
// Rule OutlivesNominalType from RFC 1214. // Rule OutlivesNominalType from RFC 1214.
// compile-pass
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![allow(dead_code)] #![allow(dead_code)]
@ -21,9 +23,8 @@ mod variant_struct_type {
x: T x: T
} }
enum Bar<'a,'b> { enum Bar<'a,'b> {
F(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime V(&'a Foo<&'b i32>)
} }
} }
#[rustc_error]
fn main() { } fn main() { }

View file

@ -1,20 +0,0 @@
error[E0491]: in type `&'a variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references
--> $DIR/regions-outlives-nominal-type-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`.

View file

@ -13,6 +13,8 @@
// //
// Rule OutlivesNominalType from RFC 1214. // Rule OutlivesNominalType from RFC 1214.
// compile-pass
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![allow(dead_code)] #![allow(dead_code)]
@ -21,9 +23,8 @@ mod rev_variant_struct_region {
x: fn(&'a i32), x: fn(&'a i32),
} }
struct Bar<'a,'b> { struct Bar<'a,'b> {
f: &'a Foo<'b> //~ ERROR reference has a longer lifetime f: &'a Foo<'b>
} }
} }
#[rustc_error]
fn main() { } fn main() { }

View file

@ -1,20 +0,0 @@
error[E0491]: in type `&'a rev_variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references
--> $DIR/regions-outlives-nominal-type-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`.

View file

@ -13,6 +13,8 @@
// //
// Rule OutlivesNominalType from RFC 1214. // Rule OutlivesNominalType from RFC 1214.
// compile-pass
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![allow(dead_code)] #![allow(dead_code)]
@ -25,5 +27,4 @@ mod variant_struct_region {
} }
} }
#[rustc_error]
fn main() { } fn main() { }

View file

@ -1,20 +0,0 @@
error[E0491]: in type `&'a variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references
--> $DIR/regions-outlives-nominal-type-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`.

View file

@ -13,6 +13,8 @@
// //
// Rule OutlivesNominalType from RFC 1214. // Rule OutlivesNominalType from RFC 1214.
// compile-pass
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![allow(dead_code)] #![allow(dead_code)]
@ -25,5 +27,4 @@ mod rev_variant_struct_type {
} }
} }
#[rustc_error]
fn main() { } fn main() { }

View file

@ -1,20 +0,0 @@
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`.

View file

@ -13,6 +13,8 @@
// //
// Rule OutlivesNominalType from RFC 1214. // Rule OutlivesNominalType from RFC 1214.
// compile-pass
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![allow(dead_code)] #![allow(dead_code)]
@ -25,5 +27,4 @@ mod variant_struct_type {
} }
} }
#[rustc_error]
fn main() { } fn main() { }

View file

@ -1,20 +0,0 @@
error[E0491]: in type `&'a variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references
--> $DIR/regions-outlives-nominal-type-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`.

View file

@ -1,49 +0,0 @@
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`.

View file

@ -1,49 +0,0 @@
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`.

View file

@ -10,31 +10,29 @@
// Various examples of structs whose fields are not well-formed. // Various examples of structs whose fields are not well-formed.
// revisions:lexical nll
#![allow(dead_code)] #![allow(dead_code)]
#![cfg_attr(nll, feature(nll))]
struct Ref<'a, T> { trait Trait<'a, T> {
field: &'a T type Out;
//[lexical]~^ ERROR the parameter type `T` may not live long enough }
//[nll]~^^ ERROR the parameter type `T` may not live long enough trait Trait1<'a, 'b, T> {
type Out;
}
impl<'a, T> Trait<'a, T> for usize {
type Out = &'a T;
} }
struct RefOk<'a, T:'a> { struct RefOk<'a, T:'a> {
field: &'a T field: &'a T
} }
struct RefIndirect<'a, T> { impl<'a, T> Trait<'a, T> for u32 {
field: RefOk<'a, T> type Out = 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
} }
struct DoubleRef<'a, 'b, T> { impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 {
field: &'a &'b T type Out = &'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() { } fn main() { }

View file

@ -0,0 +1,49 @@
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`.

View file

@ -9,10 +9,9 @@
// except according to those terms. // except according to those terms.
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(infer_outlives_requirements)]
#[rustc_outlives] #[rustc_outlives]
struct Foo<'a, T> { //~ ERROR 15:1: 17:2: rustc_outlives struct Foo<'a, T> { //~ ERROR 14:1: 16:2: rustc_outlives
bar: std::slice::IterMut<'a, T> bar: std::slice::IterMut<'a, T>
} }

View file

@ -1,7 +1,7 @@
error: rustc_outlives error: rustc_outlives
--> $DIR/cross-crate.rs:15:1 --> $DIR/cross-crate.rs:14:1
| |
LL | / struct Foo<'a, T> { //~ ERROR 15:1: 17:2: rustc_outlives LL | / struct Foo<'a, T> { //~ ERROR 14:1: 16:2: rustc_outlives
LL | | bar: std::slice::IterMut<'a, T> LL | | bar: std::slice::IterMut<'a, T>
LL | | } LL | | }
| |_^ | |_^

View file

@ -10,8 +10,6 @@
// ignore-tidy-linelength // ignore-tidy-linelength
#![feature(infer_outlives_requirements)]
/* /*
* We don't infer `T: 'static` outlives relationships by default. * We don't infer `T: 'static` outlives relationships by default.
* Instead an additional feature gate `infer_static_outlives_requirements` * Instead an additional feature gate `infer_static_outlives_requirements`
@ -19,7 +17,7 @@
*/ */
struct Foo<U> { struct Foo<U> {
bar: Bar<U> //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310] bar: Bar<U> //~ ERROR 20:5: 20:16: the parameter type `U` may not live long enough [E0310]
} }
struct Bar<T: 'static> { struct Bar<T: 'static> {
x: T, x: T,

View file

@ -1,15 +1,15 @@
error[E0310]: the parameter type `U` may not live long enough error[E0310]: the parameter type `U` may not live long enough
--> $DIR/dont-infer-static.rs:22:5 --> $DIR/dont-infer-static.rs:20:5
| |
LL | struct Foo<U> { LL | struct Foo<U> {
| - help: consider adding an explicit lifetime bound `U: 'static`... | - help: consider adding an explicit lifetime bound `U: 'static`...
LL | bar: Bar<U> //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310] LL | bar: Bar<U> //~ ERROR 20:5: 20:16: the parameter type `U` may not live long enough [E0310]
| ^^^^^^^^^^^ | ^^^^^^^^^^^
| |
note: ...so that the type `U` will meet its required lifetime bounds note: ...so that the type `U` will meet its required lifetime bounds
--> $DIR/dont-infer-static.rs:22:5 --> $DIR/dont-infer-static.rs:20:5
| |
LL | bar: Bar<U> //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310] LL | bar: Bar<U> //~ ERROR 20:5: 20:16: the parameter type `U` may not live long enough [E0310]
| ^^^^^^^^^^^ | ^^^^^^^^^^^
error: aborting due to previous error error: aborting due to previous error

View file

@ -10,24 +10,26 @@
// ignore-tidy-linelength // ignore-tidy-linelength
#![feature(rustc_attrs)]
// Needs an explicit where clause stating outlives condition. (RFC 2093) // Needs an explicit where clause stating outlives condition. (RFC 2093)
// Type T needs to outlive lifetime 'a. // Type T needs to outlive lifetime 'a.
enum Foo<'a, T> { #[rustc_outlives]
enum Foo<'a, T> { //~ ERROR rustc_outlives
One(Bar<'a, T>) One(Bar<'a, T>)
} }
// Type U needs to outlive lifetime 'b // Type U needs to outlive lifetime 'b
struct Bar<'b, U> { #[rustc_outlives]
field2: &'b U //~ ERROR the parameter type `U` may not live long enough [E0309] struct Bar<'b, U> { //~ ERROR rustc_outlives
field2: &'b U
} }
// Type K needs to outlive lifetime 'c. // Type K needs to outlive lifetime 'c.
enum Ying<'c, K> { #[rustc_outlives]
One(&'c Yang<K>) //~ ERROR the parameter type `K` may not live long enough [E0309] enum Ying<'c, K> { //~ ERROR rustc_outlives
One(&'c Yang<K>)
} }
struct Yang<V> { struct Yang<V> {

View file

@ -1,31 +1,32 @@
error[E0309]: the parameter type `U` may not live long enough error: rustc_outlives
--> $DIR/enum.rs:23:5 --> $DIR/enum.rs:19:1
| |
LL | struct Bar<'b, U> { LL | / enum Foo<'a, T> { //~ ERROR rustc_outlives
| - help: consider adding an explicit lifetime bound `U: 'b`... LL | | One(Bar<'a, T>)
LL | field2: &'b U //~ ERROR the parameter type `U` may not live long enough [E0309] LL | | }
| ^^^^^^^^^^^^^ | |_^
| |
note: ...so that the reference type `&'b U` does not outlive the data it points at = note: T : 'a
--> $DIR/enum.rs:23:5
|
LL | field2: &'b U //~ ERROR the parameter type `U` may not live long enough [E0309]
| ^^^^^^^^^^^^^
error[E0309]: the parameter type `K` may not live long enough error: rustc_outlives
--> $DIR/enum.rs:30:9 --> $DIR/enum.rs:25:1
| |
LL | enum Ying<'c, K> { LL | / struct Bar<'b, U> { //~ ERROR rustc_outlives
| - help: consider adding an explicit lifetime bound `K: 'c`... LL | | field2: &'b U
LL | One(&'c Yang<K>) //~ ERROR the parameter type `K` may not live long enough [E0309] LL | | }
| ^^^^^^^^^^^ | |_^
| |
note: ...so that the reference type `&'c Yang<K>` does not outlive the data it points at = note: U : 'b
--> $DIR/enum.rs:30:9
|
LL | One(&'c Yang<K>) //~ ERROR the parameter type `K` may not live long enough [E0309]
| ^^^^^^^^^^^
error: aborting due to 2 previous errors error: rustc_outlives
--> $DIR/enum.rs:31:1
|
LL | / enum Ying<'c, K> { //~ ERROR rustc_outlives
LL | | One(&'c Yang<K>)
LL | | }
| |_^
|
= note: K : 'c
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0309`.

View file

@ -10,13 +10,12 @@
#![feature(dyn_trait)] #![feature(dyn_trait)]
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(infer_outlives_requirements)]
trait Trait<'x, T> where T: 'x { trait Trait<'x, T> where T: 'x {
} }
#[rustc_outlives] #[rustc_outlives]
struct Foo<'a, A> //~ ERROR 19:1: 22:2: rustc_outlives struct Foo<'a, A> //~ ERROR 18:1: 21:2: rustc_outlives
{ {
foo: Box<dyn Trait<'a, A>> foo: Box<dyn Trait<'a, A>>
} }

View file

@ -1,7 +1,7 @@
error: rustc_outlives error: rustc_outlives
--> $DIR/explicit-dyn.rs:19:1 --> $DIR/explicit-dyn.rs:18:1
| |
LL | / struct Foo<'a, A> //~ ERROR 19:1: 22:2: rustc_outlives LL | / struct Foo<'a, A> //~ ERROR 18:1: 21:2: rustc_outlives
LL | | { LL | | {
LL | | foo: Box<dyn Trait<'a, A>> LL | | foo: Box<dyn Trait<'a, A>>
LL | | } LL | | }

View file

@ -9,10 +9,9 @@
// except according to those terms. // except according to those terms.
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(infer_outlives_requirements)]
#[rustc_outlives] #[rustc_outlives]
enum Foo<'a, U> { //~ ERROR 15:1: 17:2: rustc_outlives enum Foo<'a, U> { //~ ERROR 14:1: 16:2: rustc_outlives
One(Bar<'a, U>) One(Bar<'a, U>)
} }

View file

@ -1,7 +1,7 @@
error: rustc_outlives error: rustc_outlives
--> $DIR/explicit-enum.rs:15:1 --> $DIR/explicit-enum.rs:14:1
| |
LL | / enum Foo<'a, U> { //~ ERROR 15:1: 17:2: rustc_outlives LL | / enum Foo<'a, U> { //~ ERROR 14:1: 16:2: rustc_outlives
LL | | One(Bar<'a, U>) LL | | One(Bar<'a, U>)
LL | | } LL | | }
| |_^ | |_^

View file

@ -9,7 +9,6 @@
// except according to those terms. // except according to those terms.
#![feature(rustc_attrs)] #![feature(rustc_attrs)]
#![feature(infer_outlives_requirements)]
trait Trait<'x, T> where T: 'x { trait Trait<'x, T> where T: 'x {
type Type; type Type;

View file

@ -1,5 +1,5 @@
error: rustc_outlives error: rustc_outlives
--> $DIR/explicit-projection.rs:19:1 --> $DIR/explicit-projection.rs:18:1
| |
LL | / struct Foo<'a, A, B> where A: Trait<'a, B> //~ ERROR rustc_outlives LL | / struct Foo<'a, A, B> where A: Trait<'a, B> //~ ERROR rustc_outlives
LL | | { LL | | {

Some files were not shown because too many files have changed in this diff Show more