-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
typeck: suggest use of match_default_bindings feature #45409
Conversation
264265f
to
bca2201
Compare
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. |
a3dbc28
to
570f476
Compare
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.
Looks great. I left one suggestion -- let me know what you think.
src/librustc_typeck/check/_match.rs
Outdated
err.span_suggestion(pat.span, "consider using", format!("&{}", &snippet)); | ||
} | ||
err.emit(); | ||
None |
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, 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).
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.
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"; |
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.
let's change this test from "foo"
to 22
-- I feel like the message about non-reference patterns isn't central to the test.
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.
Done.
@@ -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"; |
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.
let's change this test from "foo"
to 22
-- I feel like the message about non-reference patterns isn't central to the test.
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.
Done.
@@ -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"; |
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.
let's change this test from "foo"
to 22
-- I feel like the message about non-reference patterns isn't central to the test.
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.
Done.
@@ -9,5 +9,7 @@ | |||
// except according to those terms. | |||
|
|||
fn main() { | |||
let true = "foo"; //~ error: mismatched types | |||
let true = "foo"; |
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.
let's change this test from "foo"
to 22
-- I feel like the message about non-reference patterns isn't central to the test.
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.
Done.
570f476
to
bd5a587
Compare
@kennytm should be waiting-on-review again. |
@bors r+ |
📌 Commit bd5a587 has been approved by |
@tamird sorry for the delay; I was at the Rust Belt Rust conference. Looks good, thanks! |
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>
.
|
@bors r- (Waiting on author to cleanup.) |
bd5a587
to
9844777
Compare
OK, should be good to go, unless y'all have tweaks for the message. |
@bors r=nikomatsakis |
📌 Commit 9844777 has been approved by |
⌛ Testing commit 9844777 with merge 772b3b75fb91588606b396da6e00fc91e447fce9... |
💔 Test failed - status-travis |
@bors retry #45230 LLDB segfault at
|
⌛ Testing commit 9844777 with merge a274ae0746b48c8dc7926e35a75b690a2b02e059... |
💔 Test failed - status-appveyor |
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... |
@bors retry |
@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 |
@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 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. |
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. |
@bors r+ |
📌 Commit 9844777 has been approved by |
…atsakis typeck: suggest use of match_default_bindings feature Fixes #45383. Updates #42640. r? @nikomatsakis cc @tschottdorf This needs a UI test, but thought I'd get some early feedback.
AppVeyor passed 😕 I'm going to record that as a spurious error. |
☀️ Test successful - status-appveyor, status-travis |
Fixes #45383.
Updates #42640.
r? @nikomatsakis
cc @tschottdorf
This needs a UI test, but thought I'd get some early feedback.