Skip to content

Move 'doesn't live long enough' errors to labels #35732

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

Merged
merged 2 commits into from
Aug 18, 2016

Conversation

sophiajt
Copy link
Contributor

This patch moves the "doesn't live long enough" region-style errors to instead use labels.

An example follows.

Before:

error: `x` does not live long enough
  --> src/test/compile-fail/send-is-not-static-ensures-scoping.rs:26:18
   |
26 |         let y = &x;
   |                  ^
   |
note: reference must be valid for the block at 23:10...
  --> src/test/compile-fail/send-is-not-static-ensures-scoping.rs:23:11
   |
23 | fn main() {
   |           ^
note: ...but borrowed value is only valid for the block suffix following statement 0 at 25:18
  --> src/test/compile-fail/send-is-not-static-ensures-scoping.rs:25:19
   |
25 |         let x = 1;
   |                   ^

After:

error: `x` does not live long enough
  --> src/test/compile-fail/send-is-not-static-ensures-scoping.rs:26:18
   |
26 |         let y = &x;
   |                  ^ does not live long enough
...
32 |     };
   |     - borrowed value only valid until here
...
35 | }
   | - borrowed value must be valid until here

r? @nikomatsakis

Some(s) => {
let mut last_span = s;
last_span.lo = BytePos(last_span.hi.0 - 1);
Some(last_span)
Copy link
Contributor

@nikomatsakis nikomatsakis Aug 17, 2016

Choose a reason for hiding this comment

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

I think you can use s.end_point() here...

@nikomatsakis
Copy link
Contributor

r=me modulo nits

@sophiajt sophiajt force-pushed the region_error_labels branch from 286c996 to 864b3ef Compare August 17, 2016 22:53
@sophiajt
Copy link
Contributor Author

@bors r=nikomatsakis

@bors
Copy link
Collaborator

bors commented Aug 17, 2016

📌 Commit 864b3ef has been approved by nikomatsakis

@bors
Copy link
Collaborator

bors commented Aug 18, 2016

⌛ Testing commit 864b3ef with merge 43c090e...

bors added a commit that referenced this pull request Aug 18, 2016
…sakis

Move 'doesn't live long enough' errors to labels

This patch moves the "doesn't live long enough" region-style errors to instead use labels.

An example follows.

Before:

```
error: `x` does not live long enough
  --> src/test/compile-fail/send-is-not-static-ensures-scoping.rs:26:18
   |
26 |         let y = &x;
   |                  ^
   |
note: reference must be valid for the block at 23:10...
  --> src/test/compile-fail/send-is-not-static-ensures-scoping.rs:23:11
   |
23 | fn main() {
   |           ^
note: ...but borrowed value is only valid for the block suffix following statement 0 at 25:18
  --> src/test/compile-fail/send-is-not-static-ensures-scoping.rs:25:19
   |
25 |         let x = 1;
   |                   ^
```

After:

```
error: `x` does not live long enough
  --> src/test/compile-fail/send-is-not-static-ensures-scoping.rs:26:18
   |
26 |         let y = &x;
   |                  ^ does not live long enough
...
32 |     };
   |     - borrowed value only valid until here
...
35 | }
   | - borrowed value must be valid until here
```

r? @nikomatsakis
@bors bors merged commit 864b3ef into rust-lang:master Aug 18, 2016
@sophiajt sophiajt deleted the region_error_labels branch August 18, 2016 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants