Skip to content

Rollup of 7 pull requests #143434

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 50 commits into from
Jul 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
10c9537
Preparing for merge from rustc
invalid-email-address Jun 26, 2025
fdf44db
Merge from rustc
invalid-email-address Jun 26, 2025
fe2fd8a
Merge pull request #2479 from rust-lang/rustc-pull
tshepang Jun 26, 2025
005dd43
Add `arguments sharing and isolation` section in `diagnostic-struct` …
xizheyin Jun 26, 2025
e8ff13c
Fix typo
xizheyin Jun 27, 2025
61dafd7
Merge pull request #2480 from xizheyin/argument-sharing-and-isolation
oli-obk Jun 27, 2025
98c3470
Add a link to rust-forge to explain where rdg changes should be submi…
xizheyin Jun 26, 2025
84abd4e
Merge pull request #2481 from xizheyin/submit-in-rdg-or-r
tshepang Jun 28, 2025
e9721a6
Add broken `./x test library/std` advisory
jieyouxu Jun 29, 2025
5628341
Merge pull request #2482 from jieyouxu/download-rustc
Kobzol Jun 29, 2025
787a4cc
build-fail directive: make explanation more uniform
tshepang Jun 30, 2025
390d1be
update AST-to-HIR lowering examples for conditionals and loops
dianne Jun 30, 2025
67e53f2
Merge pull request #2485 from dianne/update-cond-loop-desugaring
Noratrieb Jun 30, 2025
e82121f
Merge pull request #2483 from rust-lang/tshepang-patch-1
jieyouxu Jul 1, 2025
6bef238
refactor: Make -Ztrack-diagnostics emit like a note
Muscraft Jun 3, 2025
2b22d0f
Make __rust_alloc_error_handler_should_panic a function
dpaoliello Jul 3, 2025
35453a8
Add tidy-alphabetical for cross-crate attribute match
GrigorenkoPV Jul 3, 2025
e2e3f58
Remove PointerLike trait
compiler-errors Jul 3, 2025
ef4dece
Port `#[rustc_pass_by_value]` to the new attribute system
GrigorenkoPV Jun 15, 2025
90d54a1
adjust docs, after splitting up autodiff into two forward and reverse…
ZuseZ4 Jul 3, 2025
3fd6613
Merge pull request #2488 from rust-lang/autodiff-doc-updates
ZuseZ4 Jul 3, 2025
d0130ae
refactor: add `Tables<'tcx, B: Bridge>` and `SmirContainer`
makai410 May 5, 2025
7f5e382
refactor: make `SmirInterface` a trait and impl it for `SmirContainer`
makai410 May 5, 2025
3a43ed2
refactor: move `IndexedVal` from `stable_mir` to `rustc_smir`
makai410 May 5, 2025
96ad388
refactor: impl `SmirError` for `stable_mir::Error`
makai410 May 5, 2025
3b328e1
refactor: split `rustc_smir::alloc` into two parts
makai410 May 5, 2025
0f6f683
refactor: rewrite the whole `rustc_smir::context`
makai410 May 5, 2025
663e2b7
refactor: move `convert` module to `stable_mir`
makai410 May 5, 2025
6916089
fix: rewrite some parts of `rustc_smir::builder.rs`
makai410 May 5, 2025
45cf29d
refactor: remove the `tcx` field in `Tables`
makai410 May 6, 2025
62d6031
refactor: unify `Tables` implementation with bridge types and re-expo…
makai410 May 11, 2025
b5a2e7d
refactor: move `IndexMap` to `rustc_smir`
makai410 May 11, 2025
efa26e1
fix: resolve the unsoundness
makai410 Jun 9, 2025
a61e508
refactor: move `convert` to `unstable`
makai410 Jun 9, 2025
e3f2096
refactor: avoid calling internal functions in `predicates_of()` and `…
makai410 Jun 9, 2025
b7be9cd
refactor: don't use rustc_type_ir directly
makai410 Jun 21, 2025
854292d
refactor: rewrite `adt_repr()`, `adt_discr_for_variant()` and `corout…
makai410 Jun 21, 2025
e26ae60
refactor: implement a new bridge trait `Allocation`
makai410 Jun 25, 2025
e631555
bump termize dep
klensy Jul 4, 2025
9345940
Add josh-sync config file
Kobzol Jul 4, 2025
ac1a8b3
Prepare for merging from rust-lang/rust
Kobzol Jul 4, 2025
c33dd1b
Merge ref 'c96a69059ecc' from rust-lang/rust
Kobzol Jul 4, 2025
ad97597
Merge pull request #2489 from Kobzol/pull
jieyouxu Jul 4, 2025
da25619
Rollup merge of #140643 - makai410:smir-refactor-migrate, r=oli-obk,c…
matthiaskrgr Jul 4, 2025
324aa5d
Rollup merge of #143286 - Muscraft:track-diagnostics-note, r=WaffleLa…
matthiaskrgr Jul 4, 2025
18b374d
Rollup merge of #143308 - compiler-errors:no-pointer-like, r=oli-obk
matthiaskrgr Jul 4, 2025
2faf66d
Rollup merge of #143387 - dpaoliello:shouldpanicfn, r=bjorn3
matthiaskrgr Jul 4, 2025
f3e7ec5
Rollup merge of #143400 - GrigorenkoPV:attributes/lints, r=jdonszelmann
matthiaskrgr Jul 4, 2025
8e4cca8
Rollup merge of #143417 - klensy:termize, r=jieyouxu
matthiaskrgr Jul 4, 2025
3a5da6c
Rollup merge of #143420 - Kobzol:rdg-push, r=jieyouxu
matthiaskrgr Jul 4, 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
16 changes: 13 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ dependencies = [
"serde_json",
"syn 2.0.104",
"tempfile",
"termize",
"termize 0.1.1",
"tokio",
"toml 0.7.8",
"ui_test",
Expand Down Expand Up @@ -3761,7 +3761,7 @@ dependencies = [
"serde",
"serde_json",
"termcolor",
"termize",
"termize 0.2.0",
"tracing",
"windows 0.61.3",
]
Expand Down Expand Up @@ -4522,7 +4522,7 @@ dependencies = [
"rustc_serialize",
"rustc_span",
"rustc_target",
"termize",
"termize 0.2.0",
"tracing",
"windows 0.61.3",
]
Expand Down Expand Up @@ -5294,6 +5294,16 @@ dependencies = [
"winapi",
]

[[package]]
name = "termize"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a8da106d1a19c5b9c53c03311936568a0439926a7607815bd3461139cbab1cc"
dependencies = [
"libc",
"windows-sys 0.60.2",
]

[[package]]
name = "test-float-parse"
version = "0.1.0"
Expand Down
12 changes: 1 addition & 11 deletions compiler/rustc_abi/src/layout/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_macros::HashStable_Generic;

use crate::{
AbiAlign, Align, BackendRepr, FieldsShape, Float, HasDataLayout, LayoutData, Niche,
PointeeInfo, Primitive, Scalar, Size, TargetDataLayout, Variants,
PointeeInfo, Primitive, Size, Variants,
};

// Explicitly import `Float` to avoid ambiguity with `Primitive::Float`.
Expand Down Expand Up @@ -115,16 +115,6 @@ impl<'a> Layout<'a> {
pub fn unadjusted_abi_align(self) -> Align {
self.0.0.unadjusted_abi_align
}

/// Whether the layout is from a type that implements [`std::marker::PointerLike`].
///
/// Currently, that means that the type is pointer-sized, pointer-aligned,
/// and has a initialized (non-union), scalar ABI.
pub fn is_pointer_like(self, data_layout: &TargetDataLayout) -> bool {
self.size() == data_layout.pointer_size
&& self.align().abi == data_layout.pointer_align.abi
&& matches!(self.backend_repr(), BackendRepr::Scalar(Scalar::Initialized { .. }))
}
}

/// The layout of a type, alongside the type itself.
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_attr_data_structures/src/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ pub enum AttributeKind {
/// Represents `#[optimize(size|speed)]`
Optimize(OptimizeAttr, Span),

/// Represents `#[rustc_pass_by_value]` (used by the `rustc_pass_by_value` lint).
PassByValue(Span),

/// Represents `#[rustc_pub_transparent]` (used by the `repr_transparent_external_private_fields` lint).
PubTransparent(Span),

Expand Down
15 changes: 9 additions & 6 deletions compiler/rustc_attr_data_structures/src/encode_cross_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,43 @@ impl AttributeKind {
use EncodeCrossCrate::*;

match self {
// tidy-alphabetical-start
Align { .. } => No,
AllowConstFnUnstable(..) => No,
AllowInternalUnstable(..) => Yes,
AsPtr(..) => Yes,
BodyStability { .. } => No,
Cold(..) => No,
Confusables { .. } => Yes,
ConstContinue(..) => No,
ConstStability { .. } => Yes,
ConstStabilityIndirect => No,
Deprecation { .. } => Yes,
DocComment { .. } => Yes,
ExportName { .. } => Yes,
Inline(..) => No,
LinkSection { .. } => No,
MacroTransparency(..) => Yes,
Repr(..) => No,
Stability { .. } => Yes,
Cold(..) => No,
ConstContinue(..) => No,
LinkName { .. } => Yes,
LinkSection { .. } => No,
LoopMatch(..) => No,
MacroTransparency(..) => Yes,
MayDangle(..) => No,
MustUse { .. } => Yes,
Naked(..) => No,
NoImplicitPrelude(..) => No,
NoMangle(..) => No,
Optimize(..) => No,
PassByValue(..) => Yes,
PubTransparent(..) => Yes,
Repr(..) => No,
RustcLayoutScalarValidRangeEnd(..) => Yes,
RustcLayoutScalarValidRangeStart(..) => Yes,
RustcObjectLifetimeDefault => No,
SkipDuringMethodDispatch { .. } => No,
Stability { .. } => Yes,
TargetFeature(..) => No,
TrackCaller(..) => Yes,
Used { .. } => No,
// tidy-alphabetical-end
}
}
}
7 changes: 7 additions & 0 deletions compiler/rustc_attr_parsing/src/attributes/lint_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,10 @@ impl<S: Stage> NoArgsAttributeParser<S> for PubTransparentParser {
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const CREATE: fn(Span) -> AttributeKind = AttributeKind::PubTransparent;
}

pub(crate) struct PassByValueParser;
impl<S: Stage> NoArgsAttributeParser<S> for PassByValueParser {
const PATH: &[Symbol] = &[sym::rustc_pass_by_value];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const CREATE: fn(Span) -> AttributeKind = AttributeKind::PassByValue;
}
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 @@ -23,7 +23,7 @@ use crate::attributes::confusables::ConfusablesParser;
use crate::attributes::deprecation::DeprecationParser;
use crate::attributes::inline::{InlineParser, RustcForceInlineParser};
use crate::attributes::link_attrs::{LinkNameParser, LinkSectionParser};
use crate::attributes::lint_helpers::{AsPtrParser, PubTransparentParser};
use crate::attributes::lint_helpers::{AsPtrParser, PassByValueParser, PubTransparentParser};
use crate::attributes::loop_match::{ConstContinueParser, LoopMatchParser};
use crate::attributes::must_use::MustUseParser;
use crate::attributes::no_implicit_prelude::NoImplicitPreludeParser;
Expand Down Expand Up @@ -144,6 +144,7 @@ attribute_parsers!(
Single<WithoutArgs<MayDangleParser>>,
Single<WithoutArgs<NoImplicitPreludeParser>>,
Single<WithoutArgs<NoMangleParser>>,
Single<WithoutArgs<PassByValueParser>>,
Single<WithoutArgs<PubTransparentParser>>,
Single<WithoutArgs<TrackCallerParser>>,
// tidy-alphabetical-end
Expand Down
41 changes: 28 additions & 13 deletions compiler/rustc_codegen_cranelift/src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,34 @@ fn codegen_inner(
&mangle_internal_symbol(tcx, alloc_error_handler_name(alloc_error_handler_kind)),
);

let data_id = module
.declare_data(
&mangle_internal_symbol(tcx, OomStrategy::SYMBOL),
Linkage::Export,
false,
false,
)
.unwrap();
let mut data = DataDescription::new();
data.set_align(1);
let val = oom_strategy.should_panic();
data.define(Box::new([val]));
module.define_data(data_id, &data).unwrap();
{
let sig = Signature {
call_conv: module.target_config().default_call_conv,
params: vec![],
returns: vec![AbiParam::new(types::I8)],
};
let func_id = module
.declare_function(
&mangle_internal_symbol(tcx, OomStrategy::SYMBOL),
Linkage::Export,
&sig,
)
.unwrap();
let mut ctx = Context::new();
ctx.func.signature = sig;
{
let mut func_ctx = FunctionBuilderContext::new();
let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx);

let block = bcx.create_block();
bcx.switch_to_block(block);
let value = bcx.ins().iconst(types::I8, oom_strategy.should_panic() as i64);
bcx.ins().return_(&[value]);
bcx.seal_all_blocks();
bcx.finalize();
}
module.define_function(func_id, &mut ctx).unwrap();
}

{
let sig = Signature {
Expand Down
44 changes: 33 additions & 11 deletions compiler/rustc_codegen_gcc/src/allocator.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use gccjit::{Context, FunctionType, GlobalKind, ToRValue, Type};
#[cfg(feature = "master")]
use gccjit::{FnAttribute, VarAttribute};
use gccjit::FnAttribute;
use gccjit::{Context, FunctionType, RValue, ToRValue, Type};
use rustc_ast::expand::allocator::{
ALLOCATOR_METHODS, AllocatorKind, AllocatorTy, NO_ALLOC_SHIM_IS_UNSTABLE,
alloc_error_handler_name, default_fn_name, global_fn_name,
Expand Down Expand Up @@ -71,15 +71,13 @@ pub(crate) unsafe fn codegen(
None,
);

let name = mangle_internal_symbol(tcx, OomStrategy::SYMBOL);
let global = context.new_global(None, GlobalKind::Exported, i8, name);
#[cfg(feature = "master")]
global.add_attribute(VarAttribute::Visibility(symbol_visibility_to_gcc(
tcx.sess.default_visibility(),
)));
let value = tcx.sess.opts.unstable_opts.oom.should_panic();
let value = context.new_rvalue_from_int(i8, value as i32);
global.global_set_initializer_rvalue(value);
create_const_value_function(
tcx,
context,
&mangle_internal_symbol(tcx, OomStrategy::SYMBOL),
i8,
context.new_rvalue_from_int(i8, tcx.sess.opts.unstable_opts.oom.should_panic() as i32),
);

create_wrapper_function(
tcx,
Expand All @@ -91,6 +89,30 @@ pub(crate) unsafe fn codegen(
);
}

fn create_const_value_function(
tcx: TyCtxt<'_>,
context: &Context<'_>,
name: &str,
output: Type<'_>,
value: RValue<'_>,
) {
let func = context.new_function(None, FunctionType::Exported, output, &[], name, false);

#[cfg(feature = "master")]
func.add_attribute(FnAttribute::Visibility(symbol_visibility_to_gcc(
tcx.sess.default_visibility(),
)));

func.add_attribute(FnAttribute::AlwaysInline);

if tcx.sess.must_emit_unwind_tables() {
// TODO(antoyo): emit unwind tables.
}

let block = func.new_block("entry");
block.end_with_return(None, value);
}

fn create_wrapper_function(
tcx: TyCtxt<'_>,
context: &Context<'_>,
Expand Down
45 changes: 37 additions & 8 deletions compiler/rustc_codegen_llvm/src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustc_symbol_mangling::mangle_internal_symbol;

use crate::builder::SBuilder;
use crate::declare::declare_simple_fn;
use crate::llvm::{self, False, True, Type};
use crate::llvm::{self, False, True, Type, Value};
use crate::{SimpleCx, attributes, debuginfo};

pub(crate) unsafe fn codegen(
Expand Down Expand Up @@ -73,13 +73,14 @@ pub(crate) unsafe fn codegen(
);

unsafe {
// __rust_alloc_error_handler_should_panic
let name = mangle_internal_symbol(tcx, OomStrategy::SYMBOL);
let ll_g = cx.declare_global(&name, i8);
llvm::set_visibility(ll_g, llvm::Visibility::from_generic(tcx.sess.default_visibility()));
let val = tcx.sess.opts.unstable_opts.oom.should_panic();
let llval = llvm::LLVMConstInt(i8, val as u64, False);
llvm::set_initializer(ll_g, llval);
// __rust_alloc_error_handler_should_panic_v2
create_const_value_function(
tcx,
&cx,
&mangle_internal_symbol(tcx, OomStrategy::SYMBOL),
&i8,
&llvm::LLVMConstInt(i8, tcx.sess.opts.unstable_opts.oom.should_panic() as u64, False),
);

// __rust_no_alloc_shim_is_unstable_v2
create_wrapper_function(
Expand All @@ -100,6 +101,34 @@ pub(crate) unsafe fn codegen(
}
}

fn create_const_value_function(
tcx: TyCtxt<'_>,
cx: &SimpleCx<'_>,
name: &str,
output: &Type,
value: &Value,
) {
let ty = cx.type_func(&[], output);
let llfn = declare_simple_fn(
&cx,
name,
llvm::CallConv::CCallConv,
llvm::UnnamedAddr::Global,
llvm::Visibility::from_generic(tcx.sess.default_visibility()),
ty,
);

attributes::apply_to_llfn(
llfn,
llvm::AttributePlace::Function,
&[llvm::AttributeKind::AlwaysInline.create_attr(cx.llcx)],
);

let llbb = unsafe { llvm::LLVMAppendBasicBlockInContext(cx.llcx, llfn, c"entry".as_ptr()) };
let mut bx = SBuilder::build(&cx, llbb);
bx.ret(value);
}

fn create_wrapper_function(
tcx: TyCtxt<'_>,
cx: &SimpleCx<'_>,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_errors/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ rustc_type_ir = { path = "../rustc_type_ir" }
serde = { version = "1.0.125", features = [ "derive" ] }
serde_json = "1.0.59"
termcolor = "1.2.0"
termize = "0.1.1"
termize = "0.2"
tracing = "0.1"
# tidy-alphabetical-end

Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,15 @@ impl DiagInner {
self.args = std::mem::take(&mut self.reserved_args);
}

pub fn emitted_at_sub_diag(&self) -> Subdiag {
let track = format!("-Ztrack-diagnostics: created at {}", self.emitted_at);
Subdiag {
level: crate::Level::Note,
messages: vec![(DiagMessage::Str(Cow::Owned(track)), Style::NoStyle)],
span: MultiSpan::new(),
}
}

/// Fields used for Hash, and PartialEq trait.
fn keys(
&self,
Expand Down
Loading