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

Rollup of 24 pull requests #79057

Closed
wants to merge 70 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
3dd0a7d
Do not call `unwrap` with `signatures` option enabled
JohnTitor Oct 25, 2020
459dae9
fix #72680 by explicitly checking for or-pattern before test
mark-i-m Nov 7, 2020
43e4783
address reviewer comments
mark-i-m Nov 9, 2020
659aa77
test: add `()=()=()=...` to weird-exprs.rs
slanterns Nov 11, 2020
f5e67b5
Add a test for r# identifiers
poliorcetics Nov 12, 2020
9c70696
Ignore tidy linelength
poliorcetics Nov 12, 2020
bd0eb07
Added some unit tests as requested
richkadel Nov 3, 2020
ecfeac5
Use intradoc-links for the whole test, add a @has check
poliorcetics Nov 12, 2020
562d50e
Include llvm-as in llvm-tools-preview component
zec Nov 12, 2020
e4a43fc
Merge changes from rust-lang/rust
zec Nov 12, 2020
38fa66a
Rename empty_tuple_assignment to monkey_barrel
slanterns Nov 12, 2020
eb9f2bb
Overcome Sync issues with non-parallel compiler
richkadel Nov 12, 2020
775f1e5
fix pretty print for qpath
gui1117 Nov 12, 2020
f8a32e9
Bumped minimal tested LLVM version to 9
DevJPM Nov 7, 2020
6323565
explicitly add llvm-9-dev in dockerfile
DevJPM Nov 7, 2020
6830f1c
Bump the minimal supported LLVM version in the bootstrapping code to 9.0
DevJPM Nov 7, 2020
b51bcc7
fully exploited the dropped support of LLVM 8
DevJPM Nov 7, 2020
8236830
Removed an unused function now that LLVM 9 is the minimal supported v…
DevJPM Nov 7, 2020
7e443c4
Dropped Support for Bidirectional Custom Target Definition Emulation
DevJPM Nov 10, 2020
86193ca
fixed a re-format due to removed chain call
DevJPM Nov 10, 2020
3747df7
Avoid installing external LLVM dylibs
Mark-Simulacrum Nov 12, 2020
010265a
Fix an intrinsic invocation on threaded wasm
alexcrichton Nov 12, 2020
dd682cb
rustc_target: Fix dash vs underscore mismatches in option names
petrochenkov Nov 12, 2020
0b4af16
Never inline when `no_sanitize` attributes differ
tmiasko Nov 11, 2020
ae43326
Never inline cold functions
tmiasko Nov 11, 2020
9bb3d6b
Remove check for impossible condition
tmiasko Nov 11, 2020
66cadec
Fix generator inlining by checking for rust-call abi and spread arg
tmiasko Nov 11, 2020
79d853e
Never inline C variadic functions
tmiasko Nov 11, 2020
2a010dd
./x.py test --bless
tmiasko Nov 11, 2020
d486bfc
Normalize function type during validation
tmiasko Nov 12, 2020
99be78d
Always use param_env_reveal_all_normalized in validator
tmiasko Nov 12, 2020
cc6baf7
rustc_expand: Mark inner `#![test]` attributes as soft-unstable
petrochenkov Nov 12, 2020
31741aa
Add `--color` support to bootstrap
jyn514 Nov 12, 2020
8766c04
cleanup: Remove `ParseSess::injected_crate_name`
petrochenkov Nov 12, 2020
c131063
Added a unit test for BcbCounters
richkadel Nov 13, 2020
309d863
Fix wrong XPath
poliorcetics Nov 13, 2020
894b1f7
extract closures into a separate trait
lcnr Nov 13, 2020
b4b0ef3
Addressed feedback
richkadel Nov 13, 2020
75dfc71
refactor: vec_deque ignore-tidy-filelength
DeveloperC286 Nov 13, 2020
bf6902c
Add BTreeMap::retain and BTreeSet::retain
mbrubeck Nov 13, 2020
7eb1a1a
Validate that locals have a corresponding `LocalDecl`
camelid Nov 13, 2020
ac4c1f5
rustc_resolve: Make `macro_rules` scope chain compression lazy
petrochenkov Nov 13, 2020
41c44b4
Move Steal to rustc_data_structures.
cjgillot Nov 14, 2020
03cbee8
Rename ItemEnum -> ItemKind, inner -> kind
jyn514 Nov 14, 2020
b825ae7
Style nit
mark-i-m Nov 14, 2020
8cf3564
Add underscore expressions for destructuring assignments
fanzier Nov 11, 2020
3ae1a3a
Rollup merge of #78352 - JohnTitor:issue-75229, r=Dylan-DPC
jonas-schievink Nov 14, 2020
b1a3a09
Rollup merge of #78590 - DeveloperC286:issue_60302, r=varkor
jonas-schievink Nov 14, 2020
a8d6c47
Rollup merge of #78848 - DevJPM:ci-llvm-9, r=nikic
jonas-schievink Nov 14, 2020
4319f8c
Rollup merge of #78856 - mark-i-m:fix-or-pat-ice, r=matthewjasper
jonas-schievink Nov 14, 2020
ddb4850
Rollup merge of #78948 - slanterns:master, r=varkor
jonas-schievink Nov 14, 2020
e7b2849
Rollup merge of #78962 - poliorcetics:rustdoc-raw-ident-test, r=jyn514
jonas-schievink Nov 14, 2020
8d38921
Rollup merge of #78963 - richkadel:llvm-coverage-counters-2.0.4, r=tm…
jonas-schievink Nov 14, 2020
43d3afa
Rollup merge of #78966 - tmiasko:inline-never, r=oli-obk
jonas-schievink Nov 14, 2020
07d508c
Rollup merge of #78968 - zec:add-llvm-as, r=Mark-Simulacrum
jonas-schievink Nov 14, 2020
ad2e901
Rollup merge of #78969 - tmiasko:normalize, r=davidtwco
jonas-schievink Nov 14, 2020
177755f
Rollup merge of #78980 - thiolliere:gui-fix-qpath, r=estebank
jonas-schievink Nov 14, 2020
b636385
Rollup merge of #78986 - Mark-Simulacrum:fix-llvm, r=alexcrichton
jonas-schievink Nov 14, 2020
d1ae8db
Rollup merge of #78988 - alexcrichton:one-more-intrinsic, r=sfackler
jonas-schievink Nov 14, 2020
c7546bb
Rollup merge of #78993 - petrochenkov:specdash, r=oli-obk
jonas-schievink Nov 14, 2020
423fccc
Rollup merge of #79003 - petrochenkov:innertest, r=estebank
jonas-schievink Nov 14, 2020
4b4cfdc
Rollup merge of #79004 - jyn514:bacon, r=Mark-Simulacrum
jonas-schievink Nov 14, 2020
cffb7d5
Rollup merge of #79005 - petrochenkov:noinjected, r=davidtwco
jonas-schievink Nov 14, 2020
86842af
Rollup merge of #79016 - fanzier:underscore-expressions, r=petrochenkov
jonas-schievink Nov 14, 2020
8f47ccf
Rollup merge of #79019 - lcnr:generic-arg-validation, r=petrochenkov
jonas-schievink Nov 14, 2020
81acd2a
Rollup merge of #79026 - mbrubeck:btree_retain, r=m-ou-se
jonas-schievink Nov 14, 2020
96d4f77
Rollup merge of #79031 - camelid:mir-validate-local-decl, r=jonas-sch…
jonas-schievink Nov 14, 2020
68bcb6f
Rollup merge of #79034 - petrochenkov:mrscopes3, r=eddyb
jonas-schievink Nov 14, 2020
94528fe
Rollup merge of #79036 - cjgillot:steal, r=oli-obk
jonas-schievink Nov 14, 2020
a0a619f
Rollup merge of #79041 - jyn514:inner-to-kind, r=petrochenkov
jonas-schievink Nov 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add underscore expressions for destructuring assignments
Co-authored-by: varkor <[email protected]>
fanzier and varkor committed Nov 14, 2020
commit 8cf35643106bba09b5d6c71ceac74dc58573f371
3 changes: 3 additions & 0 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
@@ -1192,6 +1192,7 @@ impl Expr {
ExprKind::Field(..) => ExprPrecedence::Field,
ExprKind::Index(..) => ExprPrecedence::Index,
ExprKind::Range(..) => ExprPrecedence::Range,
ExprKind::Underscore => ExprPrecedence::Path,
ExprKind::Path(..) => ExprPrecedence::Path,
ExprKind::AddrOf(..) => ExprPrecedence::AddrOf,
ExprKind::Break(..) => ExprPrecedence::Break,
@@ -1324,6 +1325,8 @@ pub enum ExprKind {
Index(P<Expr>, P<Expr>),
/// A range (e.g., `1..2`, `1..`, `..2`, `1..=2`, `..=2`; and `..` in destructuring assingment).
Range(Option<P<Expr>>, Option<P<Expr>>, RangeLimits),
/// An underscore, used in destructuring assignment to ignore a value.
Underscore,

/// Variable reference, possibly containing `::` and/or type
/// parameters (e.g., `foo::bar::<baz>`).
1 change: 1 addition & 0 deletions compiler/rustc_ast/src/mut_visit.rs
Original file line number Diff line number Diff line change
@@ -1232,6 +1232,7 @@ pub fn noop_visit_expr<T: MutVisitor>(
visit_opt(e1, |e1| vis.visit_expr(e1));
visit_opt(e2, |e2| vis.visit_expr(e2));
}
ExprKind::Underscore => {}
ExprKind::Path(qself, path) => {
vis.visit_qself(qself);
vis.visit_path(path);
1 change: 1 addition & 0 deletions compiler/rustc_ast/src/visit.rs
Original file line number Diff line number Diff line change
@@ -806,6 +806,7 @@ pub fn walk_expr<'a, V: Visitor<'a>>(visitor: &mut V, expression: &'a Expr) {
walk_list!(visitor, visit_expr, start);
walk_list!(visitor, visit_expr, end);
}
ExprKind::Underscore => {}
ExprKind::Path(ref maybe_qself, ref path) => {
if let Some(ref qself) = *maybe_qself {
visitor.visit_ty(&qself.ty);
19 changes: 18 additions & 1 deletion compiler/rustc_ast_lowering/src/expr.rs
Original file line number Diff line number Diff line change
@@ -164,6 +164,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
ExprKind::Range(ref e1, ref e2, lims) => {
self.lower_expr_range(e.span, e1.as_deref(), e2.as_deref(), lims)
}
ExprKind::Underscore => {
self.sess
.struct_span_err(
e.span,
"in expressions, `_` can only be used on the left-hand side of an assignment",
)
.span_label(e.span, "`_` not allowed here")
.emit();
hir::ExprKind::Err
}
ExprKind::Path(ref qself, ref path) => {
let qpath = self.lower_qpath(
e.id,
@@ -863,7 +873,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
// Return early in case of an ordinary assignment.
fn is_ordinary(lower_ctx: &mut LoweringContext<'_, '_>, lhs: &Expr) -> bool {
match &lhs.kind {
ExprKind::Array(..) | ExprKind::Struct(..) | ExprKind::Tup(..) => false,
ExprKind::Array(..)
| ExprKind::Struct(..)
| ExprKind::Tup(..)
| ExprKind::Underscore => false,
// Check for tuple struct constructor.
ExprKind::Call(callee, ..) => lower_ctx.extract_tuple_struct_path(callee).is_none(),
ExprKind::Paren(e) => {
@@ -943,6 +956,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
assignments: &mut Vec<hir::Stmt<'hir>>,
) -> &'hir hir::Pat<'hir> {
match &lhs.kind {
// Underscore pattern.
ExprKind::Underscore => {
return self.pat_without_dbm(lhs.span, hir::PatKind::Wild);
}
// Slice patterns.
ExprKind::Array(elements) => {
let (pats, rest) =
6 changes: 5 additions & 1 deletion compiler/rustc_ast_passes/src/feature_gate.rs
Original file line number Diff line number Diff line change
@@ -630,7 +630,11 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
gate_all!(const_trait_impl, "const trait impls are experimental");
gate_all!(half_open_range_patterns, "half-open range patterns are unstable");
gate_all!(inline_const, "inline-const is experimental");
gate_all!(destructuring_assignment, "destructuring assignments are unstable");
if sess.parse_sess.span_diagnostic.err_count() == 0 {
// Errors for `destructuring_assignment` can get quite noisy, especially where `_` is
// involved, so we only emit errors where there are no other parsing errors.
gate_all!(destructuring_assignment, "destructuring assignments are unstable");
}

// All uses of `gate_all!` below this point were added in #65742,
// and subsequently disabled (with the non-early gating readded).
1 change: 1 addition & 0 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
@@ -2068,6 +2068,7 @@ impl<'a> State<'a> {
self.print_expr_maybe_paren(e, fake_prec);
}
}
ast::ExprKind::Underscore => self.s.word("_"),
ast::ExprKind::Path(None, ref path) => self.print_path(path, true, 0),
ast::ExprKind::Path(Some(ref qself), ref path) => self.print_qpath(path, qself, true),
ast::ExprKind::Break(opt_label, ref opt_expr) => {
3 changes: 3 additions & 0 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
@@ -1089,6 +1089,9 @@ impl<'a> Parser<'a> {
self.parse_yield_expr(attrs)
} else if self.eat_keyword(kw::Let) {
self.parse_let_expr(attrs)
} else if self.eat_keyword(kw::Underscore) {
self.sess.gated_spans.gate(sym::destructuring_assignment, self.prev_token.span);
Ok(self.mk_expr(self.prev_token.span, ExprKind::Underscore, attrs))
} else if !self.unclosed_delims.is_empty() && self.check(&token::Semi) {
// Don't complain about bare semicolons after unclosed braces
// recovery in order to keep the error count down. Fixing the
3 changes: 2 additions & 1 deletion src/test/ui/cross/cross-file-errors/main.rs
Original file line number Diff line number Diff line change
@@ -3,5 +3,6 @@ mod underscore;

fn main() {
underscore!();
//~^ ERROR expected expression, found reserved identifier `_`
//~^ ERROR `_` can only be used on the left-hand side of an assignment
//~| ERROR destructuring assignments are unstable
}
22 changes: 19 additions & 3 deletions src/test/ui/cross/cross-file-errors/main.stderr
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
error: expected expression, found reserved identifier `_`
error[E0658]: destructuring assignments are unstable
--> $DIR/underscore.rs:8:9
|
LL | _
| ^ expected expression
| ^
|
::: $DIR/main.rs:5:5
|
LL | underscore!();
| -------------- in this macro invocation
|
= note: see issue #71126 <https://github.com/rust-lang/rust/issues/71126> for more information
= help: add `#![feature(destructuring_assignment)]` to the crate attributes to enable
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error
error: in expressions, `_` can only be used on the left-hand side of an assignment
--> $DIR/underscore.rs:8:9
|
LL | _
| ^ `_` not allowed here
|
::: $DIR/main.rs:5:5
|
LL | underscore!();
| -------------- in this macro invocation
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.
3 changes: 3 additions & 0 deletions src/test/ui/destructuring-assignment/nested_destructure.rs
Original file line number Diff line number Diff line change
@@ -14,4 +14,7 @@ fn main() {
Struct { a: TupleStruct((a, b), c), b: [d] } =
Struct { a: TupleStruct((0, 1), 2), b: [3] };
assert_eq!((a, b, c, d), (0, 1, 2, 3));

// unnested underscore: just discard
_ = 1;
}
2 changes: 2 additions & 0 deletions src/test/ui/destructuring-assignment/slice_destructure.rs
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@ fn main() {
let mut c;
[a, .., b, c] = [1, 2, 3, 4, 5];
assert_eq!((a, b, c), (1, 4, 5));
[_, a, _] = [1, 2, 3];
assert_eq!((a, b), (2, 4));
[..] = [1, 2, 3];
[c, ..] = [5, 6, 6];
assert_eq!(c, 5);
Original file line number Diff line number Diff line change
@@ -4,4 +4,5 @@ fn main() {
let (mut a, mut b);
[a, .., b, ..] = [0, 1]; //~ ERROR `..` can only be used once per slice pattern
[a, a, b] = [1, 2]; //~ ERROR pattern requires 3 elements but array has 2
[_] = [1, 2]; //~ ERROR pattern requires 1 element but array has 2
}
Original file line number Diff line number Diff line change
@@ -12,6 +12,12 @@ error[E0527]: pattern requires 3 elements but array has 2
LL | [a, a, b] = [1, 2];
| ^^^^^^^^^ expected 2 elements

error: aborting due to 2 previous errors
error[E0527]: pattern requires 1 element but array has 2
--> $DIR/slice_destructure_fail.rs:7:3
|
LL | [_] = [1, 2];
| ^^^ expected 2 elements

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0527`.
6 changes: 4 additions & 2 deletions src/test/ui/destructuring-assignment/struct_destructure.rs
Original file line number Diff line number Diff line change
@@ -12,8 +12,10 @@ fn main() {
assert_eq!((a, b), (0, 1));
Struct { a: b, b: a } = Struct { a: 1, b: 2 };
assert_eq!((a,b), (2, 1));
Struct { a: _, b } = Struct { a: 1, b: 2 };
assert_eq!((a, b), (2, 2));
Struct { a, .. } = Struct { a: 1, b: 3 };
assert_eq!((a, b), (1, 1));
assert_eq!((a, b), (1, 2));
Struct { .. } = Struct { a: 1, b: 4 };
assert_eq!((a, b), (1, 1));
assert_eq!((a, b), (1, 2));
}
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@ fn main() {
let mut c;
let d = Struct { a: 0, b: 1 };
Struct { a, b, c } = Struct { a: 0, b: 1 }; //~ ERROR does not have a field named `c`
Struct { a, _ } = Struct { a: 1, b: 2 }; //~ ERROR pattern does not mention field `b`
//~| ERROR expected identifier, found reserved identifier `_`
Struct { a, ..d } = Struct { a: 1, b: 2 };
//~^ ERROR functional record updates are not allowed in destructuring assignments
Struct { a, .. }; //~ ERROR base expression required after `..`
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
error: expected identifier, found reserved identifier `_`
--> $DIR/struct_destructure_fail.rs:12:17
|
LL | Struct { a, _ } = Struct { a: 1, b: 2 };
| ------ ^ expected identifier, found reserved identifier
| |
| while parsing this struct

error: functional record updates are not allowed in destructuring assignments
--> $DIR/struct_destructure_fail.rs:12:19
--> $DIR/struct_destructure_fail.rs:14:19
|
LL | Struct { a, ..d } = Struct { a: 1, b: 2 };
| ^ help: consider removing the trailing pattern

error: base expression required after `..`
--> $DIR/struct_destructure_fail.rs:14:19
--> $DIR/struct_destructure_fail.rs:16:19
|
LL | Struct { a, .. };
| ^ add a base expression here
@@ -16,6 +24,22 @@ error[E0026]: struct `Struct` does not have a field named `c`
LL | Struct { a, b, c } = Struct { a: 0, b: 1 };
| ^ struct `Struct` does not have this field

error: aborting due to 3 previous errors
error[E0027]: pattern does not mention field `b`
--> $DIR/struct_destructure_fail.rs:12:5
|
LL | Struct { a, _ } = Struct { a: 1, b: 2 };
| ^^^^^^^^^^^^^^^ missing field `b`
|
help: include the missing field in the pattern
|
LL | Struct { a, b, _ } = Struct { a: 1, b: 2 };
| ^^^
help: if you don't care about this missing field, you can explicitly ignore it
|
LL | Struct { a, .., _ } = Struct { a: 1, b: 2 };
| ^^^^

error: aborting due to 5 previous errors

For more information about this error, try `rustc --explain E0026`.
Some errors have detailed explanations: E0026, E0027.
For more information about an error, try `rustc --explain E0026`.
2 changes: 2 additions & 0 deletions src/test/ui/destructuring-assignment/tuple_destructure.rs
Original file line number Diff line number Diff line change
@@ -16,6 +16,8 @@ fn main() {
assert_eq!((a, b), (2, 2));
(b, ..) = (5, 6, 7);
assert_eq!(b, 5);
(a, _) = (8, 9);
assert_eq!(a, 8);

// Test for a non-Copy type (String):
let (mut c, mut d);
Original file line number Diff line number Diff line change
@@ -7,4 +7,5 @@ fn main() {
(a, .., b, ..) = (0, 1); //~ ERROR `..` can only be used once per tuple pattern
(a, a, b) = (1, 2); //~ ERROR mismatched types
(C, ..) = (0,1); //~ ERROR invalid left-hand side of assignment
(_,) = (1, 2); //~ ERROR mismatched types
}
Original file line number Diff line number Diff line change
@@ -25,7 +25,18 @@ LL | (C, ..) = (0,1);
| |
| cannot assign to this expression

error: aborting due to 3 previous errors
error[E0308]: mismatched types
--> $DIR/tuple_destructure_fail.rs:10:5
|
LL | (_,) = (1, 2);
| ^^^^ ------ this expression has type `({integer}, {integer})`
| |
| expected a tuple with 2 elements, found one with 1 element
|
= note: expected type `({integer}, {integer})`
found tuple `(_,)`

error: aborting due to 4 previous errors

Some errors have detailed explanations: E0070, E0308.
For more information about an error, try `rustc --explain E0070`.
Original file line number Diff line number Diff line change
@@ -23,8 +23,10 @@ fn main() {
assert_eq!((a, b), (0, 1));
TupleStruct(a, .., b) = TupleStruct(1, 2);
assert_eq!((a, b), (1, 2));
TupleStruct(_, a) = TupleStruct(2, 2);
assert_eq!((a, b), (2, 2));
TupleStruct(..) = TupleStruct(3, 4);
assert_eq!((a, b), (1, 2));
assert_eq!((a, b), (2, 2));
TupleStruct(5,6).assign(&mut a, &mut b);
assert_eq!((a, b), (5, 6));
Enum::SingleVariant(a, b) = Enum::SingleVariant(7, 8);
Original file line number Diff line number Diff line change
@@ -29,8 +29,12 @@ fn main() {

TupleStruct(a, a, b) = TupleStruct(1, 2);
//~^ ERROR this pattern has 3 fields, but the corresponding tuple struct has 2 fields
TupleStruct(_) = TupleStruct(1, 2);
//~^ ERROR this pattern has 1 field, but the corresponding tuple struct has 2 fields
Enum::SingleVariant(a, a, b) = Enum::SingleVariant(1, 2);
//~^ ERROR this pattern has 3 fields, but the corresponding tuple variant has 2 fields
Enum::SingleVariant(_) = Enum::SingleVariant(1, 2);
//~^ ERROR this pattern has 1 field, but the corresponding tuple variant has 2 fields

// Check if `test` is recognized as not a tuple struct but a function call:
test() = TupleStruct(0, 0);
Original file line number Diff line number Diff line change
@@ -23,40 +23,58 @@ LL | struct TupleStruct<S, T>(S, T);
LL | TupleStruct(a, a, b) = TupleStruct(1, 2);
| ^^^^^^^^^^^^^^^^^^^^ expected 2 fields, found 3

error[E0023]: this pattern has 3 fields, but the corresponding tuple variant has 2 fields
error[E0023]: this pattern has 1 field, but the corresponding tuple struct has 2 fields
--> $DIR/tuple_struct_destructure_fail.rs:32:5
|
LL | struct TupleStruct<S, T>(S, T);
| ------------------------------- tuple struct defined here
...
LL | TupleStruct(_) = TupleStruct(1, 2);
| ^^^^^^^^^^^^^^ expected 2 fields, found 1

error[E0023]: this pattern has 3 fields, but the corresponding tuple variant has 2 fields
--> $DIR/tuple_struct_destructure_fail.rs:34:5
|
LL | SingleVariant(S, T)
| ------------------- tuple variant defined here
...
LL | Enum::SingleVariant(a, a, b) = Enum::SingleVariant(1, 2);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 2 fields, found 3

error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields
--> $DIR/tuple_struct_destructure_fail.rs:36:5
|
LL | SingleVariant(S, T)
| ------------------- tuple variant defined here
...
LL | Enum::SingleVariant(_) = Enum::SingleVariant(1, 2);
| ^^^^^^^^^^^^^^^^^^^^^^ expected 2 fields, found 1

error[E0070]: invalid left-hand side of assignment
--> $DIR/tuple_struct_destructure_fail.rs:36:12
--> $DIR/tuple_struct_destructure_fail.rs:40:12
|
LL | test() = TupleStruct(0, 0);
| ------ ^
| |
| cannot assign to this expression

error[E0070]: invalid left-hand side of assignment
--> $DIR/tuple_struct_destructure_fail.rs:38:14
--> $DIR/tuple_struct_destructure_fail.rs:42:14
|
LL | (test)() = TupleStruct(0, 0);
| -------- ^
| |
| cannot assign to this expression

error[E0070]: invalid left-hand side of assignment
--> $DIR/tuple_struct_destructure_fail.rs:40:38
--> $DIR/tuple_struct_destructure_fail.rs:44:38
|
LL | <Alias::<isize> as Test>::test() = TupleStruct(0, 0);
| -------------------------------- ^
| |
| cannot assign to this expression

error: aborting due to 7 previous errors
error: aborting due to 9 previous errors

Some errors have detailed explanations: E0023, E0070.
For more information about an error, try `rustc --explain E0023`.
Original file line number Diff line number Diff line change
@@ -4,5 +4,7 @@ struct S { x : u32 }

#[cfg(FALSE)]
fn foo() {
_; //~ ERROR destructuring assignments are unstable

S { x: 5, .. }; //~ ERROR destructuring assignments are unstable
}
Loading