Skip to content
Merged
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
6afedf3
Say that docs.rs sometimes rebuilds crates.
aDotInTheVoid Nov 5, 2025
a606c19
Merge pull request #2629 from rust-lang/aDotInTheVoid-patch-1
aDotInTheVoid Nov 5, 2025
9c1b958
sembr src/rustdoc.md
tshepang Nov 5, 2025
899ff1a
use sentence case for titles
tshepang Nov 5, 2025
06d329e
some text improvements
tshepang Nov 5, 2025
c6b4a22
that redirects to docs.rs
tshepang Nov 5, 2025
3a4d146
sembr src/rustdoc-internals.md
tshepang Nov 5, 2025
8808940
some text improvements
tshepang Nov 5, 2025
2e6ff58
rustdoc json format remains unstable today
tshepang Nov 5, 2025
717449c
fix code block markers
tshepang Nov 5, 2025
205aa55
Merge pull request #2630 from rust-lang/tshepang/sembr
tshepang Nov 5, 2025
037ee61
Fix some invalid language tags
ehuss Nov 5, 2025
5f04888
Add code spans around HTML-like text
ehuss Nov 5, 2025
032c820
Merge pull request #2631 from ehuss/markup-cleanup
tshepang Nov 6, 2025
5a4bb89
the download-ci-llvm experiment turned out to be too unreliable
ZuseZ4 Nov 6, 2025
9774d0a
Merge pull request #2632 from rust-lang/autodiff-remove-downloadllvm
ZuseZ4 Nov 6, 2025
c2f56ef
std: support `RwLock` and thread parking on TEEOS
joboet Nov 8, 2025
a5814a5
Move `parse_cfg_select` to `rustc_builtin_macros`
JonathanBrouwer Nov 9, 2025
c111ccc
Add more tests for `cfg_select` parsing
JonathanBrouwer Nov 8, 2025
90f36af
Port `cfg_select!` to the new attribute parsing system
JonathanBrouwer Nov 8, 2025
2f00812
typo
tshepang Nov 9, 2025
3bca1a2
Merge pull request #2633 from rust-lang/tshepang-patch-2
tshepang Nov 9, 2025
6ed469c
IAT: Reinstate early bailout
fmease Nov 9, 2025
c5f2eb6
rustc_target: hide TargetOptions::vendor
tamird Nov 9, 2025
ca4abb5
typo
tshepang Nov 9, 2025
bc59f94
Merge pull request #2634 from rust-lang/tshepang-patch-4
tshepang Nov 9, 2025
b1542c9
Prefer to use file.stable_id over file.name from source map
chenyukang Nov 10, 2025
ed09431
Prepare for merging from rust-lang/rust
invalid-email-address Nov 10, 2025
68710f6
Merge ref '8401398e1f14' from rust-lang/rust
invalid-email-address Nov 10, 2025
3d44aca
Fix a typo in the documentation for the strict_shr function
reddevilmidzy Nov 10, 2025
6bfb876
Implement DynSend and DynSync for std::panic::Location.
zachs18 Nov 10, 2025
4eb0beb
Rename master branch references to main
reddevilmidzy Nov 10, 2025
5ee331f
fix doc comment
luca3s Nov 10, 2025
1839cdb
Remove unneeded `allow(rustc::potential_query_instability)`
GuillaumeGomez Nov 10, 2025
cec4a23
Merge pull request #2635 from rust-lang/rustc-pull
tshepang Nov 10, 2025
f4e2f0b
sembr src/getting-started.md
tshepang Nov 10, 2025
49143e5
use chapter name instead of text that does not fit well
tshepang Nov 10, 2025
7a7608c
overlong
tshepang Nov 10, 2025
b4a91c3
a double dot is not end of sentence
tshepang Nov 10, 2025
2ae4b0b
Merge pull request #2636 from rust-lang/tshepang/sembr
tshepang Nov 10, 2025
299a13b
sembr tests/running.md
tshepang Nov 10, 2025
b271341
sembr: handle text inside div blocks
tshepang Nov 10, 2025
241e890
tests/running.md: minor improvements
tshepang Nov 10, 2025
87c4064
fix code block language marker
tshepang Nov 10, 2025
6e14d2a
a more suitable marker
tshepang Nov 10, 2025
191778d
Merge pull request #2637 from rust-lang/tshepang/sembr
tshepang Nov 10, 2025
7675d7a
sembr sanitizers.md
tshepang Nov 10, 2025
de1b775
some text improvements
tshepang Nov 10, 2025
dbd05d3
Merge pull request #2638 from rust-lang/tshepang/sembr
tshepang Nov 10, 2025
c6dbda8
Document (and test) a problem with `Clone`/`Copy` deriving.
nnethercote Nov 10, 2025
2570c23
add test for assoc type norm wf check
lcnr Nov 10, 2025
3150714
Rollup merge of #148694 - joboet:teeos-sync, r=ChrisDenton
Zalathar Nov 11, 2025
e26b423
Rollup merge of #148712 - JonathanBrouwer:cfg_select, r=jdonszelmann
Zalathar Nov 11, 2025
d738f03
Rollup merge of #148760 - tamird:avoid-vendor-logic, r=madsmtm
Zalathar Nov 11, 2025
24e0724
Rollup merge of #148771 - fmease:iat-reinstate-early-elim, r=BoxyUwU
Zalathar Nov 11, 2025
0c615a1
Rollup merge of #148775 - reddevilmidzy:fix-typo, r=joboet
Zalathar Nov 11, 2025
58b44fc
Rollup merge of #148779 - zachs18:panic-location-dynsendsync, r=nneth…
Zalathar Nov 11, 2025
2171eee
Rollup merge of #148781 - GuillaumeGomez:rm-unneeded-attr, r=yotamofek
Zalathar Nov 11, 2025
561d0a1
Rollup merge of #148783 - lcnr:add-soundness-test, r=BoxyUwU
Zalathar Nov 11, 2025
3382d31
Rollup merge of #148785 - reddevilmidzy:rename-to-main, r=Kobzol
Zalathar Nov 11, 2025
c9158ce
Rollup merge of #148791 - luca3s:fix-doc-comment, r=lqd
Zalathar Nov 11, 2025
a929960
Rollup merge of #148792 - chenyukang:yukang-fix-file-name, r=Muscraft
Zalathar Nov 11, 2025
b30c004
Rollup merge of #148805 - tshepang:rdg-sync, r=tshepang
Zalathar Nov 11, 2025
224ff38
Rollup merge of #148807 - nnethercote:doc-Copy-Clone-problem, r=saethlin
Zalathar Nov 11, 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
89 changes: 89 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/cfg_select.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
use rustc_ast::token::Token;
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{AttrStyle, NodeId, token};
use rustc_feature::{AttributeTemplate, Features};
use rustc_hir::AttrPath;
use rustc_hir::attrs::CfgEntry;
use rustc_parse::exp;
use rustc_parse::parser::Parser;
use rustc_session::Session;
use rustc_span::{ErrorGuaranteed, Ident, Span};

use crate::parser::MetaItemOrLitParser;
use crate::{AttributeParser, ParsedDescription, ShouldEmit, parse_cfg_entry};

pub enum CfgSelectPredicate {
Cfg(CfgEntry),
Wildcard(Token),
}

#[derive(Default)]
pub struct CfgSelectBranches {
/// All the conditional branches.
pub reachable: Vec<(CfgEntry, TokenStream, Span)>,
/// The first wildcard `_ => { ... }` branch.
pub wildcard: Option<(Token, TokenStream, Span)>,
/// All branches after the first wildcard, including further wildcards.
/// These branches are kept for formatting.
pub unreachable: Vec<(CfgSelectPredicate, TokenStream, Span)>,
}

pub fn parse_cfg_select(
p: &mut Parser<'_>,
sess: &Session,
features: Option<&Features>,
lint_node_id: NodeId,
) -> Result<CfgSelectBranches, ErrorGuaranteed> {
let mut branches = CfgSelectBranches::default();

while p.token != token::Eof {
if p.eat_keyword(exp!(Underscore)) {
let underscore = p.prev_token;
p.expect(exp!(FatArrow)).map_err(|e| e.emit())?;

let tts = p.parse_delimited_token_tree().map_err(|e| e.emit())?;
let span = underscore.span.to(p.token.span);

match branches.wildcard {
None => branches.wildcard = Some((underscore, tts, span)),
Some(_) => {
branches.unreachable.push((CfgSelectPredicate::Wildcard(underscore), tts, span))
}
}
} else {
let meta = MetaItemOrLitParser::parse_single(p, ShouldEmit::ErrorsAndLints)
.map_err(|diag| diag.emit())?;
let cfg_span = meta.span();
let cfg = AttributeParser::parse_single_args(
sess,
cfg_span,
cfg_span,
AttrStyle::Inner,
AttrPath {
segments: vec![Ident::from_str("cfg_select")].into_boxed_slice(),
span: cfg_span,
},
ParsedDescription::Macro,
cfg_span,
lint_node_id,
features,
ShouldEmit::ErrorsAndLints,
&meta,
parse_cfg_entry,
&AttributeTemplate::default(),
)?;

p.expect(exp!(FatArrow)).map_err(|e| e.emit())?;

let tts = p.parse_delimited_token_tree().map_err(|e| e.emit())?;
let span = cfg_span.to(p.token.span);

match branches.wildcard {
None => branches.reachable.push((cfg, tts, span)),
Some(_) => branches.unreachable.push((CfgSelectPredicate::Cfg(cfg), tts, span)),
}
}
}

Ok(branches)
}
1 change: 1 addition & 0 deletions compiler/rustc_attr_parsing/src/attributes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ pub(crate) mod allow_unstable;
pub(crate) mod body;
pub(crate) mod cfg;
pub(crate) mod cfg_old;
pub(crate) mod cfg_select;
pub(crate) mod codegen_attrs;
pub(crate) mod confusables;
pub(crate) mod crate_level;
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_attr_parsing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ pub use attributes::cfg::{
CFG_TEMPLATE, EvalConfigResult, eval_config_entry, parse_cfg, parse_cfg_attr, parse_cfg_entry,
};
pub use attributes::cfg_old::*;
pub use attributes::cfg_select::*;
pub use attributes::util::{is_builtin_attr, is_doc_alias_attrs_contain_symbol, parse_version};
pub use context::{Early, Late, OmitDoc, ShouldEmit};
pub use interface::AttributeParser;
Expand Down
74 changes: 40 additions & 34 deletions compiler/rustc_builtin_macros/src/cfg_select.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
use rustc_ast::tokenstream::TokenStream;
use rustc_attr_parsing as attr;
use rustc_attr_parsing::{
CfgSelectBranches, CfgSelectPredicate, EvalConfigResult, ShouldEmit, parse_cfg_select,
};
use rustc_expand::base::{DummyResult, ExpandResult, ExtCtxt, MacroExpanderResult};
use rustc_parse::parser::cfg_select::{CfgSelectBranches, CfgSelectPredicate, parse_cfg_select};
use rustc_span::{Ident, Span, sym};

use crate::errors::{CfgSelectNoMatches, CfgSelectUnreachable};

/// Selects the first arm whose predicate evaluates to true.
fn select_arm(ecx: &ExtCtxt<'_>, branches: CfgSelectBranches) -> Option<(TokenStream, Span)> {
for (cfg, tt, arm_span) in branches.reachable {
if attr::cfg_matches(
&cfg,
if let EvalConfigResult::True = attr::eval_config_entry(
&ecx.sess,
&cfg,
ecx.current_expansion.lint_node_id,
Some(ecx.ecfg.features),
ShouldEmit::ErrorsAndLints,
) {
return Some((tt, arm_span));
}
Expand All @@ -27,37 +29,41 @@ pub(super) fn expand_cfg_select<'cx>(
sp: Span,
tts: TokenStream,
) -> MacroExpanderResult<'cx> {
ExpandResult::Ready(match parse_cfg_select(&mut ecx.new_parser_from_tts(tts)) {
Ok(branches) => {
if let Some((underscore, _, _)) = branches.wildcard {
// Warn for every unreachable predicate. We store the fully parsed branch for rustfmt.
for (predicate, _, _) in &branches.unreachable {
let span = match predicate {
CfgSelectPredicate::Wildcard(underscore) => underscore.span,
CfgSelectPredicate::Cfg(cfg) => cfg.span(),
};
let err = CfgSelectUnreachable { span, wildcard_span: underscore.span };
ecx.dcx().emit_warn(err);
ExpandResult::Ready(
match parse_cfg_select(
&mut ecx.new_parser_from_tts(tts),
ecx.sess,
Some(ecx.ecfg.features),
ecx.current_expansion.lint_node_id,
) {
Ok(branches) => {
if let Some((underscore, _, _)) = branches.wildcard {
// Warn for every unreachable predicate. We store the fully parsed branch for rustfmt.
for (predicate, _, _) in &branches.unreachable {
let span = match predicate {
CfgSelectPredicate::Wildcard(underscore) => underscore.span,
CfgSelectPredicate::Cfg(cfg) => cfg.span(),
};
let err = CfgSelectUnreachable { span, wildcard_span: underscore.span };
ecx.dcx().emit_warn(err);
}
}
}

if let Some((tts, arm_span)) = select_arm(ecx, branches) {
return ExpandResult::from_tts(
ecx,
tts,
sp,
arm_span,
Ident::with_dummy_span(sym::cfg_select),
);
} else {
// Emit a compiler error when none of the predicates matched.
let guar = ecx.dcx().emit_err(CfgSelectNoMatches { span: sp });
DummyResult::any(sp, guar)
if let Some((tts, arm_span)) = select_arm(ecx, branches) {
return ExpandResult::from_tts(
ecx,
tts,
sp,
arm_span,
Ident::with_dummy_span(sym::cfg_select),
);
} else {
// Emit a compiler error when none of the predicates matched.
let guar = ecx.dcx().emit_err(CfgSelectNoMatches { span: sp });
DummyResult::any(sp, guar)
}
}
}
Err(err) => {
let guar = err.emit();
DummyResult::any(sp, guar)
}
})
Err(guar) => DummyResult::any(sp, guar),
},
)
}
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_cranelift/src/abi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,8 @@ pub(crate) fn codegen_call_with_unwind_action(
pub(crate) fn lib_call_arg_param(tcx: TyCtxt<'_>, ty: Type, is_signed: bool) -> AbiParam {
let param = AbiParam::new(ty);
if ty.is_int() && u64::from(ty.bits()) < tcx.data_layout.pointer_size().bits() {
match (&tcx.sess.target.arch, tcx.sess.target.vendor.as_ref()) {
(Arch::X86_64, _) | (Arch::AArch64, "apple") => match (ty, is_signed) {
match (&tcx.sess.target.arch, tcx.sess.target.is_like_darwin) {
(Arch::X86_64, _) | (Arch::AArch64, true) => match (ty, is_signed) {
(types::I8 | types::I16, true) => param.sext(),
(types::I8 | types::I16, false) => param.uext(),
_ => param,
Expand Down
8 changes: 3 additions & 5 deletions compiler/rustc_codegen_cranelift/src/codegen_f16_f128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::prelude::*;

pub(crate) fn f16_to_f32(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
let (value, arg_ty) =
if fx.tcx.sess.target.vendor == "apple" && fx.tcx.sess.target.arch == Arch::X86_64 {
if fx.tcx.sess.target.is_like_darwin && fx.tcx.sess.target.arch == Arch::X86_64 {
(
fx.bcx.ins().bitcast(types::I16, MemFlags::new(), value),
lib_call_arg_param(fx.tcx, types::I16, false),
Expand All @@ -22,8 +22,7 @@ fn f16_to_f64(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
}

pub(crate) fn f32_to_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
let ret_ty = if fx.tcx.sess.target.vendor == "apple" && fx.tcx.sess.target.arch == Arch::X86_64
{
let ret_ty = if fx.tcx.sess.target.is_like_darwin && fx.tcx.sess.target.arch == Arch::X86_64 {
types::I16
} else {
types::F16
Expand All @@ -38,8 +37,7 @@ pub(crate) fn f32_to_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value
}

fn f64_to_f16(fx: &mut FunctionCx<'_, '_, '_>, value: Value) -> Value {
let ret_ty = if fx.tcx.sess.target.vendor == "apple" && fx.tcx.sess.target.arch == Arch::X86_64
{
let ret_ty = if fx.tcx.sess.target.is_like_darwin && fx.tcx.sess.target.arch == Arch::X86_64 {
types::I16
} else {
types::F16
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,7 @@ fn self_contained_components(
LinkSelfContainedDefault::InferredForMusl => sess.crt_static(Some(crate_type)),
LinkSelfContainedDefault::InferredForMingw => {
sess.host == sess.target
&& sess.target.vendor != "uwp"
&& sess.target.abi != "uwp"
&& detect_self_contained_mingw(sess, linker)
}
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub(crate) fn get_linker<'a>(
// To comply with the Windows App Certification Kit,
// MSVC needs to link with the Store versions of the runtime libraries (vcruntime, msvcrt, etc).
let t = &sess.target;
if matches!(flavor, LinkerFlavor::Msvc(..)) && t.vendor == "uwp" {
if matches!(flavor, LinkerFlavor::Msvc(..)) && t.abi == "uwp" {
if let Some(ref tool) = msvc_tool {
let original_path = tool.path();
if let Some(root_lib_path) = original_path.ancestors().nth(4) {
Expand Down Expand Up @@ -134,7 +134,7 @@ pub(crate) fn get_linker<'a>(

// FIXME: Move `/LIBPATH` addition for uwp targets from the linker construction
// to the linker args construction.
assert!(cmd.get_args().is_empty() || sess.target.vendor == "uwp");
assert!(cmd.get_args().is_empty() || sess.target.abi == "uwp");
match flavor {
LinkerFlavor::Unix(Cc::No) if sess.target.os == "l4re" => {
Box::new(L4Bender::new(cmd, sess)) as Box<dyn Linker>
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ pub fn asm_const_to_str<'tcx>(
}

pub fn is_mingw_gnu_toolchain(target: &Target) -> bool {
target.vendor == "pc" && target.os == "windows" && target.env == "gnu" && target.abi.is_empty()
target.os == "windows" && target.env == "gnu" && target.abi.is_empty()
}

pub fn i686_decorated_name(
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_data_structures/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ impl !DynSend for std::env::VarsOs {}

macro_rules! already_send {
($([$ty: ty])*) => {
$(unsafe impl DynSend for $ty where $ty: Send {})*
$(unsafe impl DynSend for $ty where Self: Send {})*
};
}

// These structures are already `Send`.
already_send!(
[std::backtrace::Backtrace][std::io::Stdout][std::io::Stderr][std::io::Error][std::fs::File]
[std::backtrace::Backtrace][std::io::Stdout][std::io::Stderr][std::io::Error][std::fs::File][std::panic::Location<'_>]
[rustc_arena::DroplessArena][jobserver_crate::Client][jobserver_crate::HelperThread]
[crate::memmap::Mmap][crate::profiling::SelfProfiler][crate::owned_slice::OwnedSlice]
);
Expand Down Expand Up @@ -127,14 +127,14 @@ impl !DynSync for std::env::VarsOs {}

macro_rules! already_sync {
($([$ty: ty])*) => {
$(unsafe impl DynSync for $ty where $ty: Sync {})*
$(unsafe impl DynSync for $ty where Self: Sync {})*
};
}

// These structures are already `Sync`.
already_sync!(
[std::sync::atomic::AtomicBool][std::sync::atomic::AtomicUsize][std::sync::atomic::AtomicU8]
[std::sync::atomic::AtomicU32][std::backtrace::Backtrace][std::io::Error][std::fs::File]
[std::sync::atomic::AtomicU32][std::backtrace::Backtrace][std::io::Error][std::fs::File][std::panic::Location<'_>]
[jobserver_crate::Client][jobserver_crate::HelperThread][crate::memmap::Mmap]
[crate::profiling::SelfProfiler][crate::owned_slice::OwnedSlice]
);
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_errors/src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,7 @@ impl HumanEmitter {
}
// print out the span location and spacer before we print the annotated source
// to do this, we need to know if this span will be primary
let is_primary = primary_lo.file.name == annotated_file.file.name;
let is_primary = primary_lo.file.stable_id == annotated_file.file.stable_id;
if is_primary {
let loc = primary_lo.clone();
if !self.short_message {
Expand Down Expand Up @@ -3108,7 +3108,7 @@ impl FileWithAnnotatedLines {
) {
for slot in file_vec.iter_mut() {
// Look through each of our files for the one we're adding to
if slot.file.name == file.name {
if slot.file.stable_id == file.stable_id {
// See if we already have a line for it
for line_slot in &mut slot.lines {
if line_slot.line_index == line_index {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_expand/src/proc_macro_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ impl server::Span for Rustc<'_, '_> {
let self_loc = self.psess().source_map().lookup_char_pos(first.lo());
let other_loc = self.psess().source_map().lookup_char_pos(second.lo());

if self_loc.file.name != other_loc.file.name {
if self_loc.file.stable_id != other_loc.file.stable_id {
return None;
}

Expand Down
12 changes: 12 additions & 0 deletions compiler/rustc_hir/src/attrs/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,18 @@ pub enum CfgEntry {
Version(Option<RustcVersion>, Span),
}

impl CfgEntry {
pub fn span(&self) -> Span {
let (CfgEntry::All(_, span)
| CfgEntry::Any(_, span)
| CfgEntry::Not(_, span)
| CfgEntry::Bool(_, span)
| CfgEntry::NameValue { span, .. }
| CfgEntry::Version(_, span)) = self;
*span
}
}

/// Possible values for the `#[linkage]` attribute, allowing to specify the
/// linkage type for a `MonoItem`.
///
Expand Down
Loading
Loading