Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 10 pull requests #137855

Merged
merged 21 commits into from
Mar 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c86a7ef
Fully qualify `Result` in generated doctest code
GuillaumeGomez Feb 28, 2025
aac65f5
rename BackendRepr::Vector → SimdVector
RalfJung Feb 28, 2025
cdef388
Use correct error message casing for `io::const_error`s
Noratrieb Feb 28, 2025
2d3639d
tests: adapt for LLVM 21 changes
durin42 Feb 28, 2025
a9ca113
Update query normalizer docs
BoxyUwU Feb 28, 2025
adb5eca
Tweak invalid RTN errors
estebank Feb 28, 2025
4c1f51b
Fix link failure on AVR (incompatible ISA error)
LuigiPiucco Feb 28, 2025
4549266
correct the docs on `simd_` comparison operators
folkertdev Feb 24, 2025
854e9f4
intrinsics::simd: document that masks must be signed integer vectors
folkertdev Feb 28, 2025
340a249
triagebot: only ping me for constck
fee1-dead Mar 1, 2025
2f4b9dd
Update `const_conditions` and `explicit_implied_const_bounds` docs
fee1-dead Mar 1, 2025
3bf9765
Rollup merge of #137804 - RalfJung:backend-repr-simd-vector, r=workin…
matthiaskrgr Mar 1, 2025
643c19c
Rollup merge of #137807 - GuillaumeGomez:doctest-qualify-result, r=no…
matthiaskrgr Mar 1, 2025
bc89ab1
Rollup merge of #137809 - Noratrieb:io-error-casing, r=thomcc
matthiaskrgr Mar 1, 2025
224ea37
Rollup merge of #137818 - durin42:llvm-21-remove-readonly, r=jieyouxu
matthiaskrgr Mar 1, 2025
88e7547
Rollup merge of #137822 - BoxyUwU:query_normalizer_docs, r=compiler-e…
matthiaskrgr Mar 1, 2025
a500a43
Rollup merge of #137824 - estebank:rtn-sugg, r=compiler-errors
matthiaskrgr Mar 1, 2025
c112b70
Rollup merge of #137828 - folkertdev:simd-intrinsic-doc-fixes, r=work…
matthiaskrgr Mar 1, 2025
878f383
Rollup merge of #137830 - LuigiPiucco:incompatible-isa-fix, r=working…
matthiaskrgr Mar 1, 2025
935535d
Rollup merge of #137837 - fee1-dead-contrib:push-pvqvwuvrnwsy, r=comp…
matthiaskrgr Mar 1, 2025
5bdde89
Rollup merge of #137840 - fee1-dead-contrib:push-uwkzouvnrnvs, r=oli-obk
matthiaskrgr Mar 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_abi/src/callconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
Ok(HomogeneousAggregate::Homogeneous(Reg { kind, size: self.size }))
}

BackendRepr::Vector { .. } => {
BackendRepr::SimdVector { .. } => {
assert!(!self.is_zst());
Ok(HomogeneousAggregate::Homogeneous(Reg {
kind: RegKind::Vector,
Expand Down
12 changes: 8 additions & 4 deletions compiler/rustc_abi/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,13 +386,15 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
BackendRepr::Memory { sized: true }
}
// Vectors require at least element alignment, else disable the opt
BackendRepr::Vector { element, count: _ } if element.align(dl).abi > align.abi => {
BackendRepr::SimdVector { element, count: _ }
if element.align(dl).abi > align.abi =>
{
BackendRepr::Memory { sized: true }
}
// the alignment tests passed and we can use this
BackendRepr::Scalar(..)
| BackendRepr::ScalarPair(..)
| BackendRepr::Vector { .. }
| BackendRepr::SimdVector { .. }
| BackendRepr::Memory { .. } => repr,
},
};
Expand Down Expand Up @@ -464,7 +466,7 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
hide_niches(a);
hide_niches(b);
}
BackendRepr::Vector { element, count: _ } => hide_niches(element),
BackendRepr::SimdVector { element, count: _ } => hide_niches(element),
BackendRepr::Memory { sized: _ } => {}
}
st.largest_niche = None;
Expand Down Expand Up @@ -1314,7 +1316,9 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
match field.backend_repr {
// For plain scalars, or vectors of them, we can't unpack
// newtypes for `#[repr(C)]`, as that affects C ABIs.
BackendRepr::Scalar(_) | BackendRepr::Vector { .. } if optimize_abi => {
BackendRepr::Scalar(_) | BackendRepr::SimdVector { .. }
if optimize_abi =>
{
abi = field.backend_repr;
}
// But scalar pairs are Rust-specific and get
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_abi/src/layout/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
C: HasDataLayout,
{
match self.backend_repr {
BackendRepr::Vector { .. } => self.size == expected_size,
BackendRepr::SimdVector { .. } => self.size == expected_size,
BackendRepr::Memory { .. } => {
if self.fields.count() == 1 && self.fields.offset(0).bytes() == 0 {
self.field(cx, 0).is_single_vector_element(cx, expected_size)
Expand Down
28 changes: 14 additions & 14 deletions compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ impl AddressSpace {
pub enum BackendRepr {
Scalar(Scalar),
ScalarPair(Scalar, Scalar),
Vector {
SimdVector {
element: Scalar,
count: u64,
},
Expand All @@ -1426,9 +1426,9 @@ impl BackendRepr {
#[inline]
pub fn is_unsized(&self) -> bool {
match *self {
BackendRepr::Scalar(_) | BackendRepr::ScalarPair(..) | BackendRepr::Vector { .. } => {
false
}
BackendRepr::Scalar(_)
| BackendRepr::ScalarPair(..)
| BackendRepr::SimdVector { .. } => false,
BackendRepr::Memory { sized } => !sized,
}
}
Expand Down Expand Up @@ -1467,7 +1467,7 @@ impl BackendRepr {
BackendRepr::Scalar(s) => Some(s.align(cx).abi),
BackendRepr::ScalarPair(s1, s2) => Some(s1.align(cx).max(s2.align(cx)).abi),
// The align of a Vector can vary in surprising ways
BackendRepr::Vector { .. } | BackendRepr::Memory { .. } => None,
BackendRepr::SimdVector { .. } | BackendRepr::Memory { .. } => None,
}
}

Expand All @@ -1489,7 +1489,7 @@ impl BackendRepr {
Some(size)
}
// The size of a Vector can vary in surprising ways
BackendRepr::Vector { .. } | BackendRepr::Memory { .. } => None,
BackendRepr::SimdVector { .. } | BackendRepr::Memory { .. } => None,
}
}

Expand All @@ -1500,8 +1500,8 @@ impl BackendRepr {
BackendRepr::ScalarPair(s1, s2) => {
BackendRepr::ScalarPair(s1.to_union(), s2.to_union())
}
BackendRepr::Vector { element, count } => {
BackendRepr::Vector { element: element.to_union(), count }
BackendRepr::SimdVector { element, count } => {
BackendRepr::SimdVector { element: element.to_union(), count }
}
BackendRepr::Memory { .. } => BackendRepr::Memory { sized: true },
}
Expand All @@ -1513,8 +1513,8 @@ impl BackendRepr {
// We do *not* ignore the sign since it matters for some ABIs (e.g. s390x).
(BackendRepr::Scalar(l), BackendRepr::Scalar(r)) => l.primitive() == r.primitive(),
(
BackendRepr::Vector { element: element_l, count: count_l },
BackendRepr::Vector { element: element_r, count: count_r },
BackendRepr::SimdVector { element: element_l, count: count_l },
BackendRepr::SimdVector { element: element_r, count: count_r },
) => element_l.primitive() == element_r.primitive() && count_l == count_r,
(BackendRepr::ScalarPair(l1, l2), BackendRepr::ScalarPair(r1, r2)) => {
l1.primitive() == r1.primitive() && l2.primitive() == r2.primitive()
Expand Down Expand Up @@ -1735,7 +1735,7 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
/// Returns `true` if this is an aggregate type (including a ScalarPair!)
pub fn is_aggregate(&self) -> bool {
match self.backend_repr {
BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => false,
BackendRepr::Scalar(_) | BackendRepr::SimdVector { .. } => false,
BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => true,
}
}
Expand Down Expand Up @@ -1877,9 +1877,9 @@ impl<FieldIdx: Idx, VariantIdx: Idx> LayoutData<FieldIdx, VariantIdx> {
/// non-trivial alignment constraints. You probably want to use `is_1zst` instead.
pub fn is_zst(&self) -> bool {
match self.backend_repr {
BackendRepr::Scalar(_) | BackendRepr::ScalarPair(..) | BackendRepr::Vector { .. } => {
false
}
BackendRepr::Scalar(_)
| BackendRepr::ScalarPair(..)
| BackendRepr::SimdVector { .. } => false,
BackendRepr::Memory { sized } => sized && self.size.bytes() == 0,
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ ast_lowering_bad_return_type_notation_inputs =
.suggestion = remove the input types

ast_lowering_bad_return_type_notation_needs_dots = return type notation arguments must be elided with `..`
.suggestion = add `..`
.suggestion = use the correct syntax by adding `..` to the arguments

ast_lowering_bad_return_type_notation_output =
return type not allowed with return type notation
.suggestion = remove the return type
ast_lowering_bad_return_type_notation_output_suggestion = use the right argument notation and remove the return type

ast_lowering_bad_return_type_notation_position = return type notation not allowed in this position yet

Expand Down
21 changes: 18 additions & 3 deletions compiler/rustc_ast_lowering/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,24 +373,39 @@ pub(crate) struct InclusiveRangeWithNoEnd {
pub span: Span,
}

#[derive(Subdiagnostic)]
#[multipart_suggestion(
ast_lowering_bad_return_type_notation_output_suggestion,
applicability = "machine-applicable",
style = "verbose"
)]
/// Given `T: Tr<m() -> Ret>` or `T: Tr<m(Ty) -> Ret>`, suggest `T: Tr<m(..)>`.
pub(crate) struct RTNSuggestion {
#[suggestion_part(code = "")]
pub output: Span,
#[suggestion_part(code = "(..)")]
pub input: Span,
}

#[derive(Diagnostic)]
pub(crate) enum BadReturnTypeNotation {
#[diag(ast_lowering_bad_return_type_notation_inputs)]
Inputs {
#[primary_span]
#[suggestion(code = "()", applicability = "maybe-incorrect")]
#[suggestion(code = "(..)", applicability = "machine-applicable", style = "verbose")]
span: Span,
},
#[diag(ast_lowering_bad_return_type_notation_output)]
Output {
#[primary_span]
#[suggestion(code = "", applicability = "maybe-incorrect")]
span: Span,
#[subdiagnostic]
suggestion: RTNSuggestion,
},
#[diag(ast_lowering_bad_return_type_notation_needs_dots)]
NeedsDots {
#[primary_span]
#[suggestion(code = "(..)", applicability = "maybe-incorrect")]
#[suggestion(code = "(..)", applicability = "machine-applicable", style = "verbose")]
span: Span,
},
#[diag(ast_lowering_bad_return_type_notation_position)]
Expand Down
32 changes: 20 additions & 12 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,19 +926,27 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
if let Some(first_char) = constraint.ident.as_str().chars().next()
&& first_char.is_ascii_lowercase()
{
let mut err = if !data.inputs.is_empty() {
self.dcx().create_err(errors::BadReturnTypeNotation::Inputs {
span: data.inputs_span,
})
} else if let FnRetTy::Ty(ty) = &data.output {
self.dcx().create_err(errors::BadReturnTypeNotation::Output {
span: data.inputs_span.shrink_to_hi().to(ty.span),
})
} else {
self.dcx().create_err(errors::BadReturnTypeNotation::NeedsDots {
span: data.inputs_span,
})
tracing::info!(?data, ?data.inputs);
let err = match (&data.inputs[..], &data.output) {
([_, ..], FnRetTy::Default(_)) => {
errors::BadReturnTypeNotation::Inputs { span: data.inputs_span }
}
([], FnRetTy::Default(_)) => {
errors::BadReturnTypeNotation::NeedsDots { span: data.inputs_span }
}
// The case `T: Trait<method(..) -> Ret>` is handled in the parser.
(_, FnRetTy::Ty(ty)) => {
let span = data.inputs_span.shrink_to_hi().to(ty.span);
errors::BadReturnTypeNotation::Output {
span,
suggestion: errors::RTNSuggestion {
output: span,
input: data.inputs_span,
},
}
}
};
let mut err = self.dcx().create_err(err);
if !self.tcx.features().return_type_notation()
&& self.tcx.sess.is_nightly_build()
{
Expand Down
34 changes: 21 additions & 13 deletions compiler/rustc_ast_lowering/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tracing::{debug, instrument};

use super::errors::{
AsyncBoundNotOnTrait, AsyncBoundOnlyForFnTraits, BadReturnTypeNotation,
GenericTypeWithParentheses, UseAngleBrackets,
GenericTypeWithParentheses, RTNSuggestion, UseAngleBrackets,
};
use super::{
AllowReturnTypeNotation, GenericArgsCtor, GenericArgsMode, ImplTraitContext, ImplTraitPosition,
Expand Down Expand Up @@ -268,19 +268,27 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
}
GenericArgs::Parenthesized(data) => match generic_args_mode {
GenericArgsMode::ReturnTypeNotation => {
let mut err = if !data.inputs.is_empty() {
self.dcx().create_err(BadReturnTypeNotation::Inputs {
span: data.inputs_span,
})
} else if let FnRetTy::Ty(ty) = &data.output {
self.dcx().create_err(BadReturnTypeNotation::Output {
span: data.inputs_span.shrink_to_hi().to(ty.span),
})
} else {
self.dcx().create_err(BadReturnTypeNotation::NeedsDots {
span: data.inputs_span,
})
tracing::info!(?data, ?data.inputs);
let err = match (&data.inputs[..], &data.output) {
([_, ..], FnRetTy::Default(_)) => {
BadReturnTypeNotation::Inputs { span: data.inputs_span }
}
([], FnRetTy::Default(_)) => {
BadReturnTypeNotation::NeedsDots { span: data.inputs_span }
}
// The case `T: Trait<method(..) -> Ret>` is handled in the parser.
(_, FnRetTy::Ty(ty)) => {
let span = data.inputs_span.shrink_to_hi().to(ty.span);
BadReturnTypeNotation::Output {
span,
suggestion: RTNSuggestion {
output: span,
input: data.inputs_span,
},
}
}
};
let mut err = self.dcx().create_err(err);
if !self.tcx.features().return_type_notation()
&& self.tcx.sess.is_nightly_build()
{
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
AbiParam::new(scalar_to_clif_type(tcx, scalar)),
attrs
)],
BackendRepr::Vector { .. } => {
BackendRepr::SimdVector { .. } => {
let vector_ty = crate::intrinsics::clif_vector_type(tcx, self.layout);
smallvec![AbiParam::new(vector_ty)]
}
Expand Down Expand Up @@ -135,7 +135,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
BackendRepr::Scalar(scalar) => {
(None, vec![AbiParam::new(scalar_to_clif_type(tcx, scalar))])
}
BackendRepr::Vector { .. } => {
BackendRepr::SimdVector { .. } => {
let vector_ty = crate::intrinsics::clif_vector_type(tcx, self.layout);
(None, vec![AbiParam::new(vector_ty)])
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn report_atomic_type_validation_error<'tcx>(

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

Expand Down
8 changes: 5 additions & 3 deletions compiler/rustc_codegen_cranelift/src/value_and_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,11 @@ impl<'tcx> CValue<'tcx> {
CValueInner::ByRef(ptr, None) => {
let clif_ty = match layout.backend_repr {
BackendRepr::Scalar(scalar) => scalar_to_clif_type(fx.tcx, scalar),
BackendRepr::Vector { element, count } => scalar_to_clif_type(fx.tcx, element)
.by(u32::try_from(count).unwrap())
.unwrap(),
BackendRepr::SimdVector { element, count } => {
scalar_to_clif_type(fx.tcx, element)
.by(u32::try_from(count).unwrap())
.unwrap()
}
_ => unreachable!("{:?}", layout.ty),
};
let mut flags = MemFlags::new();
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/intrinsic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
let layout = self.layout_of(tp_ty).layout;
let _use_integer_compare = match layout.backend_repr() {
Scalar(_) | ScalarPair(_, _) => true,
Vector { .. } => false,
SimdVector { .. } => false,
Memory { .. } => {
// For rusty ABIs, small aggregates are actually passed
// as `RegKind::Integer` (see `FnAbi::adjust_for_abi`),
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_codegen_gcc/src/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn uncached_gcc_type<'gcc, 'tcx>(
) -> Type<'gcc> {
match layout.backend_repr {
BackendRepr::Scalar(_) => bug!("handled elsewhere"),
BackendRepr::Vector { ref element, count } => {
BackendRepr::SimdVector { ref element, count } => {
let element = layout.scalar_gcc_type_at(cx, element, Size::ZERO);
let element =
// NOTE: gcc doesn't allow pointer types in vectors.
Expand Down Expand Up @@ -178,17 +178,17 @@ pub trait LayoutGccExt<'tcx> {
impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
fn is_gcc_immediate(&self) -> bool {
match self.backend_repr {
BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => true,
BackendRepr::Scalar(_) | BackendRepr::SimdVector { .. } => true,
BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => false,
}
}

fn is_gcc_scalar_pair(&self) -> bool {
match self.backend_repr {
BackendRepr::ScalarPair(..) => true,
BackendRepr::Scalar(_) | BackendRepr::Vector { .. } | BackendRepr::Memory { .. } => {
false
}
BackendRepr::Scalar(_)
| BackendRepr::SimdVector { .. }
| BackendRepr::Memory { .. } => false,
}
}

Expand Down
Loading
Loading