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 upSome more pattern cleanup and bugfixing #34365
Conversation
rust-highfive
assigned
eddyb
Jun 19, 2016
petrochenkov
force-pushed the
petrochenkov:deferr
branch
from
0dcd412
to
914bf7d
Jun 19, 2016
eddyb
added
the
S-waiting-on-crater
label
Jun 19, 2016
This comment has been minimized.
This comment has been minimized.
eddyb
reviewed
Jun 19, 2016
| let adt = ccx.tcx.intern_adt_def(did, ty::AdtKind::Struct, variants); | ||
| if let Some(ctor_id) = ctor_id { | ||
| // Make adt definition available through constructor id as well. | ||
| ccx.tcx.insert_adt_def(ctor_id, adt); |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
petrochenkov
Jun 19, 2016
•
Author
Contributor
So you can go directly from Def::Struct to ADT definition regardless of where this Def::Struct is used - in a pattern, expression or a type. Sometimes Def::Struct denotes a type and sometimes a constructor and previously lookup_adt_def worked only with Def::Structs in type context and panicked otherwise, so workarounds had to be used.
petrochenkov
referenced this pull request
Jun 19, 2016
Merged
Merge PatKind::QPath into PatKind::Path in AST #34368
petrochenkov
reviewed
Jun 21, 2016
| let ty_substituted = self.instantiate_type_scheme(path.span, substs, &type_scheme.ty); | ||
| self.write_ty(node_id, ty_substituted); | ||
| self.write_substs(node_id, ty::ItemSubsts { | ||
| substs: substs |
This comment has been minimized.
This comment has been minimized.
petrochenkov
Jun 21, 2016
Author
Contributor
Hm, this is probably a mistake and regression. The substs written are substs before instantiate_type_scheme, not after.
I.e. for
type Alias<T> = S<T, u16>;
// Inside match
Alias::<u8> { .. }
only u8 is written, not [u8, u16].
However, instantiate_path does the same mistake(?) even without this PR.
petrochenkov
referenced this pull request
Jun 22, 2016
Closed
Rustc panic when wrong namespace in destructuring patern #34413
jseyfried
added a commit
to jseyfried/rust
that referenced
this pull request
Jun 25, 2016
jseyfried
added a commit
to jseyfried/rust
that referenced
this pull request
Jun 25, 2016
This comment has been minimized.
This comment has been minimized.
|
|
petrochenkov
force-pushed the
petrochenkov:deferr
branch
from
914bf7d
to
6bd1d7a
Jun 29, 2016
This comment has been minimized.
This comment has been minimized.
|
Rebased. |
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov Sorry about that, @nikomatsakis is on vacation. |
eddyb
added
I-nominated
T-lang
and removed
S-waiting-on-crater
labels
Jun 29, 2016
This comment has been minimized.
This comment has been minimized.
|
So as I wrote on IRC, I don't think that |
petrochenkov
referenced this pull request
Jun 29, 2016
Closed
Non-existent struct enum variant in pattern causes ICE #34564
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
I agree on both counts. It seems OK for this name to be available on stable Rust. |
This comment has been minimized.
This comment has been minimized.
|
Lang team meeting: we decided we should try this PR, but with marking the |
This comment has been minimized.
This comment has been minimized.
|
@petrochenkov Looks like |
pnkfelix
removed
the
I-nominated
label
Jul 7, 2016
petrochenkov
added some commits
Jun 10, 2016
petrochenkov
added some commits
Jun 11, 2016
petrochenkov
force-pushed the
petrochenkov:deferr
branch
from
6bd1d7a
to
d27e55c
Jul 8, 2016
This comment has been minimized.
This comment has been minimized.
|
Rebased, |
This comment has been minimized.
This comment has been minimized.
|
Crater report only shows 4 regressions in code using the unstable @alexcrichton @aturon Can we merge this with the stabilization of |
This comment has been minimized.
This comment has been minimized.
|
@eddyb Yep, at this point everybody's signed off on that step. |
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
petrochenkov commentedJun 19, 2016
•
edited
The next part of #34095
The most significant fixed mistake is definitions for partially resolved associated types not being updated after full resolution.
For this reason unstable associated types of stable traits, like
FnOnce::Output, could be used in stable code when written in unqualified form. Now they are properly checked, this is a [breaking-change] (pretty minor one, but a crater run would be nice). The fix is not to use unstable library features in stable code, alternativelyFnOnce::Outputcan be stabilized.Besides that, paths in struct patterns and expressions
S::A { .. }are now fully resolved as associated types. Such types cannot be identified as structs at the moment, i.e. the change doesn't make previously invalid code valid, but it improves error diagnostics.Other changes:
Def::Erris supported better (less chances for ICEs for erroneous code), some incorrect error messages are corrected, some duplicated error messages are not reported, ADT definitions are now available through constructor IDs, everything else is cleanup and code audit.Fixes #34209
Closes #22933 (adds tests)
r? @eddyb