Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d2ed8cf
Optionally add type names to `TypeId`s.
kpreid Jan 27, 2025
8fb8885
core/net: IpAddr*::as_octets()
npry Feb 5, 2025
5112ecb
Stabilise `os_str_display`
riverbl Feb 16, 2025
ff7533e
rustdoc book: acknowlage --document-hidden-items
lolbinarycat Nov 10, 2024
43c2b00
Store `TyCtxt` instead of `Map` in some iterators.
nnethercote Feb 20, 2025
d32eeb8
Implement read_buf for WASI stdin
thaliaarchi Feb 5, 2025
806be25
Move methods from Map to TyCtxt, part 3.
nnethercote Feb 20, 2025
da77b39
Refactor `OperandRef::extract_field` to prep for 838
scottmcm Feb 21, 2025
2f29c2e
Do not exempt nonexistent platforms from platform policy
workingjubilee Feb 21, 2025
918b5c3
remove unused pred_rcache
klensy Feb 21, 2025
8d2de63
convert all_macro_rules from hashmap to hashset
klensy Feb 21, 2025
7b74920
Stacker now handles miri using a noop impl itself
bjorn3 Feb 13, 2025
4395618
Rollup merge of #132876 - lolbinarycat:rustdoc-document-hidden-items,…
matthiaskrgr Feb 21, 2025
28164f1
Rollup merge of #136148 - kpreid:type-str, r=joboet
matthiaskrgr Feb 21, 2025
4aa973b
Rollup merge of #136609 - mammothbane:master, r=scottmcm
matthiaskrgr Feb 21, 2025
2dc7573
Rollup merge of #137336 - riverbl:stabilise-os-str-display, r=tgross35
matthiaskrgr Feb 21, 2025
a24eb0b
Rollup merge of #137350 - nnethercote:remove-Map-3, r=Zalathar
matthiaskrgr Feb 21, 2025
ef14e9a
Rollup merge of #137353 - thaliaarchi:io-optional-methods/wasi-stdin,…
matthiaskrgr Feb 21, 2025
b012356
Rollup merge of #137361 - scottmcm:mcp-838-prep, r=compiler-errors
matthiaskrgr Feb 21, 2025
0f56361
Rollup merge of #137367 - workingjubilee:remove-stray-line, r=jieyouxu
matthiaskrgr Feb 21, 2025
45b4314
Rollup merge of #137374 - bjorn3:remove_stacker_miri_special_case, r=…
matthiaskrgr Feb 21, 2025
cfc2d11
Rollup merge of #137392 - klensy:unused, r=compiler-errors
matthiaskrgr Feb 21, 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 library/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ optimize_for_size = []
# Make `RefCell` store additional debugging information, which is printed out when
# a borrow error occurs
debug_refcell = []
# Make `TypeId` store a reference to the name of the type, so that it can print that name.
debug_typeid = []

[lints.rust.unexpected_cfgs]
level = "warn"
Expand Down
20 changes: 17 additions & 3 deletions library/core/src/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,8 @@ pub struct TypeId {
// We avoid using `u128` because that imposes higher alignment requirements on many platforms.
// See issue #115620 for more information.
t: (u64, u64),
#[cfg(feature = "debug_typeid")]
name: &'static str,
}

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -741,10 +743,14 @@ impl TypeId {
#[rustc_const_unstable(feature = "const_type_id", issue = "77125")]
pub const fn of<T: ?Sized + 'static>() -> TypeId {
let t: u128 = intrinsics::type_id::<T>();

let t1 = (t >> 64) as u64;
let t2 = t as u64;
TypeId { t: (t1, t2) }

TypeId {
t: (t1, t2),
#[cfg(feature = "debug_typeid")]
name: type_name::<T>(),
}
}

fn as_u128(self) -> u128 {
Expand Down Expand Up @@ -775,7 +781,15 @@ impl hash::Hash for TypeId {
#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Debug for TypeId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
write!(f, "TypeId({:#034x})", self.as_u128())
#[cfg(feature = "debug_typeid")]
{
write!(f, "TypeId({:#034x} = {})", self.as_u128(), self.name)?;
}
#[cfg(not(feature = "debug_typeid"))]
{
write!(f, "TypeId({:#034x})", self.as_u128())?;
}
Ok(())
}
}

Expand Down
8 changes: 8 additions & 0 deletions library/coretests/tests/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ fn any_unsized() {
is_any::<[i32]>();
}

#[cfg(feature = "debug_typeid")]
#[test]
fn debug_typeid_includes_name() {
let type_id = TypeId::of::<[usize; 2]>();
let debug_str = format!("{type_id:?}");
assert!(debug_str.ends_with("= [usize; 2])"), "{debug_str:?} did not match");
}

#[test]
fn distinct_type_names() {
// https://github.com/rust-lang/rust/issues/84666
Expand Down
7 changes: 7 additions & 0 deletions library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ panic_immediate_abort = [
# Choose algorithms that are optimized for binary size instead of runtime performance
optimize_for_size = ["core/optimize_for_size", "alloc/optimize_for_size"]

# Make `RefCell` store additional debugging information, which is printed out when
# a borrow error occurs
debug_refcell = ["core/debug_refcell"]
# Make `TypeId` store a reference to the name of the type, so that it can print that name.
debug_typeid = ["core/debug_typeid"]


# Enable std_detect default features for stdarch/crates/std_detect:
# https://github.com/rust-lang/stdarch/blob/master/crates/std_detect/Cargo.toml
std_detect_file_io = ["std_detect/std_detect_file_io"]
Expand Down
4 changes: 3 additions & 1 deletion library/sysroot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ compiler-builtins-mem = ["std/compiler-builtins-mem"]
compiler-builtins-no-asm = ["std/compiler-builtins-no-asm"]
compiler-builtins-no-f16-f128 = ["std/compiler-builtins-no-f16-f128"]
compiler-builtins-mangled-names = ["std/compiler-builtins-mangled-names"]
debug_refcell = ["std/debug_refcell"]
debug_typeid = ["std/debug_typeid"]
llvm-libunwind = ["std/llvm-libunwind"]
system-llvm-libunwind = ["std/system-llvm-libunwind"]
optimize_for_size = ["std/optimize_for_size"]
panic-unwind = ["std/panic_unwind"]
panic_immediate_abort = ["std/panic_immediate_abort"]
optimize_for_size = ["std/optimize_for_size"]
profiler = ["dep:profiler_builtins"]
std_detect_file_io = ["std/std_detect_file_io"]
std_detect_dlsym_getauxval = ["std/std_detect_dlsym_getauxval"]
Expand Down