]> git.lizzy.rs Git - rust.git/blob - tests/ui/constructor-lifetime-args.rs
Rollup merge of #106709 - khuey:disable_split_dwarf_inlining_by_default, r=davidtwco
[rust.git] / tests / ui / constructor-lifetime-args.rs
1 // All lifetime parameters in struct constructors are currently considered early bound,
2 // i.e., `S::<ARGS>` is interpreted kinda like an associated item `S::<ARGS>::ctor`.
3 // This behavior is a bit weird, because if equivalent constructor were written manually
4 // it would get late bound lifetime parameters.
5 // Variant constructors behave in the same way, lifetime parameters are considered
6 // belonging to the enum and being early bound.
7 // https://github.com/rust-lang/rust/issues/30904
8
9 struct S<'a, 'b>(&'a u8, &'b u8);
10 enum E<'a, 'b> {
11     V(&'a u8),
12     U(&'b u8),
13 }
14
15 fn main() {
16     S(&0, &0); // OK
17     S::<'static>(&0, &0);
18     //~^ ERROR this struct takes 2 lifetime arguments
19     S::<'static, 'static, 'static>(&0, &0);
20     //~^ ERROR this struct takes 2 lifetime arguments
21     E::V(&0); // OK
22     E::V::<'static>(&0);
23     //~^ ERROR this enum takes 2 lifetime arguments
24     E::V::<'static, 'static, 'static>(&0);
25     //~^ ERROR this enum takes 2 lifetime arguments
26 }