Skip to content

Commit 4a6c56e

Browse files
authored
Unrolled build for #142587
Rollup merge of #142587 - compiler-errors:try-visit-expr-fields, r=jieyouxu Make sure to propagate result from `visit_expr_fields` We weren't propagating the `ControlFlow::Break` out of a struct field, which means that the solution implemented in #130443 didn't work for nested fields. Fixes #142525.
2 parents 86d0aef + ac8b506 commit 4a6c56e

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

compiler/rustc_ast/src/visit.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ macro_rules! common_visitor_and_walkers {
884884
TyKind::BareFn(function_declaration) => {
885885
let BareFnTy { safety, ext: _, generic_params, decl, decl_span } =
886886
&$($mut)? **function_declaration;
887-
visit_safety(vis, safety);
887+
try_visit!(visit_safety(vis, safety));
888888
try_visit!(visit_generic_params(vis, generic_params));
889889
try_visit!(vis.visit_fn_decl(decl));
890890
try_visit!(visit_span(vis, decl_span));
@@ -1235,7 +1235,7 @@ macro_rules! common_visitor_and_walkers {
12351235
bounds,
12361236
bound_generic_params,
12371237
}) => {
1238-
visit_generic_params(vis, bound_generic_params);
1238+
try_visit!(visit_generic_params(vis, bound_generic_params));
12391239
try_visit!(vis.visit_ty(bounded_ty));
12401240
walk_list!(vis, visit_param_bound, bounds, BoundKind::Bound);
12411241
}
@@ -1420,7 +1420,7 @@ macro_rules! common_visitor_and_walkers {
14201420
let StructExpr { qself, path, fields, rest } = &$($mut)?**se;
14211421
try_visit!(vis.visit_qself(qself));
14221422
try_visit!(vis.visit_path(path));
1423-
visit_expr_fields(vis, fields);
1423+
try_visit!(visit_expr_fields(vis, fields));
14241424
match rest {
14251425
StructRest::Base(expr) => try_visit!(vis.visit_expr(expr)),
14261426
StructRest::Rest(_span) => {}

tests/ui/invalid/invalid-rustc_legacy_const_generics-issue-123077.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,11 @@ fn main() {
2828

2929
std::arch::x86_64::_mm_inserti_si64(loop {}, loop {}, || (), 1 + || ());
3030
//~^ ERROR invalid argument to a legacy const generic
31+
32+
// A regression test for <https://github.com/rust-lang/rust/issues/142525>.
33+
struct Struct<T> {
34+
field: T,
35+
}
36+
std::arch::x86_64::_mm_blend_ps(loop {}, loop {}, Struct { field: || () });
37+
//~^ ERROR invalid argument to a legacy const generic
3138
}

tests/ui/invalid/invalid-rustc_legacy_const_generics-issue-123077.stderr

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,17 @@ LL - std::arch::x86_64::_mm_inserti_si64(loop {}, loop {}, || (), 1 + || ())
8484
LL + std::arch::x86_64::_mm_inserti_si64::<{ || () }, { 1 + || () }>(loop {}, loop {});
8585
|
8686

87-
error: aborting due to 7 previous errors
87+
error: invalid argument to a legacy const generic: cannot have const blocks, closures, async blocks or items
88+
--> $DIR/invalid-rustc_legacy_const_generics-issue-123077.rs:36:71
89+
|
90+
LL | std::arch::x86_64::_mm_blend_ps(loop {}, loop {}, Struct { field: || () });
91+
| ^^^^^
92+
|
93+
help: try using a const generic argument instead
94+
|
95+
LL - std::arch::x86_64::_mm_blend_ps(loop {}, loop {}, Struct { field: || () });
96+
LL + std::arch::x86_64::_mm_blend_ps::<{ Struct { field: || () } }>(loop {}, loop {});
97+
|
98+
99+
error: aborting due to 8 previous errors
88100

0 commit comments

Comments
 (0)