Skip to content

Commit d264161

Browse files
committed
Auto merge of rust-lang#137855 - matthiaskrgr:rollup-uh7f3fi, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - rust-lang#137804 (rename BackendRepr::Vector → SimdVector) - rust-lang#137807 (Fully qualify `Result` in generated doctest code) - rust-lang#137809 (Use correct error message casing for `io::const_error`s) - rust-lang#137818 (tests: adapt for LLVM 21 changes) - rust-lang#137822 (Update query normalizer docs to not position it as the greatest pioneer in the space of normalization) - rust-lang#137824 (Tweak invalid RTN errors) - rust-lang#137828 (Fix inaccurate `std::intrinsics::simd` documentation) - rust-lang#137830 (Fix link failure on AVR (incompatible ISA error)) - rust-lang#137837 (Update `const_conditions` and `explicit_implied_const_bounds` docs) - rust-lang#137840 (triagebot: only ping me for constck) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8c39296 + 5bdde89 commit d264161

File tree

67 files changed

+374
-264
lines changed

Some content is hidden

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

67 files changed

+374
-264
lines changed

compiler/rustc_abi/src/callconv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
7474
Ok(HomogeneousAggregate::Homogeneous(Reg { kind, size: self.size }))
7575
}
7676

77-
BackendRepr::Vector { .. } => {
77+
BackendRepr::SimdVector { .. } => {
7878
assert!(!self.is_zst());
7979
Ok(HomogeneousAggregate::Homogeneous(Reg {
8080
kind: RegKind::Vector,

compiler/rustc_abi/src/layout.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -386,13 +386,15 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
386386
BackendRepr::Memory { sized: true }
387387
}
388388
// Vectors require at least element alignment, else disable the opt
389-
BackendRepr::Vector { element, count: _ } if element.align(dl).abi > align.abi => {
389+
BackendRepr::SimdVector { element, count: _ }
390+
if element.align(dl).abi > align.abi =>
391+
{
390392
BackendRepr::Memory { sized: true }
391393
}
392394
// the alignment tests passed and we can use this
393395
BackendRepr::Scalar(..)
394396
| BackendRepr::ScalarPair(..)
395-
| BackendRepr::Vector { .. }
397+
| BackendRepr::SimdVector { .. }
396398
| BackendRepr::Memory { .. } => repr,
397399
},
398400
};
@@ -464,7 +466,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
464466
hide_niches(a);
465467
hide_niches(b);
466468
}
467-
BackendRepr::Vector { element, count: _ } => hide_niches(element),
469+
BackendRepr::SimdVector { element, count: _ } => hide_niches(element),
468470
BackendRepr::Memory { sized: _ } => {}
469471
}
470472
st.largest_niche = None;
@@ -1314,7 +1316,9 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
13141316
match field.backend_repr {
13151317
// For plain scalars, or vectors of them, we can't unpack
13161318
// newtypes for `#[repr(C)]`, as that affects C ABIs.
1317-
BackendRepr::Scalar(_) | BackendRepr::Vector { .. } if optimize_abi => {
1319+
BackendRepr::Scalar(_) | BackendRepr::SimdVector { .. }
1320+
if optimize_abi =>
1321+
{
13181322
abi = field.backend_repr;
13191323
}
13201324
// But scalar pairs are Rust-specific and get

compiler/rustc_abi/src/layout/ty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
219219
C: HasDataLayout,
220220
{
221221
match self.backend_repr {
222-
BackendRepr::Vector { .. } => self.size == expected_size,
222+
BackendRepr::SimdVector { .. } => self.size == expected_size,
223223
BackendRepr::Memory { .. } => {
224224
if self.fields.count() == 1 && self.fields.offset(0).bytes() == 0 {
225225
self.field(cx, 0).is_single_vector_element(cx, expected_size)

compiler/rustc_abi/src/lib.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@ impl AddressSpace {
14101410
pub enum BackendRepr {
14111411
Scalar(Scalar),
14121412
ScalarPair(Scalar, Scalar),
1413-
Vector {
1413+
SimdVector {
14141414
element: Scalar,
14151415
count: u64,
14161416
},
@@ -1426,9 +1426,9 @@ impl BackendRepr {
14261426
#[inline]
14271427
pub fn is_unsized(&self) -> bool {
14281428
match *self {
1429-
BackendRepr::Scalar(_) | BackendRepr::ScalarPair(..) | BackendRepr::Vector { .. } => {
1430-
false
1431-
}
1429+
BackendRepr::Scalar(_)
1430+
| BackendRepr::ScalarPair(..)
1431+
| BackendRepr::SimdVector { .. } => false,
14321432
BackendRepr::Memory { sized } => !sized,
14331433
}
14341434
}
@@ -1467,7 +1467,7 @@ impl BackendRepr {
14671467
BackendRepr::Scalar(s) => Some(s.align(cx).abi),
14681468
BackendRepr::ScalarPair(s1, s2) => Some(s1.align(cx).max(s2.align(cx)).abi),
14691469
// The align of a Vector can vary in surprising ways
1470-
BackendRepr::Vector { .. } | BackendRepr::Memory { .. } => None,
1470+
BackendRepr::SimdVector { .. } | BackendRepr::Memory { .. } => None,
14711471
}
14721472
}
14731473

@@ -1489,7 +1489,7 @@ impl BackendRepr {
14891489
Some(size)
14901490
}
14911491
// The size of a Vector can vary in surprising ways
1492-
BackendRepr::Vector { .. } | BackendRepr::Memory { .. } => None,
1492+
BackendRepr::SimdVector { .. } | BackendRepr::Memory { .. } => None,
14931493
}
14941494
}
14951495

@@ -1500,8 +1500,8 @@ impl BackendRepr {
15001500
BackendRepr::ScalarPair(s1, s2) => {
15011501
BackendRepr::ScalarPair(s1.to_union(), s2.to_union())
15021502
}
1503-
BackendRepr::Vector { element, count } => {
1504-
BackendRepr::Vector { element: element.to_union(), count }
1503+
BackendRepr::SimdVector { element, count } => {
1504+
BackendRepr::SimdVector { element: element.to_union(), count }
15051505
}
15061506
BackendRepr::Memory { .. } => BackendRepr::Memory { sized: true },
15071507
}
@@ -1513,8 +1513,8 @@ impl BackendRepr {
15131513
// We do *not* ignore the sign since it matters for some ABIs (e.g. s390x).
15141514
(BackendRepr::Scalar(l), BackendRepr::Scalar(r)) => l.primitive() == r.primitive(),
15151515
(
1516-
BackendRepr::Vector { element: element_l, count: count_l },
1517-
BackendRepr::Vector { element: element_r, count: count_r },
1516+
BackendRepr::SimdVector { element: element_l, count: count_l },
1517+
BackendRepr::SimdVector { element: element_r, count: count_r },
15181518
) => element_l.primitive() == element_r.primitive() && count_l == count_r,
15191519
(BackendRepr::ScalarPair(l1, l2), BackendRepr::ScalarPair(r1, r2)) => {
15201520
l1.primitive() == r1.primitive() && l2.primitive() == r2.primitive()
@@ -1735,7 +1735,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
17351735
/// Returns `true` if this is an aggregate type (including a ScalarPair!)
17361736
pub fn is_aggregate(&self) -> bool {
17371737
match self.backend_repr {
1738-
BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => false,
1738+
BackendRepr::Scalar(_) | BackendRepr::SimdVector { .. } => false,
17391739
BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => true,
17401740
}
17411741
}
@@ -1877,9 +1877,9 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
18771877
/// non-trivial alignment constraints. You probably want to use `is_1zst` instead.
18781878
pub fn is_zst(&self) -> bool {
18791879
match self.backend_repr {
1880-
BackendRepr::Scalar(_) | BackendRepr::ScalarPair(..) | BackendRepr::Vector { .. } => {
1881-
false
1882-
}
1880+
BackendRepr::Scalar(_)
1881+
| BackendRepr::ScalarPair(..)
1882+
| BackendRepr::SimdVector { .. } => false,
18831883
BackendRepr::Memory { sized } => sized && self.size.bytes() == 0,
18841884
}
18851885
}

compiler/rustc_ast_lowering/messages.ftl

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ ast_lowering_bad_return_type_notation_inputs =
3737
.suggestion = remove the input types
3838
3939
ast_lowering_bad_return_type_notation_needs_dots = return type notation arguments must be elided with `..`
40-
.suggestion = add `..`
40+
.suggestion = use the correct syntax by adding `..` to the arguments
4141
4242
ast_lowering_bad_return_type_notation_output =
4343
return type not allowed with return type notation
44-
.suggestion = remove the return type
44+
ast_lowering_bad_return_type_notation_output_suggestion = use the right argument notation and remove the return type
4545
4646
ast_lowering_bad_return_type_notation_position = return type notation not allowed in this position yet
4747

compiler/rustc_ast_lowering/src/errors.rs

+18-3
Original file line numberDiff line numberDiff line change
@@ -373,24 +373,39 @@ pub(crate) struct InclusiveRangeWithNoEnd {
373373
pub span: Span,
374374
}
375375

376+
#[derive(Subdiagnostic)]
377+
#[multipart_suggestion(
378+
ast_lowering_bad_return_type_notation_output_suggestion,
379+
applicability = "machine-applicable",
380+
style = "verbose"
381+
)]
382+
/// Given `T: Tr<m() -> Ret>` or `T: Tr<m(Ty) -> Ret>`, suggest `T: Tr<m(..)>`.
383+
pub(crate) struct RTNSuggestion {
384+
#[suggestion_part(code = "")]
385+
pub output: Span,
386+
#[suggestion_part(code = "(..)")]
387+
pub input: Span,
388+
}
389+
376390
#[derive(Diagnostic)]
377391
pub(crate) enum BadReturnTypeNotation {
378392
#[diag(ast_lowering_bad_return_type_notation_inputs)]
379393
Inputs {
380394
#[primary_span]
381-
#[suggestion(code = "()", applicability = "maybe-incorrect")]
395+
#[suggestion(code = "(..)", applicability = "machine-applicable", style = "verbose")]
382396
span: Span,
383397
},
384398
#[diag(ast_lowering_bad_return_type_notation_output)]
385399
Output {
386400
#[primary_span]
387-
#[suggestion(code = "", applicability = "maybe-incorrect")]
388401
span: Span,
402+
#[subdiagnostic]
403+
suggestion: RTNSuggestion,
389404
},
390405
#[diag(ast_lowering_bad_return_type_notation_needs_dots)]
391406
NeedsDots {
392407
#[primary_span]
393-
#[suggestion(code = "(..)", applicability = "maybe-incorrect")]
408+
#[suggestion(code = "(..)", applicability = "machine-applicable", style = "verbose")]
394409
span: Span,
395410
},
396411
#[diag(ast_lowering_bad_return_type_notation_position)]

compiler/rustc_ast_lowering/src/lib.rs

+20-12
Original file line numberDiff line numberDiff line change
@@ -926,19 +926,27 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
926926
if let Some(first_char) = constraint.ident.as_str().chars().next()
927927
&& first_char.is_ascii_lowercase()
928928
{
929-
let mut err = if !data.inputs.is_empty() {
930-
self.dcx().create_err(errors::BadReturnTypeNotation::Inputs {
931-
span: data.inputs_span,
932-
})
933-
} else if let FnRetTy::Ty(ty) = &data.output {
934-
self.dcx().create_err(errors::BadReturnTypeNotation::Output {
935-
span: data.inputs_span.shrink_to_hi().to(ty.span),
936-
})
937-
} else {
938-
self.dcx().create_err(errors::BadReturnTypeNotation::NeedsDots {
939-
span: data.inputs_span,
940-
})
929+
tracing::info!(?data, ?data.inputs);
930+
let err = match (&data.inputs[..], &data.output) {
931+
([_, ..], FnRetTy::Default(_)) => {
932+
errors::BadReturnTypeNotation::Inputs { span: data.inputs_span }
933+
}
934+
([], FnRetTy::Default(_)) => {
935+
errors::BadReturnTypeNotation::NeedsDots { span: data.inputs_span }
936+
}
937+
// The case `T: Trait<method(..) -> Ret>` is handled in the parser.
938+
(_, FnRetTy::Ty(ty)) => {
939+
let span = data.inputs_span.shrink_to_hi().to(ty.span);
940+
errors::BadReturnTypeNotation::Output {
941+
span,
942+
suggestion: errors::RTNSuggestion {
943+
output: span,
944+
input: data.inputs_span,
945+
},
946+
}
947+
}
941948
};
949+
let mut err = self.dcx().create_err(err);
942950
if !self.tcx.features().return_type_notation()
943951
&& self.tcx.sess.is_nightly_build()
944952
{

compiler/rustc_ast_lowering/src/path.rs

+21-13
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use tracing::{debug, instrument};
1313

1414
use super::errors::{
1515
AsyncBoundNotOnTrait, AsyncBoundOnlyForFnTraits, BadReturnTypeNotation,
16-
GenericTypeWithParentheses, UseAngleBrackets,
16+
GenericTypeWithParentheses, RTNSuggestion, UseAngleBrackets,
1717
};
1818
use super::{
1919
AllowReturnTypeNotation, GenericArgsCtor, GenericArgsMode, ImplTraitContext, ImplTraitPosition,
@@ -268,19 +268,27 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
268268
}
269269
GenericArgs::Parenthesized(data) => match generic_args_mode {
270270
GenericArgsMode::ReturnTypeNotation => {
271-
let mut err = if !data.inputs.is_empty() {
272-
self.dcx().create_err(BadReturnTypeNotation::Inputs {
273-
span: data.inputs_span,
274-
})
275-
} else if let FnRetTy::Ty(ty) = &data.output {
276-
self.dcx().create_err(BadReturnTypeNotation::Output {
277-
span: data.inputs_span.shrink_to_hi().to(ty.span),
278-
})
279-
} else {
280-
self.dcx().create_err(BadReturnTypeNotation::NeedsDots {
281-
span: data.inputs_span,
282-
})
271+
tracing::info!(?data, ?data.inputs);
272+
let err = match (&data.inputs[..], &data.output) {
273+
([_, ..], FnRetTy::Default(_)) => {
274+
BadReturnTypeNotation::Inputs { span: data.inputs_span }
275+
}
276+
([], FnRetTy::Default(_)) => {
277+
BadReturnTypeNotation::NeedsDots { span: data.inputs_span }
278+
}
279+
// The case `T: Trait<method(..) -> Ret>` is handled in the parser.
280+
(_, FnRetTy::Ty(ty)) => {
281+
let span = data.inputs_span.shrink_to_hi().to(ty.span);
282+
BadReturnTypeNotation::Output {
283+
span,
284+
suggestion: RTNSuggestion {
285+
output: span,
286+
input: data.inputs_span,
287+
},
288+
}
289+
}
283290
};
291+
let mut err = self.dcx().create_err(err);
284292
if !self.tcx.features().return_type_notation()
285293
&& self.tcx.sess.is_nightly_build()
286294
{

compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
8484
AbiParam::new(scalar_to_clif_type(tcx, scalar)),
8585
attrs
8686
)],
87-
BackendRepr::Vector { .. } => {
87+
BackendRepr::SimdVector { .. } => {
8888
let vector_ty = crate::intrinsics::clif_vector_type(tcx, self.layout);
8989
smallvec![AbiParam::new(vector_ty)]
9090
}
@@ -135,7 +135,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
135135
BackendRepr::Scalar(scalar) => {
136136
(None, vec![AbiParam::new(scalar_to_clif_type(tcx, scalar))])
137137
}
138-
BackendRepr::Vector { .. } => {
138+
BackendRepr::SimdVector { .. } => {
139139
let vector_ty = crate::intrinsics::clif_vector_type(tcx, self.layout);
140140
(None, vec![AbiParam::new(vector_ty)])
141141
}

compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ fn report_atomic_type_validation_error<'tcx>(
5353

5454
pub(crate) fn clif_vector_type<'tcx>(tcx: TyCtxt<'tcx>, layout: TyAndLayout<'tcx>) -> Type {
5555
let (element, count) = match layout.backend_repr {
56-
BackendRepr::Vector { element, count } => (element, count),
56+
BackendRepr::SimdVector { element, count } => (element, count),
5757
_ => unreachable!(),
5858
};
5959

compiler/rustc_codegen_cranelift/src/value_and_place.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,11 @@ impl<'tcx> CValue<'tcx> {
173173
CValueInner::ByRef(ptr, None) => {
174174
let clif_ty = match layout.backend_repr {
175175
BackendRepr::Scalar(scalar) => scalar_to_clif_type(fx.tcx, scalar),
176-
BackendRepr::Vector { element, count } => scalar_to_clif_type(fx.tcx, element)
177-
.by(u32::try_from(count).unwrap())
178-
.unwrap(),
176+
BackendRepr::SimdVector { element, count } => {
177+
scalar_to_clif_type(fx.tcx, element)
178+
.by(u32::try_from(count).unwrap())
179+
.unwrap()
180+
}
179181
_ => unreachable!("{:?}", layout.ty),
180182
};
181183
let mut flags = MemFlags::new();

compiler/rustc_codegen_gcc/src/intrinsic/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
312312
let layout = self.layout_of(tp_ty).layout;
313313
let _use_integer_compare = match layout.backend_repr() {
314314
Scalar(_) | ScalarPair(_, _) => true,
315-
Vector { .. } => false,
315+
SimdVector { .. } => false,
316316
Memory { .. } => {
317317
// For rusty ABIs, small aggregates are actually passed
318318
// as `RegKind::Integer` (see `FnAbi::adjust_for_abi`),

compiler/rustc_codegen_gcc/src/type_of.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn uncached_gcc_type<'gcc, 'tcx>(
6363
) -> Type<'gcc> {
6464
match layout.backend_repr {
6565
BackendRepr::Scalar(_) => bug!("handled elsewhere"),
66-
BackendRepr::Vector { ref element, count } => {
66+
BackendRepr::SimdVector { ref element, count } => {
6767
let element = layout.scalar_gcc_type_at(cx, element, Size::ZERO);
6868
let element =
6969
// NOTE: gcc doesn't allow pointer types in vectors.
@@ -178,17 +178,17 @@ pub trait LayoutGccExt<'tcx> {
178178
impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
179179
fn is_gcc_immediate(&self) -> bool {
180180
match self.backend_repr {
181-
BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => true,
181+
BackendRepr::Scalar(_) | BackendRepr::SimdVector { .. } => true,
182182
BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => false,
183183
}
184184
}
185185

186186
fn is_gcc_scalar_pair(&self) -> bool {
187187
match self.backend_repr {
188188
BackendRepr::ScalarPair(..) => true,
189-
BackendRepr::Scalar(_) | BackendRepr::Vector { .. } | BackendRepr::Memory { .. } => {
190-
false
191-
}
189+
BackendRepr::Scalar(_)
190+
| BackendRepr::SimdVector { .. }
191+
| BackendRepr::Memory { .. } => false,
192192
}
193193
}
194194

0 commit comments

Comments
 (0)