-// Copyright 2018 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.
-
// rust-lang/rust#45696: This test is checking that we *cannot* return
// mutable borrows that would be scribbled over by destructors before
// the return occurs.
//
-// We will explicitly test AST-borrowck, NLL, and migration modes;
+// We will explicitly test NLL, and migration modes;
// thus we will also skip the automated compare-mode=nll.
-// revisions: ast nll migrate
+// revisions: nll migrate
// ignore-compare-mode-nll
-// This test is going to pass in the ast and migrate revisions,
-// because the AST-borrowck accepted this code in the past (see notes
-// below). So we use `#[rustc_error]` to keep the outcome as an error
-// in all scenarios, and rely on the stderr files to show what the
-// actual behavior is. (See rust-lang/rust#49855.)
+// This test is going to pass in the migrate revision, because the AST-borrowck
+// accepted this code in the past (see notes below). So we use `#[rustc_error]`
+// to keep the outcome as an error in all scenarios, and rely on the stderr
+// files to show what the actual behavior is. (See rust-lang/rust#49855.)
#![feature(rustc_attrs)]
#![cfg_attr(nll, feature(nll))]
-//[migrate]compile-flags: -Z borrowck=migrate -Z two-phase-borrows
struct Scribble<'a>(&'a mut u32);
fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 {
&mut *s.0 //[nll]~ ERROR borrow may still be in use when destructor runs [E0713]
//[migrate]~^ WARNING borrow may still be in use when destructor runs [E0713]
- //[migrate]~| WARNING This error has been downgraded to a warning for backwards compatibility
+ //[migrate]~| WARNING this error has been downgraded to a warning for backwards compatibility
+ //[migrate]~| WARNING this represents potential undefined behavior in your code
}
// This, by analogy to previous case, is *also* not okay.
fn boxed_scribbled<'a>(s: Box<Scribble<'a>>) -> &'a mut u32 {
&mut *(*s).0 //[nll]~ ERROR borrow may still be in use when destructor runs [E0713]
//[migrate]~^ WARNING borrow may still be in use when destructor runs [E0713]
- //[migrate]~| WARNING This error has been downgraded to a warning for backwards compatibility
+ //[migrate]~| WARNING this error has been downgraded to a warning for backwards compatibility
+ //[migrate]~| WARNING this represents potential undefined behavior in your code
}
// This, by analogy to previous case, is *also* not okay.
fn boxed_boxed_scribbled<'a>(s: Box<Box<Scribble<'a>>>) -> &'a mut u32 {
&mut *(**s).0 //[nll]~ ERROR borrow may still be in use when destructor runs [E0713]
//[migrate]~^ WARNING borrow may still be in use when destructor runs [E0713]
- //[migrate]~| WARNING This error has been downgraded to a warning for backwards compatibility
+ //[migrate]~| WARNING this error has been downgraded to a warning for backwards compatibility
+ //[migrate]~| WARNING this represents potential undefined behavior in your code
}
#[rustc_error]
-fn main() { //[ast]~ ERROR compilation successful
- //[migrate]~^ ERROR compilation successful
+fn main() { //[migrate]~ ERROR compilation successful
let mut x = 1;
{
let mut long_lived = Scribble(&mut x);