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

Projects
None yet
6 participants
@nikomatsakis
Copy link
Contributor

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

@estebank

This comment has been minimized.

Copy link
Contributor

estebank commented Jul 9, 2018

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jul 9, 2018

📌 Commit a6adb1e has been approved by estebank

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jul 10, 2018

Rollup merge of rust-lang#52168 - nikomatsakis:nll-region-name, r=est…
…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 added a commit that referenced this pull request Jul 10, 2018

Auto merge of #52199 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 8 pull requests

Successful merges:

 - #51722 (Updated RELEASES for 1.28.0)
 - #52064 (Clarifying how the alignment of the struct works)
 - #52149 (Add #[repr(transparent)] to Atomic* types)
 - #52157 (Copy libgcc as well after building musl)
 - #52164 (use proper footnote syntax for references)
 - #52168 (find and highlight the `&` or `'_` in `region_name`)
 - #52171 (Correct some codegen stats counter inconsistencies)
 - #52177 (Warn windows-gnu users that the bundled gcc can't compile)

Failed merges:

r? @ghost
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Jul 10, 2018

⌛️ Testing commit a6adb1e with merge d15bc51...

bors added a commit that referenced this pull request Jul 10, 2018

Auto merge of #52168 - nikomatsakis:nll-region-name, r=estebank
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

This comment has been minimized.

Copy link
Contributor

bors commented Jul 10, 2018

💔 Test failed - status-travis

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jul 10, 2018

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

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jul 10, 2018

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

This comment has been minimized.

Copy link
Member

kennytm commented Jul 10, 2018

@bors

This comment has been minimized.

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

Auto merge of #52168 - nikomatsakis:nll-region-name, r=estebank
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

This comment has been minimized.

Copy link
Contributor

bors commented Jul 10, 2018

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

@bors bors merged commit a6adb1e into rust-lang:master Jul 10, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
@Eh2406

This comment has been minimized.

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`

This comment has been minimized.

@estebank

estebank Jul 11, 2018

Contributor

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
You can’t perform that action at this time.