2020-01-26 22:43:35 +01:00
|
|
|
//! Defines language items.
|
2020-01-26 12:49:18 +01:00
|
|
|
//!
|
|
|
|
//! Language items are items that represent concepts intrinsic to the language
|
|
|
|
//! itself. Examples are:
|
|
|
|
//!
|
|
|
|
//! * Traits that specify "kinds"; e.g., `Sync`, `Send`.
|
|
|
|
//! * Traits that represent operators; e.g., `Add`, `Sub`, `Index`.
|
|
|
|
//! * Functions called by the compiler itself.
|
|
|
|
|
2020-01-30 01:24:51 +01:00
|
|
|
use crate::def_id::DefId;
|
2020-08-04 14:04:25 +01:00
|
|
|
use crate::{MethodKind, Target};
|
2020-01-26 12:49:18 +01:00
|
|
|
|
2020-04-27 23:26:11 +05:30
|
|
|
use rustc_ast as ast;
|
2020-01-26 12:49:18 +01:00
|
|
|
use rustc_data_structures::fx::FxHashMap;
|
|
|
|
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
|
|
|
use rustc_macros::HashStable_Generic;
|
2020-07-08 11:04:10 +10:00
|
|
|
use rustc_span::symbol::{kw, sym, Symbol};
|
2020-01-26 12:49:18 +01:00
|
|
|
use rustc_span::Span;
|
|
|
|
|
2020-09-01 21:31:22 +01:00
|
|
|
use std::lazy::SyncLazy;
|
2020-01-26 12:49:18 +01:00
|
|
|
|
2020-06-11 13:48:46 -04:00
|
|
|
pub enum LangItemGroup {
|
|
|
|
Op,
|
2021-12-09 22:42:17 +08:00
|
|
|
Fn,
|
2020-06-11 13:48:46 -04:00
|
|
|
}
|
|
|
|
|
2021-12-29 16:29:14 +08:00
|
|
|
const NUM_GROUPS: usize = 2;
|
2020-06-11 13:48:46 -04:00
|
|
|
|
|
|
|
macro_rules! expand_group {
|
|
|
|
() => {
|
|
|
|
None
|
|
|
|
};
|
|
|
|
($group:expr) => {
|
|
|
|
Some($group)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-01-26 12:49:18 +01:00
|
|
|
// The actual lang items defined come at the end of this file in one handy table.
|
|
|
|
// So you probably just want to nip down to the end.
|
|
|
|
macro_rules! language_item_table {
|
|
|
|
(
|
2021-08-14 21:38:37 -04:00
|
|
|
$( $(#[$attr:meta])* $variant:ident $($group:expr)?, $module:ident :: $name:ident, $method:ident, $target:expr, $generics:expr; )*
|
2020-01-26 12:49:18 +01:00
|
|
|
) => {
|
|
|
|
|
2020-02-11 23:21:21 +01:00
|
|
|
enum_from_u32! {
|
|
|
|
/// A representation of all the valid language items in Rust.
|
2020-06-11 15:49:57 +01:00
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash, Encodable, Decodable)]
|
2020-02-11 23:21:21 +01:00
|
|
|
pub enum LangItem {
|
2021-02-19 14:13:25 -08:00
|
|
|
$(
|
|
|
|
#[doc = concat!("The `", stringify!($name), "` lang item.")]
|
2021-02-28 12:01:08 -08:00
|
|
|
///
|
2021-03-10 09:02:40 -08:00
|
|
|
$(#[$attr])*
|
2021-02-19 14:13:25 -08:00
|
|
|
$variant,
|
|
|
|
)*
|
2020-02-11 23:21:21 +01:00
|
|
|
}
|
2020-01-26 12:49:18 +01:00
|
|
|
}
|
|
|
|
|
2020-02-11 23:21:21 +01:00
|
|
|
impl LangItem {
|
2020-07-08 11:04:10 +10:00
|
|
|
/// Returns the `name` symbol in `#[lang = "$name"]`.
|
2021-02-19 14:13:25 -08:00
|
|
|
/// For example, [`LangItem::PartialEq`]`.name()`
|
|
|
|
/// would result in [`sym::eq`] since it is `#[lang = "eq"]`.
|
2020-07-08 11:04:10 +10:00
|
|
|
pub fn name(self) -> Symbol {
|
2020-02-11 23:21:21 +01:00
|
|
|
match self {
|
2021-03-10 09:05:59 -08:00
|
|
|
$( LangItem::$variant => $module::$name, )*
|
2020-02-11 23:21:21 +01:00
|
|
|
}
|
|
|
|
}
|
2020-06-11 13:48:46 -04:00
|
|
|
|
2021-02-19 14:13:25 -08:00
|
|
|
/// The [group](LangItemGroup) that this lang item belongs to,
|
|
|
|
/// or `None` if it doesn't belong to a group.
|
2020-06-11 13:48:46 -04:00
|
|
|
pub fn group(self) -> Option<LangItemGroup> {
|
|
|
|
use LangItemGroup::*;
|
|
|
|
match self {
|
2020-08-18 11:47:27 +01:00
|
|
|
$( LangItem::$variant => expand_group!($($group)*), )*
|
2020-06-11 13:48:46 -04:00
|
|
|
}
|
|
|
|
}
|
2021-08-14 21:38:37 -04:00
|
|
|
|
|
|
|
pub fn required_generics(&self) -> GenericRequirement {
|
|
|
|
match self {
|
|
|
|
$( LangItem::$variant => $generics, )*
|
|
|
|
}
|
|
|
|
}
|
2020-01-26 12:49:18 +01:00
|
|
|
}
|
|
|
|
|
2021-03-10 09:20:12 -08:00
|
|
|
/// All of the language items, defined or not.
|
|
|
|
/// Defined lang items can come from the current crate or its dependencies.
|
2021-01-03 09:19:16 -05:00
|
|
|
#[derive(HashStable_Generic, Debug)]
|
2020-02-11 23:21:21 +01:00
|
|
|
pub struct LanguageItems {
|
2021-02-19 14:13:25 -08:00
|
|
|
/// Mappings from lang items to their possibly found [`DefId`]s.
|
|
|
|
/// The index corresponds to the order in [`LangItem`].
|
2020-02-11 23:21:21 +01:00
|
|
|
pub items: Vec<Option<DefId>>,
|
|
|
|
/// Lang items that were not found during collection.
|
|
|
|
pub missing: Vec<LangItem>,
|
2021-02-19 14:13:25 -08:00
|
|
|
/// Mapping from [`LangItemGroup`] discriminants to all
|
|
|
|
/// [`DefId`]s of lang items in that group.
|
2020-06-11 13:48:46 -04:00
|
|
|
pub groups: [Vec<DefId>; NUM_GROUPS],
|
2020-02-11 23:21:21 +01:00
|
|
|
}
|
2020-01-26 12:49:18 +01:00
|
|
|
|
2020-02-11 23:21:21 +01:00
|
|
|
impl LanguageItems {
|
|
|
|
/// Construct an empty collection of lang items and no missing ones.
|
|
|
|
pub fn new() -> Self {
|
|
|
|
fn init_none(_: LangItem) -> Option<DefId> { None }
|
2021-12-29 16:29:14 +08:00
|
|
|
const EMPTY: Vec<DefId> = Vec::new();
|
2020-02-11 23:21:21 +01:00
|
|
|
|
|
|
|
Self {
|
2020-08-18 11:47:27 +01:00
|
|
|
items: vec![$(init_none(LangItem::$variant)),*],
|
2020-02-11 23:21:21 +01:00
|
|
|
missing: Vec::new(),
|
2021-12-29 16:29:14 +08:00
|
|
|
groups: [EMPTY; NUM_GROUPS],
|
2020-02-11 23:21:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns the mappings to the possibly found `DefId`s for each lang item.
|
|
|
|
pub fn items(&self) -> &[Option<DefId>] {
|
|
|
|
&*self.items
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Requires that a given `LangItem` was bound and returns the corresponding `DefId`.
|
|
|
|
/// If it wasn't bound, e.g. due to a missing `#[lang = "<it.name()>"]`,
|
|
|
|
/// returns an error message as a string.
|
|
|
|
pub fn require(&self, it: LangItem) -> Result<DefId, String> {
|
|
|
|
self.items[it as usize].ok_or_else(|| format!("requires `{}` lang_item", it.name()))
|
|
|
|
}
|
|
|
|
|
2021-02-19 14:13:25 -08:00
|
|
|
/// Returns the [`DefId`]s of all lang items in a group.
|
2020-06-11 13:48:46 -04:00
|
|
|
pub fn group(&self, group: LangItemGroup) -> &[DefId] {
|
|
|
|
self.groups[group as usize].as_ref()
|
|
|
|
}
|
|
|
|
|
2020-02-11 23:21:21 +01:00
|
|
|
$(
|
2021-02-19 14:13:25 -08:00
|
|
|
#[doc = concat!("Returns the [`DefId`] of the `", stringify!($name), "` lang item if it is defined.")]
|
2020-02-11 23:21:21 +01:00
|
|
|
pub fn $method(&self) -> Option<DefId> {
|
2020-08-18 11:47:27 +01:00
|
|
|
self.items[LangItem::$variant as usize]
|
2020-02-11 23:21:21 +01:00
|
|
|
}
|
|
|
|
)*
|
2020-01-26 12:49:18 +01:00
|
|
|
}
|
|
|
|
|
2020-09-01 21:31:22 +01:00
|
|
|
/// A mapping from the name of the lang item to its order and the form it must be of.
|
|
|
|
pub static ITEM_REFS: SyncLazy<FxHashMap<Symbol, (usize, Target)>> = SyncLazy::new(|| {
|
|
|
|
let mut item_refs = FxHashMap::default();
|
2021-03-10 09:05:59 -08:00
|
|
|
$( item_refs.insert($module::$name, (LangItem::$variant as usize, $target)); )*
|
2020-09-01 21:31:22 +01:00
|
|
|
item_refs
|
|
|
|
});
|
2020-01-26 12:49:18 +01:00
|
|
|
|
|
|
|
// End of the macro
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<CTX> HashStable<CTX> for LangItem {
|
|
|
|
fn hash_stable(&self, _: &mut CTX, hasher: &mut StableHasher) {
|
|
|
|
::std::hash::Hash::hash(self, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Extracts the first `lang = "$name"` out of a list of attributes.
|
|
|
|
/// The attributes `#[panic_handler]` and `#[alloc_error_handler]`
|
|
|
|
/// are also extracted out when found.
|
2022-01-09 13:41:04 -08:00
|
|
|
pub fn extract(attrs: &[ast::Attribute]) -> Option<(Symbol, Span)> {
|
2020-01-26 12:49:18 +01:00
|
|
|
attrs.iter().find_map(|attr| {
|
|
|
|
Some(match attr {
|
2022-01-09 13:41:04 -08:00
|
|
|
_ if attr.has_name(sym::lang) => (attr.value_str()?, attr.span),
|
|
|
|
_ if attr.has_name(sym::panic_handler) => (sym::panic_impl, attr.span),
|
|
|
|
_ if attr.has_name(sym::alloc_error_handler) => (sym::oom, attr.span),
|
2020-01-26 12:49:18 +01:00
|
|
|
_ => return None,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
language_item_table! {
|
2021-08-14 21:38:37 -04:00
|
|
|
// Variant name, Name, Method name, Target Generic requirements;
|
|
|
|
Sized, sym::sized, sized_trait, Target::Trait, GenericRequirement::Exact(0);
|
|
|
|
Unsize, sym::unsize, unsize_trait, Target::Trait, GenericRequirement::Minimum(1);
|
2021-02-28 12:01:08 -08:00
|
|
|
/// Trait injected by `#[derive(PartialEq)]`, (i.e. "Partial EQ").
|
2021-08-14 21:38:37 -04:00
|
|
|
StructuralPeq, sym::structural_peq, structural_peq_trait, Target::Trait, GenericRequirement::None;
|
2021-02-28 12:01:08 -08:00
|
|
|
/// Trait injected by `#[derive(Eq)]`, (i.e. "Total EQ"; no, I will not apologize).
|
2021-08-14 21:38:37 -04:00
|
|
|
StructuralTeq, sym::structural_teq, structural_teq_trait, Target::Trait, GenericRequirement::None;
|
|
|
|
Copy, sym::copy, copy_trait, Target::Trait, GenericRequirement::Exact(0);
|
|
|
|
Clone, sym::clone, clone_trait, Target::Trait, GenericRequirement::None;
|
|
|
|
Sync, sym::sync, sync_trait, Target::Trait, GenericRequirement::Exact(0);
|
|
|
|
DiscriminantKind, sym::discriminant_kind, discriminant_kind_trait, Target::Trait, GenericRequirement::None;
|
2021-02-28 12:01:08 -08:00
|
|
|
/// The associated item of the [`DiscriminantKind`] trait.
|
2021-08-14 21:38:37 -04:00
|
|
|
Discriminant, sym::discriminant_type, discriminant_type, Target::AssocTy, GenericRequirement::None;
|
|
|
|
|
|
|
|
PointeeTrait, sym::pointee_trait, pointee_trait, Target::Trait, GenericRequirement::None;
|
|
|
|
Metadata, sym::metadata_type, metadata_type, Target::AssocTy, GenericRequirement::None;
|
|
|
|
DynMetadata, sym::dyn_metadata, dyn_metadata, Target::Struct, GenericRequirement::None;
|
|
|
|
|
|
|
|
Freeze, sym::freeze, freeze_trait, Target::Trait, GenericRequirement::Exact(0);
|
|
|
|
|
|
|
|
Drop, sym::drop, drop_trait, Target::Trait, GenericRequirement::None;
|
2022-03-21 16:52:41 +11:00
|
|
|
Destruct, sym::destruct, destruct_trait, Target::Trait, GenericRequirement::None;
|
2021-08-14 21:38:37 -04:00
|
|
|
|
|
|
|
CoerceUnsized, sym::coerce_unsized, coerce_unsized_trait, Target::Trait, GenericRequirement::Minimum(1);
|
|
|
|
DispatchFromDyn, sym::dispatch_from_dyn, dispatch_from_dyn_trait, Target::Trait, GenericRequirement::Minimum(1);
|
|
|
|
|
|
|
|
Add(Op), sym::add, add_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
Sub(Op), sym::sub, sub_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
Mul(Op), sym::mul, mul_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
Div(Op), sym::div, div_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
Rem(Op), sym::rem, rem_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
Neg(Op), sym::neg, neg_trait, Target::Trait, GenericRequirement::Exact(0);
|
|
|
|
Not(Op), sym::not, not_trait, Target::Trait, GenericRequirement::Exact(0);
|
|
|
|
BitXor(Op), sym::bitxor, bitxor_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
BitAnd(Op), sym::bitand, bitand_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
BitOr(Op), sym::bitor, bitor_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
Shl(Op), sym::shl, shl_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
Shr(Op), sym::shr, shr_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
AddAssign(Op), sym::add_assign, add_assign_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
SubAssign(Op), sym::sub_assign, sub_assign_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
MulAssign(Op), sym::mul_assign, mul_assign_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
DivAssign(Op), sym::div_assign, div_assign_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
RemAssign(Op), sym::rem_assign, rem_assign_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
BitXorAssign(Op), sym::bitxor_assign, bitxor_assign_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
BitAndAssign(Op), sym::bitand_assign, bitand_assign_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
BitOrAssign(Op), sym::bitor_assign, bitor_assign_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
ShlAssign(Op), sym::shl_assign, shl_assign_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
ShrAssign(Op), sym::shr_assign, shr_assign_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
Index(Op), sym::index, index_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
IndexMut(Op), sym::index_mut, index_mut_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
|
|
|
|
UnsafeCell, sym::unsafe_cell, unsafe_cell_type, Target::Struct, GenericRequirement::None;
|
|
|
|
VaList, sym::va_list, va_list, Target::Struct, GenericRequirement::None;
|
|
|
|
|
|
|
|
Deref, sym::deref, deref_trait, Target::Trait, GenericRequirement::Exact(0);
|
|
|
|
DerefMut, sym::deref_mut, deref_mut_trait, Target::Trait, GenericRequirement::Exact(0);
|
|
|
|
DerefTarget, sym::deref_target, deref_target, Target::AssocTy, GenericRequirement::None;
|
|
|
|
Receiver, sym::receiver, receiver_trait, Target::Trait, GenericRequirement::None;
|
|
|
|
|
2021-12-09 22:42:17 +08:00
|
|
|
Fn(Fn), kw::Fn, fn_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
FnMut(Fn), sym::fn_mut, fn_mut_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
FnOnce(Fn), sym::fn_once, fn_once_trait, Target::Trait, GenericRequirement::Exact(1);
|
2021-08-14 21:38:37 -04:00
|
|
|
|
|
|
|
FnOnceOutput, sym::fn_once_output, fn_once_output, Target::AssocTy, GenericRequirement::None;
|
|
|
|
|
|
|
|
Future, sym::future_trait, future_trait, Target::Trait, GenericRequirement::Exact(0);
|
|
|
|
GeneratorState, sym::generator_state, gen_state, Target::Enum, GenericRequirement::None;
|
|
|
|
Generator, sym::generator, gen_trait, Target::Trait, GenericRequirement::Minimum(1);
|
2021-11-21 21:15:27 -08:00
|
|
|
GeneratorReturn, sym::generator_return, generator_return, Target::AssocTy, GenericRequirement::None;
|
2021-08-14 21:38:37 -04:00
|
|
|
Unpin, sym::unpin, unpin_trait, Target::Trait, GenericRequirement::None;
|
|
|
|
Pin, sym::pin, pin_type, Target::Struct, GenericRequirement::None;
|
|
|
|
|
2021-12-09 22:42:17 +08:00
|
|
|
PartialEq(Op), sym::eq, eq_trait, Target::Trait, GenericRequirement::Exact(1);
|
|
|
|
PartialOrd(Op), sym::partial_ord, partial_ord_trait, Target::Trait, GenericRequirement::Exact(1);
|
2020-08-18 11:47:27 +01:00
|
|
|
|
|
|
|
// A number of panic-related lang items. The `panic` item corresponds to divide-by-zero and
|
|
|
|
// various panic cases with `match`. The `panic_bounds_check` item is for indexing arrays.
|
2020-01-26 12:49:18 +01:00
|
|
|
//
|
2020-08-18 11:47:27 +01:00
|
|
|
// The `begin_unwind` lang item has a predefined symbol name and is sort of a "weak lang item"
|
|
|
|
// in the sense that a crate is not required to have it defined to use it, but a final product
|
|
|
|
// is required to define it somewhere. Additionally, there are restrictions on crates that use
|
|
|
|
// a weak lang item, but do not have it defined.
|
2021-10-31 17:57:32 +00:00
|
|
|
Panic, sym::panic, panic_fn, Target::Fn, GenericRequirement::Exact(0);
|
2021-08-14 21:38:37 -04:00
|
|
|
PanicFmt, sym::panic_fmt, panic_fmt, Target::Fn, GenericRequirement::None;
|
2021-09-14 19:14:37 +01:00
|
|
|
PanicDisplay, sym::panic_display, panic_display, Target::Fn, GenericRequirement::None;
|
2021-08-14 21:38:37 -04:00
|
|
|
ConstPanicFmt, sym::const_panic_fmt, const_panic_fmt, Target::Fn, GenericRequirement::None;
|
2021-10-31 17:57:32 +00:00
|
|
|
PanicBoundsCheck, sym::panic_bounds_check, panic_bounds_check_fn, Target::Fn, GenericRequirement::Exact(0);
|
2021-08-14 21:38:37 -04:00
|
|
|
PanicInfo, sym::panic_info, panic_info, Target::Struct, GenericRequirement::None;
|
|
|
|
PanicLocation, sym::panic_location, panic_location, Target::Struct, GenericRequirement::None;
|
|
|
|
PanicImpl, sym::panic_impl, panic_impl, Target::Fn, GenericRequirement::None;
|
2022-01-12 20:45:31 +00:00
|
|
|
PanicNoUnwind, sym::panic_no_unwind, panic_no_unwind, Target::Fn, GenericRequirement::Exact(0);
|
2021-02-28 12:01:08 -08:00
|
|
|
/// libstd panic entry point. Necessary for const eval to be able to catch it
|
2021-08-14 21:38:37 -04:00
|
|
|
BeginPanic, sym::begin_panic, begin_panic_fn, Target::Fn, GenericRequirement::None;
|
2020-01-26 12:49:18 +01:00
|
|
|
|
2021-08-14 21:38:37 -04:00
|
|
|
ExchangeMalloc, sym::exchange_malloc, exchange_malloc_fn, Target::Fn, GenericRequirement::None;
|
|
|
|
BoxFree, sym::box_free, box_free_fn, Target::Fn, GenericRequirement::Minimum(1);
|
|
|
|
DropInPlace, sym::drop_in_place, drop_in_place_fn, Target::Fn, GenericRequirement::Minimum(1);
|
|
|
|
Oom, sym::oom, oom, Target::Fn, GenericRequirement::None;
|
|
|
|
AllocLayout, sym::alloc_layout, alloc_layout, Target::Struct, GenericRequirement::None;
|
2021-10-12 05:06:37 +00:00
|
|
|
ConstEvalSelect, sym::const_eval_select, const_eval_select, Target::Fn, GenericRequirement::Exact(4);
|
|
|
|
ConstConstEvalSelect, sym::const_eval_select_ct,const_eval_select_ct, Target::Fn, GenericRequirement::Exact(4);
|
2020-01-26 12:49:18 +01:00
|
|
|
|
2021-09-06 03:35:37 -04:00
|
|
|
Start, sym::start, start_fn, Target::Fn, GenericRequirement::Exact(1);
|
2020-01-26 12:49:18 +01:00
|
|
|
|
2021-08-14 21:38:37 -04:00
|
|
|
EhPersonality, sym::eh_personality, eh_personality, Target::Fn, GenericRequirement::None;
|
|
|
|
EhCatchTypeinfo, sym::eh_catch_typeinfo, eh_catch_typeinfo, Target::Static, GenericRequirement::None;
|
2020-01-26 12:49:18 +01:00
|
|
|
|
2021-08-14 21:38:37 -04:00
|
|
|
OwnedBox, sym::owned_box, owned_box, Target::Struct, GenericRequirement::Minimum(1);
|
2020-01-26 12:49:18 +01:00
|
|
|
|
2021-08-14 21:38:37 -04:00
|
|
|
PhantomData, sym::phantom_data, phantom_data, Target::Struct, GenericRequirement::Exact(1);
|
2020-01-26 12:49:18 +01:00
|
|
|
|
2021-08-14 21:38:37 -04:00
|
|
|
ManuallyDrop, sym::manually_drop, manually_drop, Target::Struct, GenericRequirement::None;
|
2020-01-26 12:49:18 +01:00
|
|
|
|
2021-08-14 21:38:37 -04:00
|
|
|
MaybeUninit, sym::maybe_uninit, maybe_uninit, Target::Union, GenericRequirement::None;
|
2020-01-26 12:49:18 +01:00
|
|
|
|
2021-02-28 12:01:08 -08:00
|
|
|
/// Align offset for stride != 1; must not panic.
|
2021-08-14 21:38:37 -04:00
|
|
|
AlignOffset, sym::align_offset, align_offset_fn, Target::Fn, GenericRequirement::None;
|
2020-01-26 12:49:18 +01:00
|
|
|
|
2021-08-14 21:38:37 -04:00
|
|
|
Termination, sym::termination, termination, Target::Trait, GenericRequirement::None;
|
2020-05-22 10:11:52 +08:00
|
|
|
|
2021-08-14 21:38:37 -04:00
|
|
|
Try, sym::Try, try_trait, Target::Trait, GenericRequirement::None;
|
2020-07-02 11:27:15 -07:00
|
|
|
|
2021-08-14 21:38:37 -04:00
|
|
|
SliceLen, sym::slice_len_fn, slice_len_fn, Target::Method(MethodKind::Inherent), GenericRequirement::None;
|
2021-06-20 16:09:42 +02:00
|
|
|
|
2020-08-04 14:04:25 +01:00
|
|
|
// Language items from AST lowering
|
2021-08-14 21:38:37 -04:00
|
|
|
TryTraitFromResidual, sym::from_residual, from_residual_fn, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None;
|
|
|
|
TryTraitFromOutput, sym::from_output, from_output_fn, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None;
|
|
|
|
TryTraitBranch, sym::branch, branch_fn, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None;
|
|
|
|
|
|
|
|
PollReady, sym::Ready, poll_ready_variant, Target::Variant, GenericRequirement::None;
|
|
|
|
PollPending, sym::Pending, poll_pending_variant, Target::Variant, GenericRequirement::None;
|
2020-08-04 14:04:25 +01:00
|
|
|
|
2021-08-14 21:38:37 -04:00
|
|
|
FromGenerator, sym::from_generator, from_generator_fn, Target::Fn, GenericRequirement::None;
|
|
|
|
GetContext, sym::get_context, get_context_fn, Target::Fn, GenericRequirement::None;
|
2020-08-04 14:04:25 +01:00
|
|
|
|
2021-08-14 21:38:37 -04:00
|
|
|
FuturePoll, sym::poll, future_poll_fn, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None;
|
2020-08-04 14:04:25 +01:00
|
|
|
|
2021-08-14 21:38:37 -04:00
|
|
|
FromFrom, sym::from, from_fn, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None;
|
2020-08-04 14:04:25 +01:00
|
|
|
|
2021-08-14 21:38:37 -04:00
|
|
|
OptionSome, sym::Some, option_some_variant, Target::Variant, GenericRequirement::None;
|
|
|
|
OptionNone, sym::None, option_none_variant, Target::Variant, GenericRequirement::None;
|
2020-08-04 14:04:25 +01:00
|
|
|
|
2021-08-14 21:38:37 -04:00
|
|
|
ResultOk, sym::Ok, result_ok_variant, Target::Variant, GenericRequirement::None;
|
|
|
|
ResultErr, sym::Err, result_err_variant, Target::Variant, GenericRequirement::None;
|
2020-08-04 14:04:25 +01:00
|
|
|
|
2021-08-14 21:38:37 -04:00
|
|
|
ControlFlowContinue, sym::Continue, cf_continue_variant, Target::Variant, GenericRequirement::None;
|
|
|
|
ControlFlowBreak, sym::Break, cf_break_variant, Target::Variant, GenericRequirement::None;
|
2020-08-04 14:04:25 +01:00
|
|
|
|
2021-11-09 10:08:38 -08:00
|
|
|
IntoFutureIntoFuture, sym::into_future, into_future_fn, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None;
|
2021-08-14 21:38:37 -04:00
|
|
|
IntoIterIntoIter, sym::into_iter, into_iter_fn, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None;
|
|
|
|
IteratorNext, sym::next, next_fn, Target::Method(MethodKind::Trait { body: false}), GenericRequirement::None;
|
2021-04-15 00:33:55 -07:00
|
|
|
|
2021-08-14 21:38:37 -04:00
|
|
|
PinNewUnchecked, sym::new_unchecked, new_unchecked_fn, Target::Method(MethodKind::Inherent), GenericRequirement::None;
|
2020-08-04 14:04:25 +01:00
|
|
|
|
2021-08-14 21:38:37 -04:00
|
|
|
RangeFrom, sym::RangeFrom, range_from_struct, Target::Struct, GenericRequirement::None;
|
|
|
|
RangeFull, sym::RangeFull, range_full_struct, Target::Struct, GenericRequirement::None;
|
|
|
|
RangeInclusiveStruct, sym::RangeInclusive, range_inclusive_struct, Target::Struct, GenericRequirement::None;
|
|
|
|
RangeInclusiveNew, sym::range_inclusive_new, range_inclusive_new_method, Target::Method(MethodKind::Inherent), GenericRequirement::None;
|
|
|
|
Range, sym::Range, range_struct, Target::Struct, GenericRequirement::None;
|
|
|
|
RangeToInclusive, sym::RangeToInclusive, range_to_inclusive_struct, Target::Struct, GenericRequirement::None;
|
|
|
|
RangeTo, sym::RangeTo, range_to_struct, Target::Struct, GenericRequirement::None;
|
2022-02-16 19:23:37 +08:00
|
|
|
|
|
|
|
CStr, sym::CStr, c_str, Target::Struct, GenericRequirement::None;
|
2021-08-14 21:38:37 -04:00
|
|
|
}
|
2020-08-04 14:04:25 +01:00
|
|
|
|
2021-08-14 21:38:37 -04:00
|
|
|
pub enum GenericRequirement {
|
|
|
|
None,
|
|
|
|
Minimum(usize),
|
|
|
|
Exact(usize),
|
2020-01-26 12:49:18 +01:00
|
|
|
}
|