Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rollup of 16 pull requests #58766

Closed
wants to merge 40 commits into from
Closed

Rollup of 16 pull requests #58766

wants to merge 40 commits into from

Conversation

Centril
Copy link
Contributor

@Centril Centril commented Feb 27, 2019

Successful merges:

Failed merges:

r? @ghost

euclio and others added 30 commits February 19, 2019 15:27
Report all unused attributes on a given doc comment instead of just the
first one, and extend the span of sugared doc comments to encompass the
whole comment.
Report the diagnostic on macro expansions, and add a label indicating
why the comment is unused.
Fix style issues and update diagnostic messages

Update src/librustc_passes/diagnostics.rs

Co-Authored-By: doctorn <me@nathancorbyn.com>

Deny nested `async fn` in Rust 2015 edition

Deny nested `async fn` in Rust 2015 edition

Deny nested `async fn` in Rust 2015 edition
* A number of `Stdio` related doc examples include running the "rev"
command to illustrate piping commands. The majority of these tests are
marked as `no_run` except for two tests which were not
* Not running these tests is unlikely to cause any negative impact, and
doing so also allows the test suite to pass in environments where the
"rev" command is unavailable
I wondered what the `<<!` operator is although the exclamation mark was
only the end of the sentence.
This is required at the very least in order to evaluate associated
constants for arrays (see rust-lang#58212).
Signed-off-by: Adonis <adonis.settouf@gmail.com>

Update src/libsyntax/ext/tt/quoted.rs

Co-Authored-By: asettouf <adonis.settouf@gmail.com>

Update src/libsyntax/ext/tt/quoted.rs

Co-Authored-By: asettouf <adonis.settouf@gmail.com>

Update src/libsyntax/ext/tt/quoted.rs

Co-Authored-By: asettouf <adonis.settouf@gmail.com>

Update src/libsyntax/ext/tt/quoted.rs

Co-Authored-By: asettouf <adonis.settouf@gmail.com>

Update src/libsyntax/ext/tt/quoted.rs

Co-Authored-By: asettouf <adonis.settouf@gmail.com>

Update src/libsyntax/ext/tt/quoted.rs

Co-Authored-By: asettouf <adonis.settouf@gmail.com>

Update src/test/ui/macros/macro-at-most-once-rep-2015-ques-rep.stderr

Co-Authored-By: asettouf <adonis.settouf@gmail.com>

Update src/test/ui/macros/macro-at-most-once-rep-2015-ques-rep.stderr

Co-Authored-By: asettouf <adonis.settouf@gmail.com>

Stabilize split_ascii_whitespace

Tracking issue FCP to merge: rust-lang#48656 (comment)

fix stabilization order of uniform_paths.

hir: add HirId to main Hir nodes

Fix `std::os::fortanix_sgx::usercalls::raw::UsercallNrs`

Fixes fortanix/rust-sgx#88

Update src/libsyntax/ext/tt/quoted.rs

Co-Authored-By: asettouf <adonis.settouf@gmail.com>

Revert "Merge remote-tracking branch 'upstream/master'"

This reverts commit 751f05bd155e2c55d4177fe8211df634faf3a644, reversing
changes made to 545a3e62b0cb473108869a61b271bc589afb49da.
…ebank

overhaul unused doc comments lint

This PR contains a number of improvements to the `unused_doc_comments` lint.

- Extends the span to cover the entire comment when using sugared doc comments.
- Triggers the lint for all unused doc comments on a node, instead of just the first one.
- Triggers the lint on macro expansions, and provides a help note explaining that doc comments must be expanded by the macro.
- Adds a label pointing at the node that cannot be documented.

Furthermore, this PR fixes any instances in rustc where a macro expansion was erroneously documented.
Fix for issue  rust-lang#58050

Hi,

a quick PR to mention in the compiler error message that `?` is a macro operator, as according to issue rust-lang#58050

It passed `python x.py test src/tools/tidy`  locally, as well as the recommendation to run `/x.py test src/test/ui --stage 1 --bless`.

Let me know if anything else is needed.
…isdreavus

rustdoc: move collapse and unindent docs passes earlier

Moves these passes as early as possible so later passes will see the same markdown that is passed to the test collector.

Fixes rust-lang#58473, and a similar issue with the private-doc-tests lint.

r? @QuietMisdreavus
rust-lldb: fix crash when printing empty string

Fixes rust-lang#52185.

~Re-enables the pretty-std debuginfo test and tweaks the test as necessary to get it to pass again. This reveals that lldb's formatting of enums is broken (rust-lang#58492). I also removed the emoji from the test because I couldn't get the docker image's gdb to print the emoji, just octal escapes (https://github.com/rust-lang/rust/pull/53154/files#r208263904).~
…rochenkov

Make `visit_clobber` panic-safe.

Local measurements indicate the performance effect is negligible.

r? @petrochenkov
…n, r=varkor

Deny `async fn` in 2015 edition

This commit prevents code using `async fn` from being compiled in Rust 2015 edition.

Compiling code of the form:

```rust
async fn foo() {}
```

Will now result in the error:

```
error[E0670]: `async fn` is not permitted in the 2015 edition
 --> async.rs:1:1
  |
1 | async fn foo() {}
  | ^^^^^

error: aborting due to error

For more information about an error, try `rustc --explain E0670`.
```

This resolves rust-lang#58652 and also resolves rust-lang#53714.

r? @varkor
…crichton

Fix an indexing error when using `x.py help`

Fixes rust-lang#58640.
Fix copy-pasted typo for read_string return value
std: docs: Disable running several Stdio doctests

* A number of `Stdio` related doc examples include running the "rev"
command to illustrate piping commands. The majority of these tests are
marked as `no_run` except for two tests which were not
* Not running these tests is unlikely to cause any negative impact, and
doing so also allows the test suite to pass in environments where the
"rev" command is unavailable
update scoped_tls to 1.0

scoped_tls has been updated to version 1.0
This PR will hopefully merge flawlessly :)

This fixes, among others, alexcrichton/scoped-tls#9

Note, that the nightly feature has been removed in alexcrichton/scoped-tls@64bd7b8
Make `Unique::as_ptr`, `NonNull::dangling` and `NonNull::cast` const
…, r=alexcrichton

Update string_cache_codegen to 0.4.2

This removes two dependencies of the old version (string_cache is already the latest version).
Clarify `rotate_{left,right}` docs

I wondered what the `<<!` operator is although the exclamation mark was
only the end of the sentence.
Normalize the type Self resolves to in an impl

This is required at the very least in order to evaluate associated
constants for arrays.

Fixes rust-lang#57796
Fixes rust-lang#58212.

r? @oli-obk
cc @hellow554
@Centril
Copy link
Contributor Author

Centril commented Feb 27, 2019

@bors r+ p=16

@bors
Copy link
Contributor

bors commented Feb 27, 2019

📌 Commit 2055bff has been approved by Centril

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

bors commented Feb 27, 2019

⌛ Testing commit 2055bff with merge 9299a514d5014d4fc8293e30295a0a7c102189bc...

@bors
Copy link
Contributor

bors commented Feb 27, 2019

💔 Test failed - status-appveyor

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

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

Click to expand the log.
[01:38:49] 
[01:38:49] ---- [ui (nll)] ui/consts/const-ptr-unique.rs stdout ----
[01:38:49] diff of stderr:
[01:38:49] 
[01:38:49] - error[E0597]: borrowed value does not live long enough
[01:38:49] + error[E0716]: temporary value dropped while borrowed
[01:38:49] 2   --> $DIR/const-ptr-unique.rs:8:33
[01:38:49] 3    |
[01:38:49] 4 LL |     let x: &'static *mut u32 = &(unique.as_ptr());
[01:38:49] 
[01:38:49] -    |                                 ^^^^^^^^^^^^^^^^^ temporary value does not live long enough
[01:38:49] +    |            -----------------    ^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
[01:38:49] +    |            type annotation requires that borrow lasts for `'static`
[01:38:49] +    |            type annotation requires that borrow lasts for `'static`
[01:38:49] 6 LL |     //~^ ERROR borrowed value does not live long enough
[01:38:49] 7 LL | }
[01:38:49] -    | - temporary value only lives until here
[01:38:49] -    |
[01:38:49] -    = note: borrowed value must be valid for the static lifetime...
[01:38:49] +    | - temporary value is freed at the end of this statement
[01:38:49] 12 error: aborting due to previous error
[01:38:49] 13 
[01:38:49] 
[01:38:49] - For more information about this error, try `rustc --explain E0597`.
[01:38:49] - For more information about this error, try `rustc --explain E0597`.
[01:38:49] + For more information about this error, try `rustc --explain E0716`.
[01:38:49] 15 
[01:38:49] 
[01:38:49] 
[01:38:49] The actual stderr differed from the expected stderr.
[01:38:49] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-ptr-unique.nll/const-ptr-unique.nll.stderr
[01:38:49] To update references, rerun the tests and pass the `--bless` flag
[01:38:49] To only update this specific test, also pass `--test-args consts/const-ptr-unique.rs`
[01:38:49] error: 1 errors occurred comparing output.
[01:38:49] status: exit code: 1
[01:38:49] status: exit code: 1
[01:38:49] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/consts/const-ptr-unique.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/consts/const-ptr-unique.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-Crpath" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-ptr-unique.nll/auxiliary" "-A" "unused"
[01:38:49] ------------------------------------------
[01:38:49] 
[01:38:49] ------------------------------------------
[01:38:49] stderr:
[01:38:49] stderr:
[01:38:49] ------------------------------------------
[01:38:49] {"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/consts/const-ptr-unique.rs","byte_start":167,"byte_end":184,"line_start":8,"line_end":8,"column_start":33,"column_end":50,"is_primary":true,"text":[{"text":"    let x: &'static *mut u32 = &(unique.as_ptr());","highlight_start":33,"highlight_end":50}],"label":"creates a temporary which is freed while still in use","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-ptr-unique.rs","byte_start":242,"byte_end":243,"line_start":10,"line_end":10,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"temporary value is freed at the end of this statement","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-ptr-unique.rs","byte_start":146,"byte_end":163,"line_start":8,"line_end":8,"column_start":12,"column_end":29,"is_primary":false,"text":[{"text":"    let x: &'static *mut u32 = &(unique.as_ptr());","highlight_start":12,"highlight_end":29}],"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/consts/const-ptr-unique.rs:8:33\n   |\nLL |     let x: &'static *mut u32 = &(unique.as_ptr());\n   |            -----------------    ^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use\n   |            |\n   |            type annotation requires that borrow lasts for `'static`\nLL |     //~^ ERROR borrowed value does not live long enough\nLL | }\n   | - temporary value is freed at the end of this statement\n\n"}
[01:38:49] {"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:38:49] 
[01:38:49] ------------------------------------------
[01:38:49] 
[01:38:49] 
[01:38:49] thread '[ui (nll)] ui/consts/const-ptr-unique.rs' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3295:9
[01:38:49] note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
[01:38:49] 
[01:38:49] ---- [ui (nll)] ui/consts/const-ptr-nonnull.rs stdout ----
[01:38:49] diff of stderr:
[01:38:49] 
[01:38:49] - error[E0597]: borrowed value does not live long enough
[01:38:49] + error[E0716]: temporary value dropped while borrowed
[01:38:49] 3    |
[01:38:49] 3    |
[01:38:49] 4 LL |     let x: &'static NonNull<u32> = &(NonNull::dangling());
[01:38:49] 
[01:38:49] -    |                                     ^^^^^^^^^^^^^^^^^^^^^ temporary value does not live long enough
[01:38:49] +    |            ---------------------    ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
[01:38:49] +    |            type annotation requires that borrow lasts for `'static`
[01:38:49] 6 ...
[01:38:49] 7 LL | }
[01:38:49] 7 LL | }
[01:38:49] -    | - temporary value only lives until here
[01:38:49] -    |
[01:38:49] -    = note: borrowed value must be valid for the static lifetime...
[01:38:49] +    | - temporary value is freed at the end of this statement
[01:38:49] 11 
[01:38:49] - error[E0597]: borrowed value does not live long enough
[01:38:49] + error[E0716]: temporary value dropped while borrowed
[01:38:49] 14    |
[01:38:49] 14    |
[01:38:49] 15 LL |     let x: &'static NonNull<u32> = &(non_null.cast());
[01:38:49] 
[01:38:49] -    |                                     ^^^^^^^^^^^^^^^^^ temporary value does not live long enough
[01:38:49] +    |            ---------------------    ^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use
[01:38:49] +    |            type annotation requires that borrow lasts for `'static`
[01:38:49] +    |            type annotation requires that borrow lasts for `'static`
[01:38:49] 17 LL |     //~^ ERROR borrowed value does not live long enough
[01:38:49] 18 LL | }
[01:38:49] -    | - temporary value only lives until here
[01:38:49] -    |
[01:38:49] -    = note: borrowed value must be valid for the static lifetime...
[01:38:49] +    | - temporary value is freed at the end of this statement
[01:38:49] 23 error: aborting due to 2 previous errors
[01:38:49] 24 
[01:38:49] 
[01:38:49] - For more information about this error, try `rustc --explain E0597`.
[01:38:49] - For more information about this error, try `rustc --explain E0597`.
[01:38:49] + For more information about this error, try `rustc --explain E0716`.
[01:38:49] 26 
[01:38:49] 
[01:38:49] 
[01:38:49] The actual stderr differed from the expected stderr.
[01:38:49] Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-ptr-nonnull.nll/const-ptr-nonnull.nll.stderr
[01:38:49] To update references, rerun the tests and pass the `--bless` flag
[01:38:49] To only update this specific test, also pass `--test-args consts/const-ptr-nonnull.rs`
[01:38:49] error: 1 errors occurred comparing output.
[01:38:49] status: exit code: 1
[01:38:49] status: exit code: 1
[01:38:49] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/consts/const-ptr-nonnull.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/consts/const-ptr-nonnull.nll/a" "-Zborrowck=migrate" "-Ztwo-phase-borrows" "-Crpath" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-ptr-nonnull.nll/auxiliary" "-A" "unused"
[01:38:49] ------------------------------------------
[01:38:49] 
[01:38:49] ------------------------------------------
[01:38:49] stderr:
[01:38:49] stderr:
[01:38:49] ------------------------------------------
[01:38:49] {"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/consts/const-ptr-nonnull.rs","byte_start":72,"byte_end":93,"line_start":4,"line_end":4,"column_start":37,"column_end":58,"is_primary":true,"text":[{"text":"    let x: &'static NonNull<u32> = &(NonNull::dangling());","highlight_start":37,"highlight_end":58}],"label":"creates a temporary which is freed while still in use","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-ptr-nonnull.rs","byte_start":338,"byte_end":339,"line_start":11,"line_end":11,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"temporary value is freed at the end of this statement","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-ptr-nonnull.rs","byte_start":47,"byte_end":68,"line_start":4,"line_end":4,"column_start":12,"column_end":33,"is_primary":false,"text":[{"text":"    let x: &'static NonNull<u32> = &(NonNull::dangling());","highlight_start":12,"highlight_end":33}],"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/consts/const-ptr-nonnull.rs:4:37\n   |\nLL |     let x: &'static NonNull<u32> = &(NonNull::dangling());\n   |            ---------------------    ^^^^^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use\n   |            |\n   |            type annotation requires that borrow lasts for `'static`\n...\nLL | }\n   | - temporary value is freed at the end of this statement\n\n"}
[01:38:49] {"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/consts/const-ptr-nonnull.rs","byte_start":263,"byte_end":280,"line_start":9,"line_end":9,"column_start":37,"column_end":54,"is_primary":true,"text":[{"text":"    let x: &'static NonNull<u32> = &(non_null.cast());","highlight_start":37,"highlight_end":54}],"label":"creates a temporary which is freed while still in use","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-ptr-nonnull.rs","byte_start":338,"byte_end":339,"line_start":11,"line_end":11,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"}","highlight_start":1,"highlight_end":2}],"label":"temporary value is freed at the end of this statement","suggested_replacement":null,"suggestion_applicability":null,"expansion":null},{"file_name":"/checkout/src/test/ui/consts/const-ptr-nonnull.rs","byte_start":238,"byte_end":259,"line_start":9,"line_end":9,"column_start":12,"column_end":33,"is_primary":false,"text":[{"text":"    let x: &'static NonNull<u32> = &(non_null.cast());","highlight_start":12,"highlight_end":33}],"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/consts/const-ptr-nonnull.rs:9:37\n   |\nLL |     let x: &'static NonNull<u32> = &(non_null.cast());\n   |            ---------------------    ^^^^^^^^^^^^^^^^^ creates a temporary which is freed while still in use\n   |            |\n   |            type annotation requires that borrow lasts for `'static`\nLL |     //~^ ERROR borrowed value does not live long enough\nLL | }\n   | - temporary value is freed at the end of this statement\n\n"}
[01:38:49] {"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:38:49] 
[01:38:49] ------------------------------------------
[01:38:49] 
---
[01:38:49] 
[01:38:49] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:496:22
[01:38:49] 
[01:38:49] 
[01:38:49] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--host-rustcflags" "-Crpath -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--llvm-version" "8.0.0\n" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always" "--compare-mode" "nll"
[01:38:49] 
[01:38:49] 
[01:38:49] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:38:49] Build completed unsuccessfully in 0:08:54
[01:38:49] Build completed unsuccessfully in 0:08:54
[01:38:49] Makefile:48: recipe for target 'check' failed
[01:38:49] make: *** [check] Error 1
The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:02f199f6
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
Wed Feb 27 07:54:53 UTC 2019
---
travis_time:end:3a53450c:start=1551254096049891545,finish=1551254096061404110,duration=11512565
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0339bc84
$ 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:26cd498c
travis_time:start:26cd498c
$ 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:24df6efc
$ 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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.