Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
66b489f
Update syntax of try build delegation in bors
Kobzol Jun 20, 2026
aa78a1d
Merge pull request #2906 from Kobzol/delegate-try-update
tshepang Jun 20, 2026
35990d1
do not use title case for section names
tshepang Jun 22, 2026
36f0600
Merge pull request #2908 from rust-lang/tshepang-patch-2
tshepang Jun 22, 2026
616c9f8
do not use title case for section names (part 2)
tshepang Jun 22, 2026
52c6f5f
Merge pull request #2909 from rust-lang/tshepang-patch-3
tshepang Jun 22, 2026
35df795
std: allocate less memory in `current_exe` for OpenBSD
joboet Jun 22, 2026
db9b6a1
std: program names starting with a dot may not be path-like
joboet Jun 25, 2026
4928ea5
Prepare for merging from rust-lang/rust
invalid-email-address Jun 29, 2026
1c09ec1
Merge ref '7fb284d9037f' from rust-lang/rust
invalid-email-address Jun 29, 2026
7b24788
Merge pull request #2912 from rust-lang/rustc-pull
tshepang Jun 29, 2026
9af8904
Add well-formedness chapter
fallible-algebra Jun 1, 2026
4066557
Add Well-formedness dev guide page
BoxyUwU Jun 29, 2026
6bf1cd9
update autodiff install docs for nix
activexray Jun 23, 2026
70859bd
Merge pull request #2910 from activexray/main
ZuseZ4 Jun 29, 2026
4c65d6e
Fix typo in best-practices.md
teor2345 Jul 1, 2026
a4eba1d
make more simple
tshepang Jul 1, 2026
2ffca4e
Merge pull request #2913 from teor2345/patch-1
tshepang Jul 1, 2026
866e997
move a few tests out of tests/ui/issues
danieljofficial Jun 16, 2026
2c0fe5b
add links and bless
danieljofficial Jul 1, 2026
34df033
Update `FIXME(static_mut_refs)` comments
obeis Jul 3, 2026
9016189
move batch
zedddie Jul 3, 2026
0c42d92
bless batch
zedddie Jul 3, 2026
ba53d1b
Add some more AST size assertions
nnethercote Jul 3, 2026
b14e429
Use `ThinVec` in `Expr::OffsetOf`
nnethercote Jul 3, 2026
3a0a977
Use `ThinVec` in `GenericBounds`
nnethercote Jul 3, 2026
27935a6
Fix incorrect tracking issue link for read_le/read_be
kpeis695 Jul 4, 2026
4c7acb4
add rustdoc-ui regression for non-ident doc auto_cfg values
TaKO8Ki Jul 4, 2026
86960f5
handle non-ident doc auto_cfg values without panicking
TaKO8Ki Jul 4, 2026
c341ff5
sembr src/analysis/well-formed.md
tshepang Jul 4, 2026
ccec2e0
fix misplaced quotes
tshepang Jul 4, 2026
eefd538
sembr src/analysis/well-formed.md
tshepang Jul 4, 2026
6b77786
use sentence case
tshepang Jul 4, 2026
2452d9d
Update date-check markers for July 2026
krishna3554 Jul 3, 2026
5ba2f10
less words
tshepang Jul 4, 2026
42fa311
Merge pull request #2915 from krishna3554/update-date-check-markers-2…
tshepang Jul 4, 2026
bae7fba
new mdbook now gives this for free
tshepang Jul 4, 2026
769c5bd
document accepted practice
tshepang Jul 4, 2026
dd200ba
use local
tshepang Jul 4, 2026
4132d73
sembr src/building/bootstrapping/debugging-bootstrap.md
tshepang Jul 4, 2026
d8954e6
sembr src/building/bootstrapping/intro.md
tshepang Jul 4, 2026
3b40dd0
indirection
tshepang Jul 4, 2026
02b4d2b
sembr src/building/bootstrapping/how-bootstrap-does-it.md
tshepang Jul 4, 2026
3ca83eb
sembr src/building/bootstrapping/bootstrap-in-dependencies.md
tshepang Jul 4, 2026
ecb36ae
capitalise
tshepang Jul 4, 2026
41462bb
overlong
tshepang Jul 4, 2026
b593a46
missing pause
tshepang Jul 4, 2026
f070f47
Merge pull request #2916 from rust-lang/tshepang/misc
tshepang Jul 4, 2026
99b3d11
library: expand HashSet extract_if coverage
ArshLabs Jul 4, 2026
d0c3225
bootstrap: only encode RUSTFLAGS when a flag contains a space
valentynkit Jul 4, 2026
835045e
hook intrinsic-test into aarch64-gnu
xonx4l Jul 4, 2026
ee37726
Add and use cfg(target_has_threads) to enforce no_thread impl usage
Mark-Simulacrum Jul 4, 2026
8815b1e
Rollup merge of #158775 - valentynkit:bootstrap-readable-rustflags, r…
JonathanBrouwer Jul 5, 2026
629242a
Rollup merge of #158782 - Mark-Simulacrum:expose-no-threads, r=Urgau
JonathanBrouwer Jul 5, 2026
457ac30
Rollup merge of #158785 - xonx4l:intrinsic-test-aarch64, r=Kobzol
JonathanBrouwer Jul 5, 2026
b894f8f
Rollup merge of #158183 - joboet:openbsd_current_exe, r=Mark-Simulacrum
JonathanBrouwer Jul 5, 2026
3d384a5
Rollup merge of #158671 - danieljofficial:move-tests-batch-17, r=Kivooeo
JonathanBrouwer Jul 5, 2026
117ebc9
Rollup merge of #158730 - obeis:raw-pointer-static-mut, r=RalfJung
JonathanBrouwer Jul 5, 2026
3c13c7a
Rollup merge of #158752 - zedddie:gsoc-batch-18-meow, r=Kivooeo
JonathanBrouwer Jul 5, 2026
8b1ee68
Rollup merge of #158755 - nnethercote:ast-ThinVec, r=mejrs
JonathanBrouwer Jul 5, 2026
50d354a
Rollup merge of #158757 - kpeis695:fix/read-le-be-tracking-issue-link…
JonathanBrouwer Jul 5, 2026
bafe293
Rollup merge of #158765 - TaKO8Ki:fix-doc-auto-cfg-values-non-ident, …
JonathanBrouwer Jul 5, 2026
09184b4
Rollup merge of #158771 - ArshLabs:test/hashset-extract-if-coverage, …
JonathanBrouwer Jul 5, 2026
8366848
Rollup merge of #158772 - tshepang:rdg-sync, r=tshepang
JonathanBrouwer Jul 5, 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
16 changes: 13 additions & 3 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ impl GenericBound {
}
}

pub type GenericBounds = Vec<GenericBound>;
pub type GenericBounds = ThinVec<GenericBound>;

/// Specifies the enforced ordering for generic parameters. In the future,
/// if we wanted to relax this order, we could override `PartialEq` and
Expand Down Expand Up @@ -1534,7 +1534,7 @@ impl Expr {
let (Some(lhs), Some(rhs)) = (lhs.to_bound(), rhs.to_bound()) else {
return None;
};
TyKind::TraitObject(vec![lhs, rhs], TraitObjectSyntax::None)
TyKind::TraitObject(thin_vec![lhs, rhs], TraitObjectSyntax::None)
}

ExprKind::Underscore => TyKind::Infer,
Expand Down Expand Up @@ -1868,7 +1868,7 @@ pub enum ExprKind {
///
/// Usually not written directly in user code but
/// indirectly via the macro `core::mem::offset_of!(...)`.
OffsetOf(Box<Ty>, Vec<Ident>),
OffsetOf(Box<Ty>, ThinVec<Ident>),

/// A macro invocation; pre-expansion.
MacCall(Box<MacCall>),
Expand Down Expand Up @@ -4391,27 +4391,37 @@ mod size_asserts {
// tidy-alphabetical-start
static_assert_size!(AssocItem, 80);
static_assert_size!(AssocItemKind, 16);
static_assert_size!(AttrKind, 16);
static_assert_size!(Attribute, 32);
static_assert_size!(Block, 32);
static_assert_size!(Expr, 72);
static_assert_size!(ExprKind, 40);
static_assert_size!(Fn, 192);
static_assert_size!(FnDecl, 24);
static_assert_size!(FnHeader, 76);
static_assert_size!(FnSig, 96);
static_assert_size!(ForeignItem, 80);
static_assert_size!(ForeignItemKind, 16);
static_assert_size!(GenericArg, 24);
static_assert_size!(GenericArgs, 40);
static_assert_size!(GenericBound, 88);
static_assert_size!(GenericParam, 80);
static_assert_size!(Generics, 40);
static_assert_size!(Impl, 80);
static_assert_size!(Item, 152);
static_assert_size!(ItemKind, 88);
static_assert_size!(Lifetime, 16);
static_assert_size!(LitKind, 24);
static_assert_size!(Local, 96);
static_assert_size!(MetaItem, 88);
static_assert_size!(MetaItemKind, 40);
static_assert_size!(MetaItemLit, 40);
static_assert_size!(Param, 40);
static_assert_size!(Pat, 80);
static_assert_size!(PatKind, 56);
static_assert_size!(Path, 24);
static_assert_size!(PathSegment, 24);
static_assert_size!(QSelf, 24);
static_assert_size!(Stmt, 32);
static_assert_size!(StmtKind, 16);
static_assert_size!(TraitImplHeader, 72);
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_ast/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,8 @@ macro_rules! common_visitor_and_walkers {
impl_visitable_list!(<$($lt)? $($mut)?>
ThinVec<AngleBracketedArg>,
ThinVec<Attribute>,
ThinVec<GenericBound>,
ThinVec<Ident>,
ThinVec<(Ident, Option<Ident>)>,
ThinVec<(NodeId, Path)>,
ThinVec<PathSegment>,
Expand Down
11 changes: 6 additions & 5 deletions compiler/rustc_attr_parsing/src/attributes/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,11 @@ impl DocParser {
// If it's a list, then only `any()` and `none()` are allowed and they must not
// contain any item.
MetaItemOrLitParser::MetaItemParser(sub_item) => {
if let Some(ident) = sub_item.ident()
&& [sym::any, sym::none].contains(&ident.name)
let Some(ident) = sub_item.ident() else {
cx.adcx().expected_identifier(sub_item.path().span());
continue;
};
if [sym::any, sym::none].contains(&ident.name)
&& let ArgParser::List(list) = sub_item.args()
&& list.mixed().count() == 0
{
Expand All @@ -371,9 +374,7 @@ impl DocParser {
} else {
cx.emit_lint(
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
DocAutoCfgHideShowUnexpectedItem {
attr_name: sub_item.ident().unwrap().name,
},
DocAutoCfgHideShowUnexpectedItem { attr_name: ident.name },
sub_item.span(),
);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_builtin_macros/src/deriving/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ fn show_substructure(cx: &ExtCtxt<'_>, span: Span, substr: &Substructure<'_>) ->
let ty_dyn_debug = cx.ty(
span,
ast::TyKind::TraitObject(
vec![cx.trait_bound(path_debug, false)],
thin_vec![cx.trait_bound(path_debug, false)],
ast::TraitObjectSyntax::Dyn,
),
);
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_builtin_macros/src/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ impl<'a> TraitDef<'a> {
ident,
generics: Generics::default(),
after_where_clause: ast::WhereClause::default(),
bounds: Vec::new(),
bounds: ThinVec::new(),
ty: Some(type_def.to_ty(cx, self.span, type_ident, generics)),
})),
tokens: None,
Expand All @@ -639,7 +639,7 @@ impl<'a> TraitDef<'a> {
// Extra restrictions on the generics parameters to the
// type being derived upon.
let span = param.ident.span.with_ctxt(ctxt);
let bounds: Vec<_> = self
let bounds: ThinVec<_> = self
.additional_bounds
.iter()
.map(|p| {
Expand Down Expand Up @@ -723,7 +723,7 @@ impl<'a> TraitDef<'a> {
{
continue;
}
let mut bounds: Vec<_> = self
let mut bounds: ThinVec<_> = self
.additional_bounds
.iter()
.map(|p| {
Expand Down
12 changes: 3 additions & 9 deletions compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use rustc_fs_util::{link_or_copy, path_to_c_string};
use rustc_middle::ty::TyCtxt;
use rustc_session::Session;
use rustc_session::config::{self, Lto, OutputType, Passes, SplitDwarfKind, SwitchWithOptPath};
use rustc_span::{BytePos, InnerSpan, Pos, RemapPathScopeComponents, SpanData, SyntaxContext, sym};
use rustc_span::{BytePos, InnerSpan, Pos, RemapPathScopeComponents, SpanData, SyntaxContext};
use rustc_target::spec::{CodeModel, FloatAbi, RelocModel, SanitizerSet, SplitDebuginfo, TlsModel};
use tracing::{debug, trace};

Expand Down Expand Up @@ -209,14 +209,8 @@ pub(crate) fn target_machine_factory(

let code_model = to_llvm_code_model(sess.code_model());

let mut singlethread = sess.target.singlethread;

// On the wasm target once the `atomics` feature is enabled that means that
// we're no longer single-threaded, or otherwise we don't want LLVM to
// lower atomic operations to single-threaded operations.
if singlethread && sess.target.is_like_wasm && sess.target_features.contains(&sym::atomics) {
singlethread = false;
}
// This is used to set cfg_has_threads, so all logic must be in this method.
let singlethread = sess.target.singlethread(&sess.target_features);

let triple = SmallCStr::new(&versioned_llvm_target(sess));
let cpu = SmallCStr::new(llvm_util::target_cpu(sess));
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const GATED_CFGS: &[GatedCfg] = &[
sym::cfg_target_has_reliable_f16_f128,
Features::cfg_target_has_reliable_f16_f128,
),
(sym::target_has_threads, sym::cfg_target_has_threads, Features::cfg_target_has_threads),
(sym::target_object_format, sym::cfg_target_object_format, Features::cfg_target_object_format),
];

Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ declare_features! (
(unstable, anonymous_lifetime_in_impl_trait, "1.63.0", None),
/// Allows checking whether or not the backend correctly supports unstable float types.
(internal, cfg_target_has_reliable_f16_f128, "1.88.0", None),
/// Allows checking whether or not the target might have thread support.
(internal, cfg_target_has_threads, "CURRENT_RUSTC_VERSION", None),
/// Allows identifying the `compiler_builtins` crate.
(internal, compiler_builtins, "1.13.0", None),
/// Allows skipping `ConstParamTy_` trait implementation checks
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_parse/src/parser/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,8 +1154,8 @@ impl<'a> Parser<'a> {
/// Parse the field access used in offset_of, matched by `$(e:expr)+`.
/// Currently returns a list of idents. However, it should be possible in
/// future to also do array indices, which might be arbitrary expressions.
pub(crate) fn parse_floating_field_access(&mut self) -> PResult<'a, Vec<Ident>> {
let mut fields = Vec::new();
pub(crate) fn parse_floating_field_access(&mut self) -> PResult<'a, ThinVec<Ident>> {
let mut fields = ThinVec::new();
let mut trailing_dot = None;

loop {
Expand Down
12 changes: 6 additions & 6 deletions compiler/rustc_parse/src/parser/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl<'a> Parser<'a> {
/// BOUND = LT_BOUND (e.g., `'a`)
/// ```
fn parse_lt_param_bounds(&mut self) -> GenericBounds {
let mut lifetimes = Vec::new();
let mut lifetimes = ThinVec::new();
while self.check_lifetime() {
lifetimes.push(ast::GenericBound::Outlives(self.expect_lifetime()));

Expand Down Expand Up @@ -86,7 +86,7 @@ impl<'a> Parser<'a> {
}
self.parse_generic_bounds()?
} else {
Vec::new()
ThinVec::new()
};

let default = if self.eat(exp!(Eq)) { Some(self.parse_ty()?) } else { None };
Expand Down Expand Up @@ -125,7 +125,7 @@ impl<'a> Parser<'a> {
ident,
id: ast::DUMMY_NODE_ID,
attrs: preceding_attrs,
bounds: Vec::new(),
bounds: ThinVec::new(),
kind: GenericParamKind::Const { ty, span, default: None },
is_placeholder: false,
colon_span: None,
Expand All @@ -148,7 +148,7 @@ impl<'a> Parser<'a> {
ident,
id: ast::DUMMY_NODE_ID,
attrs: preceding_attrs,
bounds: Vec::new(),
bounds: ThinVec::new(),
kind: GenericParamKind::Const { ty, span, default },
is_placeholder: false,
colon_span: None,
Expand Down Expand Up @@ -189,7 +189,7 @@ impl<'a> Parser<'a> {
ident,
id: ast::DUMMY_NODE_ID,
attrs: preceding_attrs,
bounds: Vec::new(),
bounds: ThinVec::new(),
kind: GenericParamKind::Const { ty, span, default },
is_placeholder: false,
colon_span: None,
Expand Down Expand Up @@ -225,7 +225,7 @@ impl<'a> Parser<'a> {
let (colon_span, bounds) = if this.eat(exp!(Colon)) {
(Some(this.prev_token.span), this.parse_lt_param_bounds())
} else {
(None, Vec::new())
(None, ThinVec::new())
};

if this.check_noexpect(&token::Eq) && this.look_ahead(1, |t| t.is_lifetime()) {
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,7 @@ impl<'a> Parser<'a> {
// Parse optional colon and supertrait bounds.
let had_colon = self.eat(exp!(Colon));
let span_at_colon = self.prev_token.span;
let bounds = if had_colon { self.parse_generic_bounds()? } else { Vec::new() };
let bounds = if had_colon { self.parse_generic_bounds()? } else { ThinVec::new() };

let span_before_eq = self.prev_token.span;
if self.eat(exp!(Eq)) {
Expand Down Expand Up @@ -1253,7 +1253,8 @@ impl<'a> Parser<'a> {
let mut generics = self.parse_generics()?;

// Parse optional colon and param bounds.
let bounds = if self.eat(exp!(Colon)) { self.parse_generic_bounds()? } else { Vec::new() };
let bounds =
if self.eat(exp!(Colon)) { self.parse_generic_bounds()? } else { ThinVec::new() };
generics.where_clause = self.parse_where_clause()?;

let ty = if self.eat(exp!(Eq)) { Some(self.parse_ty()?) } else { None };
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_parse/src/parser/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ impl<'a> Parser<'a> {
lo.to(self.prev_token.span),
parens,
);
let bounds = vec![GenericBound::Trait(poly_trait_ref)];
let bounds = thin_vec![GenericBound::Trait(poly_trait_ref)];
self.parse_remaining_bounds(bounds, parse_plus)
}

Expand Down Expand Up @@ -1080,7 +1080,7 @@ impl<'a> Parser<'a> {
/// Only if `allow_plus` this parses a `+`-separated list of bounds (trailing `+` is admitted).
/// Otherwise, this only parses a single bound or none.
fn parse_generic_bounds_common(&mut self, allow_plus: AllowPlus) -> PResult<'a, GenericBounds> {
let mut bounds = Vec::new();
let mut bounds = ThinVec::new();

// In addition to looping while we find generic bounds:
// We continue even if we find a keyword. This is necessary for error recovery on,
Expand Down Expand Up @@ -1432,7 +1432,7 @@ impl<'a> Parser<'a> {
// Someone has written something like `&dyn (Trait + Other)`. The correct code
// would be `&(dyn Trait + Other)`
if self.token.is_like_plus() && leading_token.is_keyword(kw::Dyn) {
let bounds = vec![];
let bounds = thin_vec![];
self.parse_remaining_bounds(bounds, true)?;
self.expect(exp!(CloseParen))?;
self.dcx().emit_err(errors::IncorrectParensTraitBounds {
Expand Down Expand Up @@ -1617,7 +1617,7 @@ impl<'a> Parser<'a> {
id: lt.id,
ident: lt.ident,
attrs: ast::AttrVec::new(),
bounds: Vec::new(),
bounds: ThinVec::new(),
is_placeholder: false,
kind: ast::GenericParamKind::Lifetime,
colon_span: None,
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use rustc_session::{Session, lint};
use rustc_span::edit_distance::{edit_distance, find_best_match_for_name};
use rustc_span::edition::Edition;
use rustc_span::{DUMMY_SP, DesugaringKind, Ident, Span, Symbol, kw, sym};
use thin_vec::ThinVec;
use thin_vec::{ThinVec, thin_vec};
use tracing::debug;

use super::NoConstantGenericsReason;
Expand Down Expand Up @@ -4522,7 +4522,7 @@ fn mk_where_bound_predicate(
let new_where_bound_predicate = ast::WhereBoundPredicate {
bound_generic_params: ThinVec::new(),
bounded_ty: Box::new(ty.clone()),
bounds: vec![ast::GenericBound::Trait(ast::PolyTraitRef {
bounds: thin_vec![ast::GenericBound::Trait(ast::PolyTraitRef {
bound_generic_params: ThinVec::new(),
modifiers: ast::TraitBoundModifiers::NONE,
trait_ref: ast::TraitRef {
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_session/src/config/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ pub(crate) fn disallow_cfgs(sess: &Session, user_cfgs: &Cfg) {
| (sym::target_pointer_width, Some(_))
| (sym::target_vendor, None | Some(_))
| (sym::target_has_atomic, Some(_))
| (sym::target_has_threads, None | Some(_))
| (sym::target_has_atomic_primitive_alignment, Some(_))
| (sym::target_has_atomic_load_store, Some(_))
| (sym::target_has_reliable_f16, None | Some(_))
Expand Down Expand Up @@ -303,6 +304,10 @@ pub(crate) fn default_configuration(sess: &Session) -> Cfg {
}
}

if !sess.target.singlethread(&sess.target_features) {
ins_none!(sym::target_has_threads);
}

ins_sym!(sym::target_os, sess.target.os.desc_symbol());
ins_sym!(sym::target_pointer_width, sym::integer(sess.target.pointer_width));

Expand Down Expand Up @@ -485,6 +490,7 @@ impl CheckCfg {
ins!(sym::target_has_atomic_primitive_alignment, empty_values).extend(atomic_values);

ins!(sym::target_thread_local, no_values);
ins!(sym::target_has_threads, no_values);

ins!(sym::ub_checks, no_values);
ins!(sym::contract_checks, no_values);
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ symbols! {
cfg_target_has_atomic,
cfg_target_has_atomic_equal_alignment,
cfg_target_has_reliable_f16_f128,
cfg_target_has_threads,
cfg_target_object_format,
cfg_target_thread_local,
cfg_target_vendor,
Expand Down Expand Up @@ -2084,6 +2085,7 @@ symbols! {
target_has_reliable_f16_math,
target_has_reliable_f128,
target_has_reliable_f128_math,
target_has_threads,
target_object_format,
target_os,
target_pointer_width,
Expand Down
23 changes: 22 additions & 1 deletion compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2256,6 +2256,26 @@ impl Target {
}
}
}

/// Is this target single-threaded?
///
/// This affects both optimizations (e.g., atomics can be lowered to regular operations) and
/// is also exposed as cfg(target_has_threads).
pub fn singlethread(&self, target_features: &FxIndexSet<Symbol>) -> bool {
// On the wasm target once the `atomics` feature is enabled that means that
// we're no longer single-threaded, or otherwise we don't want LLVM to
// lower atomic operations to single-threaded operations.
//
// FIXME: This (probably?) implies that atomics should be a target modifier, at which point
// it probably makes sense to be a separate target to ship precompiled artifacts for it?
//
// cc #77839 (tracking issue for wasm atomics)
if self.singlethread && self.is_like_wasm && target_features.contains(&sym::atomics) {
return false;
}

self.singlethread
}
}

pub trait HasTargetSpec {
Expand Down Expand Up @@ -2571,7 +2591,8 @@ pub struct TargetOptions {
pub requires_lto: bool,

/// This target has no support for threads.
pub singlethread: bool,
// This is private because wasm changes this depending on target features.
singlethread: bool,

/// Whether library functions call lowering/optimization is disabled in LLVM
/// for this target unconditionally.
Expand Down
Loading
Loading