Skip to content

Commit 5bea2c6

Browse files
committed
Auto merge of #145680 - jhpratt:rollup-cokwvpc, r=jhpratt
Rollup of 12 pull requests Successful merges: - #143383 (stabilize `const_array_each_ref`) - #144443 (Make target pointer width in target json an integer) - #144758 ([Doc] Add links to the various collections) - #144915 (Defer tail call ret ty equality to check_tail_calls) - #145256 (Add new `--test-codegen-backend` bootstrap option) - #145415 (std_detect: RISC-V: implement implication to "C") - #145573 (Add an experimental unsafe(force_target_feature) attribute.) - #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) Failed merges: - #145647 (miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 040a98a + 68247ae commit 5bea2c6

File tree

94 files changed

+724
-286
lines changed

Some content is hidden

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

94 files changed

+724
-286
lines changed

compiler/rustc_abi/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ pub enum TargetDataLayoutErrors<'a> {
315315
MissingAlignment { cause: &'a str },
316316
InvalidAlignment { cause: &'a str, err: AlignFromBytesError },
317317
InconsistentTargetArchitecture { dl: &'a str, target: &'a str },
318-
InconsistentTargetPointerWidth { pointer_size: u64, target: u32 },
318+
InconsistentTargetPointerWidth { pointer_size: u64, target: u16 },
319319
InvalidBitsSize { err: String },
320320
UnknownPointerSpecification { err: String },
321321
}

compiler/rustc_ast_ir/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl IntTy {
6969
})
7070
}
7171

72-
pub fn normalize(&self, target_width: u32) -> Self {
72+
pub fn normalize(&self, target_width: u16) -> Self {
7373
match self {
7474
IntTy::Isize => match target_width {
7575
16 => IntTy::I16,
@@ -148,7 +148,7 @@ impl UintTy {
148148
})
149149
}
150150

151-
pub fn normalize(&self, target_width: u32) -> Self {
151+
pub fn normalize(&self, target_width: u16) -> Self {
152152
match self {
153153
UintTy::Usize => match target_width {
154154
16 => UintTy::U16,

compiler/rustc_ast_lowering/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15961596
let safety = self.lower_safety(h.safety, default_safety);
15971597

15981598
// Treat safe `#[target_feature]` functions as unsafe, but also remember that we did so.
1599-
let safety = if find_attr!(attrs, AttributeKind::TargetFeature { .. })
1599+
let safety = if find_attr!(attrs, AttributeKind::TargetFeature { was_forced: false, .. })
16001600
&& safety.is_safe()
16011601
&& !self.tcx.sess.target.is_like_wasm
16021602
{

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: 11 additions & 0 deletions
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,

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_attr_parsing/src/attributes/codegen_attrs.rs

Lines changed: 78 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -385,57 +385,68 @@ impl<S: Stage> AttributeParser<S> for UsedParser {
385385
}
386386
}
387387

388+
fn parse_tf_attribute<'c, S: Stage>(
389+
cx: &'c mut AcceptContext<'_, '_, S>,
390+
args: &'c ArgParser<'_>,
391+
) -> impl IntoIterator<Item = (Symbol, Span)> + 'c {
392+
let mut features = Vec::new();
393+
let ArgParser::List(list) = args else {
394+
cx.expected_list(cx.attr_span);
395+
return features;
396+
};
397+
if list.is_empty() {
398+
cx.warn_empty_attribute(cx.attr_span);
399+
return features;
400+
}
401+
for item in list.mixed() {
402+
let Some(name_value) = item.meta_item() else {
403+
cx.expected_name_value(item.span(), Some(sym::enable));
404+
return features;
405+
};
406+
407+
// Validate name
408+
let Some(name) = name_value.path().word_sym() else {
409+
cx.expected_name_value(name_value.path().span(), Some(sym::enable));
410+
return features;
411+
};
412+
if name != sym::enable {
413+
cx.expected_name_value(name_value.path().span(), Some(sym::enable));
414+
return features;
415+
}
416+
417+
// Use value
418+
let Some(name_value) = name_value.args().name_value() else {
419+
cx.expected_name_value(item.span(), Some(sym::enable));
420+
return features;
421+
};
422+
let Some(value_str) = name_value.value_as_str() else {
423+
cx.expected_string_literal(name_value.value_span, Some(name_value.value_as_lit()));
424+
return features;
425+
};
426+
for feature in value_str.as_str().split(",") {
427+
features.push((Symbol::intern(feature), item.span()));
428+
}
429+
}
430+
features
431+
}
432+
388433
pub(crate) struct TargetFeatureParser;
389434

390435
impl<S: Stage> CombineAttributeParser<S> for TargetFeatureParser {
391436
type Item = (Symbol, Span);
392437
const PATH: &[Symbol] = &[sym::target_feature];
393-
const CONVERT: ConvertFn<Self::Item> = |items, span| AttributeKind::TargetFeature(items, span);
438+
const CONVERT: ConvertFn<Self::Item> = |items, span| AttributeKind::TargetFeature {
439+
features: items,
440+
attr_span: span,
441+
was_forced: false,
442+
};
394443
const TEMPLATE: AttributeTemplate = template!(List: &["enable = \"feat1, feat2\""]);
395444

396445
fn extend<'c>(
397446
cx: &'c mut AcceptContext<'_, '_, S>,
398447
args: &'c ArgParser<'_>,
399448
) -> impl IntoIterator<Item = Self::Item> + 'c {
400-
let mut features = Vec::new();
401-
let ArgParser::List(list) = args else {
402-
cx.expected_list(cx.attr_span);
403-
return features;
404-
};
405-
if list.is_empty() {
406-
cx.warn_empty_attribute(cx.attr_span);
407-
return features;
408-
}
409-
for item in list.mixed() {
410-
let Some(name_value) = item.meta_item() else {
411-
cx.expected_name_value(item.span(), Some(sym::enable));
412-
return features;
413-
};
414-
415-
// Validate name
416-
let Some(name) = name_value.path().word_sym() else {
417-
cx.expected_name_value(name_value.path().span(), Some(sym::enable));
418-
return features;
419-
};
420-
if name != sym::enable {
421-
cx.expected_name_value(name_value.path().span(), Some(sym::enable));
422-
return features;
423-
}
424-
425-
// Use value
426-
let Some(name_value) = name_value.args().name_value() else {
427-
cx.expected_name_value(item.span(), Some(sym::enable));
428-
return features;
429-
};
430-
let Some(value_str) = name_value.value_as_str() else {
431-
cx.expected_string_literal(name_value.value_span, Some(name_value.value_as_lit()));
432-
return features;
433-
};
434-
for feature in value_str.as_str().split(",") {
435-
features.push((Symbol::intern(feature), item.span()));
436-
}
437-
}
438-
features
449+
parse_tf_attribute(cx, args)
439450
}
440451

441452
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
@@ -449,3 +460,30 @@ impl<S: Stage> CombineAttributeParser<S> for TargetFeatureParser {
449460
Warn(Target::MacroDef),
450461
]);
451462
}
463+
464+
pub(crate) struct ForceTargetFeatureParser;
465+
466+
impl<S: Stage> CombineAttributeParser<S> for ForceTargetFeatureParser {
467+
type Item = (Symbol, Span);
468+
const PATH: &[Symbol] = &[sym::force_target_feature];
469+
const CONVERT: ConvertFn<Self::Item> = |items, span| AttributeKind::TargetFeature {
470+
features: items,
471+
attr_span: span,
472+
was_forced: true,
473+
};
474+
const TEMPLATE: AttributeTemplate = template!(List: &["enable = \"feat1, feat2\""]);
475+
476+
fn extend<'c>(
477+
cx: &'c mut AcceptContext<'_, '_, S>,
478+
args: &'c ArgParser<'_>,
479+
) -> impl IntoIterator<Item = Self::Item> + 'c {
480+
parse_tf_attribute(cx, args)
481+
}
482+
483+
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[
484+
Allow(Target::Fn),
485+
Allow(Target::Method(MethodKind::Inherent)),
486+
Allow(Target::Method(MethodKind::Trait { body: true })),
487+
Allow(Target::Method(MethodKind::TraitImpl)),
488+
]);
489+
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use crate::attributes::allow_unstable::{
2121
};
2222
use crate::attributes::body::CoroutineParser;
2323
use crate::attributes::codegen_attrs::{
24-
ColdParser, CoverageParser, ExportNameParser, NakedParser, NoMangleParser, OptimizeParser,
25-
TargetFeatureParser, TrackCallerParser, UsedParser,
24+
ColdParser, CoverageParser, ExportNameParser, ForceTargetFeatureParser, NakedParser,
25+
NoMangleParser, OptimizeParser, TargetFeatureParser, TrackCallerParser, UsedParser,
2626
};
2727
use crate::attributes::confusables::ConfusablesParser;
2828
use crate::attributes::deprecation::DeprecationParser;
@@ -161,6 +161,7 @@ attribute_parsers!(
161161
// tidy-alphabetical-start
162162
Combine<AllowConstFnUnstableParser>,
163163
Combine<AllowInternalUnstableParser>,
164+
Combine<ForceTargetFeatureParser>,
164165
Combine<ReprParser>,
165166
Combine<TargetFeatureParser>,
166167
Combine<UnstableFeatureBoundParser>,

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_codegen_gcc/target_specs/m68k-unknown-linux-gnu.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
"unix"
2323
],
2424
"target-mcount": "_mcount",
25-
"target-pointer-width": "32"
25+
"target-pointer-width": 32
2626
}

0 commit comments

Comments
 (0)