Skip to content

Commit 6ff8054

Browse files
committed
Continue to borrowck even if there were previous errors
1 parent dc618dc commit 6ff8054

File tree

198 files changed

+3174
-477
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+3174
-477
lines changed

compiler/rustc_hir_analysis/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub fn check_crate(tcx: TyCtxt<'_>) -> Result<(), ErrorGuaranteed> {
209209

210210
tcx.ensure().check_unused_traits(());
211211

212-
if let Some(reported) = tcx.dcx().has_errors() { Err(reported) } else { Ok(()) }
212+
Ok(())
213213
}
214214

215215
/// A quasi-deprecated helper used in rustdoc and clippy to get

compiler/rustc_mir_build/src/build/mod.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,12 @@ fn construct_error(tcx: TyCtxt<'_>, def_id: LocalDefId, guar: ErrorGuaranteed) -
675675
))),
676676
)
677677
}
678-
_ => {
679-
span_bug!(span, "expected type of closure body to be a closure or coroutine");
678+
ty::Error(_) => (vec![closure_ty, closure_ty], closure_ty, None),
679+
kind => {
680+
span_bug!(
681+
span,
682+
"expected type of closure body to be a closure or coroutine, got {kind:?}"
683+
);
680684
}
681685
}
682686
}

compiler/rustc_mir_build/src/build/scope.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,17 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
655655
let drops = if destination.is_some() {
656656
&mut self.scopes.breakable_scopes[break_index].break_drops
657657
} else {
658-
self.scopes.breakable_scopes[break_index].continue_drops.as_mut().unwrap()
658+
let Some(drops) = self.scopes.breakable_scopes[break_index].continue_drops.as_mut()
659+
else {
660+
self.tcx.dcx().span_delayed_bug(
661+
source_info.span,
662+
"unlabelled `continue` within labelled block",
663+
);
664+
self.cfg.terminate(block, source_info, TerminatorKind::Unreachable);
665+
666+
return self.cfg.start_new_block().unit();
667+
};
668+
drops
659669
};
660670

661671
let drop_idx = self.scopes.scopes[scope_index + 1..]

compiler/rustc_mir_transform/src/ffi_unwind_calls.rs

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ fn has_ffi_unwind_calls(tcx: TyCtxt<'_>, local_def_id: LocalDefId) -> bool {
5858
ty::FnDef(..) => body_ty.fn_sig(tcx).abi(),
5959
ty::Closure(..) => Abi::RustCall,
6060
ty::Coroutine(..) => Abi::Rust,
61+
ty::Error(_) => return false,
6162
_ => span_bug!(body.span, "unexpected body ty: {:?}", body_ty),
6263
};
6364
let body_can_unwind = layout::fn_can_unwind(tcx, Some(def_id), body_abi);

compiler/rustc_parse/src/parser/expr.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -2911,12 +2911,22 @@ impl<'a> Parser<'a> {
29112911
Ok(arm) => arms.push(arm),
29122912
Err(e) => {
29132913
// Recover by skipping to the end of the block.
2914-
e.emit();
2914+
let guar = e.emit();
29152915
self.recover_stmt();
29162916
let span = lo.to(self.token.span);
29172917
if self.token == token::CloseDelim(Delimiter::Brace) {
29182918
self.bump();
29192919
}
2920+
// Always push at least one arm to make the match non-empty
2921+
arms.push(Arm {
2922+
attrs: Default::default(),
2923+
pat: self.mk_pat(span, ast::PatKind::Err(guar)),
2924+
guard: None,
2925+
body: Some(self.mk_expr_err(span)),
2926+
span,
2927+
id: DUMMY_NODE_ID,
2928+
is_placeholder: false,
2929+
});
29202930
return Ok(self.mk_expr_with_attrs(
29212931
span,
29222932
ExprKind::Match(scrutinee, arms),

compiler/rustc_passes/src/liveness.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ enum LiveNodeKind {
123123
VarDefNode(Span, HirId),
124124
ClosureNode,
125125
ExitNode,
126+
ErrNode,
126127
}
127128

128129
fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_>) -> String {
@@ -133,6 +134,7 @@ fn live_node_kind_to_string(lnk: LiveNodeKind, tcx: TyCtxt<'_>) -> String {
133134
VarDefNode(s, _) => format!("Var def node [{}]", sm.span_to_diagnostic_string(s)),
134135
ClosureNode => "Closure node".to_owned(),
135136
ExitNode => "Exit node".to_owned(),
137+
ErrNode => "Error node".to_owned(),
136138
}
137139
}
138140

@@ -962,10 +964,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
962964

963965
// Now that we know the label we're going to,
964966
// look it up in the continue loop nodes table
965-
self.cont_ln
966-
.get(&sc)
967-
.cloned()
968-
.unwrap_or_else(|| span_bug!(expr.span, "continue to unknown label"))
967+
self.cont_ln.get(&sc).cloned().unwrap_or_else(|| {
968+
self.ir.tcx.dcx().span_delayed_bug(expr.span, "continue to unknown label");
969+
self.ir.add_live_node(ErrNode)
970+
})
969971
}
970972

971973
hir::ExprKind::Assign(ref l, ref r, _) => {

tests/incremental/const-generics/issue-62536.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// revisions:cfail1
2+
3+
#![allow(unused_variables)]
4+
25
struct S<T, const N: usize>([T; N]);
36

47
fn f<T, const N: usize>(x: T) -> S<T, {N}> { panic!() }

tests/incremental/const-generics/try_unify_abstract_const_regression_tests/issue-77708-1.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// revisions: cfail
22
#![feature(generic_const_exprs)]
3-
#![allow(incomplete_features, unused_braces)]
3+
#![allow(incomplete_features, unused_braces, unused_variables)]
44

55
trait Delegates<T> {}
66

tests/incremental/struct_change_field_name.rs

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// [cfail2] compile-flags: -Z query-dep-graph -Z assert-incr-state=loaded
77

88
#![feature(rustc_attrs)]
9+
#![allow(unused_variables)]
910

1011
#[cfg(rpass1)]
1112
pub struct X {

tests/ui/asm/bad-template.aarch64.stderr

+26-26
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
error: invalid reference to argument at index 0
2-
--> $DIR/bad-template.rs:27:15
2+
--> $DIR/bad-template.rs:30:15
33
|
44
LL | asm!("{}");
55
| ^^ from here
66
|
77
= note: no arguments were given
88

99
error: invalid reference to argument at index 1
10-
--> $DIR/bad-template.rs:29:15
10+
--> $DIR/bad-template.rs:32:15
1111
|
1212
LL | asm!("{1}", in(reg) foo);
1313
| ^^^ from here
1414
|
1515
= note: there is 1 argument
1616

1717
error: argument never used
18-
--> $DIR/bad-template.rs:29:21
18+
--> $DIR/bad-template.rs:32:21
1919
|
2020
LL | asm!("{1}", in(reg) foo);
2121
| ^^^^^^^^^^^ argument never used
2222
|
2323
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"`
2424

2525
error: there is no argument named `a`
26-
--> $DIR/bad-template.rs:32:16
26+
--> $DIR/bad-template.rs:35:16
2727
|
2828
LL | asm!("{a}");
2929
| ^
3030

3131
error: invalid reference to argument at index 0
32-
--> $DIR/bad-template.rs:34:15
32+
--> $DIR/bad-template.rs:37:15
3333
|
3434
LL | asm!("{}", a = in(reg) foo);
3535
| ^^ --------------- named argument
@@ -38,37 +38,37 @@ LL | asm!("{}", a = in(reg) foo);
3838
|
3939
= note: no positional arguments were given
4040
note: named arguments cannot be referenced by position
41-
--> $DIR/bad-template.rs:34:20
41+
--> $DIR/bad-template.rs:37:20
4242
|
4343
LL | asm!("{}", a = in(reg) foo);
4444
| ^^^^^^^^^^^^^^^
4545

4646
error: named argument never used
47-
--> $DIR/bad-template.rs:34:20
47+
--> $DIR/bad-template.rs:37:20
4848
|
4949
LL | asm!("{}", a = in(reg) foo);
5050
| ^^^^^^^^^^^^^^^ named argument never used
5151
|
5252
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
5353

5454
error: invalid reference to argument at index 1
55-
--> $DIR/bad-template.rs:37:15
55+
--> $DIR/bad-template.rs:40:15
5656
|
5757
LL | asm!("{1}", a = in(reg) foo);
5858
| ^^^ from here
5959
|
6060
= note: no positional arguments were given
6161

6262
error: named argument never used
63-
--> $DIR/bad-template.rs:37:21
63+
--> $DIR/bad-template.rs:40:21
6464
|
6565
LL | asm!("{1}", a = in(reg) foo);
6666
| ^^^^^^^^^^^^^^^ named argument never used
6767
|
6868
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
6969

7070
error: invalid reference to argument at index 0
71-
--> $DIR/bad-template.rs:44:15
71+
--> $DIR/bad-template.rs:47:15
7272
|
7373
LL | asm!("{}", in("x0") foo);
7474
| ^^ ------------ explicit register argument
@@ -77,24 +77,24 @@ LL | asm!("{}", in("x0") foo);
7777
|
7878
= note: no positional arguments were given
7979
note: explicit register arguments cannot be used in the asm template
80-
--> $DIR/bad-template.rs:44:20
80+
--> $DIR/bad-template.rs:47:20
8181
|
8282
LL | asm!("{}", in("x0") foo);
8383
| ^^^^^^^^^^^^
8484
help: use the register name directly in the assembly code
85-
--> $DIR/bad-template.rs:44:20
85+
--> $DIR/bad-template.rs:47:20
8686
|
8787
LL | asm!("{}", in("x0") foo);
8888
| ^^^^^^^^^^^^
8989

9090
error: asm template modifier must be a single character
91-
--> $DIR/bad-template.rs:46:17
91+
--> $DIR/bad-template.rs:49:17
9292
|
9393
LL | asm!("{:foo}", in(reg) foo);
9494
| ^^^
9595

9696
error: multiple unused asm arguments
97-
--> $DIR/bad-template.rs:49:18
97+
--> $DIR/bad-template.rs:52:18
9898
|
9999
LL | asm!("", in(reg) 0, in(reg) 1);
100100
| ^^^^^^^^^ ^^^^^^^^^ argument never used
@@ -104,37 +104,37 @@ LL | asm!("", in(reg) 0, in(reg) 1);
104104
= help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"`
105105

106106
error: invalid reference to argument at index 0
107-
--> $DIR/bad-template.rs:55:14
107+
--> $DIR/bad-template.rs:58:14
108108
|
109109
LL | global_asm!("{}");
110110
| ^^ from here
111111
|
112112
= note: no arguments were given
113113

114114
error: invalid reference to argument at index 1
115-
--> $DIR/bad-template.rs:57:14
115+
--> $DIR/bad-template.rs:60:14
116116
|
117117
LL | global_asm!("{1}", const FOO);
118118
| ^^^ from here
119119
|
120120
= note: there is 1 argument
121121

122122
error: argument never used
123-
--> $DIR/bad-template.rs:57:20
123+
--> $DIR/bad-template.rs:60:20
124124
|
125125
LL | global_asm!("{1}", const FOO);
126126
| ^^^^^^^^^ argument never used
127127
|
128128
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {0} */"`
129129

130130
error: there is no argument named `a`
131-
--> $DIR/bad-template.rs:60:15
131+
--> $DIR/bad-template.rs:63:15
132132
|
133133
LL | global_asm!("{a}");
134134
| ^
135135

136136
error: invalid reference to argument at index 0
137-
--> $DIR/bad-template.rs:62:14
137+
--> $DIR/bad-template.rs:65:14
138138
|
139139
LL | global_asm!("{}", a = const FOO);
140140
| ^^ ------------- named argument
@@ -143,43 +143,43 @@ LL | global_asm!("{}", a = const FOO);
143143
|
144144
= note: no positional arguments were given
145145
note: named arguments cannot be referenced by position
146-
--> $DIR/bad-template.rs:62:19
146+
--> $DIR/bad-template.rs:65:19
147147
|
148148
LL | global_asm!("{}", a = const FOO);
149149
| ^^^^^^^^^^^^^
150150

151151
error: named argument never used
152-
--> $DIR/bad-template.rs:62:19
152+
--> $DIR/bad-template.rs:65:19
153153
|
154154
LL | global_asm!("{}", a = const FOO);
155155
| ^^^^^^^^^^^^^ named argument never used
156156
|
157157
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
158158

159159
error: invalid reference to argument at index 1
160-
--> $DIR/bad-template.rs:65:14
160+
--> $DIR/bad-template.rs:68:14
161161
|
162162
LL | global_asm!("{1}", a = const FOO);
163163
| ^^^ from here
164164
|
165165
= note: no positional arguments were given
166166

167167
error: named argument never used
168-
--> $DIR/bad-template.rs:65:20
168+
--> $DIR/bad-template.rs:68:20
169169
|
170170
LL | global_asm!("{1}", a = const FOO);
171171
| ^^^^^^^^^^^^^ named argument never used
172172
|
173173
= help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {a} */"`
174174

175175
error: asm template modifier must be a single character
176-
--> $DIR/bad-template.rs:68:16
176+
--> $DIR/bad-template.rs:71:16
177177
|
178178
LL | global_asm!("{:foo}", const FOO);
179179
| ^^^
180180

181181
error: multiple unused asm arguments
182-
--> $DIR/bad-template.rs:70:17
182+
--> $DIR/bad-template.rs:73:17
183183
|
184184
LL | global_asm!("", const FOO, const FOO);
185185
| ^^^^^^^^^ ^^^^^^^^^ argument never used
@@ -189,7 +189,7 @@ LL | global_asm!("", const FOO, const FOO);
189189
= help: if these arguments are intentionally unused, consider using them in an asm comment: `"/* {0} {1} */"`
190190

191191
warning: formatting may not be suitable for sub-register argument
192-
--> $DIR/bad-template.rs:46:15
192+
--> $DIR/bad-template.rs:49:15
193193
|
194194
LL | asm!("{:foo}", in(reg) foo);
195195
| ^^^^^^ --- for this argument

tests/ui/asm/bad-template.rs

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ macro_rules! global_asm {
2121
#[lang = "sized"]
2222
trait Sized {}
2323

24+
#[lang = "copy"]
25+
trait Copy {}
26+
2427
fn main() {
2528
let mut foo = 0;
2629
unsafe {

0 commit comments

Comments
 (0)