Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
acc8c0b
Reduce usage of FnAbi in codegen_llvm_intrinsic_call
bjorn3 Dec 28, 2025
f1ab003
Don't compute FnAbi for LLVM intrinsics in backends
bjorn3 Jan 8, 2026
fe9715b
Remove support for ScalarPair unadjusted arguments
bjorn3 Jan 8, 2026
d4454e5
add regression test
lcnr Jan 29, 2026
aa7c785
Add note for `?Sized` params in int-ptr casts diag
JohnTitor Feb 5, 2026
3b705ea
Add ui test insufficient-suggestion-issue-141679.rs
xizheyin Feb 9, 2026
ed90b35
Add note when inherent impl for a alias type defined outside of the c…
xizheyin Feb 9, 2026
c9b5c93
Fix passing/returning structs with the 64-bit SPARC ABI
folkertdev Feb 10, 2026
39a5324
prevent incorrect layout error
lcnr Feb 10, 2026
337abba
fix rustdoc test
lcnr Feb 10, 2026
f53eed5
Borrowck: simplify diagnostics for placeholders.
amandasystems Jan 30, 2026
846e4ee
Add FCW for derive helper attributes that will conflict with built-in…
nik-rev Feb 8, 2026
3c5840c
add field representing types
BennoLossin Jan 1, 2026
0de45db
Clarify names of `QueryVTable` functions for "executing" a query
Zalathar Feb 10, 2026
33274e5
Rollup merge of #142415 - xizheyin:141679, r=estebank
Zalathar Feb 11, 2026
54ace8d
Rollup merge of #142680 - beetrees:sparc64-float-struct-abi, r=tgross35
Zalathar Feb 11, 2026
b7d0913
Rollup merge of #146307 - BennoLossin:field-projections, r=oli-obk
Zalathar Feb 11, 2026
6bde56a
Rollup merge of #150768 - bjorn3:llvm_intrinsic_no_fn_abi, r=wesleywiser
Zalathar Feb 11, 2026
b432b13
Rollup merge of #151152 - nik-contrib:helper_attr_builtin, r=chenyukang
Zalathar Feb 11, 2026
95031be
Rollup merge of #151814 - lcnr:silent-layout-error, r=jackh726
Zalathar Feb 11, 2026
aa9b953
Rollup merge of #151863 - amandasystems:streamline-borrow-error-handl…
Zalathar Feb 11, 2026
06d9d3b
Rollup merge of #152159 - JohnTitor:issue-74756, r=estebank
Zalathar Feb 11, 2026
a7a1ae6
Rollup merge of #152434 - Zalathar:call-query, r=nnethercote
Zalathar Feb 11, 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
2 changes: 2 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3431,6 +3431,7 @@ dependencies = [
"rustc_macros",
"rustc_serialize",
"rustc_span",
"serde",
"tracing",
]

Expand Down Expand Up @@ -4250,6 +4251,7 @@ dependencies = [
"rustc_target",
"rustc_thread_pool",
"rustc_type_ir",
"serde",
"smallvec",
"thin-vec",
"tracing",
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_abi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ rustc_index = { path = "../rustc_index", default-features = false }
rustc_macros = { path = "../rustc_macros", optional = true }
rustc_serialize = { path = "../rustc_serialize", optional = true }
rustc_span = { path = "../rustc_span", optional = true }
serde = { version = "1.0.125", features = ["derive"] }
tracing = "0.1"
# tidy-alphabetical-end

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 @@ -35,6 +35,7 @@ impl Reg {

reg_ctor!(f32, Float, 32);
reg_ctor!(f64, Float, 64);
reg_ctor!(f128, Float, 128);
}

impl Reg {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_abi/src/layout/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ rustc_index::newtype_index! {
/// `b` is `FieldIdx(1)` in `VariantIdx(0)`,
/// `d` is `FieldIdx(1)` in `VariantIdx(1)`, and
/// `f` is `FieldIdx(1)` in `VariantIdx(0)`.
#[derive(HashStable_Generic)]
#[derive(HashStable_Generic, serde::Serialize)]
#[encodable]
#[orderable]
pub struct FieldIdx {}
Expand All @@ -57,7 +57,7 @@ rustc_index::newtype_index! {
///
/// `struct`s, `tuples`, and `unions`s are considered to have a single variant
/// with variant index zero, aka [`FIRST_VARIANT`].
#[derive(HashStable_Generic)]
#[derive(HashStable_Generic, serde::Serialize)]
#[encodable]
#[orderable]
pub struct VariantIdx {
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2553,6 +2553,11 @@ pub enum TyKind {
/// Pattern types like `pattern_type!(u32 is 1..=)`, which is the same as `NonZero<u32>`,
/// just as part of the type system.
Pat(Box<Ty>, Box<TyPat>),
/// A `field_of` expression (e.g., `builtin # field_of(Struct, field)`).
///
/// Usually not written directly in user code but indirectly via the macro
/// `core::field::field_of!(...)`.
FieldOf(Box<Ty>, Option<Ident>, Ident),
/// Sometimes we need a dummy value when no error has occurred.
Dummy,
/// Placeholder for a kind that has failed to be defined.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_ast/src/util/classify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ fn type_trailing_braced_mac_call(mut ty: &ast::Ty) -> Option<&ast::MacCall> {
| ast::TyKind::ImplicitSelf
| ast::TyKind::CVarArgs
| ast::TyKind::Pat(..)
| ast::TyKind::FieldOf(..)
| ast::TyKind::Dummy
| ast::TyKind::Err(..) => break None,
}
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1497,6 +1497,14 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
TyKind::Pat(ty, pat) => {
hir::TyKind::Pat(self.lower_ty_alloc(ty, itctx), self.lower_ty_pat(pat, ty.span))
}
TyKind::FieldOf(ty, variant, field) => hir::TyKind::FieldOf(
self.lower_ty_alloc(ty, itctx),
self.arena.alloc(hir::TyFieldPath {
variant: variant.map(|variant| self.lower_ident(variant)),
field: self.lower_ident(*field),
}),
),

TyKind::MacCall(_) => {
span_bug!(t.span, "`TyKind::MacCall` should have been expanded by now")
}
Expand Down
17 changes: 17 additions & 0 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,23 @@ impl<'a> State<'a> {
self.word(" is ");
self.print_ty_pat(pat);
}
ast::TyKind::FieldOf(ty, variant, field) => {
self.word("builtin # field_of");
self.popen();
let ib = self.ibox(0);
self.print_type(ty);
self.word(",");
self.space();

if let Some(variant) = variant {
self.print_ident(*variant);
self.word(".");
}
self.print_ident(*field);

self.end(ib);
self.pclose();
}
}
self.end(ib);
}
Expand Down
10 changes: 10 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/proc_macro_attrs.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use rustc_hir::lints::AttributeLintKind;
use rustc_session::lint::builtin::AMBIGUOUS_DERIVE_HELPERS;

use super::prelude::*;

const PROC_MACRO_ALLOWED_TARGETS: AllowedTargets =
Expand Down Expand Up @@ -126,6 +129,13 @@ fn parse_derive_like<S: Stage>(
cx.expected_identifier(ident.span);
return None;
}
if rustc_feature::is_builtin_attr_name(ident.name) {
cx.emit_lint(
AMBIGUOUS_DERIVE_HELPERS,
AttributeLintKind::AmbiguousDeriveHelpers,
ident.span,
);
}
attributes.push(ident.name);
}
}
Expand Down
32 changes: 15 additions & 17 deletions compiler/rustc_borrowck/src/diagnostics/bound_region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use rustc_traits::{type_op_ascribe_user_type_with_span, type_op_prove_predicate_
use tracing::{debug, instrument};

use crate::MirBorrowckCtxt;
use crate::region_infer::values::RegionElement;
use crate::session_diagnostics::{
HigherRankedErrorCause, HigherRankedLifetimeError, HigherRankedSubtypeError,
};
Expand All @@ -49,11 +48,12 @@ impl<'tcx> UniverseInfo<'tcx> {
UniverseInfo::RelateTys { expected, found }
}

/// Report an error where an element erroneously made its way into `placeholder`.
pub(crate) fn report_erroneous_element(
&self,
mbcx: &mut MirBorrowckCtxt<'_, '_, 'tcx>,
placeholder: ty::PlaceholderRegion<'tcx>,
error_element: RegionElement<'tcx>,
error_element: Option<ty::PlaceholderRegion<'tcx>>,
cause: ObligationCause<'tcx>,
) {
match *self {
Expand Down Expand Up @@ -146,14 +146,14 @@ pub(crate) trait TypeOpInfo<'tcx> {
) -> Option<Diag<'infcx>>;

/// Constraints require that `error_element` appear in the
/// values of `placeholder`, but this cannot be proven to
/// values of `placeholder`, but this cannot be proven to
/// hold. Report an error.
#[instrument(level = "debug", skip(self, mbcx))]
fn report_erroneous_element(
&self,
mbcx: &mut MirBorrowckCtxt<'_, '_, 'tcx>,
placeholder: ty::PlaceholderRegion<'tcx>,
error_element: RegionElement<'tcx>,
error_element: Option<ty::PlaceholderRegion<'tcx>>,
cause: ObligationCause<'tcx>,
) {
let tcx = mbcx.infcx.tcx;
Expand All @@ -172,19 +172,17 @@ pub(crate) trait TypeOpInfo<'tcx> {
ty::PlaceholderRegion::new(adjusted_universe.into(), placeholder.bound),
);

let error_region =
if let RegionElement::PlaceholderRegion(error_placeholder) = error_element {
let adjusted_universe =
error_placeholder.universe.as_u32().checked_sub(base_universe.as_u32());
adjusted_universe.map(|adjusted| {
ty::Region::new_placeholder(
tcx,
ty::PlaceholderRegion::new(adjusted.into(), error_placeholder.bound),
)
})
} else {
None
};
// FIXME: one day this should just be error_element,
// and this method shouldn't do anything.
let error_region = error_element.and_then(|e| {
let adjusted_universe = e.universe.as_u32().checked_sub(base_universe.as_u32());
adjusted_universe.map(|adjusted| {
ty::Region::new_placeholder(
tcx,
ty::PlaceholderRegion::new(adjusted.into(), e.bound),
)
})
});

debug!(?placeholder_region);

Expand Down
73 changes: 43 additions & 30 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ use tracing::{debug, instrument, trace};

use super::{LIMITATION_NOTE, OutlivesSuggestionBuilder, RegionName, RegionNameSource};
use crate::nll::ConstraintDescription;
use crate::region_infer::values::RegionElement;
use crate::region_infer::{BlameConstraint, TypeTest};
use crate::session_diagnostics::{
FnMutError, FnMutReturnTypeErr, GenericDoesNotLiveLongEnough, LifetimeOutliveErr,
Expand Down Expand Up @@ -104,15 +103,9 @@ pub(crate) enum RegionErrorKind<'tcx> {
/// A generic bound failure for a type test (`T: 'a`).
TypeTestError { type_test: TypeTest<'tcx> },

/// Higher-ranked subtyping error.
BoundUniversalRegionError {
/// The placeholder free region.
longer_fr: RegionVid,
/// The region element that erroneously must be outlived by `longer_fr`.
error_element: RegionElement<'tcx>,
/// The placeholder region.
placeholder: ty::PlaceholderRegion<'tcx>,
},
/// 'p outlives 'r, which does not hold. 'p is always a placeholder
/// and 'r is some other region.
PlaceholderOutlivesIllegalRegion { longer_fr: RegionVid, illegally_outlived_r: RegionVid },

/// Any other lifetime error.
RegionError {
Expand Down Expand Up @@ -360,28 +353,11 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
}
}

RegionErrorKind::BoundUniversalRegionError {
RegionErrorKind::PlaceholderOutlivesIllegalRegion {
longer_fr,
placeholder,
error_element,
illegally_outlived_r,
} => {
let error_vid = self.regioncx.region_from_element(longer_fr, &error_element);

// Find the code to blame for the fact that `longer_fr` outlives `error_fr`.
let cause = self
.regioncx
.best_blame_constraint(
longer_fr,
NllRegionVariableOrigin::Placeholder(placeholder),
error_vid,
)
.0
.cause;

let universe = placeholder.universe;
let universe_info = self.regioncx.universe_info(universe);

universe_info.report_erroneous_element(self, placeholder, error_element, cause);
self.report_erroneous_rvid_reaches_placeholder(longer_fr, illegally_outlived_r)
}

RegionErrorKind::RegionError { fr_origin, longer_fr, shorter_fr, is_reported } => {
Expand Down Expand Up @@ -412,6 +388,43 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
outlives_suggestion.add_suggestion(self);
}

/// Report that `longer_fr: error_vid`, which doesn't hold,
/// where `longer_fr` is a placeholder.
fn report_erroneous_rvid_reaches_placeholder(
&mut self,
longer_fr: RegionVid,
error_vid: RegionVid,
) {
use NllRegionVariableOrigin::*;

let origin_longer = self.regioncx.definitions[longer_fr].origin;

let Placeholder(placeholder) = origin_longer else {
bug!("Expected {longer_fr:?} to come from placeholder!");
};

// FIXME: Is throwing away the existential region really the best here?
let error_region = match self.regioncx.definitions[error_vid].origin {
FreeRegion | Existential { .. } => None,
Placeholder(other_placeholder) => Some(other_placeholder),
};

// Find the code to blame for the fact that `longer_fr` outlives `error_fr`.
let cause =
self.regioncx.best_blame_constraint(longer_fr, origin_longer, error_vid).0.cause;

// FIXME these methods should have better names, and also probably not be this generic.
// FIXME note that we *throw away* the error element here! We probably want to
// thread it through the computation further down and use it, but there currently isn't
// anything there to receive it.
self.regioncx.universe_info(placeholder.universe).report_erroneous_element(
self,
placeholder,
error_region,
cause,
);
}

/// Report an error because the universal region `fr` was required to outlive
/// `outlived_fr` but it is not known to do so. For example:
///
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1890,6 +1890,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
| ty::Str
| ty::Array(_, _)
| ty::Pat(_, _)
| ty::FRT(..)
| ty::Slice(_)
| ty::FnDef(_, _)
| ty::FnPtr(..)
Expand Down Expand Up @@ -1934,6 +1935,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, '_, 'tcx> {
| ty::Str
| ty::Array(_, _)
| ty::Pat(_, _)
| ty::FRT(..)
| ty::Slice(_)
| ty::RawPtr(_, _)
| ty::Ref(_, _, _)
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_borrowck/src/region_infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1379,11 +1379,11 @@ impl<'tcx> RegionInferenceContext<'tcx> {
.elements_contained_in(longer_fr_scc)
.find(|e| *e != RegionElement::PlaceholderRegion(placeholder))
{
let illegally_outlived_r = self.region_from_element(longer_fr, &error_element);
// Stop after the first error, it gets too noisy otherwise, and does not provide more information.
errors_buffer.push(RegionErrorKind::BoundUniversalRegionError {
errors_buffer.push(RegionErrorKind::PlaceholderOutlivesIllegalRegion {
longer_fr,
error_element,
placeholder,
illegally_outlived_r,
});
} else {
debug!("check_bound_universal_region: all bounds satisfied");
Expand Down Expand Up @@ -1572,7 +1572,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
}

/// Get the region outlived by `longer_fr` and live at `element`.
pub(crate) fn region_from_element(
fn region_from_element(
&self,
longer_fr: RegionVid,
element: &RegionElement<'tcx>,
Expand Down
19 changes: 8 additions & 11 deletions compiler/rustc_codegen_gcc/src/intrinsic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,18 @@ use rustc_codegen_ssa::traits::{
ArgAbiBuilderMethods, BaseTypeCodegenMethods, BuilderMethods, ConstCodegenMethods,
IntrinsicCallBuilderMethods, LayoutTypeCodegenMethods,
};
use rustc_data_structures::fx::FxHashSet;
use rustc_middle::bug;
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf};
#[cfg(feature = "master")]
use rustc_middle::ty::layout::FnAbiOf;
use rustc_middle::ty::layout::LayoutOf;
use rustc_middle::ty::{self, Instance, Ty};
use rustc_span::{Span, Symbol, sym};
use rustc_target::callconv::{ArgAbi, PassMode};

use crate::abi::{FnAbiGccExt, GccType};
#[cfg(feature = "master")]
use crate::abi::FnAbiGccExt;
use crate::abi::GccType;
use crate::builder::Builder;
use crate::common::{SignType, TypeReflection};
use crate::context::CodegenCx;
Expand Down Expand Up @@ -617,8 +622,6 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
*func
} else {
self.linkage.set(FunctionType::Extern);
let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty());
let fn_ty = fn_abi.gcc_type(self);

let func = match sym {
"llvm.fma.f16" => {
Expand All @@ -631,13 +634,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc

self.intrinsics.borrow_mut().insert(sym.to_string(), func);

self.on_stack_function_params
.borrow_mut()
.insert(func, fn_ty.on_stack_param_indices);
#[cfg(feature = "master")]
for fn_attr in fn_ty.fn_attributes {
func.add_attribute(fn_attr);
}
self.on_stack_function_params.borrow_mut().insert(func, FxHashSet::default());

crate::attributes::from_fn_attrs(self, func, instance);

Expand Down
Loading
Loading