Skip to content

Commit 377a931

Browse files
committed
Auto merge of #147863 - matthiaskrgr:rollup-l4alyf0, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #138679 (Issue-125323: ICE non-ADT in struct pattern when long time constant evaluation is in for loop) - #146490 (Rehome 26 `tests/ui/issues/` tests to other subdirectories under `tests/ui/` [#5 of Batch #2]) - #147438 (Rename "non-inline module" to "file module" in proc macro diagnostics) - #147724 (Fix ICE in pattern matching with generic const array length errors) - #147813 (Warn on unused_attributes in uitests ) - #147816 (Do not error out for `download-rustc` if LTO is configured) - #147845 (Add regression test for 134355) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6380899 + 54c6939 commit 377a931

File tree

125 files changed

+1258
-336
lines changed

Some content is hidden

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

125 files changed

+1258
-336
lines changed

compiler/rustc_expand/messages.ftl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ expand_feature_removed =
4949
.note = removed in {$removed_rustc_version}{$pull_note}
5050
.reason = {$reason}
5151
52+
expand_file_modules_in_proc_macro_input_are_unstable =
53+
file modules in proc macro input are unstable
54+
5255
expand_glob_delegation_outside_impls =
5356
glob delegation is only supported in impls
5457
@@ -158,9 +161,6 @@ expand_mve_unrecognized_expr =
158161
expand_mve_unrecognized_var =
159162
variable `{$key}` is not recognized in meta-variable expression
160163
161-
expand_non_inline_modules_in_proc_macro_input_are_unstable =
162-
non-inline modules in proc macro input are unstable
163-
164164
expand_or_patterns_back_compat = the meaning of the `pat` fragment specifier is changing in Rust 2021, which may affect this macro
165165
.suggestion = use pat_param to preserve semantics
166166

compiler/rustc_expand/src/expand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
10501050
self.sess,
10511051
sym::proc_macro_hygiene,
10521052
item.span,
1053-
fluent_generated::expand_non_inline_modules_in_proc_macro_input_are_unstable,
1053+
fluent_generated::expand_file_modules_in_proc_macro_input_are_unstable,
10541054
)
10551055
.emit();
10561056
}

compiler/rustc_lint/src/builtin.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ declare_lint_pass!(NonShorthandFieldPatterns => [NON_SHORTHAND_FIELD_PATTERNS]);
152152

153153
impl<'tcx> LateLintPass<'tcx> for NonShorthandFieldPatterns {
154154
fn check_pat(&mut self, cx: &LateContext<'_>, pat: &hir::Pat<'_>) {
155-
if let PatKind::Struct(ref qpath, field_pats, _) = pat.kind {
155+
// The result shouldn't be tainted, otherwise it will cause ICE.
156+
if let PatKind::Struct(ref qpath, field_pats, _) = pat.kind
157+
&& cx.typeck_results().tainted_by_errors.is_none()
158+
{
156159
let variant = cx
157160
.typeck_results()
158161
.pat_ty(pat)

compiler/rustc_middle/src/query/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1202,10 +1202,10 @@ rustc_queries! {
12021202
/// Return the live symbols in the crate for dead code check.
12031203
///
12041204
/// The second return value maps from ADTs to ignored derived traits (e.g. Debug and Clone).
1205-
query live_symbols_and_ignored_derived_traits(_: ()) -> &'tcx (
1205+
query live_symbols_and_ignored_derived_traits(_: ()) -> &'tcx Result<(
12061206
LocalDefIdSet,
12071207
LocalDefIdMap<FxIndexSet<DefId>>,
1208-
) {
1208+
), ErrorGuaranteed> {
12091209
arena_cache
12101210
desc { "finding live symbols in crate" }
12111211
}

compiler/rustc_mir_build/src/builder/matches/match_pair.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,23 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
4343
) {
4444
let tcx = self.tcx;
4545
let (min_length, exact_size) = if let Some(place_resolved) = place.try_to_place(self) {
46-
match place_resolved.ty(&self.local_decls, tcx).ty.kind() {
47-
ty::Array(_, length) => (
48-
length
49-
.try_to_target_usize(tcx)
50-
.expect("expected len of array pat to be definite"),
51-
true,
52-
),
46+
let place_ty = place_resolved.ty(&self.local_decls, tcx).ty;
47+
match place_ty.kind() {
48+
ty::Array(_, length) => {
49+
if let Some(length) = length.try_to_target_usize(tcx) {
50+
(length, true)
51+
} else {
52+
// This can happen when the array length is a generic const
53+
// expression that couldn't be evaluated (e.g., due to an error).
54+
// Since there's already a compilation error, we use a fallback
55+
// to avoid an ICE.
56+
tcx.dcx().span_delayed_bug(
57+
tcx.def_span(self.def_id),
58+
"array length in pattern couldn't be evaluated",
59+
);
60+
((prefix.len() + suffix.len()).try_into().unwrap(), false)
61+
}
62+
}
5363
_ => ((prefix.len() + suffix.len()).try_into().unwrap(), false),
5464
}
5565
} else {

0 commit comments

Comments
 (0)