Auto merge of #49861 - pnkfelix:compare-mode-nll-followup-2, r=nikomatsakis
Blindly checkpoint status of NLL mode ui tests This takes the next (and potentially final?) step with #48879. Namely, this PR got things to the point where I can successfully run `compiletest` on `src/test/ui` with `--compile-mode=nll`. Here are the main pieces of it: 1. To figure out how to even run `compiletest` normally on the ui directory, I ran `x.py test -vv`, and then looked for the `compiletest` invocation that mentioned `src/test/ui`. 2. I took the aforementioned `compiletest` invocation and used it, adding `--compile-mode=nll` to the end. It had 170 failing cases. 3. Due to #49855, I had to edit some of the tests so that they fail even under NLL, via `#[rustc_error]`. That's the first commit. (Then goto 2 to double-check no such tests remain.) 4. I took the generated `build/target/test/foo.stderr` file for every case that failed, and blindly copied it to `src/test/foo.nll.stderr`. That's the second commit. 5. Goto 2 until there were no failing cases. 6. Remove any stamp files, and re-run `x.py test` to make sure that the edits and new `.nll.stderr` files haven't broken the pre-existing test suite.
This commit is contained in:
commit
32428808b4
|
@ -0,0 +1,26 @@
|
|||
error[E0505]: cannot move out of `x` because it is borrowed
|
||||
--> $DIR/augmented-assignments.rs:26:5
|
||||
|
|
||||
LL | x //~ error: use of moved value: `x`
|
||||
| -
|
||||
| |
|
||||
| _____borrow of `x` occurs here
|
||||
| |
|
||||
LL | | //~^ value used here after move
|
||||
LL | | +=
|
||||
LL | | x; //~ value moved here
|
||||
| | -
|
||||
| | |
|
||||
| |_____move out of `x` occurs here
|
||||
| borrow later used here
|
||||
|
||||
error[E0596]: cannot borrow immutable item `y` as mutable
|
||||
--> $DIR/augmented-assignments.rs:30:5
|
||||
|
|
||||
LL | y //~ error: cannot borrow immutable local variable `y` as mutable
|
||||
| ^ cannot borrow as mutable
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors occurred: E0505, E0596.
|
||||
For more information about an error, try `rustc --explain E0505`.
|
|
@ -0,0 +1,25 @@
|
|||
error[E0382]: use of moved value: `a.y`
|
||||
--> $DIR/borrowck-box-insensitivity.rs:46:14
|
||||
|
|
||||
LL | let _x = a.x;
|
||||
| --- value moved here
|
||||
LL | //~^ value moved here
|
||||
LL | let _y = a.y; //~ ERROR use of moved
|
||||
| ^^^ value used here after move
|
||||
|
|
||||
= note: move occurs because `a.y` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
|
||||
|
||||
error[E0382]: use of moved value: `a.y`
|
||||
--> $DIR/borrowck-box-insensitivity.rs:108:14
|
||||
|
|
||||
LL | let _x = a.x.x;
|
||||
| ----- value moved here
|
||||
LL | //~^ value moved here
|
||||
LL | let _y = a.y; //~ ERROR use of collaterally moved
|
||||
| ^^^ value used here after move
|
||||
|
|
||||
= note: move occurs because `a.y` has type `std::boxed::Box<isize>`, which does not implement the `Copy` trait
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
|
@ -0,0 +1,78 @@
|
|||
error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
|
||||
--> $DIR/borrowck-closures-two-mut.rs:24:24
|
||||
|
|
||||
LL | let c1 = to_fn_mut(|| x = 4);
|
||||
| -- - previous borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| first mutable borrow occurs here
|
||||
LL | let c2 = to_fn_mut(|| x = 5); //~ ERROR cannot borrow `x` as mutable more than once
|
||||
| ^^ - borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| second mutable borrow occurs here
|
||||
LL | //~| ERROR cannot borrow `x` as mutable more than once
|
||||
LL | }
|
||||
| - first borrow ends here
|
||||
|
||||
error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
|
||||
--> $DIR/borrowck-closures-two-mut.rs:35:24
|
||||
|
|
||||
LL | let c1 = to_fn_mut(|| set(&mut x));
|
||||
| -- - previous borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| first mutable borrow occurs here
|
||||
LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
|
||||
| ^^ - borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| second mutable borrow occurs here
|
||||
LL | //~| ERROR cannot borrow `x` as mutable more than once
|
||||
LL | }
|
||||
| - first borrow ends here
|
||||
|
||||
error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
|
||||
--> $DIR/borrowck-closures-two-mut.rs:42:24
|
||||
|
|
||||
LL | let c1 = to_fn_mut(|| x = 5);
|
||||
| -- - previous borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| first mutable borrow occurs here
|
||||
LL | let c2 = to_fn_mut(|| set(&mut x)); //~ ERROR cannot borrow `x` as mutable more than once
|
||||
| ^^ - borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| second mutable borrow occurs here
|
||||
LL | //~| ERROR cannot borrow `x` as mutable more than once
|
||||
LL | }
|
||||
| - first borrow ends here
|
||||
|
||||
error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
|
||||
--> $DIR/borrowck-closures-two-mut.rs:49:24
|
||||
|
|
||||
LL | let c1 = to_fn_mut(|| x = 5);
|
||||
| -- - previous borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| first mutable borrow occurs here
|
||||
LL | let c2 = to_fn_mut(|| { let _y = to_fn_mut(|| set(&mut x)); }); // (nested closure)
|
||||
| ^^ - borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| second mutable borrow occurs here
|
||||
...
|
||||
LL | }
|
||||
| - first borrow ends here
|
||||
|
||||
error[E0499]: cannot borrow `x` as mutable more than once at a time (Ast)
|
||||
--> $DIR/borrowck-closures-two-mut.rs:61:24
|
||||
|
|
||||
LL | let c1 = to_fn_mut(|| set(&mut *x.f));
|
||||
| -- - previous borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| first mutable borrow occurs here
|
||||
LL | let c2 = to_fn_mut(|| set(&mut *x.f));
|
||||
| ^^ - borrow occurs due to use of `x` in closure
|
||||
| |
|
||||
| second mutable borrow occurs here
|
||||
...
|
||||
LL | }
|
||||
| - first borrow ends here
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0499`.
|
|
@ -0,0 +1,14 @@
|
|||
error[E0597]: `books` does not live long enough
|
||||
--> $DIR/borrowck-escaping-closure-error-1.rs:23:11
|
||||
|
|
||||
LL | spawn(|| books.push(4));
|
||||
| ^^^^^^^^^^^^^^^^ borrowed value does not live long enough
|
||||
LL | //~^ ERROR E0373
|
||||
LL | }
|
||||
| - borrowed value only lives until here
|
||||
|
|
||||
= note: borrowed value must be valid for the static lifetime...
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
|
@ -0,0 +1,18 @@
|
|||
error[E0597]: `books` does not live long enough
|
||||
--> $DIR/borrowck-escaping-closure-error-2.rs:21:14
|
||||
|
|
||||
LL | Box::new(|| books.push(4))
|
||||
| ^^^^^^^^^^^^^^^^ borrowed value does not live long enough
|
||||
LL | //~^ ERROR E0373
|
||||
LL | }
|
||||
| - borrowed value only lives until here
|
||||
|
|
||||
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 19:1...
|
||||
--> $DIR/borrowck-escaping-closure-error-2.rs:19:1
|
||||
|
|
||||
LL | fn foo<'a>(x: &'a i32) -> Box<FnMut()+'a> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
|
@ -0,0 +1,9 @@
|
|||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/borrowck-in-static.rs:15:17
|
||||
|
|
||||
LL | Box::new(|| x) //~ ERROR cannot move out of captured outer variable
|
||||
| ^ cannot move out of borrowed content
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0507`.
|
|
@ -0,0 +1,40 @@
|
|||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/borrowck-move-error-with-note.rs:23:19
|
||||
|
|
||||
LL | Foo::Foo1(num1,
|
||||
| ^^^^ cannot move out of borrowed content
|
||||
|
||||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/borrowck-move-error-with-note.rs:24:19
|
||||
|
|
||||
LL | num2) => (),
|
||||
| ^^^^ cannot move out of borrowed content
|
||||
|
||||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/borrowck-move-error-with-note.rs:25:19
|
||||
|
|
||||
LL | Foo::Foo2(num) => (),
|
||||
| ^^^ cannot move out of borrowed content
|
||||
|
||||
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
|
||||
--> $DIR/borrowck-move-error-with-note.rs:42:16
|
||||
|
|
||||
LL | f: _s,
|
||||
| ^^ cannot move out of here
|
||||
|
||||
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
|
||||
--> $DIR/borrowck-move-error-with-note.rs:43:16
|
||||
|
|
||||
LL | g: _t
|
||||
| ^^ cannot move out of here
|
||||
|
||||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/borrowck-move-error-with-note.rs:59:9
|
||||
|
|
||||
LL | n => {
|
||||
| ^ cannot move out of borrowed content
|
||||
|
||||
error: aborting due to 6 previous errors
|
||||
|
||||
Some errors occurred: E0507, E0509.
|
||||
For more information about an error, try `rustc --explain E0507`.
|
|
@ -0,0 +1,15 @@
|
|||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/borrowck-move-out-of-vec-tail.rs:30:33
|
||||
|
|
||||
LL | &[Foo { string: a },
|
||||
| ^ cannot move out of borrowed content
|
||||
|
||||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/borrowck-move-out-of-vec-tail.rs:34:33
|
||||
|
|
||||
LL | Foo { string: b }] => {
|
||||
| ^ cannot move out of borrowed content
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0507`.
|
|
@ -0,0 +1,14 @@
|
|||
error: compilation successful
|
||||
--> $DIR/borrowck-report-with-custom-diagnostic.rs:12:1
|
||||
|
|
||||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
LL | | // Original borrow ends at end of function
|
||||
LL | | let mut x = 1;
|
||||
LL | | let y = &mut x;
|
||||
... |
|
||||
LL | | //~^ immutable borrow occurs here
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -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;
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/borrowck-vec-pattern-nesting.rs:42:15
|
||||
|
|
||||
LL | &mut [_a, //~ ERROR cannot move out
|
||||
| ^^ cannot move out of borrowed content
|
||||
|
||||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/borrowck-vec-pattern-nesting.rs:55:13
|
||||
|
|
||||
LL | let a = vec[0]; //~ ERROR cannot move out
|
||||
| ^^^^^^ cannot move out of borrowed content
|
||||
|
||||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/borrowck-vec-pattern-nesting.rs:65:10
|
||||
|
|
||||
LL | _b] => {}
|
||||
| ^^ cannot move out of borrowed content
|
||||
|
||||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/borrowck-vec-pattern-nesting.rs:68:13
|
||||
|
|
||||
LL | let a = vec[0]; //~ ERROR cannot move out
|
||||
| ^^^^^^ cannot move out of borrowed content
|
||||
|
||||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/borrowck-vec-pattern-nesting.rs:76:15
|
||||
|
|
||||
LL | &mut [_a, _b, _c] => {} //~ ERROR cannot move out
|
||||
| ^^ cannot move out of borrowed content
|
||||
|
||||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/borrowck-vec-pattern-nesting.rs:76:19
|
||||
|
|
||||
LL | &mut [_a, _b, _c] => {} //~ ERROR cannot move out
|
||||
| ^^ cannot move out of borrowed content
|
||||
|
||||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/borrowck-vec-pattern-nesting.rs:76:23
|
||||
|
|
||||
LL | &mut [_a, _b, _c] => {} //~ ERROR cannot move out
|
||||
| ^^ cannot move out of borrowed content
|
||||
|
||||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/borrowck-vec-pattern-nesting.rs:80:13
|
||||
|
|
||||
LL | let a = vec[0]; //~ ERROR cannot move out
|
||||
| ^^^^^^ cannot move out of borrowed content
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0507`.
|
|
@ -0,0 +1,30 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/issue-45983.rs:17:27
|
||||
|
|
||||
LL | give_any(|y| x = Some(y));
|
||||
| ^
|
||||
|
||||
error: free region `` does not outlive free region `'_#2r`
|
||||
--> $DIR/issue-45983.rs:17:27
|
||||
|
|
||||
LL | give_any(|y| x = Some(y));
|
||||
| ^
|
||||
|
||||
error[E0594]: cannot assign to immutable item `x`
|
||||
--> $DIR/issue-45983.rs:17:18
|
||||
|
|
||||
LL | give_any(|y| x = Some(y));
|
||||
| ^^^^^^^^^^^ cannot mutate
|
||||
|
|
||||
= note: Value not mutable causing this error: `x`
|
||||
|
||||
error[E0596]: cannot borrow immutable item `x` as mutable
|
||||
--> $DIR/issue-45983.rs:17:14
|
||||
|
|
||||
LL | give_any(|y| x = Some(y));
|
||||
| ^^^^^^^^^^^^^^^ cannot borrow as mutable
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors occurred: E0594, E0596.
|
||||
For more information about an error, try `rustc --explain E0594`.
|
|
@ -0,0 +1,14 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/issue-7573.rs:27:31
|
||||
|
|
||||
LL | let mut lines_to_use: Vec<&CrateId> = Vec::new();
|
||||
| ^
|
||||
|
||||
error: free region `` does not outlive free region `'_#2r`
|
||||
--> $DIR/issue-7573.rs:32:9
|
||||
|
|
||||
LL | lines_to_use.push(installed_id);
|
||||
| ^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
error[E0499]: cannot borrow `*arg` as mutable more than once at a time
|
||||
--> $DIR/mut-borrow-in-loop.rs:20:25
|
||||
|
|
||||
LL | (self.func)(arg) //~ ERROR cannot borrow
|
||||
| ^^^ mutable borrow starts here in previous iteration of loop
|
||||
|
||||
error[E0499]: cannot borrow `*arg` as mutable more than once at a time
|
||||
--> $DIR/mut-borrow-in-loop.rs:26:25
|
||||
|
|
||||
LL | (self.func)(arg) //~ ERROR cannot borrow
|
||||
| ^^^ mutable borrow starts here in previous iteration of loop
|
||||
|
||||
error[E0499]: cannot borrow `*arg` as mutable more than once at a time
|
||||
--> $DIR/mut-borrow-in-loop.rs:33:25
|
||||
|
|
||||
LL | (self.func)(arg) //~ ERROR cannot borrow
|
||||
| ^^^ mutable borrow starts here in previous iteration of loop
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0499`.
|
|
@ -0,0 +1,14 @@
|
|||
error: compilation successful
|
||||
--> $DIR/mut-borrow-outside-loop.rs:13:1
|
||||
|
|
||||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
LL | | let mut void = ();
|
||||
LL | |
|
||||
LL | | let first = &mut void;
|
||||
... |
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -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;
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/regions-escape-bound-fn-2.rs:18:27
|
||||
|
|
||||
LL | with_int(|y| x = Some(y));
|
||||
| ^
|
||||
|
||||
error: free region `` does not outlive free region `'_#2r`
|
||||
--> $DIR/regions-escape-bound-fn-2.rs:18:27
|
||||
|
|
||||
LL | with_int(|y| x = Some(y));
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/regions-escape-bound-fn.rs:18:22
|
||||
|
|
||||
LL | with_int(|y| x = Some(y));
|
||||
| ^^^^^^^
|
||||
|
||||
error: free region `` does not outlive free region `'_#2r`
|
||||
--> $DIR/regions-escape-bound-fn.rs:18:27
|
||||
|
|
||||
LL | with_int(|y| x = Some(y));
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/regions-escape-unboxed-closure.rs:16:27
|
||||
|
|
||||
LL | with_int(&mut |y| x = Some(y));
|
||||
| ^^^^^^^
|
||||
|
||||
error: free region `` does not outlive free region `'_#2r`
|
||||
--> $DIR/regions-escape-unboxed-closure.rs:16:32
|
||||
|
|
||||
LL | with_int(&mut |y| x = Some(y));
|
||||
| ^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:21:9
|
||||
|
|
||||
LL | y.into_iter();
|
||||
| ^ cannot move out of borrowed content
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0507`.
|
|
@ -0,0 +1,44 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/expect-region-supply-region.rs:28:13
|
||||
|
|
||||
LL | f = Some(x); //~ ERROR borrowed data cannot be stored outside of its closure
|
||||
| ^^^^^^^
|
||||
|
||||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/expect-region-supply-region.rs:38:13
|
||||
|
|
||||
LL | f = Some(x); //~ ERROR borrowed data cannot be stored outside of its closure
|
||||
| ^^^^^^^
|
||||
|
||||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/expect-region-supply-region.rs:47:33
|
||||
|
|
||||
LL | closure_expecting_bound(|x: &'x u32| {
|
||||
| ^^^^^^^
|
||||
|
||||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/expect-region-supply-region.rs:52:13
|
||||
|
|
||||
LL | f = Some(x);
|
||||
| ^^^^^^^
|
||||
|
||||
error: free region `` does not outlive free region `'_#2r`
|
||||
--> $DIR/expect-region-supply-region.rs:28:18
|
||||
|
|
||||
LL | f = Some(x); //~ ERROR borrowed data cannot be stored outside of its closure
|
||||
| ^
|
||||
|
||||
error: free region `` does not outlive free region `'_#2r`
|
||||
--> $DIR/expect-region-supply-region.rs:38:18
|
||||
|
|
||||
LL | f = Some(x); //~ ERROR borrowed data cannot be stored outside of its closure
|
||||
| ^
|
||||
|
||||
error: free region `` does not outlive free region `'_#2r`
|
||||
--> $DIR/expect-region-supply-region.rs:52:18
|
||||
|
|
||||
LL | f = Some(x);
|
||||
| ^
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
error[E0382]: use of moved value: `debug_dump_dict`
|
||||
--> $DIR/issue-42065.rs:21:5
|
||||
|
|
||||
LL | debug_dump_dict();
|
||||
| --------------- value moved here
|
||||
LL | debug_dump_dict();
|
||||
| ^^^^^^^^^^^^^^^ value used here after move
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
|
@ -0,0 +1,9 @@
|
|||
error[E0596]: cannot borrow immutable item `x` as mutable
|
||||
--> $DIR/huge_multispan_highlight.rs:100:13
|
||||
|
|
||||
LL | let y = &mut x; //~ ERROR cannot borrow
|
||||
| ^^^^^^ cannot borrow as mutable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
|
@ -0,0 +1,12 @@
|
|||
error: compilation successful
|
||||
--> $DIR/issue-11715.rs:97:1
|
||||
|
|
||||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
LL | | let mut x = "foo";
|
||||
LL | | let y = &mut x;
|
||||
LL | | let z = &mut x; //~ ERROR cannot borrow
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
error[E0499]: cannot borrow `v` as mutable more than once at a time
|
||||
--> $DIR/one_line.rs:13:12
|
||||
|
|
||||
LL | v.push(v.pop().unwrap()); //~ ERROR cannot borrow
|
||||
| -------^----------------
|
||||
| | |
|
||||
| | second mutable borrow occurs here
|
||||
| first mutable borrow occurs here
|
||||
| borrow later used here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0499`.
|
|
@ -0,0 +1,9 @@
|
|||
error[E0509]: cannot move out of type `S`, which implements the `Drop` trait
|
||||
--> $DIR/overlapping_spans.rs:21:14
|
||||
|
|
||||
LL | S {f:_s} => {} //~ ERROR cannot move out
|
||||
| ^^ cannot move out of here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0509`.
|
|
@ -0,0 +1,14 @@
|
|||
error[E0382]: borrow of moved value: `some_vec`
|
||||
--> $DIR/tab_3.rs:17:20
|
||||
|
|
||||
LL | some_vec.into_iter();
|
||||
| -------- value moved here
|
||||
LL | {
|
||||
LL | println!("{:?}", some_vec); //~ ERROR use of moved
|
||||
| ^^^^^^^^ value borrowed here after move
|
||||
|
|
||||
= note: move occurs because `some_vec` has type `std::vec::Vec<&str>`, which does not implement the `Copy` trait
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0382`.
|
|
@ -0,0 +1,11 @@
|
|||
error[E0384]: cannot assign twice to immutable variable `x`
|
||||
--> $DIR/command-line-diagnostics.rs:16:5
|
||||
|
|
||||
LL | let x = 42;
|
||||
| -- first assignment to `x`
|
||||
LL | x = 43;
|
||||
| ^^^^^^ cannot assign twice to immutable variable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0384`.
|
|
@ -0,0 +1,15 @@
|
|||
error[E0596]: cannot borrow immutable item `self` as mutable
|
||||
--> $DIR/issue-31424.rs:17:9
|
||||
|
|
||||
LL | (&mut self).bar(); //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^^^ cannot borrow as mutable
|
||||
|
||||
error[E0596]: cannot borrow immutable item `self` as mutable
|
||||
--> $DIR/issue-31424.rs:23:9
|
||||
|
|
||||
LL | (&mut self).bar(); //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^^^ cannot borrow as mutable
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
|
@ -0,0 +1,13 @@
|
|||
error[E0502]: cannot borrow `self` as mutable because it is also borrowed as immutable
|
||||
--> $DIR/issue-34126.rs:16:18
|
||||
|
|
||||
LL | self.run(&mut self); //~ ERROR cannot borrow
|
||||
| ---------^^^^^^^^^-
|
||||
| | |
|
||||
| | mutable borrow occurs here
|
||||
| immutable borrow occurs here
|
||||
| borrow later used here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0502`.
|
|
@ -0,0 +1,9 @@
|
|||
error[E0596]: cannot borrow immutable item `key` as mutable
|
||||
--> $DIR/issue-34337.rs:16:9
|
||||
|
|
||||
LL | get(&mut key); //~ ERROR cannot borrow
|
||||
| ^^^^^^^^ cannot borrow as mutable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
|
@ -0,0 +1,28 @@
|
|||
error[E0596]: cannot borrow immutable item `f.v` as mutable
|
||||
--> $DIR/issue-35937.rs:17:5
|
||||
|
|
||||
LL | f.v.push("cat".to_string()); //~ ERROR cannot borrow
|
||||
| ^^^ cannot borrow as mutable
|
||||
|
|
||||
= note: Value not mutable causing this error: `f`
|
||||
|
||||
error[E0384]: cannot assign twice to immutable variable `s.x`
|
||||
--> $DIR/issue-35937.rs:26:5
|
||||
|
|
||||
LL | let s = S { x: 42 };
|
||||
| ----------- first assignment to `s.x`
|
||||
LL | s.x += 1; //~ ERROR cannot assign
|
||||
| ^^^^^^^^ cannot assign twice to immutable variable
|
||||
|
||||
error[E0384]: cannot assign twice to immutable variable `s.x`
|
||||
--> $DIR/issue-35937.rs:30:5
|
||||
|
|
||||
LL | fn bar(s: S) {
|
||||
| - first assignment to `s.x`
|
||||
LL | s.x += 1; //~ ERROR cannot assign
|
||||
| ^^^^^^^^ cannot assign twice to immutable variable
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors occurred: E0384, E0596.
|
||||
For more information about an error, try `rustc --explain E0384`.
|
|
@ -0,0 +1,9 @@
|
|||
error[E0596]: cannot borrow immutable item `x` as mutable
|
||||
--> $DIR/issue-37139.rs:22:18
|
||||
|
|
||||
LL | test(&mut x); //~ ERROR cannot borrow immutable
|
||||
| ^^^^^^ cannot borrow as mutable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
|
@ -0,0 +1,11 @@
|
|||
error[E0596]: cannot borrow immutable item `*self.s` as mutable
|
||||
--> $DIR/issue-38147-1.rs:27:9
|
||||
|
|
||||
LL | self.s.push('x'); //~ ERROR cannot borrow data mutably
|
||||
| ^^^^^^ cannot borrow as mutable
|
||||
|
|
||||
= note: Value not mutable causing this error: `*self`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
|
@ -0,0 +1,9 @@
|
|||
error[E0596]: cannot borrow immutable item `*self.s` as mutable
|
||||
--> $DIR/issue-38147-2.rs:17:9
|
||||
|
|
||||
LL | self.s.push('x');
|
||||
| ^^^^^^ cannot borrow as mutable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
|
@ -0,0 +1,9 @@
|
|||
error[E0596]: cannot borrow immutable item `*self.s` as mutable
|
||||
--> $DIR/issue-38147-3.rs:17:9
|
||||
|
|
||||
LL | self.s.push('x');
|
||||
| ^^^^^^ cannot borrow as mutable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
|
@ -0,0 +1,11 @@
|
|||
error[E0596]: cannot borrow immutable item `*f.s` as mutable
|
||||
--> $DIR/issue-38147-4.rs:16:5
|
||||
|
|
||||
LL | f.s.push('x'); //~ ERROR cannot borrow data mutably
|
||||
| ^^^ cannot borrow as mutable
|
||||
|
|
||||
= note: Value not mutable causing this error: `*f`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
|
@ -0,0 +1,98 @@
|
|||
error[E0596]: cannot borrow immutable item `z.x` as mutable
|
||||
--> $DIR/issue-39544.rs:21:13
|
||||
|
|
||||
LL | let _ = &mut z.x; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^ cannot borrow as mutable
|
||||
|
|
||||
= note: Value not mutable causing this error: `z`
|
||||
|
||||
error[E0596]: cannot borrow immutable item `self.x` as mutable
|
||||
--> $DIR/issue-39544.rs:26:17
|
||||
|
|
||||
LL | let _ = &mut self.x; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^^^ cannot borrow as mutable
|
||||
|
|
||||
= note: Value not mutable causing this error: `*self`
|
||||
|
||||
error[E0596]: cannot borrow immutable item `self.x` as mutable
|
||||
--> $DIR/issue-39544.rs:30:17
|
||||
|
|
||||
LL | let _ = &mut self.x; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^^^ cannot borrow as mutable
|
||||
|
|
||||
= note: Value not mutable causing this error: `*self`
|
||||
|
||||
error[E0596]: cannot borrow immutable item `other.x` as mutable
|
||||
--> $DIR/issue-39544.rs:31:17
|
||||
|
|
||||
LL | let _ = &mut other.x; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^^^^ cannot borrow as mutable
|
||||
|
|
||||
= note: Value not mutable causing this error: `*other`
|
||||
|
||||
error[E0596]: cannot borrow immutable item `self.x` as mutable
|
||||
--> $DIR/issue-39544.rs:35:17
|
||||
|
|
||||
LL | let _ = &mut self.x; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^^^ cannot borrow as mutable
|
||||
|
|
||||
= note: Value not mutable causing this error: `*self`
|
||||
|
||||
error[E0596]: cannot borrow immutable item `other.x` as mutable
|
||||
--> $DIR/issue-39544.rs:36:17
|
||||
|
|
||||
LL | let _ = &mut other.x; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^^^^ cannot borrow as mutable
|
||||
|
|
||||
= note: Value not mutable causing this error: `*other`
|
||||
|
||||
error[E0596]: cannot borrow immutable item `self.x` as mutable
|
||||
--> $DIR/issue-39544.rs:40:17
|
||||
|
|
||||
LL | let _ = &mut self.x; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^^^ cannot borrow as mutable
|
||||
|
|
||||
= note: Value not mutable causing this error: `*self`
|
||||
|
||||
error[E0596]: cannot borrow immutable item `other.x` as mutable
|
||||
--> $DIR/issue-39544.rs:41:17
|
||||
|
|
||||
LL | let _ = &mut other.x; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^^^^ cannot borrow as mutable
|
||||
|
|
||||
= note: Value not mutable causing this error: `*other`
|
||||
|
||||
error[E0596]: cannot borrow immutable item `other.x` as mutable
|
||||
--> $DIR/issue-39544.rs:45:17
|
||||
|
|
||||
LL | let _ = &mut other.x; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^^^^^ cannot borrow as mutable
|
||||
|
|
||||
= note: Value not mutable causing this error: `*other`
|
||||
|
||||
error[E0596]: cannot borrow immutable item `z.x` as mutable
|
||||
--> $DIR/issue-39544.rs:51:13
|
||||
|
|
||||
LL | let _ = &mut z.x; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^ cannot borrow as mutable
|
||||
|
|
||||
= note: Value not mutable causing this error: `z`
|
||||
|
||||
error[E0596]: cannot borrow immutable item `w.x` as mutable
|
||||
--> $DIR/issue-39544.rs:52:13
|
||||
|
|
||||
LL | let _ = &mut w.x; //~ ERROR cannot borrow
|
||||
| ^^^^^^^^ cannot borrow as mutable
|
||||
|
|
||||
= note: Value not mutable causing this error: `*w`
|
||||
|
||||
error[E0594]: cannot assign to immutable item `*x.0`
|
||||
--> $DIR/issue-39544.rs:58:5
|
||||
|
|
||||
LL | *x.0 = 1;
|
||||
| ^^^^^^^^ cannot mutate
|
||||
|
||||
error: aborting due to 12 previous errors
|
||||
|
||||
Some errors occurred: E0594, E0596.
|
||||
For more information about an error, try `rustc --explain E0594`.
|
|
@ -0,0 +1,9 @@
|
|||
error[E0596]: cannot borrow immutable item `*buf` as mutable
|
||||
--> $DIR/issue-40823.rs:13:5
|
||||
|
|
||||
LL | buf.iter_mut(); //~ ERROR cannot borrow immutable borrowed content
|
||||
| ^^^ cannot borrow as mutable
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
|
@ -0,0 +1,14 @@
|
|||
error: compilation successful
|
||||
--> $DIR/dropck-eyepatch-extern-crate.rs:27:1
|
||||
|
|
||||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
LL | | use std::cell::Cell;
|
||||
LL | | let c_long;
|
||||
LL | | let (c, mut dt, mut dr, mut pt, mut pr, st, sr)
|
||||
... |
|
||||
LL | | println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0));
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -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)
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
error: compilation successful
|
||||
--> $DIR/dropck-eyepatch-reorder.rs:44:1
|
||||
|
|
||||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
LL | | use std::cell::Cell;
|
||||
LL | | let c_long;
|
||||
LL | | let (c, mut dt, mut dr, mut pt, mut pr, st, sr)
|
||||
... |
|
||||
LL | | println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0));
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -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)
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
error: compilation successful
|
||||
--> $DIR/dropck-eyepatch.rs:67:1
|
||||
|
|
||||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
LL | | use std::cell::Cell;
|
||||
LL | | let c_long;
|
||||
LL | | let (c, mut dt, mut dr, mut pt, mut pr, st, sr)
|
||||
... |
|
||||
LL | | println!("{:?}", (dt.0, dr.0, pt.0, pr.0, st.0, sr.0));
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -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)
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
error[E0017]: references in constants may only refer to immutable values
|
||||
--> $DIR/E0017.rs:14:30
|
||||
|
|
||||
LL | const CR: &'static mut i32 = &mut C; //~ ERROR E0017
|
||||
| ^^^^^^ constants require immutable values
|
||||
|
||||
error[E0017]: references in statics may only refer to immutable values
|
||||
--> $DIR/E0017.rs:15:39
|
||||
|
|
||||
LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
|
||||
| ^^^^^^ statics require immutable values
|
||||
|
||||
error[E0017]: references in statics may only refer to immutable values
|
||||
--> $DIR/E0017.rs:17:38
|
||||
|
|
||||
LL | static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
|
||||
| ^^^^^^ statics require immutable values
|
||||
|
||||
error[E0596]: cannot borrow immutable item `X` as mutable
|
||||
--> $DIR/E0017.rs:15:39
|
||||
|
|
||||
LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
|
||||
| ^^^^^^ cannot borrow as mutable
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors occurred: E0017, E0596.
|
||||
For more information about an error, try `rustc --explain E0017`.
|
|
@ -0,0 +1,16 @@
|
|||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/E0161.rs:14:28
|
||||
|
|
||||
LL | let _x: Box<str> = box *"hello"; //~ ERROR E0161
|
||||
| ^^^^^^^^ cannot move out of borrowed content
|
||||
|
||||
error[E0161]: cannot move a value of type str: the size of str cannot be statically determined
|
||||
--> $DIR/E0161.rs:14:28
|
||||
|
|
||||
LL | let _x: Box<str> = box *"hello"; //~ ERROR E0161
|
||||
| ^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors occurred: E0161, E0507.
|
||||
For more information about an error, try `rustc --explain E0161`.
|
|
@ -0,0 +1,28 @@
|
|||
error[E0017]: references in constants may only refer to immutable values
|
||||
--> $DIR/E0388.rs:14:30
|
||||
|
|
||||
LL | const CR: &'static mut i32 = &mut C; //~ ERROR E0017
|
||||
| ^^^^^^ constants require immutable values
|
||||
|
||||
error[E0017]: references in statics may only refer to immutable values
|
||||
--> $DIR/E0388.rs:15:39
|
||||
|
|
||||
LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
|
||||
| ^^^^^^ statics require immutable values
|
||||
|
||||
error[E0017]: references in statics may only refer to immutable values
|
||||
--> $DIR/E0388.rs:17:38
|
||||
|
|
||||
LL | static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
|
||||
| ^^^^^^ statics require immutable values
|
||||
|
||||
error[E0596]: cannot borrow immutable item `X` as mutable
|
||||
--> $DIR/E0388.rs:15:39
|
||||
|
|
||||
LL | static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
|
||||
| ^^^^^^ cannot borrow as mutable
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors occurred: E0017, E0596.
|
||||
For more information about an error, try `rustc --explain E0017`.
|
|
@ -0,0 +1,11 @@
|
|||
error[E0594]: cannot assign to immutable item `fancy_ref.num`
|
||||
--> $DIR/E0389.rs:18:5
|
||||
|
|
||||
LL | fancy_ref.num = 6; //~ ERROR E0389
|
||||
| ^^^^^^^^^^^^^^^^^ cannot mutate
|
||||
|
|
||||
= note: Value not mutable causing this error: `*fancy_ref`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0594`.
|
|
@ -0,0 +1,12 @@
|
|||
error: compilation successful
|
||||
--> $DIR/E0499.rs:11:1
|
||||
|
|
||||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
LL | | let mut i = 0;
|
||||
LL | | let mut x = &mut i;
|
||||
LL | | let mut a = &mut i; //~ ERROR E0499
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
error: compilation successful
|
||||
--> $DIR/E0502.rs:17:1
|
||||
|
|
||||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
error: compilation successful
|
||||
--> $DIR/E0503.rs:11:1
|
||||
|
|
||||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
LL | | let mut value = 3;
|
||||
LL | | let _borrow = &mut value;
|
||||
LL | | let _sum = value + 1; //~ ERROR E0503
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
error[E0505]: cannot move out of `fancy_num` because it is borrowed
|
||||
--> $DIR/E0504.rs:19:13
|
||||
|
|
||||
LL | let fancy_ref = &fancy_num;
|
||||
| ---------- borrow of `fancy_num` occurs here
|
||||
LL |
|
||||
LL | let x = move || {
|
||||
| _____________^
|
||||
LL | | println!("child function: {}", fancy_num.num); //~ ERROR E0504
|
||||
LL | | };
|
||||
| |_____^ move out of `fancy_num` occurs here
|
||||
...
|
||||
LL | println!("main function: {}", fancy_ref.num);
|
||||
| ------------- borrow later used here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0505`.
|
|
@ -0,0 +1,14 @@
|
|||
error: compilation successful
|
||||
--> $DIR/E0505.rs:15:1
|
||||
|
|
||||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
LL | | let x = Value{};
|
||||
LL | | {
|
||||
LL | | let _ref_to_val: &Value = &x;
|
||||
LL | | eat(x); //~ ERROR E0505
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -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;
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
error[E0509]: cannot move out of type `DropStruct`, which implements the `Drop` trait
|
||||
--> $DIR/E0509.rs:26:23
|
||||
|
|
||||
LL | let fancy_field = drop_struct.fancy; //~ ERROR E0509
|
||||
| ^^^^^^^^^^^^^^^^^ cannot move out of here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0509`.
|
|
@ -0,0 +1,13 @@
|
|||
error: compilation successful
|
||||
--> $DIR/E0597.rs:15:1
|
||||
|
|
||||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
LL | | let mut x = Foo { x: None };
|
||||
LL | | let y = 0;
|
||||
LL | | x.x = Some(&y);
|
||||
LL | | //~^ `y` does not live long enough [E0597]
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -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);
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/E0621-does-not-trigger-for-closures.rs:25:5
|
||||
|
|
||||
LL | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495
|
||||
| ^^^^^^
|
||||
|
||||
error: free region `` does not outlive free region `'_#2r`
|
||||
--> $DIR/E0621-does-not-trigger-for-closures.rs:25:26
|
||||
|
|
||||
LL | invoke(&x, |a, b| if a > b { a } else { b }); //~ ERROR E0495
|
||||
| ^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
error: compilation successful
|
||||
--> $DIR/feature-gate-nll.rs:13:1
|
||||
|
|
||||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
LL | | let mut x = 33;
|
||||
LL | |
|
||||
LL | | let p = &x;
|
||||
LL | | x = 22; //~ ERROR cannot assign to `x` because it is borrowed [E0506]
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -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;
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
error: compilation successful
|
||||
--> $DIR/borrowing.rs:15:1
|
||||
|
|
||||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
LL | | let _b = {
|
||||
LL | | let a = 3;
|
||||
LL | | unsafe { (|| yield &a).resume() }
|
||||
... |
|
||||
LL | | };
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -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() }
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
error: compilation successful
|
||||
--> $DIR/dropck.rs:16:1
|
||||
|
|
||||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
LL | | let (cell, mut gen);
|
||||
LL | | cell = Box::new(RefCell::new(0));
|
||||
LL | | let ref_ = Box::leak(Box::new(Some(cell.borrow_mut())));
|
||||
... |
|
||||
LL | | // drops the RefCell and then the Ref, leading to use-after-free
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -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())));
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
error: compilation successful
|
||||
--> $DIR/pattern-borrow.rs:15:1
|
||||
|
|
||||
LL | fn main() { #![rustc_error] } // rust-lang/rust#49855
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -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 || {
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
error[E0597]: `b` does not live long enough
|
||||
--> $DIR/ref-escapes-but-not-over-yield.rs:24:13
|
||||
|
|
||||
LL | a = &b;
|
||||
| ^^ borrowed value does not live long enough
|
||||
LL | //~^ ERROR `b` does not live long enough
|
||||
LL | };
|
||||
| - borrowed value only lives until here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
|
@ -0,0 +1,9 @@
|
|||
error[E0626]: borrow may still be in use when generator yields
|
||||
--> $DIR/yield-in-args.rs:18:13
|
||||
|
|
||||
LL | foo(&b, yield); //~ ERROR
|
||||
| ^^ ----- possible yield occurs here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0626`.
|
|
@ -0,0 +1,55 @@
|
|||
error[E0626]: borrow may still be in use when generator yields
|
||||
--> $DIR/yield-while-iterating.rs:22:18
|
||||
|
|
||||
LL | for p in &x { //~ ERROR
|
||||
| ^^
|
||||
LL | yield();
|
||||
| ------- possible yield occurs here
|
||||
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
--> $DIR/yield-while-iterating.rs:50:17
|
||||
|
|
||||
LL | let mut b = || {
|
||||
| _________________^
|
||||
LL | | for p in &mut x {
|
||||
LL | | yield p;
|
||||
LL | | }
|
||||
LL | | };
|
||||
| | ^
|
||||
| | |
|
||||
| |_____temporary value only lives until here
|
||||
| temporary value does not live long enough
|
||||
|
||||
error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable
|
||||
--> $DIR/yield-while-iterating.rs:67:20
|
||||
|
|
||||
LL | let mut b = || {
|
||||
| _________________-
|
||||
LL | | for p in &mut x {
|
||||
LL | | yield p;
|
||||
LL | | }
|
||||
LL | | };
|
||||
| |_____- mutable borrow occurs here
|
||||
LL | println!("{}", x[0]); //~ ERROR
|
||||
| ^ immutable borrow occurs here
|
||||
LL | b.resume();
|
||||
| - borrow later used here
|
||||
|
||||
error[E0597]: borrowed value does not live long enough
|
||||
--> $DIR/yield-while-iterating.rs:62:17
|
||||
|
|
||||
LL | let mut b = || {
|
||||
| _________________^
|
||||
LL | | for p in &mut x {
|
||||
LL | | yield p;
|
||||
LL | | }
|
||||
LL | | };
|
||||
| | ^
|
||||
| | |
|
||||
| |_____temporary value only lives until here
|
||||
| temporary value does not live long enough
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
Some errors occurred: E0502, E0597, E0626.
|
||||
For more information about an error, try `rustc --explain E0502`.
|
|
@ -0,0 +1,18 @@
|
|||
error[E0501]: cannot borrow `x` as immutable because previous closure requires unique access
|
||||
--> $DIR/yield-while-ref-reborrowed.rs:45:20
|
||||
|
|
||||
LL | let mut b = || {
|
||||
| _________________-
|
||||
LL | | let a = &mut *x;
|
||||
LL | | yield();
|
||||
LL | | println!("{}", a);
|
||||
LL | | };
|
||||
| |_____- closure construction occurs here
|
||||
LL | println!("{}", x); //~ ERROR
|
||||
| ^ borrow occurs here
|
||||
LL | b.resume();
|
||||
| - borrow later used here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0501`.
|
|
@ -0,0 +1,14 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/dyn-trait.rs:33:16
|
||||
|
|
||||
LL | static_val(x); //~ ERROR cannot infer
|
||||
| ^
|
||||
|
||||
error: free region `'a` does not outlive free region `'static`
|
||||
--> $DIR/dyn-trait.rs:33:5
|
||||
|
|
||||
LL | static_val(x); //~ ERROR cannot infer
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/mismatched.rs:14:42
|
||||
|
|
||||
LL | fn foo(x: &'a u32, y: &u32) -> &'a u32 { y } //~ ERROR explicit lifetime required
|
||||
| ^
|
||||
|
||||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/mismatched.rs:16:46
|
||||
|
|
||||
LL | fn foo2(x: &'a u32, y: &'b u32) -> &'a u32 { y } //~ ERROR lifetime mismatch
|
||||
| ^
|
||||
|
||||
error[E0621]: explicit lifetime required in the type of `y`
|
||||
--> $DIR/mismatched.rs:14:42
|
||||
|
|
||||
LL | fn foo(x: &'a u32, y: &u32) -> &'a u32 { y } //~ ERROR explicit lifetime required
|
||||
| - ^ lifetime `'a` required
|
||||
| |
|
||||
| consider changing the type of `y` to `&'a u32`
|
||||
|
||||
error[E0623]: lifetime mismatch
|
||||
--> $DIR/mismatched.rs:16:46
|
||||
|
|
||||
LL | fn foo2(x: &'a u32, y: &'b u32) -> &'a u32 { y } //~ ERROR lifetime mismatch
|
||||
| ------- ------- ^ ...but data from `y` is returned here
|
||||
| |
|
||||
| this parameter and the return type are declared with different lifetimes...
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors occurred: E0621, E0623.
|
||||
For more information about an error, try `rustc --explain E0621`.
|
|
@ -0,0 +1,17 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/mismatched_trait.rs:16:9
|
||||
|
|
||||
LL | y //~ ERROR explicit lifetime required
|
||||
| ^
|
||||
|
||||
error[E0621]: explicit lifetime required in the type of `y`
|
||||
--> $DIR/mismatched_trait.rs:16:9
|
||||
|
|
||||
LL | fn baz(&self, x: &'a u32, y: &u32) -> &'a u32 {
|
||||
| - consider changing the type of `y` to `&'a u32`
|
||||
LL | y //~ ERROR explicit lifetime required
|
||||
| ^ lifetime `'a` required
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0621`.
|
|
@ -0,0 +1,13 @@
|
|||
error[E0506]: cannot assign to `p` because it is borrowed
|
||||
--> $DIR/mut_while_borrow.rs:19:5
|
||||
|
|
||||
LL | let r = foo(&p);
|
||||
| -- borrow of `p` occurs here
|
||||
LL | p += 1; //~ ERROR cannot assign to `p` because it is borrowed
|
||||
| ^^^^^^ assignment to borrowed `p` occurs here
|
||||
LL | println!("{}", r);
|
||||
| - borrow later used here
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0506`.
|
|
@ -0,0 +1,27 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/issue-13058.rs:24:21
|
||||
|
|
||||
LL | let cont_iter = cont.iter();
|
||||
| ^^^^
|
||||
|
||||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/issue-13058.rs:24:26
|
||||
|
|
||||
LL | let cont_iter = cont.iter();
|
||||
| ^^^^
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-13058.rs:36:11
|
||||
|
|
||||
LL | check((3, 5));
|
||||
| ^^^^^^
|
||||
| |
|
||||
| expected reference, found tuple
|
||||
| help: consider borrowing here: `&(3, 5)`
|
||||
|
|
||||
= note: expected type `&_`
|
||||
found type `({integer}, {integer})`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
|
@ -0,0 +1,14 @@
|
|||
error: compilation successful
|
||||
--> $DIR/issue-17263.rs:15:1
|
||||
|
|
||||
LL | / fn main() { #![rustc_error] // rust-lang/rust#49855
|
||||
LL | | let mut x: Box<_> = box Foo { a: 1, b: 2 };
|
||||
LL | | let (a, b) = (&mut x.a, &mut x.b);
|
||||
LL | | //~^ ERROR cannot borrow `x` (via `x.b`) as mutable more than once at a time
|
||||
... |
|
||||
LL | | //~^ ERROR cannot borrow `foo` (via `foo.b`) as immutable
|
||||
LL | | }
|
||||
| |_^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
error[E0596]: cannot borrow immutable item `x` as mutable
|
||||
--> $DIR/issue-21600.rs:24:20
|
||||
|
|
||||
LL | call_it(|| x.gen_mut()); //~ ERROR cannot borrow data mutably in a captured outer
|
||||
| ^ cannot borrow as mutable
|
||||
|
||||
error[E0596]: cannot borrow immutable item `x` as mutable
|
||||
--> $DIR/issue-21600.rs:24:17
|
||||
|
|
||||
LL | call_it(|| x.gen_mut()); //~ ERROR cannot borrow data mutably in a captured outer
|
||||
| ^^^^^^^^^^^^^^ cannot borrow as mutable
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
|
@ -0,0 +1,8 @@
|
|||
error: compilation successful
|
||||
--> $DIR/issue-25793.rs:32:1
|
||||
|
|
||||
LL | fn main() { #![rustc_error] } // rust-lang/rust#49855
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -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()
|
||||
|
@ -29,4 +29,4 @@ impl HasInfo {
|
|||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
fn main() { #![rustc_error] } // rust-lang/rust#49855
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
error[E0596]: cannot borrow immutable item `*x` as mutable
|
||||
--> $DIR/issue-36400.rs:15:7
|
||||
|
|
||||
LL | f(&mut *x); //~ ERROR cannot borrow immutable
|
||||
| ^^^^^^^ cannot borrow as mutable
|
||||
|
|
||||
= note: Value not mutable causing this error: `x`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0596`.
|
|
@ -0,0 +1,9 @@
|
|||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/issue-40402-1.rs:19:13
|
||||
|
|
||||
LL | let e = f.v[0]; //~ ERROR cannot move out of indexed content
|
||||
| ^^^^^^ cannot move out of borrowed content
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0507`.
|
|
@ -0,0 +1,15 @@
|
|||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/issue-40402-2.rs:15:10
|
||||
|
|
||||
LL | let (a, b) = x[0]; //~ ERROR cannot move out of indexed content
|
||||
| ^ cannot move out of borrowed content
|
||||
|
||||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/issue-40402-2.rs:15:13
|
||||
|
|
||||
LL | let (a, b) = x[0]; //~ ERROR cannot move out of indexed content
|
||||
| ^ cannot move out of borrowed content
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0507`.
|
|
@ -0,0 +1,8 @@
|
|||
error: compilation successful
|
||||
--> $DIR/issue-42106.rs:16:1
|
||||
|
|
||||
LL | fn main() { #![rustc_error] } // rust-lang/rust#49855
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
error[E0507]: cannot move out of borrowed content
|
||||
--> $DIR/issue-4335.rs:16:20
|
||||
|
|
||||
LL | id(Box::new(|| *v))
|
||||
| ^^ cannot move out of borrowed content
|
||||
|
||||
error[E0597]: `v` does not live long enough
|
||||
--> $DIR/issue-4335.rs:16:17
|
||||
|
|
||||
LL | id(Box::new(|| *v))
|
||||
| ^^^^^ borrowed value does not live long enough
|
||||
...
|
||||
LL | }
|
||||
| - borrowed value only lives until here
|
||||
|
|
||||
note: borrowed value must be valid for the lifetime 'r as defined on the function body at 15:1...
|
||||
--> $DIR/issue-4335.rs:15:1
|
||||
|
|
||||
LL | fn f<'r, T>(v: &'r T) -> Box<FnMut() -> T + 'r> {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors occurred: E0507, E0597.
|
||||
For more information about an error, try `rustc --explain E0507`.
|
|
@ -0,0 +1,34 @@
|
|||
error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast)
|
||||
--> $DIR/issue-45697-1.rs:30:9
|
||||
|
|
||||
LL | let z = copy_borrowed_ptr(&mut y);
|
||||
| - borrow of `*y.pointer` occurs here
|
||||
LL | *y.pointer += 1;
|
||||
| ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here
|
||||
|
||||
error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir)
|
||||
--> $DIR/issue-45697-1.rs:30:9
|
||||
|
|
||||
LL | let z = copy_borrowed_ptr(&mut y);
|
||||
| ------ borrow of `y` occurs here
|
||||
LL | *y.pointer += 1;
|
||||
| ^^^^^^^^^^^^^^^ use of borrowed `y`
|
||||
...
|
||||
LL | *z.pointer += 1;
|
||||
| --------------- borrow later used here
|
||||
|
||||
error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Mir)
|
||||
--> $DIR/issue-45697-1.rs:30:9
|
||||
|
|
||||
LL | let z = copy_borrowed_ptr(&mut y);
|
||||
| ------ borrow of `*y.pointer` occurs here
|
||||
LL | *y.pointer += 1;
|
||||
| ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here
|
||||
...
|
||||
LL | *z.pointer += 1;
|
||||
| --------------- borrow later used here
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors occurred: E0503, E0506.
|
||||
For more information about an error, try `rustc --explain E0503`.
|
|
@ -0,0 +1,34 @@
|
|||
error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Ast)
|
||||
--> $DIR/issue-45697.rs:30:9
|
||||
|
|
||||
LL | let z = copy_borrowed_ptr(&mut y);
|
||||
| - borrow of `*y.pointer` occurs here
|
||||
LL | *y.pointer += 1;
|
||||
| ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here
|
||||
|
||||
error[E0503]: cannot use `*y.pointer` because it was mutably borrowed (Mir)
|
||||
--> $DIR/issue-45697.rs:30:9
|
||||
|
|
||||
LL | let z = copy_borrowed_ptr(&mut y);
|
||||
| ------ borrow of `y` occurs here
|
||||
LL | *y.pointer += 1;
|
||||
| ^^^^^^^^^^^^^^^ use of borrowed `y`
|
||||
...
|
||||
LL | *z.pointer += 1;
|
||||
| --------------- borrow later used here
|
||||
|
||||
error[E0506]: cannot assign to `*y.pointer` because it is borrowed (Mir)
|
||||
--> $DIR/issue-45697.rs:30:9
|
||||
|
|
||||
LL | let z = copy_borrowed_ptr(&mut y);
|
||||
| ------ borrow of `*y.pointer` occurs here
|
||||
LL | *y.pointer += 1;
|
||||
| ^^^^^^^^^^^^^^^ assignment to borrowed `*y.pointer` occurs here
|
||||
...
|
||||
LL | *z.pointer += 1;
|
||||
| --------------- borrow later used here
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
Some errors occurred: E0503, E0506.
|
||||
For more information about an error, try `rustc --explain E0503`.
|
|
@ -0,0 +1,28 @@
|
|||
error[E0597]: `z` does not live long enough (Ast)
|
||||
--> $DIR/issue-46471-1.rs:16:14
|
||||
|
|
||||
LL | &mut z
|
||||
| ^ borrowed value does not live long enough
|
||||
LL | };
|
||||
| - `z` dropped here while still borrowed
|
||||
...
|
||||
LL | }
|
||||
| - borrowed value needs to live until here
|
||||
|
||||
error[E0597]: `z` does not live long enough (Mir)
|
||||
--> $DIR/issue-46471-1.rs:16:9
|
||||
|
|
||||
LL | let y = {
|
||||
| _____________-
|
||||
LL | | let mut z = 0;
|
||||
LL | | &mut z
|
||||
| | ^^^^^^ borrowed value does not live long enough
|
||||
LL | | };
|
||||
| | -
|
||||
| | |
|
||||
| |_____borrowed value only lives until here
|
||||
| borrow later used here
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0597`.
|
|
@ -0,0 +1,22 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/42701_one_named_and_one_anonymous.rs:20:9
|
||||
|
|
||||
LL | &*x //~ ERROR explicit lifetime
|
||||
| ^^^
|
||||
|
||||
error[E0621]: explicit lifetime required in the type of `x`
|
||||
--> $DIR/42701_one_named_and_one_anonymous.rs:16:5
|
||||
|
|
||||
LL | fn foo2<'a>(a: &'a Foo, x: &i32) -> &'a i32 {
|
||||
| - consider changing the type of `x` to `&'a i32`
|
||||
LL | / if true {
|
||||
LL | | let p: &i32 = &a.field;
|
||||
LL | | &*p
|
||||
LL | | } else {
|
||||
LL | | &*x //~ ERROR explicit lifetime
|
||||
LL | | }
|
||||
| |_____^ lifetime `'a` required
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0621`.
|
|
@ -0,0 +1,23 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/ex1-return-one-existing-name-early-bound-in-struct.rs:21:21
|
||||
|
|
||||
LL | other //~ ERROR explicit lifetime
|
||||
| ^^^^^
|
||||
|
||||
error[E0621]: explicit lifetime required in the type of `other`
|
||||
--> $DIR/ex1-return-one-existing-name-early-bound-in-struct.rs:18:9
|
||||
|
|
||||
LL | fn bar(&self, other: Foo) -> Foo<'a> {
|
||||
| ----- consider changing the type of `other` to `Foo<'a>`
|
||||
LL | / match *self {
|
||||
LL | | Foo::Bar(s) => {
|
||||
LL | | if s == "test" {
|
||||
LL | | other //~ ERROR explicit lifetime
|
||||
... |
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_________^ lifetime `'a` required
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0621`.
|
|
@ -0,0 +1,17 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/ex1-return-one-existing-name-if-else-2.rs:12:16
|
||||
|
|
||||
LL | if x > y { x } else { y } //~ ERROR explicit lifetime
|
||||
| ^
|
||||
|
||||
error[E0621]: explicit lifetime required in the type of `x`
|
||||
--> $DIR/ex1-return-one-existing-name-if-else-2.rs:12:8
|
||||
|
|
||||
LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
|
||||
| - consider changing the type of `x` to `&'a i32`
|
||||
LL | if x > y { x } else { y } //~ ERROR explicit lifetime
|
||||
| ^^^^^ lifetime `'a` required
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0621`.
|
|
@ -0,0 +1,18 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/ex1-return-one-existing-name-if-else-3.rs:12:27
|
||||
|
|
||||
LL | if x > y { x } else { y } //~ ERROR explicit lifetime
|
||||
| ^
|
||||
|
||||
error[E0621]: explicit lifetime required in parameter type
|
||||
--> $DIR/ex1-return-one-existing-name-if-else-3.rs:11:13
|
||||
|
|
||||
LL | fn foo<'a>((x, y): (&'a i32, &i32)) -> &'a i32 {
|
||||
| -^----
|
||||
| ||
|
||||
| |lifetime `'a` required
|
||||
| consider changing type to `(&'a i32, &'a i32)`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0621`.
|
|
@ -0,0 +1,17 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/ex1-return-one-existing-name-if-else-using-impl-2.rs:14:15
|
||||
|
|
||||
LL | if x > y { x } else { y } //~ ERROR explicit lifetime
|
||||
| ^
|
||||
|
||||
error[E0621]: explicit lifetime required in the type of `x`
|
||||
--> $DIR/ex1-return-one-existing-name-if-else-using-impl-2.rs:14:7
|
||||
|
|
||||
LL | fn foo<'a>(x: &i32, y: &'a i32) -> &'a i32 {
|
||||
| - consider changing the type of `x` to `&'a i32`
|
||||
LL | if x > y { x } else { y } //~ ERROR explicit lifetime
|
||||
| ^^^^^ lifetime `'a` required
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0621`.
|
|
@ -0,0 +1,18 @@
|
|||
warning: not reporting region error due to -Znll
|
||||
--> $DIR/ex1-return-one-existing-name-if-else-using-impl-3.rs:18:36
|
||||
|
|
||||
LL | if true { &self.field } else { x } //~ ERROR explicit lifetime
|
||||
| ^
|
||||
|
||||
error[E0621]: explicit lifetime required in the type of `x`
|
||||
--> $DIR/ex1-return-one-existing-name-if-else-using-impl-3.rs:18:5
|
||||
|
|
||||
LL | fn foo<'a>(&'a self, x: &i32) -> &i32 {
|
||||
| - consider changing the type of `x` to `&'a i32`
|
||||
LL |
|
||||
LL | if true { &self.field } else { x } //~ ERROR explicit lifetime
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ lifetime `'a` required
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0621`.
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue