Skip to content
Merged
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
72076c6
move and rename proc_macro::tracked_{env::var,path::path}
Skgland Nov 26, 2025
8d8d702
change proc_macro::tracked::path to take an AsRef<Path> instead of an…
Skgland Nov 26, 2025
f4296bc
fix tests
Skgland Nov 27, 2025
3f67246
fix tests/run-make/track-path-dep-info attempt 2
Skgland Nov 28, 2025
0030e8a
compiler-builtins: Change gating for outline atomic symbols
tgross35 Aug 5, 2025
2105a25
Make the `RUST_LSE_INIT` constructor cross-platform
tgross35 Aug 5, 2025
1ed1b6e
Enable `outline-atomics` by default on AArch64 Windows platforms
tgross35 Sep 5, 2025
c455903
Enable `outline-atomics` by default on AArch64 Android
tgross35 Sep 5, 2025
21525f8
Enable `outline-atomics` by default on AArch64 Fuchsia
tgross35 Sep 5, 2025
66c150c
Enable `outline-atomics` by default on AArch64 OpenBSD
tgross35 Sep 5, 2025
01e2cf8
Handle macro invocation in attribute during parse
estebank Sep 15, 2025
0b0e826
Rework attribute recovery logic
estebank Sep 28, 2025
c1500f9
review comment
estebank Nov 3, 2025
761cb57
fix test
estebank Dec 9, 2025
75df299
Mirror `ubuntu:24.04` on ghcr
Kobzol Dec 9, 2025
2a2da78
add check for uninhabited types along side never
Kivooeo Dec 4, 2025
7637023
Rollup merge of #144938 - tgross35:more-outline-atomics, r=davidtwco
matthiaskrgr Dec 9, 2025
90dc2b6
Rollup merge of #146579 - estebank:issue-146325, r=jdonszelmann
matthiaskrgr Dec 9, 2025
679ab9e
Rollup merge of #149400 - Skgland:tracked_mod, r=Amanieu
matthiaskrgr Dec 9, 2025
6188f82
Rollup merge of #149664 - Kivooeo:infallible-type-unreachable-code, r…
matthiaskrgr Dec 9, 2025
a00807e
Rollup merge of #149806 - Kobzol:mirror-ubuntu-24.04, r=marcoieni
matthiaskrgr Dec 9, 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
2 changes: 2 additions & 0 deletions .github/workflows/ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ jobs:
images=(
# Mirrored because used by the tidy job, which doesn't cache Docker images
"ubuntu:22.04"
# Mirrored because used by x86-64-gnu-miri
"ubuntu:24.04"
# Mirrored because used by all linux CI jobs, including tidy
"moby/buildkit:buildx-stable-1"
# Mirrored because used when CI is running inside a Docker container
Expand Down
13 changes: 13 additions & 0 deletions compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,19 @@ pub enum StmtKind {
MacCall(Box<MacCallStmt>),
}

impl StmtKind {
pub fn descr(&self) -> &'static str {
match self {
StmtKind::Let(_) => "local",
StmtKind::Item(_) => "item",
StmtKind::Expr(_) => "expression",
StmtKind::Semi(_) => "statement",
StmtKind::Empty => "semicolon",
StmtKind::MacCall(_) => "macro call",
}
}
}

#[derive(Clone, Encodable, Decodable, Debug, Walkable)]
pub struct MacCallStmt {
pub mac: Box<MacCall>,
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_attr_parsing/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ attr_parsing_invalid_link_modifier =
attr_parsing_invalid_meta_item = expected a literal (`1u8`, `1.0f32`, `"string"`, etc.) here, found {$descr}
.remove_neg_sugg = negative numbers are not literals, try removing the `-` sign
.quote_ident_sugg = surround the identifier with quotation marks to make it into a string literal
.label = {$descr}s are not allowed here
attr_parsing_invalid_predicate =
invalid predicate `{$predicate}`
Expand Down
68 changes: 45 additions & 23 deletions compiler/rustc_attr_parsing/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ use std::fmt::{Debug, Display};

use rustc_ast::token::{self, Delimiter, MetaVarKind};
use rustc_ast::tokenstream::TokenStream;
use rustc_ast::{AttrArgs, Expr, ExprKind, LitKind, MetaItemLit, NormalAttr, Path};
use rustc_ast::{AttrArgs, Expr, ExprKind, LitKind, MetaItemLit, NormalAttr, Path, StmtKind, UnOp};
use rustc_ast_pretty::pprust;
use rustc_errors::{Diag, PResult};
use rustc_hir::{self as hir, AttrPath};
use rustc_parse::exp;
use rustc_parse::parser::{Parser, PathStyle, token_descr};
use rustc_parse::parser::{ForceCollect, Parser, PathStyle, token_descr};
use rustc_session::errors::{create_lit_error, report_lit_error};
use rustc_session::parse::ParseSess;
use rustc_span::{ErrorGuaranteed, Ident, Span, Symbol, sym};
Expand Down Expand Up @@ -488,33 +488,55 @@ impl<'a, 'sess> MetaItemListParserContext<'a, 'sess> {
descr: token_descr(&self.parser.token),
quote_ident_sugg: None,
remove_neg_sugg: None,
label: None,
};

if let token::OpenInvisible(_) = self.parser.token.kind {
// Do not attempt to suggest anything when encountered as part of a macro expansion.
return self.parser.dcx().create_err(err);
}

// Suggest quoting idents, e.g. in `#[cfg(key = value)]`. We don't use `Token::ident` and
// don't `uninterpolate` the token to avoid suggesting anything butchered or questionable
// when macro metavariables are involved.
if self.parser.prev_token == token::Eq
&& let token::Ident(..) = self.parser.token.kind
{
let before = self.parser.token.span.shrink_to_lo();
while let token::Ident(..) = self.parser.token.kind {
self.parser.bump();
let snapshot = self.parser.create_snapshot_for_diagnostic();
let stmt = self.parser.parse_stmt_without_recovery(false, ForceCollect::No, false);
match stmt {
Ok(Some(stmt)) => {
// The user tried to write something like
// `#[deprecated(note = concat!("a", "b"))]`.
err.descr = stmt.kind.descr().to_string();
err.label = Some(stmt.span);
err.span = stmt.span;
if let StmtKind::Expr(expr) = &stmt.kind
&& let ExprKind::Unary(UnOp::Neg, val) = &expr.kind
&& let ExprKind::Lit(_) = val.kind
{
err.remove_neg_sugg = Some(InvalidMetaItemRemoveNegSugg {
negative_sign: expr.span.until(val.span),
});
} else if let StmtKind::Expr(expr) = &stmt.kind
&& let ExprKind::Path(None, Path { segments, .. }) = &expr.kind
&& segments.len() == 1
{
while let token::Ident(..) | token::Literal(_) | token::Dot =
self.parser.token.kind
{
// We've got a word, so we try to consume the rest of a potential sentence.
// We include `.` to correctly handle things like `A sentence here.`.
self.parser.bump();
}
err.quote_ident_sugg = Some(InvalidMetaItemQuoteIdentSugg {
before: expr.span.shrink_to_lo(),
after: self.parser.prev_token.span.shrink_to_hi(),
});
}
}
Ok(None) => {}
Err(e) => {
e.cancel();
self.parser.restore_snapshot(snapshot);
}
err.quote_ident_sugg = Some(InvalidMetaItemQuoteIdentSugg {
before,
after: self.parser.prev_token.span.shrink_to_hi(),
});
}

if self.parser.token == token::Minus
&& self
.parser
.look_ahead(1, |t| matches!(t.kind, rustc_ast::token::TokenKind::Literal { .. }))
{
err.remove_neg_sugg =
Some(InvalidMetaItemRemoveNegSugg { negative_sign: self.parser.token.span });
self.parser.bump();
self.parser.bump();
}

self.parser.dcx().create_err(err)
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_attr_parsing/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,8 @@ pub(crate) struct InvalidMetaItem {
pub quote_ident_sugg: Option<InvalidMetaItemQuoteIdentSugg>,
#[subdiagnostic]
pub remove_neg_sugg: Option<InvalidMetaItemRemoveNegSugg>,
#[label]
pub label: Option<Span>,
}

#[derive(Subdiagnostic)]
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_fluent_macro/src/fluent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ use fluent_syntax::ast::{
Attribute, Entry, Expression, Identifier, InlineExpression, Message, Pattern, PatternElement,
};
use fluent_syntax::parser::ParserError;
#[cfg(not(bootstrap))]
use proc_macro::tracked::path;
#[cfg(bootstrap)]
use proc_macro::tracked_path::path;
use proc_macro::{Diagnostic, Level, Span};
use proc_macro2::TokenStream;
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_fluent_macro/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// tidy-alphabetical-start
#![allow(rustc::default_hash_types)]
#![cfg_attr(bootstrap, feature(track_path))]
#![cfg_attr(not(bootstrap), feature(proc_macro_tracked_path))]
#![feature(proc_macro_diagnostic)]
#![feature(track_path)]
// tidy-alphabetical-end

use proc_macro::TokenStream;
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_macros/src/current_version.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ struct RustcVersion {

impl RustcVersion {
fn parse_cfg_release(env_var: &str) -> Result<Self, Box<dyn std::error::Error>> {
#[cfg(not(bootstrap))]
let value = proc_macro::tracked::env_var(env_var)?;
#[cfg(bootstrap)]
let value = proc_macro::tracked_env::var(env_var)?;

Self::parse_str(&value)
.ok_or_else(|| format!("failed to parse rustc version: {:?}", value).into())
}
Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_macros/src/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,13 @@ fn symbols_with_errors(input: TokenStream) -> (TokenStream, Vec<syn::Error>) {
break;
}

let value = match proc_macro::tracked_env::var(env_var.value()) {
#[cfg(bootstrap)]
let tracked_env = proc_macro::tracked_env::var(env_var.value());

#[cfg(not(bootstrap))]
let tracked_env = proc_macro::tracked::env_var(env_var.value());

let value = match tracked_env {
Ok(value) => value,
Err(err) => {
errors.list.push(syn::Error::new_spanned(expr, err));
Expand Down
21 changes: 20 additions & 1 deletion compiler/rustc_mir_build/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,25 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
self.infcx.typing_env(self.param_env),
);

// check if the function's return type is inhabited
// this was added here because of this regression
// https://github.com/rust-lang/rust/issues/149571
let output_is_inhabited =
if matches!(self.tcx.def_kind(self.def_id), DefKind::Fn | DefKind::AssocFn) {
self.tcx
.fn_sig(self.def_id)
.instantiate_identity()
.skip_binder()
.output()
.is_inhabited_from(
self.tcx,
self.parent_module,
self.infcx.typing_env(self.param_env),
)
} else {
true
};

if !ty_is_inhabited {
// Unreachable code warnings are already emitted during type checking.
// However, during type checking, full type information is being
Expand All @@ -849,7 +868,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
// uninhabited types (e.g. empty enums). The check above is used so
// that we do not emit the same warning twice if the uninhabited type
// is indeed `!`.
if !ty.is_never() {
if !ty.is_never() && output_is_inhabited {
lints.push((target_bb, ty, term.source_info.span));
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/parser/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ impl<'a> Parser<'a> {
}

/// Replace `self` with `snapshot.parser`.
pub(super) fn restore_snapshot(&mut self, snapshot: SnapshotParser<'a>) {
pub fn restore_snapshot(&mut self, snapshot: SnapshotParser<'a>) {
*self = snapshot.parser;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub(crate) fn target() -> Target {
max_atomic_width: Some(128),
// As documented in https://developer.android.com/ndk/guides/cpu-features.html
// the neon (ASIMD) and FP must exist on all android aarch64 targets.
features: "+v8a,+neon".into(),
features: "+v8a,+neon,+outline-atomics".into(),
// the AAPCS64 expects use of non-leaf frame pointers per
// https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer
// and we tend to encounter interesting bugs in AArch64 unwinding code if we do not
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::spec::{Arch, Cc, FramePointer, LinkerFlavor, Lld, Target, TargetMetad
pub(crate) fn target() -> Target {
let mut base = base::windows_gnullvm::opts();
base.max_atomic_width = Some(128);
base.features = "+v8a,+neon".into();
base.features = "+v8a,+neon,+outline-atomics".into();
base.linker = Some("aarch64-w64-mingw32-clang".into());
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &["-m", "arm64pe"]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::spec::{Arch, FramePointer, Target, TargetMetadata, base};
pub(crate) fn target() -> Target {
let mut base = base::windows_msvc::opts();
base.max_atomic_width = Some(128);
base.features = "+v8a,+neon".into();
base.features = "+v8a,+neon,+outline-atomics".into();

// Microsoft recommends enabling frame pointers on Arm64 Windows.
// From https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#integer-registers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::spec::{
pub(crate) fn target() -> Target {
let mut base = base::fuchsia::opts();
base.cpu = "generic".into();
base.features = "+v8a,+crc,+aes,+sha2,+neon".into();
base.features = "+v8a,+crc,+aes,+sha2,+neon,+outline-atomics".into();
base.max_atomic_width = Some(128);
base.stack_probes = StackProbeType::Inline;
base.supported_sanitizers = SanitizerSet::ADDRESS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub(crate) fn target() -> Target {
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
arch: Arch::AArch64,
options: TargetOptions {
features: "+v8a".into(),
features: "+v8a,+outline-atomics".into(),
max_atomic_width: Some(128),
stack_probes: StackProbeType::Inline,
..base::openbsd::opts()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ macro_rules! compare_and_swap {
"cbnz w17, 0b",
"1:",
"ret",
have_lse = sym crate::aarch64_linux::HAVE_LSE_ATOMICS,
have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS,
}
}
}
Expand Down Expand Up @@ -228,7 +228,7 @@ macro_rules! compare_and_swap_i128 {
"cbnz w15, 0b",
"1:",
"ret",
have_lse = sym crate::aarch64_linux::HAVE_LSE_ATOMICS,
have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS,
}
}
}
Expand Down Expand Up @@ -256,7 +256,7 @@ macro_rules! swap {
concat!(stxr!($ordering, $bytes), " w17, ", reg!($bytes, 16), ", [x1]"),
"cbnz w17, 0b",
"ret",
have_lse = sym crate::aarch64_linux::HAVE_LSE_ATOMICS,
have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS,
}
}
}
Expand Down Expand Up @@ -286,7 +286,7 @@ macro_rules! fetch_op {
concat!(stxr!($ordering, $bytes), " w15, ", reg!($bytes, 17), ", [x1]"),
"cbnz w15, 0b",
"ret",
have_lse = sym crate::aarch64_linux::HAVE_LSE_ATOMICS,
have_lse = sym crate::aarch64_outline_atomics::HAVE_LSE_ATOMICS,
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions library/compiler-builtins/compiler-builtins/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ pub mod arm;
#[cfg(any(target_arch = "aarch64", target_arch = "arm64ec"))]
pub mod aarch64;

#[cfg(all(target_arch = "aarch64", target_os = "linux"))]
pub mod aarch64_linux;
#[cfg(all(target_arch = "aarch64", target_feature = "outline-atomics"))]
pub mod aarch64_outline_atomics;

#[cfg(all(
kernel_user_helpers,
Expand Down
27 changes: 14 additions & 13 deletions library/proc_macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1594,37 +1594,38 @@ impl fmt::Debug for Literal {
}
}

/// Tracked access to environment variables.
#[unstable(feature = "proc_macro_tracked_env", issue = "99515")]
pub mod tracked_env {
#[unstable(
feature = "proc_macro_tracked_path",
issue = "99515",
implied_by = "proc_macro_tracked_env"
)]
/// Functionality for adding environment state to the build dependency info.
pub mod tracked {

use std::env::{self, VarError};
use std::ffi::OsStr;
use std::path::Path;

/// Retrieve an environment variable and add it to build dependency info.
/// The build system executing the compiler will know that the variable was accessed during
/// compilation, and will be able to rerun the build when the value of that variable changes.
/// Besides the dependency tracking this function should be equivalent to `env::var` from the
/// standard library, except that the argument must be UTF-8.
#[unstable(feature = "proc_macro_tracked_env", issue = "99515")]
pub fn var<K: AsRef<OsStr> + AsRef<str>>(key: K) -> Result<String, VarError> {
pub fn env_var<K: AsRef<OsStr> + AsRef<str>>(key: K) -> Result<String, VarError> {
let key: &str = key.as_ref();
let value = crate::bridge::client::FreeFunctions::injected_env_var(key)
.map_or_else(|| env::var(key), Ok);
crate::bridge::client::FreeFunctions::track_env_var(key, value.as_deref().ok());
value
}
}

/// Tracked access to additional files.
#[unstable(feature = "track_path", issue = "99515")]
pub mod tracked_path {

/// Track a file explicitly.
/// Track a file or directory explicitly.
///
/// Commonly used for tracking asset preprocessing.
#[unstable(feature = "track_path", issue = "99515")]
pub fn path<P: AsRef<str>>(path: P) {
let path: &str = path.as_ref();
#[unstable(feature = "proc_macro_tracked_path", issue = "99515")]
pub fn path<P: AsRef<Path>>(path: P) {
let path: &str = path.as_ref().to_str().unwrap();
crate::bridge::client::FreeFunctions::track_path(path);
}
}
Loading
Loading