Skip to content

Commit 1c8d2bd

Browse files
committed
Workaround #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).
1 parent ae05961 commit 1c8d2bd

27 files changed

+54
-54
lines changed

src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
10+
#![feature(rustc_attrs)]
1111
#![allow(dead_code)]
12-
fn main() {
12+
fn main() { #![rustc_error] // rust-lang/rust#49855
1313
// Original borrow ends at end of function
1414
let mut x = 1;
1515
let y = &mut x;

src/test/ui/borrowck/mut-borrow-outside-loop.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// except according to those terms.
1010

1111
// ensure borrowck messages are correct outside special case
12-
13-
fn main() {
12+
#![feature(rustc_attrs)]
13+
fn main() { #![rustc_error] // rust-lang/rust#49855
1414
let mut void = ();
1515

1616
let first = &mut void;

src/test/ui/codemap_tests/issue-11715.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@
9393

9494

9595

96-
97-
fn main() {
96+
#![feature(rustc_attrs)]
97+
fn main() { #![rustc_error] // rust-lang/rust#49855
9898
let mut x = "foo";
9999
let y = &mut x;
100100
let z = &mut x; //~ ERROR cannot borrow

src/test/ui/dropck/dropck-eyepatch-extern-crate.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
//
2020
// See also dropck-eyepatch.rs for more information about the general
2121
// structure of the test.
22-
22+
#![feature(rustc_attrs)]
2323
extern crate dropck_eyepatch_extern_crate as other;
2424

2525
use other::{Dt,Dr,Pt,Pr,St,Sr};
2626

27-
fn main() {
27+
fn main() { #![rustc_error] // rust-lang/rust#49855
2828
use std::cell::Cell;
2929
let c_long;
3030
let (c, mut dt, mut dr, mut pt, mut pr, st, sr)

src/test/ui/dropck/dropck-eyepatch-reorder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(dropck_eyepatch)]
11+
#![feature(dropck_eyepatch, rustc_attrs)]
1212

1313
// The point of this test is to test uses of `#[may_dangle]` attribute
1414
// 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> {
4141
fn drop(&mut self) { println!("drop {} {:?}", self.0, self.2); }
4242
}
4343

44-
fn main() {
44+
fn main() { #![rustc_error] // rust-lang/rust#49855
4545
use std::cell::Cell;
4646
let c_long;
4747
let (c, mut dt, mut dr, mut pt, mut pr, st, sr)

src/test/ui/dropck/dropck-eyepatch.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(dropck_eyepatch)]
11+
#![feature(dropck_eyepatch, rustc_attrs)]
1212

1313
// The point of this test is to illustrate that the `#[may_dangle]`
1414
// 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> {
6464
fn drop(&mut self) { println!("drop {} {:?}", self.0, self.2); }
6565
}
6666

67-
fn main() {
67+
fn main() { #![rustc_error] // rust-lang/rust#49855
6868
use std::cell::Cell;
6969
let c_long;
7070
let (c, mut dt, mut dr, mut pt, mut pr, st, sr)

src/test/ui/error-codes/E0499.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
11-
fn main() {
10+
#![feature(rustc_attrs)]
11+
fn main() { #![rustc_error] // rust-lang/rust#49855
1212
let mut i = 0;
1313
let mut x = &mut i;
1414
let mut a = &mut i; //~ ERROR E0499

src/test/ui/error-codes/E0502.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
10+
#![feature(rustc_attrs)]
1111
fn bar(x: &mut i32) {}
1212
fn foo(a: &mut i32) {
1313
let ref y = a;
1414
bar(a); //~ ERROR E0502
1515
}
1616

17-
fn main() {
17+
fn main() { #![rustc_error] // rust-lang/rust#49855
1818
}

src/test/ui/error-codes/E0503.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
11-
fn main() {
10+
#![feature(rustc_attrs)]
11+
fn main() { #![rustc_error] // rust-lang/rust#49855
1212
let mut value = 3;
1313
let _borrow = &mut value;
1414
let _sum = value + 1; //~ ERROR E0503

src/test/ui/error-codes/E0505.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
10+
#![feature(rustc_attrs)]
1111
struct Value {}
1212

1313
fn eat(val: Value) {}
1414

15-
fn main() {
15+
fn main() { #![rustc_error] // rust-lang/rust#49855
1616
let x = Value{};
1717
{
1818
let _ref_to_val: &Value = &x;

src/test/ui/error-codes/E0597.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
10+
#![feature(rustc_attrs)]
1111
struct Foo<'a> {
1212
x: Option<&'a u32>,
1313
}
1414

15-
fn main() {
15+
fn main() { #![rustc_error] // rust-lang/rust#49855
1616
let mut x = Foo { x: None };
1717
let y = 0;
1818
x.x = Some(&y);

src/test/ui/feature-gate-nll.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
10+
#![feature(rustc_attrs)]
1111
#![allow(dead_code)]
1212

13-
fn main() {
13+
fn main() { #![rustc_error] // rust-lang/rust#49855
1414
let mut x = 33;
1515

1616
let p = &x;

src/test/ui/generator/borrowing.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(generators, generator_trait)]
11+
#![feature(generators, generator_trait, rustc_attrs)]
1212

1313
use std::ops::Generator;
1414

15-
fn main() {
15+
fn main() { #![rustc_error] // rust-lang/rust#49855
1616
let _b = {
1717
let a = 3;
1818
unsafe { (|| yield &a).resume() }

src/test/ui/generator/dropck.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(generators, generator_trait, box_leak)]
11+
#![feature(generators, generator_trait, box_leak, rustc_attrs)]
1212

1313
use std::cell::RefCell;
1414
use std::ops::Generator;
1515

16-
fn main() {
16+
fn main() { #![rustc_error] // rust-lang/rust#49855
1717
let (cell, mut gen);
1818
cell = Box::new(RefCell::new(0));
1919
let ref_ = Box::leak(Box::new(Some(cell.borrow_mut())));

src/test/ui/generator/pattern-borrow.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(generators)]
11+
#![feature(generators, rustc_attrs)]
1212

1313
enum Test { A(i32), B, }
1414

15-
fn main() { }
15+
fn main() { #![rustc_error] } // rust-lang/rust#49855
1616

1717
fn fun(test: Test) {
1818
move || {

src/test/ui/issue-17263.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(box_syntax)]
11+
#![feature(box_syntax, rustc_attrs)]
1212

1313
struct Foo { a: isize, b: isize }
1414

15-
fn main() {
15+
fn main() { #![rustc_error] // rust-lang/rust#49855
1616
let mut x: Box<_> = box Foo { a: 1, b: 2 };
1717
let (a, b) = (&mut x.a, &mut x.b);
1818
//~^ ERROR cannot borrow `x` (via `x.b`) as mutable more than once at a time

src/test/ui/issue-25793.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
10+
#![feature(rustc_attrs)]
1111
macro_rules! width(
1212
($this:expr) => {
1313
$this.width.unwrap()
@@ -29,4 +29,4 @@ impl HasInfo {
2929
}
3030
}
3131

32-
fn main() {}
32+
fn main() { #![rustc_error] } // rust-lang/rust#49855

src/test/ui/issue-42106.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
10+
#![feature(rustc_attrs)]
1111
fn do_something<T>(collection: &mut Vec<T>) {
1212
let _a = &collection;
1313
collection.swap(1, 2); //~ ERROR also borrowed as immutable
1414
}
1515

16-
fn main() {}
16+
fn main() { #![rustc_error] } // rust-lang/rust#49855

src/test/ui/lifetimes/borrowck-let-suggestion.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
10+
#![feature(rustc_attrs)]
1111
fn f() {
1212
let x = vec![1].iter();
1313
}
1414

15-
fn main() {
15+
fn main() { #![rustc_error] // rust-lang/rust#49855
1616
f();
1717
}

src/test/ui/span/borrowck-let-suggestion-suffixes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
10+
#![feature(rustc_attrs)]
1111
fn id<T>(x: T) -> T { x }
1212

1313
fn f() {
@@ -58,6 +58,6 @@ fn f() {
5858
//~| NOTE temporary value needs to live until here
5959
//~| NOTE temporary value needs to live until here
6060

61-
fn main() {
61+
fn main() { #![rustc_error] // rust-lang/rust#49855
6262
f();
6363
}

src/test/ui/span/issue-36537.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
11-
fn main() {
10+
#![feature(rustc_attrs)]
11+
fn main() { #![rustc_error] // rust-lang/rust#49855
1212
let p;
1313
let a = 42;
1414
p = &a;

src/test/ui/span/mut-ptr-cant-outlive-ref.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
10+
#![feature(rustc_attrs)]
1111
use std::cell::RefCell;
1212

13-
fn main() {
13+
fn main() { #![rustc_error] // rust-lang/rust#49855
1414
let m = RefCell::new(0);
1515
let p;
1616
{

src/test/ui/span/range-2.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
// except according to those terms.
1010

1111
// Test range syntax - borrow errors.
12-
13-
pub fn main() {
12+
#![feature(rustc_attrs)]
13+
pub fn main() { #![rustc_error] // rust-lang/rust#49855
1414
let r = {
1515
let a = 42;
1616
let b = 42;

src/test/ui/span/regionck-unboxed-closure-lifetimes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
10+
#![feature(rustc_attrs)]
1111
use std::ops::FnMut;
1212

13-
fn main() {
13+
fn main() { #![rustc_error] // rust-lang/rust#49855
1414
let mut f;
1515
{
1616
let c = 1;

src/test/ui/span/slice-borrow.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
10+
#![feature(rustc_attrs)]
1111
// Test slicing expressions doesn't defeat the borrow checker.
1212

13-
fn main() {
13+
fn main() { #![rustc_error] // rust-lang/rust#49855
1414
let y;
1515
{
1616
let x: &[isize] = &vec![1, 2, 3, 4, 5];

src/test/ui/span/vec_refs_data_with_early_death.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
// element it owns; thus, for data like this, it seems like we could
1818
// loosen the restrictions here if we wanted. But it also is not
1919
// clear whether such loosening is terribly important.)
20-
21-
fn main() {
20+
#![feature(rustc_attrs)]
21+
fn main() { #![rustc_error] // rust-lang/rust#49855
2222
let mut v = Vec::new();
2323

2424
let x: i8 = 3;

src/test/ui/span/wf-method-late-bound-regions.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
// A method's receiver must be well-formed, even if it has late-bound regions.
1212
// Because of this, a method's substs being well-formed does not imply that
1313
// the method's implied bounds are met.
14-
14+
#![feature(rustc_attrs)]
1515
struct Foo<'b>(Option<&'b ()>);
1616

1717
trait Bar<'b> {
@@ -22,7 +22,7 @@ impl<'b> Bar<'b> for Foo<'b> {
2222
fn xmute<'a>(&'a self, u: &'b u32) -> &'a u32 { u }
2323
}
2424

25-
fn main() {
25+
fn main() { #![rustc_error] // rust-lang/rust#49855
2626
let f = Foo(None);
2727
let f2 = f;
2828
let dangling = {

0 commit comments

Comments
 (0)