Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0c8e360
RISC-V: Add zmmul target feature
TechnoPorg Sep 9, 2026
7a6e24a
Document interaction between "m" and "zmmul"
TechnoPorg Sep 10, 2026
d609aff
Tweak wording of comment in target_features.rs
TechnoPorg Sep 11, 2026
a33e6eb
Address review comments
TechnoPorg Sep 11, 2026
aadf13c
add `non_zst_field` helper
folkertdev Sep 13, 2026
ee524a2
fix `is_single_fp_element` for `s390x` and `x86`
folkertdev Aug 29, 2026
33871b9
abi/compatibility test: add simple float type tests
RalfJung Aug 29, 2026
5dd4631
rustc_{codegen_,}llvm: adapt to new ThreadModel API
durin42 Sep 15, 2026
3c283d4
Copy metadata workproduct when session dir rename fails
TheHighestBit Sep 6, 2026
26e7e77
Gate finalize_session_directory rename fallbacks to windows
TheHighestBit Sep 9, 2026
b4beb1e
Pass File to Fallback::lock
bjorn3 Sep 16, 2026
0143ce1
Have a separate copy of the flock code for rustdoc
bjorn3 Sep 16, 2026
435b07d
Remove wait argument from Lock::new
bjorn3 Sep 10, 2026
de50895
Introduce a global lock registry for the fcntl lock fallback
bjorn3 Sep 10, 2026
0bae8cf
Move metadata work product name into a constant
TheHighestBit Sep 15, 2026
4138d02
Remove redundant "add bound" help messages
nnethercote Sep 17, 2026
82ddf4c
Change "the following changes may resolve your lifetime errors" diagn…
nnethercote Sep 17, 2026
31fafe3
Clarify `Level::{Help,Note,FailureNote}` details
nnethercote Sep 17, 2026
6d008f3
libm: Avoid `debug_assert_eq!` if `feature = "compiler-builtins"`
tgross35 Sep 17, 2026
362d116
c-b: Export `fmaf16` now that we have an implementation
tgross35 Sep 10, 2026
db58d50
`f16b` Implementation and documentation
Jamesbarford Sep 17, 2026
ef2c67f
Add `F16B` to `Float` enum & wireup trivial matches
Jamesbarford Sep 17, 2026
ddab56a
Wire up f16b in backends
Jamesbarford Sep 17, 2026
dcf9ab4
Update Tidy rules to allow for `//@ revision`
Jamesbarford Sep 17, 2026
4ff2c1d
Update and write tests
Jamesbarford Sep 17, 2026
2be177e
Use HashMap::entry
bjorn3 Sep 17, 2026
3c8dcac
Add regression tests for derive suggestions on generated enums
chenyukang Sep 10, 2026
4a1b4b0
Avoid derive edits on macro-generated types
chenyukang Sep 10, 2026
9600948
Error on invalid uses of the `cfi_encoding` attribute.
mejrs Sep 17, 2026
4173f8d
Rollup merge of #160859 - Jamesbarford:feat/fb16-pt1, r=folkertdev,tg…
JonathanBrouwer Sep 17, 2026
0711e4e
Rollup merge of #161987 - folkertdev:single-fp-element, r=beetrees
JonathanBrouwer Sep 17, 2026
9a26526
Rollup merge of #162366 - TheHighestBit:copy-on-finalize-error, r=bjorn3
JonathanBrouwer Sep 17, 2026
f5e8760
Rollup merge of #162552 - TechnoPorg:riscv-feature-zmmul, r=beetrees
JonathanBrouwer Sep 17, 2026
e17eab5
Rollup merge of #162602 - bjorn3:safer_fcntl_fallback, r=oli-obk
JonathanBrouwer Sep 17, 2026
e700d09
Rollup merge of #162885 - nnethercote:rm-Level-Help, r=estebank
JonathanBrouwer Sep 17, 2026
295dc73
Rollup merge of #162606 - tgross35:fmaf16-fallback, r=folkertdev
JonathanBrouwer Sep 17, 2026
3e2eae3
Rollup merge of #162817 - durin42:llvm-24-thread-model, r=nikic
JonathanBrouwer Sep 17, 2026
9273f2e
Rollup merge of #162895 - chenyukang:yukang-fix-148207-generated-deri…
JonathanBrouwer Sep 17, 2026
9edabb4
Rollup merge of #162899 - mejrs:cfi_encoding, r=JonathanBrouwer
JonathanBrouwer Sep 17, 2026
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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5055,6 +5055,7 @@ dependencies = [
"expect-test",
"indexmap",
"itertools",
"libc",
"minifier",
"proc-macro2",
"pulldown-cmark-escape",
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_abi/src/callconv/reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl Reg {
reg_ctor!(i64, Integer, 64);
reg_ctor!(i128, Integer, 128);

reg_ctor!(f16, Float, 16);
reg_ctor!(f32, Float, 32);
reg_ctor!(f64, Float, 64);
reg_ctor!(f128, Float, 128);
Expand Down
45 changes: 24 additions & 21 deletions compiler/rustc_abi/src/layout/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,26 +156,6 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
Ty::ty_and_layout_pointee_info_at(self, cx, offset)
}

pub fn is_single_fp_element<C>(self, cx: &C) -> bool
where
Ty: TyAbiInterface<'a, C>,
C: HasDataLayout,
{
match self.backend_repr {
BackendRepr::Scalar(scalar) => {
matches!(scalar.primitive(), Primitive::Float(Float::F32 | Float::F64))
}
BackendRepr::Memory { .. } => {
if self.fields.count() == 1 && self.fields.offset(0).bytes() == 0 {
self.field(cx, 0).is_single_fp_element(cx)
} else {
false
}
}
_ => false,
}
}

pub fn is_single_vector_element<C>(self, cx: &C, expected_size: Size) -> bool
where
Ty: TyAbiInterface<'a, C>,
Expand Down Expand Up @@ -309,6 +289,29 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
found
}

/// Finds the one field that is not a ZST.
/// Returns `None` if there are multiple non-ZST fields or only ZST-fields.
///
/// Note that this function checks for ZSTs, not just 1-ZSTs.
pub fn non_zst_field_ignore_alignment<C>(&self, cx: &C) -> Option<(FieldIdx, Self)>
where
Ty: TyAbiInterface<'a, C> + Copy,
{
let mut found = None;
for field_idx in 0..self.fields.count() {
let field = self.field(cx, field_idx);
if field.is_zst() {
continue;
}
if found.is_some() {
// More than one non-ZST field.
return None;
}
found = Some((FieldIdx::from_usize(field_idx), field));
}
found
}

/// If this type should match the ABI of the C `_Complex` type, returns the primitive that is
/// used for its components.
///
Expand Down Expand Up @@ -339,7 +342,7 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
Primitive::Float(float @ (Float::F16 | Float::F32 | Float::F64 | Float::F128)) => {
Some(Numeric::Float(float))
}
Primitive::Pointer(..) => None,
Primitive::Pointer(..) | Primitive::Float(Float::F16B) => None,
}
}

Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,10 @@ impl Integer {
#[cfg_attr(feature = "nightly", derive(StableHash))]
pub enum Float {
F16,
/// `f16b`. This is not a builtin type in Rust (it is exposed as a lang item),
/// but it is a builtin type in LLVM so needs to be explicitly represented
/// in the backend.
F16B,
F32,
F64,
F128,
Expand All @@ -1431,6 +1435,7 @@ impl Float {

match self {
F16 => Size::from_bits(16),
F16B => Size::from_bits(16),
F32 => Size::from_bits(32),
F64 => Size::from_bits(64),
F128 => Size::from_bits(128),
Expand All @@ -1442,7 +1447,7 @@ impl Float {
let dl = cx.data_layout();

AbiAlign::new(match self {
F16 => dl.f16_align,
F16 | F16B => dl.f16_align,
F32 => dl.f32_align,
F64 => dl.f64_align,
F128 => dl.f128_align,
Expand All @@ -1454,6 +1459,7 @@ impl Float {

match self {
F16 => "f16",
F16B => "f16b",
F32 => "f32",
F64 => "f64",
F128 => "f128",
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_attr_ir/src/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ language_item_table! {
PartialEq, sym::eq, eq_trait, Target::Trait, GenericRequirement::Exact(1);
PartialOrd, sym::partial_ord, partial_ord_trait, Target::Trait, GenericRequirement::Exact(1);
CVoid, sym::c_void, c_void, Target::Enum, GenericRequirement::None;
F16B, sym::f16b, f16b, Target::Struct, GenericRequirement::Exact(0);

Type, sym::type_info, type_struct, Target::Struct, GenericRequirement::None;
TypeGeneric, sym::type_info_generic, type_generic, Target::Enum, GenericRequirement::None;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_attr_parsing/src/attributes/cfi_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::prelude::*;
pub(crate) struct CfiEncodingParser;
impl SingleAttributeParser for CfiEncodingParser {
const PATH: &[Symbol] = &[sym::cfi_encoding];
const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowListWarnRest(&[
const ALLOWED_TARGETS: AllowedTargets<'_> = AllowedTargets::AllowList(&[
Allow(Target::Struct),
Allow(Target::ForeignTy),
Allow(Target::Enum),
Expand Down
38 changes: 6 additions & 32 deletions compiler/rustc_borrowck/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,6 @@ pub(super) struct DescribePlaceOpt {

pub(super) struct IncludingTupleField(pub(super) bool);

pub(crate) enum BufferedDiag<'diag> {
Error(Diag<'diag>),
NonError(Diag<'diag, ()>),
}

impl<'diag> BufferedDiag<'diag> {
fn sort_span(&self) -> Span {
match self {
BufferedDiag::Error(diag) => diag.sort_span,
BufferedDiag::NonError(diag) => diag.sort_span,
}
}
}

#[derive(Default)]
pub(crate) struct BorrowckDiagnosticsBuffer<'diag, 'tcx> {
/// This field keeps track of move errors that are to be reported for given move indices.
Expand All @@ -108,16 +94,13 @@ pub(crate) struct BorrowckDiagnosticsBuffer<'diag, 'tcx> {

buffered_mut_errors: FxIndexMap<Span, (Diag<'diag>, usize)>,

/// Buffer of diagnostics to be reported. A mixture of error and non-error diagnostics.
buffered_diags: Vec<BufferedDiag<'diag>>,
/// Buffer of diagnostics to be reported.
buffered_diags: Vec<Diag<'diag>>,
}

impl<'diag, 'tcx> BorrowckDiagnosticsBuffer<'diag, 'tcx> {
pub(crate) fn buffer_non_error(&mut self, diag: Diag<'diag, ()>) {
self.buffered_diags.push(BufferedDiag::NonError(diag));
}
pub(crate) fn buffer_error(&mut self, diag: Diag<'diag>) {
self.buffered_diags.push(BufferedDiag::Error(diag));
self.buffered_diags.push(diag);
}

pub(crate) fn emit_errors(&mut self) {
Expand All @@ -134,14 +117,9 @@ impl<'diag, 'tcx> BorrowckDiagnosticsBuffer<'diag, 'tcx> {
}

if !self.buffered_diags.is_empty() {
self.buffered_diags.sort_by_key(|buffered_diag| buffered_diag.sort_span());
for buffered_diag in self.buffered_diags.drain(..) {
match buffered_diag {
BufferedDiag::Error(diag) => {
diag.emit();
}
BufferedDiag::NonError(diag) => diag.emit(),
}
self.buffered_diags.sort_by_key(|diag| diag.sort_span);
for diag in self.buffered_diags.drain(..) {
diag.emit();
}
}
}
Expand All @@ -152,10 +130,6 @@ impl<'diag, 'tcx> MirBorrowckCtxt<'_, 'diag, 'tcx> {
self.diags_buffer.buffer_error(diag.with_dcx(self.dcx()));
}

pub(crate) fn buffer_non_error(&mut self, diag: Diag<'_, ()>) {
self.diags_buffer.buffer_non_error(diag.with_dcx(self.dcx()));
}

pub(crate) fn buffer_move_error(
&mut self,
move_out_indices: Vec<MoveOutIndex>,
Expand Down
79 changes: 26 additions & 53 deletions compiler/rustc_borrowck/src/diagnostics/outlives_suggestion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ use crate::MirBorrowckCtxt;

/// The different things we could suggest.
enum SuggestedConstraint {
/// Outlives(a, [b, c, d, ...]) => 'a: 'b + 'c + 'd + ...
Outlives(RegionName, SmallVec<[RegionName; 2]>),

/// 'a = 'b
Equal(RegionName, RegionName),

Expand Down Expand Up @@ -106,11 +103,10 @@ impl OutlivesSuggestionBuilder {
continue;
}

// There are three types of suggestions we can make:
// 1) Suggest a bound: 'a: 'b
// 2) Suggest replacing 'a with 'static. If any of `outlived` is `'static`, then we
// There are two types of suggestions we can make:
// 1) Suggest replacing 'a with 'static. If any of `outlived` is `'static`, then we
// should just replace 'a with 'static.
// 3) Suggest unifying 'a with 'b if we have both 'a: 'b and 'b: 'a
// 2) Suggest unifying 'a with 'b if we have both 'a: 'b and 'b: 'a

if outlived
.iter()
Expand All @@ -121,7 +117,7 @@ impl OutlivesSuggestionBuilder {
// We want to isolate out all lifetimes that should be unified and print out
// separate messages for them.

let (unified, other): (Vec<_>, Vec<_>) = outlived.into_iter().partition(
let unified = outlived.into_iter().filter(
// Do we have both 'fr: 'r and 'r: 'fr?
|(r, _)| {
self.constraints_to_add
Expand All @@ -130,17 +126,12 @@ impl OutlivesSuggestionBuilder {
},
);

for (r, bound) in unified.into_iter() {
for (r, bound) in unified {
if !unified_already.contains(fr) {
suggested.push(SuggestedConstraint::Equal(fr_name, bound));
unified_already.insert(r);
}
}

if !other.is_empty() {
let other = other.iter().map(|(_, rname)| *rname).collect::<SmallVec<_>>();
suggested.push(SuggestedConstraint::Outlives(fr_name, other))
}
}
}

Expand Down Expand Up @@ -202,54 +193,36 @@ impl OutlivesSuggestionBuilder {
return;
}

// If there is exactly one suggestable constraints, then just suggest it. Otherwise, emit a
// list of diagnostics.
let mut diag = if let [constraint] = suggested.as_slice() {
mbcx.dcx().struct_help(match constraint {
SuggestedConstraint::Outlives(a, bs) => {
let bs: SmallVec<[String; 2]> = bs.iter().map(|r| r.to_string()).collect();
format!("add bound `{a}: {}`", bs.join(" + "))
}

// Emit an error with a list of one or more help suggestions. This is a weird error because
// it's just there to provide somewhere to put the help suggestions that describe how to
// fix the one or more borrow errors already reported within the item.
let tcx = mbcx.infcx.tcx;
let def_id = mbcx.mir_def_id();
let span = tcx.def_ident_span(def_id).unwrap_or_else(|| tcx.def_span(def_id));
let mut diag = tcx
.dcx()
.struct_err("one or more lifetime errors were found in this item")
.with_span(span);

// Add suggestions.
for constraint in suggested {
match constraint {
SuggestedConstraint::Equal(a, b) => {
format!("`{a}` and `{b}` must be the same: replace one with the other")
diag.help(format!(
"`{a}` and `{b}` must be the same: replace one with the other",
));
}
SuggestedConstraint::Static(a) => format!("replace `{a}` with `'static`"),
})
} else {
// Create a new diagnostic.
let mut diag = mbcx
.infcx
.tcx
.dcx()
.struct_help("the following changes may resolve your lifetime errors");

// Add suggestions.
for constraint in suggested {
match constraint {
SuggestedConstraint::Outlives(a, bs) => {
let bs: SmallVec<[String; 2]> = bs.iter().map(|r| r.to_string()).collect();
diag.help(format!("add bound `{a}: {}`", bs.join(" + ")));
}
SuggestedConstraint::Equal(a, b) => {
diag.help(format!(
"`{a}` and `{b}` must be the same: replace one with the other",
));
}
SuggestedConstraint::Static(a) => {
diag.help(format!("replace `{a}` with `'static`"));
}
SuggestedConstraint::Static(a) => {
diag.help(format!("replace `{a}` with `'static`"));
}
}

diag
};
}

// We want this message to appear after other messages on the mir def.
let mir_span = mbcx.body.span;
diag.sort_span = mir_span.shrink_to_hi();

// Buffer the diagnostic
mbcx.buffer_non_error(diag);
mbcx.buffer_error(diag);
}
}
1 change: 1 addition & 0 deletions compiler/rustc_codegen_cranelift/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub(crate) fn scalar_to_clif_type(tcx: TyCtxt<'_>, scalar: Scalar) -> Type {
},
Primitive::Float(float) => match float {
Float::F16 => types::F16,
Float::F16B => bug!("f16b is not supported by the Cranelift codegen backend"),
Float::F32 => types::F32,
Float::F64 => types::F64,
Float::F128 => types::F128,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_cranelift/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
// available in Cranelift.
has_reliable_f16: has_reliable_f16_f128,
has_reliable_f16_math: has_reliable_f16_f128,
has_reliable_f16b: false,
has_reliable_f128: has_reliable_f16_f128,
has_reliable_f128_math,
}
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_gcc/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ pub fn compile_codegen_unit(
// -fsyntax-only), forbid the compilation when get_target_info() is called on a
// context.
let f16_type_supported = target_info.supports_target_dependent_type(CType::Float16);
let f16b_type_supported = target_info.supports_target_dependent_type(CType::BFloat16);
let f32_type_supported = target_info.supports_target_dependent_type(CType::Float32);
let f64_type_supported = target_info.supports_target_dependent_type(CType::Float64);
let f128_type_supported = target_info.supports_target_dependent_type(CType::Float128);
Expand All @@ -225,6 +226,7 @@ pub fn compile_codegen_unit(
tcx,
u128_type_supported,
f16_type_supported,
f16b_type_supported,
f32_type_supported,
f64_type_supported,
f128_type_supported,
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_codegen_gcc/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pub struct CodegenCx<'gcc, 'tcx> {

pub supports_128bit_integers: bool,
pub supports_f16_type: bool,
pub supports_f16b_type: bool,
pub supports_f32_type: bool,
pub supports_f64_type: bool,
pub supports_f128_type: bool,
Expand Down Expand Up @@ -140,6 +141,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
tcx: TyCtxt<'tcx>,
supports_128bit_integers: bool,
supports_f16_type: bool,
supports_f16b_type: bool,
supports_f32_type: bool,
supports_f64_type: bool,
supports_f128_type: bool,
Expand Down Expand Up @@ -276,6 +278,7 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {

supports_128bit_integers,
supports_f16_type,
supports_f16b_type,
supports_f32_type,
supports_f64_type,
supports_f128_type,
Expand Down
Loading
Loading