Add UI test for preserving user types in type ascriptions

This commit is contained in:
Keith Yeung 2018-09-25 11:51:36 -07:00
parent 4a293a3990
commit 8380b25d13
2 changed files with 32 additions and 0 deletions

View file

@ -0,0 +1,19 @@
// Copyright 2012-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 <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.
#![allow(warnings)]
#![feature(nll)]
#![feature(type_ascription)]
fn main() {
let x = 22_u32;
let y: &u32 = &x: &'static u32; //~ ERROR E0597
}

View file

@ -0,0 +1,13 @@
error[E0597]: `x` does not live long enough
--> $DIR/type_ascription_static_lifetime.rs:18:19
|
LL | let y: &u32 = &x: &'static u32; //~ ERROR E0597
| ^^ borrowed value does not live long enough
LL | }
| - `x` dropped here while still borrowed
|
= note: borrowed value must be valid for the static lifetime...
error: aborting due to previous error
For more information about this error, try `rustc --explain E0597`.