Auto merge of #136918 - GuillaumeGomez:rollup-f6h21gg, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - #134981 ( Explain that in paths generics can't be set on both the enum and the variant) - #136698 (Replace i686-unknown-redox target with i586-unknown-redox) - #136767 (improve host/cross target checking) - #136829 ([rustdoc] Move line numbers into the `<code>` directly) - #136875 (Rustc dev guide subtree update) - #136900 (compiler: replace `ExternAbi::name` calls with formatters) - #136913 (Put kobzol back on review rotation) - #136915 (documentation fix: `f16` and `f128` are not double-precision) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
552a959051
69 changed files with 576 additions and 397 deletions
|
@ -367,9 +367,7 @@ fn push_debuginfo_type_name<'tcx>(
|
|||
output.push_str(sig.safety.prefix_str());
|
||||
|
||||
if sig.abi != rustc_abi::ExternAbi::Rust {
|
||||
output.push_str("extern \"");
|
||||
output.push_str(sig.abi.name());
|
||||
output.push_str("\" ");
|
||||
let _ = write!(output, "extern {} ", sig.abi);
|
||||
}
|
||||
|
||||
output.push_str("fn(");
|
||||
|
|
|
@ -93,6 +93,7 @@ into_diag_arg_using_display!(
|
|||
SplitDebuginfo,
|
||||
ExitStatus,
|
||||
ErrCode,
|
||||
rustc_abi::ExternAbi,
|
||||
);
|
||||
|
||||
impl<I: rustc_type_ir::Interner> IntoDiagArg for rustc_type_ir::TraitRef<I> {
|
||||
|
|
|
@ -72,17 +72,17 @@ hir_analysis_cmse_entry_generic =
|
|||
functions with the `"C-cmse-nonsecure-entry"` ABI cannot contain generics in their type
|
||||
|
||||
hir_analysis_cmse_inputs_stack_spill =
|
||||
arguments for `"{$abi_name}"` function too large to pass via registers
|
||||
arguments for `{$abi}` function too large to pass via registers
|
||||
.label = {$plural ->
|
||||
[false] this argument doesn't
|
||||
*[true] these arguments don't
|
||||
} fit in the available registers
|
||||
.note = functions with the `"{$abi_name}"` ABI must pass all their arguments via the 4 32-bit available argument registers
|
||||
.note = functions with the `{$abi}` ABI must pass all their arguments via the 4 32-bit available argument registers
|
||||
|
||||
hir_analysis_cmse_output_stack_spill =
|
||||
return value of `"{$abi_name}"` function too large to pass via registers
|
||||
return value of `{$abi}` function too large to pass via registers
|
||||
.label = this type doesn't fit in the available registers
|
||||
.note1 = functions with the `"{$abi_name}"` ABI must pass their result via the available return registers
|
||||
.note1 = functions with the `{$abi}` ABI must pass their result via the available return registers
|
||||
.note2 = the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size
|
||||
|
||||
hir_analysis_coerce_pointee_no_field = `CoercePointee` can only be derived on `struct`s with at least one field
|
||||
|
|
|
@ -614,9 +614,10 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
|
|||
if !infer_replacements.is_empty() {
|
||||
diag.multipart_suggestion(
|
||||
format!(
|
||||
"try replacing `_` with the type{} in the corresponding trait method signature",
|
||||
rustc_errors::pluralize!(infer_replacements.len()),
|
||||
),
|
||||
"try replacing `_` with the type{} in the corresponding trait method \
|
||||
signature",
|
||||
rustc_errors::pluralize!(infer_replacements.len()),
|
||||
),
|
||||
infer_replacements,
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
//! Errors emitted by `rustc_hir_analysis`.
|
||||
|
||||
use rustc_abi::ExternAbi;
|
||||
use rustc_errors::codes::*;
|
||||
use rustc_errors::{
|
||||
Applicability, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, MultiSpan,
|
||||
|
@ -1690,7 +1691,7 @@ pub(crate) struct CmseInputsStackSpill {
|
|||
#[label]
|
||||
pub span: Span,
|
||||
pub plural: bool,
|
||||
pub abi_name: &'static str,
|
||||
pub abi: ExternAbi,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
@ -1701,7 +1702,7 @@ pub(crate) struct CmseOutputStackSpill {
|
|||
#[primary_span]
|
||||
#[label]
|
||||
pub span: Span,
|
||||
pub abi_name: &'static str,
|
||||
pub abi: ExternAbi,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
|
|
|
@ -17,8 +17,6 @@ pub(crate) fn validate_cmse_abi<'tcx>(
|
|||
abi: ExternAbi,
|
||||
fn_sig: ty::PolyFnSig<'tcx>,
|
||||
) {
|
||||
let abi_name = abi.name();
|
||||
|
||||
match abi {
|
||||
ExternAbi::CCmseNonSecureCall => {
|
||||
let hir_node = tcx.hir_node(hir_id);
|
||||
|
@ -56,7 +54,7 @@ pub(crate) fn validate_cmse_abi<'tcx>(
|
|||
.to(bare_fn_ty.decl.inputs[index].span)
|
||||
.to(bare_fn_ty.decl.inputs.last().unwrap().span);
|
||||
let plural = bare_fn_ty.param_names.len() - index != 1;
|
||||
dcx.emit_err(errors::CmseInputsStackSpill { span, plural, abi_name });
|
||||
dcx.emit_err(errors::CmseInputsStackSpill { span, plural, abi });
|
||||
}
|
||||
Err(layout_err) => {
|
||||
if should_emit_generic_error(abi, layout_err) {
|
||||
|
@ -69,7 +67,7 @@ pub(crate) fn validate_cmse_abi<'tcx>(
|
|||
Ok(true) => {}
|
||||
Ok(false) => {
|
||||
let span = bare_fn_ty.decl.output.span();
|
||||
dcx.emit_err(errors::CmseOutputStackSpill { span, abi_name });
|
||||
dcx.emit_err(errors::CmseOutputStackSpill { span, abi });
|
||||
}
|
||||
Err(layout_err) => {
|
||||
if should_emit_generic_error(abi, layout_err) {
|
||||
|
@ -92,7 +90,7 @@ pub(crate) fn validate_cmse_abi<'tcx>(
|
|||
// ^^^^^^
|
||||
let span = decl.inputs[index].span.to(decl.inputs.last().unwrap().span);
|
||||
let plural = decl.inputs.len() - index != 1;
|
||||
dcx.emit_err(errors::CmseInputsStackSpill { span, plural, abi_name });
|
||||
dcx.emit_err(errors::CmseInputsStackSpill { span, plural, abi });
|
||||
}
|
||||
Err(layout_err) => {
|
||||
if should_emit_generic_error(abi, layout_err) {
|
||||
|
@ -105,7 +103,7 @@ pub(crate) fn validate_cmse_abi<'tcx>(
|
|||
Ok(true) => {}
|
||||
Ok(false) => {
|
||||
let span = decl.output.span();
|
||||
dcx.emit_err(errors::CmseOutputStackSpill { span, abi_name });
|
||||
dcx.emit_err(errors::CmseOutputStackSpill { span, abi });
|
||||
}
|
||||
Err(layout_err) => {
|
||||
if should_emit_generic_error(abi, layout_err) {
|
||||
|
|
|
@ -6,7 +6,7 @@ use rustc_errors::{
|
|||
Applicability, Diag, ErrorGuaranteed, MultiSpan, listify, pluralize, struct_span_code_err,
|
||||
};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def::{DefKind, Res};
|
||||
use rustc_hir::def::{CtorOf, DefKind, Res};
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::ty::fast_reject::{TreatParams, simplify_type};
|
||||
|
@ -1027,7 +1027,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
&self,
|
||||
segments: impl Iterator<Item = &'a hir::PathSegment<'a>> + Clone,
|
||||
args_visitors: impl Iterator<Item = &'a hir::GenericArg<'a>> + Clone,
|
||||
err_extend: GenericsArgsErrExtend<'_>,
|
||||
err_extend: GenericsArgsErrExtend<'a>,
|
||||
) -> ErrorGuaranteed {
|
||||
#[derive(PartialEq, Eq, Hash)]
|
||||
enum ProhibitGenericsArg {
|
||||
|
@ -1047,23 +1047,24 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
};
|
||||
});
|
||||
|
||||
let segments: Vec<_> = segments.collect();
|
||||
let types_and_spans: Vec<_> = segments
|
||||
.clone()
|
||||
.iter()
|
||||
.flat_map(|segment| {
|
||||
if segment.args().args.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some((
|
||||
match segment.res {
|
||||
hir::def::Res::PrimTy(ty) => {
|
||||
Res::PrimTy(ty) => {
|
||||
format!("{} `{}`", segment.res.descr(), ty.name())
|
||||
}
|
||||
hir::def::Res::Def(_, def_id)
|
||||
Res::Def(_, def_id)
|
||||
if let Some(name) = self.tcx().opt_item_name(def_id) =>
|
||||
{
|
||||
format!("{} `{name}`", segment.res.descr())
|
||||
}
|
||||
hir::def::Res::Err => "this type".to_string(),
|
||||
Res::Err => "this type".to_string(),
|
||||
_ => segment.res.descr().to_string(),
|
||||
},
|
||||
segment.ident.span,
|
||||
|
@ -1074,11 +1075,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
let this_type = listify(&types_and_spans, |(t, _)| t.to_string())
|
||||
.expect("expected one segment to deny");
|
||||
|
||||
let arg_spans: Vec<Span> = segments
|
||||
.clone()
|
||||
.flat_map(|segment| segment.args().args)
|
||||
.map(|arg| arg.span())
|
||||
.collect();
|
||||
let arg_spans: Vec<Span> =
|
||||
segments.iter().flat_map(|segment| segment.args().args).map(|arg| arg.span()).collect();
|
||||
|
||||
let mut kinds = Vec::with_capacity(4);
|
||||
prohibit_args.iter().for_each(|arg| match arg {
|
||||
|
@ -1103,7 +1101,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
for (what, span) in types_and_spans {
|
||||
err.span_label(span, format!("not allowed on {what}"));
|
||||
}
|
||||
generics_args_err_extend(self.tcx(), segments, &mut err, err_extend);
|
||||
generics_args_err_extend(self.tcx(), segments.into_iter(), &mut err, err_extend);
|
||||
err.emit()
|
||||
}
|
||||
|
||||
|
@ -1400,7 +1398,7 @@ pub enum GenericsArgsErrExtend<'tcx> {
|
|||
},
|
||||
SelfTyParam(Span),
|
||||
Param(DefId),
|
||||
DefVariant,
|
||||
DefVariant(&'tcx [hir::PathSegment<'tcx>]),
|
||||
None,
|
||||
}
|
||||
|
||||
|
@ -1408,7 +1406,7 @@ fn generics_args_err_extend<'a>(
|
|||
tcx: TyCtxt<'_>,
|
||||
segments: impl Iterator<Item = &'a hir::PathSegment<'a>> + Clone,
|
||||
err: &mut Diag<'_>,
|
||||
err_extend: GenericsArgsErrExtend<'_>,
|
||||
err_extend: GenericsArgsErrExtend<'a>,
|
||||
) {
|
||||
match err_extend {
|
||||
GenericsArgsErrExtend::EnumVariant { qself, assoc_segment, adt_def } => {
|
||||
|
@ -1496,6 +1494,32 @@ fn generics_args_err_extend<'a>(
|
|||
];
|
||||
err.multipart_suggestion_verbose(msg, suggestion, Applicability::MaybeIncorrect);
|
||||
}
|
||||
GenericsArgsErrExtend::DefVariant(segments) => {
|
||||
let args: Vec<Span> = segments
|
||||
.iter()
|
||||
.filter_map(|segment| match segment.res {
|
||||
Res::Def(
|
||||
DefKind::Ctor(CtorOf::Variant, _) | DefKind::Variant | DefKind::Enum,
|
||||
_,
|
||||
) => segment.args().span_ext().map(|s| s.with_lo(segment.ident.span.hi())),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
if args.len() > 1
|
||||
&& let Some(span) = args.into_iter().last()
|
||||
{
|
||||
err.note(
|
||||
"generic arguments are not allowed on both an enum and its variant's path \
|
||||
segments simultaneously; they are only valid in one place or the other",
|
||||
);
|
||||
err.span_suggestion_verbose(
|
||||
span,
|
||||
"remove the generics arguments from one of the path segments",
|
||||
String::new(),
|
||||
Applicability::MaybeIncorrect,
|
||||
);
|
||||
}
|
||||
}
|
||||
GenericsArgsErrExtend::PrimTy(prim_ty) => {
|
||||
let name = prim_ty.name_str();
|
||||
for segment in segments {
|
||||
|
@ -1512,9 +1536,6 @@ fn generics_args_err_extend<'a>(
|
|||
GenericsArgsErrExtend::OpaqueTy => {
|
||||
err.note("`impl Trait` types can't have type parameters");
|
||||
}
|
||||
GenericsArgsErrExtend::DefVariant => {
|
||||
err.note("enum variants can't have type parameters");
|
||||
}
|
||||
GenericsArgsErrExtend::Param(def_id) => {
|
||||
let span = tcx.def_ident_span(def_id).unwrap();
|
||||
let kind = tcx.def_descr(def_id);
|
||||
|
|
|
@ -1694,7 +1694,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
pub fn prohibit_generic_args<'a>(
|
||||
&self,
|
||||
segments: impl Iterator<Item = &'a hir::PathSegment<'a>> + Clone,
|
||||
err_extend: GenericsArgsErrExtend<'_>,
|
||||
err_extend: GenericsArgsErrExtend<'a>,
|
||||
) -> Result<(), ErrorGuaranteed> {
|
||||
let args_visitors = segments.clone().flat_map(|segment| segment.args().args);
|
||||
let mut result = Ok(());
|
||||
|
@ -1911,7 +1911,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
path.segments.iter().enumerate().filter_map(|(index, seg)| {
|
||||
if !indices.contains(&index) { Some(seg) } else { None }
|
||||
}),
|
||||
GenericsArgsErrExtend::DefVariant,
|
||||
GenericsArgsErrExtend::DefVariant(&path.segments),
|
||||
);
|
||||
|
||||
let GenericPathSegment(def_id, index) = generic_segments.last().unwrap();
|
||||
|
|
|
@ -1043,12 +1043,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
|
||||
let mut user_self_ty = None;
|
||||
let mut is_alias_variant_ctor = false;
|
||||
let mut err_extend = GenericsArgsErrExtend::None;
|
||||
match res {
|
||||
Res::Def(DefKind::Ctor(CtorOf::Variant, _), _) if let Some(self_ty) = self_ty => {
|
||||
let adt_def = self_ty.normalized.ty_adt_def().unwrap();
|
||||
user_self_ty =
|
||||
Some(UserSelfTy { impl_def_id: adt_def.did(), self_ty: self_ty.raw });
|
||||
is_alias_variant_ctor = true;
|
||||
err_extend = GenericsArgsErrExtend::DefVariant(segments);
|
||||
}
|
||||
Res::Def(DefKind::Ctor(CtorOf::Variant, _), _) => {
|
||||
err_extend = GenericsArgsErrExtend::DefVariant(segments);
|
||||
}
|
||||
Res::Def(DefKind::AssocFn | DefKind::AssocConst, def_id) => {
|
||||
let assoc_item = tcx.associated_item(def_id);
|
||||
|
@ -1095,7 +1100,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
segments.iter().enumerate().filter_map(|(index, seg)| {
|
||||
if !indices.contains(&index) || is_alias_variant_ctor { Some(seg) } else { None }
|
||||
}),
|
||||
GenericsArgsErrExtend::None,
|
||||
err_extend,
|
||||
);
|
||||
|
||||
if let Res::Local(hid) = res {
|
||||
|
|
|
@ -160,8 +160,7 @@ pub(super) fn decorate_lint(
|
|||
.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::MissingAbi(label_span, default_abi) => {
|
||||
lints::MissingAbi { span: label_span, default_abi: default_abi.name() }
|
||||
.decorate_lint(diag);
|
||||
lints::MissingAbi { span: label_span, default_abi }.decorate_lint(diag);
|
||||
}
|
||||
BuiltinLintDiag::LegacyDeriveHelpers(label_span) => {
|
||||
lints::LegacyDeriveHelpers { span: label_span }.decorate_lint(diag);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#![allow(rustc::untranslatable_diagnostic)]
|
||||
use std::num::NonZero;
|
||||
|
||||
use rustc_abi::ExternAbi;
|
||||
use rustc_errors::codes::*;
|
||||
use rustc_errors::{
|
||||
Applicability, Diag, DiagArgValue, DiagMessage, DiagStyledString, ElidedLifetimeInPathSubdiag,
|
||||
|
@ -2833,9 +2834,9 @@ pub(crate) struct PatternsInFnsWithoutBodySub {
|
|||
#[derive(LintDiagnostic)]
|
||||
#[diag(lint_extern_without_abi)]
|
||||
pub(crate) struct MissingAbi {
|
||||
#[suggestion(code = "extern \"{default_abi}\"", applicability = "machine-applicable")]
|
||||
#[suggestion(code = "extern {default_abi}", applicability = "machine-applicable")]
|
||||
pub span: Span,
|
||||
pub default_abi: &'static str,
|
||||
pub default_abi: ExternAbi,
|
||||
}
|
||||
|
||||
#[derive(LintDiagnostic)]
|
||||
|
|
|
@ -161,12 +161,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> {
|
|||
let unsafety = fn_sig.safety().prefix_str();
|
||||
let abi = match fn_sig.abi() {
|
||||
ExternAbi::Rust => String::from(""),
|
||||
other_abi => {
|
||||
let mut s = String::from("extern \"");
|
||||
s.push_str(other_abi.name());
|
||||
s.push_str("\" ");
|
||||
s
|
||||
}
|
||||
other_abi => format!("extern {other_abi} "),
|
||||
};
|
||||
let ident = self.tcx.item_ident(fn_id);
|
||||
let ty_params = fn_args.types().map(|ty| format!("{ty}"));
|
||||
|
|
|
@ -1790,7 +1790,7 @@ supported_targets! {
|
|||
("x86_64-unknown-l4re-uclibc", x86_64_unknown_l4re_uclibc),
|
||||
|
||||
("aarch64-unknown-redox", aarch64_unknown_redox),
|
||||
("i686-unknown-redox", i686_unknown_redox),
|
||||
("i586-unknown-redox", i586_unknown_redox),
|
||||
("x86_64-unknown-redox", x86_64_unknown_redox),
|
||||
|
||||
("i386-apple-ios", i386_apple_ios),
|
||||
|
|
|
@ -10,7 +10,7 @@ pub(crate) fn target() -> Target {
|
|||
base.stack_probes = StackProbeType::Call;
|
||||
|
||||
Target {
|
||||
llvm_target: "i686-unknown-redox".into(),
|
||||
llvm_target: "i586-unknown-redox".into(),
|
||||
metadata: crate::spec::TargetMetadata {
|
||||
description: None,
|
||||
tier: None,
|
Loading…
Add table
Add a link
Reference in a new issue