mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-28 10:39:45 +00:00
Support RFC 2396
AKA. target_feature 1.1, or non unsafe target_feature.
This commit is contained in:
parent
2df4ecfc74
commit
791b1ebfd4
14 changed files with 132 additions and 24 deletions
|
|
@ -101,6 +101,10 @@ impl FunctionData {
|
|||
flags.remove(FnFlags::HAS_UNSAFE_KW);
|
||||
}
|
||||
|
||||
if attrs.by_key(&sym::target_feature).exists() {
|
||||
flags.insert(FnFlags::HAS_TARGET_FEATURE);
|
||||
}
|
||||
|
||||
Arc::new(FunctionData {
|
||||
name: func.name.clone(),
|
||||
params: func
|
||||
|
|
@ -155,6 +159,10 @@ impl FunctionData {
|
|||
pub fn is_varargs(&self) -> bool {
|
||||
self.flags.contains(FnFlags::IS_VARARGS)
|
||||
}
|
||||
|
||||
pub fn has_target_feature(&self) -> bool {
|
||||
self.flags.contains(FnFlags::HAS_TARGET_FEATURE)
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_rustc_legacy_const_generics(tt: &crate::tt::TopSubtree) -> Box<[u32]> {
|
||||
|
|
|
|||
|
|
@ -937,7 +937,7 @@ pub struct Param {
|
|||
|
||||
bitflags::bitflags! {
|
||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
|
||||
pub(crate) struct FnFlags: u8 {
|
||||
pub(crate) struct FnFlags: u16 {
|
||||
const HAS_SELF_PARAM = 1 << 0;
|
||||
const HAS_BODY = 1 << 1;
|
||||
const HAS_DEFAULT_KW = 1 << 2;
|
||||
|
|
@ -946,6 +946,11 @@ bitflags::bitflags! {
|
|||
const HAS_UNSAFE_KW = 1 << 5;
|
||||
const IS_VARARGS = 1 << 6;
|
||||
const HAS_SAFE_KW = 1 << 7;
|
||||
/// The `#[target_feature]` attribute is necessary to check safety (with RFC 2396),
|
||||
/// but keeping it for all functions will consume a lot of memory when there are
|
||||
/// only very few functions with it. So we only encode its existence here, and lookup
|
||||
/// it if needed.
|
||||
const HAS_TARGET_FEATURE = 1 << 8;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue