Skip to content

Commit b499c5c

Browse files
committed
Auto merge of #145691 - jhpratt:rollup-fekj1bx, r=jhpratt
Rollup of 15 pull requests Successful merges: - #143383 (stabilize `const_array_each_ref`) - #144758 ([Doc] Add links to the various collections) - #144915 (Defer tail call ret ty equality to check_tail_calls) - #145137 (Consolidate panicking functions in `slice/index.rs`) - #145256 (Add new `--test-codegen-backend` bootstrap option) - #145297 (fix(debuginfo): handle false positives in overflow check) - #145415 (std_detect: RISC-V: implement implication to "C") - #145590 (Prevent impossible combinations in `ast::ModKind`.) - #145621 (Fix some doc typos) - #145642 (Do not use effective_visibilities query for Adt types of a local trait while proving a where-clause) - #145650 (Fix JS search scripts path) - #145654 (Download CI GCC into the correct directory) - #145662 (Enforce correct number of arguments for `"x86-interrupt"` functions) - #145674 (Enable triagebot `[review-changes-since]` feature) - #145678 (Fix typo in docstring) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 125ff8a + f250b8e commit b499c5c

File tree

87 files changed

+712
-364
lines changed

Some content is hidden

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

87 files changed

+712
-364
lines changed

RELEASES.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1778,7 +1778,7 @@ Language
17781778
- [Undeprecate lint `unstable_features` and make use of it in the compiler.](https://github.com/rust-lang/rust/pull/118639/)
17791779
- [Make inductive cycles in coherence ambiguous always.](https://github.com/rust-lang/rust/pull/118649/)
17801780
- [Get rid of type-driven traversal in const-eval interning](https://github.com/rust-lang/rust/pull/119044/),
1781-
only as a [future compatiblity lint](https://github.com/rust-lang/rust/pull/122204) for now.
1781+
only as a [future compatibility lint](https://github.com/rust-lang/rust/pull/122204) for now.
17821782
- [Deny braced macro invocations in let-else.](https://github.com/rust-lang/rust/pull/119062/)
17831783

17841784
<a id="1.77.0-Compiler"></a>

compiler/rustc_ast/src/ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3137,7 +3137,7 @@ impl FnRetTy {
31373137
#[derive(Clone, Copy, PartialEq, Encodable, Decodable, Debug, Walkable)]
31383138
pub enum Inline {
31393139
Yes,
3140-
No,
3140+
No { had_parse_error: Result<(), ErrorGuaranteed> },
31413141
}
31423142

31433143
/// Module item kind.
@@ -3147,7 +3147,7 @@ pub enum ModKind {
31473147
/// or with definition outlined to a separate file `mod foo;` and already loaded from it.
31483148
/// The inner span is from the first token past `{` to the last token until `}`,
31493149
/// or from the first to the last token in the loaded file.
3150-
Loaded(ThinVec<Box<Item>>, Inline, ModSpans, Result<(), ErrorGuaranteed>),
3150+
Loaded(ThinVec<Box<Item>>, Inline, ModSpans),
31513151
/// Module with definition outlined to a separate file `mod foo;` but not yet loaded from it.
31523152
Unloaded,
31533153
}

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
251251
ItemKind::Mod(_, ident, mod_kind) => {
252252
let ident = self.lower_ident(*ident);
253253
match mod_kind {
254-
ModKind::Loaded(items, _, spans, _) => {
254+
ModKind::Loaded(items, _, spans) => {
255255
hir::ItemKind::Mod(ident, self.lower_mod(items, spans))
256256
}
257257
ModKind::Unloaded => panic!("`mod` items should have been loaded by now"),

compiler/rustc_ast_passes/messages.ftl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ ast_passes_abi_must_not_have_return_type=
2020
.note = functions with the {$abi} ABI cannot have a return type
2121
.help = remove the return type
2222
23+
ast_passes_abi_x86_interrupt =
24+
invalid signature for `extern "x86-interrupt"` function
25+
.note = functions with the "x86-interrupt" ABI must be have either 1 or 2 parameters (but found {$param_count})
26+
2327
ast_passes_assoc_const_without_body =
2428
associated constant in `impl` without body
2529
.suggestion = provide a definition for the constant

compiler/rustc_ast_passes/src/ast_validation.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,17 @@ impl<'a> AstValidator<'a> {
405405
if let InterruptKind::X86 = interrupt_kind {
406406
// "x86-interrupt" is special because it does have arguments.
407407
// FIXME(workingjubilee): properly lint on acceptable input types.
408+
let inputs = &sig.decl.inputs;
409+
let param_count = inputs.len();
410+
if !matches!(param_count, 1 | 2) {
411+
let mut spans: Vec<Span> =
412+
inputs.iter().map(|arg| arg.span).collect();
413+
if spans.is_empty() {
414+
spans = vec![sig.span];
415+
}
416+
self.dcx().emit_err(errors::AbiX86Interrupt { spans, param_count });
417+
}
418+
408419
if let FnRetTy::Ty(ref ret_ty) = sig.decl.output
409420
&& match &ret_ty.kind {
410421
TyKind::Never => false,
@@ -1169,7 +1180,7 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
11691180
self.dcx().emit_err(errors::UnsafeItem { span, kind: "module" });
11701181
}
11711182
// Ensure that `path` attributes on modules are recorded as used (cf. issue #35584).
1172-
if !matches!(mod_kind, ModKind::Loaded(_, Inline::Yes, _, _))
1183+
if !matches!(mod_kind, ModKind::Loaded(_, Inline::Yes, _))
11731184
&& !attr::contains_name(&item.attrs, sym::path)
11741185
{
11751186
self.check_mod_file_item_asciionly(*ident);

compiler/rustc_ast_passes/src/errors.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,3 +891,12 @@ pub(crate) struct AbiMustNotHaveReturnType {
891891
pub span: Span,
892892
pub abi: ExternAbi,
893893
}
894+
895+
#[derive(Diagnostic)]
896+
#[diag(ast_passes_abi_x86_interrupt)]
897+
#[note]
898+
pub(crate) struct AbiX86Interrupt {
899+
#[primary_span]
900+
pub spans: Vec<Span>,
901+
pub param_count: usize,
902+
}

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
18951895
if !output_ty
18961896
.is_privately_uninhabited(self.tcx(), self.infcx.typing_env(self.infcx.param_env))
18971897
{
1898-
span_mirbug!(self, term, "call to converging function {:?} w/o dest", sig);
1898+
span_mirbug!(self, term, "call to non-diverging function {:?} w/o dest", sig);
18991899
}
19001900
} else {
19011901
let dest_ty = destination.ty(self.body, tcx).ty;

compiler/rustc_builtin_macros/src/test_harness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl<'a> MutVisitor for TestHarnessGenerator<'a> {
141141
if let ast::ItemKind::Mod(
142142
_,
143143
_,
144-
ModKind::Loaded(.., ast::ModSpans { inner_span: span, .. }, _),
144+
ModKind::Loaded(.., ast::ModSpans { inner_span: span, .. }),
145145
) = item.kind
146146
{
147147
let prev_tests = mem::take(&mut self.tests);

compiler/rustc_codegen_llvm/src/debuginfo/metadata/type_map.rs

Lines changed: 38 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ pub(super) fn build_type_with_children<'ll, 'tcx>(
276276
&& let ty::Adt(adt_def, args) = ty.kind()
277277
{
278278
let def_id = adt_def.did();
279-
// If any sub type reference the original type definition and the sub type has a type
279+
// If any child type references the original type definition and the child type has a type
280280
// parameter that strictly contains the original parameter, the original type is a recursive
281281
// type that can expanding indefinitely. Example,
282282
// ```
@@ -285,21 +285,43 @@ pub(super) fn build_type_with_children<'ll, 'tcx>(
285285
// Item(T),
286286
// }
287287
// ```
288-
let is_expanding_recursive = adt_def.is_enum()
289-
&& debug_context(cx).adt_stack.borrow().iter().any(|(parent_def_id, parent_args)| {
290-
if def_id == *parent_def_id {
291-
args.iter().zip(parent_args.iter()).any(|(arg, parent_arg)| {
292-
if let (Some(arg), Some(parent_arg)) = (arg.as_type(), parent_arg.as_type())
293-
{
294-
arg != parent_arg && arg.contains(parent_arg)
295-
} else {
296-
false
297-
}
298-
})
299-
} else {
300-
false
301-
}
302-
});
288+
let is_expanding_recursive = {
289+
let stack = debug_context(cx).adt_stack.borrow();
290+
stack
291+
.iter()
292+
.enumerate()
293+
.rev()
294+
.skip(1)
295+
.filter(|(_, (ancestor_def_id, _))| def_id == *ancestor_def_id)
296+
.any(|(ancestor_index, (_, ancestor_args))| {
297+
args.iter()
298+
.zip(ancestor_args.iter())
299+
.filter_map(|(arg, ancestor_arg)| arg.as_type().zip(ancestor_arg.as_type()))
300+
.any(|(arg, ancestor_arg)|
301+
// Strictly contains.
302+
(arg != ancestor_arg && arg.contains(ancestor_arg))
303+
// Check all types between current and ancestor use the
304+
// ancestor_arg.
305+
// Otherwise, duplicate wrappers in normal recursive type may be
306+
// regarded as expanding.
307+
// ```
308+
// struct Recursive {
309+
// a: Box<Box<Recursive>>,
310+
// }
311+
// ```
312+
// It can produce an ADT stack like this,
313+
// - Box<Recursive>
314+
// - Recursive
315+
// - Box<Box<Recursive>>
316+
&& stack[ancestor_index + 1..stack.len()].iter().all(
317+
|(_, intermediate_args)|
318+
intermediate_args
319+
.iter()
320+
.filter_map(|arg| arg.as_type())
321+
.any(|mid_arg| mid_arg.contains(ancestor_arg))
322+
))
323+
})
324+
};
303325
if is_expanding_recursive {
304326
// FIXME: indicate that this is an expanding recursive type in stub metadata?
305327
return DINodeCreationResult::new(stub_info.metadata, false);

compiler/rustc_expand/src/expand.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,8 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
801801
ItemKind::Mod(
802802
_,
803803
_,
804-
ModKind::Unloaded | ModKind::Loaded(_, Inline::No, _, _),
804+
ModKind::Unloaded
805+
| ModKind::Loaded(_, Inline::No { .. }, _),
805806
)
806807
) =>
807808
{
@@ -1035,7 +1036,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
10351036
fn visit_item(&mut self, item: &'ast ast::Item) {
10361037
match &item.kind {
10371038
ItemKind::Mod(_, _, mod_kind)
1038-
if !matches!(mod_kind, ModKind::Loaded(_, Inline::Yes, _, _)) =>
1039+
if !matches!(mod_kind, ModKind::Loaded(_, Inline::Yes, _)) =>
10391040
{
10401041
feature_err(
10411042
self.sess,
@@ -1346,7 +1347,7 @@ impl InvocationCollectorNode for Box<ast::Item> {
13461347
let ItemKind::Mod(_, ident, ref mut mod_kind) = node.kind else { unreachable!() };
13471348
let ecx = &mut collector.cx;
13481349
let (file_path, dir_path, dir_ownership) = match mod_kind {
1349-
ModKind::Loaded(_, inline, _, _) => {
1350+
ModKind::Loaded(_, inline, _) => {
13501351
// Inline `mod foo { ... }`, but we still need to push directories.
13511352
let (dir_path, dir_ownership) = mod_dir_path(
13521353
ecx.sess,
@@ -1360,7 +1361,7 @@ impl InvocationCollectorNode for Box<ast::Item> {
13601361
// This lets `parse_external_mod` catch cycles if it's self-referential.
13611362
let file_path = match inline {
13621363
Inline::Yes => None,
1363-
Inline::No => mod_file_path_from_attr(ecx.sess, &attrs, &dir_path),
1364+
Inline::No { .. } => mod_file_path_from_attr(ecx.sess, &attrs, &dir_path),
13641365
};
13651366
node.attrs = attrs;
13661367
(file_path, dir_path, dir_ownership)
@@ -1396,7 +1397,7 @@ impl InvocationCollectorNode for Box<ast::Item> {
13961397
);
13971398
}
13981399

1399-
*mod_kind = ModKind::Loaded(items, Inline::No, spans, had_parse_error);
1400+
*mod_kind = ModKind::Loaded(items, Inline::No { had_parse_error }, spans);
14001401
node.attrs = attrs;
14011402
if node.attrs.len() > old_attrs_len {
14021403
// If we loaded an out-of-line module and added some inner attributes,

0 commit comments

Comments
 (0)