Auto merge of #52761 - toidiu:ak-static-infer-fg, r=nikomatsakis
static infer feature gate https://github.com/rust-lang/rust/issues/44493 r? @nikomatsakis
This commit is contained in:
commit
5b465e309d
9 changed files with 199 additions and 7 deletions
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// Needs an explicit where clause stating outlives condition. (RFC 2093)
|
||||
|
||||
// Type T needs to outlive lifetime 'static.
|
||||
struct Foo<U> {
|
||||
bar: Bar<U> //~ ERROR 15:5: 15:16: the parameter type `U` may not live long enough [E0310]
|
||||
}
|
||||
struct Bar<T: 'static> {
|
||||
x: T,
|
||||
}
|
||||
|
||||
|
||||
fn main() { }
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
error[E0310]: the parameter type `U` may not live long enough
|
||||
--> $DIR/feature-gate-infer_static_outlives_requirements.rs:15:5
|
||||
|
|
||||
LL | struct Foo<U> {
|
||||
| - help: consider adding an explicit lifetime bound `U: 'static`...
|
||||
LL | bar: Bar<U> //~ ERROR 15:5: 15:16: the parameter type `U` may not live long enough [E0310]
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
note: ...so that the type `U` will meet its required lifetime bounds
|
||||
--> $DIR/feature-gate-infer_static_outlives_requirements.rs:15:5
|
||||
|
|
||||
LL | bar: Bar<U> //~ ERROR 15:5: 15:16: the parameter type `U` may not live long enough [E0310]
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0310`.
|
||||
29
src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs
Normal file
29
src/test/ui/rfc-2093-infer-outlives/dont-infer-static.rs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// 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`
|
||||
* is required.
|
||||
*/
|
||||
|
||||
struct Foo<U> {
|
||||
bar: Bar<U> //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310]
|
||||
}
|
||||
struct Bar<T: 'static> {
|
||||
x: T,
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
17
src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr
Normal file
17
src/test/ui/rfc-2093-infer-outlives/dont-infer-static.stderr
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
error[E0310]: the parameter type `U` may not live long enough
|
||||
--> $DIR/dont-infer-static.rs:22:5
|
||||
|
|
||||
LL | struct Foo<U> {
|
||||
| - help: consider adding an explicit lifetime bound `U: 'static`...
|
||||
LL | bar: Bar<U> //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310]
|
||||
| ^^^^^^^^^^^
|
||||
|
|
||||
note: ...so that the type `U` will meet its required lifetime bounds
|
||||
--> $DIR/dont-infer-static.rs:22:5
|
||||
|
|
||||
LL | bar: Bar<U> //~ ERROR 22:5: 22:16: the parameter type `U` may not live long enough [E0310]
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0310`.
|
||||
24
src/test/ui/rfc-2093-infer-outlives/infer-static.rs
Normal file
24
src/test/ui/rfc-2093-infer-outlives/infer-static.rs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(rustc_attrs)]
|
||||
#![feature(infer_outlives_requirements)]
|
||||
#![feature(infer_static_outlives_requirements)]
|
||||
|
||||
#[rustc_outlives]
|
||||
struct Foo<U> { //~ ERROR 16:1: 18:2: rustc_outlives
|
||||
bar: Bar<U>
|
||||
}
|
||||
struct Bar<T: 'static> {
|
||||
x: T,
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
12
src/test/ui/rfc-2093-infer-outlives/infer-static.stderr
Normal file
12
src/test/ui/rfc-2093-infer-outlives/infer-static.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
error: rustc_outlives
|
||||
--> $DIR/infer-static.rs:16:1
|
||||
|
|
||||
LL | / struct Foo<U> { //~ ERROR 16:1: 18:2: rustc_outlives
|
||||
LL | | bar: Bar<U>
|
||||
LL | | }
|
||||
| |_^
|
||||
|
|
||||
= note: U : 'static
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue