-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
nll type annotations in multisegment path #55093
Merged
bors
merged 19 commits into
rust-lang:master
from
nikomatsakis:nll-issue-54574-multisegment-path
Oct 17, 2018
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4b69edc
rename to `user_substs_applied_to_def` for consistency
nikomatsakis 24bee00
add `force_instantiate_unchecked` method
nikomatsakis ca52427
make `TypeRelating` take an infcx again
nikomatsakis a3409a1
make `instantiate_canonical_with_fresh_inference_vars` public again
nikomatsakis b6a080e
rework `relate_type_and_user_type` to use type inference variables
nikomatsakis e7ed997
extract `type_relate` into the inference context as `nll_relate`
nikomatsakis e339e84
move `force_instantiate_unchecked` to be local to `nll_relate` code
nikomatsakis aed6e4a
introduce a `UserTypeAnnotation` enum
nikomatsakis 2a7fc22
introduce `FnDef` and `AdtDef` to `UserTypeAnnotation`
nikomatsakis 1443ac0
introduce a more expressive `UserSubsts`
nikomatsakis 0e1d362
pull the common code across user-ty variants up top
nikomatsakis 547182e
handle user-self-type for def-ids
nikomatsakis 16a3824
pass along `user_self_ty`
nikomatsakis ba20806
avoid type variables in the self-type
nikomatsakis 2e4e983
update tests
nikomatsakis 087d129
pacify the mercilous tidy
nikomatsakis 7ce2e7a
fix mir-opt test
nikomatsakis 1008539
fix comment
nikomatsakis b70b4a6
add ~ERROR annotations
nikomatsakis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/test/ui/nll/user-annotations/method-ufcs-inherent-1.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#![feature(nll)] | ||
|
||
// Check that substitutions given on the self type (here, `A`) carry | ||
// through to NLL. | ||
|
||
struct A<'a> { x: &'a u32 } | ||
|
||
impl<'a> A<'a> { | ||
fn new<'b, T>(x: &'a u32, y: T) -> Self { | ||
Self { x } | ||
} | ||
} | ||
|
||
fn foo<'a>() { | ||
let v = 22; | ||
let x = A::<'a>::new(&v, 22); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you and I mirrored each other on our respective PR's; there should be an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eep yes, will add. |
||
} | ||
|
||
fn main() {} |
17 changes: 17 additions & 0 deletions
17
src/test/ui/nll/user-annotations/method-ufcs-inherent-1.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error[E0597]: `v` does not live long enough | ||
--> $DIR/method-ufcs-inherent-1.rs:16:26 | ||
| | ||
LL | let x = A::<'a>::new(&v, 22); | ||
| ^^ borrowed value does not live long enough | ||
LL | } | ||
| - `v` dropped here while still borrowed | ||
| | ||
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 14:8... | ||
--> $DIR/method-ufcs-inherent-1.rs:14:8 | ||
| | ||
LL | fn foo<'a>() { | ||
| ^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0597`. |
19 changes: 19 additions & 0 deletions
19
src/test/ui/nll/user-annotations/method-ufcs-inherent-2.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#![feature(nll)] | ||
|
||
// Check that substitutions given on the self type (here, `A`) can be | ||
// used in combination with annotations given for method arguments. | ||
|
||
struct A<'a> { x: &'a u32 } | ||
|
||
impl<'a> A<'a> { | ||
fn new<'b, T>(x: &'a u32, y: T) -> Self { | ||
Self { x } | ||
} | ||
} | ||
|
||
fn foo<'a>() { | ||
let v = 22; | ||
let x = A::<'a>::new::<&'a u32>(&v, &v); | ||
} | ||
|
||
fn main() {} |
31 changes: 31 additions & 0 deletions
31
src/test/ui/nll/user-annotations/method-ufcs-inherent-2.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
error[E0597]: `v` does not live long enough | ||
--> $DIR/method-ufcs-inherent-2.rs:16:37 | ||
| | ||
LL | let x = A::<'a>::new::<&'a u32>(&v, &v); | ||
| ^^ borrowed value does not live long enough | ||
LL | } | ||
| - `v` dropped here while still borrowed | ||
| | ||
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 14:8... | ||
--> $DIR/method-ufcs-inherent-2.rs:14:8 | ||
| | ||
LL | fn foo<'a>() { | ||
| ^^ | ||
|
||
error[E0597]: `v` does not live long enough | ||
--> $DIR/method-ufcs-inherent-2.rs:16:41 | ||
| | ||
LL | let x = A::<'a>::new::<&'a u32>(&v, &v); | ||
| ^^ borrowed value does not live long enough | ||
LL | } | ||
| - `v` dropped here while still borrowed | ||
| | ||
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 14:8... | ||
--> $DIR/method-ufcs-inherent-2.rs:14:8 | ||
| | ||
LL | fn foo<'a>() { | ||
| ^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0597`. |
19 changes: 19 additions & 0 deletions
19
src/test/ui/nll/user-annotations/method-ufcs-inherent-3.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#![feature(nll)] | ||
|
||
// Check that inherent methods invoked with `<T>::new` style | ||
// carry their annotations through to NLL. | ||
|
||
struct A<'a> { x: &'a u32 } | ||
|
||
impl<'a> A<'a> { | ||
fn new<'b, T>(x: &'a u32, y: T) -> Self { | ||
Self { x } | ||
} | ||
} | ||
|
||
fn foo<'a>() { | ||
let v = 22; | ||
let x = <A<'a>>::new(&v, 22); | ||
} | ||
|
||
fn main() {} |
17 changes: 17 additions & 0 deletions
17
src/test/ui/nll/user-annotations/method-ufcs-inherent-3.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
error[E0597]: `v` does not live long enough | ||
--> $DIR/method-ufcs-inherent-3.rs:16:26 | ||
| | ||
LL | let x = <A<'a>>::new(&v, 22); | ||
| ^^ borrowed value does not live long enough | ||
LL | } | ||
| - `v` dropped here while still borrowed | ||
| | ||
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 14:8... | ||
--> $DIR/method-ufcs-inherent-3.rs:14:8 | ||
| | ||
LL | fn foo<'a>() { | ||
| ^^ | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0597`. |
20 changes: 20 additions & 0 deletions
20
src/test/ui/nll/user-annotations/method-ufcs-inherent-4.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#![feature(nll)] | ||
|
||
// Check that inherent methods invoked with `<T>::new` style | ||
// carry their annotations through to NLL in connection with | ||
// method type parameters. | ||
|
||
struct A<'a> { x: &'a u32 } | ||
|
||
impl<'a> A<'a> { | ||
fn new<'b, T>(x: &'a u32, y: T) -> Self { | ||
Self { x } | ||
} | ||
} | ||
|
||
fn foo<'a>() { | ||
let v = 22; | ||
let x = <A<'a>>::new::<&'a u32>(&v, &v); | ||
} | ||
|
||
fn main() {} |
31 changes: 31 additions & 0 deletions
31
src/test/ui/nll/user-annotations/method-ufcs-inherent-4.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
error[E0597]: `v` does not live long enough | ||
--> $DIR/method-ufcs-inherent-4.rs:17:37 | ||
| | ||
LL | let x = <A<'a>>::new::<&'a u32>(&v, &v); | ||
| ^^ borrowed value does not live long enough | ||
LL | } | ||
| - `v` dropped here while still borrowed | ||
| | ||
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 15:8... | ||
--> $DIR/method-ufcs-inherent-4.rs:15:8 | ||
| | ||
LL | fn foo<'a>() { | ||
| ^^ | ||
|
||
error[E0597]: `v` does not live long enough | ||
--> $DIR/method-ufcs-inherent-4.rs:17:41 | ||
| | ||
LL | let x = <A<'a>>::new::<&'a u32>(&v, &v); | ||
| ^^ borrowed value does not live long enough | ||
LL | } | ||
| - `v` dropped here while still borrowed | ||
| | ||
note: borrowed value must be valid for the lifetime 'a as defined on the function body at 15:8... | ||
--> $DIR/method-ufcs-inherent-4.rs:15:8 | ||
| | ||
LL | fn foo<'a>() { | ||
| ^^ | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0597`. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is there a
'b
here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I see the same thing occuring in the other tests. To be honest I had thought that we didn't allow unreferenced lifetimes in generic binders ... but I guess that is just a lint, when it comes to lifetimes...?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copy and paste error, I think