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

find and highlight the & or '_ in region_name #52168

Merged
merged 1 commit into from
Jul 10, 2018

Conversation

nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented Jul 9, 2018

Before:

   --> $DIR/dyn-trait-underscore.rs:18:5
    |
 LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
-   |         ----- lifetime `'1` appears in this argument
 LL |     Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
    |     ^^^^^^^^^^^^^^^^^^^^^^ cast requires that `'1` must outlive `'static`

After:

   --> $DIR/dyn-trait-underscore.rs:18:5
    |
 LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
+   |                - let's call the lifetime of this reference `'1`
 LL |     Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
    |     ^^^^^^^^^^^^^^^^^^^^^^ cast requires that `'1` must outlive `'static`

Not intended as the final end point necessarily in any sense. I intentionally left some to-do points to fill in later:

  • Does not apply to upvars in closures yet (should be relatively easy)
  • Does not handle the case where we can't find a precise match very well
  • And of course we can still tweak wording

but shows the basic idea of how to make the Ty and hir::Ty to find a good spot to highlight.

r? @estebank
cc @davidtwco

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 9, 2018
@estebank
Copy link
Contributor

estebank commented Jul 9, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Jul 9, 2018

📌 Commit a6adb1e has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 9, 2018
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jul 10, 2018
…ebank

find and highlight the `&` or `'_` in `region_name`

Before:

```
   --> $DIR/dyn-trait-underscore.rs:18:5
    |
 LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
-   |         ----- lifetime `'1` appears in this argument
 LL |     Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
    |     ^^^^^^^^^^^^^^^^^^^^^^ cast requires that `'1` must outlive `'static`
```

After:

```
   --> $DIR/dyn-trait-underscore.rs:18:5
    |
 LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
+   |                - let's call the lifetime of this reference `'1`
 LL |     Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
    |     ^^^^^^^^^^^^^^^^^^^^^^ cast requires that `'1` must outlive `'static`
```

Not intended as the final end point necessarily in any sense. I intentionally left some to-do points to fill in later:

- Does not apply to upvars in closures yet (should be relatively easy)
- Does not handle the case where we can't find a precise match very well
- And of course we can still tweak wording

but shows the basic idea of how to make the `Ty` and `hir::Ty` to find a good spot to highlight.

r? @estebank
cc @davidtwco
@bors
Copy link
Contributor

bors commented Jul 10, 2018

⌛ Testing commit a6adb1e with merge d15bc51abb19f897e57a22500cc49dfc9a94e0bd...

@bors
Copy link
Contributor

bors commented Jul 10, 2018

💔 Test failed - status-travis

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

The job x86_64-gnu-distcheck 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.
[00:27:33] curl: (6) Could not resolve host: static.rust-lang.org
[00:27:33] 
[00:27:33] spurious failure, trying again
[00:31:27] curl: (6) Could not resolve host: static.rust-lang.org
[00:31:27] failed to run: curl -s --retry 3 -Sf -o /tmp/tmpyydmix.sha256 https://static.rust-lang.org/dist/2018-06-30/rust-std-beta-x86_64-unknown-linux-gnu.tar.gz.sha256
[00:31:27] Build completed unsuccessfully in 0:19:26
[00:31:27] Makefile:58: recipe for target 'check' failed
[00:31:27] make: *** [check] Error 1
[00:31:27] 
[00:31:27] 
[00:31:27] command did not execute successfully: "make" "check"
[00:31:27] 
[00:31:27] 
[00:31:27] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test distcheck
[00:31:27] Build completed unsuccessfully in 0:28:47
---
travis_time:end:08bed90d:start=1531205497364462230,finish=1531205497372361178,duration=7898948
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:04985211
$ head -30 ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
head: cannot open ‘./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers’ for reading: No such file or directory
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:1578da7c
$ 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)

1 similar comment
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-distcheck 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.
[00:27:33] curl: (6) Could not resolve host: static.rust-lang.org
[00:27:33] 
[00:27:33] spurious failure, trying again
[00:31:27] curl: (6) Could not resolve host: static.rust-lang.org
[00:31:27] failed to run: curl -s --retry 3 -Sf -o /tmp/tmpyydmix.sha256 https://static.rust-lang.org/dist/2018-06-30/rust-std-beta-x86_64-unknown-linux-gnu.tar.gz.sha256
[00:31:27] Build completed unsuccessfully in 0:19:26
[00:31:27] Makefile:58: recipe for target 'check' failed
[00:31:27] make: *** [check] Error 1
[00:31:27] 
[00:31:27] 
[00:31:27] command did not execute successfully: "make" "check"
[00:31:27] 
[00:31:27] 
[00:31:27] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test distcheck
[00:31:27] Build completed unsuccessfully in 0:28:47
---
travis_time:end:08bed90d:start=1531205497364462230,finish=1531205497372361178,duration=7898948
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:04985211
$ head -30 ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
head: cannot open ‘./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers’ for reading: No such file or directory
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:1578da7c
$ 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)

@kennytm
Copy link
Member

kennytm commented Jul 10, 2018

@bors retry travis-ci/travis-ci#9696

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

bors commented Jul 10, 2018

⌛ Testing commit a6adb1e with merge fc49152...

bors added a commit that referenced this pull request Jul 10, 2018
find and highlight the `&` or `'_` in `region_name`

Before:

```
   --> $DIR/dyn-trait-underscore.rs:18:5
    |
 LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
-   |         ----- lifetime `'1` appears in this argument
 LL |     Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
    |     ^^^^^^^^^^^^^^^^^^^^^^ cast requires that `'1` must outlive `'static`
```

After:

```
   --> $DIR/dyn-trait-underscore.rs:18:5
    |
 LL | fn a<T>(items: &[T]) -> Box<dyn Iterator<Item=&T>> {
+   |                - let's call the lifetime of this reference `'1`
 LL |     Box::new(items.iter()) //~ ERROR cannot infer an appropriate lifetime
    |     ^^^^^^^^^^^^^^^^^^^^^^ cast requires that `'1` must outlive `'static`
```

Not intended as the final end point necessarily in any sense. I intentionally left some to-do points to fill in later:

- Does not apply to upvars in closures yet (should be relatively easy)
- Does not handle the case where we can't find a precise match very well
- And of course we can still tweak wording

but shows the basic idea of how to make the `Ty` and `hir::Ty` to find a good spot to highlight.

r? @estebank
cc @davidtwco
@bors
Copy link
Contributor

bors commented Jul 10, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: estebank
Pushing fc49152 to master...

@Eh2406
Copy link
Contributor

Eh2406 commented Jul 11, 2018

I find it amusing that this was a noticeable improvement to perf inflate-check and the graphs suggest that it was not just noize.

@@ -49,7 +49,7 @@ LL | let mut f: Option<&u32> = None;
| ----- lifetime `'2` appears in the type of `f`
...
LL | closure_expecting_bound(|x: &'x u32| {
| - lifetime `'1` appears in this argument
| - let's call the lifetime of this reference `'1`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hadn't noticed this before, shouldn't it complain about 'x needing to outlive '2, pointing out that it is unconstrained on the input so it evaluates shorten than '2? I found the message surprising until I looked at the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants