Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ca5a254
rustdoc: change getVar signature
lolbinarycat Jan 19, 2026
b7ba80d
rustdoc(storage.js): add comment explaining use of @ts-ignore
lolbinarycat Jan 19, 2026
760d886
rustdoc(main.js): use instanceof instead of tagName where applicable
lolbinarycat Jan 19, 2026
38d7b53
rustdoc(main.js): use nonnull to clear up type errors
lolbinarycat Jan 19, 2026
3b4de4b
rustdoc: make TypeImpls more specific.
lolbinarycat Jan 19, 2026
519c0d9
rustdoc: remove redundant mainContent variable
lolbinarycat Jan 19, 2026
bd1c36a
rustdoc(main.js): use typeof in register_type_impls for isTrait
lolbinarycat Jan 28, 2026
73d06be
Set hidden visibility on naked functions in compiler-builtins
zmodem Jan 22, 2026
baca864
Set hidden visibility for compiler-builtins statics too.
zmodem Feb 4, 2026
a8d7a47
improve associated-type suggestions from bounds
JohnTitor Feb 11, 2026
391a395
Improve diagnostics following reviews
JohnTitor Feb 13, 2026
a187245
nix-dev-shell: fix a typo
makai410 Feb 13, 2026
4796ff1
move `escape_symbol_name` to `cg_ssa`
usamoi Feb 13, 2026
b4f38c1
add regression test
lcnr Feb 13, 2026
b3d9fbc
ICE to delayed bug
lcnr Feb 13, 2026
c61c260
Port `#[lang]` to the new attribute parsers
JonathanBrouwer Feb 13, 2026
ee8ca0a
Port `#[panic_handler]` to the new attribute parsers
JonathanBrouwer Feb 13, 2026
c43a33e
Feed `ErrorGuaranteed` from late lifetime resolution to RBV
eggyal Feb 3, 2026
be204dd
make per-point liveness accessible
lqd Feb 13, 2026
65eb2e7
add another NLL problem case 3 variant
lqd Feb 13, 2026
dca86a9
rustdoc: sort stable items first
lolbinarycat Nov 29, 2025
cc9e8c9
c-variadic: implement `va_arg` for `wasm64`
folkertdev Feb 13, 2026
4571317
Rollup merge of #151998 - zmodem:naked_visibility.squash, r=saethlin,…
jhpratt Feb 14, 2026
9b4219b
Rollup merge of #149460 - lolbinarycat:rustdoc-search-sort-stable-fir…
jhpratt Feb 14, 2026
000d1f1
Rollup merge of #152076 - eggyal:undeclared-object-lifetime, r=fmease
jhpratt Feb 14, 2026
b805124
Rollup merge of #152471 - JohnTitor:sugg-assoc-items-from-bounds, r=e…
jhpratt Feb 14, 2026
202f102
Rollup merge of #152573 - usamoi:escape-2, r=bjorn3
jhpratt Feb 14, 2026
61dee57
Rollup merge of #152594 - folkertdev:va-list-wasm64, r=alexcrichton
jhpratt Feb 14, 2026
9f3f83b
Rollup merge of #151386 - lolbinarycat:rustdoc-ts-cleanup, r=Guillaum…
jhpratt Feb 14, 2026
7719d63
Rollup merge of #152567 - makai410:nix-typo, r=WaffleLapkin
jhpratt Feb 14, 2026
22f973d
Rollup merge of #152568 - JonathanBrouwer:port_lang, r=jdonszelmann
jhpratt Feb 14, 2026
8125a56
Rollup merge of #152575 - lcnr:layout-error-to-delayed-bug, r=jackh726
jhpratt Feb 14, 2026
4bcbf62
Rollup merge of #152587 - lqd:tiny-things, r=jackh726
jhpratt Feb 14, 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
56 changes: 30 additions & 26 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {

(hir::ParamName::Fresh, hir::LifetimeParamKind::Elided(kind))
}
LifetimeRes::Static { .. } | LifetimeRes::Error => return None,
LifetimeRes::Static { .. } | LifetimeRes::Error(..) => return None,
res => panic!(
"Unexpected lifetime resolution {:?} for {:?} at {:?}",
res, ident, ident.span
Expand Down Expand Up @@ -1931,26 +1931,29 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
source: LifetimeSource,
syntax: LifetimeSyntax,
) -> &'hir hir::Lifetime {
let res = self.resolver.get_lifetime_res(id).unwrap_or(LifetimeRes::Error);
let res = match res {
LifetimeRes::Param { param, .. } => hir::LifetimeKind::Param(param),
LifetimeRes::Fresh { param, .. } => {
assert_eq!(ident.name, kw::UnderscoreLifetime);
let param = self.local_def_id(param);
hir::LifetimeKind::Param(param)
}
LifetimeRes::Infer => {
assert_eq!(ident.name, kw::UnderscoreLifetime);
hir::LifetimeKind::Infer
}
LifetimeRes::Static { .. } => {
assert!(matches!(ident.name, kw::StaticLifetime | kw::UnderscoreLifetime));
hir::LifetimeKind::Static
}
LifetimeRes::Error => hir::LifetimeKind::Error,
LifetimeRes::ElidedAnchor { .. } => {
panic!("Unexpected `ElidedAnchar` {:?} at {:?}", ident, ident.span);
let res = if let Some(res) = self.resolver.get_lifetime_res(id) {
match res {
LifetimeRes::Param { param, .. } => hir::LifetimeKind::Param(param),
LifetimeRes::Fresh { param, .. } => {
assert_eq!(ident.name, kw::UnderscoreLifetime);
let param = self.local_def_id(param);
hir::LifetimeKind::Param(param)
}
LifetimeRes::Infer => {
assert_eq!(ident.name, kw::UnderscoreLifetime);
hir::LifetimeKind::Infer
}
LifetimeRes::Static { .. } => {
assert!(matches!(ident.name, kw::StaticLifetime | kw::UnderscoreLifetime));
hir::LifetimeKind::Static
}
LifetimeRes::Error(guar) => hir::LifetimeKind::Error(guar),
LifetimeRes::ElidedAnchor { .. } => {
panic!("Unexpected `ElidedAnchar` {:?} at {:?}", ident, ident.span);
}
}
} else {
hir::LifetimeKind::Error(self.dcx().span_delayed_bug(ident.span, "unresolved lifetime"))
};

debug!(?res);
Expand Down Expand Up @@ -2014,12 +2017,13 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
// AST resolution emitted an error on those parameters, so we lower them using
// `ParamName::Error`.
let ident = self.lower_ident(param.ident);
let param_name =
if let Some(LifetimeRes::Error) = self.resolver.get_lifetime_res(param.id) {
ParamName::Error(ident)
} else {
ParamName::Plain(ident)
};
let param_name = if let Some(LifetimeRes::Error(..)) =
self.resolver.get_lifetime_res(param.id)
{
ParamName::Error(ident)
} else {
ParamName::Plain(ident)
};
let kind =
hir::GenericParamKind::Lifetime { kind: hir::LifetimeParamKind::Explicit };

Expand Down
38 changes: 37 additions & 1 deletion compiler/rustc_attr_parsing/src/attributes/rustc_internal.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::path::PathBuf;

use rustc_ast::{LitIntType, LitKind, MetaItemLit};
use rustc_hir::LangItem;
use rustc_hir::attrs::{
BorrowckGraphvizFormatKind, CguFields, CguKind, DivergingBlockBehavior,
DivergingFallbackBehavior, RustcCleanAttribute, RustcCleanQueries, RustcLayoutType,
Expand All @@ -12,7 +13,7 @@ use rustc_span::Symbol;
use super::prelude::*;
use super::util::parse_single_integer;
use crate::session_diagnostics::{
AttributeRequiresOpt, CguFieldsMissing, RustcScalableVectorCountOutOfRange,
AttributeRequiresOpt, CguFieldsMissing, RustcScalableVectorCountOutOfRange, UnknownLangItem,
};

pub(crate) struct RustcMainParser;
Expand Down Expand Up @@ -626,6 +627,32 @@ impl<S: Stage> SingleAttributeParser<S> for RustcScalableVectorParser {
}
}

pub(crate) struct LangParser;

impl<S: Stage> SingleAttributeParser<S> for LangParser {
const PATH: &[Symbol] = &[sym::lang];
const ATTRIBUTE_ORDER: AttributeOrder = AttributeOrder::KeepInnermost;
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS); // Targets are checked per lang item in `rustc_passes`
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;
};
let Some(lang_item) = LangItem::from_name(name) else {
cx.emit_err(UnknownLangItem { span: cx.attr_span, name });
return None;
};
Some(AttributeKind::Lang(lang_item, cx.attr_span))
}
}

pub(crate) struct RustcHasIncoherentInherentImplsParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcHasIncoherentInherentImplsParser {
Expand All @@ -641,6 +668,15 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcHasIncoherentInherentImplsParse
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcHasIncoherentInherentImpls;
}

pub(crate) struct PanicHandlerParser;

impl<S: Stage> NoArgsAttributeParser<S> for PanicHandlerParser {
const PATH: &[Symbol] = &[sym::panic_handler];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(ALL_TARGETS); // Targets are checked per lang item in `rustc_passes`
const CREATE: fn(Span) -> AttributeKind = |span| AttributeKind::Lang(LangItem::PanicImpl, span);
}

pub(crate) struct RustcHiddenTypeOfOpaquesParser;

impl<S: Stage> NoArgsAttributeParser<S> for RustcHiddenTypeOfOpaquesParser {
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ attribute_parsers!(
Single<IgnoreParser>,
Single<InlineParser>,
Single<InstructionSetParser>,
Single<LangParser>,
Single<LinkNameParser>,
Single<LinkOrdinalParser>,
Single<LinkSectionParser>,
Expand Down Expand Up @@ -254,6 +255,7 @@ attribute_parsers!(
Single<WithoutArgs<NoMangleParser>>,
Single<WithoutArgs<NoStdParser>>,
Single<WithoutArgs<NonExhaustiveParser>>,
Single<WithoutArgs<PanicHandlerParser>>,
Single<WithoutArgs<PanicRuntimeParser>>,
Single<WithoutArgs<ParenSugarParser>>,
Single<WithoutArgs<PassByValueParser>>,
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_attr_parsing/src/session_diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,15 @@ pub(crate) struct DocAliasMalformed {
pub span: Span,
}

#[derive(Diagnostic)]
#[diag("definition of an unknown lang item: `{$name}`", code = E0522)]
pub(crate) struct UnknownLangItem {
#[primary_span]
#[label("definition of unknown lang item `{$name}`")]
pub span: Span,
pub name: Symbol,
}

#[derive(Diagnostic)]
#[diag("target `{$current_target}` does not support `#[instruction_set({$instruction_set}::*)]`")]
pub(crate) struct UnsupportedInstructionSet<'a> {
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_borrowck/src/polonius/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,7 @@ impl LocalizedConstraintGraphVisitor for LoanLivenessVisitor<'_> {
//
// FIXME: analyze potential unsoundness, possibly in concert with a borrowck
// implementation in a-mir-formality, fuzzing, or manually crafting counter-examples.
let location = self.liveness.location_from_point(node.point);
if self.liveness.is_live_at(node.region, location) {
if self.liveness.is_live_at_point(node.region, node.point) {
self.live_loans.insert(node.point, loan);
}
}
Expand Down
10 changes: 9 additions & 1 deletion compiler/rustc_borrowck/src/region_infer/values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,17 @@ impl LivenessValues {
}
}

/// Returns whether `region` is marked live at the given `location`.
/// Returns whether `region` is marked live at the given
/// [`location`][rustc_middle::mir::Location].
pub(crate) fn is_live_at(&self, region: RegionVid, location: Location) -> bool {
let point = self.location_map.point_from_location(location);
self.is_live_at_point(region, point)
}

/// Returns whether `region` is marked live at the given
/// [`point`][rustc_mir_dataflow::points::PointIndex].
#[inline]
pub(crate) fn is_live_at_point(&self, region: RegionVid, point: PointIndex) -> bool {
if let Some(points) = &self.points {
points.row(region).is_some_and(|r| r.contains(point))
} else {
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_codegen_cranelift/src/global_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ fn codegen_global_asm_inner<'tcx>(
match *piece {
InlineAsmTemplatePiece::String(ref s) => global_asm.push_str(s),
InlineAsmTemplatePiece::Placeholder { operand_idx, modifier: _, span } => {
use rustc_codegen_ssa::back::symbol_export::escape_symbol_name;
match operands[operand_idx] {
GlobalAsmOperandRef::Const { ref string } => {
global_asm.push_str(string);
Expand All @@ -121,7 +122,7 @@ fn codegen_global_asm_inner<'tcx>(
let symbol = tcx.symbol_name(instance);
// FIXME handle the case where the function was made private to the
// current codegen unit
global_asm.push_str(symbol.name);
global_asm.push_str(&escape_symbol_name(tcx, symbol.name, span));
}
GlobalAsmOperandRef::SymStatic { def_id } => {
if cfg!(not(feature = "inline_asm_sym")) {
Expand All @@ -133,7 +134,7 @@ fn codegen_global_asm_inner<'tcx>(

let instance = Instance::mono(tcx, def_id);
let symbol = tcx.symbol_name(instance);
global_asm.push_str(symbol.name);
global_asm.push_str(&escape_symbol_name(tcx, symbol.name, span));
}
}
}
Expand Down
44 changes: 3 additions & 41 deletions compiler/rustc_codegen_llvm/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ impl<'tcx> AsmCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
match *piece {
InlineAsmTemplatePiece::String(ref s) => template_str.push_str(s),
InlineAsmTemplatePiece::Placeholder { operand_idx, modifier: _, span } => {
use rustc_codegen_ssa::back::symbol_export::escape_symbol_name;
match operands[operand_idx] {
GlobalAsmOperandRef::Const { ref string } => {
// Const operands get injected directly into the
Expand All @@ -414,7 +415,7 @@ impl<'tcx> AsmCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
llvm::LLVMRustGetMangledName(llval, s);
})
.expect("symbol is not valid UTF-8");
template_str.push_str(&escape_symbol_name(self, symbol, span));
template_str.push_str(&escape_symbol_name(self.tcx, &symbol, span));
}
GlobalAsmOperandRef::SymStatic { def_id } => {
let llval = self
Expand All @@ -428,7 +429,7 @@ impl<'tcx> AsmCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
llvm::LLVMRustGetMangledName(llval, s);
})
.expect("symbol is not valid UTF-8");
template_str.push_str(&escape_symbol_name(self, symbol, span));
template_str.push_str(&escape_symbol_name(self.tcx, &symbol, span));
}
}
}
Expand Down Expand Up @@ -1390,42 +1391,3 @@ fn llvm_fixup_output_type<'ll, 'tcx>(
_ => layout.llvm_type(cx),
}
}

fn escape_symbol_name<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>, symbol: String, span: Span) -> String {
use rustc_target::spec::{Arch, BinaryFormat};
if !symbol.is_empty()
&& symbol.chars().all(|c| matches!(c, '0'..='9' | 'A'..='Z' | 'a'..='z' | '_' | '$' | '.'))
{
return symbol;
}
if cx.tcx.sess.target.binary_format == BinaryFormat::Xcoff {
cx.tcx.sess.dcx().span_fatal(
span,
format!(
"symbol escaping is not supported for the binary format {}",
cx.tcx.sess.target.binary_format
),
);
}
if cx.tcx.sess.target.arch == Arch::Nvptx64 {
cx.tcx.sess.dcx().span_fatal(
span,
format!(
"symbol escaping is not supported for the architecture {}",
cx.tcx.sess.target.arch
),
);
}
let mut escaped_symbol = String::new();
escaped_symbol.push('\"');
for c in symbol.chars() {
match c {
'\n' => escaped_symbol.push_str("\\\n"),
'"' => escaped_symbol.push_str("\\\""),
'\\' => escaped_symbol.push_str("\\\\"),
c => escaped_symbol.push(c),
}
}
escaped_symbol.push('\"');
escaped_symbol
}
26 changes: 15 additions & 11 deletions compiler/rustc_codegen_llvm/src/mono_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ impl<'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
});

llvm::set_linkage(g, base::linkage_to_llvm(linkage));
llvm::set_visibility(g, base::visibility_to_llvm(visibility));
self.set_visibility(g, linkage, visibility);

self.assume_dso_local(g, false);

let attrs = self.tcx.codegen_instance_attrs(instance.def);
Expand Down Expand Up @@ -69,16 +70,7 @@ impl<'tcx> PreDefineCodegenMethods<'tcx> for CodegenCx<'_, 'tcx> {
{
llvm::SetUniqueComdat(self.llmod, lldecl);
}

// If we're compiling the compiler-builtins crate, e.g., the equivalent of
// compiler-rt, then we want to implicitly compile everything with hidden
// visibility as we're going to link this object all over the place but
// don't want the symbols to get exported.
if linkage != Linkage::Internal && self.tcx.is_compiler_builtins(LOCAL_CRATE) {
llvm::set_visibility(lldecl, llvm::Visibility::Hidden);
} else {
llvm::set_visibility(lldecl, base::visibility_to_llvm(visibility));
}
self.set_visibility(lldecl, linkage, visibility);

debug!("predefine_fn: instance = {:?}", instance);

Expand Down Expand Up @@ -122,6 +114,18 @@ impl CodegenCx<'_, '_> {
assume
}

fn set_visibility(&self, lldecl: &llvm::Value, linkage: Linkage, visibility: Visibility) {
// If we're compiling the compiler-builtins crate, i.e., the equivalent of
// compiler-rt, then we want to implicitly compile everything with hidden
// visibility as we're going to link this object all over the place but
// don't want the symbols to get exported.
if linkage != Linkage::Internal && self.tcx.is_compiler_builtins(LOCAL_CRATE) {
llvm::set_visibility(lldecl, llvm::Visibility::Hidden);
} else {
llvm::set_visibility(lldecl, base::visibility_to_llvm(visibility));
}
}

fn should_assume_dso_local(&self, llval: &llvm::Value, is_declaration: bool) -> bool {
let linkage = llvm::get_linkage(llval);
let visibility = llvm::get_visibility(llval);
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_llvm/src/va_arg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ pub(super) fn emit_va_arg<'ll, 'tcx>(
AllowHigherAlign::Yes,
ForceRightAdjust::No,
),
Arch::Wasm32 => emit_ptr_va_arg(
Arch::Wasm32 | Arch::Wasm64 => emit_ptr_va_arg(
bx,
addr,
target_ty,
Expand All @@ -1135,7 +1135,6 @@ pub(super) fn emit_va_arg<'ll, 'tcx>(
AllowHigherAlign::Yes,
ForceRightAdjust::No,
),
Arch::Wasm64 => bug!("c-variadic functions are not fully implemented for wasm64"),
Arch::CSky => emit_ptr_va_arg(
bx,
addr,
Expand Down
Loading
Loading