Skip to content

Commit 60552c7

Browse files
varkorfanzier
authored andcommitted
Fix rebase issues
1 parent fbced7d commit 60552c7

File tree

9 files changed

+78
-83
lines changed

9 files changed

+78
-83
lines changed

compiler/rustc_ast/src/ast.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ pub struct Expr {
10611061

10621062
// `Expr` is used a lot. Make sure it doesn't unintentionally get bigger.
10631063
#[cfg(target_arch = "x86_64")]
1064-
rustc_data_structures::static_assert_size!(Expr, 112);
1064+
rustc_data_structures::static_assert_size!(Expr, 120);
10651065

10661066
impl Expr {
10671067
/// Returns `true` if this expression would be valid somewhere that expects a value;

compiler/rustc_ast_passes/src/feature_gate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ pub fn check_crate(krate: &ast::Crate, sess: &Session) {
630630
gate_all!(const_trait_impl, "const trait impls are experimental");
631631
gate_all!(half_open_range_patterns, "half-open range patterns are unstable");
632632
gate_all!(inline_const, "inline-const is experimental");
633-
if parse_sess.span_diagnostic.err_count() == 0 {
633+
if sess.parse_sess.span_diagnostic.err_count() == 0 {
634634
// Errors for `destructuring_assignment` can get quite noisy, especially where `_` is
635635
// involved, so we only emit errors where there are no other parsing errors.
636636
gate_all!(destructuring_assignment, "destructuring assignments are unstable");

compiler/rustc_ast_pretty/src/pprust/state.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1751,19 +1751,19 @@ impl<'a> State<'a> {
17511751
|f| f.span,
17521752
);
17531753
match rest {
1754-
StructRest::Base(_) | StructRest::Rest(_) => {
1754+
ast::StructRest::Base(_) | ast::StructRest::Rest(_) => {
17551755
self.ibox(INDENT_UNIT);
17561756
if !fields.is_empty() {
17571757
self.s.word(",");
17581758
self.s.space();
17591759
}
17601760
self.s.word("..");
1761-
if let StructRest::Base(ref expr) = *rest {
1761+
if let ast::StructRest::Base(ref expr) = *rest {
17621762
self.print_expr(expr);
17631763
}
17641764
self.end();
17651765
}
1766-
StructRest::None if !fields.is_empty() => self.s.word(","),
1766+
ast::StructRest::None if !fields.is_empty() => self.s.word(","),
17671767
_ => {}
17681768
}
17691769
self.s.word("}");

compiler/rustc_parse/src/parser/expr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2108,11 +2108,11 @@ impl<'a> Parser<'a> {
21082108
// We permit `.. }` on the left-hand side of a destructuring assignment.
21092109
if self.token == token::CloseDelim(token::Brace) {
21102110
self.sess.gated_spans.gate(sym::destructuring_assignment, self.prev_token.span);
2111-
base = StructRest::Rest(self.prev_token.span.shrink_to_hi());
2111+
base = ast::StructRest::Rest(self.prev_token.span.shrink_to_hi());
21122112
break;
21132113
}
21142114
match self.parse_expr() {
2115-
Ok(e) => base = StructRest::Base(e),
2115+
Ok(e) => base = ast::StructRest::Base(e),
21162116
Err(mut e) if recover => {
21172117
e.emit();
21182118
self.recover_stmt();

compiler/rustc_save_analysis/src/dump_visitor.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ impl<'tcx> DumpVisitor<'tcx> {
816816
path: &'tcx hir::QPath<'tcx>,
817817
fields: &'tcx [hir::Field<'tcx>],
818818
variant: &'tcx ty::VariantDef,
819-
rest: &'tcx StructRest,
819+
rest: Option<&'tcx hir::Expr<'tcx>>,
820820
) {
821821
if let Some(struct_lit_data) = self.save_ctxt.get_expr_data(ex) {
822822
if let hir::QPath::Resolved(_, path) = path {
@@ -836,8 +836,8 @@ impl<'tcx> DumpVisitor<'tcx> {
836836
}
837837
}
838838

839-
if let StructRest::Base(base) = rest {
840-
self.visit_expr(base);
839+
if let Some(base) = rest {
840+
self.visit_expr(&base);
841841
}
842842
}
843843

@@ -1411,7 +1411,7 @@ impl<'tcx> Visitor<'tcx> for DumpVisitor<'tcx> {
14111411
}
14121412
};
14131413
let res = self.save_ctxt.get_path_res(hir_expr.hir_id);
1414-
self.process_struct_lit(ex, path, fields, adt.variant_of_res(res), rest)
1414+
self.process_struct_lit(ex, path, fields, adt.variant_of_res(res), *rest)
14151415
}
14161416
hir::ExprKind::MethodCall(ref seg, _, args, _) => {
14171417
self.process_method_call(ex, seg, args)

src/test/ui/issues/issue-34334.rs

-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
fn main () {
22
let sr: Vec<(u32, _, _) = vec![];
33
//~^ ERROR expected one of `,` or `>`, found `=`
4-
//~| ERROR expected value, found struct `Vec`
5-
//~| ERROR expected value, found builtin type `u32`
6-
//~| ERROR mismatched types
7-
//~| ERROR invalid left-hand side of assignment
8-
//~| ERROR expected expression, found reserved identifier `_`
9-
//~| ERROR expected expression, found reserved identifier `_`
104
let sr2: Vec<(u32, _, _)> = sr.iter().map(|(faction, th_sender, th_receiver)| {}).collect();
115
//~^ ERROR a value of type `Vec<(u32, _, _)>` cannot be built
126
}

src/test/ui/issues/issue-34334.stderr

+3-45
Original file line numberDiff line numberDiff line change
@@ -6,56 +6,14 @@ LL | let sr: Vec<(u32, _, _) = vec![];
66
| |
77
| while parsing the type for `sr`
88

9-
error[E0423]: expected value, found struct `Vec`
10-
--> $DIR/issue-34334.rs:2:13
11-
|
12-
LL | let sr: Vec<(u32, _, _) = vec![];
13-
| ^^^ did you mean `Vec { /* fields */ }`?
14-
15-
error[E0423]: expected value, found builtin type `u32`
16-
--> $DIR/issue-34334.rs:2:18
17-
|
18-
LL | let sr: Vec<(u32, _, _) = vec![];
19-
| ^^^ not a value
20-
21-
error: expected expression, found reserved identifier `_`
22-
--> $DIR/issue-34334.rs:2:23
23-
|
24-
LL | let sr: Vec<(u32, _, _) = vec![];
25-
| ^ expected expression
26-
27-
error: expected expression, found reserved identifier `_`
28-
--> $DIR/issue-34334.rs:2:26
29-
|
30-
LL | let sr: Vec<(u32, _, _) = vec![];
31-
| ^ expected expression
32-
33-
error[E0308]: mismatched types
34-
--> $DIR/issue-34334.rs:2:31
35-
|
36-
LL | let sr: Vec<(u32, _, _) = vec![];
37-
| ^^^^^^ expected `bool`, found struct `std::vec::Vec`
38-
|
39-
= note: expected type `bool`
40-
found struct `std::vec::Vec<_>`
41-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
42-
43-
error[E0070]: invalid left-hand side of assignment
44-
--> $DIR/issue-34334.rs:2:29
45-
|
46-
LL | let sr: Vec<(u32, _, _) = vec![];
47-
| --------------- ^
48-
| |
49-
| cannot assign to this expression
50-
51-
error[E0599]: no method named `iter` found for unit type `()` in the current scope
52-
--> $DIR/issue-34334.rs:10:36
9+
error[E0277]: a value of type `Vec<(u32, _, _)>` cannot be built from an iterator over elements of type `()`
10+
--> $DIR/issue-34334.rs:4:87
5311
|
5412
LL | let sr2: Vec<(u32, _, _)> = sr.iter().map(|(faction, th_sender, th_receiver)| {}).collect();
5513
| ^^^^^^^ value of type `Vec<(u32, _, _)>` cannot be built from `std::iter::Iterator<Item=()>`
5614
|
5715
= help: the trait `FromIterator<()>` is not implemented for `Vec<(u32, _, _)>`
5816

59-
error: aborting due to 8 previous errors
17+
error: aborting due to 2 previous errors
6018

6119
For more information about this error, try `rustc --explain E0277`.

src/test/ui/suggestions/if-let-typo.rs

+5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ fn main() {
22
let foo = Some(0);
33
let bar = None;
44
if Some(x) = foo {} //~ ERROR cannot find value `x` in this scope
5+
//~^ ERROR mismatched types
6+
//~^^ ERROR destructuring assignments are unstable
57
if Some(foo) = bar {} //~ ERROR mismatched types
8+
//~^ ERROR destructuring assignments are unstable
69
if 3 = foo {} //~ ERROR mismatched types
710
if Some(3) = foo {} //~ ERROR mismatched types
11+
//~^ ERROR destructuring assignments are unstable
12+
//~^^ ERROR invalid left-hand side of assignment
813
}

src/test/ui/suggestions/if-let-typo.stderr

+59-21
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,51 @@ help: you might have meant to use pattern matching
99
LL | if let Some(x) = foo {}
1010
| ^^^
1111

12+
error[E0658]: destructuring assignments are unstable
13+
--> $DIR/if-let-typo.rs:4:16
14+
|
15+
LL | if Some(x) = foo {}
16+
| ------- ^
17+
| |
18+
| cannot assign to this expression
19+
|
20+
= note: see issue #71126 <https://github.com/rust-lang/rust/issues/71126> for more information
21+
= help: add `#![feature(destructuring_assignment)]` to the crate attributes to enable
22+
1223
error[E0308]: mismatched types
13-
--> $DIR/if-let-typo.rs:5:8
24+
--> $DIR/if-let-typo.rs:4:8
25+
|
26+
LL | if Some(x) = foo {}
27+
| ^^^^^^^^^^^^^ expected `bool`, found `()`
28+
29+
error[E0658]: destructuring assignments are unstable
30+
--> $DIR/if-let-typo.rs:7:18
1431
|
1532
LL | if Some(foo) = bar {}
16-
| ^^^^^^^^^^^^^^^ expected `bool`, found `()`
33+
| --------- ^
34+
| |
35+
| cannot assign to this expression
1736
|
18-
help: you might have meant to use pattern matching
37+
= note: see issue #71126 <https://github.com/rust-lang/rust/issues/71126> for more information
38+
= help: add `#![feature(destructuring_assignment)]` to the crate attributes to enable
39+
40+
error[E0308]: mismatched types
41+
--> $DIR/if-let-typo.rs:7:8
1942
|
20-
LL | if let Some(foo) = bar {}
21-
| ^^^
22-
help: you might have meant to compare for equality
43+
LL | if Some(foo) = bar {}
44+
| ^^^^^^^^^^^^^^^ expected `bool`, found `()`
45+
46+
error[E0308]: mismatched types
47+
--> $DIR/if-let-typo.rs:9:12
48+
|
49+
LL | if 3 = foo {}
50+
| ^^^ expected integer, found enum `Option`
2351
|
24-
LL | if Some(foo) == bar {}
25-
| ^^
52+
= note: expected type `{integer}`
53+
found enum `Option<{integer}>`
2654

2755
error[E0308]: mismatched types
28-
--> $DIR/if-let-typo.rs:6:8
56+
--> $DIR/if-let-typo.rs:9:8
2957
|
3058
LL | if 3 = foo {}
3159
| ^^^^^^^ expected `bool`, found `()`
@@ -35,22 +63,32 @@ help: you might have meant to use pattern matching
3563
LL | if let 3 = foo {}
3664
| ^^^
3765

38-
error[E0308]: mismatched types
39-
--> $DIR/if-let-typo.rs:7:8
66+
error[E0658]: destructuring assignments are unstable
67+
--> $DIR/if-let-typo.rs:11:16
4068
|
4169
LL | if Some(3) = foo {}
42-
| ^^^^^^^^^^^^^ expected `bool`, found `()`
70+
| ------- ^
71+
| |
72+
| cannot assign to this expression
4373
|
44-
help: you might have meant to use pattern matching
74+
= note: see issue #71126 <https://github.com/rust-lang/rust/issues/71126> for more information
75+
= help: add `#![feature(destructuring_assignment)]` to the crate attributes to enable
76+
77+
error[E0070]: invalid left-hand side of assignment
78+
--> $DIR/if-let-typo.rs:11:16
4579
|
46-
LL | if let Some(3) = foo {}
47-
| ^^^
48-
help: you might have meant to compare for equality
80+
LL | if Some(3) = foo {}
81+
| - ^
82+
| |
83+
| cannot assign to this expression
84+
85+
error[E0308]: mismatched types
86+
--> $DIR/if-let-typo.rs:11:8
4987
|
50-
LL | if Some(3) == foo {}
51-
| ^^
88+
LL | if Some(3) = foo {}
89+
| ^^^^^^^^^^^^^ expected `bool`, found `()`
5290

53-
error: aborting due to 4 previous errors
91+
error: aborting due to 10 previous errors
5492

55-
Some errors have detailed explanations: E0308, E0425.
56-
For more information about an error, try `rustc --explain E0308`.
93+
Some errors have detailed explanations: E0070, E0308, E0425, E0658.
94+
For more information about an error, try `rustc --explain E0070`.

0 commit comments

Comments
 (0)