Skip to content
Closed
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
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
0de45db
Clarify names of `QueryVTable` functions for "executing" a query
Zalathar Feb 10, 2026
2a81d8c
Rollup merge of #142415 - xizheyin:141679, r=estebank
Zalathar Feb 11, 2026
c252411
Rollup merge of #142680 - beetrees:sparc64-float-struct-abi, r=tgross35
Zalathar Feb 11, 2026
8890d4e
Rollup merge of #150768 - bjorn3:llvm_intrinsic_no_fn_abi, r=wesleywiser
Zalathar Feb 11, 2026
cde7ffc
Rollup merge of #151152 - nik-contrib:helper_attr_builtin, r=chenyukang
Zalathar Feb 11, 2026
449df4d
Rollup merge of #151814 - lcnr:silent-layout-error, r=jackh726
Zalathar Feb 11, 2026
bb40372
Rollup merge of #151863 - amandasystems:streamline-borrow-error-handl…
Zalathar Feb 11, 2026
4d64f1e
Rollup merge of #152159 - JohnTitor:issue-74756, r=estebank
Zalathar Feb 11, 2026
22d2b56
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
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
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
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
33 changes: 27 additions & 6 deletions compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -646,10 +646,32 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
) -> Self::Value {
let tcx = self.tcx();

// FIXME remove usage of fn_abi
let fn_abi = self.fn_abi_of_instance(instance, ty::List::empty());
assert!(!fn_abi.ret.is_indirect());
let fn_ty = fn_abi.llvm_type(self);
let fn_ty = instance.ty(tcx, self.typing_env());
let fn_sig = match *fn_ty.kind() {
ty::FnDef(def_id, args) => {
tcx.instantiate_bound_regions_with_erased(tcx.fn_sig(def_id).instantiate(tcx, args))
}
_ => unreachable!(),
};
assert!(!fn_sig.c_variadic);

let ret_layout = self.layout_of(fn_sig.output());
let llreturn_ty = if ret_layout.is_zst() {
self.type_void()
} else {
ret_layout.immediate_llvm_type(self)
};

let mut llargument_tys = Vec::with_capacity(fn_sig.inputs().len());
for &arg in fn_sig.inputs() {
let arg_layout = self.layout_of(arg);
if arg_layout.is_zst() {
continue;
}
llargument_tys.push(arg_layout.immediate_llvm_type(self));
}

let fn_ty = self.type_func(&llargument_tys, llreturn_ty);

let fn_ptr = if let Some(&llfn) = self.intrinsic_instances.borrow().get(&instance) {
llfn
Expand All @@ -665,12 +687,11 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
let llfn = declare_raw_fn(
self,
sym,
fn_abi.llvm_cconv(self),
llvm::CCallConv,
llvm::UnnamedAddr::Global,
llvm::Visibility::Default,
fn_ty,
);
fn_abi.apply_attrs_llfn(self, llfn, Some(instance));

llfn
};
Expand Down
17 changes: 16 additions & 1 deletion compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,22 @@ impl<'tcx> InherentCollect<'tcx> {
Ok(())
} else {
let impl_span = self.tcx.def_span(impl_def_id);
Err(self.tcx.dcx().emit_err(errors::InherentTyOutsideNew { span: impl_span }))
let mut err = errors::InherentTyOutsideNew { span: impl_span, note: None };

if let hir::TyKind::Path(rustc_hir::QPath::Resolved(_, path)) =
self.tcx.hir_node_by_def_id(impl_def_id).expect_item().expect_impl().self_ty.kind
&& let rustc_hir::def::Res::Def(DefKind::TyAlias, def_id) = path.res
{
let ty_name = self.tcx.def_path_str(def_id);
let alias_ty_name = self.tcx.type_of(def_id).skip_binder().to_string();
err.note = Some(errors::InherentTyOutsideNewAliasNote {
span: self.tcx.def_span(def_id),
ty_name,
alias_ty_name,
});
}

Err(self.tcx.dcx().emit_err(err))
}
}

Expand Down
18 changes: 17 additions & 1 deletion compiler/rustc_hir_analysis/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1223,11 +1223,27 @@ pub(crate) struct InherentTyOutsideRelevant {

#[derive(Diagnostic)]
#[diag("cannot define inherent `impl` for a type outside of the crate where the type is defined", code = E0116)]
#[note("define and implement a trait or new type instead")]
#[help(
"consider defining a trait and implementing it for the type or using a newtype wrapper like `struct MyType(ExternalType);` and implement it"
)]
#[note(
"for more details about the orphan rules, see <https://doc.rust-lang.org/reference/items/implementations.html?highlight=orphan#orphan-rules>"
)]
pub(crate) struct InherentTyOutsideNew {
#[primary_span]
#[label("impl for type defined outside of crate")]
pub span: Span,
#[subdiagnostic]
pub note: Option<InherentTyOutsideNewAliasNote>,
}

#[derive(Subdiagnostic)]
#[note("`{$ty_name}` does not define a new type, only an alias of `{$alias_ty_name}` defined here")]
pub(crate) struct InherentTyOutsideNewAliasNote {
#[primary_span]
pub span: Span,
pub ty_name: String,
pub alias_ty_name: String,
}

#[derive(Diagnostic)]
Expand Down
Loading
Loading