diff --git a/src/doc/unstable-book/src/language-features/infer-outlives-requirements.md b/src/doc/unstable-book/src/language-features/infer-outlives-requirements.md deleted file mode 100644 index fe82f8555da329e3ba96fbb10bb8b440891121e0..0000000000000000000000000000000000000000 --- a/src/doc/unstable-book/src/language-features/infer-outlives-requirements.md +++ /dev/null @@ -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 `::Item : 'a` -struct Foo<'a, T: Iterator> { - bar: &'a T::Item -``` diff --git a/src/liballoc/lib.rs b/src/liballoc/lib.rs index 452d2b1472ff4a2fb8d9b29e7097ae6da75700fb..2d271fd0dca8dcb0adc68f7c53cf4bf8e6dc02af 100644 --- a/src/liballoc/lib.rs +++ b/src/liballoc/lib.rs @@ -77,7 +77,6 @@ #![cfg_attr(not(test), feature(fn_traits))] #![cfg_attr(not(test), feature(generator_trait))] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![cfg_attr(test, feature(test))] #![feature(allocator_api)] diff --git a/src/liballoc_jemalloc/lib.rs b/src/liballoc_jemalloc/lib.rs index 3d2348f3e4546dd0701e127919c1b1cf7d3345ea..bdf0e37a2e672d8de3ae3d274b31a294c12918e8 100644 --- a/src/liballoc_jemalloc/lib.rs +++ b/src/liballoc_jemalloc/lib.rs @@ -17,7 +17,6 @@ #![feature(libc)] #![feature(linkage)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(staged_api)] #![feature(rustc_attrs)] #![cfg_attr(dummy_jemalloc, allow(dead_code, unused_extern_crates))] diff --git a/src/liballoc_system/lib.rs b/src/liballoc_system/lib.rs index 8848be5903810ef96bdbc44dda078a543e1c4fe0..65204ebf71413027a9bf79f0c0ff048907d03f74 100644 --- a/src/liballoc_system/lib.rs +++ b/src/liballoc_system/lib.rs @@ -18,7 +18,6 @@ #![feature(allocator_api)] #![feature(core_intrinsics)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(staged_api)] #![feature(rustc_attrs)] #![cfg_attr(any(unix, target_os = "cloudabi", target_os = "redox"), feature(libc))] diff --git a/src/libarena/lib.rs b/src/libarena/lib.rs index 5cb8975e9ce973cdf233afc74c3e398848558966..6ad703180c224eecd7e6777c5beb18c17ea8fe5f 100644 --- a/src/libarena/lib.rs +++ b/src/libarena/lib.rs @@ -27,7 +27,6 @@ #![feature(core_intrinsics)] #![feature(dropck_eyepatch)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(raw_vec_internals)] #![cfg_attr(test, feature(test))] diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index b0c93316301c44dbf822d01c28809a48ef1ad4f9..763409327de2bd623b7e20a111dc9a2fa87e548e 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -92,7 +92,6 @@ #![feature(link_llvm_intrinsics)] #![feature(never_type)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(exhaustive_patterns)] #![feature(macro_at_most_once_rep)] #![feature(no_core)] diff --git a/src/libfmt_macros/lib.rs b/src/libfmt_macros/lib.rs index 3720100700c9c2768249fae7fa488c62e39f78b0..1bac6d22d37441effd48a7ef1e4b0755c8c67979 100644 --- a/src/libfmt_macros/lib.rs +++ b/src/libfmt_macros/lib.rs @@ -21,7 +21,6 @@ test(attr(deny(warnings))))] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] pub use self::Piece::*; pub use self::Position::*; diff --git a/src/libgraphviz/lib.rs b/src/libgraphviz/lib.rs index 5a0c983b521a54c5afee7a4689ef59ca0478ea86..9fa48adebdf07a523411152409a2e1465c07fc37 100644 --- a/src/libgraphviz/lib.rs +++ b/src/libgraphviz/lib.rs @@ -289,7 +289,6 @@ test(attr(allow(unused_variables), deny(warnings))))] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(str_escape)] use self::LabelText::*; diff --git a/src/libpanic_abort/lib.rs b/src/libpanic_abort/lib.rs index 4da88d8522196642536d29cc876dbeb355f4f84b..14221f3d79e84050f91f50b58736b1281b022c8f 100644 --- a/src/libpanic_abort/lib.rs +++ b/src/libpanic_abort/lib.rs @@ -25,7 +25,6 @@ #![feature(core_intrinsics)] #![feature(libc)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(panic_runtime)] #![feature(staged_api)] #![feature(rustc_attrs)] diff --git a/src/libpanic_unwind/lib.rs b/src/libpanic_unwind/lib.rs index 3368790b3f76fad2e61742431b09324a532ff8ee..9c3fc76c307a6f7696ba4ce2f163c1dea7812602 100644 --- a/src/libpanic_unwind/lib.rs +++ b/src/libpanic_unwind/lib.rs @@ -35,7 +35,6 @@ #![feature(lang_items)] #![feature(libc)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(panic_unwind)] #![feature(raw)] #![feature(staged_api)] diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 1de9cd35442995ae618b1b4d630d965358751546..bb55661e45c75d7c854095219b2d3873245a093c 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -28,7 +28,6 @@ test(attr(allow(dead_code, deprecated, unused_variables, unused_mut))))] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(rustc_private)] #![feature(staged_api)] #![feature(lang_items)] diff --git a/src/libprofiler_builtins/lib.rs b/src/libprofiler_builtins/lib.rs index 00dd87022c268533b20c55493f2359fa9dfdbc1e..a85593253b100f8f184ab7a336335ef7961ea5e8 100644 --- a/src/libprofiler_builtins/lib.rs +++ b/src/libprofiler_builtins/lib.rs @@ -16,5 +16,4 @@ issue = "0")] #![allow(unused_features)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(staged_api)] diff --git a/src/librustc/diagnostics.rs b/src/librustc/diagnostics.rs index a3c0688dcc8edcaad3955249d64f03ba0cd7ab8c..3318bbd8c870ec20a9294a1c349dc466a970c789 100644 --- a/src/librustc/diagnostics.rs +++ b/src/librustc/diagnostics.rs @@ -1232,41 +1232,54 @@ fn main() {} "##, E0309: r##" -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. +The type definition contains some field whose type +requires an outlives annotation. Outlives annotations +(e.g., `T: 'a`) are used to guarantee that all the data in T is valid +for at least the lifetime `'a`. This scenario most commonly +arises when the type contains an associated type reference +like `>::Output`, as shown in this example: ```compile_fail,E0309 -// 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 +// 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. struct Foo<'a, T> { - foo: &'a T + foo: >::Output, } -``` -This will compile, because it has the constraint on the type parameter: +trait SomeTrait<'a> { + type Output; +} -``` -struct Foo<'a, T: 'a> { - foo: &'a T +impl<'a, T> SomeTrait<'a> for T +where + T: 'a, +{ + type Output = u32; } ``` -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: +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: -```compile_fail,E0309 -struct Foo<'a, T> { - foo: &'a T +``` +struct Foo<'a, T> +where + T: 'a, +{ + foo: >::Output } -fn main() { - let v = "42".to_string(); - let f = Foo{foo: &v}; - drop(v); - println!("{}", f.foo); // but we've already dropped v! +trait SomeTrait<'a> { + type Output; +} + +impl<'a, T> SomeTrait<'a> for T +where + T: 'a, +{ + type Output = u32; } ``` "##, @@ -1465,30 +1478,31 @@ struct Prince<'kiss, 'SnowWhite: 'kiss> { // You say here that 'kiss must live Erroneous code example: ```compile_fail,E0491 -// 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, +trait SomeTrait<'a> { + type Output; } -// 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 +impl<'a, T> SomeTrait<'a> for T { + type Output = &'a T; // 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> { - ref_i32: &'a i32, +trait SomeTrait<'a> { + type Output; } -// 'a: 'b means 'a outlives 'b -struct Nested<'a: 'b, 'b> { - ref_struct: &'b Struct<'a>, +impl<'a, T> SomeTrait<'a> for T +where + T: 'a, +{ + type Output = &'a T; // compile error E0491 } ``` "##, diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index d79281666d63914e7f137927c04100b96ec02368..56096a5d423f33e986b4c47b03026929bb7a6377 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -52,7 +52,6 @@ #![feature(exhaustive_patterns)] #![feature(extern_types)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(non_exhaustive)] #![feature(proc_macro_internals)] #![feature(quote)] diff --git a/src/librustc_allocator/lib.rs b/src/librustc_allocator/lib.rs index 44fbcade6bc066eabf9754034f0dc7a1434ffc69..2a3404ee830343d10de823c8663c175394c9d7a6 100644 --- a/src/librustc_allocator/lib.rs +++ b/src/librustc_allocator/lib.rs @@ -9,7 +9,6 @@ // except according to those terms. #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(rustc_private)] #[macro_use] extern crate log; diff --git a/src/librustc_apfloat/lib.rs b/src/librustc_apfloat/lib.rs index c3c32ba7d5b6c05623ac577be65321111f81b171..d6e821d427d0580f45266e98cce22d40be793747 100644 --- a/src/librustc_apfloat/lib.rs +++ b/src/librustc_apfloat/lib.rs @@ -46,7 +46,6 @@ #![forbid(unsafe_code)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(try_from)] // See librustc_cratesio_shim/Cargo.toml for a comment explaining this. #[allow(unused_extern_crates)] diff --git a/src/librustc_asan/lib.rs b/src/librustc_asan/lib.rs index ed8fd305977e5e9b7a71359411211774d4d81420..b3ba86ad8a4b32af8f7f6629cca53f8891221b8f 100644 --- a/src/librustc_asan/lib.rs +++ b/src/librustc_asan/lib.rs @@ -11,7 +11,6 @@ #![sanitizer_runtime] #![feature(alloc_system)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] diff --git a/src/librustc_borrowck/lib.rs b/src/librustc_borrowck/lib.rs index edd837e9401a7da2097c39409ed73431dd6da0f3..16da8c8a3b8bf6651dc41d8b70ef0f9b7cc8341d 100644 --- a/src/librustc_borrowck/lib.rs +++ b/src/librustc_borrowck/lib.rs @@ -15,7 +15,6 @@ #![allow(non_camel_case_types)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(quote)] #![recursion_limit="256"] diff --git a/src/librustc_codegen_llvm/lib.rs b/src/librustc_codegen_llvm/lib.rs index dcdd8c1f6e9f99a5c2848af27fba61feaaaa8789..9cb233122c3d086d105b6d73e51d7b9259ae1aaa 100644 --- a/src/librustc_codegen_llvm/lib.rs +++ b/src/librustc_codegen_llvm/lib.rs @@ -27,7 +27,6 @@ #![allow(unused_attributes)] #![feature(libc)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(quote)] #![feature(range_contains)] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc_codegen_utils/lib.rs b/src/librustc_codegen_utils/lib.rs index 45db22ec6dabc59945ee62c28fd1deea617348c9..635819e94e8679bfed6b729350c25cb400ce79c9 100644 --- a/src/librustc_codegen_utils/lib.rs +++ b/src/librustc_codegen_utils/lib.rs @@ -20,7 +20,6 @@ #![feature(box_syntax)] #![feature(custom_attribute)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![allow(unused_attributes)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc_cratesio_shim/src/lib.rs b/src/librustc_cratesio_shim/src/lib.rs index ebceb00cca8b0b72c7a65bc4af1f944cdc62e170..55dec45a0982471fbec041d2f11ec61102625b68 100644 --- a/src/librustc_cratesio_shim/src/lib.rs +++ b/src/librustc_cratesio_shim/src/lib.rs @@ -12,7 +12,6 @@ #![allow(unused_extern_crates)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] extern crate bitflags; extern crate log; diff --git a/src/librustc_data_structures/lib.rs b/src/librustc_data_structures/lib.rs index 7915650fd89f70401d79422f01aa15105168394a..87a033138c32e1e49be0e416e19097e3d1c4e5ce 100644 --- a/src/librustc_data_structures/lib.rs +++ b/src/librustc_data_structures/lib.rs @@ -29,7 +29,6 @@ #![feature(optin_builtin_traits)] #![cfg_attr(stage0, feature(macro_vis_matcher))] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(allow_internal_unstable)] #![feature(vec_resize_with)] diff --git a/src/librustc_driver/lib.rs b/src/librustc_driver/lib.rs index 13e1df6e538887c4735a413a4da600351b55d40c..a96c277d4b555d723e9967cdf55c7b717daf8a22 100644 --- a/src/librustc_driver/lib.rs +++ b/src/librustc_driver/lib.rs @@ -21,7 +21,6 @@ #![feature(box_syntax)] #![cfg_attr(unix, feature(libc))] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(option_replace)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index d31db4b2d00acc8b9e706fbf46cef352ba871ee4..3582c2359c8b9f653f5ed5d27148f2845e18e801 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -17,7 +17,6 @@ #![feature(range_contains)] #![cfg_attr(unix, feature(libc))] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(optin_builtin_traits)] extern crate atty; diff --git a/src/librustc_incremental/lib.rs b/src/librustc_incremental/lib.rs index 4ffd726c1d47ce2b5aba82c21f2e403fdcc28992..acdcf2b459e92efc99006e02a97e445be61aaf45 100644 --- a/src/librustc_incremental/lib.rs +++ b/src/librustc_incremental/lib.rs @@ -15,7 +15,6 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(specialization)] #![recursion_limit="256"] diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs index 681cf0d5fc9dedab38cdf14e37e83d053905b1b2..9ed69a2dc9b8ec95528f6cc2a09712985204624c 100644 --- a/src/librustc_lint/lib.rs +++ b/src/librustc_lint/lib.rs @@ -28,7 +28,6 @@ #![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)] diff --git a/src/librustc_llvm/lib.rs b/src/librustc_llvm/lib.rs index 13605e993a59cc5140811691c94590fc9964a15f..387660473a887dea0a2524a4bdceefbd0b78b515 100644 --- a/src/librustc_llvm/lib.rs +++ b/src/librustc_llvm/lib.rs @@ -9,7 +9,6 @@ // except according to those terms. #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(static_nobundle)] #![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", diff --git a/src/librustc_lsan/lib.rs b/src/librustc_lsan/lib.rs index ed8fd305977e5e9b7a71359411211774d4d81420..b3ba86ad8a4b32af8f7f6629cca53f8891221b8f 100644 --- a/src/librustc_lsan/lib.rs +++ b/src/librustc_lsan/lib.rs @@ -11,7 +11,6 @@ #![sanitizer_runtime] #![feature(alloc_system)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index 107245488acf322c30c58eb911cf2bafaa46315b..09a8bea0941b618a20933ac77ec9a5a079fb1711 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -16,7 +16,6 @@ #![feature(libc)] #![feature(macro_at_most_once_rep)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(proc_macro_internals)] #![feature(proc_macro_quote)] #![feature(quote)] diff --git a/src/librustc_mir/lib.rs b/src/librustc_mir/lib.rs index f2c011ccee6a5704ffed97ff84204987d05caf1b..e71de0001fbe342d14a829e7b4addc68ce090da3 100644 --- a/src/librustc_mir/lib.rs +++ b/src/librustc_mir/lib.rs @@ -15,7 +15,6 @@ */ #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(in_band_lifetimes)] #![feature(impl_header_lifetime_elision)] #![feature(slice_patterns)] diff --git a/src/librustc_msan/lib.rs b/src/librustc_msan/lib.rs index ed8fd305977e5e9b7a71359411211774d4d81420..b3ba86ad8a4b32af8f7f6629cca53f8891221b8f 100644 --- a/src/librustc_msan/lib.rs +++ b/src/librustc_msan/lib.rs @@ -11,7 +11,6 @@ #![sanitizer_runtime] #![feature(alloc_system)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] diff --git a/src/librustc_passes/lib.rs b/src/librustc_passes/lib.rs index 94ea229cbd91ba03f01697adc3057d2f81322390..d62cb00923f7047411ff3a17d5da3886d33d6ea9 100644 --- a/src/librustc_passes/lib.rs +++ b/src/librustc_passes/lib.rs @@ -19,7 +19,6 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(rustc_diagnostic_macros)] #[macro_use] diff --git a/src/librustc_platform_intrinsics/lib.rs b/src/librustc_platform_intrinsics/lib.rs index f093d672498ad4b2483ad71133cb43b4a38cd852..fa7008be73a0797d7a4570886396af6b3a0db7d9 100644 --- a/src/librustc_platform_intrinsics/lib.rs +++ b/src/librustc_platform_intrinsics/lib.rs @@ -11,7 +11,6 @@ #![allow(nonstandard_style)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] pub struct Intrinsic { pub inputs: &'static [&'static Type], diff --git a/src/librustc_plugin/lib.rs b/src/librustc_plugin/lib.rs index 5b56266638552490473463f22f13505052b0fdab..67f53a67313f798f1f9d2979d9f57e0a949095af 100644 --- a/src/librustc_plugin/lib.rs +++ b/src/librustc_plugin/lib.rs @@ -65,7 +65,6 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(rustc_diagnostic_macros)] #[macro_use] extern crate syntax; diff --git a/src/librustc_privacy/lib.rs b/src/librustc_privacy/lib.rs index fe66110120d40e2a1c212ce8371dbf402349fd17..47e8588857d6a3303b77ef3dfb16c7906d2b0de4 100644 --- a/src/librustc_privacy/lib.rs +++ b/src/librustc_privacy/lib.rs @@ -13,7 +13,6 @@ 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"] @@ -1381,7 +1380,13 @@ fn generics(&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 { predicate.visit_with(self); match predicate { diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 8c769094f521181d3314d0180443c9c189804916..c725d56d0cfdc8b178dbace230bb982c1e8395e6 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -14,7 +14,6 @@ #![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)] diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs index 48e4d93e07b36f82fb06aba96834cdd0f82ba3e6..8d6a75ecc59257eb83b66c5d4090327824ee7b41 100644 --- a/src/librustc_save_analysis/lib.rs +++ b/src/librustc_save_analysis/lib.rs @@ -13,7 +13,6 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![feature(custom_attribute)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![allow(unused_attributes)] #![recursion_limit="256"] diff --git a/src/librustc_target/lib.rs b/src/librustc_target/lib.rs index e4d958e3b6f3520e84ae3a76b6f6fa098a65fc25..c198b19ce616075e3cc55b88973ee1263478363f 100644 --- a/src/librustc_target/lib.rs +++ b/src/librustc_target/lib.rs @@ -25,7 +25,6 @@ #![cfg_attr(stage0, feature(const_fn))] #![cfg_attr(not(stage0), feature(min_const_fn))] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(slice_patterns)] #[macro_use] diff --git a/src/librustc_traits/lib.rs b/src/librustc_traits/lib.rs index 971dfa751f11a300c5679575c6e33796bc8b521b..7fe1af819512951ec02cd061c4e54585d66b2338 100644 --- a/src/librustc_traits/lib.rs +++ b/src/librustc_traits/lib.rs @@ -16,7 +16,6 @@ #![feature(extern_prelude)] #![feature(in_band_lifetimes)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![recursion_limit="256"] diff --git a/src/librustc_tsan/lib.rs b/src/librustc_tsan/lib.rs index ed8fd305977e5e9b7a71359411211774d4d81420..b3ba86ad8a4b32af8f7f6629cca53f8891221b8f 100644 --- a/src/librustc_tsan/lib.rs +++ b/src/librustc_tsan/lib.rs @@ -11,7 +11,6 @@ #![sanitizer_runtime] #![feature(alloc_system)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(sanitizer_runtime)] #![feature(staged_api)] #![no_std] diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index cc83c24e51c04e0bb88806624e2529ac38f18ae9..5309be21768f1553fd575177a12c2e3ae8b55b89 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1578,14 +1578,10 @@ fn predicates_defined_on<'a, 'tcx>( def_id: DefId, ) -> ty::GenericPredicates<'tcx> { let explicit = tcx.explicit_predicates_of(def_id); - let predicates = if tcx.sess.features_untracked().infer_outlives_requirements { - [ - &explicit.predicates[..], - &tcx.inferred_outlives_of(def_id)[..], - ].concat() - } else { - explicit.predicates - }; + let predicates = [ + &explicit.predicates[..], + &tcx.inferred_outlives_of(def_id)[..], + ].concat(); ty::GenericPredicates { parent: explicit.parent, diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs index f465ff4d62163e63148d7bf39eae8376ad433156..aaa42f8d41225a8ec1dd1b06a6aaa9e84e293d16 100644 --- a/src/librustc_typeck/lib.rs +++ b/src/librustc_typeck/lib.rs @@ -76,7 +76,6 @@ #![feature(crate_visibility_modifier)] #![feature(exhaustive_patterns)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(quote)] #![feature(refcell_replace_swap)] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc_typeck/outlives/implicit_infer.rs b/src/librustc_typeck/outlives/implicit_infer.rs index 092e4d62e2e9fa5724d4618bea8f6bf957897cb8..254146c0ef3aa3dbe61976a7c7dc2705b99e8c24 100644 --- a/src/librustc_typeck/outlives/implicit_infer.rs +++ b/src/librustc_typeck/outlives/implicit_infer.rs @@ -66,7 +66,8 @@ fn visit_item(&mut self, item: &hir::Item) { 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"); @@ -108,7 +109,8 @@ fn visit_item(&mut self, item: &hir::Item) { // Therefore mark `predicates_added` as true and which will ensure // we walk the crates again and re-calculate predicates for all // items. - let item_predicates_len: usize = self.global_inferred_outlives + let item_predicates_len: usize = self + .global_inferred_outlives .get(&item_did) .map(|p| p.len()) .unwrap_or(0); diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 3211607807ff3c98bdcf1d84d105477e02a0a943..bc471d427048b5651f4d612724bc4fa658824948 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -17,7 +17,6 @@ #![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)] diff --git a/src/libserialize/lib.rs b/src/libserialize/lib.rs index e87c2793ee86701ab2d5b88d2a3bf9e2f6ad07e6..1f6ee3d867b17b3c7225b31a84266de1f039df8a 100644 --- a/src/libserialize/lib.rs +++ b/src/libserialize/lib.rs @@ -25,7 +25,6 @@ #![feature(specialization)] #![feature(never_type)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![cfg_attr(test, feature(test))] pub use self::serialize::{Decoder, Encoder, Decodable, Encodable}; diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 5c9e88dc57ca6ea869c72dbca80edf95b7785fce..17f6923eae72368b6190bc70fde284aca26b2ae4 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -274,7 +274,6 @@ #![feature(needs_panic_runtime)] #![feature(never_type)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(exhaustive_patterns)] #![feature(on_unimplemented)] #![feature(optin_builtin_traits)] diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 2b4daa6440c0cee481cead9042c16b7a35bff761..d98e457439927fac53f01e016c15dab5bb1ee4a0 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -412,9 +412,6 @@ pub fn walk_feature_fields(&self, mut f: F) // 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), @@ -672,6 +669,8 @@ pub fn walk_feature_fields(&self, mut f: F) (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), @@ -1124,12 +1123,6 @@ pub fn is_builtin_attr(attr: &ast::Attribute) -> bool { "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", diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index c8ec273a03f2866e4fd77bb57cb02e8c2fff7a04..2aaab6aaa16d931942844d5f06e73ff3bb076b3d 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -22,7 +22,6 @@ #![feature(crate_visibility_modifier)] #![feature(macro_at_most_once_rep)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(rustc_attrs)] #![feature(rustc_diagnostic_macros)] #![feature(slice_sort_by_cached_key)] diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs index 88af4a73a1515a93b58592f3c7628f54050decf7..31089c9ff82cefefc9a3111d6e65b91aafcbb024 100644 --- a/src/libsyntax_ext/lib.rs +++ b/src/libsyntax_ext/lib.rs @@ -17,7 +17,6 @@ #![feature(proc_macro_internals)] #![feature(decl_macro)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(str_escape)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] diff --git a/src/libsyntax_pos/lib.rs b/src/libsyntax_pos/lib.rs index a493ea4f565ea92139e26680770781557ad79818..bd70344b018127992879e1f0684868c91cad8035 100644 --- a/src/libsyntax_pos/lib.rs +++ b/src/libsyntax_pos/lib.rs @@ -22,7 +22,6 @@ #![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)] diff --git a/src/libterm/lib.rs b/src/libterm/lib.rs index df90be6393743a75dfc058d41c556c3116a1e580..a49fd67639dbe5210fe1118a2f1e672f8958f7b5 100644 --- a/src/libterm/lib.rs +++ b/src/libterm/lib.rs @@ -51,7 +51,6 @@ // Handle rustfmt skips #![feature(custom_attribute)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![allow(unused_attributes)] use std::io::prelude::*; diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index bf3cb7c537bd0da9879851e85c5c1d5312c49d94..6ffa6e9be937d134c91b661134d31a00b8603f18 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -36,7 +36,6 @@ #![feature(fnbox)] #![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc))] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(set_stdio)] #![feature(panic_unwind)] #![feature(staged_api)] diff --git a/src/libunwind/lib.rs b/src/libunwind/lib.rs index 3b94dc238d91cf9aab3686fc3671bb4caa4b9e11..424a7e3d009ecaa6c930c200c7819552b7609e89 100644 --- a/src/libunwind/lib.rs +++ b/src/libunwind/lib.rs @@ -14,7 +14,6 @@ #![feature(cfg_target_vendor)] #![feature(link_cfg)] #![cfg_attr(not(stage0), feature(nll))] -#![cfg_attr(not(stage0), feature(infer_outlives_requirements))] #![feature(staged_api)] #![feature(unwind_attributes)] #![feature(static_nobundle)] diff --git a/src/test/incremental/issue-51409.rs b/src/test/incremental/issue-51409.rs index d7aff5afe409e04b300c4c2691c4234138c85522..8aa75e6315d1ddf245844a938d47d8f745e4e9f1 100644 --- a/src/test/incremental/issue-51409.rs +++ b/src/test/incremental/issue-51409.rs @@ -13,8 +13,6 @@ // Regression test that `infer_outlives_predicates` can be // used with incremental without an ICE. -#![feature(infer_outlives_requirements)] - struct Foo<'a, T> { x: &'a T } diff --git a/src/test/ui/dep-graph/dep-graph-struct-signature.rs b/src/test/ui/dep-graph/dep-graph-struct-signature.rs index 647605ae4383e823623bf7314139624dc798b0bd..6343dc201c5d9f3e3980f0753798649e856fc423 100644 --- a/src/test/ui/dep-graph/dep-graph-struct-signature.rs +++ b/src/test/ui/dep-graph/dep-graph-struct-signature.rs @@ -88,7 +88,6 @@ trait A { } #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path - #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path fn b(x: WontChange) { } #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path from `WillChange` diff --git a/src/test/ui/dep-graph/dep-graph-struct-signature.stderr b/src/test/ui/dep-graph/dep-graph-struct-signature.stderr index cbb695d0cf2b96696cd768cfe4d1f172acdebe6f..0d75bf5a9adc0831109ade2e8e4558ba051d27a8 100644 --- a/src/test/ui/dep-graph/dep-graph-struct-signature.stderr +++ b/src/test/ui/dep-graph/dep-graph-struct-signature.stderr @@ -82,20 +82,14 @@ error: no path from `WillChange` to `FnSignature` LL | #[rustc_then_this_would_need(FnSignature)] //~ ERROR no path | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: no path from `WillChange` to `TypeckTables` - --> $DIR/dep-graph-struct-signature.rs:91:5 - | -LL | #[rustc_then_this_would_need(TypeckTables)] //~ ERROR no path - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: no path from `WillChange` to `FnSignature` - --> $DIR/dep-graph-struct-signature.rs:94:5 + --> $DIR/dep-graph-struct-signature.rs:93: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:95:5 + --> $DIR/dep-graph-struct-signature.rs:94:5 | 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 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 23 previous errors +error: aborting due to 22 previous errors diff --git a/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.rs b/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.rs deleted file mode 100644 index 01ccc50a130f2a56b976bf16a6f1f8c8a9d58e45..0000000000000000000000000000000000000000 --- a/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.rs +++ /dev/null @@ -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 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// Needs an explicit where clause stating outlives condition. (RFC 2093) - -// Type T needs to outlive lifetime 'a. -struct Foo<'a, T> { - bar: &'a [T] //~ ERROR the parameter type `T` may not live long enough [E0309] -} - -fn main() { } diff --git a/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.stderr b/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.stderr deleted file mode 100644 index 560e494b5828dec66e2a5705001b090911c8146e..0000000000000000000000000000000000000000 --- a/src/test/ui/feature-gates/feature-gate-infer_outlives_requirements.stderr +++ /dev/null @@ -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`. diff --git a/src/test/ui/issue-53419.rs b/src/test/ui/issue-53419.rs index e4ade1b6323b7b30023a06bfba6b1fbea9e76126..0dd5a8512852a53033649ebb2e800ccb3e52542b 100644 --- a/src/test/ui/issue-53419.rs +++ b/src/test/ui/issue-53419.rs @@ -10,8 +10,6 @@ //compile-pass -#![feature(infer_outlives_requirements)] - struct Foo { bar: for<'r> Fn(usize, &'r FnMut()) } diff --git a/src/test/ui/issues/issue-37323.rs b/src/test/ui/issues/issue-37323.rs index 98806cdd1b9aff8e720f05d42568cf1588c2ca71..24ed7ce92bfda9e14f7e3aa37dc562724fe106a5 100644 --- a/src/test/ui/issues/issue-37323.rs +++ b/src/test/ui/issues/issue-37323.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// compile-pass + #![feature(rustc_attrs)] #![allow(warnings)] @@ -17,7 +19,6 @@ struct Point { struct NestedA<'a, 'b> { x: &'a NestedB<'b> - //~^ ERROR E0491 } struct NestedB<'a> { diff --git a/src/test/ui/issues/issue-37323.stderr b/src/test/ui/issues/issue-37323.stderr deleted file mode 100644 index a83923a591023896456569943f7bea7e5c347e10..0000000000000000000000000000000000000000 --- a/src/test/ui/issues/issue-37323.stderr +++ /dev/null @@ -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`. diff --git a/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs index 0099a8bc10f5a2a2682174a5fdd5e911a288664b..7bc83fd750703b00d22bd2a09c1f6748bcec27ca 100644 --- a/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs +++ b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.rs @@ -14,9 +14,9 @@ trait ListItem<'a> { trait Collection { fn len(&self) -> usize; } +// is now well formed. RFC 2093 struct List<'a, T: ListItem<'a>> { slice: &'a [T] - //~^ ERROR may not live long enough } impl<'a, T: ListItem<'a>> Collection for List<'a, T> { diff --git a/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr index ea79990bbb1fb21bdb5932d29e944c3f27a08dbd..db8d57bb19d03e931cb14ba35852606e900a7c29 100644 --- a/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr +++ b/src/test/ui/lifetimes/lifetime-doesnt-live-long-enough.stderr @@ -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 --> $DIR/lifetime-doesnt-live-long-enough.rs:29:5 | @@ -109,7 +95,7 @@ LL | | //~^ ERROR may not live long enough LL | | } | |_____^ -error: aborting due to 7 previous errors +error: aborting due to 6 previous errors Some errors occurred: E0309, E0310. For more information about an error, try `rustc --explain E0309`. diff --git a/src/test/ui/lint/lint-ctypes.rs b/src/test/ui/lint/lint-ctypes.rs index b8b1a675c5f6dbef301f694c8c6d52f2b46a2938..e09aabaf69253ee855c1b7a8368c033dd5af38f7 100644 --- a/src/test/ui/lint/lint-ctypes.rs +++ b/src/test/ui/lint/lint-ctypes.rs @@ -11,6 +11,8 @@ #![deny(improper_ctypes)] #![feature(libc)] +#![allow(private_in_public)] + extern crate libc; use std::marker::PhantomData; diff --git a/src/test/ui/lint/lint-ctypes.stderr b/src/test/ui/lint/lint-ctypes.stderr index b97e4662660fbd5c5236d5cca266c83a619beda6..b243c49316f8cdacdb408ae449242a66eac784e2 100644 --- a/src/test/ui/lint/lint-ctypes.stderr +++ b/src/test/ui/lint/lint-ctypes.stderr @@ -1,5 +1,5 @@ error: `extern` block uses type `Foo` which is not FFI-safe: this struct has unspecified layout - --> $DIR/lint-ctypes.rs:54:28 + --> $DIR/lint-ctypes.rs:56:28 | LL | pub fn ptr_type1(size: *const Foo); //~ ERROR: uses type `Foo` | ^^^^^^^^^^ @@ -11,26 +11,26 @@ LL | #![deny(improper_ctypes)] | ^^^^^^^^^^^^^^^ = help: consider adding a #[repr(C)] or #[repr(transparent)] attribute to this struct note: type defined here - --> $DIR/lint-ctypes.rs:32:1 + --> $DIR/lint-ctypes.rs:34: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:55:28 + --> $DIR/lint-ctypes.rs:57: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:32:1 + --> $DIR/lint-ctypes.rs:34: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:56:26 + --> $DIR/lint-ctypes.rs:58:26 | LL | pub fn slice_type(p: &[u32]); //~ ERROR: uses type `[u32]` | ^^^^^^ @@ -38,7 +38,7 @@ LL | pub fn slice_type(p: &[u32]); //~ ERROR: uses type `[u32]` = help: consider using a raw pointer instead error: `extern` block uses type `str` which is not FFI-safe: string slices have no C equivalent - --> $DIR/lint-ctypes.rs:57:24 + --> $DIR/lint-ctypes.rs:59:24 | LL | pub fn str_type(p: &str); //~ ERROR: uses type `str` | ^^^^ @@ -46,7 +46,7 @@ LL | pub fn str_type(p: &str); //~ ERROR: uses type `str` = help: consider using `*const u8` and a length instead error: `extern` block uses type `std::boxed::Box` which is not FFI-safe: this struct has unspecified layout - --> $DIR/lint-ctypes.rs:58:24 + --> $DIR/lint-ctypes.rs:60:24 | LL | pub fn box_type(p: Box); //~ ERROR uses type `std::boxed::Box` | ^^^^^^^^ @@ -54,7 +54,7 @@ LL | pub fn box_type(p: Box); //~ ERROR uses type `std::boxed::Box = help: consider adding a #[repr(C)] or #[repr(transparent)] attribute to this struct error: `extern` block uses type `char` which is not FFI-safe: the `char` type has no C equivalent - --> $DIR/lint-ctypes.rs:59:25 + --> $DIR/lint-ctypes.rs:61:25 | LL | pub fn char_type(p: char); //~ ERROR uses type `char` | ^^^^ @@ -62,25 +62,25 @@ LL | pub fn char_type(p: char); //~ ERROR uses type `char` = help: consider using `u32` or `libc::wchar_t` instead error: `extern` block uses type `i128` which is not FFI-safe: 128-bit integers don't currently have a known stable ABI - --> $DIR/lint-ctypes.rs:60:25 + --> $DIR/lint-ctypes.rs:62: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:61:25 + --> $DIR/lint-ctypes.rs:63: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:62:26 + --> $DIR/lint-ctypes.rs:64: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:63:26 + --> $DIR/lint-ctypes.rs:65:26 | LL | pub fn tuple_type(p: (i32, i32)); //~ ERROR uses type `(i32, i32)` | ^^^^^^^^^^ @@ -88,7 +88,7 @@ LL | pub fn tuple_type(p: (i32, i32)); //~ ERROR uses type `(i32, i32)` = help: consider using a struct instead error: `extern` block uses type `(i32, i32)` which is not FFI-safe: tuples have unspecified layout - --> $DIR/lint-ctypes.rs:64:27 + --> $DIR/lint-ctypes.rs:66:27 | LL | pub fn tuple_type2(p: I32Pair); //~ ERROR uses type `(i32, i32)` | ^^^^^^^ @@ -96,32 +96,32 @@ LL | pub fn tuple_type2(p: I32Pair); //~ ERROR uses type `(i32, i32)` = help: consider using a struct instead error: `extern` block uses type `ZeroSize` which is not FFI-safe: this struct has no fields - --> $DIR/lint-ctypes.rs:65:25 + --> $DIR/lint-ctypes.rs:67: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:28:1 + --> $DIR/lint-ctypes.rs:30:1 | LL | pub struct ZeroSize; | ^^^^^^^^^^^^^^^^^^^^ 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 | ^^^^^^^^^^^^^^^^^^^^^^^ error: `extern` block uses type `std::marker::PhantomData` 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; //~ 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:69:23 + --> $DIR/lint-ctypes.rs:71:23 | LL | pub fn fn_type(p: RustFn); //~ ERROR function pointer has Rust-specific | ^^^^^^ @@ -129,7 +129,7 @@ LL | pub fn fn_type(p: RustFn); //~ ERROR function pointer has Rust-specific = help: consider using an `extern fn(...) -> ...` function pointer instead error: `extern` block uses type `fn()` which is not FFI-safe: this function pointer has Rust-specific calling convention - --> $DIR/lint-ctypes.rs:70:24 + --> $DIR/lint-ctypes.rs:72:24 | LL | pub fn fn_type2(p: fn()); //~ ERROR function pointer has Rust-specific | ^^^^ @@ -137,7 +137,7 @@ LL | pub fn fn_type2(p: fn()); //~ ERROR function pointer has Rust-specific = help: consider using an `extern fn(...) -> ...` function pointer instead error: `extern` block uses type `std::boxed::Box` which is not FFI-safe: this struct has unspecified layout - --> $DIR/lint-ctypes.rs:71:28 + --> $DIR/lint-ctypes.rs:73:28 | LL | pub fn fn_contained(p: RustBadRet); //~ ERROR: uses type `std::boxed::Box` | ^^^^^^^^^^ @@ -145,13 +145,13 @@ LL | pub fn fn_contained(p: RustBadRet); //~ ERROR: uses type `std::boxed::B = help: consider adding a #[repr(C)] or #[repr(transparent)] attribute to this struct error: `extern` block uses type `i128` which is not FFI-safe: 128-bit integers don't currently have a known stable ABI - --> $DIR/lint-ctypes.rs:72:32 + --> $DIR/lint-ctypes.rs:74: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:73:31 + --> $DIR/lint-ctypes.rs:75:31 | LL | pub fn transparent_str(p: TransparentStr); //~ ERROR: uses type `str` | ^^^^^^^^^^^^^^ @@ -159,7 +159,7 @@ LL | pub fn transparent_str(p: TransparentStr); //~ ERROR: uses type `str` = help: consider using `*const u8` and a length instead error: `extern` block uses type `std::boxed::Box` which is not FFI-safe: this struct has unspecified layout - --> $DIR/lint-ctypes.rs:74:30 + --> $DIR/lint-ctypes.rs:76:30 | LL | pub fn transparent_fn(p: TransparentBadFn); //~ ERROR: uses type `std::boxed::Box` | ^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/no_owned_box_lang_item.rs b/src/test/ui/no_owned_box_lang_item.rs index 1c2bf1573dcc1900e2f2becbc6396ccc58a016f0..34d1075f9b71dbd1d1bd766d2422bb3e1a606832 100644 --- a/src/test/ui/no_owned_box_lang_item.rs +++ b/src/test/ui/no_owned_box_lang_item.rs @@ -15,10 +15,12 @@ #![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() -> ! { loop {} } +#[lang = "panic_impl"] fn panic_impl(panic: &PanicInfo) -> ! { loop {} } diff --git a/src/test/ui/regions/regions-enum-not-wf.rs b/src/test/ui/regions/regions-enum-not-wf.rs index e21f92bc9b885947d84bc603015edeb5c1175413..a2d3cf6779f1768f4bf620ddd76862cd89bdd934 100644 --- a/src/test/ui/regions/regions-enum-not-wf.rs +++ b/src/test/ui/regions/regions-enum-not-wf.rs @@ -8,31 +8,43 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// ignore-tidy-linelength + // Various examples of structs whose fields are not well-formed. #![allow(dead_code)] +trait Dummy<'a> { + type Out; +} +impl<'a, T> Dummy<'a> for T +where T: 'a +{ + type Out = (); +} +type RequireOutlives<'a, T> = >::Out; + enum Ref1<'a, T> { - Ref1Variant1(&'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> { 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> { 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> { - RefDoubleVariant1(&'a &'b T) - //~^ ERROR reference has a longer lifetime than the data +enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] + RefDoubleVariant1(&'a RequireOutlives<'b, T>) + //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309] } fn main() { } diff --git a/src/test/ui/regions/regions-enum-not-wf.stderr b/src/test/ui/regions/regions-enum-not-wf.stderr index 381a8aada5a3f9fdda8a850604ca271f373d3da4..923ea17622ac08e5b62457b8fde3cb2c7dd17886 100644 --- a/src/test/ui/regions/regions-enum-not-wf.stderr +++ b/src/test/ui/regions/regions-enum-not-wf.stderr @@ -1,64 +1,67 @@ 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> { | - 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 - --> $DIR/regions-enum-not-wf.rs:16:18 +note: ...so that the type `T` will meet its required lifetime bounds + --> $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 - --> $DIR/regions-enum-not-wf.rs:21:25 + --> $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, &'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 +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-enum-not-wf.rs:33:25 | -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 + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-enum-not-wf.rs:29:32 + --> $DIR/regions-enum-not-wf.rs:45:1 | -LL | enum RefIndirect<'a, T> { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | RefIndirectVariant1(isize, RefOk<'a,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: ...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:45:1 | -LL | RefIndirectVariant1(isize, RefOk<'a,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>) +LL | | //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309] +LL | | } + | |_^ -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 | RefDoubleVariant1(&'a &'b T) - | ^^^^^^^^^ +error[E0309]: the parameter type `T` may not live long enough + --> $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> { //~ 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 | 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 +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-enum-not-wf.rs:46:23 | -LL | enum RefDouble<'a, 'b, T> { - | ^^ +LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 4 previous errors -Some errors occurred: E0309, E0491. -For more information about an error, try `rustc --explain E0309`. +For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.rs b/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.rs index db25a0698fed4333e21c74f76b87a1407d06d431..7a2be8c0d95bb2fb5f2b8256de2e6e1424bc8015 100644 --- a/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.rs +++ b/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.rs @@ -13,6 +13,8 @@ // // Rule OutlivesNominalType from RFC 1214. +// compile-pass + #![feature(rustc_attrs)] #![allow(dead_code)] @@ -21,9 +23,8 @@ struct Foo<'a> { x: fn(&'a i32), } enum Bar<'a,'b> { - V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime + V(&'a Foo<'b>) } } -#[rustc_error] fn main() { } diff --git a/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.stderr b/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.stderr deleted file mode 100644 index 5084097e30d1104c707c4120f363362671f7ae16..0000000000000000000000000000000000000000 --- a/src/test/ui/regions/regions-outlives-nominal-type-enum-region-rev.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a rev_variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-enum-region-rev.rs:24:11 - | -LL | V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the enum at 23:14 - --> $DIR/regions-outlives-nominal-type-enum-region-rev.rs:23:14 - | -LL | enum Bar<'a,'b> { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 23:17 - --> $DIR/regions-outlives-nominal-type-enum-region-rev.rs:23:17 - | -LL | enum Bar<'a,'b> { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-outlives-nominal-type-enum-region.rs b/src/test/ui/regions/regions-outlives-nominal-type-enum-region.rs index 403757042d2f3521783564870700ef2323abd7a9..07127263bf869814be1c7e140c7378c7fe4d09f7 100644 --- a/src/test/ui/regions/regions-outlives-nominal-type-enum-region.rs +++ b/src/test/ui/regions/regions-outlives-nominal-type-enum-region.rs @@ -13,6 +13,8 @@ // // Rule OutlivesNominalType from RFC 1214. +// compile-pass + #![feature(rustc_attrs)] #![allow(dead_code)] @@ -21,9 +23,8 @@ struct Foo<'a> { x: &'a i32, } enum Bar<'a,'b> { - V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime + V(&'a Foo<'b>) } } -#[rustc_error] fn main() { } diff --git a/src/test/ui/regions/regions-outlives-nominal-type-enum-region.stderr b/src/test/ui/regions/regions-outlives-nominal-type-enum-region.stderr deleted file mode 100644 index ce187eddfa9d69fbd77dc094b7e82fd5e1575e17..0000000000000000000000000000000000000000 --- a/src/test/ui/regions/regions-outlives-nominal-type-enum-region.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-enum-region.rs:24:11 - | -LL | V(&'a Foo<'b>) //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the enum at 23:14 - --> $DIR/regions-outlives-nominal-type-enum-region.rs:23:14 - | -LL | enum Bar<'a,'b> { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 23:17 - --> $DIR/regions-outlives-nominal-type-enum-region.rs:23:17 - | -LL | enum Bar<'a,'b> { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.rs b/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.rs index cc294651db773cc91b5c44abfe268f89526f2a73..4941b568fc6c97ef6a628b98d8a4f6b5ce5f8c54 100644 --- a/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.rs +++ b/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.rs @@ -13,17 +13,18 @@ // // Rule OutlivesNominalType from RFC 1214. +//compile-pass + #![feature(rustc_attrs)] #![allow(dead_code)] -mod rev_variant_struct_type { +mod variant_struct_type { struct Foo { x: fn(T) } enum Bar<'a,'b> { - V(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime + V(&'a Foo<&'b i32>) } } -#[rustc_error] fn main() { } diff --git a/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.stderr b/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.stderr deleted file mode 100644 index 8636b89b71abe181903eb713b7c935e4be2f877f..0000000000000000000000000000000000000000 --- a/src/test/ui/regions/regions-outlives-nominal-type-enum-type-rev.stderr +++ /dev/null @@ -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`. diff --git a/src/test/ui/regions/regions-outlives-nominal-type-enum-type.rs b/src/test/ui/regions/regions-outlives-nominal-type-enum-type.rs index e269767cc1683a817feb16692387077aa5fcf532..38eb0c97a47dea6967a38579070ccd7af2d99e84 100644 --- a/src/test/ui/regions/regions-outlives-nominal-type-enum-type.rs +++ b/src/test/ui/regions/regions-outlives-nominal-type-enum-type.rs @@ -13,6 +13,8 @@ // // Rule OutlivesNominalType from RFC 1214. +// compile-pass + #![feature(rustc_attrs)] #![allow(dead_code)] @@ -21,9 +23,8 @@ struct Foo { x: T } enum Bar<'a,'b> { - F(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime + V(&'a Foo<&'b i32>) } } -#[rustc_error] fn main() { } diff --git a/src/test/ui/regions/regions-outlives-nominal-type-enum-type.stderr b/src/test/ui/regions/regions-outlives-nominal-type-enum-type.stderr deleted file mode 100644 index c209547e20c8489ff20d7c06e563281dd636303d..0000000000000000000000000000000000000000 --- a/src/test/ui/regions/regions-outlives-nominal-type-enum-type.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-enum-type.rs:24:11 - | -LL | F(&'a Foo<&'b i32>) //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the enum at 23:14 - --> $DIR/regions-outlives-nominal-type-enum-type.rs:23:14 - | -LL | enum Bar<'a,'b> { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the enum at 23:17 - --> $DIR/regions-outlives-nominal-type-enum-type.rs:23:17 - | -LL | enum Bar<'a,'b> { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.rs b/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.rs index c7e6ace8b9224165050e505bbb6c603ebe2e02e4..50febdd45797ee8a27476237391f24f397a005a8 100644 --- a/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.rs +++ b/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.rs @@ -13,6 +13,8 @@ // // Rule OutlivesNominalType from RFC 1214. +// compile-pass + #![feature(rustc_attrs)] #![allow(dead_code)] @@ -21,9 +23,8 @@ struct Foo<'a> { x: fn(&'a i32), } struct Bar<'a,'b> { - f: &'a Foo<'b> //~ ERROR reference has a longer lifetime + f: &'a Foo<'b> } } -#[rustc_error] fn main() { } diff --git a/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.stderr b/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.stderr deleted file mode 100644 index 48980bdf8320ed94d4990cd590847bf287e010b3..0000000000000000000000000000000000000000 --- a/src/test/ui/regions/regions-outlives-nominal-type-struct-region-rev.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a rev_variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-struct-region-rev.rs:24:9 - | -LL | f: &'a Foo<'b> //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the struct at 23:16 - --> $DIR/regions-outlives-nominal-type-struct-region-rev.rs:23:16 - | -LL | struct Bar<'a,'b> { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 23:19 - --> $DIR/regions-outlives-nominal-type-struct-region-rev.rs:23:19 - | -LL | struct Bar<'a,'b> { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-outlives-nominal-type-struct-region.rs b/src/test/ui/regions/regions-outlives-nominal-type-struct-region.rs index 2fe6444c33aecd1d060c68c22b280fd99f63f54e..ea07fb4104be160cc6c49fc465e06cd7ffcd03d8 100644 --- a/src/test/ui/regions/regions-outlives-nominal-type-struct-region.rs +++ b/src/test/ui/regions/regions-outlives-nominal-type-struct-region.rs @@ -13,6 +13,8 @@ // // Rule OutlivesNominalType from RFC 1214. +// compile-pass + #![feature(rustc_attrs)] #![allow(dead_code)] @@ -25,5 +27,4 @@ struct Bar<'a,'b> { } } -#[rustc_error] fn main() { } diff --git a/src/test/ui/regions/regions-outlives-nominal-type-struct-region.stderr b/src/test/ui/regions/regions-outlives-nominal-type-struct-region.stderr deleted file mode 100644 index e2b328886b334f9386c1ca3350667dd34b9b8c72..0000000000000000000000000000000000000000 --- a/src/test/ui/regions/regions-outlives-nominal-type-struct-region.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-struct-region.rs:24:9 - | -LL | f: &'a Foo<'b> //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the struct at 23:16 - --> $DIR/regions-outlives-nominal-type-struct-region.rs:23:16 - | -LL | struct Bar<'a,'b> { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 23:19 - --> $DIR/regions-outlives-nominal-type-struct-region.rs:23:19 - | -LL | struct Bar<'a,'b> { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.rs b/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.rs index c4b631bce98740d191b6ec3411c516075cd910b3..735037ac2f6d4a9b507e69d80169723d0729e31b 100644 --- a/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.rs +++ b/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.rs @@ -13,6 +13,8 @@ // // Rule OutlivesNominalType from RFC 1214. +// compile-pass + #![feature(rustc_attrs)] #![allow(dead_code)] @@ -25,5 +27,4 @@ struct Bar<'a,'b> { } } -#[rustc_error] fn main() { } diff --git a/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.stderr b/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.stderr deleted file mode 100644 index 2bf04ffa64afb87f24d9e185dc0e032dd72b2222..0000000000000000000000000000000000000000 --- a/src/test/ui/regions/regions-outlives-nominal-type-struct-type-rev.stderr +++ /dev/null @@ -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`. diff --git a/src/test/ui/regions/regions-outlives-nominal-type-struct-type.rs b/src/test/ui/regions/regions-outlives-nominal-type-struct-type.rs index 1c9489444a6a3a70bdc8a78ed0d6f3dfaba702ee..dfd3583ce6cab95016749f98650f596183024bef 100644 --- a/src/test/ui/regions/regions-outlives-nominal-type-struct-type.rs +++ b/src/test/ui/regions/regions-outlives-nominal-type-struct-type.rs @@ -13,6 +13,8 @@ // // Rule OutlivesNominalType from RFC 1214. +// compile-pass + #![feature(rustc_attrs)] #![allow(dead_code)] @@ -25,5 +27,4 @@ struct Bar<'a,'b> { } } -#[rustc_error] fn main() { } diff --git a/src/test/ui/regions/regions-outlives-nominal-type-struct-type.stderr b/src/test/ui/regions/regions-outlives-nominal-type-struct-type.stderr deleted file mode 100644 index af9f1d3722aebf7c5204b7b65e8717b553d69dae..0000000000000000000000000000000000000000 --- a/src/test/ui/regions/regions-outlives-nominal-type-struct-type.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0491]: in type `&'a variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-struct-type.rs:24:9 - | -LL | f: &'a Foo<&'b i32> //~ ERROR reference has a longer lifetime - | ^^^^^^^^^^^^^^^^^^^ - | -note: the pointer is valid for the lifetime 'a as defined on the struct at 23:16 - --> $DIR/regions-outlives-nominal-type-struct-type.rs:23:16 - | -LL | struct Bar<'a,'b> { - | ^^ -note: but the referenced data is only valid for the lifetime 'b as defined on the struct at 23:19 - --> $DIR/regions-outlives-nominal-type-struct-type.rs:23:19 - | -LL | struct Bar<'a,'b> { - | ^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/regions/regions-struct-not-wf.lexical.stderr b/src/test/ui/regions/regions-struct-not-wf.lexical.stderr deleted file mode 100644 index 9433b8b1952f24b13a61200ba08047251c1818b1..0000000000000000000000000000000000000000 --- a/src/test/ui/regions/regions-struct-not-wf.lexical.stderr +++ /dev/null @@ -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`. diff --git a/src/test/ui/regions/regions-struct-not-wf.nll.stderr b/src/test/ui/regions/regions-struct-not-wf.nll.stderr deleted file mode 100644 index 9433b8b1952f24b13a61200ba08047251c1818b1..0000000000000000000000000000000000000000 --- a/src/test/ui/regions/regions-struct-not-wf.nll.stderr +++ /dev/null @@ -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`. diff --git a/src/test/ui/regions/regions-struct-not-wf.rs b/src/test/ui/regions/regions-struct-not-wf.rs index 9106f1f0ba69c87d45c1fa0df87b4ea15405a709..bdd708197bc768a497ca5b939b5e34858fca96ef 100644 --- a/src/test/ui/regions/regions-struct-not-wf.rs +++ b/src/test/ui/regions/regions-struct-not-wf.rs @@ -10,31 +10,29 @@ // Various examples of structs whose fields are not well-formed. -// revisions:lexical nll - #![allow(dead_code)] -#![cfg_attr(nll, feature(nll))] -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 +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 } -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, T> Trait<'a, T> for u32 { + type Out = RefOk<'a, 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 +impl<'a, 'b, T> Trait1<'a, 'b, T> for u32 { + type Out = &'a &'b T; } fn main() { } diff --git a/src/test/ui/regions/regions-struct-not-wf.stderr b/src/test/ui/regions/regions-struct-not-wf.stderr new file mode 100644 index 0000000000000000000000000000000000000000..d8c8b6c3ccc86bc944f7853c11709d84a333cf12 --- /dev/null +++ b/src/test/ui/regions/regions-struct-not-wf.stderr @@ -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`. diff --git a/src/test/ui/rfc-2093-infer-outlives/cross-crate.rs b/src/test/ui/rfc-2093-infer-outlives/cross-crate.rs index 016739978834b0c9558a94374073ba311f0c8aef..cc659cd14b1a1c5328a228ff3063d922e66cea76 100644 --- a/src/test/ui/rfc-2093-infer-outlives/cross-crate.rs +++ b/src/test/ui/rfc-2093-infer-outlives/cross-crate.rs @@ -9,10 +9,9 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #[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> } diff --git a/src/test/ui/rfc-2093-infer-outlives/cross-crate.stderr b/src/test/ui/rfc-2093-infer-outlives/cross-crate.stderr index a90643ae8916be2a7d27772495ef7555af2064aa..dd00c14ea16f2d3157b41ad29a3f8452f3303e12 100644 --- a/src/test/ui/rfc-2093-infer-outlives/cross-crate.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/cross-crate.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/cross-crate.rs: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 | | } | |_^ diff --git a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs index 72d5127c294dc704cbd32a984e3e8f88a257221c..47dc5dfdc96e6f0a8bd421ae90fdb2ff5b1b977b 100644 --- a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs +++ b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs @@ -10,8 +10,6 @@ // 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` @@ -19,7 +17,7 @@ */ struct Foo { - bar: Bar //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310] + bar: Bar //~ ERROR 20:5: 20:16: the parameter type `U` may not live long enough [E0310] } struct Bar { x: T, diff --git a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr index 775ac215e190df8f8d547a0f4f581cac05ca506e..5d8cf0aa3245c262378a6210b0b7c814ba4a67a8 100644 --- a/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr @@ -1,15 +1,15 @@ error[E0310]: the parameter type `U` may not live long enough - --> $DIR/dont-infer-static.rs:22:5 + --> $DIR/dont-infer-static.rs:20:5 | LL | struct Foo { | - help: consider adding an explicit lifetime bound `U: 'static`... -LL | bar: Bar //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310] +LL | bar: Bar //~ 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 - --> $DIR/dont-infer-static.rs:22:5 + --> $DIR/dont-infer-static.rs:20:5 | -LL | bar: Bar //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310] +LL | bar: Bar //~ ERROR 20:5: 20:16: the parameter type `U` may not live long enough [E0310] | ^^^^^^^^^^^ error: aborting due to previous error diff --git a/src/test/ui/rfc-2093-infer-outlives/enum.rs b/src/test/ui/rfc-2093-infer-outlives/enum.rs index 5071465b5f647569c5c5e754601658179bb411fe..b2c18b274ce013331cb1c94da4cc68fadb730fa2 100644 --- a/src/test/ui/rfc-2093-infer-outlives/enum.rs +++ b/src/test/ui/rfc-2093-infer-outlives/enum.rs @@ -10,24 +10,26 @@ // ignore-tidy-linelength +#![feature(rustc_attrs)] + // Needs an explicit where clause stating outlives condition. (RFC 2093) // Type T needs to outlive lifetime 'a. -enum Foo<'a, T> { - +#[rustc_outlives] +enum Foo<'a, T> { //~ ERROR rustc_outlives One(Bar<'a, T>) } // Type U needs to outlive lifetime 'b -struct Bar<'b, U> { - field2: &'b U //~ ERROR the parameter type `U` may not live long enough [E0309] +#[rustc_outlives] +struct Bar<'b, U> { //~ ERROR rustc_outlives + field2: &'b U } - - // Type K needs to outlive lifetime 'c. -enum Ying<'c, K> { - One(&'c Yang) //~ ERROR the parameter type `K` may not live long enough [E0309] +#[rustc_outlives] +enum Ying<'c, K> { //~ ERROR rustc_outlives + One(&'c Yang) } struct Yang { diff --git a/src/test/ui/rfc-2093-infer-outlives/enum.stderr b/src/test/ui/rfc-2093-infer-outlives/enum.stderr index 604dd0b43c04a775346316858a92a415f0fbd987..e621c435eea35a5301aebf23c46330fbe9eb5e2b 100644 --- a/src/test/ui/rfc-2093-infer-outlives/enum.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/enum.stderr @@ -1,31 +1,32 @@ -error[E0309]: the parameter type `U` may not live long enough - --> $DIR/enum.rs:23:5 +error: rustc_outlives + --> $DIR/enum.rs:19:1 | -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] - | ^^^^^^^^^^^^^ +LL | / enum Foo<'a, T> { //~ ERROR rustc_outlives +LL | | One(Bar<'a, T>) +LL | | } + | |_^ | -note: ...so that the reference type `&'b U` does not outlive the data it points at - --> $DIR/enum.rs:23:5 - | -LL | field2: &'b U //~ ERROR the parameter type `U` may not live long enough [E0309] - | ^^^^^^^^^^^^^ + = note: T : 'a -error[E0309]: the parameter type `K` may not live long enough - --> $DIR/enum.rs:30:9 +error: rustc_outlives + --> $DIR/enum.rs:25:1 + | +LL | / struct Bar<'b, U> { //~ ERROR rustc_outlives +LL | | field2: &'b U +LL | | } + | |_^ | -LL | enum Ying<'c, K> { - | - help: consider adding an explicit lifetime bound `K: 'c`... -LL | One(&'c Yang) //~ ERROR the parameter type `K` may not live long enough [E0309] - | ^^^^^^^^^^^ + = note: U : 'b + +error: rustc_outlives + --> $DIR/enum.rs:31:1 | -note: ...so that the reference type `&'c Yang` does not outlive the data it points at - --> $DIR/enum.rs:30:9 +LL | / enum Ying<'c, K> { //~ ERROR rustc_outlives +LL | | One(&'c Yang) +LL | | } + | |_^ | -LL | One(&'c Yang) //~ ERROR the parameter type `K` may not live long enough [E0309] - | ^^^^^^^^^^^ + = note: K : 'c -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.rs b/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.rs index 445c246a1206726243a59690964e163e40bf486c..9264259520952055409cded862356bc82416fe38 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.rs +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.rs @@ -10,13 +10,12 @@ #![feature(dyn_trait)] #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] trait Trait<'x, T> where T: 'x { } #[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> } diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.stderr b/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.stderr index 4bb5d90e9644ec30ff553243626d1e18a8930ad5..5d167493308fd431aeec1f5ad4c60efd9c922136 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-dyn.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/explicit-dyn.rs: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 | | foo: Box> LL | | } diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-enum.rs b/src/test/ui/rfc-2093-infer-outlives/explicit-enum.rs index e85b49bb0bf2391caefc237a67aa53f2057cb018..0ac75fc255601287f07f65387a514fdddd8a1141 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-enum.rs +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-enum.rs @@ -9,10 +9,9 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #[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>) } diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-enum.stderr b/src/test/ui/rfc-2093-infer-outlives/explicit-enum.stderr index d7438758d77af350e60a16b4ec954322aec6f747..33ef4b7e6a1080d01f300cde271218da7fc12f00 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-enum.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-enum.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/explicit-enum.rs: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 | | } | |_^ diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-projection.rs b/src/test/ui/rfc-2093-infer-outlives/explicit-projection.rs index 2662043c36d59c9e01a461a9d712fc78bd2e10f5..02c171627e6f03bf227b33fa8404346cd770b342 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-projection.rs +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-projection.rs @@ -9,7 +9,6 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] trait Trait<'x, T> where T: 'x { type Type; diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-projection.stderr b/src/test/ui/rfc-2093-infer-outlives/explicit-projection.stderr index 43ab02d01ed57293862b3a099219bd22b60fe641..5480130c2d3f17cc001d9612b12d27191679b354 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-projection.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-projection.stderr @@ -1,5 +1,5 @@ error: rustc_outlives - --> $DIR/explicit-projection.rs:19:1 + --> $DIR/explicit-projection.rs:18:1 | LL | / struct Foo<'a, A, B> where A: Trait<'a, B> //~ ERROR rustc_outlives LL | | { diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-struct.rs b/src/test/ui/rfc-2093-infer-outlives/explicit-struct.rs index d42c9160e1e751c554906ab989f29ee66a7e5fc4..4dc01a5221006e3e338d0594dead0b32de85507c 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-struct.rs +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-struct.rs @@ -9,10 +9,9 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #[rustc_outlives] -struct Foo<'b, U> { //~ ERROR 15:1: 17:2: rustc_outlives +struct Foo<'b, U> { //~ ERROR 14:1: 16:2: rustc_outlives bar: Bar<'b, U> } diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-struct.stderr b/src/test/ui/rfc-2093-infer-outlives/explicit-struct.stderr index 0223f707e8d9bc449059eba59ae23e177af0e67d..7655dec5cb851ff739c9dd9dde9a8a8617806fb6 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-struct.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-struct.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/explicit-struct.rs:15:1 + --> $DIR/explicit-struct.rs:14:1 | -LL | / struct Foo<'b, U> { //~ ERROR 15:1: 17:2: rustc_outlives +LL | / struct Foo<'b, U> { //~ ERROR 14:1: 16:2: rustc_outlives LL | | bar: Bar<'b, U> LL | | } | |_^ diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-union.rs b/src/test/ui/rfc-2093-infer-outlives/explicit-union.rs index e548b24719383cb0697a5a50278922205408b845..ae4b9b15f683bfae216149c81250a5ffa7d51e08 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-union.rs +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-union.rs @@ -9,13 +9,11 @@ // 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 18:1: 20:2: rustc_outlives +union Foo<'b, U> { //~ ERROR 16:1: 18:2: rustc_outlives bar: Bar<'b, U> } diff --git a/src/test/ui/rfc-2093-infer-outlives/explicit-union.stderr b/src/test/ui/rfc-2093-infer-outlives/explicit-union.stderr index 8622ae12aa10cb95a63cfabb6f20276e964540fa..c01c7532c86247d4051de54b37c1ea4d59c8305d 100644 --- a/src/test/ui/rfc-2093-infer-outlives/explicit-union.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/explicit-union.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/explicit-union.rs:18:1 + --> $DIR/explicit-union.rs:16:1 | -LL | / union Foo<'b, U> { //~ ERROR 18:1: 20:2: rustc_outlives +LL | / union Foo<'b, U> { //~ ERROR 16:1: 18:2: rustc_outlives LL | | bar: Bar<'b, U> LL | | } | |_^ diff --git a/src/test/ui/rfc-2093-infer-outlives/infer-static.rs b/src/test/ui/rfc-2093-infer-outlives/infer-static.rs index aeca18c24b3db211e22aaff9ecdd446a6e515f56..c4407b8b89f24a8eb953df006ab09af7aadc3461 100644 --- a/src/test/ui/rfc-2093-infer-outlives/infer-static.rs +++ b/src/test/ui/rfc-2093-infer-outlives/infer-static.rs @@ -9,11 +9,10 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #![feature(infer_static_outlives_requirements)] #[rustc_outlives] -struct Foo { //~ ERROR 16:1: 18:2: rustc_outlives +struct Foo { //~ ERROR 15:1: 17:2: rustc_outlives bar: Bar } struct Bar { diff --git a/src/test/ui/rfc-2093-infer-outlives/infer-static.stderr b/src/test/ui/rfc-2093-infer-outlives/infer-static.stderr index f167e522df650a29f62c53395af769be864e6997..0cb4f3faa335264c3641c2f2af7f271628714139 100644 --- a/src/test/ui/rfc-2093-infer-outlives/infer-static.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/infer-static.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/infer-static.rs:16:1 + --> $DIR/infer-static.rs:15:1 | -LL | / struct Foo { //~ ERROR 16:1: 18:2: rustc_outlives +LL | / struct Foo { //~ ERROR 15:1: 17:2: rustc_outlives LL | | bar: Bar LL | | } | |_^ diff --git a/src/test/ui/rfc-2093-infer-outlives/nested-enum.rs b/src/test/ui/rfc-2093-infer-outlives/nested-enum.rs index 85f381ea515c33e93b4a90274b04b34334aacd69..5cb365b7a7bbf703f5487c3c0feba6c04e040b91 100644 --- a/src/test/ui/rfc-2093-infer-outlives/nested-enum.rs +++ b/src/test/ui/rfc-2093-infer-outlives/nested-enum.rs @@ -9,11 +9,9 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] - #[rustc_outlives] -enum Foo<'a, T> { //~ ERROR 16:1: 19:2: rustc_outlives +enum Foo<'a, T> { //~ ERROR 14:1: 17:2: rustc_outlives One(Bar<'a, T>) } diff --git a/src/test/ui/rfc-2093-infer-outlives/nested-enum.stderr b/src/test/ui/rfc-2093-infer-outlives/nested-enum.stderr index 54a886a92fd409d3d47624bac3e1c5ac56fbb401..f0a6905d14bdda31fcf14c47947b3d1a2b3203e0 100644 --- a/src/test/ui/rfc-2093-infer-outlives/nested-enum.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/nested-enum.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/nested-enum.rs:16:1 + --> $DIR/nested-enum.rs:14:1 | -LL | / enum Foo<'a, T> { //~ ERROR 16:1: 19:2: rustc_outlives +LL | / enum Foo<'a, T> { //~ ERROR 14:1: 17:2: rustc_outlives LL | | LL | | One(Bar<'a, T>) LL | | } diff --git a/src/test/ui/rfc-2093-infer-outlives/nested-regions.rs b/src/test/ui/rfc-2093-infer-outlives/nested-regions.rs index 792d2a02962dcc54e01f8e69a228a0c3e779b219..e56d7d7a053b17363fbdad46520b54ec439ccad7 100644 --- a/src/test/ui/rfc-2093-infer-outlives/nested-regions.rs +++ b/src/test/ui/rfc-2093-infer-outlives/nested-regions.rs @@ -9,10 +9,9 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #[rustc_outlives] -struct Foo<'a, 'b, T> { //~ ERROR 15:1: 17:2: rustc_outlives +struct Foo<'a, 'b, T> { //~ ERROR 14:1: 16:2: rustc_outlives x: &'a &'b T } diff --git a/src/test/ui/rfc-2093-infer-outlives/nested-regions.stderr b/src/test/ui/rfc-2093-infer-outlives/nested-regions.stderr index 04fe4814a0415fb800a682a2c1c490d0d6a8ec87..978fe352bc750b463dbb11c2cd6811a8c3cbcad2 100644 --- a/src/test/ui/rfc-2093-infer-outlives/nested-regions.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/nested-regions.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/nested-regions.rs:15:1 + --> $DIR/nested-regions.rs:14:1 | -LL | / struct Foo<'a, 'b, T> { //~ ERROR 15:1: 17:2: rustc_outlives +LL | / struct Foo<'a, 'b, T> { //~ ERROR 14:1: 16:2: rustc_outlives LL | | x: &'a &'b T LL | | } | |_^ diff --git a/src/test/ui/rfc-2093-infer-outlives/nested-structs.rs b/src/test/ui/rfc-2093-infer-outlives/nested-structs.rs index 71a36dfb344233b048c8f985fb98e3f813891b97..84d1b88188003c6296719d65524413e218445b2a 100644 --- a/src/test/ui/rfc-2093-infer-outlives/nested-structs.rs +++ b/src/test/ui/rfc-2093-infer-outlives/nested-structs.rs @@ -9,10 +9,9 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #[rustc_outlives] -struct Foo<'a, T> { //~ ERROR 15:1: 17:2: rustc_outlives +struct Foo<'a, T> { //~ ERROR 14:1: 16:2: rustc_outlives field1: Bar<'a, T> } diff --git a/src/test/ui/rfc-2093-infer-outlives/nested-structs.stderr b/src/test/ui/rfc-2093-infer-outlives/nested-structs.stderr index abea71f2d12fcf77dfc556b7af27f45c90f128dc..db02232b9130ba02e0170e59ea89227ce77dbe0e 100644 --- a/src/test/ui/rfc-2093-infer-outlives/nested-structs.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/nested-structs.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/nested-structs.rs:15:1 + --> $DIR/nested-structs.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 | | field1: Bar<'a, T> LL | | } | |_^ diff --git a/src/test/ui/rfc-2093-infer-outlives/nested-union.rs b/src/test/ui/rfc-2093-infer-outlives/nested-union.rs index 0720e581e2c5b8783df95b3e3f2ec0d642abec7e..974675f51c711191969a81f7f52f01ad4d2e1442 100644 --- a/src/test/ui/rfc-2093-infer-outlives/nested-union.rs +++ b/src/test/ui/rfc-2093-infer-outlives/nested-union.rs @@ -9,13 +9,11 @@ // 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 18:1: 20:2: rustc_outlives +union Foo<'a, T> { //~ ERROR 16:1: 18:2: rustc_outlives field1: Bar<'a, T> } diff --git a/src/test/ui/rfc-2093-infer-outlives/nested-union.stderr b/src/test/ui/rfc-2093-infer-outlives/nested-union.stderr index b7b50c1506146a0e80401a886dd09a86b2af304f..2704a1d2def779c50e6b3fb626076d6ce5020b2e 100644 --- a/src/test/ui/rfc-2093-infer-outlives/nested-union.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/nested-union.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/nested-union.rs:18:1 + --> $DIR/nested-union.rs:16:1 | -LL | / union Foo<'a, T> { //~ ERROR 18:1: 20:2: rustc_outlives +LL | / union Foo<'a, T> { //~ ERROR 16:1: 18:2: rustc_outlives LL | | field1: Bar<'a, T> LL | | } | |_^ diff --git a/src/test/ui/rfc-2093-infer-outlives/privacy.rs b/src/test/ui/rfc-2093-infer-outlives/privacy.rs new file mode 100644 index 0000000000000000000000000000000000000000..180f5ac6cdc46718e8048602850167a93eff15cf --- /dev/null +++ b/src/test/ui/rfc-2093-infer-outlives/privacy.rs @@ -0,0 +1,20 @@ +// Test that we do not get a privacy error here. Initially, we did, +// because we inferred an outlives predciate of ` as +// Private>::Out: 'a`, but the private trait is -- well -- private, +// and hence it was not something that a pub trait could refer to. +// +// run-pass + +#![allow(dead_code)] + +pub struct Foo<'a> { + field: Option<&'a as Private>::Out> +} + +trait Private { + type Out: ?Sized; +} + +impl Private for T { type Out = Self; } + +fn main() { } diff --git a/src/test/ui/rfc-2093-infer-outlives/projection.rs b/src/test/ui/rfc-2093-infer-outlives/projection.rs index 3abce873b28f9967d2f05ce3ca77aaed734a44ad..7693d0e9401d2594390565e2928c26a9052cb89a 100644 --- a/src/test/ui/rfc-2093-infer-outlives/projection.rs +++ b/src/test/ui/rfc-2093-infer-outlives/projection.rs @@ -9,7 +9,6 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #[rustc_outlives] struct Foo<'a, T: Iterator> { //~ ERROR rustc_outlives diff --git a/src/test/ui/rfc-2093-infer-outlives/projection.stderr b/src/test/ui/rfc-2093-infer-outlives/projection.stderr index dfaf7793a51f26f23e684825739580d272eb285c..fb4835ae2d8bf2cb408a088e7b7ebc0a7559a400 100644 --- a/src/test/ui/rfc-2093-infer-outlives/projection.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/projection.stderr @@ -1,5 +1,5 @@ error: rustc_outlives - --> $DIR/projection.rs:15:1 + --> $DIR/projection.rs:14:1 | LL | / struct Foo<'a, T: Iterator> { //~ ERROR rustc_outlives LL | | bar: &'a T::Item diff --git a/src/test/ui/rfc-2093-infer-outlives/reference.rs b/src/test/ui/rfc-2093-infer-outlives/reference.rs index 56b1bc3c7d11ee0999247b209389cf33246db5c3..760d9889bbe76989285c9bc8623028c01c50fbcc 100644 --- a/src/test/ui/rfc-2093-infer-outlives/reference.rs +++ b/src/test/ui/rfc-2093-infer-outlives/reference.rs @@ -9,7 +9,6 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #[rustc_outlives] struct Foo<'a, T> { //~ ERROR rustc_outlives diff --git a/src/test/ui/rfc-2093-infer-outlives/reference.stderr b/src/test/ui/rfc-2093-infer-outlives/reference.stderr index 785d76e8f22756c49da849289424f6fa281a7a0c..fdd312f9b89c5f8bc34177fd8def3e2e6238ca9f 100644 --- a/src/test/ui/rfc-2093-infer-outlives/reference.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/reference.stderr @@ -1,5 +1,5 @@ error: rustc_outlives - --> $DIR/reference.rs:15:1 + --> $DIR/reference.rs:14:1 | LL | / struct Foo<'a, T> { //~ ERROR rustc_outlives LL | | bar: &'a T, diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs b/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs new file mode 100644 index 0000000000000000000000000000000000000000..a2d3cf6779f1768f4bf620ddd76862cd89bdd934 --- /dev/null +++ b/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.rs @@ -0,0 +1,50 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// ignore-tidy-linelength + +// Various examples of structs whose fields are not well-formed. + +#![allow(dead_code)] + +trait Dummy<'a> { + type Out; +} +impl<'a, T> Dummy<'a> for T +where T: 'a +{ + type Out = (); +} +type RequireOutlives<'a, T> = >::Out; + +enum Ref1<'a, T> { + Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough +} + +enum Ref2<'a, T> { + Ref2Variant1, + Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough +} + +enum RefOk<'a, T:'a> { + RefOkVariant1(&'a T) +} + +// This is now well formed. RFC 2093 +enum RefIndirect<'a, T> { + RefIndirectVariant1(isize, RefOk<'a,T>) +} + +enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] + RefDoubleVariant1(&'a RequireOutlives<'b, T>) + //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309] +} + +fn main() { } diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr new file mode 100644 index 0000000000000000000000000000000000000000..923ea17622ac08e5b62457b8fde3cb2c7dd17886 --- /dev/null +++ b/src/test/ui/rfc-2093-infer-outlives/regions-enum-not-wf.stderr @@ -0,0 +1,67 @@ +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-enum-not-wf.rs:28:18 + | +LL | enum Ref1<'a, T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-enum-not-wf.rs:28:18 + | +LL | Ref1Variant1(RequireOutlives<'a, T>) //~ ERROR the parameter type `T` may not live long enough + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-enum-not-wf.rs:33:25 + | +LL | enum Ref2<'a, T> { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | Ref2Variant1, +LL | Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-enum-not-wf.rs:33:25 + | +LL | Ref2Variant2(isize, RequireOutlives<'a, T>), //~ ERROR the parameter type `T` may not live long enough + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-enum-not-wf.rs:45:1 + | +LL | enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] + | ^ - help: consider adding an explicit lifetime bound `T: 'b`... + | _| + | | +LL | | RefDoubleVariant1(&'a RequireOutlives<'b, T>) +LL | | //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309] +LL | | } + | |_^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-enum-not-wf.rs:45:1 + | +LL | / enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] +LL | | RefDoubleVariant1(&'a RequireOutlives<'b, T>) +LL | | //~^ 46:23: 46:49: the parameter type `T` may not live long enough [E0309] +LL | | } + | |_^ + +error[E0309]: the parameter type `T` may not live long enough + --> $DIR/regions-enum-not-wf.rs:46:23 + | +LL | enum RefDouble<'a, 'b, T> { //~ ERROR 45:1: 48:2: the parameter type `T` may not live long enough [E0309] + | - help: consider adding an explicit lifetime bound `T: 'b`... +LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: ...so that the type `T` will meet its required lifetime bounds + --> $DIR/regions-enum-not-wf.rs:46:23 + | +LL | RefDoubleVariant1(&'a RequireOutlives<'b, T>) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0309`. diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs new file mode 100644 index 0000000000000000000000000000000000000000..44af621ef24dc8b7ca649828db6408b14d2b4386 --- /dev/null +++ b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod rev_variant_struct_region { + struct Foo<'a> { + x: fn(&'a i32), + } + trait Trait<'a, 'b> { + type Out; + } + impl<'a, 'b> Trait<'a, 'b> for usize { + type Out = &'a Foo<'b>; //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr new file mode 100644 index 0000000000000000000000000000000000000000..bd4682f0acfe70c58ac964eafb18329d526e2780 --- /dev/null +++ b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a rev_variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-region-rev.rs:27:9 + | +LL | type Out = &'a Foo<'b>; //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the impl at 26:10 + --> $DIR/regions-outlives-nominal-type-region-rev.rs:26:10 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the impl at 26:14 + --> $DIR/regions-outlives-nominal-type-region-rev.rs:26:14 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs new file mode 100644 index 0000000000000000000000000000000000000000..93f16350a7b4dcb7a7e70d59c7f3c580aa28bf30 --- /dev/null +++ b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod variant_struct_region { + struct Foo<'a> { + x: &'a i32, + } + trait Trait<'a, 'b> { + type Out; + } + impl<'a, 'b> Trait<'a, 'b> for usize { + type Out = &'a Foo<'b>; //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr new file mode 100644 index 0000000000000000000000000000000000000000..3fdfb673b3700ada395eb097e304dbd01dbdea70 --- /dev/null +++ b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a variant_struct_region::Foo<'b>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-region.rs:27:9 + | +LL | type Out = &'a Foo<'b>; //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the impl at 26:10 + --> $DIR/regions-outlives-nominal-type-region.rs:26:10 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the impl at 26:14 + --> $DIR/regions-outlives-nominal-type-region.rs:26:14 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs new file mode 100644 index 0000000000000000000000000000000000000000..e44e049a9e5dc3a3cf5ec123420917eaa5898369 --- /dev/null +++ b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod variant_struct_type { + struct Foo { + x: fn(T) + } + trait Trait<'a, 'b> { + type Out; + } + impl<'a, 'b> Trait<'a, 'b> for usize { + type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr new file mode 100644 index 0000000000000000000000000000000000000000..166e95cdeddf30693236f555d11471d6f0aab2e6 --- /dev/null +++ b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-type-rev.rs:27:9 + | +LL | type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the impl at 26:10 + --> $DIR/regions-outlives-nominal-type-type-rev.rs:26:10 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the impl at 26:14 + --> $DIR/regions-outlives-nominal-type-type-rev.rs:26:14 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs new file mode 100644 index 0000000000000000000000000000000000000000..1293e6c234bc14de26722937d2b2cc12d63e314e --- /dev/null +++ b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.rs @@ -0,0 +1,32 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Test that a nominal type (like `Foo<'a>`) outlives `'b` if its +// arguments (like `'a`) outlive `'b`. +// +// Rule OutlivesNominalType from RFC 1214. + +#![feature(rustc_attrs)] +#![allow(dead_code)] + +mod variant_struct_type { + struct Foo { + x: T + } + trait Trait<'a, 'b> { + type Out; + } + impl<'a, 'b> Trait<'a, 'b> for usize { + type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime + } +} + +#[rustc_error] +fn main() { } diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr new file mode 100644 index 0000000000000000000000000000000000000000..54952ec1676dbd71124544053e90402714bed230 --- /dev/null +++ b/src/test/ui/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr @@ -0,0 +1,20 @@ +error[E0491]: in type `&'a variant_struct_type::Foo<&'b i32>`, reference has a longer lifetime than the data it references + --> $DIR/regions-outlives-nominal-type-type.rs:27:9 + | +LL | type Out = &'a Foo<&'b i32>; //~ ERROR reference has a longer lifetime + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the pointer is valid for the lifetime 'a as defined on the impl at 26:10 + --> $DIR/regions-outlives-nominal-type-type.rs:26:10 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ +note: but the referenced data is only valid for the lifetime 'b as defined on the impl at 26:14 + --> $DIR/regions-outlives-nominal-type-type.rs:26:14 + | +LL | impl<'a, 'b> Trait<'a, 'b> for usize { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0491`. diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs b/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs new file mode 100644 index 0000000000000000000000000000000000000000..bdd708197bc768a497ca5b939b5e34858fca96ef --- /dev/null +++ b/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.rs @@ -0,0 +1,38 @@ +// Copyright 2014 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// 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() { } diff --git a/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr b/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr new file mode 100644 index 0000000000000000000000000000000000000000..d8c8b6c3ccc86bc944f7853c11709d84a333cf12 --- /dev/null +++ b/src/test/ui/rfc-2093-infer-outlives/regions-struct-not-wf.stderr @@ -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`. diff --git a/src/test/ui/rfc-2093-infer-outlives/self-dyn.rs b/src/test/ui/rfc-2093-infer-outlives/self-dyn.rs index a19bcf8afff9a8d35fad799e6ad81745c0ac505c..37c468f2f83101c4f660cd15d5c2fb9b2b48ba00 100644 --- a/src/test/ui/rfc-2093-infer-outlives/self-dyn.rs +++ b/src/test/ui/rfc-2093-infer-outlives/self-dyn.rs @@ -10,14 +10,13 @@ #![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 20:1: 23:2: rustc_outlives +struct Foo<'a, 'b, A> //~ ERROR 19:1: 22:2: rustc_outlives { foo: Box> } diff --git a/src/test/ui/rfc-2093-infer-outlives/self-dyn.stderr b/src/test/ui/rfc-2093-infer-outlives/self-dyn.stderr index 546ba9db6446007a211b060726807b6c898b18d0..8c69307ddfb72da571caeb7bfcce80b326f7f2ff 100644 --- a/src/test/ui/rfc-2093-infer-outlives/self-dyn.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/self-dyn.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/self-dyn.rs:20:1 + --> $DIR/self-dyn.rs:19:1 | -LL | / struct Foo<'a, 'b, A> //~ ERROR 20:1: 23:2: rustc_outlives +LL | / struct Foo<'a, 'b, A> //~ ERROR 19:1: 22:2: rustc_outlives LL | | { LL | | foo: Box> LL | | } diff --git a/src/test/ui/rfc-2093-infer-outlives/self-structs.rs b/src/test/ui/rfc-2093-infer-outlives/self-structs.rs index c4f8f83bdcefd0d77d547d477d568b22c373e267..82d13d9179a1b7b376d567571292dbe3c8b93233 100644 --- a/src/test/ui/rfc-2093-infer-outlives/self-structs.rs +++ b/src/test/ui/rfc-2093-infer-outlives/self-structs.rs @@ -9,10 +9,9 @@ // except according to those terms. #![feature(rustc_attrs)] -#![feature(infer_outlives_requirements)] #[rustc_outlives] -struct Foo<'a, 'b, T> { //~ ERROR 15:1: 17:2: rustc_outlives +struct Foo<'a, 'b, T> { //~ ERROR 14:1: 16:2: rustc_outlives field1: Bar<'a, 'b, T> } diff --git a/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr b/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr index 04284577a07467c25052be427031df1afece9ba2..541e282f23874f3a4f6b245d456e87c603043f0a 100644 --- a/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr +++ b/src/test/ui/rfc-2093-infer-outlives/self-structs.stderr @@ -1,7 +1,7 @@ error: rustc_outlives - --> $DIR/self-structs.rs:15:1 + --> $DIR/self-structs.rs:14:1 | -LL | / struct Foo<'a, 'b, T> { //~ ERROR 15:1: 17:2: rustc_outlives +LL | / struct Foo<'a, 'b, T> { //~ ERROR 14:1: 16:2: rustc_outlives LL | | field1: Bar<'a, 'b, T> LL | | } | |_^ diff --git a/src/test/ui/typeck/typeck_type_placeholder_item.stderr b/src/test/ui/typeck/typeck_type_placeholder_item.stderr index 3f814085955f75ada1e2a61ee16675f326a49c0e..598f18bf8d8d2b62f1cde515a11e6d4f682452b9 100644 --- a/src/test/ui/typeck/typeck_type_placeholder_item.stderr +++ b/src/test/ui/typeck/typeck_type_placeholder_item.stderr @@ -76,6 +76,24 @@ error[E0121]: the type placeholder `_` is not allowed within types on item signa LL | b: (_, _), | ^ not allowed in type signatures +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/typeck_type_placeholder_item.rs:112:12 + | +LL | a: _, + | ^ not allowed in type signatures + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/typeck_type_placeholder_item.rs:114:13 + | +LL | b: (_, _), + | ^ not allowed in type signatures + +error[E0121]: the type placeholder `_` is not allowed within types on item signatures + --> $DIR/typeck_type_placeholder_item.rs:114:16 + | +LL | b: (_, _), + | ^ not allowed in type signatures + error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:67:21 | @@ -136,24 +154,6 @@ error[E0121]: the type placeholder `_` is not allowed within types on item signa LL | fn fn_test8(_f: fn() -> _) { } | ^ not allowed in type signatures -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:112:12 - | -LL | a: _, - | ^ not allowed in type signatures - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:114:13 - | -LL | b: (_, _), - | ^ not allowed in type signatures - -error[E0121]: the type placeholder `_` is not allowed within types on item signatures - --> $DIR/typeck_type_placeholder_item.rs:114:16 - | -LL | b: (_, _), - | ^ not allowed in type signatures - error[E0121]: the type placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:43:24 | diff --git a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs index c11b2e4c544e1fd524f25affa77fe82a637c2fed..afdf59d1e5bc55d22cba7292b944b7207bdee11f 100644 --- a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs +++ b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.rs @@ -8,25 +8,26 @@ // 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 { } +trait Trait<'a, T> { + type Out; +} + +impl<'a, T> Trait<'a, T> for usize { + type Out = &'a fn(T); +} struct Foo<'a,T> { f: &'a fn(T), - //~^ ERROR E0309 } -struct Bar<'a,T> { - f: &'a Trait, - //~^ ERROR E0309 +trait Baz { } + +impl<'a, T> Trait<'a, T> for u32 { + type Out = &'a Baz; } -#[rustc_error] fn main() { } diff --git a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr index 9a8c63126f28ec0a64e563f27f8b870e77fcddee..26a2138c9f83c2afa689c4027f19731f577d2cfa 100644 --- a/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr +++ b/src/test/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr @@ -1,30 +1,30 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:21:5 + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:19:5 | -LL | struct Foo<'a,T> { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | f: &'a fn(T), - | ^^^^^^^^^^^^ +LL | impl<'a, T> Trait<'a, T> for usize { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | type Out = &'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:21:5 + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:19:5 | -LL | f: &'a fn(T), - | ^^^^^^^^^^^^ +LL | type Out = &'a fn(T); + | ^^^^^^^^^^^^^^^^^^^^^ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:26:5 + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:29:5 | -LL | struct Bar<'a,T> { - | - help: consider adding an explicit lifetime bound `T: 'a`... -LL | f: &'a Trait, - | ^^^^^^^^^^^^^^^ +LL | impl<'a, T> Trait<'a, T> for u32 { + | - help: consider adding an explicit lifetime bound `T: 'a`... +LL | type Out = &'a Baz; + | ^^^^^^^^^^^^^^^^^^^^^^ | -note: ...so that the reference type `&'a (dyn Trait + 'a)` does not outlive the data it points at - --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:26:5 +note: ...so that the reference type `&'a (dyn Baz + 'a)` does not outlive the data it points at + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:29:5 | -LL | f: &'a Trait, - | ^^^^^^^^^^^^^^^ +LL | type Out = &'a Baz; + | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 2 previous errors