Expand description
Resolution of well-known core/std/alloc function paths to their
internal [DefId]s.
This module is the single home for “which standard-library item is this
DefId?”, used by crate::verify::api_classify and the alias checker to
match APIs exactly instead of substring-matching a def_path_str. It is
deliberately placed at the crate root (next to crate::compat) rather
than under helpers/, because it owns global state and a one-time
init(tcx) hook in the compiler callback.
§How a lookup works
- The [
intrinsics!] macro declares a path table: each identifier maps to one or more candidatefn_def.name()strings (typically thestd::re-export plus thecore::/alloc::canonical form, for#![no_std]crates) and generates a{id}() -> Option<DefId>accessor. initruns once from [crate::RapCallback::after_analysis], iterates everyfn_defof thecore/std/alloccrates viarustc_public, and caches thepath -> DefIdmap in aOnceLock.containstests whether a call-siteDefIdis in a set of resolved ids;is_drop_fnis a convenience wrapper over the drop family.
§Path format
rustc_public::CrateDef::name() is def_path_str with crate-name
resolution and untrimmed paths, so a re-exported item appears under its
std:: name and generics are kept: std::mem::MaybeUninit::<T>::write,
std::result::Result::<T, E>::unwrap, std::vec::Vec::<T, A>::push,
std::ptr::mut_ptr::<impl *mut T>::copy_from.
§Limitations
- In
#![no_std]builds some intrinsics are absent;initonly warns (rap_warn!) instead of panicking, so an entry with no matching path simply yieldsNone.
Macros§
Structs§
- Intrinsics 🔒
- Methods 🔒
- Types 🔒
- Resolved
DefIds of well-known std types (ADTs), used by the ADT type-name classifiers (crate::verify::api_classify::is_std_box,crate::verify::api_classify::is_std_vec, …). Each entry collects the std type’sDefId(via lang/diagnostic item, or — forNonNull, which has neither — by name-scanning the std crates’adts()) and any same-named re-implementations in the local crate (the std-challenge suites re-implementVec/NonNullunder the same names).
Constants§
- INTRINSICS 🔒
- NEGATIVE_
TYPE_ 🔒NAMES - Short names of the std
!Send/!Syncnegative types resolved by name scan (those without a lang/diagnostic item).UnsafeCellis resolved via its#[lang = "unsafe_cell"]item instead.
Statics§
- INIT 🔒
- METHODS 🔒
- Resolved
DefIds of std methods that are matched by generic name rather than a fixedintrinsics!path (e.g.len,capacity,::abs,::checked_add,::split_at,Iterator::position, …). Each group collects everyfn_def— from the std crates and the local crate (the std-challenge suites re-implementVec/slice-like types and their methods) — whose name matches the group’s pattern. Callers match a call-siteDefIdagainst these sets viacontains. - TYPES 🔒
Functions§
- abs_fns
- align_
to_ local_ fns - arc_
as_ ptr - arc_
from_ raw - arc_
from_ raw_ in - arc_
into_ raw - ascii_
char_ types core::ascii::Char(AsciiChar, theu8newtype; and any local re-implementation).- assume_
init_ read - bit_
preserving_ nz_ fns - box_
alloc_ ctors Box::new/new_in/new_uninit/new_uninit_in(andtry_variants).- box_
as_ mut_ ptr - box_
as_ ptr - box_
assume_ init_ into_ vec_ unsafe - box_
from_ raw - box_
from_ raw_ in - box_
into_ raw - box_
types alloc::boxed::Box(and any localBoxre-implementation).- call_
mut - capacity_
fns capacityquery methods (Vec::capacityand local re-implementations).- checked_
add_ fns - checked_
mul_ fns - checked_
next_ pow2_ fns - checked_
nonzero_ iff_ fns - clamp_
fns - clone
- const_
ptr_ add - const_
ptr_ addr - const_
ptr_ align_ offset - const_
ptr_ byte_ add - const_
ptr_ byte_ offset - const_
ptr_ byte_ sub - const_
ptr_ cast - const_
ptr_ cast_ array - const_
ptr_ cast_ mut - const_
ptr_ is_ null - const_
ptr_ offset - const_
ptr_ slice_ as_ ptr - const_
ptr_ slice_ is_ empty - const_
ptr_ slice_ len - const_
ptr_ sub - const_
ptr_ wrapping_ add - const_
ptr_ wrapping_ byte_ add - const_
ptr_ wrapping_ byte_ offset - const_
ptr_ wrapping_ byte_ sub - const_
ptr_ wrapping_ offset - const_
ptr_ wrapping_ sub - contains
- Is the targe DefId in the given array.
- copy_
from - copy_
from_ nonoverlapping - copy_to
- copy_
to_ nonoverlapping - cstr_
as_ ptr - cstr_
from_ bytes_ with_ nul_ unchecked - cstr_
from_ ptr - cstr_
is_ empty - cstring_
from_ raw - cstring_
from_ vec_ with_ nul_ unchecked - cstring_
into_ raw - cstring_
types alloc::ffi::CString(and any localCStringre-implementation).- dealloc
- drop
- drop_
in_ place - exchange_
malloc alloc::alloc::exchange_malloc, if present on this toolchain.- from_
raw_ parts_ fns from_raw_partsconstructors (slice/str/ptr/NonNull/Vec/Stringand local re-implementations).- from_
raw_ parts_ mut_ fns from_raw_parts_mutconstructors (slice/ptr/NonNulland local re-implementations).- hint_
select_ unpredictable - init
- init_
inner 🔒 - init_
methods 🔒 - init_
types 🔒 - intrinsics_
align_ of - intrinsics_
copy - intrinsics_
copy_ nonoverlapping - intrinsics_
size_ of - is_
drop_ fn - Find any drop fn. Any of these drop fns can be missing, e.g. for crates like no_std without using alloc, dealloc doesn’t exist.
- is_
sync_ 🔒primitive_ short_ name - Whether a type’s short name denotes a synchronization primitive that guards
its interior mutability (
Mutex/RwLock/OnceLock/OnceCell/Atomic*). - iter_
position_ fns - iter_
types core::slice::Iter/core::slice::IterMut(the two-fieldptr/endslice iterators, plus any local re-implementation).- layout_
align_ fns - len_fns
lenquery methods (slice::len,str::len,Vec::len,String::len, pointer-slicelen, and any local re-implementation).- manually_
drop - max_fns
- maybe_
uninit_ as_ mut_ ptr - maybe_
uninit_ as_ ptr - maybe_
uninit_ assume_ init - maybe_
uninit_ assume_ init_ mut - maybe_
uninit_ assume_ init_ ref - maybe_
uninit_ types core::mem::MaybeUninit(and any local re-implementation).- maybe_
uninit_ uninit - maybe_
uninit_ write - mem_
align_ of - mem_
size_ of - min_
like_ fns - mut_
ptr_ add - mut_
ptr_ addr - mut_
ptr_ align_ offset - mut_
ptr_ byte_ add - mut_
ptr_ byte_ offset - mut_
ptr_ byte_ sub - mut_
ptr_ cast - mut_
ptr_ cast_ array - mut_
ptr_ cast_ const - mut_
ptr_ is_ null - mut_
ptr_ offset - mut_
ptr_ slice_ as_ mut_ ptr - mut_
ptr_ slice_ is_ empty - mut_
ptr_ slice_ len - mut_
ptr_ sub - mut_
ptr_ wrapping_ add - mut_
ptr_ wrapping_ byte_ add - mut_
ptr_ wrapping_ byte_ offset - mut_
ptr_ wrapping_ byte_ sub - mut_
ptr_ wrapping_ offset - mut_
ptr_ wrapping_ sub - neg_fns
- negative_
type_ defs - Resolve a negative-type name (as written in
std-trait-ensures.json) to its resolvedDefIdset. Unknown names resolve to an empty set (the checker then reportsUnknown). - negative_
type_ 🔒name - The negative-type name for a short type name, if it is one of the std
!Send/!Syncnegative types. - nonnull_
add - nonnull_
addr - nonnull_
align_ offset - nonnull_
as_ mut - nonnull_
as_ ptr - nonnull_
as_ ref - nonnull_
byte_ add - nonnull_
byte_ offset - nonnull_
byte_ sub - nonnull_
cast - nonnull_
new - nonnull_
new_ unchecked - nonnull_
offset - nonnull_
slice_ as_ mut_ ptr - nonnull_
slice_ is_ empty - nonnull_
slice_ len - nonnull_
sub - nonnull_
types core::ptr::NonNull(and any localNonNullre-implementation).- option_
expect - option_
unwrap - option_
unwrap_ unchecked - ordering_
types core::cmp::Ordering.- overflowing_
nz_ fns - ptr_
align_ offset - ptr_
read - ptr_
read_ unaligned - ptr_
read_ volatile - ptr_
write - ptr_
write_ bytes - ptr_
write_ unaligned - ptr_
write_ volatile - rc_
as_ ptr - rc_
from_ raw - rc_
from_ raw_ in - rc_
into_ raw - rc_
types alloc::rc::Rc(and any localRcre-implementation) — the non-atomic reference-counted smart pointer, a!Send/!Syncnegative type.- replace
- result_
expect - result_
expect_ err - result_
unwrap - result_
unwrap_ err - result_
unwrap_ unchecked - sat_
unchecked_ add_ fns - sat_
unchecked_ mul_ fns - select_
unpredictable - slice_
as_ mut_ ptr - slice_
as_ ptr - slice_
get_ unchecked_ fns - slice_
into_ vec - slice_
is_ empty - slice_
len - slice_
range_ fns - slice_
to_ vec - sliceindex_
get_ unchecked_ fns - split_
at_ fns - str_
as_ bytes - str_
as_ mut_ ptr - str_
as_ ptr - str_
is_ empty - str_len
- string_
is_ empty - string_
len - strlen_
fns - sync_
primitive_ types - Synchronization primitives (
Mutex/RwLock/OnceLock/OnceCell/Atomic*, plus any local re-implementation) that guard their interior mutability, used to discharge theRefSendauto-trait obligation. - take
- to_
internal - rustc_public DefId to internal DefId
- vec_
as_ mut_ ptr - vec_
as_ ptr - vec_
clear - vec_
from_ elem - vec_
insert - vec_
into_ boxed_ slice - vec_
is_ empty - vec_len
- vec_
ownership_ transfer_ fns Vec::from_raw_parts/Vec::from_parts(ownership transfer into aVec).- vec_
push - vec_
remove - vec_
reserve - vec_
reserve_ exact - vec_
set_ len - vec_
shrink_ to - vec_
shrink_ to_ fit - vec_
truncate - vec_
types alloc::vec::Vec(and any localVecre-implementation).- with_
capacity_ fns Vec::with_capacity(and local re-implementations).