Skip to content

Rollup of 18 pull requests #143074

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

Merged
merged 44 commits into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e6c3008
small iter.intersperse.fold() optimization
the8472 Jun 15, 2025
644469e
Remove incorrect comments in `Weak`
theemathas Jun 19, 2025
00f369a
Add note to find_const_ty_from_env
compiler-errors Jun 23, 2025
df426cf
Uplift find_const_ty_from_env
compiler-errors Jun 23, 2025
f908939
rename run_always to run_in_dry_run
Shourya742 Jun 25, 2025
4f80053
Update `browser-ui-test` version to `0.20.7`
GuillaumeGomez Jun 25, 2025
b75b14f
Add `sym::macro_pin` diagnostic item for `core::pin::pin!()`
samueltardieu Jun 25, 2025
8304435
Compute hard errors without diagnostics in impl_intersection_has_impo…
compiler-errors Jun 17, 2025
44254c8
Remove some glob imports from the type system
compiler-errors Jun 17, 2025
c995070
rename RegionVariableOrigin::MiscVariable to RegionVariableOrigin::Misc
compiler-errors Jun 18, 2025
1f1000f
make RefCell unstably const
Daniel-Aaron-Bloom May 7, 2025
1aa5e17
Expand const-stabilized API links
jieyouxu Jun 26, 2025
ec6f0ea
Remove cache for citool
Kobzol Jun 26, 2025
7960272
Remove workflow run on master
Kobzol Jun 26, 2025
287d9af
Port `#[export_name]` to the new attribute parsing infrastructure
JonathanBrouwer Jun 24, 2025
3d1cee5
Move mixed export_name/no_mangle check to check_attr.rs and improve t…
JonathanBrouwer Jun 24, 2025
7a70f64
Fix RwLock::try_write documentation for WouldBlock condition
krikera Jun 26, 2025
169e81c
Move an ACE test out of the GCI directory
fmease Jun 26, 2025
bf9a5d4
Use stable std links
jieyouxu Jun 26, 2025
fad27aa
Add missing stabilized slice chunk methods
jieyouxu Jun 26, 2025
4925265
const-eval: allow constants to refer to mutable/external memory, but …
RalfJung May 12, 2025
ff17a22
add more sensible mut-ref-to-immutable test
RalfJung Jun 17, 2025
bade3fd
clarify and unify 'transient mutable borrow' errors
RalfJung Jun 18, 2025
0c1c648
Add more missing APIs, and minor fixes
jieyouxu Jun 26, 2025
8c15a69
Tracking issue number for `iter_macro`
GrigorenkoPV Jun 26, 2025
174cb47
Fix some fixmes that were waiting for let chains
yotamofek Jun 26, 2025
0446a0d
Rollup merge of #137843 - Daniel-Aaron-Bloom:const_cell, r=oli-obk
compiler-errors Jun 27, 2025
36cde67
Rollup merge of #140942 - RalfJung:const-ref-to-mut, r=oli-obk
compiler-errors Jun 27, 2025
9820197
Rollup merge of #142549 - the8472:intersperse-fold-tweak, r=tgross35
compiler-errors Jun 27, 2025
48d3118
Rollup merge of #142637 - compiler-errors:less-globs, r=lcnr
compiler-errors Jun 27, 2025
25e239c
Rollup merge of #142647 - compiler-errors:less-work-in-coherence, r=lcnr
compiler-errors Jun 27, 2025
58cda76
Rollup merge of #142700 - theemathas:remove-weak-comment, r=ibraheemdev
compiler-errors Jun 27, 2025
d712024
Rollup merge of #142927 - compiler-errors:note-find-const, r=BoxyUwU
compiler-errors Jun 27, 2025
c5ac143
Rollup merge of #142967 - krikera:fix-rwlock-try-write-docs, r=jhpratt
compiler-errors Jun 27, 2025
d386600
Rollup merge of #142986 - JonathanBrouwer:export_name_parser, r=jdons…
compiler-errors Jun 27, 2025
80972ae
Rollup merge of #143001 - Shourya742:2025-06-25-rename-run-always, r=…
compiler-errors Jun 27, 2025
4dca555
Rollup merge of #143010 - GuillaumeGomez:update-browser-ui-test, r=Ko…
compiler-errors Jun 27, 2025
5fca4bd
Rollup merge of #143015 - samueltardieu:pin-macro-diag-item, r=Urgau
compiler-errors Jun 27, 2025
335fde5
Rollup merge of #143033 - jieyouxu:expand-apis, r=cuviper
compiler-errors Jun 27, 2025
4a32934
Rollup merge of #143041 - Kobzol:matrix-no-cache, r=marcoieni
compiler-errors Jun 27, 2025
49944c3
Rollup merge of #143056 - fmease:mv-ace-test-out-of-gci-dir, r=BoxyUwU
compiler-errors Jun 27, 2025
93810c9
Rollup merge of #143059 - jieyouxu:slice-as-chunks, r=cuviper
compiler-errors Jun 27, 2025
434e3e5
Rollup merge of #143067 - GrigorenkoPV:142269, r=workingjubilee
compiler-errors Jun 27, 2025
cb0b621
Rollup merge of #143073 - yotamofek:pr/fix-let-chains-fixmes, r=compi…
compiler-errors Jun 27, 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
11 changes: 0 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ name: CI
on:
push:
branches:
# CI on master only serves for caching citool builds for the `calculate_matrix` job.
# In order to use GHA cache on PR CI (and auto/try) jobs, we need to write to it
# from the default branch.
- master
- auto
- try
- try-perf
Expand Down Expand Up @@ -57,13 +53,6 @@ jobs:
steps:
- name: Checkout the source code
uses: actions/checkout@v4
# Cache citool to make its build faster, as it's in the critical path.
# The rust-cache doesn't bleed into the main `job`, so it should not affect any other
# Rust compilation.
- name: Cache citool
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
with:
workspaces: src/ci/citool
- name: Test citool
# Only test citool on the auto branch, to reduce latency of the calculate matrix job
# on PR/try builds.
Expand Down
20 changes: 16 additions & 4 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,35 @@ Stabilized APIs
---------------

- [`Cell::update`](https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#method.update)
- [`impl Default for *const T`](https://doc.rust-lang.org/nightly/std/primitive.pointer.html#impl-Default-for-*const+T)
- [`impl Default for *mut T`](https://doc.rust-lang.org/nightly/std/primitive.pointer.html#impl-Default-for-*mut+T)
- [`impl Default for *const T`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#impl-Default-for-*const+T)
- [`impl Default for *mut T`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#impl-Default-for-*mut+T)
- [`HashMap::extract_if`](https://doc.rust-lang.org/stable/std/collections/struct.HashMap.html#method.extract_if)
- [`HashSet::extract_if`](https://doc.rust-lang.org/stable/std/collections/struct.HashSet.html#method.extract_if)
- [`hint::select_unpredictable`](https://doc.rust-lang.org/stable/std/hint/fn.select_unpredictable.html)
- [`proc_macro::Span::line`](https://doc.rust-lang.org/stable/proc_macro/struct.Span.html#method.line)
- [`proc_macro::Span::column`](https://doc.rust-lang.org/stable/proc_macro/struct.Span.html#method.column)
- [`proc_macro::Span::start`](https://doc.rust-lang.org/stable/proc_macro/struct.Span.html#method.start)
- [`proc_macro::Span::end`](https://doc.rust-lang.org/stable/proc_macro/struct.Span.html#method.end)
- [`proc_macro::Span::file`](https://doc.rust-lang.org/stable/proc_macro/struct.Span.html#method.file)
- [`proc_macro::Span::local_file`](https://doc.rust-lang.org/stable/proc_macro/struct.Span.html#method.local_file)
- [`<[T]>::as_chunks`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_chunks)
- [`<[T]>::as_chunks_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_chunks_mut)
- [`<[T]>::as_chunks_unchecked`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_chunks_unchecked)
- [`<[T]>::as_chunks_unchecked_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_chunks_unchecked_mut)
- [`<[T]>::as_rchunks`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_rchunks)
- [`<[T]>::as_rchunks_mut`](https://doc.rust-lang.org/stable/std/primitive.slice.html#method.as_rchunks_mut)
- [`mod ffi::c_str`](https://doc.rust-lang.org/stable/std/ffi/c_str/index.html)

These previously stable APIs are now stable in const contexts:

- [`NonNull<T>::replace`](https://doc.rust-lang.org/stable/std/ptr/struct.NonNull.html#method.replace)
- [`<*mut T>::replace`](https://doc.rust-lang.org/stable/std/primitive.pointer.html#method.replace)
- [`std::ptr::swap_nonoverlapping`](https://github.com/rust-lang/rust/pull/137280)
- [`Cell::{replace, get, get_mut, from_mut, as_slice_of_cells}`](https://github.com/rust-lang/rust/pull/137928)
- [`std::ptr::swap_nonoverlapping`](https://doc.rust-lang.org/stable/std/ptr/fn.swap_nonoverlapping.html)
- [`Cell::replace`](https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#method.replace)
- [`Cell::get`](https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#method.get)
- [`Cell::get_mut`](https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#method.get_mut)
- [`Cell::from_mut`](https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#method.from_mut)
- [`Cell::as_slice_of_cells`](https://doc.rust-lang.org/stable/std/cell/struct.Cell.html#method.as_slice_of_cells)


<a id="1.88.0-Cargo"></a>
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_attr_data_structures/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ pub enum AttributeKind {
/// Represents [`#[doc]`](https://doc.rust-lang.org/stable/rustdoc/write-documentation/the-doc-attribute.html).
DocComment { style: AttrStyle, kind: CommentKind, span: Span, comment: Symbol },

/// Represents [`#[export_name]`](https://doc.rust-lang.org/reference/abi.html#the-export_name-attribute).
ExportName {
/// The name to export this item with.
/// It may not contain \0 bytes as it will be converted to a null-terminated string.
name: Symbol,
span: Span,
},

/// Represents `#[inline]` and `#[rustc_force_inline]`.
Inline(InlineAttr, Span),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ impl AttributeKind {
ConstStabilityIndirect => No,
Deprecation { .. } => Yes,
DocComment { .. } => Yes,
ExportName { .. } => Yes,
Inline(..) => No,
MacroTransparency(..) => Yes,
Repr(..) => No,
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_attr_parsing/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@ attr_parsing_naked_functions_incompatible_attribute =
attribute incompatible with `#[unsafe(naked)]`
.label = the `{$attr}` attribute is incompatible with `#[unsafe(naked)]`
.naked_attribute = function marked with `#[unsafe(naked)]` here

attr_parsing_non_ident_feature =
'feature' is not an identifier

attr_parsing_null_on_export = `export_name` may not contain null characters

attr_parsing_repr_ident =
meta item in `repr` must be an identifier

Expand Down
29 changes: 28 additions & 1 deletion compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_span::{Span, Symbol, sym};
use super::{AcceptMapping, AttributeOrder, AttributeParser, OnDuplicate, SingleAttributeParser};
use crate::context::{AcceptContext, FinalizeContext, Stage};
use crate::parser::ArgParser;
use crate::session_diagnostics::NakedFunctionIncompatibleAttribute;
use crate::session_diagnostics::{NakedFunctionIncompatibleAttribute, NullOnExport};

pub(crate) struct OptimizeParser;

Expand Down Expand Up @@ -59,6 +59,33 @@ impl<S: Stage> SingleAttributeParser<S> for ColdParser {
}
}

pub(crate) struct ExportNameParser;

impl<S: Stage> SingleAttributeParser<S> for ExportNameParser {
const PATH: &[rustc_span::Symbol] = &[sym::export_name];
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepFirst;
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::WarnButFutureError;
const TEMPLATE: AttributeTemplate = template!(NameValueStr: "name");

fn convert(cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>) -> Option<AttributeKind> {
let Some(nv) = args.name_value() else {
cx.expected_name_value(cx.attr_span, None);
return None;
};
let Some(name) = nv.value_as_str() else {
cx.expected_string_literal(nv.value_span, Some(nv.value_as_lit()));
return None;
};
if name.as_str().contains('\0') {
// `#[export_name = ...]` will be converted to a null-terminated string,
// so it may not contain any null characters.
cx.emit_err(NullOnExport { span: cx.attr_span });
return None;
}
Some(AttributeKind::ExportName { name, span: cx.attr_span })
}
}

#[derive(Default)]
pub(crate) struct NakedParser {
span: Option<Span>,
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span, Symbol, sym};

use crate::attributes::allow_unstable::{AllowConstFnUnstableParser, AllowInternalUnstableParser};
use crate::attributes::codegen_attrs::{
ColdParser, NakedParser, NoMangleParser, OptimizeParser, TrackCallerParser,
ColdParser, ExportNameParser, NakedParser, NoMangleParser, OptimizeParser, TrackCallerParser,
};
use crate::attributes::confusables::ConfusablesParser;
use crate::attributes::deprecation::DeprecationParser;
Expand Down Expand Up @@ -117,6 +117,7 @@ attribute_parsers!(
Single<ConstContinueParser>,
Single<ConstStabilityIndirectParser>,
Single<DeprecationParser>,
Single<ExportNameParser>,
Single<InlineParser>,
Single<LoopMatchParser>,
Single<MayDangleParser>,
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_attr_parsing/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,13 @@ pub(crate) struct MustUseIllFormedAttributeInput {
pub suggestions: DiagArgValue,
}

#[derive(Diagnostic)]
#[diag(attr_parsing_null_on_export, code = E0648)]
pub(crate) struct NullOnExport {
#[primary_span]
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(attr_parsing_stability_outside_std, code = E0734)]
pub(crate) struct StabilityOutsideStd {
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_borrowck/src/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_hir::def::Res::Def;
use rustc_hir::def_id::DefId;
use rustc_hir::intravisit::VisitorExt;
use rustc_hir::{PolyTraitRef, TyKind, WhereBoundPredicate};
use rustc_infer::infer::{NllRegionVariableOrigin, RelateParamBound};
use rustc_infer::infer::{NllRegionVariableOrigin, SubregionOrigin};
use rustc_middle::bug;
use rustc_middle::hir::place::PlaceBase;
use rustc_middle::mir::{AnnotationSource, ConstraintCategory, ReturnConstraint};
Expand Down Expand Up @@ -329,7 +329,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
self.infcx.tcx,
type_test.generic_kind.to_ty(self.infcx.tcx),
);
let origin = RelateParamBound(type_test_span, generic_ty, None);
let origin =
SubregionOrigin::RelateParamBound(type_test_span, generic_ty, None);
self.buffer_error(self.infcx.err_ctxt().construct_generic_bound_failure(
self.body.source.def_id().expect_local(),
type_test_span,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use rustc_infer::infer::canonical::QueryRegionConstraints;
use rustc_infer::infer::outlives::env::RegionBoundPairs;
use rustc_infer::infer::outlives::obligations::{TypeOutlives, TypeOutlivesDelegate};
use rustc_infer::infer::region_constraints::{GenericKind, VerifyBound};
use rustc_infer::infer::{self, InferCtxt, SubregionOrigin};
use rustc_infer::infer::{InferCtxt, SubregionOrigin};
use rustc_infer::traits::query::type_op::DeeplyNormalize;
use rustc_middle::bug;
use rustc_middle::ty::{
Expand Down Expand Up @@ -172,7 +172,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
ty::Region::new_var(tcx, universal_regions.implicit_region_bound());
// we don't actually use this for anything, but
// the `TypeOutlives` code needs an origin.
let origin = infer::RelateParamBound(self.span, t1, None);
let origin = SubregionOrigin::RelateParamBound(self.span, t1, None);
TypeOutlives::new(
&mut *self,
tcx,
Expand Down
7 changes: 3 additions & 4 deletions compiler/rustc_borrowck/src/type_check/input_output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
Ty::new_tup(self.tcx(), user_provided_sig.inputs()),
args.tupled_upvars_ty(),
args.coroutine_captures_by_ref_ty(),
self.infcx
.next_region_var(RegionVariableOrigin::MiscVariable(self.body.span), || {
RegionCtxt::Unknown
}),
self.infcx.next_region_var(RegionVariableOrigin::Misc(self.body.span), || {
RegionCtxt::Unknown
}),
);

let next_ty_var = || self.infcx.next_ty_var(self.body.span);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use rustc_infer::infer::canonical::QueryRegionConstraints;
use rustc_infer::infer::outlives::env::RegionBoundPairs;
use rustc_infer::infer::region_constraints::RegionConstraintData;
use rustc_infer::infer::{
BoundRegion, BoundRegionConversionTime, InferCtxt, NllRegionVariableOrigin,
BoundRegionConversionTime, InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin,
};
use rustc_infer::traits::PredicateObligations;
use rustc_middle::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor};
Expand Down Expand Up @@ -794,7 +794,7 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
};

self.infcx.next_region_var(
BoundRegion(
RegionVariableOrigin::BoundRegion(
term.source_info.span,
br.kind,
BoundRegionConversionTime::FnCall,
Expand Down
7 changes: 0 additions & 7 deletions compiler/rustc_codegen_ssa/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,6 @@ codegen_ssa_missing_features = add the missing features in a `target_feature` at
codegen_ssa_missing_query_depgraph =
found CGU-reuse attribute but `-Zquery-dep-graph` was not specified

codegen_ssa_mixed_export_name_and_no_mangle = `{$no_mangle_attr}` attribute may not be used in combination with `#[export_name]`
.label = `{$no_mangle_attr}` is ignored
.note = `#[export_name]` takes precedence
.suggestion = remove the `{$no_mangle_attr}` attribute

codegen_ssa_msvc_missing_linker = the msvc targets depend on the msvc linker but `link.exe` was not found

codegen_ssa_multiple_external_func_decl = multiple declarations of external function `{$function}` from library `{$library_name}` have different calling conventions
Expand All @@ -230,8 +225,6 @@ codegen_ssa_no_natvis_directory = error enumerating natvis directory: {$error}

codegen_ssa_no_saved_object_file = cached cgu {$cgu_name} should have an object file, but doesn't

codegen_ssa_null_on_export = `export_name` may not contain null characters

codegen_ssa_out_of_range_integer = integer value out of range
.label = value must be between `0` and `255`

Expand Down
67 changes: 4 additions & 63 deletions compiler/rustc_codegen_ssa/src/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_attr_data_structures::{
use rustc_hir::def::DefKind;
use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId};
use rustc_hir::weak_lang_items::WEAK_LANG_ITEMS;
use rustc_hir::{self as hir, HirId, LangItem, lang_items};
use rustc_hir::{self as hir, LangItem, lang_items};
use rustc_middle::middle::codegen_fn_attrs::{
CodegenFnAttrFlags, CodegenFnAttrs, PatchableFunctionEntry,
};
Expand Down Expand Up @@ -87,7 +87,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {

let mut link_ordinal_span = None;
let mut no_sanitize_span = None;
let mut mixed_export_name_no_mangle_lint_state = MixedExportNameAndNoMangleState::default();

for attr in attrs.iter() {
// In some cases, attribute are only valid on functions, but it's the `check_attr`
Expand Down Expand Up @@ -119,16 +118,14 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
.max();
}
AttributeKind::Cold(_) => codegen_fn_attrs.flags |= CodegenFnAttrFlags::COLD,
AttributeKind::ExportName { name, .. } => {
codegen_fn_attrs.export_name = Some(*name);
}
AttributeKind::Naked(_) => codegen_fn_attrs.flags |= CodegenFnAttrFlags::NAKED,
AttributeKind::Align { align, .. } => codegen_fn_attrs.alignment = Some(*align),
AttributeKind::NoMangle(attr_span) => {
if tcx.opt_item_name(did.to_def_id()).is_some() {
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_MANGLE;
mixed_export_name_no_mangle_lint_state.track_no_mangle(
*attr_span,
tcx.local_def_id_to_hir_id(did),
attr,
);
} else {
tcx.dcx().emit_err(NoMangleNameless {
span: *attr_span,
Expand Down Expand Up @@ -223,17 +220,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
}
}
sym::thread_local => codegen_fn_attrs.flags |= CodegenFnAttrFlags::THREAD_LOCAL,
sym::export_name => {
if let Some(s) = attr.value_str() {
if s.as_str().contains('\0') {
// `#[export_name = ...]` will be converted to a null-terminated string,
// so it may not contain any null characters.
tcx.dcx().emit_err(errors::NullOnExport { span: attr.span() });
}
codegen_fn_attrs.export_name = Some(s);
mixed_export_name_no_mangle_lint_state.track_export_name(attr.span());
}
}
sym::target_feature => {
let Some(sig) = tcx.hir_node_by_def_id(did).fn_sig() else {
tcx.dcx().span_delayed_bug(attr.span(), "target_feature applied to non-fn");
Expand Down Expand Up @@ -444,8 +430,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
}
}

mixed_export_name_no_mangle_lint_state.lint_if_mixed(tcx);

// Apply the minimum function alignment here, so that individual backends don't have to.
codegen_fn_attrs.alignment =
Ord::max(codegen_fn_attrs.alignment, tcx.sess.opts.unstable_opts.min_function_alignment);
Expand Down Expand Up @@ -672,49 +656,6 @@ fn check_link_name_xor_ordinal(
}
}

#[derive(Default)]
struct MixedExportNameAndNoMangleState<'a> {
export_name: Option<Span>,
hir_id: Option<HirId>,
no_mangle: Option<Span>,
no_mangle_attr: Option<&'a hir::Attribute>,
}

impl<'a> MixedExportNameAndNoMangleState<'a> {
fn track_export_name(&mut self, span: Span) {
self.export_name = Some(span);
}

fn track_no_mangle(&mut self, span: Span, hir_id: HirId, attr_name: &'a hir::Attribute) {
self.no_mangle = Some(span);
self.hir_id = Some(hir_id);
self.no_mangle_attr = Some(attr_name);
}

/// Emit diagnostics if the lint condition is met.
fn lint_if_mixed(self, tcx: TyCtxt<'_>) {
if let Self {
export_name: Some(export_name),
no_mangle: Some(no_mangle),
hir_id: Some(hir_id),
no_mangle_attr: Some(_),
} = self
{
tcx.emit_node_span_lint(
lint::builtin::UNUSED_ATTRIBUTES,
hir_id,
no_mangle,
errors::MixedExportNameAndNoMangle {
no_mangle,
no_mangle_attr: "#[unsafe(no_mangle)]".to_string(),
export_name,
removal_span: no_mangle,
},
);
}
}
}

/// We now check the #\[rustc_autodiff\] attributes which we generated from the #[autodiff(...)]
/// macros. There are two forms. The pure one without args to mark primal functions (the functions
/// being differentiated). The other form is #[rustc_autodiff(Mode, ActivityList)] on top of the
Expand Down
Loading
Loading