Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uptypeck: suggest use of match_default_bindings feature #45409
Conversation
rust-highfive
assigned
nikomatsakis
Oct 20, 2017
kennytm
added
the
S-waiting-on-review
label
Oct 20, 2017
tamird
force-pushed the
tamird:suggest-match-default-bindings
branch
2 times, most recently
from
264265f
to
bca2201
Oct 20, 2017
This comment has been minimized.
This comment has been minimized.
|
OK, this should be in a reasonable state now - I had to do some additional juggling to prevent halfway-massaging in the case of the feature not being enabled. |
tamird
force-pushed the
tamird:suggest-match-default-bindings
branch
3 times, most recently
from
a3dbc28
to
570f476
Oct 20, 2017
nikomatsakis
requested changes
Oct 23, 2017
|
Looks great. I left one suggestion -- let me know what you think. |
| err.span_suggestion(pat.span, "consider using", format!("&{}", &snippet)); | ||
| } | ||
| err.emit(); | ||
| None |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Oct 23, 2017
Contributor
Hmm, it seems like it may be better to just update expected and def_bm either way -- i.e., if the feature gate is not enabled, we type-check as if it were, but issue an error. It'd certainly be less complicated, but it would also suppress the "duplicate-ish" errors we see below (e.g., mismatched types).
This comment has been minimized.
This comment has been minimized.
tamird
Oct 26, 2017
Author
Contributor
That's what I did initially. Added a commit that reverts to that so you can see the resulting UI test behaviour.
| @@ -9,5 +9,7 @@ | |||
| // except according to those terms. | |||
|
|
|||
| fn main() { | |||
| let false = "foo"; //~ error: mismatched types | |||
| let false = "foo"; | |||
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Oct 23, 2017
Contributor
let's change this test from "foo" to 22 -- I feel like the message about non-reference patterns isn't central to the test.
This comment has been minimized.
This comment has been minimized.
| @@ -9,5 +9,7 @@ | |||
| // except according to those terms. | |||
|
|
|||
| fn main() { | |||
| let Self = "foo"; //~ ERROR cannot find unit struct/variant or constant `Self` in this scope | |||
| let Self = "foo"; | |||
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Oct 23, 2017
Contributor
let's change this test from "foo" to 22 -- I feel like the message about non-reference patterns isn't central to the test.
This comment has been minimized.
This comment has been minimized.
| @@ -9,5 +9,7 @@ | |||
| // except according to those terms. | |||
|
|
|||
| fn main() { | |||
| let super = "foo"; //~ ERROR failed to resolve. There are too many initial `super`s | |||
| let super = "foo"; | |||
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Oct 23, 2017
Contributor
let's change this test from "foo" to 22 -- I feel like the message about non-reference patterns isn't central to the test.
This comment has been minimized.
This comment has been minimized.
| @@ -9,5 +9,7 @@ | |||
| // except according to those terms. | |||
|
|
|||
| fn main() { | |||
| let true = "foo"; //~ error: mismatched types | |||
| let true = "foo"; | |||
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Oct 23, 2017
Contributor
let's change this test from "foo" to 22 -- I feel like the message about non-reference patterns isn't central to the test.
This comment has been minimized.
This comment has been minimized.
kennytm
added
S-waiting-on-author
and removed
S-waiting-on-review
labels
Oct 25, 2017
tamird
force-pushed the
tamird:suggest-match-default-bindings
branch
from
570f476
to
bd5a587
Oct 26, 2017
This comment has been minimized.
This comment has been minimized.
|
@kennytm should be waiting-on-review again. |
kennytm
added
S-waiting-on-review
and removed
S-waiting-on-author
labels
Oct 26, 2017
nikomatsakis
approved these changes
Oct 30, 2017
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@tamird sorry for the delay; I was at the Rust Belt Rust conference. Looks good, thanks! |
This comment has been minimized.
This comment has been minimized.
|
No worries! Can you let me squash it before it merges? I'll be back at my
computer this evening.
…On Oct 30, 2017 11:07, "Niko Matsakis" ***@***.***> wrote:
@tamird <https://github.com/tamird> sorry for the delay; I was at the
Rust Belt Rust conference. Looks good, thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#45409 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABdsPCtdJcVVB-k4E2b71g94HiP_-9DDks5sxeYegaJpZM4QAo98>
.
|
This comment has been minimized.
This comment has been minimized.
|
@bors r- (Waiting on author to cleanup.) |
tamird
force-pushed the
tamird:suggest-match-default-bindings
branch
from
bd5a587
to
9844777
Oct 30, 2017
This comment has been minimized.
This comment has been minimized.
|
OK, should be good to go, unless y'all have tweaks for the message. |
This comment has been minimized.
This comment has been minimized.
|
@bors r=nikomatsakis |
This comment has been minimized.
This comment has been minimized.
|
|
kennytm
added
S-waiting-on-bors
and removed
S-waiting-on-review
labels
Oct 31, 2017
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Oct 31, 2017
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@bors retry #45230 LLDB segfault at
|
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Oct 31, 2017
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
Looks like this test generated so much log output that it caused Unsure if it's caused by this PR (in that maybe it increased the amount of logging?) but it also seems like we may just need to remove the test... |
This comment has been minimized.
This comment has been minimized.
|
@bors retry |
This comment has been minimized.
This comment has been minimized.
|
@kennytm we may want to watch this test though, I suspect this won't be the first time we see this error. Also the test ran for at least a minute which is a bit much |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton Sorry did not see your reply when commenting. @bors r- This test case has failed before, e.g. #44142 (comment) which was legit. Probably this diff caused a lot more logs to appear and failing the test case? diff --git a/src/librustc_typeck/check/_match.rs b/src/librustc_typeck/check/_match.rs
index ab8994bcae25..e25f7d796689 100644
--- a/src/librustc_typeck/check/_match.rs
+++ b/src/librustc_typeck/check/_match.rs
@@ -68,7 +69,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
PatKind::Binding(..) |
PatKind::Ref(..) => false,
};
- if is_non_ref_pat && tcx.sess.features.borrow().match_default_bindings {
+ if is_non_ref_pat {
debug!("pattern is non reference pattern");
let mut exp_ty = self.resolve_type_vars_with_obligations(&expected); |
kennytm
added
S-waiting-on-review
and removed
S-waiting-on-bors
labels
Oct 31, 2017
This comment has been minimized.
This comment has been minimized.
|
@kennytm I cannot imagine how this change would affect that particular test -- it compiles an empty file, so I don't think that this code will trigger at all. I do think the test is useful, but I wonder if we should consider e.g. directing the log output into Regardless, I'm inclined to r+ again because I don't think the problem is related to this patch per se. But I'll try to run a local test to verify. |
This comment has been minimized.
This comment has been minimized.
|
Before:
With this branch:
No real difference. This branch for some reason took an extra few seconds, but it's probably because I was compiling other working directories at the same time or something. |
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Nov 2, 2017
This comment has been minimized.
This comment has been minimized.
|
AppVeyor passed |
This comment has been minimized.
This comment has been minimized.
|
|
tamird commentedOct 20, 2017
•
edited
Fixes #45383.
Updates #42640.
r? @nikomatsakis
cc @tschottdorf
This needs a UI test, but thought I'd get some early feedback.