Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 17 pull requests #59067

Closed
wants to merge 43 commits into from
Closed

Rollup of 17 pull requests #59067

wants to merge 43 commits into from

Conversation

Centril
Copy link
Contributor

@Centril Centril commented Mar 10, 2019

Successful merges:

Failed merges:

r? @ghost

GuillaumeGomez and others added 30 commits February 25, 2019 17:43
A convenience method like fs::copy() should try to prevent pitfalls a
normal user doesn't think about.

In case of an empty umask, setting the file mode early prevents
temporarily world readable or even writeable files,
because the default mode is 0o666.

In case the target is a named pipe or special device node, setting the
file mode can lead to unwanted side effects, like setting permissons on
`/dev/stdout` or for root setting permissions on `/dev/null`.

copy_file_range() returns EINVAL, if the destination is a FIFO/pipe or
a device like "/dev/null", so fallback to io::copy, too.

Fixes: rust-lang#26933
Fixed: rust-lang#37885
Ensure the core::ffi::VaList structure passes the improper_ctypes lint.
There's lots of comments in the code, but the main gist of this commit
is that the acquisition of the global malloc lock on the
`wasm32-unknown-unknown` target when threads are enabled will not spin
on contention rather than block.
MIPS r6 is quite different with the previous version.
It use some new target triples:
  mipsisa32r6-unknown-linux-gnu
  mipsisa32r6el-unknown-linux-gnu
  mipsisa64r6-unknown-linux-gnuabi64
  mipsisa64r6el-unknown-linux-gnuabi64

This patch has been tested with Debian Port for mips64r6el,
and the support of these triples also is included in llvm:
  https://reviews.llvm.org/rGe58c45a695f39004710b6ce940d489fee800dbd3
A `Def::Variant` should be considered as a function in mir pretty
printing. Each variant has a constructor that we must print.

Given the following enum definition:

```
pub enum TestMe {
    X(usize),
}
```

We will need to generate a constructor for the variant `X` with a
signature that looks something like the following:

```
fn TestMe::X(_1: usize) -> TestMe;
```
…r=QuietMisdreavus,Mark-Simulacrum

Add rustdoc JS non-std tests

@QuietMisdreavus: You asked it, here it is!

r? @QuietMisdreavus
…nkfelix

Make migrate mode work at item level granularity

Migrate mode now works entirely at the item level rather than the body level,
ensuring that we don't lose any errors in contained closures.

Closes rust-lang#58776

r? @pnkfelix
… r=sanxiyn

Update compiler_builtins to 0.1.7 to get windows/arm fix
Centril added 13 commits March 10, 2019 13:29
fs::copy() linux: set file mode early

A convenience method like fs::copy() should try to prevent pitfalls a
normal user doesn't think about.

In case of an empty umask, setting the file mode early prevents
temporarily world readable or even writeable files,
because the default mode is 0o666.

In case the target is a named pipe or special device node, setting the
file mode can lead to unwanted side effects, like setting permissons on
`/dev/stdout` or for root setting permissions on `/dev/null`.

copy_file_range() returns EINVAL, if the destination is a FIFO/pipe or
a device like "/dev/null", so fallback to io::copy, too.

Fixes: rust-lang#26933
Fixed: rust-lang#37885
librustc_interface: Update scoped-tls to 1.0

Done previously as a part of rust-lang#58748.

r? @Zoxc
…Mark-Simulacrum

Prevent cache issues on version updates

Fixes rust-lang#58827.

cc @rust-lang/infra
…oc, r=fitzgen

std: Spin for a global malloc lock on wasm32

There's lots of comments in the code, but the main gist of this commit
is that the acquisition of the global malloc lock on the
`wasm32-unknown-unknown` target when threads are enabled will not spin
on contention rather than block.
…rochenkov

Adds help message in error for invalid `impl for T` syntax

Fixes rust-lang#56031.
…henkov

Parse lifetimes that start with a number and give specific error

Fix rust-lang#58786.
Change `std::fs::copy` to use `copyfile` on MacOS and iOS

`copyfile` on MacOS is similar to `CopyFileEx` on Windows. It supports copying resource forks, extended attributes, and file ACLs, none of which are copied by the current generic unix implementation.

The API is available from MacOS 10.7 and iOS 4.3 (and possibly earlier but I haven't checked).

Closes rust-lang#58895.
core: ensure VaList passes improper_ctypes lint

Ensure the `core::ffi::VaList` structure passes the `improper_ctypes` lint.

Fixes: rust-lang#58280
MIPS: add r6 support

MIPS r6 is quite different with the previous version.
It use some new target triples:
  mipsisa32r6-unknown-linux-gnu
  mipsisa32r6el-unknown-linux-gnu
  mipsisa64r6-unknown-linux-gnuabi64
  mipsisa64r6el-unknown-linux-gnuabi64

This patch has been tested with Debian Port for mips64r6el,
and the support of these triples also is included in llvm:
  https://reviews.llvm.org/rGe58c45a695f39004710b6ce940d489fee800dbd3
…twco

When encountetring `||{}()`, suggest the likely intended `(||{})()`

Fix rust-lang#55851.
Fix ICE in MIR pretty printing

A `Def::Variant` should be considered as a function in mir pretty
printing. Each variant has a constructor that we must print.

Given the following enum definition:

```rust
pub enum TestMe {
    X(usize),
}
```

We will need to generate a constructor for the variant `X` with a
signature that looks something like the following:

```
fn TestMe::X(_1: usize) -> TestMe;
```

Fixes: rust-lang#59021
resolve: Account for new importable entities

Fixes the ICE encountered in rust-lang#58837
r? @Centril
…ackler

Use lifetime contravariance to elide more lifetimes in core+alloc+std

Sample:
```diff
-    impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a mut A where A: PartialEq<B> {
+    impl<A: ?Sized, B: ?Sized> PartialEq<&mut B> for &mut A where A: PartialEq<B> {
         #[inline]
-        fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) }
+        fn eq(&self, other: &&mut B) -> bool { PartialEq::eq(*self, *other) }
         #[inline]
-        fn ne(&self, other: &&'b mut B) -> bool { PartialEq::ne(*self, *other) }
+        fn ne(&self, other: &&mut B) -> bool { PartialEq::ne(*self, *other) }
     }
```

[I didn't know this worked](https://internals.rust-lang.org/t/why-can-you-use-different-unconstrained-lifetimes-to-implement-traits/9544/2?u=scottmcm) until recently, but since defining methods contravariantly in their lifetimes this way has worked back to Rust 1.0, we might as well take advantage of combining it with IHLE.
@Centril
Copy link
Contributor Author

Centril commented Mar 10, 2019

@bors r+ p=17

@bors
Copy link
Contributor

bors commented Mar 10, 2019

📌 Commit 6a94f44 has been approved by Centril

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Mar 10, 2019
@bors
Copy link
Contributor

bors commented Mar 10, 2019

⌛ Testing commit 6a94f44 with merge 8859e70db2b494bdcd0b475f69bc91c8094226f0...

@bors
Copy link
Contributor

bors commented Mar 10, 2019

💔 Test failed - checks-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 10, 2019
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-nopt of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[01:38:31] ---- [ui (nll)] ui/borrowck/borrowck-in-static.rs stdout ----
[01:38:31] 
[01:38:31] error: ui test compiled successfully!
[01:38:31] status: exit code: 0
[01:38:31] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-in-static.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-in-static.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-Crpath" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-in-static.nll/auxiliary" "-A" "unused"
[01:38:31] ------------------------------------------
[01:38:31] 
[01:38:31] ------------------------------------------
[01:38:31] stderr:
[01:38:31] stderr:
[01:38:31] ------------------------------------------
[01:38:31] {"message":"cannot move out of captured variable in an `Fn` closure","code":{"code":"E0507","explanation":"\nYou tried to move out of a value which was borrowed. Erroneous code example:\n\n```compile_fail,E0507\nuse std::cell::RefCell;\n\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(self) {}\n}\n\nfn main() {\n    let x = RefCell::new(TheDarkKnight);\n\n    x.borrow().nothing_is_true(); // error: cannot move out of borrowed content\n}\n```\n\nHere, the `nothing_is_true` method takes the ownership of `self`. However,\n`self` cannot be moved because `.borrow()` only provides an `&TheDarkKnight`,\nwhich is a borrow of the content owned by the `RefCell`. To fix this error,\nyou have three choices:\n\n* Try to avoid moving the variable.\n* Somehow reclaim the ownership.\n* Implement the `Copy` trait on the type.\n\nExamples:\n\n```\nuse std::cell::RefCell;\n\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(&self) {} // First case, we don't take ownership\n}\n\nfn main() {\n    let x = RefCell::new(TheDarkKnight);\n\n    x.borrow().nothing_is_true(); // ok!\n}\n```\n\nOr:\n\n```\nuse std::cell::RefCell;\n\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(self) {}\n}\n\nfn main() {\n    let x = RefCell::new(TheDarkKnight);\n    let x = x.into_inner(); // we get back ownership\n\n    x.nothing_is_true(); // ok!\n}\n```\n\nOr:\n\n```\nuse std::cell::RefCell;\n\n#[derive(Clone, Copy)] // we implement the Copy trait\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(self) {}\n}\n\nfn main() {\n    let x = RefCell::new(TheDarkKnight);\n\n    x.borrow().nothing_is_true(); // ok!\n}\n```\n\nMoving a member out of a mutably borrowed struct will also cause E0507 error:\n\n```compile_fail,E0507\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(self) {}\n}\n\nstruct Batcave {\n    knight: TheDarkKnight\n}\n\nfn main() {\n    let mut cave = Batcave {\n        knight: TheDarkKnight\n    };\n    let borrowed = &mut cave;\n\n    borrowed.knight.nothing_is_true(); // E0507\n}\n```\n\nIt is fine only if you put something back. `mem::replace` can be used for that:\n\n```\n# struct TheDarkKnight;\n# impl TheDarkKnight { fn nothing_is_true(self) {} }\n# struct Batcave { knight: TheDarkKnight }\nuse std::mem;\n\nlet mut cave = Batcave {\n    knight: TheDarkKnight\n};\nlet borrowed = &mut cave;\n\nmem::replace(&mut borrowed.knight, TheDarkKnight).nothing_is_true(); // ok!\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html\n"},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-in-static.rs","byte_start":161,"byte_end":162,"line_start":5,"line_end":5,"column_start":17,"column_end":18,"is_primary":true,"text":[{"text":"    Box::new(|| x) //~ ERROR cannot move out of captured outer variable","highlight_start":17,"highlight_end":18}],"label":"cannot move out of captured variable in an `Fn` closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-in-static.rs","byte_start":128,"byte_end":129,"line_start":4,"line_end":4,"column_start":9,"column_end":10,"is_primary":false,"text":[{"text":"    let x = Box::new(0);","highlight_start":9,"highlight_end":10}],"label":"captured outer variable","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"this error has been downgraded to a warning for backwards compatibility with previous releases","code":null,"level":"warning","spans":[],"children":[],"rendered":null},{"message":"this represents potential undefined behavior in your code and this warning will become a hard error in the future","code":null,"level":"warning","spans":[],"children":[],"rendered":null}],"rendered":"warning[E0507]: cannot move out of captured variable in an `Fn` closure\n  --> /checkout/src/test/ui/borrowck/borrowck-in-static.rs:5:17\n   |\nLL |     let x = Box::new(0);\n   |         - captured outer variable\nLL |     Box::new(|| x) //~ ERROR cannot move out of captured outer variable\n   |                 ^ cannot move out of captured variable in an `Fn` closure\n   |\n   = warning: this error has been downgraded to a warning for backwards compatibility with previous releases\n   = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future\n\n"}
[01:38:31] ------------------------------------------
[01:38:31] 
[01:38:31] thread '[ui (nll)] ui/borrowck/borrowck-in-static.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3319:9
[01:38:31] note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
[01:38:31] note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
[01:38:31] 
[01:38:31] ---- [ui (nll)] ui/borrowck/borrowck-move-in-irrefut-pat.rs#ast stdout ----
[01:38:31] diff of stderr:
[01:38:31] 
[01:38:31] 14 LL | fn arg_item(&_x: &String) {}
[01:38:31] 16 
[01:38:31] - error[E0507]: cannot move out of borrowed content
[01:38:31] - error[E0507]: cannot move out of borrowed content
[01:38:31] + warning[E0507]: cannot move out of borrowed content
[01:38:31] 19    |
[01:38:31] 19    |
[01:38:31] 20 LL |     with(|&_x| ())
[01:38:31] 29    |
[01:38:31] 29    |
[01:38:31] 30 LL |     with(|&_x| ())
[01:38:31] +    = warning: this error has been downgraded to a warning for backwards compatibility with previous releases
[01:38:31] +    = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
[01:38:31] 32 
[01:38:31] 33 error[E0507]: cannot move out of borrowed content
[01:38:31] 33 error[E0507]: cannot move out of borrowed content
[01:38:31] 34   --> $DIR/borrowck-move-in-irrefut-pat.rs:17:15
[01:38:31] 
[01:38:31] 45 LL |     let &_x = &"hi".to_string();
[01:38:31] 47 
[01:38:31] - error: aborting due to 3 previous errors
[01:38:31] + error: aborting due to 2 previous errors
[01:38:31] 49 
[01:38:31] 49 
[01:38:31] 50 For more information about this error, try `rustc --explain E0507`.
[01:38:31] 51 
[01:38:31] 
[01:38:31] 
[01:38:31] The actual stderr differed from the expected stderr.
[01:38:31] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll/borrowck-move-in-irrefut-pat.ast.nll.stderr
[01:38:31] To update references, rerun the tests and pass the `--bless` flag
[01:38:31] To only update this specific test, also pass `--test-args borrowck/borrowck-move-in-irrefut-pat.rs`
[01:38:31] 
[01:38:31] error in revision `ast`: 1 errors occurred comparing output.
[01:38:31] status: exit code: 1
[01:38:31] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--cfg" "ast" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-Crpath" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-move-in-irrefut-pat.ast.nll/auxiliary" "-A" "unused"
[01:38:31] ------------------------------------------
[01:38:31] 
[01:38:31] ------------------------------------------
[01:38:31] stderr:
[01:38:31] stderr:
[01:38:31] ------------------------------------------
[01:38:31] {"message":"cannot move out of borrowed content","code":{"code":"E0507","explanation":"\nYou tried to move out of a value which was borrowed. Erroneous code example:\n\n```compile_fail,E0507\nuse std::cell::RefCell;\n\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(self) {}\n}\n\nfn main() {\n    let x = RefCell::new(TheDarkKnight);\n\n    x.borrow().nothing_is_true(); // error: cannot move out of borrowed content\n}\n```\n\nHere, the `nothing_is_true` method takes the ownership of `self`. However,\n`self` cannot be moved because `.borrow()` only provides an `&TheDarkKnight`,\nwhich is a borrow of the content owned by the `RefCell`. To fix this error,\nyou have three choices:\n\n* Try to avoid moving the variable.\n* Somehow reclaim the ownership.\n* Implement the `Copy` trait on the type.\n\nExamples:\n\n```\nuse std::cell::RefCell;\n\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(&self) {} // First case, we don't take ownership\n}\n\nfn main() {\n    let x = RefCell::new(TheDarkKnight);\n\n    x.borrow().nothing_is_true(); // ok!\n}\n```\n\nOr:\n\n```\nuse std::cell::RefCell;\n\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(self) {}\n}\n\nfn main() {\n    let x = RefCell::new(TheDarkKnight);\n    let x = x.into_inner(); // we get back ownership\n\n    x.nothing_is_true(); // ok!\n}\n```\n\nOr:\n\n```\nuse std::cell::RefCell;\n\n#[derive(Clone, Copy)] // we implement the Copy trait\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(self) {}\n}\n\nfn main() {\n    let x = RefCell::new(TheDarkKnight);\n\n    x.borrow().nothing_is_true(); // ok!\n}\n```\n\nMoving a member out of a mutably borrowed struct will also cause E0507 error:\n\n```compile_fail,E0507\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(self) {}\n}\n\nstruct Batcave {\n    knight: TheDarkKnight\n}\n\nfn main() {\n    let mut cave = Batcave {\n        knight: TheDarkKnight\n    };\n    let borrowed = &mut cave;\n\n    borrowed.knight.nothing_is_true(); // E0507\n}\n```\n\nIt is fine only if you put something back. `mem::replace` can be used for that:\n\n```\n# struct TheDarkKnight;\n# impl TheDarkKnight { fn nothing_is_true(self) {} }\n# struct Batcave { knight: TheDarkKnight }\nuse std::mem;\n\nlet mut cave = Batcave {\n    knight: TheDarkKnight\n};\nlet borrowed = &mut cave;\n\nmem::replace(&mut borrowed.knight, TheDarkKnight).nothing_is_true(); // ok!\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs","byte_start":119,"byte_end":122,"line_start":6,"line_end":6,"column_start":13,"column_end":16,"is_primary":true,"text":[{"text":"fn arg_item(&_x: &String) {}","highlight_start":13,"highlight_end":16}],"label":"cannot move out of borrowed content","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs","byte_start":120,"byte_end":122,"line_start":6,"line_end":6,"column_start":14,"column_end":16,"is_primary":false,"text":[{"text":"fn arg_item(&_x: &String) {}","highlight_start":14,"highlight_end":16}],"label":"data moved here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs","byte_start":120,"byte_end":122,"line_start":6,"line_end":6,"column_start":14,"column_end":16,"is_primary":true,"text":[{"text":"fn arg_item(&_x: &String) {}","highlight_start":14,"highlight_end":16}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"consider removing the `&`","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs","byte_start":119,"byte_end":122,"line_start":6,"line_end":6,"column_start":13,"column_end":16,"is_primary":true,"text":[{"text":"fn arg_item(&_x: &String) {}","highlight_start":13,"highlight_end":16}],"label":null,"suggested_replacement":"_x","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0507]: cannot move out of borrowed content\n  --> /checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs:6:13\n   |\nLL | fn arg_item(&_x: &String) {}\n   |             ^--\n   |             ||\n   |             |data moved here\n   |             cannot move out of borrowed content\n   |             help: consider removing the `&`: `_x`\n   |\nnote: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait\n  --> /checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs:6:14\n   |\nLL | fn arg_item(&_x: &String) {}\n   |              ^^\n\n"}
[01:38:31] {"message":"cannot move out of borrowed content","code":{"code":"E0507","explanation":"\nYou tried to move out of a value which was borrowed. Erroneous code example:\n\n```compile_fail,E0507\nuse std::cell::RefCell;\n\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(self) {}\n}\n\nfn main() {\n    let x = RefCell::new(TheDarkKnight);\n\n    x.borrow().nothing_is_true(); // error: cannot move out of borrowed content\n}\n```\n\nHere, the `nothing_is_true` method takes the ownership of `self`. However,\n`self` cannot be moved because `.borrow()` only provides an `&TheDarkKnight`,\nwhich is a borrow of the content owned by the `RefCell`. To fix this error,\nyou have three choices:\n\n* Try to avoid moving the variable.\n* Somehow reclaim the ownership.\n* Implement the `Copy` trait on the type.\n\nExamples:\n\n```\nuse std::cell::RefCell;\n\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(&self) {} // First case, we don't take ownership\n}\n\nfn main() {\n    let x = RefCell::new(TheDarkKnight);\n\n    x.borrow().nothing_is_true(); // ok!\n}\n```\n\nOr:\n\n```\nuse std::cell::RefCell;\n\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(self) {}\n}\n\nfn main() {\n    let x = RefCell::new(TheDarkKnight);\n    let x = x.into_inner(); // we get back ownership\n\n    x.nothing_is_true(); // ok!\n}\n```\n\nOr:\n\n```\nuse std::cell::RefCell;\n\n#[derive(Clone, Copy)] // we implement the Copy trait\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(self) {}\n}\n\nfn main() {\n    let x = RefCell::new(TheDarkKnight);\n\n    x.borrow().nothing_is_true(); // ok!\n}\n```\n\nMoving a member out of a mutably borrowed struct will also cause E0507 error:\n\n```compile_fail,E0507\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(self) {}\n}\n\nstruct Batcave {\n    knight: TheDarkKnight\n}\n\nfn main() {\n    let mut cave = Batcave {\n        knight: TheDarkKnight\n    };\n    let borrowed = &mut cave;\n\n    borrowed.knight.nothing_is_true(); // E0507\n}\n```\n\nIt is fine only if you put something back. `mem::replace` can be used for that:\n\n```\n# struct TheDarkKnight;\n# impl TheDarkKnight { fn nothing_is_true(self) {} }\n# struct Batcave { knight: TheDarkKnight }\nuse std::mem;\n\nlet mut cave = Batcave {\n    knight: TheDarkKnight\n};\nlet borrowed = &mut cave;\n\nmem::replace(&mut borrowed.knight, TheDarkKnight).nothing_is_true(); // ok!\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html\n"},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs","byte_start":259,"byte_end":262,"line_start":11,"line_end":11,"column_start":11,"column_end":14,"is_primary":true,"text":[{"text":"    with(|&_x| ())","highlight_start":11,"highlight_end":14}],"label":"cannot move out of borrowed content","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs","byte_start":260,"byte_end":262,"line_start":11,"line_end":11,"column_start":12,"column_end":14,"is_primary":false,"text":[{"text":"    with(|&_x| ())","highlight_start":12,"highlight_end":14}],"label":"data moved here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs","byte_start":260,"byte_end":262,"line_start":11,"line_end":11,"column_start":12,"column_end":14,"is_primary":true,"text":[{"text":"    with(|&_x| ())","highlight_start":12,"highlight_end":14}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"this error has been downgraded to a warning for backwards compatibility with previous releases","code":null,"level":"warning","spans":[],"children":[],"rendered":null},{"message":"this represents potential undefined behavior in your code and this warning will become a hard error in the future","code":null,"level":"warning","spans":[],"children":[],"rendered":null},{"message":"consider removing the `&`","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs","byte_start":259,"byte_end":262,"line_start":11,"line_end":11,"column_start":11,"column_end":14,"is_primary":true,"text":[{"text":"    with(|&_x| ())","highlight_start":11,"highlight_end":14}],"label":null,"suggested_replacement":"_x","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning[E0507]: cannot move out of borrowed content\n  --> /checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs:11:11\n   |\nLL |     with(|&_x| ())\n   |           ^--\n   |           ||\n   |           |data moved here\n   |           cannot move out of borrowed content\n   |           help: consider removing the `&`: `_x`\n   |\nnote: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait\n  --> /checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs:11:12\n   |\nLL |     with(|&_x| ())\n   |            ^^\n   = warning: this error has been downgraded to a warning for backwards compatibility with previous releases\n   = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future\n\n"}
[01:38:31] {"message":"cannot move out of borrowed content","code":{"code":"E0507","explanation":"\nYou tried to move out of a value which was borrowed. Erroneous code example:\n\n```compile_fail,E0507\nuse std::cell::RefCell;\n\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(self) {}\n}\n\nfn main() {\n    let x = RefCell::new(TheDarkKnight);\n\n    x.borrow().nothing_is_true(); // error: cannot move out of borrowed content\n}\n```\n\nHere, the `nothing_is_true` method takes the ownership of `self`. However,\n`self` cannot be moved because `.borrow()` only provides an `&TheDarkKnight`,\nwhich is a borrow of the content owned by the `RefCell`. To fix this error,\nyou have three choices:\n\n* Try to avoid moving the variable.\n* Somehow reclaim the ownership.\n* Implement the `Copy` trait on the type.\n\nExamples:\n\n```\nuse std::cell::RefCell;\n\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(&self) {} // First case, we don't take ownership\n}\n\nfn main() {\n    let x = RefCell::new(TheDarkKnight);\n\n    x.borrow().nothing_is_true(); // ok!\n}\n```\n\nOr:\n\n```\nuse std::cell::RefCell;\n\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(self) {}\n}\n\nfn main() {\n    let x = RefCell::new(TheDarkKnight);\n    let x = x.into_inner(); // we get back ownership\n\n    x.nothing_is_true(); // ok!\n}\n```\n\nOr:\n\n```\nuse std::cell::RefCell;\n\n#[derive(Clone, Copy)] // we implement the Copy trait\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(self) {}\n}\n\nfn main() {\n    let x = RefCell::new(TheDarkKnight);\n\n    x.borrow().nothing_is_true(); // ok!\n}\n```\n\nMoving a member out of a mutably borrowed struct will also cause E0507 error:\n\n```compile_fail,E0507\nstruct TheDarkKnight;\n\nimpl TheDarkKnight {\n    fn nothing_is_true(self) {}\n}\n\nstruct Batcave {\n    knight: TheDarkKnight\n}\n\nfn main() {\n    let mut cave = Batcave {\n        knight: TheDarkKnight\n    };\n    let borrowed = &mut cave;\n\n    borrowed.knight.nothing_is_true(); // E0507\n}\n```\n\nIt is fine only if you put something back. `mem::replace` can be used for that:\n\n```\n# struct TheDarkKnight;\n# impl TheDarkKnight { fn nothing_is_true(self) {} }\n# struct Batcave { knight: TheDarkKnight }\nuse std::mem;\n\nlet mut cave = Batcave {\n    knight: TheDarkKnight\n};\nlet borrowed = &mut cave;\n\nmem::replace(&mut borrowed.knight, TheDarkKnight).nothing_is_true(); // ok!\n```\n\nYou can find more information about borrowing in the rust-book:\nhttp://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs","byte_start":393,"byte_end":410,"line_start":17,"line_end":17,"column_start":15,"column_end":32,"is_primary":true,"text":[{"text":"    let &_x = &\"hi\".to_string();","highlight_start":15,"highlight_end":32}],"label":"cannot move out of borrowed content","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs","byte_start":388,"byte_end":390,"line_start":17,"line_end":17,"column_start":10,"column_end":12,"is_primary":false,"text":[{"text":"    let &_x = &\"hi\".to_string();","highlight_start":10,"highlight_end":12}],"label":"data moved here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait","code":null,"level":"note","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs","byte_start":388,"byte_end":390,"line_start":17,"line_end":17,"column_start":10,"column_end":12,"is_primary":true,"text":[{"text":"    let &_x = &\"hi\".to_string();","highlight_start":10,"highlight_end":12}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":null},{"message":"consider removing the `&`","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs","byte_start":387,"byte_end":390,"line_start":17,"line_end":17,"column_start":9,"column_end":12,"is_primary":true,"text":[{"text":"    let &_x = &\"hi\".to_string();","highlight_start":9,"highlight_end":12}],"label":null,"suggested_replacement":"_x","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0507]: cannot move out of borrowed content\n  --> /checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs:17:15\n   |\nLL |     let &_x = &\"hi\".to_string();\n   |         ---   ^^^^^^^^^^^^^^^^^ cannot move out of borrowed content\n   |         ||\n   |         |data moved here\n   |         help: consider removing the `&`: `_x`\n   |\nnote: move occurs because `_x` has type `std::string::String`, which does not implement the `Copy` trait\n  --> /checkout/src/test/ui/borrowck/borrowck-move-in-irrefut-pat.rs:17:10\n   |\nLL |     let &_x = &\"hi\".to_string();\n   |          ^^\n\n"}
[01:38:31] {"message":"For more information about this error, try `rustc --explain E0507`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0507`.\n"}
[01:38:31] 
[01:38:31] ------------------------------------------
[01:38:31] 
[01:38:31] 
[01:38:31] thread '[ui (nll)] ui/borrowck/borrowck-move-in-irrefut-pat.rs#ast' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3319:9
[01:38:31] 
[01:38:31] ---- [ui (nll)] ui/borrowck/borrowck-report-with-custom-diagnostic.rs stdout ----
[01:38:31] diff of stderr:
[01:38:31] 
[01:38:31] 22 LL |             y.use_ref();
[01:38:31] 23    |             - immutable borrow later used here
[01:38:31] 24 
[01:38:31] - error[E0499]: cannot borrow `x` as mutable more than once at a time
[01:38:31] + warning[E0499]: cannot borrow `x` as mutable more than once at a time
[01:38:31] 27    |
[01:38:31] 28 LL |         let y = &mut x;
[01:38:31] 
[01:38:31] 33 ...
[01:38:31] 33 ...
[01:38:31] 34 LL |         y.use_mut();
[01:38:31] +    |
[01:38:31] +    = warning: this error has been downgraded to a warning for backwards compatibility with previous releases
[01:38:31] +    = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
[01:38:31] 36 
---
[01:38:31] 40 For more information about an error, try `rustc --explain E0499`.
[01:38:31] 
[01:38:31] 
[01:38:31] The actual stderr differed from the expected stderr.
[01:38:31] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-report-with-custom-diagnostic.nll/borrowck-report-with-custom-diagnostic.nll.stderr
[01:38:31] To update references, rerun the tests and pass the `--bless` flag
[01:38:31] To only update this specific test, also pass `--test-args borrowck/borrowck-report-with-custom-diagnostic.rs`
[01:38:31] error: 1 errors occurred comparing output.
[01:38:31] status: exit code: 1
[01:38:31] status: exit code: 1
[01:38:31] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-report-with-custom-diagnostic.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-Crpath" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/borrowck/borrowck-report-with-custom-diagnostic.nll/auxiliary" "-A" "unused"
[01:38:31] ------------------------------------------
[01:38:31] 
[01:38:31] ------------------------------------------
[01:38:31] stderr:
[01:38:31] stderr:
[01:38:31] ------------------------------------------
[01:38:31] {"message":"cannot borrow `x` as immutable because it is also borrowed as mutable","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    bar(a);\n    let ref y = a; // ok!\n}\n```\n\nFor more information on the rust ownership system, take a look at\nhttps://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs","byte_start":232,"byte_end":234,"line_start":8,"line_end":8,"column_start":13,"column_end":15,"is_primary":true,"text":[{"text":"    let z = &x; //~ ERROR cannot borrow","highlight_start":13,"highlight_end":15}],"label":"immutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs","byte_start":176,"byte_end":182,"line_start":6,"line_end":6,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":"    let y = &mut x;","highlight_start":13,"highlight_end":19}],"label":"mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs","byte_start":319,"byte_end":320,"line_start":11,"line_end":11,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    y.use_mut();","highlight_start":5,"highlight_end":6}],"label":"mutable borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `x` as immutable because it is also borrowed as mutable\n  --> /checkout/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs:8:13\n   |\nLL |     let y = &mut x;\n   |             ------ mutable borrow occurs here\nLL |     //~^ mutable borrow occurs here\nLL |     let z = &x; //~ ERROR cannot borrow\n   |             ^^ immutable borrow occurs here\n...\nLL |     y.use_mut();\n   |     - mutable borrow later used here\n\n"}
[01:38:31] {"message":"cannot borrow `x` as mutable because it is also borrowed as immutable","code":{"code":"E0502","explanation":"\nThis error indicates that you are trying to borrow a variable as mutable when it\nhas already been borrowed as immutable.\n\nExample of erroneous code:\n\n```compile_fail,E0502\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    let ref y = a; // a is borrowed as immutable.\n    bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed\n            //        as immutable\n}\n```\n\nTo fix this error, ensure that you don't have any other references to the\nvariable before trying to access it mutably:\n\n```\nfn bar(x: &mut i32) {}\nfn foo(a: &mut i32) {\n    bar(a);\n    let ref y = a; // ok!\n}\n```\n\nFor more information on the rust ownership system, take a look at\nhttps://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs","byte_start":554,"byte_end":560,"line_start":21,"line_end":21,"column_start":21,"column_end":27,"is_primary":true,"text":[{"text":"            let z = &mut x; //~ ERROR cannot borrow","highlight_start":21,"highlight_end":27}],"label":"mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs","byte_start":484,"byte_end":486,"line_start":19,"line_end":19,"column_start":21,"column_end":23,"is_primary":false,"text":[{"text":"            let y = &x;","highlight_start":21,"highlight_end":23}],"label":"immutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs","byte_start":667,"byte_end":668,"line_start":24,"line_end":24,"column_start":13,"column_end":14,"is_primary":false,"text":[{"text":"            y.use_ref();","highlight_start":13,"highlight_end":14}],"label":"immutable borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0502]: cannot borrow `x` as mutable because it is also borrowed as immutable\n  --> /checkout/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs:21:21\n   |\nLL |             let y = &x;\n   |                     -- immutable borrow occurs here\nLL |             //~^ immutable borrow occurs here\nLL |             let z = &mut x; //~ ERROR cannot borrow\n   |                     ^^^^^^ mutable borrow occurs here\n...\nLL |             y.use_ref();\n   |             - immutable borrow later used here\n\n"}
[01:38:31] {"message":"cannot borrow `x` as mutable more than once at a time","code":{"code":"E0499","explanation":"\nA variable was borrowed as mutable more than once. Erroneous code example:\n\n```compile_fail,E0499\nlet mut i = 0;\nlet mut x = &mut i;\nlet mut a = &mut i;\n// error: cannot borrow `i` as mutable more than once at a time\n```\n\nPlease note that in rust, you can either have many immutable references, or one\nmutable reference. Take a look at\nhttps://doc.rust-lang.org/book/ch04-02-references-and-borrowing.html for more\ninformation. Example:\n\n\n```\nlet mut i = 0;\nlet mut x = &mut i; // ok!\n\n// or:\nlet mut i = 0;\nlet a = &i; // ok!\nlet b = &i; // still ok!\nlet c = &i; // still ok!\n```\n"},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs","byte_start":824,"byte_end":830,"line_start":34,"line_end":34,"column_start":17,"column_end":23,"is_primary":false,"text":[{"text":"        let y = &mut x;","highlight_start":17,"highlight_end":23}],"label":"first mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs","byte_start":894,"byte_end":900,"line_start":36,"line_end":36,"column_start":17,"column_end":23,"is_primary":true,"text":[{"text":"        let z = &mut x; //~ ERROR cannot borrow","highlight_start":17,"highlight_end":23}],"label":"second mutable borrow occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs","byte_start":1002,"byte_end":1003,"line_start":39,"line_end":39,"column_start":9,"column_end":10,"is_primary":false,"text":[{"text":"        y.use_mut();","highlight_start":9,"highlight_end":10}],"label":"first borrow later used here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"this error has been downgraded to a warning for backwards compatibility with previous releases","code":null,"level":"warning","spans":[],"children":[],"rendered":null},{"message":"this represents potential undefined behavior in your code and this warning will become a hard error in the future","code":null,"level":"warning","spans":[],"children":[],"rendered":null}],"rendered":"warning[E0499]: cannot borrow `x` as mutable more than once at a time\n  --> /checkout/src/test/ui/borrowck/borrowck-report-with-custom-diagnostic.rs:36:17\n   |\nLL |         let y = &mut x;\n   |                 ------ first mutable borrow occurs here\nLL |         //~^ first mutable borrow occurs here\nLL |         let z = &mut x; //~ ERROR cannot borrow\n   |                 ^^^^^^ second mutable borrow occurs here\n...\nLL |         y.use_mut();\n   |         - first borrow later used here\n   |\n   = warning: this error has been downgraded to a warning for backwards compatibility with previous releases\n   = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future\n\n"}
[01:38:31] {"message":"aborting due to 2 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 2 previous errors\n\n"}
[01:38:31] {"message":"Some errors occurred: E0499, E0502.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0499, E0502.\n"}
[01:38:31] 
[01:38:31] ------------------------------------------
[01:38:31] 
[01:38:31] thread '[ui (nll)] ui/borrowck/borrowck-report-with-custom-diagnostic.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3319:9
[01:38:31] thread '[ui (nll)] ui/borrowck/borrowck-report-with-custom-diagnostic.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3319:9
[01:38:31] 
[01:38:31] ---- [ui (nll)] ui/generator/yield-in-args.rs stdout ----
[01:38:31] 
[01:38:31] error: ui test compiled successfully!
[01:38:31] status: exit code: 0
[01:38:31] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/generator/yield-in-args.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/generator/yield-in-args.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-Crpath" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/generator/yield-in-args.nll/auxiliary" "-A" "unused"
[01:38:31] ------------------------------------------
[01:38:31] 
[01:38:31] ------------------------------------------
[01:38:31] stderr:
[01:38:31] stderr:
[01:38:31] ------------------------------------------
[01:38:31] {"message":"borrow may still be in use when generator yields","code":{"code":"E0626","explanation":"\nThis error occurs because a borrow in a generator persists across a\nyield point.\n\n```compile_fail,E0626\n# #![feature(generators, generator_trait, pin)]\n# use std::ops::Generator;\n# use std::pin::Pin;\nlet mut b = || {\n    let a = &String::new(); // <-- This borrow...\n    yield (); // ...is still in scope here, when the yield occurs.\n    println!(\"{}\", a);\n};\nPin::new(&mut b).resume();\n```\n\nAt present, it is not permitted to have a yield that occurs while a\nborrow is still in scope. To resolve this error, the borrow must\neither be \"contained\" to a smaller scope that does not overlap the\nyield or else eliminated in another way. So, for example, we might\nresolve the previous example by removing the borrow and just storing\nthe integer by value:\n\n```\n# #![feature(generators, generator_trait, pin)]\n# use std::ops::Generator;\n# use std::pin::Pin;\nlet mut b = || {\n    let a = 3;\n    yield ();\n    println!(\"{}\", a);\n};\nPin::new(&mut b).resume();\n```\n\nThis is a very simple case, of course. In more complex cases, we may\nwish to have more than one reference to the value that was borrowed --\nin those cases, something like the `Rc` or `Arc` types may be useful.\n\nThis error also frequently arises with iteration:\n\n```compile_fail,E0626\n# #![feature(generators, generator_trait, pin)]\n# use std::ops::Generator;\n# use std::pin::Pin;\nlet mut b = || {\n  let v = vec![1,2,3];\n  for &x in &v { // <-- borrow of `v` is still in scope...\n    yield x; // ...when this yield occurs.\n  }\n};\nPin::new(&mut b).resume();\n```\n\nSuch cases can sometimes be resolved by iterating \"by value\" (or using\n`into_iter()`) to avoid borrowing:\n\n```\n# #![feature(generators, generator_trait, pin)]\n# use std::ops::Generator;\n# use std::pin::Pin;\nlet mut b = || {\n  let v = vec![1,2,3];\n  for x in v { // <-- Take ownership of the values instead!\n    yield x; // <-- Now yield is OK.\n  }\n};\nPin::new(&mut b).resume();\n```\n\nIf taking ownership is not an option, using indices can work too:\n\n```\n# #![feature(generators, generator_trait, pin)]\n# use std::ops::Generator;\n# use std::pin::Pin;\nlet mut b = || {\n  let v = vec![1,2,3];\n  let len = v.len(); // (*)\n  for i in 0..len {\n    let x = v[i]; // (*)\n    yield x; // <-- Now yield is OK.\n  }\n};\nPin::new(&mut b).resume();\n\n// (*) -- Unfortunately, these temporaries are currently required.\n// See <https://github.com/rust-lang/rust/issues/43122>.\n```\n"},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/generator/yield-in-args.rs","byte_start":114,"byte_end":119,"line_start":8,"line_end":8,"column_start":17,"column_end":22,"is_primary":false,"text":[{"text":"        foo(&b, yield); //~ ERROR","highlight_start":17,"highlight_end":22}],"label":"possible yield occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/generator/yield-in-args.rs","byte_start":110,"byte_end":112,"line_start":8,"line_end":8,"column_start":13,"column_end":15,"is_primary":true,"text":[{"text":"        foo(&b, yield); //~ ERROR","highlight_start":13,"highlight_end":15}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"this error has been downgraded to a warning for backwards compatibility with previous releases","code":null,"level":"warning","spans":[],"children":[],"rendered":null},{"message":"this represents potential undefined behavior in your code and this warning will become a hard error in the future","code":null,"level":"warning","spans":[],"children":[],"rendered":null}],"rendered":"warning[E0626]: borrow may still be in use when generator yields\n  --> /checkout/src/test/ui/generator/yield-in-args.rs:8:13\n   |\nLL |         foo(&b, yield); //~ ERROR\n   |             ^^  ----- possible yield occurs here\n   |\n   = warning: this error has been downgraded to a warning for backwards compatibility with previous releases\n   = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future\n\n"}
[01:38:31] ------------------------------------------
[01:38:31] 
[01:38:31] thread '[ui (nll)] ui/generator/yield-in-args.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3319:9
[01:38:31] 
[01:38:31] 
[01:38:31] ---- [ui (nll)] ui/issues/issue-27592.rs stdout ----
[01:38:31] 
[01:38:31] error: ui test compiled successfully!
[01:38:31] status: exit code: 0
[01:38:31] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issues/issue-27592.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-27592.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-Crpath" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-27592.nll/auxiliary" "-A" "unused"
[01:38:31] ------------------------------------------
[01:38:31] 
[01:38:31] ------------------------------------------
[01:38:31] stderr:
[01:38:31] stderr:
[01:38:31] ------------------------------------------
[01:38:31] {"message":"cannot return value referencing temporary value","code":{"code":"E0515","explanation":"\nCannot return value that references local variable\n\nLocal variables, function parameters and temporaries are all dropped before the\nend of the function body. So a reference to them cannot be returned.\n\n```compile_fail,E0515\n#![feature(nll)]\nfn get_dangling_reference() -> &'static i32 {\n    let x = 0;\n    &x\n}\n```\n\n```compile_fail,E0515\n#![feature(nll)]\nuse std::slice::Iter;\nfn get_dangling_iterator<'a>() -> Iter<'a, i32> {\n    let v = vec![1, 2, 3];\n    v.iter()\n}\n```\n\nConsider returning an owned value instead:\n\n```\nuse std::vec::IntoIter;\n\nfn get_integer() -> i32 {\n    let x = 0;\n    x\n}\n\nfn get_owned_iterator() -> IntoIter<i32> {\n    let v = vec![1, 2, 3];\n    v.into_iter()\n}\n```\n"},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-27592.rs","byte_start":374,"byte_end":421,"line_start":16,"line_end":16,"column_start":14,"column_end":61,"is_primary":true,"text":[{"text":"    write(|| format_args!(\"{}\", String::from(\"Hello world\")));","highlight_start":14,"highlight_end":61}],"label":"returns a value referencing data owned by the current function","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/issues/issue-27592.rs","byte_start":374,"byte_end":421,"line_start":16,"line_end":16,"column_start":14,"column_end":61,"is_primary":false,"text":[{"text":"    write(|| format_args!(\"{}\", String::from(\"Hello world\")));","highlight_start":14,"highlight_end":61}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"format_args!","def_site_span":null}},{"file_name":"/checkout/src/test/ui/issues/issue-27592.rs","byte_start":393,"byte_end":420,"line_start":16,"line_end":16,"column_start":33,"column_end":60,"is_primary":false,"text":[{"text":"    write(|| format_args!(\"{}\", String::from(\"Hello world\")));","highlight_start":33,"highlight_end":60}],"label":"temporary value created here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"this error has been downgraded to a warning for backwards compatibility with previous releases","code":null,"level":"warning","spans":[],"children":[],"rendered":null},{"message":"this represents potential undefined behavior in your code and this warning will become a hard error in the future","code":null,"level":"warning","spans":[],"children":[],"rendered":null}],"rendered":"warning[E0515]: cannot return value referencing temporary value\n  --> /checkout/src/test/ui/issues/issue-27592.rs:16:14\n   |\nLL |     write(|| format_args!(\"{}\", String::from(\"Hello world\")));\n   |              ^^^^^^^^^^^^^^^^^^^---------------------------^\n   |              |                  |\n   |              |                  temporary value created here\n   |              returns a value referencing data owned by the current function\n   |\n   = warning: this error has been downgraded to a warning for backwards compatibility with previous releases\n   = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future\n\n"}
[01:38:31] {"message":"cannot return value referencing temporary value","code":{"code":"E0515","explanation":"\nCannot return value that references local variable\n\nLocal variables, function parameters and temporaries are all dropped before the\nend of the function body. So a reference to them cannot be returned.\n\n```compile_fail,E0515\n#![feature(nll)]\nfn get_dangling_reference() -> &'static i32 {\n    let x = 0;\n    &x\n}\n```\n\n```compile_fail,E0515\n#![feature(nll)]\nuse std::slice::Iter;\nfn get_dangling_iterator<'a>() -> Iter<'a, i32> {\n    let v = vec![1, 2, 3];\n    v.iter()\n}\n```\n\nConsider returning an owned value instead:\n\n```\nuse std::vec::IntoIter;\n\nfn get_integer() -> i32 {\n    let x = 0;\n    x\n}\n\nfn get_owned_iterator() -> IntoIter<i32> {\n    let v = vec![1, 2, 3];\n    v.into_iter()\n}\n```\n"},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-27592.rs","byte_start":374,"byte_end":421,"line_start":16,"line_end":16,"column_start":14,"column_end":61,"is_primary":true,"text":[{"text":"    write(|| format_args!(\"{}\", String::from(\"Hello world\")));","highlight_start":14,"highlight_end":61}],"label":"returns a value referencing data owned by the current function","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/issues/issue-27592.rs","byte_start":374,"byte_end":421,"line_start":16,"line_end":16,"column_start":14,"column_end":61,"is_primary":false,"text":[{"text":"    write(|| format_args!(\"{}\", String::from(\"Hello world\")));","highlight_start":14,"highlight_end":61}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"format_args!","def_site_span":null}},{"file_name":"/checkout/src/test/ui/issues/issue-27592.rs","byte_start":387,"byte_end":391,"line_start":16,"line_end":16,"column_start":27,"column_end":31,"is_primary":false,"text":[{"text":"    write(|| format_args!(\"{}\", String::from(\"Hello world\")));","highlight_start":27,"highlight_end":31}],"label":"temporary value created here","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/issues/issue-27592.rs","byte_start":374,"byte_end":421,"line_start":16,"line_end":16,"column_start":14,"column_end":61,"is_primary":false,"text":[{"text":"    write(|| format_args!(\"{}\", String::from(\"Hello world\")));","highlight_start":14,"highlight_end":61}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"format_args!","def_site_span":null}}],"children":[{"message":"this error has been downgraded to a warning for backwards compatibility with previous releases","code":null,"level":"warning","spans":[],"children":[],"rendered":null},{"message":"this represents potential undefined behavior in your code and this warning will become a hard error in the future","code":null,"level":"warning","spans":[],"children":[],"rendered":null}],"rendered":"warning[E0515]: cannot return value referencing temporary value\n  --> /checkout/src/test/ui/issues/issue-27592.rs:16:14\n   |\nLL |     write(|| format_args!(\"{}\", String::from(\"Hello world\")));\n   |              ^^^^^^^^^^^^^----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |              |            |\n   |              |            temporary value created here\n   |              returns a value referencing data owned by the current function\n   |\n   = warning: this error has been downgraded to a warning for backwards compatibility with previous releases\n   = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future\n\n"}
[01:38:31] ------------------------------------------
[01:38:31] 
[01:38:31] thread '[ui (nll)] ui/issues/issue-27592.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3319:9
[01:38:31] 
[01:38:31] 
[01:38:31] ---- [ui (nll)] ui/nll/issue-55850.rs stdout ----
[01:38:31] 
[01:38:31] error: ui test compiled successfully!
[01:38:31] status: exit code: 0
[01:38:31] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/nll/issue-55850.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/issue-55850.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-Crpath" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/issue-55850.nll/auxiliary" "-A" "unused"
[01:38:31] ------------------------------------------
[01:38:31] 
[01:38:31] ------------------------------------------
[01:38:31] stderr:
[01:38:31] stderr:
[01:38:31] ------------------------------------------
[01:38:31] {"message":"`s` does not live long enough","code":{"code":"E0597","explanation":"\nThis error occurs because a borrow was made inside a variable which has a\ngreater lifetime than the borrowed one.\n\nExample of erroneous code:\n\n```compile_fail,E0597\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet mut x = Foo { x: None };\nlet y = 0;\nx.x = Some(&y); // error: `y` does not live long enough\n```\n\nIn here, `x` is created before `y` and therefore has a greater lifetime. Always\nkeep in mind that values in a scope are dropped in the opposite order they are\ncreated. So to fix the previous example, just make the `y` lifetime greater than\nthe `x`'s one:\n\n```\nstruct Foo<'a> {\n    x: Option<&'a u32>,\n}\n\nlet y = 0;\nlet mut x = Foo { x: None };\nx.x = Some(&y);\n```\n"},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/nll/issue-55850.rs","byte_start":583,"byte_end":584,"line_start":28,"line_end":28,"column_start":16,"column_end":17,"is_primary":true,"text":[{"text":"        yield &s[..] //~ ERROR `s` does not live long enough [E0597]","highlight_start":16,"highlight_end":17}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/issue-55850.rs","byte_start":641,"byte_end":642,"line_start":29,"line_end":29,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    })","highlight_start":5,"highlight_end":6}],"label":"`s` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"this error has been downgraded to a warning for backwards compatibility with previous releases","code":null,"level":"warning","spans":[],"children":[],"rendered":null},{"message":"this represents potential undefined behavior in your code and this warning will become a hard error in the future","code":null,"level":"warning","spans":[],"children":[],"rendered":null}],"rendered":"warning[E0597]: `s` does not live long enough\n  --> /checkout/src/test/ui/nll/issue-55850.rs:28:16\n   |\nLL |         yield &s[..] //~ ERROR `s` does not live long enough [E0597]\n   |                ^ borrowed value does not live long enough\nLL |     })\n   |     - `s` dropped here while still borrowed\n   |\n   = warning: this error has been downgraded to a warning for backwards compatibility with previous releases\n   = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future\n\n"}
[01:38:31] {"message":"borrow may still be in use when generator yields","code":{"code":"E0626","explanation":"\nThis error occurs because a borrow in a generator persists across a\nyield point.\n\n```compile_fail,E0626\n# #![feature(generators, generator_trait, pin)]\n# use std::ops::Generator;\n# use std::pin::Pin;\nlet mut b = || {\n    let a = &String::new(); // <-- This borrow...\n    yield (); // ...is still in scope here, when the yield occurs.\n    println!(\"{}\", a);\n};\nPin::new(&mut b).resume();\n```\n\nAt present, it is not permitted to have a yield that occurs while a\nborrow is still in scope. To resolve this error, the borrow must\neither be \"contained\" to a smaller scope that does not overlap the\nyield or else eliminated in another way. So, for example, we might\nresolve the previous example by removing the borrow and just storing\nthe integer by value:\n\n```\n# #![feature(generators, generator_trait, pin)]\n# use std::ops::Generator;\n# use std::pin::Pin;\nlet mut b = || {\n    let a = 3;\n    yield ();\n    println!(\"{}\", a);\n};\nPin::new(&mut b).resume();\n```\n\nThis is a very simple case, of course. In more complex cases, we may\nwish to have more than one reference to the value that was borrowed --\nin those cases, something like the `Rc` or `Arc` types may be useful.\n\nThis error also frequently arises with iteration:\n\n```compile_fail,E0626\n# #![feature(generators, generator_trait, pin)]\n# use std::ops::Generator;\n# use std::pin::Pin;\nlet mut b = || {\n  let v = vec![1,2,3];\n  for &x in &v { // <-- borrow of `v` is still in scope...\n    yield x; // ...when this yield occurs.\n  }\n};\nPin::new(&mut b).resume();\n```\n\nSuch cases can sometimes be resolved by iterating \"by value\" (or using\n`into_iter()`) to avoid borrowing:\n\n```\n# #![feature(generators, generator_trait, pin)]\n# use std::ops::Generator;\n# use std::pin::Pin;\nlet mut b = || {\n  let v = vec![1,2,3];\n  for x in v { // <-- Take ownership of the values instead!\n    yield x; // <-- Now yield is OK.\n  }\n};\nPin::new(&mut b).resume();\n```\n\nIf taking ownership is not an option, using indices can work too:\n\n```\n# #![feature(generators, generator_trait, pin)]\n# use std::ops::Generator;\n# use std::pin::Pin;\nlet mut b = || {\n  let v = vec![1,2,3];\n  let len = v.len(); // (*)\n  for i in 0..len {\n    let x = v[i]; // (*)\n    yield x; // <-- Now yield is OK.\n  }\n};\nPin::new(&mut b).resume();\n\n// (*) -- Unfortunately, these temporaries are currently required.\n// See <https://github.com/rust-lang/rust/issues/43122>.\n```\n"},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/nll/issue-55850.rs","byte_start":576,"byte_end":588,"line_start":28,"line_end":28,"column_start":9,"column_end":21,"is_primary":false,"text":[{"text":"        yield &s[..] //~ ERROR `s` does not live long enough [E0597]","highlight_start":9,"highlight_end":21}],"label":"possible yield occurs here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/issue-55850.rs","byte_start":583,"byte_end":584,"line_start":28,"line_end":28,"column_start":16,"column_end":17,"is_primary":true,"text":[{"text":"        yield &s[..] //~ ERROR `s` does not live long enough [E0597]","highlight_start":16,"highlight_end":17}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"this error has been downgraded to a warning for backwards compatibility with previous releases","code":null,"level":"warning","spans":[],"children":[],"rendered":null},{"message":"this represents potential undefined behavior in your code and this warning will become a hard error in the future","code":null,"level":"warning","spans":[],"children":[],"rendered":null}],"rendered":"warning[E0626]: borrow may still be in use when generator yields\n  --> /checkout/src/test/ui/nll/issue-55850.rs:28:16\n   |\nLL |         yield &s[..] //~ ERROR `s` does not live long enough [E0597]\n   |         -------^---- possible yield occurs here\n   |\n   = warning: this error has been downgraded to a warning for backwards compatibility with previous releases\n   = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future\n\n"}
[01:38:31] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:496:22
[01:38:31] make: *** [check] Error 1
[01:38:31] ------------------------------------------
[01:38:31] 
[01:38:31] thread '[ui (nll)] ui/nll/issue-55850.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3319:9
[01:38:31] 
[01:38:31] 
[01:38:31] ---- [ui (nll)] ui/regions/regions-ref-in-fn-arg.rs stdout ----
[01:38:31] diff of stderr:
[01:38:31] 
[01:38:31] 6 LL |     x //~^ ERROR borrowed value does not live long enough
[01:38:31] 7    |     ^ returns a value referencing data owned by the current function
[01:38:31] - error[E0515]: cannot return value referencing function parameter
[01:38:31] - error[E0515]: cannot return value referencing function parameter
[01:38:31] + warning[E0515]: cannot return value referencing function parameter
[01:38:31] 11    |
[01:38:31] 11    |
[01:38:31] 12 LL |     with(|box ref x| x) //~ ERROR borrowed value does not live long enough
[01:38:31] 
[01:38:31] 13    |           ---------  ^ returns a value referencing data owned by the current function
[01:38:31] 15    |           function parameter borrowed here
[01:38:31] +    |
[01:38:31] +    = warning: this error has been downgraded to a warning for backwards compatibility with previous releases
[01:38:31] +    = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future
---
[01:38:31] 20 
[01:38:31] 
[01:38:31] 
[01:38:31] The actual stderr differed from the expected stderr.
[01:38:31] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/regions-ref-in-fn-arg.nll/regions-ref-in-fn-arg.nll.stderr
[01:38:31] To update references, rerun the tests and pass the `--bless` flag
[01:38:31] To only update this specific test, also pass `--test-args regions/regions-ref-in-fn-arg.rs`
[01:38:31] error: 1 errors occurred comparing output.
[01:38:31] status: exit code: 1
[01:38:31] status: exit code: 1
[01:38:31] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/regions/regions-ref-in-fn-arg.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/regions-ref-in-fn-arg.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-Crpath" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/regions/regions-ref-in-fn-arg.nll/auxiliary" "-A" "unused"
[01:38:31] ------------------------------------------
[01:38:31] 
[01:38:31] ------------------------------------------
[01:38:31] stderr:
[01:38:31] stderr:
[01:38:31] ------------------------------------------
[01:38:31] {"message":"cannot return value referencing function parameter","code":{"code":"E0515","explanation":"\nCannot return value that references local variable\n\nLocal variables, function parameters and temporaries are all dropped before the\nend of the function body. So a reference to them cannot be returned.\n\n```compile_fail,E0515\n#![feature(nll)]\nfn get_dangling_reference() -> &'static i32 {\n    let x = 0;\n    &x\n}\n```\n\n```compile_fail,E0515\n#![feature(nll)]\nuse std::slice::Iter;\nfn get_dangling_iterator<'a>() -> Iter<'a, i32> {\n    let v = vec![1, 2, 3];\n    v.iter()\n}\n```\n\nConsider returning an owned value instead:\n\n```\nuse std::vec::IntoIter;\n\nfn get_integer() -> i32 {\n    let x = 0;\n    x\n}\n\nfn get_owned_iterator() -> IntoIter<i32> {\n    let v = vec![1, 2, 3];\n    v.into_iter()\n}\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/regions/regions-ref-in-fn-arg.rs","byte_start":110,"byte_end":111,"line_start":5,"line_end":5,"column_start":5,"column_end":6,"is_primary":true,"text":[{"text":"    x //~^ ERROR borrowed value does not live long enough","highlight_start":5,"highlight_end":6}],"label":"returns a value referencing data owned by the current function","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/regions/regions-ref-in-fn-arg.rs","byte_start":63,"byte_end":72,"line_start":4,"line_end":4,"column_start":13,"column_end":22,"is_primary":false,"text":[{"text":"fn arg_item(box ref x: Box<isize>) -> &'static isize {","highlight_start":13,"highlight_end":22}],"label":"function parameter borrowed here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0515]: cannot return value referencing function parameter\n  --> /checkout/src/test/ui/regions/regions-ref-in-fn-arg.rs:5:5\n   |\nLL | fn arg_item(box ref x: Box<isize>) -> &'static isize {\n   |             --------- function parameter borrowed here\nLL |     x //~^ ERROR borrowed value does not live long enough\n   |     ^ returns a value referencing data owned by the current function\n\n"}
[01:38:31] {"message":"cannot return value referencing function parameter","code":{"code":"E0515","explanation":"\nCannot return value that references local variable\n\nLocal variables, function parameters and temporaries are all dropped before the\nend of the function body. So a reference to them cannot be returned.\n\n```compile_fail,E0515\n#![feature(nll)]\nfn get_dangling_reference() -> &'static i32 {\n    let x = 0;\n    &x\n}\n```\n\n```compile_fail,E0515\n#![feature(nll)]\nuse std::slice::Iter;\nfn get_dangling_iterator<'a>() -> Iter<'a, i32> {\n    let v = vec![1, 2, 3];\n    v.iter()\n}\n```\n\nConsider returning an owned value instead:\n\n```\nuse std::vec::IntoIter;\n\nfn get_integer() -> i32 {\n    let x = 0;\n    x\n}\n\nfn get_owned_iterator() -> IntoIter<i32> {\n    let v = vec![1, 2, 3];\n    v.into_iter()\n}\n```\n"},"level":"warning","spans":[{"file_name":"/checkout/src/test/ui/regions/regions-ref-in-fn-arg.rs","byte_start":297,"byte_end":298,"line_start":11,"line_end":11,"column_start":22,"column_end":23,"is_primary":true,"text":[{"text":"    with(|box ref x| x) //~ ERROR borrowed value does not live long enough","highlight_start":22,"highlight_end":23}],"label":"returns a value referencing data owned by the current function","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/regions/regions-ref-in-fn-arg.rs","byte_start":286,"byte_end":295,"line_start":11,"line_end":11,"column_start":11,"column_end":20,"is_primary":false,"text":[{"text":"    with(|box ref x| x) //~ ERROR borrowed value does not live long enough","highlight_start":11,"highlight_end":20}],"label":"function parameter borrowed here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"this error has been downgraded to a warning for backwards compatibility with previous releases","code":null,"level":"warning","spans":[],"children":[],"rendered":null},{"message":"this represents potential undefined behavior in your code and this warning will become a hard error in the future","code":null,"level":"warning","spans":[],"children":[],"rendered":null}],"rendered":"warning[E0515]: cannot return value referencing function parameter\n  --> /checkout/src/test/ui/regions/regions-ref-in-fn-arg.rs:11:22\n   |\nLL |     with(|box ref x| x) //~ ERROR borrowed value does not live long enough\n   |           ---------  ^ returns a value referencing data owned by the current function\n   |           |\n   |           function parameter borrowed here\n   |\n   = warning: this error has been downgraded to a warning for backwards compatibility with previous releases\n   = warning: this represents potential undefined behavior in your code and this warning will become a hard error in the future\n\n"}
[01:38:31] {"message":"For more information about this error, try `rustc --explain E0515`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0515`.\n"}
[01:38:31] 
[01:38:31] ------------------------------------------
[01:38:31] 
---
[01:38:31] test result: FAILED. 5354 passed; 7 failed; 90 ignored; 0 measured; 0 filtered out
[01:38:31] 
[01:38:31] 
[01:38:31] 
[01:38:31] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--host-rustcflags" "-Crpath -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--llvm-version" "8.0.0\n" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always" "--compare-mode" "nll"
[01:38:31] 
[01:38:31] 
[01:38:31] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:38:31] Build completed unsuccessfully in 0:08:02
---
travis_time:end:1a7535b0:start=1552233424157945139,finish=1552233424166115027,duration=8169888
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0338f548
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:06f73617
travis_time:start:06f73617
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:00dd05ec
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@Centril Centril closed this Mar 10, 2019
@Centril Centril deleted the rollup branch March 10, 2019 16:07
@Centril Centril added the rollup A PR which is a rollup label Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.