-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
support ascription for patterns in NLL #53873
Merged
bors
merged 27 commits into
rust-lang:master
from
nikomatsakis:nll-universe-subtyping-and-pattern-ascription
Sep 11, 2018
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
fa1f564
document the purpose of `ScopeInstantiator`
nikomatsakis 09f4172
remove extra lifetime bound
nikomatsakis d6a98db
factor out `lookup_bound_region`
nikomatsakis 5c5741b
add some comments
nikomatsakis 3f60043
infer/mod.rs: rustfmt
nikomatsakis 5c016f4
add ability to create region vars with explicit universe
nikomatsakis 39b9281
add a `first_free_index` parameter
nikomatsakis 5f43b09
instantiate traversed binders rather than saving the scopes
nikomatsakis aa52e12
add generalization
nikomatsakis 07e21b1
add a test for variables used twice
nikomatsakis 34575e6
now that we can handle subtyping, fix higher-ranked equality
nikomatsakis 4b5f19a
remove the old `UserAssertTy` support
nikomatsakis 50754d0
add a `AscribeUserType` pattern, largely ignored
nikomatsakis 22f9bcc
matches/mod.rs: rustfmt
nikomatsakis dd3cc96
add the `AscribeUserType` statement kind
nikomatsakis 7e1b978
insert `AscribeUserType` for ascriptions
nikomatsakis 05a6e1e
pacify the mercilous tidy
nikomatsakis f0e3a09
fixup: rename `UserAssertTy` to `AscribeUserType`
nikomatsakis fced2b1
fix SCCs containing mixture of universes
nikomatsakis 9c5e794
WIP remove incorrect nll.stderr reference files
nikomatsakis 16f4e8a
generalize `AscribeUserType` to handle sub or super type
nikomatsakis 2f6628e
optimize `let x: T = ..` to avoid a temporary
nikomatsakis a871053
expand the patterns test with a bunch more scenarios
nikomatsakis e87bf30
propagate user-ascribes types down onto resulting bindings
nikomatsakis 2b6f966
add link to https://github.com/rust-lang/rust/issues/54105
nikomatsakis df37678
add FIXME related to `ref x` bindings
nikomatsakis f95f23f
fix incremental test
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -3,10 +3,41 @@ | |
#![feature(nll)] | ||
|
||
fn variable_no_initializer() { | ||
// FIXME: It is unclear to me whether this should be an error or not. | ||
|
||
let x = 22; | ||
let y: &'static u32; | ||
y = &x; //~ ERROR | ||
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. 🎉 |
||
} | ||
|
||
fn tuple_no_initializer() { | ||
// FIXME(#47187): We are not propagating ascribed type through tuples. | ||
|
||
let x = 22; | ||
let (y, z): (&'static u32, &'static u32); | ||
y = &x; | ||
} | ||
|
||
fn ref_with_ascribed_static_type() -> u32 { | ||
// Check the behavior in some wacky cases. | ||
let x = 22; | ||
let y = &x; //~ ERROR | ||
let ref z: &'static u32 = y; //~ ERROR | ||
**z | ||
} | ||
|
||
fn ref_with_ascribed_any_type() -> u32 { | ||
let x = 22; | ||
let y = &x; | ||
let ref z: &u32 = y; | ||
**z | ||
} | ||
|
||
struct Single<T> { value: T } | ||
|
||
fn struct_no_initializer() { | ||
// FIXME(#47187): We are not propagating ascribed type through patterns. | ||
|
||
let x = 22; | ||
let Single { value: y }: Single<&'static u32>; | ||
y = &x; | ||
} | ||
|
||
|
@@ -39,8 +70,6 @@ fn pair_variable_with_initializer() { | |
let (y, _): (&'static u32, u32) = (&x, 44); //~ ERROR | ||
} | ||
|
||
struct Single<T> { value: T } | ||
|
||
fn struct_single_field_variable_with_initializer() { | ||
let x = 22; | ||
let Single { value: y }: Single<&'static u32> = Single { value: &x }; //~ ERROR | ||
|
@@ -73,7 +102,7 @@ fn static_to_a_to_static_through_variable<'a>(x: &'a u32) -> &'static u32 { | |
} | ||
|
||
fn static_to_a_to_static_through_tuple<'a>(x: &'a u32) -> &'static u32 { | ||
// FIXME: The fact that this type-checks is perhaps surprising. | ||
// FIXME(#47187): The fact that this type-checks is perhaps surprising. | ||
// What happens is that the right-hand side is constrained to have | ||
// type `&'a u32`, which is possible, because it has type | ||
// `&'static u32`. The variable `y` is then forced to have type | ||
|
Oops, something went wrong.
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.
hmm. I'd have to think about this syntax and whether it makes sense. (But I won't let that block landing this PR; the printed MIR output format is unstable, afterall...)
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.
yeah it...probably doesn't make sense =)