Skip to content

Commit 552a959

Browse files
committed
Auto merge of rust-lang#136918 - GuillaumeGomez:rollup-f6h21gg, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - rust-lang#134981 ( Explain that in paths generics can't be set on both the enum and the variant) - rust-lang#136698 (Replace i686-unknown-redox target with i586-unknown-redox) - rust-lang#136767 (improve host/cross target checking) - rust-lang#136829 ([rustdoc] Move line numbers into the `<code>` directly) - rust-lang#136875 (Rustc dev guide subtree update) - rust-lang#136900 (compiler: replace `ExternAbi::name` calls with formatters) - rust-lang#136913 (Put kobzol back on review rotation) - rust-lang#136915 (documentation fix: `f16` and `f128` are not double-precision) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 021fb9c + 40f0499 commit 552a959

File tree

69 files changed

+578
-399
lines changed

Some content is hidden

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

69 files changed

+578
-399
lines changed

Diff for: compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,7 @@ fn push_debuginfo_type_name<'tcx>(
367367
output.push_str(sig.safety.prefix_str());
368368

369369
if sig.abi != rustc_abi::ExternAbi::Rust {
370-
output.push_str("extern \"");
371-
output.push_str(sig.abi.name());
372-
output.push_str("\" ");
370+
let _ = write!(output, "extern {} ", sig.abi);
373371
}
374372

375373
output.push_str("fn(");

Diff for: compiler/rustc_errors/src/diagnostic_impls.rs

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ into_diag_arg_using_display!(
9393
SplitDebuginfo,
9494
ExitStatus,
9595
ErrCode,
96+
rustc_abi::ExternAbi,
9697
);
9798

9899
impl<I: rustc_type_ir::Interner> IntoDiagArg for rustc_type_ir::TraitRef<I> {

Diff for: compiler/rustc_hir_analysis/messages.ftl

+4-4
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,17 @@ hir_analysis_cmse_entry_generic =
7272
functions with the `"C-cmse-nonsecure-entry"` ABI cannot contain generics in their type
7373
7474
hir_analysis_cmse_inputs_stack_spill =
75-
arguments for `"{$abi_name}"` function too large to pass via registers
75+
arguments for `{$abi}` function too large to pass via registers
7676
.label = {$plural ->
7777
[false] this argument doesn't
7878
*[true] these arguments don't
7979
} fit in the available registers
80-
.note = functions with the `"{$abi_name}"` ABI must pass all their arguments via the 4 32-bit available argument registers
80+
.note = functions with the `{$abi}` ABI must pass all their arguments via the 4 32-bit available argument registers
8181
8282
hir_analysis_cmse_output_stack_spill =
83-
return value of `"{$abi_name}"` function too large to pass via registers
83+
return value of `{$abi}` function too large to pass via registers
8484
.label = this type doesn't fit in the available registers
85-
.note1 = functions with the `"{$abi_name}"` ABI must pass their result via the available return registers
85+
.note1 = functions with the `{$abi}` ABI must pass their result via the available return registers
8686
.note2 = the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size
8787
8888
hir_analysis_coerce_pointee_no_field = `CoercePointee` can only be derived on `struct`s with at least one field

Diff for: compiler/rustc_hir_analysis/src/collect.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -614,9 +614,10 @@ impl<'tcx> HirTyLowerer<'tcx> for ItemCtxt<'tcx> {
614614
if !infer_replacements.is_empty() {
615615
diag.multipart_suggestion(
616616
format!(
617-
"try replacing `_` with the type{} in the corresponding trait method signature",
618-
rustc_errors::pluralize!(infer_replacements.len()),
619-
),
617+
"try replacing `_` with the type{} in the corresponding trait method \
618+
signature",
619+
rustc_errors::pluralize!(infer_replacements.len()),
620+
),
620621
infer_replacements,
621622
Applicability::MachineApplicable,
622623
);

Diff for: compiler/rustc_hir_analysis/src/errors.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Errors emitted by `rustc_hir_analysis`.
22
3+
use rustc_abi::ExternAbi;
34
use rustc_errors::codes::*;
45
use rustc_errors::{
56
Applicability, Diag, DiagCtxtHandle, Diagnostic, EmissionGuarantee, Level, MultiSpan,
@@ -1690,7 +1691,7 @@ pub(crate) struct CmseInputsStackSpill {
16901691
#[label]
16911692
pub span: Span,
16921693
pub plural: bool,
1693-
pub abi_name: &'static str,
1694+
pub abi: ExternAbi,
16941695
}
16951696

16961697
#[derive(Diagnostic)]
@@ -1701,7 +1702,7 @@ pub(crate) struct CmseOutputStackSpill {
17011702
#[primary_span]
17021703
#[label]
17031704
pub span: Span,
1704-
pub abi_name: &'static str,
1705+
pub abi: ExternAbi,
17051706
}
17061707

17071708
#[derive(Diagnostic)]

Diff for: compiler/rustc_hir_analysis/src/hir_ty_lowering/cmse.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ pub(crate) fn validate_cmse_abi<'tcx>(
1717
abi: ExternAbi,
1818
fn_sig: ty::PolyFnSig<'tcx>,
1919
) {
20-
let abi_name = abi.name();
21-
2220
match abi {
2321
ExternAbi::CCmseNonSecureCall => {
2422
let hir_node = tcx.hir_node(hir_id);
@@ -56,7 +54,7 @@ pub(crate) fn validate_cmse_abi<'tcx>(
5654
.to(bare_fn_ty.decl.inputs[index].span)
5755
.to(bare_fn_ty.decl.inputs.last().unwrap().span);
5856
let plural = bare_fn_ty.param_names.len() - index != 1;
59-
dcx.emit_err(errors::CmseInputsStackSpill { span, plural, abi_name });
57+
dcx.emit_err(errors::CmseInputsStackSpill { span, plural, abi });
6058
}
6159
Err(layout_err) => {
6260
if should_emit_generic_error(abi, layout_err) {
@@ -69,7 +67,7 @@ pub(crate) fn validate_cmse_abi<'tcx>(
6967
Ok(true) => {}
7068
Ok(false) => {
7169
let span = bare_fn_ty.decl.output.span();
72-
dcx.emit_err(errors::CmseOutputStackSpill { span, abi_name });
70+
dcx.emit_err(errors::CmseOutputStackSpill { span, abi });
7371
}
7472
Err(layout_err) => {
7573
if should_emit_generic_error(abi, layout_err) {
@@ -92,7 +90,7 @@ pub(crate) fn validate_cmse_abi<'tcx>(
9290
// ^^^^^^
9391
let span = decl.inputs[index].span.to(decl.inputs.last().unwrap().span);
9492
let plural = decl.inputs.len() - index != 1;
95-
dcx.emit_err(errors::CmseInputsStackSpill { span, plural, abi_name });
93+
dcx.emit_err(errors::CmseInputsStackSpill { span, plural, abi });
9694
}
9795
Err(layout_err) => {
9896
if should_emit_generic_error(abi, layout_err) {
@@ -105,7 +103,7 @@ pub(crate) fn validate_cmse_abi<'tcx>(
105103
Ok(true) => {}
106104
Ok(false) => {
107105
let span = decl.output.span();
108-
dcx.emit_err(errors::CmseOutputStackSpill { span, abi_name });
106+
dcx.emit_err(errors::CmseOutputStackSpill { span, abi });
109107
}
110108
Err(layout_err) => {
111109
if should_emit_generic_error(abi, layout_err) {

Diff for: compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs

+38-17
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_errors::{
66
Applicability, Diag, ErrorGuaranteed, MultiSpan, listify, pluralize, struct_span_code_err,
77
};
88
use rustc_hir as hir;
9-
use rustc_hir::def::{DefKind, Res};
9+
use rustc_hir::def::{CtorOf, DefKind, Res};
1010
use rustc_hir::def_id::DefId;
1111
use rustc_middle::bug;
1212
use rustc_middle::ty::fast_reject::{TreatParams, simplify_type};
@@ -1027,7 +1027,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
10271027
&self,
10281028
segments: impl Iterator<Item = &'a hir::PathSegment<'a>> + Clone,
10291029
args_visitors: impl Iterator<Item = &'a hir::GenericArg<'a>> + Clone,
1030-
err_extend: GenericsArgsErrExtend<'_>,
1030+
err_extend: GenericsArgsErrExtend<'a>,
10311031
) -> ErrorGuaranteed {
10321032
#[derive(PartialEq, Eq, Hash)]
10331033
enum ProhibitGenericsArg {
@@ -1047,23 +1047,24 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
10471047
};
10481048
});
10491049

1050+
let segments: Vec<_> = segments.collect();
10501051
let types_and_spans: Vec<_> = segments
1051-
.clone()
1052+
.iter()
10521053
.flat_map(|segment| {
10531054
if segment.args().args.is_empty() {
10541055
None
10551056
} else {
10561057
Some((
10571058
match segment.res {
1058-
hir::def::Res::PrimTy(ty) => {
1059+
Res::PrimTy(ty) => {
10591060
format!("{} `{}`", segment.res.descr(), ty.name())
10601061
}
1061-
hir::def::Res::Def(_, def_id)
1062+
Res::Def(_, def_id)
10621063
if let Some(name) = self.tcx().opt_item_name(def_id) =>
10631064
{
10641065
format!("{} `{name}`", segment.res.descr())
10651066
}
1066-
hir::def::Res::Err => "this type".to_string(),
1067+
Res::Err => "this type".to_string(),
10671068
_ => segment.res.descr().to_string(),
10681069
},
10691070
segment.ident.span,
@@ -1074,11 +1075,8 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
10741075
let this_type = listify(&types_and_spans, |(t, _)| t.to_string())
10751076
.expect("expected one segment to deny");
10761077

1077-
let arg_spans: Vec<Span> = segments
1078-
.clone()
1079-
.flat_map(|segment| segment.args().args)
1080-
.map(|arg| arg.span())
1081-
.collect();
1078+
let arg_spans: Vec<Span> =
1079+
segments.iter().flat_map(|segment| segment.args().args).map(|arg| arg.span()).collect();
10821080

10831081
let mut kinds = Vec::with_capacity(4);
10841082
prohibit_args.iter().for_each(|arg| match arg {
@@ -1103,7 +1101,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
11031101
for (what, span) in types_and_spans {
11041102
err.span_label(span, format!("not allowed on {what}"));
11051103
}
1106-
generics_args_err_extend(self.tcx(), segments, &mut err, err_extend);
1104+
generics_args_err_extend(self.tcx(), segments.into_iter(), &mut err, err_extend);
11071105
err.emit()
11081106
}
11091107

@@ -1400,15 +1398,15 @@ pub enum GenericsArgsErrExtend<'tcx> {
14001398
},
14011399
SelfTyParam(Span),
14021400
Param(DefId),
1403-
DefVariant,
1401+
DefVariant(&'tcx [hir::PathSegment<'tcx>]),
14041402
None,
14051403
}
14061404

14071405
fn generics_args_err_extend<'a>(
14081406
tcx: TyCtxt<'_>,
14091407
segments: impl Iterator<Item = &'a hir::PathSegment<'a>> + Clone,
14101408
err: &mut Diag<'_>,
1411-
err_extend: GenericsArgsErrExtend<'_>,
1409+
err_extend: GenericsArgsErrExtend<'a>,
14121410
) {
14131411
match err_extend {
14141412
GenericsArgsErrExtend::EnumVariant { qself, assoc_segment, adt_def } => {
@@ -1496,6 +1494,32 @@ fn generics_args_err_extend<'a>(
14961494
];
14971495
err.multipart_suggestion_verbose(msg, suggestion, Applicability::MaybeIncorrect);
14981496
}
1497+
GenericsArgsErrExtend::DefVariant(segments) => {
1498+
let args: Vec<Span> = segments
1499+
.iter()
1500+
.filter_map(|segment| match segment.res {
1501+
Res::Def(
1502+
DefKind::Ctor(CtorOf::Variant, _) | DefKind::Variant | DefKind::Enum,
1503+
_,
1504+
) => segment.args().span_ext().map(|s| s.with_lo(segment.ident.span.hi())),
1505+
_ => None,
1506+
})
1507+
.collect();
1508+
if args.len() > 1
1509+
&& let Some(span) = args.into_iter().last()
1510+
{
1511+
err.note(
1512+
"generic arguments are not allowed on both an enum and its variant's path \
1513+
segments simultaneously; they are only valid in one place or the other",
1514+
);
1515+
err.span_suggestion_verbose(
1516+
span,
1517+
"remove the generics arguments from one of the path segments",
1518+
String::new(),
1519+
Applicability::MaybeIncorrect,
1520+
);
1521+
}
1522+
}
14991523
GenericsArgsErrExtend::PrimTy(prim_ty) => {
15001524
let name = prim_ty.name_str();
15011525
for segment in segments {
@@ -1512,9 +1536,6 @@ fn generics_args_err_extend<'a>(
15121536
GenericsArgsErrExtend::OpaqueTy => {
15131537
err.note("`impl Trait` types can't have type parameters");
15141538
}
1515-
GenericsArgsErrExtend::DefVariant => {
1516-
err.note("enum variants can't have type parameters");
1517-
}
15181539
GenericsArgsErrExtend::Param(def_id) => {
15191540
let span = tcx.def_ident_span(def_id).unwrap();
15201541
let kind = tcx.def_descr(def_id);

Diff for: compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
16941694
pub fn prohibit_generic_args<'a>(
16951695
&self,
16961696
segments: impl Iterator<Item = &'a hir::PathSegment<'a>> + Clone,
1697-
err_extend: GenericsArgsErrExtend<'_>,
1697+
err_extend: GenericsArgsErrExtend<'a>,
16981698
) -> Result<(), ErrorGuaranteed> {
16991699
let args_visitors = segments.clone().flat_map(|segment| segment.args().args);
17001700
let mut result = Ok(());
@@ -1911,7 +1911,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
19111911
path.segments.iter().enumerate().filter_map(|(index, seg)| {
19121912
if !indices.contains(&index) { Some(seg) } else { None }
19131913
}),
1914-
GenericsArgsErrExtend::DefVariant,
1914+
GenericsArgsErrExtend::DefVariant(&path.segments),
19151915
);
19161916

19171917
let GenericPathSegment(def_id, index) = generic_segments.last().unwrap();

Diff for: compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1043,12 +1043,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10431043

10441044
let mut user_self_ty = None;
10451045
let mut is_alias_variant_ctor = false;
1046+
let mut err_extend = GenericsArgsErrExtend::None;
10461047
match res {
10471048
Res::Def(DefKind::Ctor(CtorOf::Variant, _), _) if let Some(self_ty) = self_ty => {
10481049
let adt_def = self_ty.normalized.ty_adt_def().unwrap();
10491050
user_self_ty =
10501051
Some(UserSelfTy { impl_def_id: adt_def.did(), self_ty: self_ty.raw });
10511052
is_alias_variant_ctor = true;
1053+
err_extend = GenericsArgsErrExtend::DefVariant(segments);
1054+
}
1055+
Res::Def(DefKind::Ctor(CtorOf::Variant, _), _) => {
1056+
err_extend = GenericsArgsErrExtend::DefVariant(segments);
10521057
}
10531058
Res::Def(DefKind::AssocFn | DefKind::AssocConst, def_id) => {
10541059
let assoc_item = tcx.associated_item(def_id);
@@ -1095,7 +1100,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10951100
segments.iter().enumerate().filter_map(|(index, seg)| {
10961101
if !indices.contains(&index) || is_alias_variant_ctor { Some(seg) } else { None }
10971102
}),
1098-
GenericsArgsErrExtend::None,
1103+
err_extend,
10991104
);
11001105

11011106
if let Res::Local(hid) = res {

Diff for: compiler/rustc_lint/src/early/diagnostics.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,7 @@ pub(super) fn decorate_lint(
160160
.decorate_lint(diag);
161161
}
162162
BuiltinLintDiag::MissingAbi(label_span, default_abi) => {
163-
lints::MissingAbi { span: label_span, default_abi: default_abi.name() }
164-
.decorate_lint(diag);
163+
lints::MissingAbi { span: label_span, default_abi }.decorate_lint(diag);
165164
}
166165
BuiltinLintDiag::LegacyDeriveHelpers(label_span) => {
167166
lints::LegacyDeriveHelpers { span: label_span }.decorate_lint(diag);

Diff for: compiler/rustc_lint/src/lints.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![allow(rustc::untranslatable_diagnostic)]
33
use std::num::NonZero;
44

5+
use rustc_abi::ExternAbi;
56
use rustc_errors::codes::*;
67
use rustc_errors::{
78
Applicability, Diag, DiagArgValue, DiagMessage, DiagStyledString, ElidedLifetimeInPathSubdiag,
@@ -2833,9 +2834,9 @@ pub(crate) struct PatternsInFnsWithoutBodySub {
28332834
#[derive(LintDiagnostic)]
28342835
#[diag(lint_extern_without_abi)]
28352836
pub(crate) struct MissingAbi {
2836-
#[suggestion(code = "extern \"{default_abi}\"", applicability = "machine-applicable")]
2837+
#[suggestion(code = "extern {default_abi}", applicability = "machine-applicable")]
28372838
pub span: Span,
2838-
pub default_abi: &'static str,
2839+
pub default_abi: ExternAbi,
28392840
}
28402841

28412842
#[derive(LintDiagnostic)]

Diff for: compiler/rustc_mir_transform/src/function_item_references.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,7 @@ impl<'tcx> FunctionItemRefChecker<'_, 'tcx> {
161161
let unsafety = fn_sig.safety().prefix_str();
162162
let abi = match fn_sig.abi() {
163163
ExternAbi::Rust => String::from(""),
164-
other_abi => {
165-
let mut s = String::from("extern \"");
166-
s.push_str(other_abi.name());
167-
s.push_str("\" ");
168-
s
169-
}
164+
other_abi => format!("extern {other_abi} "),
170165
};
171166
let ident = self.tcx.item_ident(fn_id);
172167
let ty_params = fn_args.types().map(|ty| format!("{ty}"));

Diff for: compiler/rustc_target/src/spec/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1790,7 +1790,7 @@ supported_targets! {
17901790
("x86_64-unknown-l4re-uclibc", x86_64_unknown_l4re_uclibc),
17911791

17921792
("aarch64-unknown-redox", aarch64_unknown_redox),
1793-
("i686-unknown-redox", i686_unknown_redox),
1793+
("i586-unknown-redox", i586_unknown_redox),
17941794
("x86_64-unknown-redox", x86_64_unknown_redox),
17951795

17961796
("i386-apple-ios", i386_apple_ios),

Diff for: compiler/rustc_target/src/spec/targets/i686_unknown_redox.rs renamed to compiler/rustc_target/src/spec/targets/i586_unknown_redox.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub(crate) fn target() -> Target {
1010
base.stack_probes = StackProbeType::Call;
1111

1212
Target {
13-
llvm_target: "i686-unknown-redox".into(),
13+
llvm_target: "i586-unknown-redox".into(),
1414
metadata: crate::spec::TargetMetadata {
1515
description: None,
1616
tier: None,

Diff for: library/std/src/f128.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Constants for the `f128` double-precision floating point type.
1+
//! Constants for the `f128` quadruple-precision floating point type.
22
//!
33
//! *[See also the `f128` primitive type](primitive@f128).*
44
//!

Diff for: library/std/src/f16.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Constants for the `f16` double-precision floating point type.
1+
//! Constants for the `f16` half-precision floating point type.
22
//!
33
//! *[See also the `f16` primitive type](primitive@f16).*
44
//!

Diff for: src/bootstrap/src/core/build_steps/compile.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl Step for Std {
191191
// The LLD wrappers and `rust-lld` are self-contained linking components that can be
192192
// necessary to link the stdlib on some targets. We'll also need to copy these binaries to
193193
// the `stage0-sysroot` to ensure the linker is found when bootstrapping on such a target.
194-
if compiler.stage == 0 && compiler.host == builder.config.build {
194+
if compiler.stage == 0 && builder.is_builder_target(&compiler.host) {
195195
// We want to copy the host `bin` folder within the `rustlib` folder in the sysroot.
196196
let src_sysroot_bin = builder
197197
.rustc_snapshot_sysroot()
@@ -2310,7 +2310,8 @@ pub fn strip_debug(builder: &Builder<'_>, target: TargetSelection, path: &Path)
23102310
// FIXME: to make things simpler for now, limit this to the host and target where we know
23112311
// `strip -g` is both available and will fix the issue, i.e. on a x64 linux host that is not
23122312
// cross-compiling. Expand this to other appropriate targets in the future.
2313-
if target != "x86_64-unknown-linux-gnu" || target != builder.config.build || !path.exists() {
2313+
if target != "x86_64-unknown-linux-gnu" || !builder.is_builder_target(&target) || !path.exists()
2314+
{
23142315
return;
23152316
}
23162317

0 commit comments

Comments
 (0)