Skip to content

Commit

Permalink
Workaround #49855 by forcing rustc_error in any mode, including NLL.
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
pnkfelix committed Apr 10, 2018
1 parent ae05961 commit 1c8d2bd
Show file tree
Hide file tree
Showing 27 changed files with 54 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
// <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.

#![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;
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/borrowck/mut-borrow-outside-loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/codemap_tests/issue-11715.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/dropck/dropck-eyepatch-extern-crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/dropck/dropck-eyepatch-reorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/dropck/dropck-eyepatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/error-codes/E0499.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// <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.

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
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/error-codes/E0502.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// <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.

#![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
}
4 changes: 2 additions & 2 deletions src/test/ui/error-codes/E0503.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// <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.

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
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/error-codes/E0505.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// <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.

#![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;
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/error-codes/E0597.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// <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.

#![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);
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/feature-gate-nll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
// <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.

#![feature(rustc_attrs)]
#![allow(dead_code)]

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

let p = &x;
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/generator/borrowing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() }
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/generator/dropck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())));
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/generator/pattern-borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/issue-17263.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/issue-25793.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// <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.

#![feature(rustc_attrs)]
macro_rules! width(
($this:expr) => {
$this.width.unwrap()
Expand All @@ -29,4 +29,4 @@ impl HasInfo {
}
}

fn main() {}
fn main() { #![rustc_error] } // rust-lang/rust#49855
4 changes: 2 additions & 2 deletions src/test/ui/issue-42106.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
// <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.

#![feature(rustc_attrs)]
fn do_something<T>(collection: &mut Vec<T>) {
let _a = &collection;
collection.swap(1, 2); //~ ERROR also borrowed as immutable
}

fn main() {}
fn main() { #![rustc_error] } // rust-lang/rust#49855
4 changes: 2 additions & 2 deletions src/test/ui/lifetimes/borrowck-let-suggestion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
// <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.

#![feature(rustc_attrs)]
fn f() {
let x = vec![1].iter();
}

fn main() {
fn main() { #![rustc_error] // rust-lang/rust#49855
f();
}
4 changes: 2 additions & 2 deletions src/test/ui/span/borrowck-let-suggestion-suffixes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// <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.

#![feature(rustc_attrs)]
fn id<T>(x: T) -> T { x }

fn f() {
Expand Down Expand Up @@ -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();
}
4 changes: 2 additions & 2 deletions src/test/ui/span/issue-36537.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// <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.

fn main() {
#![feature(rustc_attrs)]
fn main() { #![rustc_error] // rust-lang/rust#49855
let p;
let a = 42;
p = &a;
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/span/mut-ptr-cant-outlive-ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
// <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.

#![feature(rustc_attrs)]
use std::cell::RefCell;

fn main() {
fn main() { #![rustc_error] // rust-lang/rust#49855
let m = RefCell::new(0);
let p;
{
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/span/range-2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/span/regionck-unboxed-closure-lifetimes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
// <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.

#![feature(rustc_attrs)]
use std::ops::FnMut;

fn main() {
fn main() { #![rustc_error] // rust-lang/rust#49855
let mut f;
{
let c = 1;
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/span/slice-borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
// <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.

#![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];
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/span/vec_refs_data_with_early_death.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/test/ui/span/wf-method-late-bound-regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand All @@ -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 = {
Expand Down

0 comments on commit 1c8d2bd

Please sign in to comment.