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

check_match: misc unifications and ICE fixes #68399

Merged
merged 3 commits into from
Jan 21, 2020

Conversation

Centril
Copy link
Contributor

@Centril Centril commented Jan 20, 2020

These are some unifications made as a by-product of working on hir::ExprKind::Let.

Fixes #68396.
Fixes #68394.
Fixes #68393.

r? @oli-obk @matthewjasper

@Centril Centril added the F-let_chains `#![feature(let_chains)]` label Jan 20, 2020
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 20, 2020
@oli-obk
Copy link
Contributor

oli-obk commented Jan 21, 2020

@bors r+

@bors
Copy link
Contributor

bors commented Jan 21, 2020

📌 Commit 58eb03d has been approved by oli-obk

@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-review Status: Awaiting review from the assignee but also interested parties. labels Jan 21, 2020
@oli-obk
Copy link
Contributor

oli-obk commented Jan 21, 2020

cc @rust-lang/wg-diagnostics

Centril added a commit to Centril/rust that referenced this pull request Jan 21, 2020
check_match: misc unifications and ICE fixes

These are some unifications made as a by-product of working on `hir::ExprKind::Let`.

Fixes rust-lang#68396.
Fixes rust-lang#68394.
Fixes rust-lang#68393.

r? @oli-obk @matthewjasper
bors added a commit that referenced this pull request Jan 21, 2020
Rollup of 7 pull requests

Successful merges:

 - #67686 (Simplify NodeHeader by avoiding slices in BTreeMaps with shared roots)
 - #68140 (Implement `?const` opt-out for trait bounds)
 - #68313 (Options IP_MULTICAST_TTL and IP_MULTICAST_LOOP are 1 byte on BSD)
 - #68328 (Actually pass target LLVM args to LLVM)
 - #68399 (check_match: misc unifications and ICE fixes)
 - #68415 (tidy: fix most clippy warnings)
 - #68416 (lowering: cleanup some hofs)

Failed merges:

r? @ghost
@@ -0,0 +1,9 @@
error[E0080]: runtime values cannot be referenced in patterns
Copy link
Contributor

Choose a reason for hiding this comment

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

I would like the wording of this error to be tweaked a bit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's wrong with the current?

Copy link
Contributor

Choose a reason for hiding this comment

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

I feel it is a bit jargony, but I guess it's no worse than other more common errors we emit.

Comment on lines +1 to +11
error[E0158]: associated consts cannot be referenced in patterns
--> $DIR/issue-68393-let-pat-assoc-constant.rs:20:40
|
LL | pub fn test<A: Foo, B: Foo>(arg: EFoo, A::X: EFoo) {
| ^^^^

error[E0158]: associated consts cannot be referenced in patterns
--> $DIR/issue-68393-let-pat-assoc-constant.rs:22:9
|
LL | let A::X = arg;
| ^^^^
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we customize the "patterns" wording in fn args and let bindings? I would expect people that are unfamiliar with the language to get confused by this. At least a note with something like (but better) "let statements introduce new bindings to some pattern, normally a simple name which are also patterns".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think this is unlikely that a beginner would write this code personally. Using an associated constant in an irrefutable context seems fairly niche. In fact, I found this ICE by trying to unify the code, realizing that a check was missing in the irrefutable contexts. A::X also does not seem confusable for a binding. I would prefer not to preempt better diagnostics here until a beginner shows up.

If we are going to improve diagnostics, I'd rather add "defined here" span_labels for X and A.

Comment on lines +34 to +36
//~^ ERROR variable `Foo` should have a snake case name
//~^^ WARN `Foo` is named the same as one of the variants of the type `foo::Foo`
//~^^^ WARN unused variable: `Foo`
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use //~| in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I mostly copied existing code. Should we file an issue for follow-up?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nah, its fine.

@bors bors merged commit 58eb03d into rust-lang:master Jan 21, 2020
@Centril Centril deleted the check-match-unify branch January 21, 2020 22:13
@bors
Copy link
Contributor

bors commented Jan 21, 2020

☔ The latest upstream changes (presumably #68423) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-let_chains `#![feature(let_chains)]` S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
5 participants