]> git.lizzy.rs Git - rust.git/blobdiff - src/test/ui/issues/issue-45696-scribble-on-boxed-borrow.rs
Rollup merge of #62337 - Mark-Simulacrum:fix-cpu-usage-script, r=alexcrichton
[rust.git] / src / test / ui / issues / issue-45696-scribble-on-boxed-borrow.rs
index 2af05172d24db05cddf4048c3b4374378154e2aa..f568efa487cd736857243428ea8de1e7a9bcde8c 100644 (file)
@@ -1,32 +1,20 @@
-// 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);
 
@@ -62,7 +50,8 @@ fn boxed_boxed_borrowed_scribble<'a>(s: Box<Box<&'a mut Scribble>>) -> &'a mut u
 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.
@@ -72,7 +61,8 @@ fn scribbled<'a>(s: Scribble<'a>) -> &'a mut u32 {
 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.
@@ -82,12 +72,12 @@ fn boxed_scribbled<'a>(s: Box<Scribble<'a>>) -> &'a mut u32 {
 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);