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

When encountering an Item in a pat context, point at the item def #67741

Merged
merged 1 commit into from
Mar 7, 2020

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Dec 31, 2019

error[E0308]: mismatched types
  --> $DIR/const-in-struct-pat.rs:8:17
   |
LL | struct foo;
   | ----------- `foo` defined here
...
LL |     let Thing { foo } = t;
   |                 ^^^ expected struct `std::string::String`, found struct `foo`
   |
   = note: `foo` is interpreted as a unit struct, not a new binding
help: you can bind the struct field to a different name
   |
LL |     let Thing { foo: other_foo } = t;
   |                 ^^^^^^^^^^^^^^
error[E0308]: mismatched types
  --> $DIR/const.rs:14:9
   |
LL | const FOO: Foo = Foo{bar: 5};
   | ----------------------------- constant defined here
...
LL |         FOO => {},
   |         ^^^
   |         |
   |         expected `&Foo`, found struct `Foo`
   |         `FOO` is interpreted as a constant, not a new binding
   |         help: use different name to introduce a new binding: `other_foo`

Fix #55631, fix #48062, cc #42876.

@rust-highfive

This comment has been minimized.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 31, 2019
@Centril
Copy link
Contributor

Centril commented Dec 31, 2019

r? @Centril

@rust-highfive rust-highfive assigned Centril and unassigned zackmdavis Dec 31, 2019
Copy link
Contributor

@Centril Centril left a comment

Choose a reason for hiding this comment

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

Looks promising, but needs some changes.

Also, I'd like for #67730 to land first cause that one will be harder to rebase.

src/librustc_typeck/check/pat.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/pat.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/pat.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/pat.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/pat.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/pat.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/pat.rs Outdated Show resolved Hide resolved
src/test/ui/issues/issue-33504.stderr Outdated Show resolved Hide resolved
src/test/ui/suggestions/const-in-struct-pat.rs Outdated Show resolved Hide resolved
@estebank
Copy link
Contributor Author

I'm away for a week. I'll incorporate the feedback once I'm back.

@Centril Centril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 31, 2019
@bors

This comment has been minimized.

@estebank estebank force-pushed the point-at-pat-def branch 2 times, most recently from 1c1142d to 7251e3f Compare January 7, 2020 03:23
@rust-highfive

This comment has been minimized.

@estebank estebank added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 7, 2020
@bors

This comment has been minimized.

src/librustc_typeck/check/pat.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/pat.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/pat.rs Outdated Show resolved Hide resolved
@Centril Centril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 9, 2020
@estebank estebank added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 15, 2020
@estebank estebank removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 17, 2020
@estebank estebank added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 17, 2020
Copy link
Contributor

@Centril Centril left a comment

Choose a reason for hiding this comment

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

r=me with these comments addressed

src/librustc_typeck/check/pat.rs Outdated Show resolved Hide resolved
src/librustc_typeck/check/pat.rs Outdated Show resolved Hide resolved
@Centril Centril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 28, 2020
@bors

This comment has been minimized.

@Centril
Copy link
Contributor

Centril commented Mar 4, 2020

Ping @estebank :)

@estebank
Copy link
Contributor Author

estebank commented Mar 6, 2020

Rebased and addressed all coments, I believe.

@Centril
Copy link
Contributor

Centril commented Mar 7, 2020

Excellent! I'll follow up with a PR on my own to polish a bit, but this is great.

@bors r+

@bors
Copy link
Contributor

bors commented Mar 7, 2020

📌 Commit 125159f has been approved by Centril

@bors
Copy link
Contributor

bors commented Mar 7, 2020

🌲 The tree is currently closed for pull requests below priority 1000, this pull request will be tested once the tree is reopened

@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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 7, 2020
Centril added a commit to Centril/rust that referenced this pull request Mar 7, 2020
When encountering an Item in a pat context, point at the item def

```
error[E0308]: mismatched types
  --> $DIR/const-in-struct-pat.rs:8:17
   |
LL | struct foo;
   | ----------- `foo` defined here
...
LL |     let Thing { foo } = t;
   |                 ^^^ expected struct `std::string::String`, found struct `foo`
   |
   = note: `foo` is interpreted as a unit struct, not a new binding
help: you can bind the struct field to a different name
   |
LL |     let Thing { foo: other_foo } = t;
   |                 ^^^^^^^^^^^^^^
```
```
error[E0308]: mismatched types
  --> $DIR/const.rs:14:9
   |
LL | const FOO: Foo = Foo{bar: 5};
   | ----------------------------- constant defined here
...
LL |         FOO => {},
   |         ^^^
   |         |
   |         expected `&Foo`, found struct `Foo`
   |         `FOO` is interpreted as a constant, not a new binding
   |         help: use different name to introduce a new binding: `other_foo`
```

Fix rust-lang#55631, fix rust-lang#48062, cc rust-lang#42876.
bors added a commit that referenced this pull request Mar 7, 2020
Rollup of 9 pull requests

Successful merges:

 - #67741 (When encountering an Item in a pat context, point at the item def)
 - #68985 (Parse & reject postfix operators after casts)
 - #69656 (Use .next() instead of .nth(0) on iterators.)
 - #69680 (rustc_expand: Factor out `Annotatable::into_tokens` to a separate method)
 - #69690 (test(pattern): add tests for combinations of pattern features)
 - #69706 (Use subslice patterns in slice methods)
 - #69727 (Avoid using `unwrap()` in suggestions)
 - #69754 (Update deprecation version to 1.42 for Error::description)
 - #69782 (Don't redundantly repeat field names (clippy::redundant_field_names))

Failed merges:

r? @ghost
@bors bors merged commit e8bb6c0 into rust-lang:master Mar 7, 2020
@estebank estebank deleted the point-at-pat-def branch November 9, 2023 05:17
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
5 participants