Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
0909712
alloc: fix `Debug` implementation of `ExtractIf`
joboet Sep 25, 2025
0d6a313
add doc for va_list APIs
DiuDiu777 Sep 23, 2025
d8b6752
describe bors try parent=sha builds
jdonszelmann Nov 12, 2025
9d1c273
update some uses of `master` in the devguide
jdonszelmann Nov 12, 2025
8c1cb5b
Merge pull request #2640 from jdonszelmann/try-parent-and-main-branch
jdonszelmann Nov 12, 2025
f6bc9d5
some updates and improvements
tshepang Nov 12, 2025
4fd2b77
Merge pull request #2639 from rust-lang/tshepang/default-branch
tshepang Nov 12, 2025
7b0c218
sembr implementing_new_features.md
tshepang Nov 12, 2025
4a845a6
typo
tshepang Nov 12, 2025
de3b053
add date marker
tshepang Nov 12, 2025
407da40
reduce overlong physical lines
tshepang Nov 12, 2025
0f497ce
needless repetition
tshepang Nov 12, 2025
7b35dd1
Merge pull request #2641 from rust-lang/tshepang/sembr
tshepang Nov 12, 2025
6d42077
do not ignore lines that are list entries
tshepang Nov 13, 2025
e4ef199
avoid surprising string handling behavior
tshepang Nov 13, 2025
5517b2c
sembr src/stabilization_guide.md
tshepang Nov 13, 2025
aefdfa8
some text improvements
tshepang Nov 13, 2025
9d16bc4
Merge pull request #2642 from rust-lang/tshepang/sembr
tshepang Nov 13, 2025
74caf6d
sembr implementing_new_features.md again
tshepang Nov 13, 2025
cf542b5
Merge pull request #2643 from rust-lang/tshepang/sembr
tshepang Nov 13, 2025
d5f14ae
use latest checkout action
tshepang Nov 13, 2025
662facc
ci: avoid sembr getting rebuilt on every push
tshepang Nov 13, 2025
e7cd6c6
ci: run sembr in release mode
tshepang Nov 13, 2025
d2a8e42
Merge pull request #2644 from rust-lang/tshepang/ci
tshepang Nov 13, 2025
a70b5c6
sembr sanitizers.md again
tshepang Nov 13, 2025
fe3871f
sembr: update lockfile
tshepang Nov 13, 2025
5d1dc38
handle another edge case
tshepang Nov 13, 2025
9ce4c1a
Merge pull request #2645 from rust-lang/tshepang/sembr
tshepang Nov 13, 2025
3dcaf9b
add missing " and -Zoffload=Enable flag
ZuseZ4 Nov 14, 2025
2bf2f44
Merge pull request #2646 from rust-lang/update-offload-docs
ZuseZ4 Nov 14, 2025
ecfc642
Add support for hexagon-unknown-qurt target
androm3da Sep 30, 2025
901183b
Prepare for merging from rust-lang/rust
invalid-email-address Nov 17, 2025
6367ba4
Merge ref '69d4d5fc0e4d' from rust-lang/rust
invalid-email-address Nov 17, 2025
8564d67
Merge pull request #2647 from rust-lang/rustc-pull
tshepang Nov 17, 2025
6766db0
Prepare for merging from rust-lang/rust
invalid-email-address Nov 17, 2025
a76d78b
Merge ref 'cc328c12382f' from rust-lang/rust
invalid-email-address Nov 17, 2025
239cf98
Merge pull request #2648 from rust-lang/rustc-pull
tshepang Nov 17, 2025
bbf7dc0
ignore unsized types in mips64 and sparc64 callconvs
folkertdev Nov 16, 2025
10172d1
disable the fragment_in_dst_padding_gets_overwritten test on s390x
fneddy Nov 18, 2025
8c569c1
run-make-support: re-export rustdoc_json_types
aDotInTheVoid Nov 19, 2025
e7b8460
rustc_public: Make Id types !Send / !Sync
aDotInTheVoid Oct 29, 2025
a74d572
[AIX][ppc64le-linux-gnu] Add Amy Kwan to target maintainers
daltenty Nov 19, 2025
457ed4e
rustdoc-json: add rlib path to ExternalCrate to enable robust crate r…
aDotInTheVoid Nov 17, 2025
39ae65b
Rollup merge of #146925 - DiuDiu777:va-doc-fix, r=tgross35
Zalathar Nov 20, 2025
fb720c1
Rollup merge of #147035 - joboet:extract_if_debug, r=tgross35
Zalathar Nov 20, 2025
c1c9647
Rollup merge of #147173 - androm3da:bcain/hexagon_qurt, r=davidtwco,t…
Zalathar Nov 20, 2025
163022d
Rollup merge of #148261 - aDotInTheVoid:no-sync-for-smir, r=celinval
Zalathar Nov 20, 2025
3a9567e
Rollup merge of #149041 - folkertdev:sparc64-mips64-ignore-unsized, r…
Zalathar Nov 20, 2025
ced17d6
Rollup merge of #149043 - aDotInTheVoid:is-this-real-is-this-out-of-s…
Zalathar Nov 20, 2025
0d25ac4
Rollup merge of #149056 - fneddy:fix_s390_test_padding_overwrite, r=R…
Zalathar Nov 20, 2025
11cee4c
Rollup merge of #149095 - tshepang:rdg-sync, r=tshepang
Zalathar Nov 20, 2025
b29cde4
Rollup merge of #149108 - daltenty:daltenty/add-maintainer, r=Noratrieb
Zalathar Nov 20, 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 Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3285,6 +3285,7 @@ dependencies = [
"libc",
"object 0.37.3",
"regex",
"rustdoc-json-types",
"serde_json",
"similar",
"wasmparser 0.236.1",
Expand Down Expand Up @@ -4472,6 +4473,7 @@ dependencies = [
"rustc_target",
"scoped-tls",
"serde",
"serde_json",
"tracing",
]

Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_public/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
rustc_target = { path = "../rustc_target" }
scoped-tls = "1.0"
serde = { version = "1.0.125", features = [ "derive" ] }
serde = { version = "1.0.125", features = ["derive"] }
tracing = "0.1"
# tidy-alphabetical-end

[dev-dependencies]
# tidy-alphabetical-start
serde_json = "1.0.142"
# tidy-alphabetical-end

[features]
# tidy-alphabetical-start
# Provides access to APIs that expose internals of the rust compiler.
Expand Down
18 changes: 5 additions & 13 deletions compiler/rustc_public/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use serde::Serialize;
use crate::compiler_interface::with;
use crate::mir::FieldIdx;
use crate::target::{MachineInfo, MachineSize as Size};
use crate::ty::{Align, Ty, VariantIdx};
use crate::{Error, Opaque, error};
use crate::ty::{Align, Ty, VariantIdx, index_impl};
use crate::{Error, Opaque, ThreadLocalIndex, error};

/// A function ABI definition.
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)]
Expand Down Expand Up @@ -109,24 +109,16 @@ impl LayoutShape {
}
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize)]
pub struct Layout(usize);
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct Layout(usize, ThreadLocalIndex);
index_impl!(Layout);

impl Layout {
pub fn shape(self) -> LayoutShape {
with(|cx| cx.layout_shape(self))
}
}

impl crate::IndexedVal for Layout {
fn to_val(index: usize) -> Self {
Layout(index)
}
fn to_index(&self) -> usize {
self.0
}
}

/// Describes how the fields of a type are shaped in memory.
#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)]
pub enum FieldsShape {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_public/src/compiler_interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::ty::{
use crate::unstable::{RustcInternal, Stable, new_item_kind};
use crate::{
AssocItems, Crate, CrateDef, CrateItem, CrateItems, CrateNum, DefId, Error, Filename,
ImplTraitDecls, ItemKind, Symbol, TraitDecls, alloc, mir,
ImplTraitDecls, ItemKind, Symbol, ThreadLocalIndex, TraitDecls, alloc, mir,
};

pub struct BridgeTys;
Expand Down Expand Up @@ -866,7 +866,7 @@ fn smir_crate<'tcx>(
) -> Crate {
let name = cx.crate_name(crate_num);
let is_local = cx.crate_is_local(crate_num);
let id = cx.crate_num_id(crate_num);
let id = CrateNum(cx.crate_num_id(crate_num), ThreadLocalIndex);
debug!(?name, ?crate_num, "smir_crate");
Crate { id, name, is_local }
}
11 changes: 5 additions & 6 deletions compiler/rustc_public/src/crate_def.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
//! Module that define a common trait for things that represent a crate definition,
//! such as, a function, a trait, an enum, and any other definitions.
use serde::Serialize;

use crate::ty::{GenericArgs, Span, Ty};
use crate::{AssocItems, Crate, Symbol, with};
use crate::ty::{GenericArgs, Span, Ty, index_impl};
use crate::{AssocItems, Crate, Symbol, ThreadLocalIndex, with};

/// A unique identification number for each item accessible for the current compilation unit.
#[derive(Clone, Copy, PartialEq, Eq, Hash, Serialize)]
pub struct DefId(pub(crate) usize);
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
pub struct DefId(pub(crate) usize, ThreadLocalIndex);
index_impl!(DefId);

impl DefId {
/// Return fully qualified name of this definition
Expand Down
44 changes: 32 additions & 12 deletions compiler/rustc_public/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
//! [crates.io](https://crates.io).
use std::fmt::Debug;
use std::marker::PhantomData;
use std::{fmt, io};

pub(crate) use rustc_public_bridge::IndexedVal;
Expand All @@ -33,7 +34,10 @@ pub use crate::crate_def::{CrateDef, CrateDefItems, CrateDefType, DefId};
pub use crate::error::*;
use crate::mir::mono::StaticDef;
use crate::mir::{Body, Mutability};
use crate::ty::{AssocItem, FnDef, ForeignModuleDef, ImplDef, ProvenanceMap, Span, TraitDef, Ty};
use crate::ty::{
AssocItem, FnDef, ForeignModuleDef, ImplDef, ProvenanceMap, Span, TraitDef, Ty,
serialize_index_impl,
};
use crate::unstable::Stable;

pub mod abi;
Expand All @@ -46,31 +50,25 @@ pub mod compiler_interface;
pub mod error;
pub mod mir;
pub mod target;
#[cfg(test)]
mod tests;
pub mod ty;
pub mod visitor;

/// Use String for now but we should replace it.
pub type Symbol = String;

/// The number that identifies a crate.
pub type CrateNum = usize;
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct CrateNum(pub(crate) usize, ThreadLocalIndex);
serialize_index_impl!(CrateNum);

impl Debug for DefId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DefId").field("id", &self.0).field("name", &self.name()).finish()
}
}

impl IndexedVal for DefId {
fn to_val(index: usize) -> Self {
DefId(index)
}

fn to_index(&self) -> usize {
self.0
}
}

/// A list of crate items.
pub type CrateItems = Vec<CrateItem>;

Expand Down Expand Up @@ -297,3 +295,25 @@ impl rustc_public_bridge::bridge::Allocation<compiler_interface::BridgeTys>
}
}
}

#[derive(Clone, Copy, Hash, PartialEq, Eq, Default)]
/// Marker type for indexes into thread local structures.
///
/// Makes things `!Send`/`!Sync`, so users don't move `rustc_public` types to
/// thread with no (or worse, different) `rustc_public` pointer.
///
/// Note. This doesn't make it impossible to confuse TLS. You could return a
/// `DefId` from one `run!` invocation, and then use it inside a different
/// `run!` invocation with different tables.
pub(crate) struct ThreadLocalIndex {
_phantom: PhantomData<*const ()>,
}
#[expect(non_upper_case_globals)]
/// Emulating unit struct `struct ThreadLocalIndex`;
pub(crate) const ThreadLocalIndex: ThreadLocalIndex = ThreadLocalIndex { _phantom: PhantomData };

impl fmt::Debug for ThreadLocalIndex {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_tuple("ThreadLocalIndex").finish()
}
}
18 changes: 5 additions & 13 deletions compiler/rustc_public/src/mir/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ use serde::Serialize;

use crate::mir::mono::{Instance, StaticDef};
use crate::target::{Endian, MachineInfo};
use crate::ty::{Allocation, Binder, ExistentialTraitRef, Ty};
use crate::{Error, IndexedVal, with};
use crate::ty::{Allocation, Binder, ExistentialTraitRef, Ty, index_impl};
use crate::{Error, ThreadLocalIndex, with};

/// An allocation in the rustc_public's IR global memory can be either a function pointer,
/// a static, or a "real" allocation with some data in it.
Expand Down Expand Up @@ -47,17 +47,9 @@ impl GlobalAlloc {
}

/// A unique identification number for each provenance
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash, Serialize)]
pub struct AllocId(usize);

impl IndexedVal for AllocId {
fn to_val(index: usize) -> Self {
AllocId(index)
}
fn to_index(&self) -> usize {
self.0
}
}
#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)]
pub struct AllocId(usize, ThreadLocalIndex);
index_impl!(AllocId);

/// Utility function used to read an allocation data into a unassigned integer.
pub(crate) fn read_target_uint(mut bytes: &[u8]) -> Result<u128, Error> {
Expand Down
18 changes: 5 additions & 13 deletions compiler/rustc_public/src/mir/mono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use serde::Serialize;
use crate::abi::FnAbi;
use crate::crate_def::CrateDef;
use crate::mir::Body;
use crate::ty::{Allocation, ClosureDef, ClosureKind, FnDef, GenericArgs, Ty};
use crate::{CrateItem, DefId, Error, IndexedVal, ItemKind, Opaque, Symbol, with};
use crate::ty::{Allocation, ClosureDef, ClosureKind, FnDef, GenericArgs, Ty, index_impl};
use crate::{CrateItem, DefId, Error, ItemKind, Opaque, Symbol, ThreadLocalIndex, with};

#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize)]
pub enum MonoItem {
Expand Down Expand Up @@ -241,8 +241,9 @@ impl From<StaticDef> for CrateItem {
}
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize)]
pub struct InstanceDef(usize);
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct InstanceDef(usize, ThreadLocalIndex);
index_impl!(InstanceDef);

impl CrateDef for InstanceDef {
fn def_id(&self) -> DefId {
Expand Down Expand Up @@ -294,12 +295,3 @@ impl StaticDef {
with(|cx| cx.eval_static_initializer(*self))
}
}

impl IndexedVal for InstanceDef {
fn to_val(index: usize) -> Self {
InstanceDef(index)
}
fn to_index(&self) -> usize {
self.0
}
}
2 changes: 1 addition & 1 deletion compiler/rustc_public/src/rustc_internal/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ where
}

pub fn crate_num(item: &crate::Crate) -> CrateNum {
item.id.into()
item.id.0.into()
}

/// Loads the current context and calls a function with it.
Expand Down
63 changes: 63 additions & 0 deletions compiler/rustc_public/src/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
use rustc_public_bridge::IndexedVal;

use crate::abi::Layout;
use crate::mir::alloc::AllocId;
use crate::mir::mono::InstanceDef;
use crate::ty::{MirConstId, TyConstId, VariantIdx};
use crate::{CrateNum, DefId, Span, ThreadLocalIndex, Ty};

#[track_caller]
fn check_serialize<T: serde::Serialize>(value: T, expected_json: &str) {
let got_json = serde_json::to_string(&value).unwrap();
assert_eq!(got_json, expected_json, "didn't get expected json for serializing");
}

#[test]
fn serialize_cratenum() {
check_serialize(CrateNum(1, ThreadLocalIndex), "1");
}

#[test]
fn serialize_defid() {
check_serialize(DefId::to_val(2), "2");
}

#[test]
fn serialize_layout() {
check_serialize(Layout::to_val(3), "3");
}

#[test]
fn serialize_allocid() {
check_serialize(AllocId::to_val(4), "4");
}

#[test]
fn serialize_ty() {
check_serialize(Ty::to_val(5), "5");
}

#[test]
fn serialize_tyconstid() {
check_serialize(TyConstId::to_val(6), "6");
}

#[test]
fn serialize_mirconstid() {
check_serialize(MirConstId::to_val(7), "7");
}

#[test]
fn serialize_span() {
check_serialize(Span::to_val(8), "8");
}

#[test]
fn serialize_variantidx() {
check_serialize(VariantIdx::to_val(9), "9");
}

#[test]
fn serialize_instancedef() {
check_serialize(InstanceDef::to_val(10), "10");
}
Loading
Loading