Skip to content

Commit 8380b25

Browse files
committed
Add UI test for preserving user types in type ascriptions
1 parent 4a293a3 commit 8380b25

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2012-2014 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+
12+
#![allow(warnings)]
13+
#![feature(nll)]
14+
#![feature(type_ascription)]
15+
16+
fn main() {
17+
let x = 22_u32;
18+
let y: &u32 = &x: &'static u32; //~ ERROR E0597
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error[E0597]: `x` does not live long enough
2+
--> $DIR/type_ascription_static_lifetime.rs:18:19
3+
|
4+
LL | let y: &u32 = &x: &'static u32; //~ ERROR E0597
5+
| ^^ borrowed value does not live long enough
6+
LL | }
7+
| - `x` dropped here while still borrowed
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`.

0 commit comments

Comments
 (0)