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

Update `vec!` to have the same coercion behavior as arrays #58377

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
6 participants
@LukasKalbertodt
Copy link
Contributor

LukasKalbertodt commented Feb 11, 2019

Before this commit, vec![a, b, c] had different coercion behavior than the
array [a, b, c]. Example:

fn foo() {}
fn bar() {}

let arr = [foo, bar];    // works, fn items coerced to fn pointer
let v = vec![foo, bar];  // doesn't work

Last line results in:

error[E0308]: mismatched types
 --> src/main.rs:6:13
  |
6 |     let v = vec![foo, bar];  // doesn't work
  |             ^^^^^^^^^^^^^^ expected slice, found array of 2 elements
  |
  = note: expected type `std::boxed::Box<[fn() {main::foo}]>`
             found type `std::boxed::Box<[fn(); 2]>`

This is due to box [a, b, c] behaving a bit strangely. A very related
question on StackOverflow: https://stackoverflow.com/q/54632524/2408867

By introducing this temporary let binding, we can fix the coercion
behavior. I'm pretty sure this is not a breaking change as it only
allows more cases to compile.


Another very related question on SO: https://stackoverflow.com/questions/28151073/how-can-i-store-function-pointers-in-an-array

I have to admit that I created this PR only with the GitHub web editor and didn't test anything (CI will notice mistakes, right?). If you think I should extend this PR, just let me know!

@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

rust-highfive commented Feb 11, 2019

r? @joshtriplett

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Feb 11, 2019

The job x86_64-gnu-llvm-6.0 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.
travis_time:end:04c4ef9c:start=1549898362386517985,finish=1549898363353221000,duration=966703015
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
[00:06:21]    Compiling rustc-demangle v0.1.10
[00:06:22] error[E0412]: cannot find type `Box` in this scope
[00:06:22]    --> src/liballoc/macros.rs:44:43
[00:06:22]     |
[00:06:22] 44  |         $crate::vec::Vec::from(box tmp as Box<[_]>)
[00:06:22]     | 
[00:06:22]    ::: src/liballoc/collections/binary_heap.rs:317:28
[00:06:22]     |
[00:06:22]     |
[00:06:22] 317 |         BinaryHeap { data: vec![] }
[00:06:22] help: possible candidate is found in another module, you can import it into scope
[00:06:22]     |
[00:06:22] 148 | use crate::boxed::Box;
[00:06:22]     |
---
[00:06:24] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "--message-format" "json"
[00:06:24] expected success, got: exit code: 101
[00:06:24] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap build
[00:06:24] Build completed unsuccessfully in 0:00:35
[00:06:24] make: *** [all] Error 1
[00:06:24] Makefile:18: recipe for target 'all' failed
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0d4031a8
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Mon Feb 11 15:25:59 UTC 2019
---
travis_time:end:1522bd5c:start=1549898760024050636,finish=1549898760028410234,duration=4359598
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:081dfcc2
$ 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:058d246a
travis_time:start:058d246a
$ 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:09368430
$ 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

This comment has been minimized.

Copy link
Contributor

Centril commented Feb 11, 2019

Show resolved Hide resolved src/liballoc/macros.rs
Update `vec!` to have the same coercion behavior as arrays
Before this commit, `vec![a, b, c]` had different coercion behavior than the
array `[a, b, c]`. Example:

    fn foo() {}
    fn bar() {}

    let arr = [foo, bar];    // works, fn items coerced to fn pointer
    let v = vec![foo, bar];  // doesn't work

Last line results in:

    error[E0308]: mismatched types
     --> src/main.rs:6:13
      |
    6 |     let v = vec![foo, bar];  // doesn't work
      |             ^^^^^^^^^^^^^^ expected slice, found array of 2 elements
      |
      = note: expected type `std::boxed::Box<[fn() {main::foo}]>`
                 found type `std::boxed::Box<[fn(); 2]>`

This is due to `box [a, b, c]` behaving a bit strangely. A very related
question on StackOverflow: https://stackoverflow.com/q/54632524/2408867

By introducing this temporary let binding, we can fix the coercion
behavior. I'm pretty sure this is not a breaking change as it only
allows more cases to compile.

@LukasKalbertodt LukasKalbertodt force-pushed the LukasKalbertodt:patch-1 branch from 74f231f to 9542188 Feb 11, 2019

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Feb 11, 2019

The job x86_64-gnu-llvm-6.0 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.
travis_time:end:14a9ff40:start=1549901434972085562,finish=1549901435875962789,duration=903877227
$ git checkout -qf FETCH_HEAD
travis_fold:end:git.checkout

Encrypted environment variables have been removed for security reasons.
See https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions
$ export SCCACHE_BUCKET=rust-lang-ci-sccache2
$ export SCCACHE_REGION=us-west-1
Setting environment variables from .travis.yml
$ export IMAGE=x86_64-gnu-llvm-6.0
---
[01:02:17] .................................................................................................... 200/5380
[01:02:20] .................................................................................................... 300/5380
[01:02:23] .................................................................................................... 400/5380
[01:02:26] .................................................................................................... 500/5380
[01:02:30] ..............................i.....F............................................................... 600/5380
[01:02:38] .................................................................................................... 800/5380
[01:02:43] .................................................................................i...............i.. 900/5380
[01:02:47] .................................................................................................... 1000/5380
[01:02:47] .................................................................................................... 1000/5380
[01:02:50] ........iiiii.....................................................................................F. 1100/5380
[01:02:55] .................................................................................................... 1300/5380
[01:02:58] .................................................................................................... 1400/5380
[01:03:01] .................................................................................................... 1500/5380
[01:03:04] .................................................................................................... 1600/5380
[01:03:04] .................................................................................................... 1600/5380
[01:03:07] .i..........................................................................i....................... 1700/5380
[01:03:10] .................................................................................................... 1800/5380
[01:03:14] .................................................................................................... 1900/5380
[01:03:17] .................................................................................................... 2000/5380
[01:03:21] ................................i................................................................... 2100/5380
[01:03:25] .................................................................................................... 2200/5380
[01:03:29] .................................................................................F.................. 2300/5380
[01:03:37] .................................................................................................... 2500/5380
[01:03:40] .................................................................................................... 2600/5380
[01:03:44] .................................................................................................... 2700/5380
[01:03:44] .................................................................................................... 2700/5380
[01:03:49] ....................................................................F............................... 2800/5380
[01:03:56] .................................................................................................... 3000/5380
[01:03:59] .................................................................................................... 3100/5380
[01:04:03] .................................................................................................... 3200/5380
[01:04:07] ................................i................................................................... 3300/5380
[01:04:07] ................................i................................................................... 3300/5380
[01:04:11] .................................................................................................... 3400/5380
[01:04:14] .ii...i..ii......................................................................................... 3500/5380
[01:04:18] .................................................................................................... 3600/5380
[01:04:21] ....................................................................F..............................i 3700/5380
[01:04:26] .................i.................................................................................. 3900/5380
[01:04:28] ..........................................................................i......................... 4000/5380
[01:04:30] .................................................................................................... 4100/5380
[01:04:37] .................................................................................................... 4200/5380
[01:04:37] .................................................................................................... 4200/5380
[01:04:45] .................................................................................................... 4300/5380
[01:04:48] .................................................................................................... 4400/5380
[01:04:51] .................................................................................................... 4500/5380
[01:04:56] ..............................i..................................................................... 4600/5380
[01:05:01] .................................................................................................... 4700/5380
[01:05:05] ....................................F............................................................... 4800/5380
[01:05:12] .................................................................................................... 5000/5380
[01:05:12] .................................................................................................... 5000/5380
[01:05:16] ..........................................................F.F....................................... 5100/5380
[01:05:21] .................................................................................................... 5300/5380
[01:05:24] ...................i............................................................
[01:05:24] failures:
[01:05:24] 
[01:05:24] 
[01:05:24] ---- [ui] ui/coercion/coerce-expect-unsized-ascribed.rs stdout ----
[01:05:24] diff of stderr:
[01:05:24] 
[01:05:24] 124    = note: expected type `std::boxed::Box<dyn std::ops::Fn(i32) -> _>`
[01:05:24] 125               found type `std::boxed::Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:26:22: 26:35]>`
[01:05:24] - error: aborting due to 14 previous errors
[01:05:24] + error[E0308]: mismatched types
[01:05:24] +   --> $DIR/coerce-expect-unsized-ascribed.rs:30:9
[01:05:24] +    |
[01:05:24] +    |
[01:05:24] + LL |         box |x| (x as i16 as u8),
[01:05:24] +    |         ^^^^^^^^^^^^^^^^^^^^^^^^ expected closure, found a different closure
[01:05:24] +    |
[01:05:24] +    = note: expected type `std::boxed::Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:29:18: 29:31]>`
[01:05:24] +               found type `std::boxed::Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:30:13: 30:33]>`
[01:05:24] +    = note: no two closures, even if identical, have the same type
[01:05:24] +    = help: consider boxing your closure and/or using it as a trait object
[01:05:24] - For more information about this error, try `rustc --explain E0308`.
[01:05:24] - For more information about this error, try `rustc --explain E0308`.
[01:05:24] + error[E0277]: the size for values of type `[std::boxed::Box<dyn std::ops::Fn(i32) -> _>]` cannot be known at compilation time
[01:05:24] +   --> $DIR/coerce-expect-unsized-ascribed.rs:28:13
[01:05:24] + LL |       let _ = vec![
[01:05:24] +    |  _____________^
[01:05:24] +    |  _____________^
[01:05:24] + LL | |         Box::new(|x| (x as u8)),
[01:05:24] + LL | |         box |x| (x as i16 as u8),
[01:05:24] + LL | |     ]: Vec<Box<Fn(i32) -> _>>;
[01:05:24] +    | |_____^ doesn't have a size known at compile-time
[01:05:24] +    |
[01:05:24] +    = help: the trait `std::marker::Sized` is not implemented for `[std::boxed::Box<dyn std::ops::Fn(i32) -> _>]`
[01:05:24] +    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
[01:05:24] +    = help: unsized locals are gated as an unstable feature
[01:05:24] +    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[01:05:24] + 
[01:05:24] + error: aborting due to 16 previous errors
[01:05:24] + error: aborting due to 16 previous errors
[01:05:24] + 
[01:05:24] + Some errors occurred: E0277, E0308.
[01:05:24] + For more information about an error, try `rustc --explain E0277`.
[01:05:24] 130 
[01:05:24] 
[01:05:24] 
[01:05:24] The actual stderr differed from the expected stderr.
[01:05:24] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/coercion/coerce-expect-unsized-ascribed/coerce-expect-unsized-ascribed.stderr
[01:05:24] To update references, rerun the tests and pass the `--bless` flag
[01:05:24] To only update this specific test, also pass `--test-args coercion/coerce-expect-unsized-ascribed.rs`
[01:05:24] error: 1 errors occurred comparing output.
[01:05:24] status: exit code: 1
[01:05:24] status: exit code: 1
[01:05:24] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.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/coercion/coerce-expect-unsized-ascribed/a" "-Crpath" "-O" "-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/coercion/coerce-expect-unsized-ascribed/auxiliary" "-A" "unused"
[01:05:24] ------------------------------------------
[01:05:24] 
[01:05:24] ------------------------------------------
[01:05:24] stderr:
[01:05:24] stderr:
[01:05:24] ------------------------------------------
[01:05:24] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expression, and the actual type explicitly assigned to the\nvariable.\n\nFor example:\n\n```compile_fail,E0308\nlet x: i32 = \"I am not a number!\";\n//     ~~~   ~~~~~~~~~~~~~~~~~~~~\n//      |             |\n//      |    initializing expression;\n//      |    compiler infers type `&str`\n//      |\n//    type `i32` assigned to variable `x`\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs","byte_start":214,"byte_end":231,"line_start":9,"line_end":9,"column_start":13,"column_end":30,"is_primary":true,"text":[{"text":"    let _ = box { [1, 2, 3] }: Box<[i32]>; //~ ERROR mismatched types","highlight_start":13,"highlight_end":30}],"label":"expected slice, found array of 3 elements","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::boxed::Box<[i32]>`\n   found type `std::boxed::Box<[i32; 3]>`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> /checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:9:13\n   |\nLL |     let _ = box { [1, 2, 3] }: Box<[i32]>; //~ ERROR mismatched types\n   |             ^^^^^^^^^^^^^^^^^ expected slice, found array of 3 elements\n   |\n   = note: expected type `std::boxed::Box<[i32]>`\n              found type `std::boxed::Box<[i32; 3]>`\n\n"}
[01:05:24] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expression, and the actual type explicitly assigned to the\nvariable.\n\nFor example:\n\n```compile_fail,E0308\nlet x: i32 = \"I am not a number!\";\n//     ~~~   ~~~~~~~~~~~~~~~~~~~~\n//      |             |\n//      |    initializing expression;\n//      |    compiler infers type `&str`\n//      |\n//    type `i32` assigned to variable `x`\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs","byte_start":284,"byte_end":328,"line_start":10,"line_end":10,"column_start":13,"column_end":57,"is_primary":true,"text":[{"text":"    let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[i32]>; //~ ERROR mismatched types","highlight_start":13,"highlight_end":57}],"label":"expected slice, found array of 3 elements","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::boxed::Box<[i32]>`\n   found type `std::boxed::Box<[i32; 3]>`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> /checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:10:13\n   |\nLL |     let _ = box if true { [1, 2, 3] } else { [1, 3, 4] }: Box<[i32]>; //~ ERROR mismatched types\n   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice, found array of 3 elements\n   |\n   = note: expected type `std::boxed::Box<[i32]>`\n              found type `std::boxed::Box<[i32; 3]>`\n\n"}
[01:05:24] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expression, and the actual type explicitly assigned to the\nvariable.\n\nFor example:\n\n```compile_fail,E0308\nlet x: i32 = \"I am not a number!\";\n//     ~~~   ~~~~~~~~~~~~~~~~~~~~\n//      |             |\n//      |    initializing expression;\n//      |    compiler infers type `&str`\n//      |\n//    type `i32` assigned to variable `x`\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs","byte_start":381,"byte_end":437,"line_start":11,"line_end":11,"column_start":13,"column_end":69,"is_primary":true,"text":[{"text":"    let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[i32]>;","highlight_start":13,"highlight_end":69}],"label":"expected slice, found array of 3 elements","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::boxed::Box<[i32]>`\n   found type `std::boxed::Box<[i32; 3]>`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> /checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:11:13\n   |\nLL |     let _ = box match true { true => [1, 2, 3], false => [1, 3, 4] }: Box<[i32]>;\n   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice, found array of 3 elements\n   |\n   = note: expected type `std::boxed::Box<[i32]>`\n              found type `std::boxed::Box<[i32; 3]>`\n\n"}
[01:05:24] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expression, and the actual type explicitly assigned to the\nvariable.\n\nFor example:\n\n```compile_fail,E0308\nlet x: i32 = \"I am not a number!\";\n//     ~~~   ~~~~~~~~~~~~~~~~~~~~\n//      |             |\n//      |    initializing expression;\n//      |    compiler infers type `&str`\n//      |\n//    type `i32` assigned to variable `x`\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs","byte_start":495,"byte_end":516,"line_start":13,"line_end":13,"column_start":13,"column_end":34,"is_primary":true,"text":[{"text":"    let _ = box { |x| (x as u8) }: Box<Fn(i32) -> _>; //~ ERROR mismatched types","highlight_start":13,"highlight_end":34}],"label":"expected trait std::ops::Fn, found closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::boxed::Box<dyn std::ops::Fn(i32) -> u8>`\n   found type `std::boxed::Box<[closure@/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:13:19: 13:32]>`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> /checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:13:13\n   |\nLL |     let _ = box { |x| (x as u8) }: Box<Fn(i32) -> _>; //~ ERROR mismatched types\n   |             ^^^^^^^^^^^^^^^^^^^^^ expected trait std::ops::Fn, found closure\n   |\n   = note: expected type `std::boxed::Box<dyn std::ops::Fn(i32) -> u8>`\n              found type `std::boxed::Box<[closure@/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:13:19: 13:32]>`\n\n"}
[01:05:24] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expression, and the actual type explicitly assigned to the\nvariable.\n\nFor example:\n\n```compile_fail,E0308\nlet x: i32 = \"I am not a number!\";\n//     ~~~   ~~~~~~~~~~~~~~~~~~~~\n//      |             |\n//      |    initializing expression;\n//      |    compiler infers type `&str`\n//      |\n//    type `i32` assigned to variable `x`\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs","byte_start":576,"byte_end":611,"line_start":14,"line_end":14,"column_start":13,"column_end":48,"is_primary":true,"text":[{"text":"    let _ = box if true { false } else { true }: Box<Debug>; //~ ERROR mismatched types","highlight_start":13,"highlight_end":48}],"label":"expected trait std::fmt::Debug, found bool","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::boxed::Box<dyn std::fmt::Debug>`\n   found type `std::boxed::Box<bool>`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> /checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:14:13\n   |\nLL |     let _ = box if true { false } else { true }: Box<Debug>; //~ ERROR mismatched types\n   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found bool\n   |\n   = note: expected type `std::boxed::Box<dyn std::fmt::Debug>`\n              found type `std::boxed::Box<bool>`\n\n"}
[01:05:24] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expression, and the actual type explicitly assigned to the\nvariable.\n\nFor example:\n\n```compile_fail,E0308\nlet x: i32 = \"I am not a number!\";\n//     ~~~   ~~~~~~~~~~~~~~~~~~~~\n//      |             |\n//      |    initializing expression;\n//      |    compiler infers type `&str`\n//      |\n//    type `i32` assigned to variable `x`\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs","byte_start":664,"byte_end":708,"line_start":15,"line_end":15,"column_start":13,"column_end":57,"is_primary":true,"text":[{"text":"    let _ = box match true { true => 'a', false => 'b' }: Box<Debug>; //~ ERROR mismatched types","highlight_start":13,"highlight_end":57}],"label":"expected trait std::fmt::Debug, found char","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::boxed::Box<dyn std::fmt::Debug>`\n   found type `std::boxed::Box<char>`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> /checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:15:13\n   |\nLL |     let _ = box match true { true => 'a', false => 'b' }: Box<Debug>; //~ ERROR mismatched types\n   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found char\n   |\n   = note: expected type `std::boxed::Box<dyn std::fmt::Debug>`\n              found type `std::boxed::Box<char>`\n\n"}
[01:05:24] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expression, and the actual type explicitly assigned to the\nvariable.\n\nFor example:\n\n```compile_fail,E0308\nlet x: i32 = \"I am not a number!\";\n//     ~~~   ~~~~~~~~~~~~~~~~~~~~\n//      |             |\n//      |    initializing expression;\n//      |    compiler infers type `&str`\n//      |\n//    type `i32` assigned to variable `x`\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs","byte_start":762,"byte_end":776,"line_start":17,"line_end":17,"column_start":13,"column_end":27,"is_primary":true,"text":[{"text":"    let _ = &{ [1, 2, 3] }: &[i32]; //~ ERROR mismatched types","highlight_start":13,"highlight_end":27}],"label":"expected slice, found array of 3 elements","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `&[i32]`\n   found type `&[i32; 3]`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> /checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:17:13\n   |\nLL |     let _ = &{ [1, 2, 3] }: &[i32]; //~ ERROR mismatched types\n   |             ^^^^^^^^^^^^^^ expected slice, found array of 3 elements\n   |\n   = note: expected type `&[i32]`\n              found type `&[i32; 3]`\n\n"}
[01:05:24] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expression, and the actual type explicitly assigned to the\nvariable.\n\nFor example:\n\n```compile_fail,E0308\nlet x: i32 = \"I am not a number!\";\n//     ~~~   ~~~~~~~~~~~~~~~~~~~~\n//      |             |\n//      |    initializing expression;\n//      |    compiler infers type `&str`\n//      |\n//    type `i32` assigned to variable `x`\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs","byte_start":825,"byte_end":866,"line_start":18,"line_end":18,"column_start":13,"column_end":54,"is_primary":true,"text":[{"text":"    let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[i32]; //~ ERROR mismatched types","highlight_start":13,"highlight_end":54}],"label":"expected slice, found array of 3 elements","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `&[i32]`\n   found type `&[i32; 3]`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> /checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:18:13\n   |\nLL |     let _ = &if true { [1, 2, 3] } else { [1, 3, 4] }: &[i32]; //~ ERROR mismatched types\n   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice, found array of 3 elements\n   |\n   = note: expected type `&[i32]`\n              found type `&[i32; 3]`\n\n"}
[01:05:24] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expression, and the actual type explicitly assigned to the\nvariable.\n\nFor example:\n\n```compile_fail,E0308\nlet x: i32 = \"I am not a number!\";\n//     ~~~   ~~~~~~~~~~~~~~~~~~~~\n//      |             |\n//      |    initializing expression;\n//      |    compiler infers type `&str`\n//      |\n//    type `i32` assigned to variable `x`\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs","byte_start":915,"byte_end":968,"line_start":19,"line_end":19,"column_start":13,"column_end":66,"is_primary":true,"text":[{"text":"    let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[i32];","highlight_start":13,"highlight_end":66}],"label":"expected slice, found array of 3 elements","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `&[i32]`\n   found type `&[i32; 3]`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> /checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:19:13\n   |\nLL |     let _ = &match true { true => [1, 2, 3], false => [1, 3, 4] }: &[i32];\n   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected slice, found array of 3 elements\n   |\n   = note: expected type `&[i32]`\n              found type `&[i32; 3]`\n\n"}
[01:05:24] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expression, and the actual type explicitly assigned to the\nvariable.\n\nFor example:\n\n```compile_fail,E0308\nlet x: i32 = \"I am not a number!\";\n//     ~~~   ~~~~~~~~~~~~~~~~~~~~\n//      |             |\n//      |    initializing expression;\n//      |    compiler infers type `&str`\n//      |\n//    type `i32` assigned to variable `x`\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs","byte_start":1022,"byte_end":1040,"line_start":21,"line_end":21,"column_start":13,"column_end":31,"is_primary":true,"text":[{"text":"    let _ = &{ |x| (x as u8) }: &Fn(i32) -> _; //~ ERROR mismatched types","highlight_start":13,"highlight_end":31}],"label":"expected trait std::ops::Fn, found closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `&dyn std::ops::Fn(i32) -> u8`\n   found type `&[closure@/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:21:16: 21:29]`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> /checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:21:13\n   |\nLL |     let _ = &{ |x| (x as u8) }: &Fn(i32) -> _; //~ ERROR mismatched types\n   |             ^^^^^^^^^^^^^^^^^^ expected trait std::ops::Fn, found closure\n   |\n   = note: expected type `&dyn std::ops::Fn(i32) -> u8`\n              found type `&[closure@/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:21:16: 21:29]`\n\n"}
[01:05:24] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expression, and the actual type explicitly assigned to the\nvariable.\n\nFor example:\n\n```compile_fail,E0308\nlet x: i32 = \"I am not a number!\";\n//     ~~~   ~~~~~~~~~~~~~~~~~~~~\n//      |             |\n//      |    initializing expression;\n//      |    compiler infers type `&str`\n//      |\n//    type `i32` assigned to variable `x`\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs","byte_start":1096,"byte_end":1128,"line_start":22,"line_end":22,"column_start":13,"column_end":45,"is_primary":true,"text":[{"text":"    let _ = &if true { false } else { true }: &Debug; //~ ERROR mismatched types","highlight_start":13,"highlight_end":45}],"label":"expected trait std::fmt::Debug, found bool","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `&dyn std::fmt::Debug`\n   found type `&bool`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> /checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:22:13\n   |\nLL |     let _ = &if true { false } else { true }: &Debug; //~ ERROR mismatched types\n   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found bool\n   |\n   = note: expected type `&dyn std::fmt::Debug`\n              found type `&bool`\n\n"}
[01:05:24] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expression, and the actual type explicitly assigned to the\nvariable.\n\nFor example:\n\n```compile_fail,E0308\nlet x: i32 = \"I am not a number!\";\n//     ~~~   ~~~~~~~~~~~~~~~~~~~~\n//      |             |\n//      |    initializing expression;\n//      |    compiler infers type `&str`\n//      |\n//    type `i32` assigned to variable `x`\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs","byte_start":1177,"byte_end":1218,"line_start":23,"line_end":23,"column_start":13,"column_end":54,"is_primary":true,"text":[{"text":"    let _ = &match true { true => 'a', false => 'b' }: &Debug; //~ ERROR mismatched types","highlight_start":13,"highlight_end":54}],"label":"expected trait std::fmt::Debug, found char","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `&dyn std::fmt::Debug`\n   found type `&char`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> /checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:23:13\n   |\nLL |     let _ = &match true { true => 'a', false => 'b' }: &Debug; //~ ERROR mismatched types\n   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::fmt::Debug, found char\n   |\n   = note: expected type `&dyn std::fmt::Debug`\n              found type `&char`\n\n"}
[01:05:24] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expression, and the actual type explicitly assigned to the\nvariable.\n\nFor example:\n\n```compile_fail,E0308\nlet x: i32 = \"I am not a number!\";\n//     ~~~   ~~~~~~~~~~~~~~~~~~~~\n//      |             |\n//      |    initializing expression;\n//      |    compiler infers type `&str`\n//      |\n//    type `i32` assigned to variable `x`\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs","byte_start":1268,"byte_end":1287,"line_start":25,"line_end":25,"column_start":13,"column_end":32,"is_primary":true,"text":[{"text":"    let _ = Box::new([1, 2, 3]): Box<[i32]>; //~ ERROR mismatched types","highlight_start":13,"highlight_end":32}],"label":"expected slice, found array of 3 elements","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::boxed::Box<[i32]>`\n   found type `std::boxed::Box<[i32; 3]>`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> /checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:25:13\n   |\nLL |     let _ = Box::new([1, 2, 3]): Box<[i32]>; //~ ERROR mismatched types\n   |             ^^^^^^^^^^^^^^^^^^^ expected slice, found array of 3 elements\n   |\n   = note: expected type `std::boxed::Box<[i32]>`\n              found type `std::boxed::Box<[i32; 3]>`\n\n"}
[01:05:24] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expression, and the actual type explicitly assigned to the\nvariable.\n\nFor example:\n\n```compile_fail,E0308\nlet x: i32 = \"I am not a number!\";\n//     ~~~   ~~~~~~~~~~~~~~~~~~~~\n//      |             |\n//      |    initializing expression;\n//      |    compiler infers type `&str`\n//      |\n//    type `i32` assigned to variable `x`\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs","byte_start":1340,"byte_end":1363,"line_start":26,"line_end":26,"column_start":13,"column_end":36,"is_primary":true,"text":[{"text":"    let _ = Box::new(|x| (x as u8)): Box<Fn(i32) -> _>; //~ ERROR mismatched types","highlight_start":13,"highlight_end":36}],"label":"expected trait std::ops::Fn, found closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::boxed::Box<dyn std::ops::Fn(i32) -> _>`\n   found type `std::boxed::Box<[closure@/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:26:22: 26:35]>`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> /checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:26:13\n   |\nLL |     let _ = Box::new(|x| (x as u8)): Box<Fn(i32) -> _>; //~ ERROR mismatched types\n   |             ^^^^^^^^^^^^^^^^^^^^^^^ expected trait std::ops::Fn, found closure\n   |\n   = note: expected type `std::boxed::Box<dyn std::ops::Fn(i32) -> _>`\n              found type `std::boxed::Box<[closure@/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:26:22: 26:35]>`\n\n"}
[01:05:24] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expression, and the actual type explicitly assigned to the\nvariable.\n\nFor example:\n\n```compile_fail,E0308\nlet x: i32 = \"I am not a number!\";\n//     ~~~   ~~~~~~~~~~~~~~~~~~~~\n//      |             |\n//      |    initializing expression;\n//      |    compiler infers type `&str`\n//      |\n//    type `i32` assigned to variable `x`\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs","byte_start":1471,"byte_end":1495,"line_start":30,"line_end":30,"column_start":9,"column_end":33,"is_primary":true,"text":[{"text":"        box |x| (x as i16 as u8),","highlight_start":9,"highlight_end":33}],"label":"expected closure, found a different closure","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `std::boxed::Box<[closure@/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:29:18: 29:31]>`\n   found type `std::boxed::Box<[closure@/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:30:13: 30:33]>`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"no two closures, even if identical, have the same type","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"consider boxing your closure and/or using it as a trait object","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> /checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:30:9\n   |\nLL |         box |x| (x as i16 as u8),\n   |         ^^^^^^^^^^^^^^^^^^^^^^^^ expected closure, found a different closure\n   |\n   = note: expected type `std::boxed::Box<[closure@/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:29:18: 29:31]>`\n              found type `std::boxed::Box<[closure@/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:30:13: 30:33]>`\n   = note: no two closures, even if identical, have the same type\n   = help: consider boxing your closure and/or using it as a trait object\n\n"}
[01:05:24] {"message":"the size for values of type `[std::boxed::Box<dyn std::ops::Fn(i32) -> _>]` cannot be known at compilation time","code":{"code":"E0277","explanation":"\nYou tried to use a type which doesn't implement some trait in a place which\nexpected that trait. Erroneous code example:\n\n```compile_fail,E0277\n// here we declare the Foo trait with a bar method\ntrait Foo {\n    fn bar(&self);\n}\n\n// we now declare a function which takes an object implementing the Foo trait\nfn some_func<T: Foo>(foo: T) {\n    foo.bar();\n}\n\nfn main() {\n    // we now call the method with the i32 type, which doesn't implement\n    // the Foo trait\n    some_func(5i32); // error: the trait bound `i32 : Foo` is not satisfied\n}\n```\n\nIn order to fix this error, verify that the type you're using does implement\nthe trait. Example:\n\n```\ntrait Foo {\n    fn bar(&self);\n}\n\nfn some_func<T: Foo>(foo: T) {\n    foo.bar(); // we can now use this method since i32 implements the\n               // Foo trait\n}\n\n// we implement the trait on the i32 type\nimpl Foo for i32 {\n    fn bar(&self) {}\n}\n\nfn main() {\n    some_func(5i32); // ok!\n}\n```\n\nOr in a generic context, an erroneous code example would look like:\n\n```compile_fail,E0277\nfn some_func<T>(foo: T) {\n    println!(\"{:?}\", foo); // error: the trait `core::fmt::Debug` is not\n                           //        implemented for the type `T`\n}\n\nfn main() {\n    // We now call the method with the i32 type,\n    // which *does* implement the Debug trait.\n    some_func(5i32);\n}\n```\n\nNote that the error here is in the definition of the generic function: Although\nwe only call it with a parameter that does implement `Debug`, the compiler\nstill rejects the function: It must work with all possible input types. In\norder to make this example compile, we need to restrict the generic type we're\naccepting:\n\n```\nuse std::fmt;\n\n// Restrict the input type to types that implement Debug.\nfn some_func<T: fmt::Debug>(foo: T) {\n    println!(\"{:?}\", foo);\n}\n\nfn main() {\n    // Calling the method is still fine, as i32 implements Debug.\n    some_func(5i32);\n\n    // This would fail to compile now:\n    // struct WithoutDebug;\n    // some_func(WithoutDebug);\n}\n```\n\nRust only looks at the signature of the called function, as such it must\nalready specify all requirements that will be used for every type parameter.\n"},"level":"error","spans":[{"file_name":"<::alloc::macros::vec macros>","byte_start":121,"byte_end":124,"line_start":3,"line_end":3,"column_start":7,"column_end":10,"is_primary":true,"text":[{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":7,"highlight_end":10}],"label":"doesn't have a size known at compile-time","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"<::alloc::macros::vec macros>","byte_start":217,"byte_end":240,"line_start":4,"line_end":4,"column_start":29,"column_end":52,"is_primary":false,"text":[{"text":"$ ( $ x : expr , ) * ) => ( vec ! [ $ ( $ x ) , * ] )","highlight_start":29,"highlight_end":52}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs","byte_start":1424,"byte_end":1502,"line_start":28,"line_end":31,"column_start":13,"column_end":6,"is_primary":false,"text":[{"text":"    let _ = vec![","highlight_start":13,"highlight_end":18},{"text":"        Box::new(|x| (x as u8)),","highlight_start":1,"highlight_end":33},{"text":"        box |x| (x as i16 as u8),","highlight_start":1,"highlight_end":34},{"text":"    ]: Vec<Box<Fn(i32) -> _>>;","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"vec!","def_site_span":{"file_name":"<::alloc::macros::vec macros>","byte_start":0,"byte_end":242,"line_start":1,"line_end":4,"column_start":1,"column_end":54,"is_primary":false,"text":[{"text":"( $ elem : expr ; $ n : expr ) => (","highlight_start":1,"highlight_end":36},{"text":"$ crate :: vec :: from_elem ( $ elem , $ n ) ) ; ( $ ( $ x : expr ) , * ) => (","highlight_start":1,"highlight_end":79},{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":1,"highlight_end":74},{"text":"$ ( $ x : expr , ) * ) => ( vec ! [ $ ( $ x ) , * ] )","highlight_start":1,"highlight_end":54}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},"macro_decl_name":"vec!","def_site_span":{"file_name":"<::alloc::macros::vec macros>","byte_start":0,"byte_end":242,"line_start":1,"line_end":4,"column_start":1,"column_end":54,"is_primary":false,"text":[{"text":"( $ elem : expr ; $ n : expr ) => (","highlight_start":1,"highlight_end":36},{"text":"$ crate :: vec :: from_elem ( $ elem , $ n ) ) ; ( $ ( $ x : expr ) , * ) => (","highlight_start":1,"highlight_end":79},{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":1,"highlight_end":74},{"text":"$ ( $ x : expr , ) * ) => ( vec ! [ $ ( $ x ) , * ] )","highlight_start":1,"highlight_end":54}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"the trait `std::marker::Sized` is not implemented for `[std::boxed::Box<dyn std::ops::Fn(i32) -> _>]`","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"all local variables must have a statically known size","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"unsized locals are gated as an unstable feature","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error[E0277]: the size for values of type `[std::boxed::Box<dyn std::ops::Fn(i32) -> _>]` cannot be known at compilation time\n  --> /checkout/src/test/ui/coercion/coerce-expect-unsized-ascribed.rs:28:13\n   |\nLL |       let _ = vec![\n   |  _____________^\nLL | |         Box::new(|x| (x as u8)),\nLL | |         box |x| (x as i16 as u8),\nLL | |     ]: Vec<Box<Fn(i32) -> _>>;\n   | |_____^ doesn't have a size known at compile-time\n   |\n   = help: the trait `std::marker::Sized` is not implemented for `[std::boxed::Box<dyn std::ops::Fn(i32) -> _>]`\n   = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>\n   = note: all local variables must have a statically known size\n   = help: unsized locals are gated as an unstable feature\n   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)\n\n"}
[01:05:24] {"message":"aborting due to 16 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 16 previous errors\n\n"}
[01:05:24] {"message":"Some errors occurred: E0277, E0308.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0277, E0308.\n"}
[01:05:24] 
[01:05:24] ------------------------------------------
[01:05:24] 
[01:05:24] thread '[ui] ui/coercion/coerce-expect-unsized-ascribed.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3295:9
[01:05:24] thread '[ui] ui/coercion/coerce-expect-unsized-ascribed.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3295:9
[01:05:24] note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
[01:05:24] 
[01:05:24] ---- [ui] ui/elide-errors-on-mismatched-tuple.rs stdout ----
[01:05:24] diff of stderr:
[01:05:24] 
[01:05:24] 7    = note: expected type `(A, A)`
[01:05:24] 9 
[01:05:24] - error: aborting due to previous error
[01:05:24] - error: aborting due to previous error
[01:05:24] + error[E0277]: the size for values of type `[&dyn T]` cannot be known at compilation time
[01:05:24] +    |
[01:05:24] +    |
[01:05:24] + LL |     let ts: Vec<&T> = vec![&a, &b, &c];
[01:05:24] +    |
[01:05:24] +    |
[01:05:24] +    = help: the trait `std::marker::Sized` is not implemented for `[&dyn T]`
[01:05:24] +    = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>
[01:05:24] +    = help: unsized locals are gated as an unstable feature
[01:05:24] +    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[01:05:24] 11 
[01:05:24] - For more information about this error, try `rustc --explain E0308`.
---
[01:05:24] 13 
[01:05:24] 
[01:05:24] 
[01:05:24] The actual stderr differed from the expected stderr.
[01:05:24] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/elide-errors-on-mismatched-tuple/elide-errors-on-mismatched-tuple.stderr
[01:05:24] To update references, rerun the tests and pass the `--bless` flag
[01:05:24] To only update this specific test, also pass `--test-args elide-errors-on-mismatched-tuple.rs`
[01:05:24] error: 1 errors occurred comparing output.
[01:05:24] status: exit code: 1
[01:05:24] status: exit code: 1
[01:05:24] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/elide-errors-on-mismatched-tuple.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/elide-errors-on-mismatched-tuple/a" "-Crpath" "-O" "-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/elide-errors-on-mismatched-tuple/auxiliary" "-A" "unused"
[01:05:24] ------------------------------------------
[01:05:24] 
[01:05:24] ------------------------------------------
[01:05:24] stderr:
[01:05:24] stderr:
[01:05:24] ------------------------------------------
[01:05:24] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expression, and the actual type explicitly assigned to the\nvariable.\n\nFor example:\n\n```compile_fail,E0308\nlet x: i32 = \"I am not a number!\";\n//     ~~~   ~~~~~~~~~~~~~~~~~~~~\n//      |             |\n//      |    initializing expression;\n//      |    compiler infers type `&str`\n//      |\n//    type `i32` assigned to variable `x`\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/elide-errors-on-mismatched-tuple.rs","byte_start":157,"byte_end":166,"line_start":14,"line_end":14,"column_start":9,"column_end":18,"is_primary":true,"text":[{"text":"    let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three","highlight_start":9,"highlight_end":18}],"label":"expected a tuple with 2 elements, found one with 3 elements","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"expected type `(A, A)`\n   found type `(_, _, _)`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> /checkout/src/test/ui/elide-errors-on-mismatched-tuple.rs:14:9\n   |\nLL |     let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three\n   |         ^^^^^^^^^ expected a tuple with 2 elements, found one with 3 elements\n   |\n   = note: expected type `(A, A)`\n              found type `(_, _, _)`\n\n"}
[01:05:24] {"message":"the size for values of type `[&dyn T]` cannot be known at compilation time","code":{"code":"E0277","explanation":"\nYou tried to use a type which doesn't implement some trait in a place which\nexpected that trait. Erroneous code example:\n\n```compile_fail,E0277\n// here we declare the Foo trait with a bar method\ntrait Foo {\n    fn bar(&self);\n}\n\n// we now declare a function which takes an object implementing the Foo trait\nfn some_func<T: Foo>(foo: T) {\n    foo.bar();\n}\n\nfn main() {\n    // we now call the method with the i32 type, which doesn't implement\n    // the Foo trait\n    some_func(5i32); // error: the trait bound `i32 : Foo` is not satisfied\n}\n```\n\nIn order to fix this error, verify that the type you're using does implement\nthe trait. Example:\n\n```\ntrait Foo {\n    fn bar(&self);\n}\n\nfn some_func<T: Foo>(foo: T) {\n    foo.bar(); // we can now use this method since i32 implements the\n               // Foo trait\n}\n\n// we implement the trait on the i32 type\nimpl Foo for i32 {\n    fn bar(&self) {}\n}\n\nfn main() {\n    some_func(5i32); // ok!\n}\n```\n\nOr in a generic context, an erroneous code example would look like:\n\n```compile_fail,E0277\nfn some_func<T>(foo: T) {\n    println!(\"{:?}\", foo); // error: the trait `core::fmt::Debug` is not\n                           //        implemented for the type `T`\n}\n\nfn main() {\n    // We now call the method with the i32 type,\n    // which *does* implement the Debug trait.\n    some_func(5i32);\n}\n```\n\nNote that the error here is in the definition of the generic function: Although\nwe only call it with a parameter that does implement `Debug`, the compiler\nstill rejects the function: It must work with all possible input types. In\norder to make this example compile, we need to restrict the generic type we're\naccepting:\n\n```\nuse std::fmt;\n\n// Restrict the input type to types that implement Debug.\nfn some_func<T: fmt::Debug>(foo: T) {\n    println!(\"{:?}\", foo);\n}\n\nfn main() {\n    // Calling the method is still fine, as i32 implements Debug.\n    some_func(5i32);\n\n    // This would fail to compile now:\n    // struct WithoutDebug;\n    // some_func(WithoutDebug);\n}\n```\n\nRust only looks at the signature of the called function, as such it must\nalready specify all requirements that will be used for every type parameter.\n"},"level":"error","spans":[{"file_name":"<::alloc::macros::vec macros>","byte_start":121,"byte_end":124,"line_start":3,"line_end":3,"column_start":7,"column_end":10,"is_primary":true,"text":[{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":7,"highlight_end":10}],"label":"doesn't have a size known at compile-time","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/elide-errors-on-mismatched-tuple.rs","byte_start":290,"byte_end":306,"line_start":16,"line_end":16,"column_start":23,"column_end":39,"is_primary":false,"text":[{"text":"    let ts: Vec<&T> = vec![&a, &b, &c];","highlight_start":23,"highlight_end":39}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"vec!","def_site_span":{"file_name":"<::alloc::macros::vec macros>","byte_start":0,"byte_end":242,"line_start":1,"line_end":4,"column_start":1,"column_end":54,"is_primary":false,"text":[{"text":"( $ elem : expr ; $ n : expr ) => (","highlight_start":1,"highlight_end":36},{"text":"$ crate :: vec :: from_elem ( $ elem , $ n ) ) ; ( $ ( $ x : expr ) , * ) => (","highlight_start":1,"highlight_end":79},{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":1,"highlight_end":74},{"text":"$ ( $ x : expr , ) * ) => ( vec ! [ $ ( $ x ) , * ] )","highlight_start":1,"highlight_end":54}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"the trait `std::marker::Sized` is not implemented for `[&dyn T]`","code":null,"level":"help","spans":[],"children":[],"rendered":null},{"message":"to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"all local variables must have a statically known size","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"unsized locals are gated as an unstable feature","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error[E0277]: the size for values of type `[&dyn T]` cannot be known at compilation time\n  --> /checkout/src/test/ui/elide-errors-on-mismatched-tuple.rs:16:23\n   |\nLL |     let ts: Vec<&T> = vec![&a, &b, &c];\n   |                       ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time\n   |\n   = help: the trait `std::marker::Sized` is not implemented for `[&dyn T]`\n   = note: to learn more, visit <https://doc.rust-lang.org/book/ch19-04-advanced-types.html#dynamically-sized-types-and-the-sized-trait>\n   = note: all local variables must have a statically known size\n   = help: unsized locals are gated as an unstable feature\n   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)\n\n"}
[01:05:24] {"message":"aborting due to 2 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 2 previous errors\n\n"}
[01:05:24] {"message":"Some errors occurred: E0277, E0308.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0277, E0308.\n"}
[01:05:24] 
[01:05:24] ------------------------------------------
[01:05:24] 
[01:05:24] thread '[ui] ui/elide-errors-on-mismatched-tuple.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3295:9
[01:05:24] thread '[ui] ui/elide-errors-on-mismatched-tuple.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3295:9
[01:05:24] 
[01:05:24] ---- [ui] ui/issues/issue-23589.rs stdout ----
[01:05:24] diff of stderr:
[01:05:24] 
[01:05:24] 8    |               help: use angle brackets instead: `<&str>`
[01:05:24] 10 error[E0308]: mismatched types
[01:05:24] -   --> $DIR/issue-23589.rs:2:29
[01:05:24] +   --> $DIR/issue-23589.rs:2:24
[01:05:24] 12    |
[01:05:24] 12    |
[01:05:24] 13 LL |     let v: Vec(&str) = vec!['1', '2'];
[01:05:24] -    |                             ^^^ expected &str, found char
[01:05:24] +    |                        ^^^^^^^^^^^^^^ expected slice, found array of 2 elements
[01:05:24] -    = note: expected type `&str`
[01:05:24] -               found type `char`
[01:05:24] -               found type `char`
[01:05:24] +    = note: expected type `std::boxed::Box<[&str]>`
[01:05:24] +               found type `std::boxed::Box<[char; 2]>`
[01:05:24] 18 
[01:05:24] 19 error: aborting due to 2 previous errors
[01:05:24] 20 
[01:05:24] 
[01:05:24] 
[01:05:24] 
[01:05:24] The actual stderr differed from the expected stderr.
[01:05:24] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-23589/issue-23589.stderr
[01:05:24] To update references, rerun the tests and pass the `--bless` flag
[01:05:24] To only update this specific test, also pass `--test-args issues/issue-23589.rs`
[01:05:24] error: 1 errors occurred comparing output.
[01:05:24] status: exit code: 1
[01:05:24] status: exit code: 1
[01:05:24] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issues/issue-23589.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-23589/a" "-Crpath" "-O" "-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-23589/auxiliary" "-A" "unused"
[01:05:24] ------------------------------------------
[01:05:24] 
[01:05:24] ------------------------------------------
[01:05:24] stderr:
[01:05:24] stderr:
[01:05:24] ------------------------------------------
[01:05:24] {"message":"parenthesized type parameters may only be used with a `Fn` trait","code":{"code":"E0214","explanation":"\nA generic type was described using parentheses rather than angle brackets.\nFor example:\n\n```compile_fail,E0214\nfn main() {\n    let v: Vec(&str) = vec![\"foo\"];\n}\n```\n\nThis is not currently supported: `v` should be defined as `Vec<&str>`.\nParentheses are currently only used with generic types when defining parameters\nfor `Fn`-family traits.\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-23589.rs","byte_start":26,"byte_end":32,"line_start":2,"line_end":2,"column_start":15,"column_end":21,"is_primary":true,"text":[{"text":"    let v: Vec(&str) = vec!['1', '2'];","highlight_start":15,"highlight_end":21}],"label":"only `Fn` traits may use parentheses","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"use angle brackets instead","code":null,"level":"help","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-23589.rs","byte_start":26,"byte_end":32,"line_start":2,"line_end":2,"column_start":15,"column_end":21,"is_primary":true,"text":[{"text":"    let v: Vec(&str) = vec!['1', '2'];","highlight_start":15,"highlight_end":21}],"label":null,"suggested_replacement":"<&str>","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"error[E0214]: parenthesized type parameters may only be used with a `Fn` trait\n  --> /checkout/src/test/ui/issues/issue-23589.rs:2:15\n   |\nLL |     let v: Vec(&str) = vec!['1', '2'];\n   |               ^^^^^^\n   |               |\n   |               only `Fn` traits may use parentheses\n   |               help: use angle brackets instead: `<&str>`\n\n"}
[01:05:24] {"message":"mismatched types","code":{"code":"E0308","explanation":"\nThis error occurs when the compiler was unable to infer the concrete type of a\nvariable. It can occur for several cases, the most common of which is a\nmismatch in the expected type that the compiler inferred for a variable's\ninitializing expression, and the actual type explicitly assigned to the\nvariable.\n\nFor example:\n\n```compile_fail,E0308\nlet x: i32 = \"I am not a number!\";\n//     ~~~   ~~~~~~~~~~~~~~~~~~~~\n//      |             |\n//      |    initializing expression;\n//      |    compiler infers type `&str`\n//      |\n//    type `i32` assigned to variable `x`\n```\n"},"level":"error","spans":[{"file_name":"<::alloc::macros::vec macros>","byte_start":171,"byte_end":178,"line_start":3,"line_end":3,"column_start":57,"column_end":64,"is_primary":true,"text":[{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":57,"highlight_end":64}],"label":"expected slice, found array of 2 elements","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/issues/issue-23589.rs","byte_start":35,"byte_end":49,"line_start":2,"line_end":2,"column_start":24,"column_end":38,"is_primary":false,"text":[{"text":"    let v: Vec(&str) = vec!['1', '2'];","highlight_start":24,"highlight_end":38}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"vec!","def_site_span":{"file_name":"<::alloc::macros::vec macros>","byte_start":0,"byte_end":242,"line_start":1,"line_end":4,"column_start":1,"column_end":54,"is_primary":false,"text":[{"text":"( $ elem : expr ; $ n : expr ) => (","highlight_start":1,"highlight_end":36},{"text":"$ crate :: vec :: from_elem ( $ elem , $ n ) ) ; ( $ ( $ x : expr ) , * ) => (","highlight_start":1,"highlight_end":79},{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":1,"highlight_end":74},{"text":"$ ( $ x : expr , ) * ) => ( vec ! [ $ ( $ x ) , * ] )","highlight_start":1,"highlight_end":54}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"expected type `std::boxed::Box<[&str]>`\n   found type `std::boxed::Box<[char; 2]>`","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"error[E0308]: mismatched types\n  --> /checkout/src/test/ui/issues/issue-23589.rs:2:24\n   |\nLL |     let v: Vec(&str) = vec!['1', '2'];\n   |                        ^^^^^^^^^^^^^^ expected slice, found array of 2 elements\n   |\n   = note: expected type `std::boxed::Box<[&str]>`\n              found type `std::boxed::Box<[char; 2]>`\n   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)\n\n"}
[01:05:24] {"message":"aborting due to 2 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 2 previous errors\n\n"}
[01:05:24] {"message":"Some errors occurred: E0214, E0308.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0214, E0308.\n"}
[01:05:24] 
[01:05:24] ------------------------------------------
[01:05:24] 
[01:05:24] thread '[ui] ui/issues/issue-23589.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3295:9
[01:05:24] thread '[ui] ui/issues/issue-23589.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3295:9
[01:05:24] 
[01:05:24] ---- [ui] ui/issues/issue-47184.rs stdout ----
[01:05:24] diff of stderr:
[01:05:24] 
[01:05:24] 2   --> $DIR/issue-47184.rs:4:44
[01:05:24] 3    |
[01:05:24] 4 LL |     let _vec: Vec<&'static String> = vec![&String::new()];
[01:05:24] -    |               --------------------         ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
[01:05:24] -    |               |                            |
[01:05:24] -    |               |                            creates a temporary which is freed while still in use
[01:05:24] +    |               |                      |     |
[01:05:24] +    |               |                      |     |
[01:05:24] +    |               |                      |     creates a temporary which is freed while still in use
[01:05:24] +    |               |                      temporary value is freed at the end of this statement
[01:05:24] 8    |               type annotation requires that borrow lasts for `'static`
[01:05:24] +    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[01:05:24] 9 
[01:05:24] 10 error: aborting due to previous error
[01:05:24] 11 
[01:05:24] 11 
[01:05:24] 
[01:05:24] 
[01:05:24] The actual stderr differed from the expected stderr.
[01:05:24] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-47184/issue-47184.stderr
[01:05:24] To update references, rerun the tests and pass the `--bless` flag
[01:05:24] To only update this specific test, also pass `--test-args issues/issue-47184.rs`
[01:05:24] error: 1 errors occurred comparing output.
[01:05:24] status: exit code: 1
[01:05:24] status: exit code: 1
[01:05:24] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issues/issue-47184.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-47184/a" "-Crpath" "-O" "-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-47184/auxiliary" "-A" "unused"
[01:05:24] ------------------------------------------
[01:05:24] 
[01:05:24] ------------------------------------------
[01:05:24] stderr:
[01:05:24] stderr:
[01:05:24] ------------------------------------------
[01:05:24] {"message":"temporary value dropped while borrowed","code":{"code":"E0716","explanation":"\nThis error indicates that a temporary value is being dropped\nwhile a borrow is still in active use.\n\nErroneous code example:\n\n```compile_fail,E0716\n# #![feature(nll)]\nfn foo() -> i32 { 22 }\nfn bar(x: &i32) -> &i32 { x }\nlet p = bar(&foo());\n         // ------ creates a temporary\nlet q = *p;\n```\n\nHere, the expression `&foo()` is borrowing the expression\n`foo()`. As `foo()` is call to a function, and not the name of\na variable, this creates a **temporary** -- that temporary stores\nthe return value from `foo()` so that it can be borrowed.\nSo you might imagine that `let p = bar(&foo())` is equivalent\nto this:\n\n```compile_fail,E0597\n# fn foo() -> i32 { 22 }\n# fn bar(x: &i32) -> &i32 { x }\nlet p = {\n  let tmp = foo(); // the temporary\n  bar(&tmp)\n}; // <-- tmp is freed as we exit this block\nlet q = p;\n```\n\nWhenever a temporary is created, it is automatically dropped (freed)\naccording to fixed rules. Ordinarily, the temporary is dropped\nat the end of the enclosing statement -- in this case, after the `let`.\nThis is illustrated in the example above by showing that `tmp` would\nbe freed as we exit the block.\n\nTo fix this problem, you need to create a local variable\nto store the value in rather than relying on a temporary.\nFor example, you might change the original program to\nthe following:\n\n```\nfn foo() -> i32 { 22 }\nfn bar(x: &i32) -> &i32 { x }\nlet value = foo(); // dropped at the end of the enclosing block\nlet p = bar(&value);\nlet q = *p;\n```\n\nBy introducing the explicit `let value`, we allocate storage\nthat will last until the end of the enclosing block (when `value`\ngoes out of scope). When we borrow `&value`, we are borrowing a\nlocal variable that already exists, and hence no temporary is created.\n\nTemporaries are not always dropped at the end of the enclosing\nstatement. In simple cases where the `&` expression is immediately\nstored into a variable, the compiler will automatically extend\nthe lifetime of the temporary until the end of the enclosing\nblock. Therefore, an alternative way to fix the original\nprogram is to write `let tmp = &foo()` and not `let tmp = foo()`:\n\n```\nfn foo() -> i32 { 22 }\nfn bar(x: &i32) -> &i32 { x }\nlet value = &foo();\nlet p = bar(value);\nlet q = *p;\n```\n\nHere, we are still borrowing `foo()`, but as the borrow is assigned\ndirectly into a variable, the temporary will not be dropped until\nthe end of the enclosing block. Similar rules apply when temporaries\nare stored into aggregate structures like a tuple or struct:\n\n```\n// Here, two temporaries are created, but\n// as they are stored directly into `value`,\n// they are not dropped until the end of the\n// enclosing block.\nfn foo() -> i32 { 22 }\nlet value = (&foo(), &foo());\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/issues/issue-47184.rs","byte_start":73,"byte_end":86,"line_start":4,"line_end":4,"column_start":44,"column_end":57,"is_primary":true,"text":[{"text":"    let _vec: Vec<&'static String> = vec![&String::new()];","highlight_start":44,"highlight_end":57}],"label":"creates a temporary which is freed while still in use","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"<::alloc::macros::vec macros>","byte_start":181,"byte_end":182,"line_start":3,"line_end":3,"column_start":67,"column_end":68,"is_primary":false,"text":[{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":67,"highlight_end":68}],"label":"temporary value is freed at the end of this statement","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/issues/issue-47184.rs","byte_start":67,"byte_end":87,"line_start":4,"line_end":4,"column_start":38,"column_end":58,"is_primary":false,"text":[{"text":"    let _vec: Vec<&'static String> = vec![&String::new()];","highlight_start":38,"highlight_end":58}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"vec!","def_site_span":{"file_name":"<::alloc::macros::vec macros>","byte_start":0,"byte_end":242,"line_start":1,"line_end":4,"column_start":1,"column_end":54,"is_primary":false,"text":[{"text":"( $ elem : expr ; $ n : expr ) => (","highlight_start":1,"highlight_end":36},{"text":"$ crate :: vec :: from_elem ( $ elem , $ n ) ) ; ( $ ( $ x : expr ) , * ) => (","highlight_start":1,"highlight_end":79},{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":1,"highlight_end":74},{"text":"$ ( $ x : expr , ) * ) => ( vec ! [ $ ( $ x ) , * ] )","highlight_start":1,"highlight_end":54}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"/checkout/src/test/ui/issues/issue-47184.rs","byte_start":44,"byte_end":64,"line_start":4,"line_end":4,"column_start":15,"column_end":35,"is_primary":false,"text":[{"text":"    let _vec: Vec<&'static String> = vec![&String::new()];","highlight_start":15,"highlight_end":35}],"label":"type annotation requires that borrow lasts for `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0716]: temporary value dropped while borrowed\n  --> /checkout/src/test/ui/issues/issue-47184.rs:4:44\n   |\nLL |     let _vec: Vec<&'static String> = vec![&String::new()];\n   |               --------------------   ------^^^^^^^^^^^^^-\n   |               |                      |     |\n   |               |                      |     creates a temporary which is freed while still in use\n   |               |                      temporary value is freed at the end of this statement\n   |               type annotation requires that borrow lasts for `'static`\n   |\n   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)\n\n"}
[01:05:24] {"message":"For more information about this error, try `rustc --explain E0716`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0716`.\n"}
[01:05:24] 
[01:05:24] ------------------------------------------
[01:05:24] 
[01:05:24] 
[01:05:24] thread '[ui] ui/issues/issue-47184.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3295:9
[01:05:24] 
[01:05:24] ---- [ui] ui/nll/user-annotations/patterns.rs stdout ----
[01:05:24] diff of stderr:
[01:05:24] 
[01:05:24] 74   --> $DIR/patterns.rs:65:41
[01:05:24] 75    |
[01:05:24] 76 LL |     let _: Vec<&'static String> = vec![&String::new()];
[01:05:24] -    |            --------------------         ^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
[01:05:24] -    |            |                            |
[01:05:24] -    |            |                            creates a temporary which is freed while still in use
[01:05:24] +    |            |                      |     |
[01:05:24] +    |            |                      |     |
[01:05:24] +    |            |                      |     creates a temporary which is freed while still in use
[01:05:24] +    |            |                      temporary value is freed at the end of this statement
[01:05:24] 80    |            type annotation requires that borrow lasts for `'static`
[01:05:24] +    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[01:05:24] 81 
[01:05:24] 81 
[01:05:24] 82 error[E0716]: temporary value dropped while borrowed
[01:05:24] 
[01:05:24] 84    |
[01:05:24] 84    |
[01:05:24] 85 LL |     let (_, a): (Vec<&'static String>, _) = (vec![&String::new()], 44);
[01:05:24] -    |                 -------------------------          ^^^^^^^^^^^^^      - temporary value is freed at the end of this statement
[01:05:24] -    |                 |                                  |
[01:05:24] -    |                 |                                  creates a temporary which is freed while still in use
[01:05:24] +    |                 |                            |     |
[01:05:24] +    |                 |                            |     |
[01:05:24] +    |                 |                            |     creates a temporary which is freed while still in use
[01:05:24] +    |                 |                            temporary value is freed at the end of this statement
[01:05:24] 89    |                 type annotation requires that borrow lasts for `'static`
[01:05:24] +    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
[01:05:24] 90 
[01:05:24] 90 
[01:05:24] 91 error[E0716]: temporary value dropped while borrowed
[01:05:24] 
[01:05:24] 93    |
[01:05:24] 93    |
[01:05:24] 94 LL |     let (_a, b): (Vec<&'static String>, _) = (vec![&String::new()], 44);
[01:05:24] -    |                  -------------------------          ^^^^^^^^^^^^^      - temporary value is freed at the end of this statement
[01:05:24] -    |                  |                                  |
[01:05:24] -    |                  |heckout/obj/build/x86_64-unknown-linux-gnu/test/ui/nll/user-annotations/patterns/a" "-Crpath" "-O" "-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/user-annotations/patterns/auxiliary" "-A" "unused"
[01:05:24] ------------------------------------------
[01:05:24] 
[01:05:24] ------------------------------------------
[01:05:24] stderr:
[01:05:24] stderr:
[01:05:24] ------------------------------------------
[01:05:24] {"message":"`x` 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":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":149,"byte_end":151,"line_start":8,"line_end":8,"column_start":9,"column_end":11,"is_primary":true,"text":[{"text":"    y = &x; //~ ERROR","highlight_start":9,"highlight_end":11}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":163,"byte_end":164,"line_start":9,"line_end":9,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"`x` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":127,"byte_end":139,"line_start":7,"line_end":7,"column_start":12,"column_end":24,"is_primary":false,"text":[{"text":"    let y: &'static u32;","highlight_start":12,"highlight_end":24}],"label":"type annotation requires that `x` is borrowed for `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `x` does not live long enough\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:8:9\n   |\nLL |     let y: &'static u32;\n   |            ------------ type annotation requires that `x` is borrowed for `'static`\nLL |     y = &x; //~ ERROR\n   |         ^^ borrowed value does not live long enough\nLL | }\n   | - `x` dropped here while still borrowed\n\n"}
[01:05:24] {"message":"`x` 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":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":266,"byte_end":268,"line_start":16,"line_end":16,"column_start":9,"column_end":11,"is_primary":true,"text":[{"text":"    y = &x; //~ ERROR","highlight_start":9,"highlight_end":11}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":280,"byte_end":281,"line_start":17,"line_end":17,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"`x` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":228,"byte_end":256,"line_start":15,"line_end":15,"column_start":17,"column_end":45,"is_primary":false,"text":[{"text":"    let (y, z): (&'static u32, &'static u32);","highlight_start":17,"highlight_end":45}],"label":"type annotation requires that `x` is borrowed for `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `x` does not live long enough\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:16:9\n   |\nLL |     let (y, z): (&'static u32, &'static u32);\n   |                 ---------------------------- type annotation requires that `x` is borrowed for `'static`\nLL |     y = &x; //~ ERROR\n   |         ^^ borrowed value does not live long enough\nLL | }\n   | - `x` dropped here while still borrowed\n\n"}
[01:05:24] {"message":"`x` 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":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":402,"byte_end":404,"line_start":22,"line_end":22,"column_start":13,"column_end":15,"is_primary":true,"text":[{"text":"    let y = &x; //~ ERROR","highlight_start":13,"highlight_end":15}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":457,"byte_end":458,"line_start":25,"line_end":25,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"`x` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":431,"byte_end":443,"line_start":23,"line_end":23,"column_start":16,"column_end":28,"is_primary":false,"text":[{"text":"    let ref z: &'static u32 = y;","highlight_start":16,"highlight_end":28}],"label":"type annotation requires that `x` is borrowed for `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `x` does not live long enough\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:22:13\n   |\nLL |     let y = &x; //~ ERROR\n   |             ^^ borrowed value does not live long enough\nLL |     let ref z: &'static u32 = y;\n   |                ------------ type annotation requires that `x` is borrowed for `'static`\nLL |     **z\nLL | }\n   | - `x` dropped here while still borrowed\n\n"}
[01:05:24] {"message":"`x` 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":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":706,"byte_end":708,"line_start":41,"line_end":41,"column_start":9,"column_end":11,"is_primary":true,"text":[{"text":"    y = &x; //~ ERROR","highlight_start":9,"highlight_end":11}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":720,"byte_end":721,"line_start":42,"line_end":42,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"`x` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":676,"byte_end":696,"line_start":40,"line_end":40,"column_start":30,"column_end":50,"is_primary":false,"text":[{"text":"    let Single { value: y }: Single<&'static u32>;","highlight_start":30,"highlight_end":50}],"label":"type annotation requires that `x` is borrowed for `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `x` does not live long enough\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:41:9\n   |\nLL |     let Single { value: y }: Single<&'static u32>;\n   |                              -------------------- type annotation requires that `x` is borrowed for `'static`\nLL |     y = &x; //~ ERROR\n   |         ^^ borrowed value does not live long enough\nLL | }\n   | - `x` dropped here while still borrowed\n\n"}
[01:05:24] {"message":"`x` 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":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1035,"byte_end":1037,"line_start":53,"line_end":53,"column_start":10,"column_end":12,"is_primary":true,"text":[{"text":"    _y = &x; //~ ERROR","highlight_start":10,"highlight_end":12}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1049,"byte_end":1050,"line_start":54,"line_end":54,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"`x` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1006,"byte_end":1024,"line_start":52,"line_end":52,"column_start":36,"column_end":54,"is_primary":false,"text":[{"text":"    let Single2 { value: mut _y }: Single2<StaticU32>;","highlight_start":36,"highlight_end":54}],"label":"type annotation requires that `x` is borrowed for `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `x` does not live long enough\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:53:10\n   |\nLL |     let Single2 { value: mut _y }: Single2<StaticU32>;\n   |                                    ------------------ type annotation requires that `x` is borrowed for `'static`\nLL |     _y = &x; //~ ERROR\n   |          ^^ borrowed value does not live long enough\nLL | }\n   | - `x` dropped here while still borrowed\n\n"}
[01:05:24] {"message":"`x` 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":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1127,"byte_end":1129,"line_start":58,"line_end":58,"column_start":27,"column_end":29,"is_primary":true,"text":[{"text":"    let y: &'static u32 = &x; //~ ERROR","highlight_start":27,"highlight_end":29}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1141,"byte_end":1142,"line_start":59,"line_end":59,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"`x` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1112,"byte_end":1124,"line_start":58,"line_end":58,"column_start":12,"column_end":24,"is_primary":false,"text":[{"text":"    let y: &'static u32 = &x; //~ ERROR","highlight_start":12,"highlight_end":24}],"label":"type annotation requires that `x` is borrowed for `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `x` does not live long enough\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:58:27\n   |\nLL |     let y: &'static u32 = &x; //~ ERROR\n   |            ------------   ^^ borrowed value does not live long enough\n   |            |\n   |            type annotation requires that `x` is borrowed for `'static`\nLL | }\n   | - `x` dropped here while still borrowed\n\n"}
[01:05:24] {"message":"`x` 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":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1221,"byte_end":1223,"line_start":63,"line_end":63,"column_start":27,"column_end":29,"is_primary":true,"text":[{"text":"    let _: &'static u32 = &x; //~ ERROR","highlight_start":27,"highlight_end":29}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1625,"byte_end":1626,"line_start":73,"line_end":73,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"`x` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1206,"byte_end":1218,"line_start":63,"line_end":63,"column_start":12,"column_end":24,"is_primary":false,"text":[{"text":"    let _: &'static u32 = &x; //~ ERROR","highlight_start":12,"highlight_end":24}],"label":"type annotation requires that `x` is borrowed for `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `x` does not live long enough\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:63:27\n   |\nLL |     let _: &'static u32 = &x; //~ ERROR\n   |            ------------   ^^ borrowed value does not live long enough\n   |            |\n   |            type annotation requires that `x` is borrowed for `'static`\n...\nLL | }\n   | - `x` dropped here while still borrowed\n\n"}
[01:05:24] {"message":"temporary value dropped while borrowed","code":{"code":"E0716","explanation":"\nThis error indicates that a temporary value is being dropped\nwhile a borrow is still in active use.\n\nErroneous code example:\n\n```compile_fail,E0716\n# #![feature(nll)]\nfn foo() -> i32 { 22 }\nfn bar(x: &i32) -> &i32 { x }\nlet p = bar(&foo());\n         // ------ creates a temporary\nlet q = *p;\n```\n\nHere, the expression `&foo()` is borrowing the expression\n`foo()`. As `foo()` is call to a function, and not the name of\na variable, this creates a **temporary** -- that temporary stores\nthe return value from `foo()` so that it can be borrowed.\nSo you might imagine that `let p = bar(&foo())` is equivalent\nto this:\n\n```compile_fail,E0597\n# fn foo() -> i32 { 22 }\n# fn bar(x: &i32) -> &i32 { x }\nlet p = {\n  let tmp = foo(); // the temporary\n  bar(&tmp)\n}; // <-- tmp is freed as we exit this block\nlet q = p;\n```\n\nWhenever a temporary is created, it is automatically dropped (freed)\naccording to fixed rules. Ordinarily, the temporary is dropped\nat the end of the enclosing statement -- in this case, after the `let`.\nThis is illustrated in the example above by showing that `tmp` would\nbe freed as we exit the block.\n\nTo fix this problem, you need to create a local variable\nto store the value in rather than relying on a temporary.\nFor example, you might change the original program to\nthe following:\n\n```\nfn foo() -> i32 { 22 }\nfn bar(x: &i32) -> &i32 { x }\nlet value = foo(); // dropped at the end of the enclosing block\nlet p = bar(&value);\nlet q = *p;\n```\n\nBy introducing the explicit `let value`, we allocate storage\nthat will last until the end of the enclosing block (when `value`\ngoes out of scope). When we borrow `&value`, we are borrowing a\nlocal variable that already exists, and hence no temporary is created.\n\nTemporaries are not always dropped at the end of the enclosing\nstatement. In simple cases where the `&` expression is immediately\nstored into a variable, the compiler will automatically extend\nthe lifetime of the temporary until the end of the enclosing\nblock. Therefore, an alternative way to fix the original\nprogram is to write `let tmp = &foo()` and not `let tmp = foo()`:\n\n```\nfn foo() -> i32 { 22 }\nfn bar(x: &i32) -> &i32 { x }\nlet value = &foo();\nlet p = bar(value);\nlet q = *p;\n```\n\nHere, we are still borrowing `foo()`, but as the borrow is assigned\ndirectly into a variable, the temporary will not be dropped until\nthe end of the enclosing block. Similar rules apply when temporaries\nare stored into aggregate structures like a tuple or struct:\n\n```\n// Here, two temporaries are created, but\n// as they are stored directly into `value`,\n// they are not dropped until the end of the\n// enclosing block.\nfn foo() -> i32 { 22 }\nlet value = (&foo(), &foo());\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1276,"byte_end":1289,"line_start":65,"line_end":65,"column_start":41,"column_end":54,"is_primary":true,"text":[{"text":"    let _: Vec<&'static String> = vec![&String::new()];","highlight_start":41,"highlight_end":54}],"label":"creates a temporary which is freed while still in use","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"<::alloc::macros::vec macros>","byte_start":181,"byte_end":182,"line_start":3,"line_end":3,"column_start":67,"column_end":68,"is_primary":false,"text":[{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":67,"highlight_end":68}],"label":"temporary value is freed at the end of this statement","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1270,"byte_end":1290,"line_start":65,"line_end":65,"column_start":35,"column_end":55,"is_primary":false,"text":[{"text":"    let _: Vec<&'static String> = vec![&String::new()];","highlight_start":35,"highlight_end":55}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"vec!","def_site_span":{"file_name":"<::alloc::macros::vec macros>","byte_start":0,"byte_end":242,"line_start":1,"line_end":4,"column_start":1,"column_end":54,"is_primary":false,"text":[{"text":"( $ elem : expr ; $ n : expr ) => (","highlight_start":1,"highlight_end":36},{"text":"$ crate :: vec :: from_elem ( $ elem , $ n ) ) ; ( $ ( $ x : expr ) , * ) => (","highlight_start":1,"highlight_end":79},{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":1,"highlight_end":74},{"text":"$ ( $ x : expr , ) * ) => ( vec ! [ $ ( $ x ) , * ] )","highlight_start":1,"highlight_end":54}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1247,"byte_end":1267,"line_start":65,"line_end":65,"column_start":12,"column_end":32,"is_primary":false,"text":[{"text":"    let _: Vec<&'static String> = vec![&String::new()];","highlight_start":12,"highlight_end":32}],"label":"type annotation requires that borrow lasts for `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0716]: temporary value dropped while borrowed\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:65:41\n   |\nLL |     let _: Vec<&'static String> = vec![&String::new()];\n   |            --------------------   ------^^^^^^^^^^^^^-\n   |            |                      |     |\n   |            |                      |     creates a temporary which is freed while still in use\n   |            |                      temporary value is freed at the end of this statement\n   |            type annotation requires that borrow lasts for `'static`\n   |\n   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)\n\n"}
[01:05:24] {"message":"temporary value dropped while borrowed","code":{"code":"E0716","explanation":"\nThis error indicates that a temporary value is being dropped\nwhile a borrow is still in active use.\n\nErroneous code example:\n\n```compile_fail,E0716\n# #![feature(nll)]\nfn foo() -> i32 { 22 }\nfn bar(x: &i32) -> &i32 { x }\nlet p = bar(&foo());\n         // ------ creates a temporary\nlet q = *p;\n```\n\nHere, the expression `&foo()` is borrowing the expression\n`foo()`. As `foo()` is call to a function, and not the name of\na variable, this creates a **temporary** -- that temporary stores\nthe return value from `foo()` so that it can be borrowed.\nSo you might imagine that `let p = bar(&foo())` is equivalent\nto this:\n\n```compile_fail,E0597\n# fn foo() -> i32 { 22 }\n# fn bar(x: &i32) -> &i32 { x }\nlet p = {\n  let tmp = foo(); // the temporary\n  bar(&tmp)\n}; // <-- tmp is freed as we exit this block\nlet q = p;\n```\n\nWhenever a temporary is created, it is automatically dropped (freed)\naccording to fixed rules. Ordinarily, the temporary is dropped\nat the end of the enclosing statement -- in this case, after the `let`.\nThis is illustrated in the example above by showing that `tmp` would\nbe freed as we exit the block.\n\nTo fix this problem, you need to create a local variable\nto store the value in rather than relying on a temporary.\nFor example, you might change the original program to\nthe following:\n\n```\nfn foo() -> i32 { 22 }\nfn bar(x: &i32) -> &i32 { x }\nlet value = foo(); // dropped at the end of the enclosing block\nlet p = bar(&value);\nlet q = *p;\n```\n\nBy introducing the explicit `let value`, we allocate storage\nthat will last until the end of the enclosing block (when `value`\ngoes out of scope). When we borrow `&value`, we are borrowing a\nlocal variable that already exists, and hence no temporary is created.\n\nTemporaries are not always dropped at the end of the enclosing\nstatement. In simple cases where the `&` expression is immediately\nstored into a variable, the compiler will automatically extend\nthe lifetime of the temporary until the end of the enclosing\nblock. Therefore, an alternative way to fix the original\nprogram is to write `let tmp = &foo()` and not `let tmp = foo()`:\n\n```\nfn foo() -> i32 { 22 }\nfn bar(x: &i32) -> &i32 { x }\nlet value = &foo();\nlet p = bar(value);\nlet q = *p;\n```\n\nHere, we are still borrowing `foo()`, but as the borrow is assigned\ndirectly into a variable, the temporary will not be dropped until\nthe end of the enclosing block. Similar rules apply when temporaries\nare stored into aggregate structures like a tuple or struct:\n\n```\n// Here, two temporaries are created, but\n// as they are stored directly into `value`,\n// they are not dropped until the end of the\n// enclosing block.\nfn foo() -> i32 { 22 }\nlet value = (&foo(), &foo());\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1406,"byte_end":1419,"line_start":68,"line_end":68,"column_start":52,"column_end":65,"is_primary":true,"text":[{"text":"    let (_, a): (Vec<&'static String>, _) = (vec![&String::new()], 44);","highlight_start":52,"highlight_end":65}],"label":"creates a temporary which is freed while still in use","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"<::alloc::macros::vec macros>","byte_start":181,"byte_end":182,"line_start":3,"line_end":3,"column_start":67,"column_end":68,"is_primary":false,"text":[{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":67,"highlight_end":68}],"label":"temporary value is freed at the end of this statement","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1400,"byte_end":1420,"line_start":68,"line_end":68,"column_start":46,"column_end":66,"is_primary":false,"text":[{"text":"    let (_, a): (Vec<&'static String>, _) = (vec![&String::new()], 44);","highlight_start":46,"highlight_end":66}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"vec!","def_site_span":{"file_name":"<::alloc::macros::vec macros>","byte_start":0,"byte_end":242,"line_start":1,"line_end":4,"column_start":1,"column_end":54,"is_primary":false,"text":[{"text":"( $ elem : expr ; $ n : expr ) => (","highlight_start":1,"highlight_end":36},{"text":"$ crate :: vec :: from_elem ( $ elem , $ n ) ) ; ( $ ( $ x : expr ) , * ) => (","highlight_start":1,"highlight_end":79},{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":1,"highlight_end":74},{"text":"$ ( $ x : expr , ) * ) => ( vec ! [ $ ( $ x ) , * ] )","highlight_start":1,"highlight_end":54}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1371,"byte_end":1396,"line_start":68,"line_end":68,"column_start":17,"column_end":42,"is_primary":false,"text":[{"text":"    let (_, a): (Vec<&'static String>, _) = (vec![&String::new()], 44);","highlight_start":17,"highlight_end":42}],"label":"type annotation requires that borrow lasts for `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0716]: temporary value dropped while borrowed\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:68:52\n   |\nLL |     let (_, a): (Vec<&'static String>, _) = (vec![&String::new()], 44);\n   |                 -------------------------    ------^^^^^^^^^^^^^-\n   |                 |                            |     |\n   |                 |                            |     creates a temporary which is freed while still in use\n   |                 |                            temporary value is freed at the end of this statement\n   |                 type annotation requires that borrow lasts for `'static`\n   |\n   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)\n\n"}
[01:05:24] {"message":"temporary value dropped while borrowed","code":{"code":"E0716","explanation":"\nThis error indicates that a temporary value is being dropped\nwhile a borrow is still in active use.\n\nErroneous code example:\n\n```compile_fail,E0716\n# #![feature(nll)]\nfn foo() -> i32 { 22 }\nfn bar(x: &i32) -> &i32 { x }\nlet p = bar(&foo());\n         // ------ creates a temporary\nlet q = *p;\n```\n\nHere, the expression `&foo()` is borrowing the expression\n`foo()`. As `foo()` is call to a function, and not the name of\na variable, this creates a **temporary** -- that temporary stores\nthe return value from `foo()` so that it can be borrowed.\nSo you might imagine that `let p = bar(&foo())` is equivalent\nto this:\n\n```compile_fail,E0597\n# fn foo() -> i32 { 22 }\n# fn bar(x: &i32) -> &i32 { x }\nlet p = {\n  let tmp = foo(); // the temporary\n  bar(&tmp)\n}; // <-- tmp is freed as we exit this block\nlet q = p;\n```\n\nWhenever a temporary is created, it is automatically dropped (freed)\naccording to fixed rules. Ordinarily, the temporary is dropped\nat the end of the enclosing statement -- in this case, after the `let`.\nThis is illustrated in the example above by showing that `tmp` would\nbe freed as we exit the block.\n\nTo fix this problem, you need to create a local variable\nto store the value in rather than relying on a temporary.\nFor example, you might change the original program to\nthe following:\n\n```\nfn foo() -> i32 { 22 }\nfn bar(x: &i32) -> &i32 { x }\nlet value = foo(); // dropped at the end of the enclosing block\nlet p = bar(&value);\nlet q = *p;\n```\n\nBy introducing the explicit `let value`, we allocate storage\nthat will last until the end of the enclosing block (when `value`\ngoes out of scope). When we borrow `&value`, we are borrowing a\nlocal variable that already exists, and hence no temporary is created.\n\nTemporaries are not always dropped at the end of the enclosing\nstatement. In simple cases where the `&` expression is immediately\nstored into a variable, the compiler will automatically extend\nthe lifetime of the temporary until the end of the enclosing\nblock. Therefore, an alternative way to fix the original\nprogram is to write `let tmp = &foo()` and not `let tmp = foo()`:\n\n```\nfn foo() -> i32 { 22 }\nfn bar(x: &i32) -> &i32 { x }\nlet value = &foo();\nlet p = bar(value);\nlet q = *p;\n```\n\nHere, we are still borrowing `foo()`, but as the borrow is assigned\ndirectly into a variable, the temporary will not be dropped until\nthe end of the enclosing block. Similar rules apply when temporaries\nare stored into aggregate structures like a tuple or struct:\n\n```\n// Here, two temporaries are created, but\n// as they are stored directly into `value`,\n// they are not dropped until the end of the\n// enclosing block.\nfn foo() -> i32 { 22 }\nlet value = (&foo(), &foo());\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1542,"byte_end":1555,"line_start":71,"line_end":71,"column_start":53,"column_end":66,"is_primary":true,"text":[{"text":"    let (_a, b): (Vec<&'static String>, _) = (vec![&String::new()], 44);","highlight_start":53,"highlight_end":66}],"label":"creates a temporary which is freed while still in use","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"<::alloc::macros::vec macros>","byte_start":181,"byte_end":182,"line_start":3,"line_end":3,"column_start":67,"column_end":68,"is_primary":false,"text":[{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":67,"highlight_end":68}],"label":"temporary value is freed at the end of this statement","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1536,"byte_end":1556,"line_start":71,"line_end":71,"column_start":47,"column_end":67,"is_primary":false,"text":[{"text":"    let (_a, b): (Vec<&'static String>, _) = (vec![&String::new()], 44);","highlight_start":47,"highlight_end":67}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"vec!","def_site_span":{"file_name":"<::alloc::macros::vec macros>","byte_start":0,"byte_end":242,"line_start":1,"line_end":4,"column_start":1,"column_end":54,"is_primary":false,"text":[{"text":"( $ elem : expr ; $ n : expr ) => (","highlight_start":1,"highlight_end":36},{"text":"$ crate :: vec :: from_elem ( $ elem , $ n ) ) ; ( $ ( $ x : expr ) , * ) => (","highlight_start":1,"highlight_end":79},{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":1,"highlight_end":74},{"text":"$ ( $ x : expr , ) * ) => ( vec ! [ $ ( $ x ) , * ] )","highlight_start":1,"highlight_end":54}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1507,"byte_end":1532,"line_start":71,"line_end":71,"column_start":18,"column_end":43,"is_primary":false,"text":[{"text":"    let (_a, b): (Vec<&'static String>, _) = (vec![&String::new()], 44);","highlight_start":18,"highlight_end":43}],"label":"type annotation requires that borrow lasts for `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0716]: temporary value dropped while borrowed\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:71:53\n   |\nLL |     let (_a, b): (Vec<&'static String>, _) = (vec![&String::new()], 44);\n   |                  -------------------------    ------^^^^^^^^^^^^^-\n   |                  |                            |     |\n   |                  |                            |     creates a temporary which is freed while still in use\n   |                  |                            temporary value is freed at the end of this statement\n   |                  type annotation requires that borrow lasts for `'static`\n   |\n   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)\n\n"}
[01:05:24] {"message":"`x` 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":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1724,"byte_end":1726,"line_start":77,"line_end":77,"column_start":40,"column_end":42,"is_primary":true,"text":[{"text":"    let (_, _): (&'static u32, u32) = (&x, 44); //~ ERROR","highlight_start":40,"highlight_end":42}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1743,"byte_end":1744,"line_start":78,"line_end":78,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"`x` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1701,"byte_end":1720,"line_start":77,"line_end":77,"column_start":17,"column_end":36,"is_primary":false,"text":[{"text":"    let (_, _): (&'static u32, u32) = (&x, 44); //~ ERROR","highlight_start":17,"highlight_end":36}],"label":"type annotation requires that `x` is borrowed for `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `x` does not live long enough\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:77:40\n   |\nLL |     let (_, _): (&'static u32, u32) = (&x, 44); //~ ERROR\n   |                 -------------------    ^^ borrowed value does not live long enough\n   |                 |\n   |                 type annotation requires that `x` is borrowed for `'static`\nLL | }\n   | - `x` dropped here while still borrowed\n\n"}
[01:05:24] {"message":"`x` 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":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1839,"byte_end":1841,"line_start":82,"line_end":82,"column_start":40,"column_end":42,"is_primary":true,"text":[{"text":"    let (y, _): (&'static u32, u32) = (&x, 44); //~ ERROR","highlight_start":40,"highlight_end":42}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1858,"byte_end":1859,"line_start":83,"line_end":83,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"`x` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1816,"byte_end":1835,"line_start":82,"line_end":82,"column_start":17,"column_end":36,"is_primary":false,"text":[{"text":"    let (y, _): (&'static u32, u32) = (&x, 44); //~ ERROR","highlight_start":17,"highlight_end":36}],"label":"type annotation requires that `x` is borrowed for `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `x` does not live long enough\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:82:40\n   |\nLL |     let (y, _): (&'static u32, u32) = (&x, 44); //~ ERROR\n   |                 -------------------    ^^ borrowed value does not live long enough\n   |                 |\n   |                 type annotation requires that `x` is borrowed for `'static`\nLL | }\n   | - `x` dropped here while still borrowed\n\n"}
[01:05:24] {"message":"`x` 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":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1998,"byte_end":2000,"line_start":87,"line_end":87,"column_start":69,"column_end":71,"is_primary":true,"text":[{"text":"    let Single { value: y }: Single<&'static u32> = Single { value: &x }; //~ ERROR","highlight_start":69,"highlight_end":71}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":2014,"byte_end":2015,"line_start":88,"line_end":88,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"`x` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":1959,"byte_end":1979,"line_start":87,"line_end":87,"column_start":30,"column_end":50,"is_primary":false,"text":[{"text":"    let Single { value: y }: Single<&'static u32> = Single { value: &x }; //~ ERROR","highlight_start":30,"highlight_end":50}],"label":"type annotation requires that `x` is borrowed for `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `x` does not live long enough\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:87:69\n   |\nLL |     let Single { value: y }: Single<&'static u32> = Single { value: &x }; //~ ERROR\n   |                              --------------------                   ^^ borrowed value does not live long enough\n   |                              |\n   |                              type annotation requires that `x` is borrowed for `'static`\nLL | }\n   | - `x` dropped here while still borrowed\n\n"}
[01:05:24] {"message":"`x` 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":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":2156,"byte_end":2158,"line_start":92,"line_end":92,"column_start":69,"column_end":71,"is_primary":true,"text":[{"text":"    let Single { value: _ }: Single<&'static u32> = Single { value: &x }; //~ ERROR","highlight_start":69,"highlight_end":71}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":2172,"byte_end":2173,"line_start":93,"line_end":93,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"`x` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":2117,"byte_end":2137,"line_start":92,"line_end":92,"column_start":30,"column_end":50,"is_primary":false,"text":[{"text":"    let Single { value: _ }: Single<&'static u32> = Single { value: &x }; //~ ERROR","highlight_start":30,"highlight_end":50}],"label":"type annotation requires that `x` is borrowed for `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `x` does not live long enough\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:92:69\n   |\nLL |     let Single { value: _ }: Single<&'static u32> = Single { value: &x }; //~ ERROR\n   |                              --------------------                   ^^ borrowed value does not live long enough\n   |                              |\n   |                              type annotation requires that `x` is borrowed for `'static`\nLL | }\n   | - `x` dropped here while still borrowed\n\n"}
[01:05:24] {"message":"`x` 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":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":2378,"byte_end":2380,"line_start":100,"line_end":100,"column_start":17,"column_end":19,"is_primary":true,"text":[{"text":"        value1: &x, //~ ERROR","highlight_start":17,"highlight_end":19}],"label":"borrowed value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":2420,"byte_end":2421,"line_start":103,"line_end":103,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"`x` dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":2330,"byte_end":2350,"line_start":99,"line_end":99,"column_start":42,"column_end":62,"is_primary":false,"text":[{"text":"    let Double { value1: _, value2: _ }: Double<&'static u32> = Double {","highlight_start":42,"highlight_end":62}],"label":"type annotation requires that `x` is borrowed for `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: `x` does not live long enough\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:100:17\n   |\nLL |     let Double { value1: _, value2: _ }: Double<&'static u32> = Double {\n   |                                          -------------------- type annotation requires that `x` is borrowed for `'static`\nLL |         value1: &x, //~ ERROR\n   |                 ^^ borrowed value does not live long enough\n...\nLL | }\n   | - `x` dropped here while still borrowed\n\n"}
[01:05:24] {"message":"lifetime may not live long enough","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":2465,"byte_end":2467,"line_start":105,"line_end":105,"column_start":43,"column_end":45,"is_primary":false,"text":[{"text":"fn static_to_a_to_static_through_variable<'a>(x: &'a u32) -> &'static u32 {","highlight_start":43,"highlight_end":45}],"label":"lifetime `'a` defined here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":2535,"byte_end":2536,"line_start":113,"line_end":113,"column_start":5,"column_end":6,"is_primary":true,"text":[{"text":"    y //~ ERROR","highlight_start":5,"highlight_end":6}],"label":"returning this value requires that `'a` must outlive `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: lifetime may not live long enough\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:113:5\n   |\nLL | fn static_to_a_to_static_through_variable<'a>(x: &'a u32) -> &'static u32 {\n   |                                           -- lifetime `'a` defined here\n...\nLL |     y //~ ERROR\n   |     ^ returning this value requires that `'a` must outlive `'static`\n\n"}
[01:05:24] {"message":"lifetime may not live long enough","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":2589,"byte_end":2591,"line_start":116,"line_end":116,"column_start":40,"column_end":42,"is_primary":false,"text":[{"text":"fn static_to_a_to_static_through_tuple<'a>(x: &'a u32) -> &'static u32 {","highlight_start":40,"highlight_end":42}],"label":"lifetime `'a` defined here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":2679,"byte_end":2680,"line_start":125,"line_end":125,"column_start":5,"column_end":6,"is_primary":true,"text":[{"text":"    y //~ ERROR","highlight_start":5,"highlight_end":6}],"label":"returning this value requires that `'a` must outlive `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: lifetime may not live long enough\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:125:5\n   |\nLL | fn static_to_a_to_static_through_tuple<'a>(x: &'a u32) -> &'static u32 {\n   |                                        -- lifetime `'a` defined here\n...\nLL |     y //~ ERROR\n   |     ^ returning this value requires that `'a` must outlive `'static`\n\n"}
[01:05:24] {"message":"lifetime may not live long enough","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":2734,"byte_end":2736,"line_start":128,"line_end":128,"column_start":41,"column_end":43,"is_primary":false,"text":[{"text":"fn static_to_a_to_static_through_struct<'a>(_x: &'a u32) -> &'static u32 {","highlight_start":41,"highlight_end":43}],"label":"lifetime `'a` defined here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":2843,"byte_end":2844,"line_start":130,"line_end":130,"column_start":5,"column_end":6,"is_primary":true,"text":[{"text":"    y //~ ERROR","highlight_start":5,"highlight_end":6}],"label":"returning this value requires that `'a` must outlive `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: lifetime may not live long enough\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:130:5\n   |\nLL | fn static_to_a_to_static_through_struct<'a>(_x: &'a u32) -> &'static u32 {\n   |                                         -- lifetime `'a` defined here\nLL |     let Single { value: y }: Single<&'a u32> = Single { value: &22 };\nLL |     y //~ ERROR\n   |     ^ returning this value requires that `'a` must outlive `'static`\n\n"}
[01:05:24] {"message":"lifetime may not live long enough","code":null,"level":"error","spans":[{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":2885,"byte_end":2887,"line_start":133,"line_end":133,"column_start":28,"column_end":30,"is_primary":false,"text":[{"text":"fn a_to_static_then_static<'a>(x: &'a u32) -> &'static u32 {","highlight_start":28,"highlight_end":30}],"label":"lifetime `'a` defined here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/nll/user-annotations/patterns.rs","byte_start":2936,"byte_end":2955,"line_start":134,"line_end":134,"column_start":18,"column_end":37,"is_primary":true,"text":[{"text":"    let (y, _z): (&'static u32, u32) = (x, 44); //~ ERROR","highlight_start":18,"highlight_end":37}],"label":"type annotation requires that `'a` must outlive `'static`","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error: lifetime may not live long enough\n  --> /checkout/src/test/ui/nll/user-annotations/patterns.rs:134:18\n   |\nLL | fn a_to_static_then_static<'a>(x: &'a u32) -> &'static u32 {\n   |                            -- lifetime `'a` defined here\nLL |     let (y, _z): (&'static u32, u32) = (x, 44); //~ ERROR\n   |                  ^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static`\n\n"}
[01:05:24] {"message":"aborting due to 19 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 19 previous errors\n\n"}
[01:05:24] {"message":"Some errors occurred: E0597, E0716.","code":null,"level":"","spans":[],"children":[],"rendered":"Some errors occurred: E0597, E0716.\n"}
[01:05:24] 
[01:05:24] ------------------------------------------
[01:05:24] 
[01:05:24] thread '[ui] ui/nll/user-annotations/patterns.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3295:9
[01:05:24] thread '[ui] ui/nll/user-annotations/patterns.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3295:9
[01:05:24] 
[01:05:24] ---- [ui] ui/span/issue-15480.rs stdout ----
[01:05:24] diff of stderr:
[01:05:24] 
[01:05:24] 1 error[E0597]: borrowed value does not live long enough
[01:05:24] 3    |
[01:05:24] 3    |
[01:05:24] - LL |         &id(3)
[01:05:24] -    |          ^^^^^ temporary valsting" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/span/issue-15480/a" "-Crpath" "-O" "-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/span/issue-15480/auxiliary" "-A" "unused"
[01:05:24] ------------------------------------------
[01:05:24] 
[01:05:24] ------------------------------------------
[01:05:24] stderr:
[01:05:24] stderr:
[01:05:24] ------------------------------------------
[01:05:24] {"message":"borrowed value 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":"error","spans":[{"file_name":"/checkout/src/test/ui/span/issue-15480.rs","byte_start":66,"byte_end":71,"line_start":5,"line_end":5,"column_start":10,"column_end":15,"is_primary":true,"text":[{"text":"        &id(3)","highlight_start":10,"highlight_end":15}],"label":"temporary value does not live long enough","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"<::alloc::macros::vec macros>","byte_start":181,"byte_end":182,"line_start":3,"line_end":3,"column_start":67,"column_end":68,"is_primary":false,"text":[{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":67,"highlight_end":68}],"label":"temporary value dropped here while still borrowed","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/span/issue-15480.rs","byte_start":51,"byte_end":77,"line_start":4,"line_end":6,"column_start":13,"column_end":6,"is_primary":false,"text":[{"text":"    let v = vec![","highlight_start":13,"highlight_end":18},{"text":"        &id(3)","highlight_start":1,"highlight_end":15},{"text":"    ];","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"vec!","def_site_span":{"file_name":"<::alloc::macros::vec macros>","byte_start":0,"byte_end":242,"line_start":1,"line_end":4,"column_start":1,"column_end":54,"is_primary":false,"text":[{"text":"( $ elem : expr ; $ n : expr ) => (","highlight_start":1,"highlight_end":36},{"text":"$ crate :: vec :: from_elem ( $ elem , $ n ) ) ; ( $ ( $ x : expr ) , * ) => (","highlight_start":1,"highlight_end":79},{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":1,"highlight_end":74},{"text":"$ ( $ x : expr , ) * ) => ( vec ! [ $ ( $ x ) , * ] )","highlight_start":1,"highlight_end":54}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"/checkout/src/test/ui/span/issue-15480.rs","byte_start":194,"byte_end":195,"line_start":12,"line_end":12,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"temporary value needs to live until here","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0597]: borrowed value does not live long enough\n  --> /checkout/src/test/ui/span/issue-15480.rs:5:10\n   |\nLL |       let v = vec![\n   |  _____________-\nLL | |         &id(3)\n   | |          ^^^^^ temporary value does not live long enough\nLL | |     ];\n   | |_____- temporary value dropped here while still borrowed\n...\nLL |   }\n   |   - temporary value needs to live until here\n   |\n   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)\n\n"}
[01:05:24] {"message":"For more information about this error, try `rustc --explain E0597`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0597`.\n"}
[01:05:24] 
[01:05:24] ------------------------------------------
[01:05:24] 
---
[01:05:24] 4 LL |     let x = vec![];
[01:05:24] -    |         -   ^^^^^^ cannot infer type for `T`
[01:05:24] +    |         -   ^^^^^^ cannot infer type
[01:05:24] 6    |         |
[01:05:24] 7    |         consider giving `x` a type
[01:05:24] 
[01:05:24] 
[01:05:24] The actual stderr differed from the expected stderr.
[01:05:24] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/type/type-check/cannot_infer_local_or_vec/cannot_infer_local_or_vec.stderr
[01:05:24] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/type/type-check/cannot_infer_local_or_vec/cannot_infer_local_or_vec.stderr
[01:05:24] To update references, rerun the tests and pass the `--bless` flag
[01:05:24] To only update this specific test, also pass `--test-args type/type-check/cannot_infer_local_or_vec.rs`
[01:05:24] error: 1 errors occurred comparing output.
[01:05:24] status: exit code: 1
[01:05:24] status: exit code: 1
[01:05:24] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/type/type-check/cannot_infer_local_or_vec.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/type/type-check/cannot_infer_local_or_vec/a" "-Crpath" "-O" "-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/type/type-check/cannot_infer_local_or_vec/auxiliary" "-A" "unused"
[01:05:24] ------------------------------------------
[01:05:24] 
[01:05:24] ------------------------------------------
[01:05:24] stderr:
[01:05:24] stderr:
[01:05:24] ------------------------------------------
[01:05:24] {"message":"type annotations needed","code":{"code":"E0282","explanation":"\nThis error indicates that type inference did not result in one unique possible\ntype, and extra information is required. In most cases this can be provided\nby adding a type annotation. Sometimes you need to specify a generic type\nparameter manually.\n\nA common example is the `collect` method on `Iterator`. It has a generic type\nparameter with a `FromIterator` bound, which for a `char` iterator is\nimplemented by `Vec` and `String` among others. Consider the following snippet\nthat reverses the characters of a string:\n\n```compile_fail,E0282\nlet x = \"hello\".chars().rev().collect();\n```\n\nIn this case, the compiler cannot infer what the type of `x` should be:\n`Vec<char>` and `String` are both suitable candidates. To specify which type to\nuse, you can use a type annotation on `x`:\n\n```\nlet x: Vec<char> = \"hello\".chars().rev().collect();\n```\n\nIt is not necessary to annotate the full type. Once the ambiguity is resolved,\nthe compiler can infer the rest:\n\n```\nlet x: Vec<_> = \"hello\".chars().rev().collect();\n```\n\nAnother way to provide the compiler with enough information, is to specify the\ngeneric type parameter:\n\n```\nlet x = \"hello\".chars().rev().collect::<Vec<char>>();\n```\n\nAgain, you need not specify the full type if the compiler can infer it:\n\n```\nlet x = \"hello\".chars().rev().collect::<Vec<_>>();\n```\n\nApart from a method or function with a generic type parameter, this error can\noccur when a type parameter of a struct or trait cannot be inferred. In that\ncase it is not always possible to use a type annotation, because all candidates\nhave the same return type. For instance:\n\n```compile_fail,E0282\nstruct Foo<T> {\n    num: T,\n}\n\nimpl<T> Foo<T> {\n    fn bar() -> i32 {\n        0\n    }\n\n    fn baz() {\n        let number = Foo::bar();\n    }\n}\n```\n\nThis will fail because the compiler does not know which instance of `Foo` to\ncall `bar` on. Change `Foo::bar()` to `Foo::<T>::bar()` to resolve the error.\n"},"level":"error","spans":[{"file_name":"<::alloc::macros::vec macros>","byte_start":127,"byte_end":144,"line_start":3,"line_end":3,"column_start":13,"column_end":30,"is_primary":true,"text":[{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":13,"highlight_end":30}],"label":"cannot infer type","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/type/type-check/cannot_infer_local_or_vec.rs","byte_start":24,"byte_end":30,"line_start":2,"line_end":2,"column_start":13,"column_end":19,"is_primary":false,"text":[{"text":"    let x = vec![];","highlight_start":13,"highlight_end":19}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"vec!","def_site_span":{"file_name":"<::alloc::macros::vec macros>","byte_start":0,"byte_end":242,"line_start":1,"line_end":4,"column_start":1,"column_end":54,"is_primary":false,"text":[{"text":"( $ elem : expr ; $ n : expr ) => (","highlight_start":1,"highlight_end":36},{"text":"$ crate :: vec :: from_elem ( $ elem , $ n ) ) ; ( $ ( $ x : expr ) , * ) => (","highlight_start":1,"highlight_end":79},{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":1,"highlight_end":74},{"text":"$ ( $ x : expr , ) * ) => ( vec ! [ $ ( $ x ) , * ] )","highlight_start":1,"highlight_end":54}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"/checkout/src/test/ui/type/type-check/cannot_infer_local_or_vec.rs","byte_start":20,"byte_end":21,"line_start":2,"line_end":2,"column_start":9,"column_end":10,"is_primary":false,"text":[{"text":"    let x = vec![];","highlight_start":9,"highlight_end":10}],"label":"consider giving `x` a type","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0282]: type annotations needed\n  --> /checkout/src/test/ui/type/type-check/cannot_infer_local_or_vec.rs:2:13\n   |\nLL |     let x = vec![];\n   |         -   ^^^^^^ cannot infer type\n   |         |\n   |         consider giving `x` a type\n   |\n   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)\n\n"}
[01:05:24] {"message":"For more information about this error, try `rustc --explain E0282`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0282`.\n"}
[01:05:24] 
[01:05:24] ------------------------------------------
[01:05:24] 
[01:05:24] 
[01:05:24] thread '[ui] ui/type/type-check/cannot_infer_local_or_vec.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3295:9
[01:05:24] 
[01:05:24] ---- [ui] ui/type/type-check/cannot_infer_local_or_vec_in_tuples.rs stdout ----
[01:05:24] diff of stderr:
[01:05:24] 
[01:05:24] 2   --> $DIR/cannot_infer_local_or_vec_in_tuples.rs:2:18
[01:05:24] 3    |
[01:05:24] 4 LL |     let (x, ) = (vec![], );
[01:05:24] -    |         -----    ^^^^^^ cannot infer type for `T`
[01:05:24] 6    |         |
[01:05:24] 7    |         consider giving the pattern a type
[01:05:24] 8    |
[01:05:24] 
[01:05:24] 
[01:05:24] 
[01:05:24] The actual stderr differed from the expected stderr.
[01:05:24] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples/cannot_infer_local_or_vec_in_tuples.stderr
[01:05:24] To update references, rerun the tests and pass the `--bless` flag
[01:05:24] To only update this specific test, also pass `--test-args type/type-check/cannot_infer_local_or_vec_in_tuples.rs`
[01:05:24] error: 1 errors occurred comparing output.
[01:05:24] status: exit code: 1
[01:05:24] status: exit code: 1
[01:05:24] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.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/type/type-check/cannot_infer_local_or_vec_in_tuples/a" "-Crpath" "-O" "-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/type/type-check/cannot_infer_local_or_vec_in_tuples/auxiliary" "-A" "unused"
[01:05:24] ------------------------------------------
[01:05:24] 
[01:05:24] ------------------------------------------
[01:05:24] stderr:
[01:05:24] stderr:
[01:05:24] ------------------------------------------
[01:05:24] {"message":"type annotations needed","code":{"code":"E0282","explanation":"\nThis error indicates that type inference did not result in one unique possible\ntype, and extra information is required. In most cases this can be provided\nby adding a type annotation. Sometimes you need to specify a generic type\nparameter manually.\n\nA common example is the `collect` method on `Iterator`. It has a generic type\nparameter with a `FromIterator` bound, which for a `char` iterator is\nimplemented by `Vec` and `String` among others. Consider the following snippet\nthat reverses the characters of a string:\n\n```compile_fail,E0282\nlet x = \"hello\".chars().rev().collect();\n```\n\nIn this case, the compiler cannot infer what the type of `x` should be:\n`Vec<char>` and `String` are both suitable candidates. To specify which type to\nuse, you can use a type annotation on `x`:\n\n```\nlet x: Vec<char> = \"hello\".chars().rev().collect();\n```\n\nIt is not necessary to annotate the full type. Once the ambiguity is resolved,\nthe compiler can infer the rest:\n\n```\nlet x: Vec<_> = \"hello\".chars().rev().collect();\n```\n\nAnother way to provide the compiler with enough information, is to specify the\ngeneric type parameter:\n\n```\nlet x = \"hello\".chars().rev().collect::<Vec<char>>();\n```\n\nAgain, you need not specify the full type if the compiler can infer it:\n\n```\nlet x = \"hello\".chars().rev().collect::<Vec<_>>();\n```\n\nApart from a method or function with a generic type parameter, this error can\noccur when a type parameter of a struct or trait cannot be inferred. In that\ncase it is not always possible to use a type annotation, because all candidates\nhave the same return type. For instance:\n\n```compile_fail,E0282\nstruct Foo<T> {\n    num: T,\n}\n\nimpl<T> Foo<T> {\n    fn bar() -> i32 {\n        0\n    }\n\n    fn baz() {\n        let number = Foo::bar();\n    }\n}\n```\n\nThis will fail because the compiler does not know which instance of `Foo` to\ncall `bar` on. Change `Foo::bar()` to `Foo::<T>::bar()` to resolve the error.\n"},"level":"error","spans":[{"file_name":"<::alloc::macros::vec macros>","byte_start":127,"byte_end":144,"line_start":3,"line_end":3,"column_start":13,"column_end":30,"is_primary":true,"text":[{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":13,"highlight_end":30}],"label":"cannot infer type","suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.rs","byte_start":29,"byte_end":35,"line_start":2,"line_end":2,"column_start":18,"column_end":24,"is_primary":false,"text":[{"text":"    let (x, ) = (vec![], );","highlight_start":18,"highlight_end":24}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"vec!","def_site_span":{"file_name":"<::alloc::macros::vec macros>","byte_start":0,"byte_end":242,"line_start":1,"line_end":4,"column_start":1,"column_end":54,"is_primary":false,"text":[{"text":"( $ elem : expr ; $ n : expr ) => (","highlight_start":1,"highlight_end":36},{"text":"$ crate :: vec :: from_elem ( $ elem , $ n ) ) ; ( $ ( $ x : expr ) , * ) => (","highlight_start":1,"highlight_end":79},{"text":"{ let tmp = [ $ ( $ x ) , * ] ; < [ _ ] > :: into_vec ( box tmp ) } ) ; (","highlight_start":1,"highlight_end":74},{"text":"$ ( $ x : expr , ) * ) => ( vec ! [ $ ( $ x ) , * ] )","highlight_start":1,"highlight_end":54}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},{"file_name":"/checkout/src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.rs","byte_start":20,"byte_end":25,"line_start":2,"line_end":2,"column_start":9,"column_end":14,"is_primary":false,"text":[{"text":"    let (x, ) = (vec![], );","highlight_start":9,"highlight_end":14}],"label":"consider giving the pattern a type","suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[],"rendered":"error[E0282]: type annotations needed\n  --> /checkout/src/test/ui/type/type-check/cannot_infer_local_or_vec_in_tuples.rs:2:18\n   |\nLL |     let (x, ) = (vec![], );\n   |         -----    ^^^^^^ cannot infer type\n   |         |\n   |         consider giving the pattern a type\n   |\n   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)\n\n"}
[01:05:24] {"message":"For more information about this error, try `rustc --explain E0282`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0282`.\n"}
[01:05:24] 
[01:05:24] ------------------------------------------
[01:05:24] 
---
[01:05:24] 
[01:05:24] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:496:22
[01:05:24] 
[01:05:24] 
[01:05:24] 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" "/usr/lib/llvm-6.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -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" "--quiet" "--llvm-version" "6.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:05:24] 
[01:05:24] 
[01:05:24] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:05:24] Build completed unsuccessfully in 0:04:13
[01:05:24] Build completed unsuccessfully in 0:04:13
[01:05:24] Makefile:48: recipe for target 'check' failed
[01:05:24] make: *** [check] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:2e9a7ae5
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Mon Feb 11 17:16:30 UTC 2019
---
travis_time:end:14b08693:start=1549905392090445099,finish=1549905392098303916,duration=7858817
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:086f3dc3
$ 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:00a822f8
$ 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)

//
// See the `macro_fn_pointer_coercion` test.
let tmp = [$($x),*];
<[_]>::into_vec(box tmp)

This comment has been minimized.

@scottmcm

scottmcm Feb 11, 2019

Member

Possibly-silly question: now that there's a temporary, is box syntax gaining us anything over using Box::new? Is there a chance that some code that was making too-big-for-the-stack Vecs with this will no longer work?

This comment has been minimized.

@scottmcm

scottmcm Feb 11, 2019

Member

Alternatively, is this something that should be fixed in the compiler about box syntax? Or is that dead enough that we should just stop ever using the keyword in the library?

This comment has been minimized.

@LukasKalbertodt

LukasKalbertodt Feb 12, 2019

Author Contributor

Good point. I guess people could use vec! with data too big for the stack, so we shouldn't change this as it might break code. I don't think there is a way to easily fix that, so I will close this PR.

The correct way would be to fix box, I guess. But I heard it's not gonna land in this form anyway, so we might also just ignore this obscure function-pointer problem for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment