From 1c8d2bdda16854743069988fdb50a0185dfcb472 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Wed, 11 Apr 2018 00:20:05 +0200 Subject: [PATCH] Workaround rust-lang/rust#49855 by forcing rustc_error in any mode, including NLL. NOTE: I was careful to make each change in a manner that preserves the existing diagnostic output (usually by ensuring that no lines were added or removed). This means that the resulting source files are not as nice to read as they were at the start. But we will have to review these cases by hand anyway as follow-up work, so cleanup could reasonably happen then (or not at all). --- .../ui/borrowck/borrowck-report-with-custom-diagnostic.rs | 4 ++-- src/test/ui/borrowck/mut-borrow-outside-loop.rs | 4 ++-- src/test/ui/codemap_tests/issue-11715.rs | 4 ++-- src/test/ui/dropck/dropck-eyepatch-extern-crate.rs | 4 ++-- src/test/ui/dropck/dropck-eyepatch-reorder.rs | 4 ++-- src/test/ui/dropck/dropck-eyepatch.rs | 4 ++-- src/test/ui/error-codes/E0499.rs | 4 ++-- src/test/ui/error-codes/E0502.rs | 4 ++-- src/test/ui/error-codes/E0503.rs | 4 ++-- src/test/ui/error-codes/E0505.rs | 4 ++-- src/test/ui/error-codes/E0597.rs | 4 ++-- src/test/ui/feature-gate-nll.rs | 4 ++-- src/test/ui/generator/borrowing.rs | 4 ++-- src/test/ui/generator/dropck.rs | 4 ++-- src/test/ui/generator/pattern-borrow.rs | 4 ++-- src/test/ui/issue-17263.rs | 4 ++-- src/test/ui/issue-25793.rs | 4 ++-- src/test/ui/issue-42106.rs | 4 ++-- src/test/ui/lifetimes/borrowck-let-suggestion.rs | 4 ++-- src/test/ui/span/borrowck-let-suggestion-suffixes.rs | 4 ++-- src/test/ui/span/issue-36537.rs | 4 ++-- src/test/ui/span/mut-ptr-cant-outlive-ref.rs | 4 ++-- src/test/ui/span/range-2.rs | 4 ++-- src/test/ui/span/regionck-unboxed-closure-lifetimes.rs | 4 ++-- src/test/ui/span/slice-borrow.rs | 4 ++-- src/test/ui/span/vec_refs_data_with_early_death.rs | 4 ++-- src/test/ui/span/wf-method-late-bound-regions.rs | 4 ++-- 27 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs b/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs index a6553160557e..cdfee2e8a704 100644 --- a/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs +++ b/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs @@ -7,9 +7,9 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - +#![feature(rustc_attrs)] #![allow(dead_code)] -fn main() { +fn main() { #![rustc_error] // rust-lang/rust#49855 // Original borrow ends at end of function let mut x = 1; let y = &mut x; diff --git a/src/test/ui/borrowck/mut-borrow-outside-loop.rs b/src/test/ui/borrowck/mut-borrow-outside-loop.rs index a1ab41bab337..edc877718ad0 100644 --- a/src/test/ui/borrowck/mut-borrow-outside-loop.rs +++ b/src/test/ui/borrowck/mut-borrow-outside-loop.rs @@ -9,8 +9,8 @@ // except according to those terms. // ensure borrowck messages are correct outside special case - -fn main() { +#![feature(rustc_attrs)] +fn main() { #![rustc_error] // rust-lang/rust#49855 let mut void = (); let first = &mut void; diff --git a/src/test/ui/codemap_tests/issue-11715.rs b/src/test/ui/codemap_tests/issue-11715.rs index 75581d389271..03c85fbfcd77 100644 --- a/src/test/ui/codemap_tests/issue-11715.rs +++ b/src/test/ui/codemap_tests/issue-11715.rs @@ -93,8 +93,8 @@ - -fn main() { +#![feature(rustc_attrs)] +fn main() { #![rustc_error] // rust-lang/rust#49855 let mut x = "foo"; let y = &mut x; let z = &mut x; //~ ERROR cannot borrow diff --git a/src/test/ui/dropck/dropck-eyepatch-extern-crate.rs b/src/test/ui/dropck/dropck-eyepatch-extern-crate.rs index 4f88b0e6fccf..e06b47a8d79d 100644 --- a/src/test/ui/dropck/dropck-eyepatch-extern-crate.rs +++ b/src/test/ui/dropck/dropck-eyepatch-extern-crate.rs @@ -19,12 +19,12 @@ // // See also dropck-eyepatch.rs for more information about the general // structure of the test. - +#![feature(rustc_attrs)] extern crate dropck_eyepatch_extern_crate as other; use other::{Dt,Dr,Pt,Pr,St,Sr}; -fn main() { +fn main() { #![rustc_error] // rust-lang/rust#49855 use std::cell::Cell; let c_long; let (c, mut dt, mut dr, mut pt, mut pr, st, sr) diff --git a/src/test/ui/dropck/dropck-eyepatch-reorder.rs b/src/test/ui/dropck/dropck-eyepatch-reorder.rs index eda8d85f6ec9..832eeacbec54 100644 --- a/src/test/ui/dropck/dropck-eyepatch-reorder.rs +++ b/src/test/ui/dropck/dropck-eyepatch-reorder.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(dropck_eyepatch)] +#![feature(dropck_eyepatch, rustc_attrs)] // The point of this test is to test uses of `#[may_dangle]` attribute // where the formal declaration order (in the impl generics) does not @@ -41,7 +41,7 @@ unsafe impl<'b, #[may_dangle] 'a, B: fmt::Debug> Drop for Pr<'a, 'b, B> { fn drop(&mut self) { println!("drop {} {:?}", self.0, self.2); } } -fn main() { +fn main() { #![rustc_error] // rust-lang/rust#49855 use std::cell::Cell; let c_long; let (c, mut dt, mut dr, mut pt, mut pr, st, sr) diff --git a/src/test/ui/dropck/dropck-eyepatch.rs b/src/test/ui/dropck/dropck-eyepatch.rs index af173a2e9791..cfa67837485e 100644 --- a/src/test/ui/dropck/dropck-eyepatch.rs +++ b/src/test/ui/dropck/dropck-eyepatch.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(dropck_eyepatch)] +#![feature(dropck_eyepatch, rustc_attrs)] // The point of this test is to illustrate that the `#[may_dangle]` // attribute specifically allows, in the context of a type @@ -64,7 +64,7 @@ unsafe impl<#[may_dangle] 'a, 'b, B: fmt::Debug> Drop for Pr<'a, 'b, B> { fn drop(&mut self) { println!("drop {} {:?}", self.0, self.2); } } -fn main() { +fn main() { #![rustc_error] // rust-lang/rust#49855 use std::cell::Cell; let c_long; let (c, mut dt, mut dr, mut pt, mut pr, st, sr) diff --git a/src/test/ui/error-codes/E0499.rs b/src/test/ui/error-codes/E0499.rs index 9a64bfe2ea9e..c39972369347 100644 --- a/src/test/ui/error-codes/E0499.rs +++ b/src/test/ui/error-codes/E0499.rs @@ -7,8 +7,8 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - -fn main() { +#![feature(rustc_attrs)] +fn main() { #![rustc_error] // rust-lang/rust#49855 let mut i = 0; let mut x = &mut i; let mut a = &mut i; //~ ERROR E0499 diff --git a/src/test/ui/error-codes/E0502.rs b/src/test/ui/error-codes/E0502.rs index fce8513ca64f..9c126bdcde84 100644 --- a/src/test/ui/error-codes/E0502.rs +++ b/src/test/ui/error-codes/E0502.rs @@ -7,12 +7,12 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - +#![feature(rustc_attrs)] fn bar(x: &mut i32) {} fn foo(a: &mut i32) { let ref y = a; bar(a); //~ ERROR E0502 } -fn main() { +fn main() { #![rustc_error] // rust-lang/rust#49855 } diff --git a/src/test/ui/error-codes/E0503.rs b/src/test/ui/error-codes/E0503.rs index 810eb8d9b075..1822a8925d3c 100644 --- a/src/test/ui/error-codes/E0503.rs +++ b/src/test/ui/error-codes/E0503.rs @@ -7,8 +7,8 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - -fn main() { +#![feature(rustc_attrs)] +fn main() { #![rustc_error] // rust-lang/rust#49855 let mut value = 3; let _borrow = &mut value; let _sum = value + 1; //~ ERROR E0503 diff --git a/src/test/ui/error-codes/E0505.rs b/src/test/ui/error-codes/E0505.rs index 2d534b8a44a0..dd2980936c0b 100644 --- a/src/test/ui/error-codes/E0505.rs +++ b/src/test/ui/error-codes/E0505.rs @@ -7,12 +7,12 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - +#![feature(rustc_attrs)] struct Value {} fn eat(val: Value) {} -fn main() { +fn main() { #![rustc_error] // rust-lang/rust#49855 let x = Value{}; { let _ref_to_val: &Value = &x; diff --git a/src/test/ui/error-codes/E0597.rs b/src/test/ui/error-codes/E0597.rs index 2f4a1da91d88..74178a694440 100644 --- a/src/test/ui/error-codes/E0597.rs +++ b/src/test/ui/error-codes/E0597.rs @@ -7,12 +7,12 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - +#![feature(rustc_attrs)] struct Foo<'a> { x: Option<&'a u32>, } -fn main() { +fn main() { #![rustc_error] // rust-lang/rust#49855 let mut x = Foo { x: None }; let y = 0; x.x = Some(&y); diff --git a/src/test/ui/feature-gate-nll.rs b/src/test/ui/feature-gate-nll.rs index f34a9cddf98e..752b1fa821f7 100644 --- a/src/test/ui/feature-gate-nll.rs +++ b/src/test/ui/feature-gate-nll.rs @@ -7,10 +7,10 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - +#![feature(rustc_attrs)] #![allow(dead_code)] -fn main() { +fn main() { #![rustc_error] // rust-lang/rust#49855 let mut x = 33; let p = &x; diff --git a/src/test/ui/generator/borrowing.rs b/src/test/ui/generator/borrowing.rs index e56927d81823..f80aca9fb00e 100644 --- a/src/test/ui/generator/borrowing.rs +++ b/src/test/ui/generator/borrowing.rs @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(generators, generator_trait)] +#![feature(generators, generator_trait, rustc_attrs)] use std::ops::Generator; -fn main() { +fn main() { #![rustc_error] // rust-lang/rust#49855 let _b = { let a = 3; unsafe { (|| yield &a).resume() } diff --git a/src/test/ui/generator/dropck.rs b/src/test/ui/generator/dropck.rs index b2240fb225f5..8f4ba64fd572 100644 --- a/src/test/ui/generator/dropck.rs +++ b/src/test/ui/generator/dropck.rs @@ -8,12 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(generators, generator_trait, box_leak)] +#![feature(generators, generator_trait, box_leak, rustc_attrs)] use std::cell::RefCell; use std::ops::Generator; -fn main() { +fn main() { #![rustc_error] // rust-lang/rust#49855 let (cell, mut gen); cell = Box::new(RefCell::new(0)); let ref_ = Box::leak(Box::new(Some(cell.borrow_mut()))); diff --git a/src/test/ui/generator/pattern-borrow.rs b/src/test/ui/generator/pattern-borrow.rs index 557a5e62f7e4..dd63b9eaa5b1 100644 --- a/src/test/ui/generator/pattern-borrow.rs +++ b/src/test/ui/generator/pattern-borrow.rs @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(generators)] +#![feature(generators, rustc_attrs)] enum Test { A(i32), B, } -fn main() { } +fn main() { #![rustc_error] } // rust-lang/rust#49855 fn fun(test: Test) { move || { diff --git a/src/test/ui/issue-17263.rs b/src/test/ui/issue-17263.rs index 242327e93ce1..b251f9a41525 100644 --- a/src/test/ui/issue-17263.rs +++ b/src/test/ui/issue-17263.rs @@ -8,11 +8,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax)] +#![feature(box_syntax, rustc_attrs)] struct Foo { a: isize, b: isize } -fn main() { +fn main() { #![rustc_error] // rust-lang/rust#49855 let mut x: Box<_> = box Foo { a: 1, b: 2 }; let (a, b) = (&mut x.a, &mut x.b); //~^ ERROR cannot borrow `x` (via `x.b`) as mutable more than once at a time diff --git a/src/test/ui/issue-25793.rs b/src/test/ui/issue-25793.rs index 4f3d29216e44..8624527145c2 100644 --- a/src/test/ui/issue-25793.rs +++ b/src/test/ui/issue-25793.rs @@ -7,7 +7,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - +#![feature(rustc_attrs)] macro_rules! width( ($this:expr) => { $this.width.unwrap() @@ -29,4 +29,4 @@ impl HasInfo { } } -fn main() {} +fn main() { #![rustc_error] } // rust-lang/rust#49855 diff --git a/src/test/ui/issue-42106.rs b/src/test/ui/issue-42106.rs index f35eee186a2a..96f410578ce5 100644 --- a/src/test/ui/issue-42106.rs +++ b/src/test/ui/issue-42106.rs @@ -7,10 +7,10 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - +#![feature(rustc_attrs)] fn do_something(collection: &mut Vec) { let _a = &collection; collection.swap(1, 2); //~ ERROR also borrowed as immutable } -fn main() {} +fn main() { #![rustc_error] } // rust-lang/rust#49855 diff --git a/src/test/ui/lifetimes/borrowck-let-suggestion.rs b/src/test/ui/lifetimes/borrowck-let-suggestion.rs index 1c904648f9e7..a7a7d5c50351 100644 --- a/src/test/ui/lifetimes/borrowck-let-suggestion.rs +++ b/src/test/ui/lifetimes/borrowck-let-suggestion.rs @@ -7,11 +7,11 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - +#![feature(rustc_attrs)] fn f() { let x = vec![1].iter(); } -fn main() { +fn main() { #![rustc_error] // rust-lang/rust#49855 f(); } diff --git a/src/test/ui/span/borrowck-let-suggestion-suffixes.rs b/src/test/ui/span/borrowck-let-suggestion-suffixes.rs index 8a27af0119aa..60e6c6e29893 100644 --- a/src/test/ui/span/borrowck-let-suggestion-suffixes.rs +++ b/src/test/ui/span/borrowck-let-suggestion-suffixes.rs @@ -7,7 +7,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - +#![feature(rustc_attrs)] fn id(x: T) -> T { x } fn f() { @@ -58,6 +58,6 @@ fn f() { //~| NOTE temporary value needs to live until here //~| NOTE temporary value needs to live until here -fn main() { +fn main() { #![rustc_error] // rust-lang/rust#49855 f(); } diff --git a/src/test/ui/span/issue-36537.rs b/src/test/ui/span/issue-36537.rs index 3eac0106b18c..ca04101cf568 100644 --- a/src/test/ui/span/issue-36537.rs +++ b/src/test/ui/span/issue-36537.rs @@ -7,8 +7,8 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - -fn main() { +#![feature(rustc_attrs)] +fn main() { #![rustc_error] // rust-lang/rust#49855 let p; let a = 42; p = &a; diff --git a/src/test/ui/span/mut-ptr-cant-outlive-ref.rs b/src/test/ui/span/mut-ptr-cant-outlive-ref.rs index 9dc0836c5e06..9774303197c5 100644 --- a/src/test/ui/span/mut-ptr-cant-outlive-ref.rs +++ b/src/test/ui/span/mut-ptr-cant-outlive-ref.rs @@ -7,10 +7,10 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - +#![feature(rustc_attrs)] use std::cell::RefCell; -fn main() { +fn main() { #![rustc_error] // rust-lang/rust#49855 let m = RefCell::new(0); let p; { diff --git a/src/test/ui/span/range-2.rs b/src/test/ui/span/range-2.rs index d69b3ea098cb..a1ed9bc6aa84 100644 --- a/src/test/ui/span/range-2.rs +++ b/src/test/ui/span/range-2.rs @@ -9,8 +9,8 @@ // except according to those terms. // Test range syntax - borrow errors. - -pub fn main() { +#![feature(rustc_attrs)] +pub fn main() { #![rustc_error] // rust-lang/rust#49855 let r = { let a = 42; let b = 42; diff --git a/src/test/ui/span/regionck-unboxed-closure-lifetimes.rs b/src/test/ui/span/regionck-unboxed-closure-lifetimes.rs index 93b3d6733598..c814941c8112 100644 --- a/src/test/ui/span/regionck-unboxed-closure-lifetimes.rs +++ b/src/test/ui/span/regionck-unboxed-closure-lifetimes.rs @@ -7,10 +7,10 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - +#![feature(rustc_attrs)] use std::ops::FnMut; -fn main() { +fn main() { #![rustc_error] // rust-lang/rust#49855 let mut f; { let c = 1; diff --git a/src/test/ui/span/slice-borrow.rs b/src/test/ui/span/slice-borrow.rs index 1b022f232466..45dff62672be 100644 --- a/src/test/ui/span/slice-borrow.rs +++ b/src/test/ui/span/slice-borrow.rs @@ -7,10 +7,10 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - +#![feature(rustc_attrs)] // Test slicing expressions doesn't defeat the borrow checker. -fn main() { +fn main() { #![rustc_error] // rust-lang/rust#49855 let y; { let x: &[isize] = &vec![1, 2, 3, 4, 5]; diff --git a/src/test/ui/span/vec_refs_data_with_early_death.rs b/src/test/ui/span/vec_refs_data_with_early_death.rs index 42373a87a6c9..a3532d919bc0 100644 --- a/src/test/ui/span/vec_refs_data_with_early_death.rs +++ b/src/test/ui/span/vec_refs_data_with_early_death.rs @@ -17,8 +17,8 @@ // element it owns; thus, for data like this, it seems like we could // loosen the restrictions here if we wanted. But it also is not // clear whether such loosening is terribly important.) - -fn main() { +#![feature(rustc_attrs)] +fn main() { #![rustc_error] // rust-lang/rust#49855 let mut v = Vec::new(); let x: i8 = 3; diff --git a/src/test/ui/span/wf-method-late-bound-regions.rs b/src/test/ui/span/wf-method-late-bound-regions.rs index d58c29d4a32d..317cd395d0a7 100644 --- a/src/test/ui/span/wf-method-late-bound-regions.rs +++ b/src/test/ui/span/wf-method-late-bound-regions.rs @@ -11,7 +11,7 @@ // A method's receiver must be well-formed, even if it has late-bound regions. // Because of this, a method's substs being well-formed does not imply that // the method's implied bounds are met. - +#![feature(rustc_attrs)] struct Foo<'b>(Option<&'b ()>); trait Bar<'b> { @@ -22,7 +22,7 @@ impl<'b> Bar<'b> for Foo<'b> { fn xmute<'a>(&'a self, u: &'b u32) -> &'a u32 { u } } -fn main() { +fn main() { #![rustc_error] // rust-lang/rust#49855 let f = Foo(None); let f2 = f; let dangling = {