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 8 pull requests #135506

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7dce0b3
Revive amdgpu-kernel calling convention
Flakebi Jan 2, 2025
94399e0
Remove rust-analyzer changes
Flakebi Jan 2, 2025
6805183
Fix unsupported calling conv tests
Flakebi Jan 2, 2025
93855de
late_report_deprecation: move fast-path closer to the core logic
RalfJung Jan 1, 2025
f4235b8
allowed_through_unstable_modules: support showing a deprecation messa…
RalfJung Jan 1, 2025
f1fcde4
intrinsics: deprecate calling them via the unstable std::intrinsics path
RalfJung Jan 1, 2025
9a80eff
show deprecation message in rustdoc, too
RalfJung Jan 6, 2025
3c31861
Don't allow transmuting ZSTs in dispatch_from_dyn impl
compiler-errors Jan 8, 2025
11bc805
Don't allow DispatchFromDyn impls that transmute ZST to non-ZST
compiler-errors Jan 8, 2025
ebd5ce1
for purely return-type based searches, deprioritize clone-like functions
lolbinarycat Jan 9, 2025
2c4ee54
Introduce gpu-kernel instead of amdgpu-kernel
Flakebi Jan 3, 2025
b8d962b
Fix tests and tidy
Flakebi Jan 14, 2025
68b2639
Disable test for not-yet-merged amdgpu target
Flakebi Jan 14, 2025
516a933
Make sure we can produce ConstArgHasWrongType errors for valtree consts
compiler-errors Jan 11, 2025
3cd7581
Normalize field before checking PhantomData in coerce/dispatch impl v…
compiler-errors Jan 8, 2025
2669f2a
Do not consider traits that have unsatisfied const conditions to be c…
compiler-errors Jan 13, 2025
b89a6e4
Consider more erroneous layouts as LayoutError::ReferencesError to su…
compiler-errors Jan 8, 2025
5775190
Make sure to scrape region constraints from deeply normalizing type o…
compiler-errors Dec 30, 2024
03674ae
Rollup merge of #134940 - compiler-errors:scrape, r=lcnr
matthiaskrgr Jan 14, 2025
b7d919b
Rollup merge of #135003 - RalfJung:deprecate-allowed-through-unstable…
matthiaskrgr Jan 14, 2025
a378c7a
Rollup merge of #135047 - Flakebi:amdgpu-kernel-cc, r=workingjubilee
matthiaskrgr Jan 14, 2025
188d159
Rollup merge of #135228 - compiler-errors:normalizes-ur-dispatch, r=B…
matthiaskrgr Jan 14, 2025
06a83a1
Rollup merge of #135264 - compiler-errors:layout-propagate-errors, r=…
matthiaskrgr Jan 14, 2025
487983f
Rollup merge of #135302 - lolbinarycat:rustdoc-search-return-sort-134…
matthiaskrgr Jan 14, 2025
33a797d
Rollup merge of #135380 - compiler-errors:mismatch-valtree, r=lcnr
matthiaskrgr Jan 14, 2025
8fdbce5
Rollup merge of #135425 - compiler-errors:not-conditionally-const, r=…
matthiaskrgr Jan 14, 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
35 changes: 22 additions & 13 deletions compiler/rustc_abi/src/extern_abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ pub enum ExternAbi {
PtxKernel,
Msp430Interrupt,
X86Interrupt,
/// An entry-point function called by the GPU's host
// FIXME: should not be callable from Rust on GPU targets, is for host's use only
GpuKernel,
EfiApi,
AvrInterrupt,
AvrNonBlockingInterrupt,
Expand Down Expand Up @@ -122,6 +125,7 @@ const AbiDatas: &[AbiData] = &[
AbiData { abi: Abi::PtxKernel, name: "ptx-kernel" },
AbiData { abi: Abi::Msp430Interrupt, name: "msp430-interrupt" },
AbiData { abi: Abi::X86Interrupt, name: "x86-interrupt" },
AbiData { abi: Abi::GpuKernel, name: "gpu-kernel" },
AbiData { abi: Abi::EfiApi, name: "efiapi" },
AbiData { abi: Abi::AvrInterrupt, name: "avr-interrupt" },
AbiData { abi: Abi::AvrNonBlockingInterrupt, name: "avr-non-blocking-interrupt" },
Expand Down Expand Up @@ -239,6 +243,10 @@ pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
feature: sym::abi_x86_interrupt,
explain: "x86-interrupt ABI is experimental and subject to change",
}),
"gpu-kernel" => Err(AbiDisabled::Unstable {
feature: sym::abi_gpu_kernel,
explain: "gpu-kernel ABI is experimental and subject to change",
}),
"avr-interrupt" | "avr-non-blocking-interrupt" => Err(AbiDisabled::Unstable {
feature: sym::abi_avr_interrupt,
explain: "avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change",
Expand Down Expand Up @@ -293,20 +301,21 @@ impl Abi {
PtxKernel => 19,
Msp430Interrupt => 20,
X86Interrupt => 21,
EfiApi => 22,
AvrInterrupt => 23,
AvrNonBlockingInterrupt => 24,
CCmseNonSecureCall => 25,
CCmseNonSecureEntry => 26,
GpuKernel => 22,
EfiApi => 23,
AvrInterrupt => 24,
AvrNonBlockingInterrupt => 25,
CCmseNonSecureCall => 26,
CCmseNonSecureEntry => 27,
// Cross-platform ABIs
System { unwind: false } => 27,
System { unwind: true } => 28,
RustIntrinsic => 29,
RustCall => 30,
Unadjusted => 31,
RustCold => 32,
RiscvInterruptM => 33,
RiscvInterruptS => 34,
System { unwind: false } => 28,
System { unwind: true } => 29,
RustIntrinsic => 30,
RustCall => 31,
Unadjusted => 32,
RustCold => 33,
RiscvInterruptM => 34,
RiscvInterruptS => 35,
};
debug_assert!(
AbiDatas
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_ast/src/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,8 @@ impl MetaItemLit {
pub trait AttributeExt: Debug {
fn id(&self) -> AttrId;

/// For a single-segment attribute (i.e., `#[attr]` and not `#[path::atrr]`),
/// return the name of the attribute, else return the empty identifier.
fn name_or_empty(&self) -> Symbol {
self.ident().unwrap_or_else(Ident::empty).name
}
Expand Down
15 changes: 12 additions & 3 deletions compiler/rustc_attr_data_structures/src/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ impl PartialConstStability {
}
}

#[derive(Encodable, Decodable, PartialEq, Copy, Clone, Debug, Eq, Hash)]
#[derive(HashStable_Generic)]
pub enum AllowedThroughUnstableModules {
/// This does not get a deprecation warning. We still generally would prefer people to use the
/// fully stable path, and a warning will likely be emitted in the future.
WithoutDeprecation,
/// Emit the given deprecation warning.
WithDeprecation(Symbol),
}

/// The available stability levels.
#[derive(Encodable, Decodable, PartialEq, Copy, Clone, Debug, Eq, Hash)]
#[derive(HashStable_Generic)]
Expand Down Expand Up @@ -137,9 +147,8 @@ pub enum StabilityLevel {
Stable {
/// Rust release which stabilized this feature.
since: StableSince,
/// Is this item allowed to be referred to on stable, despite being contained in unstable
/// modules?
allowed_through_unstable_modules: bool,
/// This is `Some` if this item allowed to be referred to on stable via unstable modules.
allowed_through_unstable_modules: Option<AllowedThroughUnstableModules>,
},
}

Expand Down
21 changes: 13 additions & 8 deletions compiler/rustc_attr_parsing/src/attributes/stability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use rustc_ast::MetaItem;
use rustc_ast::attr::AttributeExt;
use rustc_ast_pretty::pprust;
use rustc_attr_data_structures::{
ConstStability, DefaultBodyStability, Stability, StabilityLevel, StableSince, UnstableReason,
VERSION_PLACEHOLDER,
AllowedThroughUnstableModules, ConstStability, DefaultBodyStability, Stability, StabilityLevel,
StableSince, UnstableReason, VERSION_PLACEHOLDER,
};
use rustc_errors::ErrorGuaranteed;
use rustc_session::Session;
Expand All @@ -24,11 +24,16 @@ pub fn find_stability(
item_sp: Span,
) -> Option<(Stability, Span)> {
let mut stab: Option<(Stability, Span)> = None;
let mut allowed_through_unstable_modules = false;
let mut allowed_through_unstable_modules = None;

for attr in attrs {
match attr.name_or_empty() {
sym::rustc_allowed_through_unstable_modules => allowed_through_unstable_modules = true,
sym::rustc_allowed_through_unstable_modules => {
allowed_through_unstable_modules = Some(match attr.value_str() {
Some(msg) => AllowedThroughUnstableModules::WithDeprecation(msg),
None => AllowedThroughUnstableModules::WithoutDeprecation,
})
}
sym::unstable => {
if stab.is_some() {
sess.dcx().emit_err(session_diagnostics::MultipleStabilityLevels {
Expand Down Expand Up @@ -56,15 +61,15 @@ pub fn find_stability(
}
}

if allowed_through_unstable_modules {
if let Some(allowed_through_unstable_modules) = allowed_through_unstable_modules {
match &mut stab {
Some((
Stability {
level: StabilityLevel::Stable { allowed_through_unstable_modules, .. },
level: StabilityLevel::Stable { allowed_through_unstable_modules: in_stab, .. },
..
},
_,
)) => *allowed_through_unstable_modules = true,
)) => *in_stab = Some(allowed_through_unstable_modules),
_ => {
sess.dcx()
.emit_err(session_diagnostics::RustcAllowedUnstablePairing { span: item_sp });
Expand Down Expand Up @@ -283,7 +288,7 @@ fn parse_stability(sess: &Session, attr: &impl AttributeExt) -> Option<(Symbol,

match feature {
Ok(feature) => {
let level = StabilityLevel::Stable { since, allowed_through_unstable_modules: false };
let level = StabilityLevel::Stable { since, allowed_through_unstable_modules: None };
Some((feature, level))
}
Err(ErrorGuaranteed { .. }) => None,
Expand Down
67 changes: 48 additions & 19 deletions compiler/rustc_borrowck/src/type_check/free_region_relations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ use rustc_infer::infer::canonical::QueryRegionConstraints;
use rustc_infer::infer::outlives::env::RegionBoundPairs;
use rustc_infer::infer::region_constraints::GenericKind;
use rustc_infer::infer::{InferCtxt, outlives};
use rustc_infer::traits::ScrubbedTraitError;
use rustc_middle::mir::ConstraintCategory;
use rustc_middle::traits::ObligationCause;
use rustc_middle::traits::query::OutlivesBound;
use rustc_middle::ty::{self, RegionVid, Ty, TypeVisitableExt};
use rustc_span::{ErrorGuaranteed, Span};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::solve::deeply_normalize;
use rustc_trait_selection::solve::NoSolution;
use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
use rustc_trait_selection::traits::query::type_op::{self, TypeOp};
use tracing::{debug, instrument};
use type_op::TypeOpOutput;
Expand Down Expand Up @@ -229,24 +230,14 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
let mut constraints = vec![];
let mut known_type_outlives_obligations = vec![];
for bound in param_env.caller_bounds() {
let Some(mut outlives) = bound.as_type_outlives_clause() else { continue };

// In the new solver, normalize the type-outlives obligation assumptions.
if self.infcx.next_trait_solver() {
match deeply_normalize(
self.infcx.at(&ObligationCause::misc(span, defining_ty_def_id), param_env),
if let Some(outlives) = bound.as_type_outlives_clause() {
self.normalize_and_push_type_outlives_obligation(
outlives,
) {
Ok(normalized_outlives) => {
outlives = normalized_outlives;
}
Err(e) => {
self.infcx.err_ctxt().report_fulfillment_errors(e);
}
}
}

known_type_outlives_obligations.push(outlives);
span,
&mut known_type_outlives_obligations,
&mut constraints,
);
};
}

let unnormalized_input_output_tys = self
Expand Down Expand Up @@ -356,6 +347,44 @@ impl<'tcx> UniversalRegionRelationsBuilder<'_, 'tcx> {
}
}

fn normalize_and_push_type_outlives_obligation(
&self,
mut outlives: ty::PolyTypeOutlivesPredicate<'tcx>,
span: Span,
known_type_outlives_obligations: &mut Vec<ty::PolyTypeOutlivesPredicate<'tcx>>,
constraints: &mut Vec<&QueryRegionConstraints<'tcx>>,
) {
// In the new solver, normalize the type-outlives obligation assumptions.
if self.infcx.next_trait_solver() {
let Ok(TypeOpOutput {
output: normalized_outlives,
constraints: constraints_normalize,
error_info: _,
}) = CustomTypeOp::new(
|ocx| {
ocx.deeply_normalize(
&ObligationCause::dummy_with_span(span),
self.param_env,
outlives,
)
.map_err(|_: Vec<ScrubbedTraitError<'tcx>>| NoSolution)
},
"normalize type outlives obligation",
)
.fully_perform(self.infcx, span)
else {
self.infcx.dcx().delayed_bug(format!("could not normalize {outlives:?}"));
return;
};
outlives = normalized_outlives;
if let Some(c) = constraints_normalize {
constraints.push(c);
}
}

known_type_outlives_obligations.push(outlives);
}

/// Update the type of a single local, which should represent
/// either the return type of the MIR or one of its arguments. At
/// the same time, compute and add any implied bounds that come
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_codegen_cranelift/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ pub(crate) fn conv_to_call_conv(sess: &Session, c: Conv, default_call_conv: Call
sess.dcx().fatal("C-cmse-nonsecure-entry call conv is not yet implemented");
}

Conv::Msp430Intr | Conv::PtxKernel | Conv::AvrInterrupt | Conv::AvrNonBlockingInterrupt => {
Conv::Msp430Intr
| Conv::PtxKernel
| Conv::GpuKernel
| Conv::AvrInterrupt
| Conv::AvrNonBlockingInterrupt => {
unreachable!("tried to use {c:?} call conv which only exists on an unsupported target");
}
}
Expand Down
22 changes: 16 additions & 6 deletions compiler/rustc_codegen_llvm/src/abi.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::borrow::Borrow;
use std::cmp;

use libc::c_uint;
Expand Down Expand Up @@ -312,7 +313,7 @@ impl<'ll, 'tcx> ArgAbiBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
pub(crate) trait FnAbiLlvmExt<'ll, 'tcx> {
fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
fn ptr_to_llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
fn llvm_cconv(&self) -> llvm::CallConv;
fn llvm_cconv(&self, cx: &CodegenCx<'ll, 'tcx>) -> llvm::CallConv;

/// Apply attributes to a function declaration/definition.
fn apply_attrs_llfn(
Expand Down Expand Up @@ -404,8 +405,8 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
cx.type_ptr_ext(cx.data_layout().instruction_address_space)
}

fn llvm_cconv(&self) -> llvm::CallConv {
self.conv.into()
fn llvm_cconv(&self, cx: &CodegenCx<'ll, 'tcx>) -> llvm::CallConv {
llvm::CallConv::from_conv(self.conv, cx.tcx.sess.target.arch.borrow())
}

fn apply_attrs_llfn(
Expand Down Expand Up @@ -617,7 +618,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
}
}

let cconv = self.llvm_cconv();
let cconv = self.llvm_cconv(&bx.cx);
if cconv != llvm::CCallConv {
llvm::SetInstructionCallConv(callsite, cconv);
}
Expand Down Expand Up @@ -655,8 +656,8 @@ impl<'tcx> AbiBuilderMethods<'tcx> for Builder<'_, '_, 'tcx> {
}
}

impl From<Conv> for llvm::CallConv {
fn from(conv: Conv) -> Self {
impl llvm::CallConv {
pub fn from_conv(conv: Conv, arch: &str) -> Self {
match conv {
Conv::C
| Conv::Rust
Expand All @@ -666,6 +667,15 @@ impl From<Conv> for llvm::CallConv {
Conv::Cold => llvm::ColdCallConv,
Conv::PreserveMost => llvm::PreserveMost,
Conv::PreserveAll => llvm::PreserveAll,
Conv::GpuKernel => {
if arch == "amdgpu" {
llvm::AmdgpuKernel
} else if arch == "nvptx64" {
llvm::PtxKernel
} else {
panic!("Architecture {arch} does not support GpuKernel calling convention");
}
}
Conv::AvrInterrupt => llvm::AvrInterrupt,
Conv::AvrNonBlockingInterrupt => llvm::AvrNonBlockingInterrupt,
Conv::ArmAapcs => llvm::ArmAapcsCallConv,
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,10 @@ impl<'ll, 'tcx> MiscCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
if self.get_declared_value(entry_name).is_none() {
Some(self.declare_entry_fn(
entry_name,
self.sess().target.entry_abi.into(),
llvm::CallConv::from_conv(
self.sess().target.entry_abi,
self.sess().target.arch.borrow(),
),
llvm::UnnamedAddr::Global,
fn_type,
))
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
let llfn = declare_raw_fn(
self,
name,
fn_abi.llvm_cconv(),
fn_abi.llvm_cconv(self),
llvm::UnnamedAddr::Global,
llvm::Visibility::Default,
fn_abi.llvm_type(self),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ pub enum CallConv {
X86_Intr = 83,
AvrNonBlockingInterrupt = 84,
AvrInterrupt = 85,
AmdgpuKernel = 91,
}

/// Must match the layout of `LLVMLinkage`.
Expand Down
Loading
Loading