Skip to content

Commit dba1c71

Browse files
committed
Check cross crate stability of const fn
1 parent 458f5a2 commit dba1c71

7 files changed

+92
-1
lines changed

Diff for: src/test/ui/consts/const-eval/auxiliary/stability.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Crate that exports a const fn. Used for testing cross-crate.
12+
13+
#![crate_type="rlib"]
14+
#![stable(feature = "rust1", since = "1.0.0")]
15+
16+
#![feature(rustc_const_unstable, const_fn)]
17+
#![feature(staged_api)]
18+
19+
#[stable(feature = "rust1", since = "1.0.0")]
20+
#[rustc_const_unstable(feature="foo")]
21+
pub const fn foo() -> u32 { 42 }

Diff for: src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.nll.stderr

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ error[E0597]: borrowed value does not live long enough
1111
|
1212
LL | let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis();
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
14+
LL | //~^ does not live long enough
1415
LL | }
1516
| - temporary value only lives until here
1617
|

Diff for: src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.rs

+1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ fn a() {
3131
fn main() {
3232
let _: &'static u32 = &meh(); //~ ERROR does not live long enough
3333
let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis();
34+
//~^ does not live long enough
3435
}

Diff for: src/test/ui/consts/const-eval/dont_promote_unstable_const_fn.stderr

+12-1
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,23 @@ error[E0597]: borrowed value does not live long enough
2121
|
2222
LL | let _: &'static u32 = &meh(); //~ ERROR does not live long enough
2323
| ^^^^^ temporary value does not live long enough
24+
...
25+
LL | }
26+
| - temporary value only lives until here
27+
|
28+
= note: borrowed value must be valid for the static lifetime...
29+
30+
error[E0597]: borrowed value does not live long enough
31+
--> $DIR/dont_promote_unstable_const_fn.rs:33:26
32+
|
2433
LL | let x: &'static _ = &std::time::Duration::from_millis(42).subsec_millis();
34+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
35+
LL | //~^ does not live long enough
2536
LL | }
2637
| - temporary value only lives until here
2738
|
2839
= note: borrowed value must be valid for the static lifetime...
2940

30-
error: aborting due to 3 previous errors
41+
error: aborting due to 4 previous errors
3142

3243
For more information about this error, try `rustc --explain E0597`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0597]: borrowed value does not live long enough
2+
--> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:19:29
3+
|
4+
LL | let _x: &'static u32 = &foo(); //~ ERROR does not live long enough
5+
| ^^^^^ temporary value does not live long enough
6+
LL | }
7+
| - temporary value only lives until here
8+
|
9+
= note: borrowed value must be valid for the static lifetime...
10+
11+
error: aborting due to previous error
12+
13+
For more information about this error, try `rustc --explain E0597`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:stability.rs
12+
13+
extern crate stability;
14+
15+
use stability::foo;
16+
17+
fn main() {
18+
let _: &'static u32 = &foo(); //~ ERROR does not live long enough
19+
let _x: &'static u32 = &foo(); //~ ERROR does not live long enough
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
error[E0597]: borrowed value does not live long enough
2+
--> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:18:28
3+
|
4+
LL | let _: &'static u32 = &foo(); //~ ERROR does not live long enough
5+
| ^^^^^ temporary value does not live long enough
6+
LL | let _x: &'static u32 = &foo(); //~ ERROR does not live long enough
7+
LL | }
8+
| - temporary value only lives until here
9+
|
10+
= note: borrowed value must be valid for the static lifetime...
11+
12+
error[E0597]: borrowed value does not live long enough
13+
--> $DIR/dont_promote_unstable_const_fn_cross_crate.rs:19:29
14+
|
15+
LL | let _x: &'static u32 = &foo(); //~ ERROR does not live long enough
16+
| ^^^^^ temporary value does not live long enough
17+
LL | }
18+
| - temporary value only lives until here
19+
|
20+
= note: borrowed value must be valid for the static lifetime...
21+
22+
error: aborting due to 2 previous errors
23+
24+
For more information about this error, try `rustc --explain E0597`.

0 commit comments

Comments
 (0)