mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-31 20:09:01 +00:00
Merge pull request #19562 from Veykril/push-uqutltwzsnmk
fix: Fix invalid signature bitflags
This commit is contained in:
commit
9e0af2bf13
11 changed files with 100 additions and 103 deletions
|
|
@ -157,7 +157,7 @@ pub(crate) fn print_struct(
|
||||||
wln!(p, "#[repr(pack({}))]", pack.bytes());
|
wln!(p, "#[repr(pack({}))]", pack.bytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if flags.contains(StructFlags::IS_FUNDAMENTAL) {
|
if flags.contains(StructFlags::FUNDAMENTAL) {
|
||||||
wln!(p, "#[fundamental]");
|
wln!(p, "#[fundamental]");
|
||||||
}
|
}
|
||||||
w!(p, "struct ");
|
w!(p, "struct ");
|
||||||
|
|
@ -202,16 +202,16 @@ pub(crate) fn print_function(
|
||||||
line_format: LineFormat::Newline,
|
line_format: LineFormat::Newline,
|
||||||
edition,
|
edition,
|
||||||
};
|
};
|
||||||
if flags.contains(FnFlags::HAS_CONST_KW) {
|
if flags.contains(FnFlags::CONST) {
|
||||||
w!(p, "const ");
|
w!(p, "const ");
|
||||||
}
|
}
|
||||||
if flags.contains(FnFlags::HAS_ASYNC_KW) {
|
if flags.contains(FnFlags::ASYNC) {
|
||||||
w!(p, "async ");
|
w!(p, "async ");
|
||||||
}
|
}
|
||||||
if flags.contains(FnFlags::HAS_UNSAFE_KW) {
|
if flags.contains(FnFlags::UNSAFE) {
|
||||||
w!(p, "unsafe ");
|
w!(p, "unsafe ");
|
||||||
}
|
}
|
||||||
if flags.contains(FnFlags::HAS_SAFE_KW) {
|
if flags.contains(FnFlags::EXPLICIT_SAFE) {
|
||||||
w!(p, "safe ");
|
w!(p, "safe ");
|
||||||
}
|
}
|
||||||
if let Some(abi) = abi {
|
if let Some(abi) = abi {
|
||||||
|
|
|
||||||
|
|
@ -50,18 +50,18 @@ pub struct StructSignature {
|
||||||
bitflags! {
|
bitflags! {
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
pub struct StructFlags: u8 {
|
pub struct StructFlags: u8 {
|
||||||
/// Indicates whether the struct is `PhantomData`.
|
|
||||||
const IS_PHANTOM_DATA = 1 << 2;
|
|
||||||
/// Indicates whether the struct has a `#[fundamental]` attribute.
|
|
||||||
const IS_FUNDAMENTAL = 1 << 3;
|
|
||||||
/// Indicates whether the struct has a `#[rustc_has_incoherent_inherent_impls]` attribute.
|
/// Indicates whether the struct has a `#[rustc_has_incoherent_inherent_impls]` attribute.
|
||||||
const IS_RUSTC_HAS_INCOHERENT_INHERENT_IMPLS = 1 << 4;
|
const RUSTC_HAS_INCOHERENT_INHERENT_IMPLS = 1 << 1;
|
||||||
|
/// Indicates whether the struct has a `#[fundamental]` attribute.
|
||||||
|
const FUNDAMENTAL = 1 << 2;
|
||||||
|
/// Indicates whether the struct is `PhantomData`.
|
||||||
|
const IS_PHANTOM_DATA = 1 << 3;
|
||||||
/// Indicates whether this struct is `Box`.
|
/// Indicates whether this struct is `Box`.
|
||||||
const IS_BOX = 1 << 5;
|
const IS_BOX = 1 << 4;
|
||||||
/// Indicates whether this struct is `ManuallyDrop`.
|
/// Indicates whether this struct is `ManuallyDrop`.
|
||||||
const IS_MANUALLY_DROP = 1 << 6;
|
const IS_MANUALLY_DROP = 1 << 5;
|
||||||
/// Indicates whether this struct is `UnsafeCell`.
|
/// Indicates whether this struct is `UnsafeCell`.
|
||||||
const IS_UNSAFE_CELL = 1 << 7;
|
const IS_UNSAFE_CELL = 1 << 6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,10 +73,10 @@ impl StructSignature {
|
||||||
|
|
||||||
let mut flags = StructFlags::empty();
|
let mut flags = StructFlags::empty();
|
||||||
if attrs.by_key(&sym::rustc_has_incoherent_inherent_impls).exists() {
|
if attrs.by_key(&sym::rustc_has_incoherent_inherent_impls).exists() {
|
||||||
flags |= StructFlags::IS_RUSTC_HAS_INCOHERENT_INHERENT_IMPLS;
|
flags |= StructFlags::RUSTC_HAS_INCOHERENT_INHERENT_IMPLS;
|
||||||
}
|
}
|
||||||
if attrs.by_key(&sym::fundamental).exists() {
|
if attrs.by_key(&sym::fundamental).exists() {
|
||||||
flags |= StructFlags::IS_FUNDAMENTAL;
|
flags |= StructFlags::FUNDAMENTAL;
|
||||||
}
|
}
|
||||||
if let Some(lang) = attrs.lang_item() {
|
if let Some(lang) = attrs.lang_item() {
|
||||||
match lang {
|
match lang {
|
||||||
|
|
@ -129,10 +129,10 @@ impl UnionSignature {
|
||||||
let attrs = item_tree.attrs(db, krate, ModItem::from(loc.id.value).into());
|
let attrs = item_tree.attrs(db, krate, ModItem::from(loc.id.value).into());
|
||||||
let mut flags = StructFlags::empty();
|
let mut flags = StructFlags::empty();
|
||||||
if attrs.by_key(&sym::rustc_has_incoherent_inherent_impls).exists() {
|
if attrs.by_key(&sym::rustc_has_incoherent_inherent_impls).exists() {
|
||||||
flags |= StructFlags::IS_RUSTC_HAS_INCOHERENT_INHERENT_IMPLS;
|
flags |= StructFlags::RUSTC_HAS_INCOHERENT_INHERENT_IMPLS;
|
||||||
}
|
}
|
||||||
if attrs.by_key(&sym::fundamental).exists() {
|
if attrs.by_key(&sym::fundamental).exists() {
|
||||||
flags |= StructFlags::IS_FUNDAMENTAL;
|
flags |= StructFlags::FUNDAMENTAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
let repr = attrs.repr();
|
let repr = attrs.repr();
|
||||||
|
|
@ -162,7 +162,7 @@ impl UnionSignature {
|
||||||
bitflags! {
|
bitflags! {
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
pub struct EnumFlags: u8 {
|
pub struct EnumFlags: u8 {
|
||||||
const IS_RUSTC_HAS_INCOHERENT_INHERENT_IMPLS = 1 << 4;
|
const RUSTC_HAS_INCOHERENT_INHERENT_IMPLS = 1 << 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -182,7 +182,7 @@ impl EnumSignature {
|
||||||
let attrs = item_tree.attrs(db, loc.container.krate, ModItem::from(loc.id.value).into());
|
let attrs = item_tree.attrs(db, loc.container.krate, ModItem::from(loc.id.value).into());
|
||||||
let mut flags = EnumFlags::empty();
|
let mut flags = EnumFlags::empty();
|
||||||
if attrs.by_key(&sym::rustc_has_incoherent_inherent_impls).exists() {
|
if attrs.by_key(&sym::rustc_has_incoherent_inherent_impls).exists() {
|
||||||
flags |= EnumFlags::IS_RUSTC_HAS_INCOHERENT_INHERENT_IMPLS;
|
flags |= EnumFlags::RUSTC_HAS_INCOHERENT_INHERENT_IMPLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
let repr = attrs.repr();
|
let repr = attrs.repr();
|
||||||
|
|
@ -219,8 +219,8 @@ impl EnumSignature {
|
||||||
bitflags::bitflags! {
|
bitflags::bitflags! {
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
|
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
|
||||||
pub struct ConstFlags: u8 {
|
pub struct ConstFlags: u8 {
|
||||||
const HAS_BODY = 1 << 0;
|
const HAS_BODY = 1 << 1;
|
||||||
const RUSTC_ALLOW_INCOHERENT_IMPL = 1 << 1;
|
const RUSTC_ALLOW_INCOHERENT_IMPL = 1 << 7;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -271,12 +271,12 @@ impl ConstSignature {
|
||||||
bitflags::bitflags! {
|
bitflags::bitflags! {
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
|
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
|
||||||
pub struct StaticFlags: u8 {
|
pub struct StaticFlags: u8 {
|
||||||
const HAS_BODY = 1 << 0;
|
const HAS_BODY = 1 << 1;
|
||||||
const RUSTC_ALLOW_INCOHERENT_IMPL = 1 << 1;
|
const MUTABLE = 1 << 3;
|
||||||
const MUTABLE = 1 << 2;
|
const UNSAFE = 1 << 4;
|
||||||
const HAS_UNSAFE = 1 << 3;
|
const EXPLICIT_SAFE = 1 << 5;
|
||||||
const HAS_SAFE = 1 << 4;
|
const EXTERN = 1 << 6;
|
||||||
const IS_EXTERN = 1 << 5;
|
const RUSTC_ALLOW_INCOHERENT_IMPL = 1 << 7;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -302,7 +302,7 @@ impl StaticSignature {
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches!(loc.container, ItemContainerId::ExternBlockId(_)) {
|
if matches!(loc.container, ItemContainerId::ExternBlockId(_)) {
|
||||||
flags.insert(StaticFlags::IS_EXTERN);
|
flags.insert(StaticFlags::EXTERN);
|
||||||
}
|
}
|
||||||
|
|
||||||
let source = loc.source(db);
|
let source = loc.source(db);
|
||||||
|
|
@ -313,10 +313,10 @@ impl StaticSignature {
|
||||||
flags.insert(StaticFlags::MUTABLE);
|
flags.insert(StaticFlags::MUTABLE);
|
||||||
}
|
}
|
||||||
if source.value.unsafe_token().is_some() {
|
if source.value.unsafe_token().is_some() {
|
||||||
flags.insert(StaticFlags::HAS_UNSAFE);
|
flags.insert(StaticFlags::UNSAFE);
|
||||||
}
|
}
|
||||||
if source.value.safe_token().is_some() {
|
if source.value.safe_token().is_some() {
|
||||||
flags.insert(StaticFlags::HAS_SAFE);
|
flags.insert(StaticFlags::EXPLICIT_SAFE);
|
||||||
}
|
}
|
||||||
|
|
||||||
let (store, source_map, type_ref) =
|
let (store, source_map, type_ref) =
|
||||||
|
|
@ -337,8 +337,8 @@ impl StaticSignature {
|
||||||
bitflags::bitflags! {
|
bitflags::bitflags! {
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
|
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
|
||||||
pub struct ImplFlags: u8 {
|
pub struct ImplFlags: u8 {
|
||||||
const IS_NEGATIVE = 1 << 0;
|
const NEGATIVE = 1 << 1;
|
||||||
const IS_UNSAFE = 1 << 1;
|
const UNSAFE = 1 << 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -358,10 +358,10 @@ impl ImplSignature {
|
||||||
let mut flags = ImplFlags::empty();
|
let mut flags = ImplFlags::empty();
|
||||||
let src = loc.source(db);
|
let src = loc.source(db);
|
||||||
if src.value.unsafe_token().is_some() {
|
if src.value.unsafe_token().is_some() {
|
||||||
flags.insert(ImplFlags::IS_UNSAFE);
|
flags.insert(ImplFlags::UNSAFE);
|
||||||
}
|
}
|
||||||
if src.value.excl_token().is_some() {
|
if src.value.excl_token().is_some() {
|
||||||
flags.insert(ImplFlags::IS_NEGATIVE);
|
flags.insert(ImplFlags::NEGATIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
let (store, source_map, self_ty, target_trait, generic_params) =
|
let (store, source_map, self_ty, target_trait, generic_params) =
|
||||||
|
|
@ -383,13 +383,13 @@ impl ImplSignature {
|
||||||
bitflags::bitflags! {
|
bitflags::bitflags! {
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
|
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
|
||||||
pub struct TraitFlags: u8 {
|
pub struct TraitFlags: u8 {
|
||||||
const IS_AUTO = 1 << 0;
|
const RUSTC_HAS_INCOHERENT_INHERENT_IMPLS = 1 << 1;
|
||||||
const IS_UNSAFE = 1 << 1;
|
const FUNDAMENTAL = 1 << 2;
|
||||||
const IS_FUNDAMENTAL = 1 << 2;
|
const UNSAFE = 1 << 3;
|
||||||
const RUSTC_HAS_INCOHERENT_INHERENT_IMPLS = 1 << 3;
|
const AUTO = 1 << 4;
|
||||||
const SKIP_ARRAY_DURING_METHOD_DISPATCH = 1 << 4;
|
const SKIP_ARRAY_DURING_METHOD_DISPATCH = 1 << 5;
|
||||||
const SKIP_BOXED_SLICE_DURING_METHOD_DISPATCH = 1 << 5;
|
const SKIP_BOXED_SLICE_DURING_METHOD_DISPATCH = 1 << 6;
|
||||||
const RUSTC_PAREN_SUGAR = 1 << 6;
|
const RUSTC_PAREN_SUGAR = 1 << 7;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -410,13 +410,13 @@ impl TraitSignature {
|
||||||
let attrs = item_tree.attrs(db, loc.container.krate, ModItem::from(loc.id.value).into());
|
let attrs = item_tree.attrs(db, loc.container.krate, ModItem::from(loc.id.value).into());
|
||||||
let source = loc.source(db);
|
let source = loc.source(db);
|
||||||
if source.value.auto_token().is_some() {
|
if source.value.auto_token().is_some() {
|
||||||
flags.insert(TraitFlags::IS_AUTO);
|
flags.insert(TraitFlags::AUTO);
|
||||||
}
|
}
|
||||||
if source.value.unsafe_token().is_some() {
|
if source.value.unsafe_token().is_some() {
|
||||||
flags.insert(TraitFlags::IS_UNSAFE);
|
flags.insert(TraitFlags::UNSAFE);
|
||||||
}
|
}
|
||||||
if attrs.by_key(&sym::fundamental).exists() {
|
if attrs.by_key(&sym::fundamental).exists() {
|
||||||
flags |= TraitFlags::IS_FUNDAMENTAL;
|
flags |= TraitFlags::FUNDAMENTAL;
|
||||||
}
|
}
|
||||||
if attrs.by_key(&sym::rustc_has_incoherent_inherent_impls).exists() {
|
if attrs.by_key(&sym::rustc_has_incoherent_inherent_impls).exists() {
|
||||||
flags |= TraitFlags::RUSTC_HAS_INCOHERENT_INHERENT_IMPLS;
|
flags |= TraitFlags::RUSTC_HAS_INCOHERENT_INHERENT_IMPLS;
|
||||||
|
|
@ -489,21 +489,21 @@ impl TraitAliasSignature {
|
||||||
bitflags! {
|
bitflags! {
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
|
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
|
||||||
pub struct FnFlags: u16 {
|
pub struct FnFlags: u16 {
|
||||||
const HAS_SELF_PARAM = 1 << 0;
|
|
||||||
const HAS_BODY = 1 << 1;
|
const HAS_BODY = 1 << 1;
|
||||||
const HAS_DEFAULT_KW = 1 << 2;
|
const DEFAULT = 1 << 2;
|
||||||
const HAS_CONST_KW = 1 << 3;
|
const CONST = 1 << 3;
|
||||||
const HAS_ASYNC_KW = 1 << 4;
|
const ASYNC = 1 << 4;
|
||||||
const HAS_UNSAFE_KW = 1 << 5;
|
const UNSAFE = 1 << 5;
|
||||||
const IS_VARARGS = 1 << 6;
|
const HAS_VARARGS = 1 << 6;
|
||||||
const HAS_SAFE_KW = 1 << 7;
|
const RUSTC_ALLOW_INCOHERENT_IMPL = 1 << 7;
|
||||||
|
const HAS_SELF_PARAM = 1 << 8;
|
||||||
/// The `#[target_feature]` attribute is necessary to check safety (with RFC 2396),
|
/// 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
|
/// 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
|
/// only very few functions with it. So we only encode its existence here, and lookup
|
||||||
/// it if needed.
|
/// it if needed.
|
||||||
const HAS_TARGET_FEATURE = 1 << 8;
|
const HAS_TARGET_FEATURE = 1 << 9;
|
||||||
const DEPRECATED_SAFE_2024 = 1 << 9;
|
const DEPRECATED_SAFE_2024 = 1 << 10;
|
||||||
const RUSTC_ALLOW_INCOHERENT_IMPLS = 1 << 10;
|
const EXPLICIT_SAFE = 1 << 11;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -532,7 +532,7 @@ impl FunctionSignature {
|
||||||
let mut flags = FnFlags::empty();
|
let mut flags = FnFlags::empty();
|
||||||
let attrs = item_tree.attrs(db, module.krate, ModItem::from(loc.id.value).into());
|
let attrs = item_tree.attrs(db, module.krate, ModItem::from(loc.id.value).into());
|
||||||
if attrs.by_key(&sym::rustc_allow_incoherent_impl).exists() {
|
if attrs.by_key(&sym::rustc_allow_incoherent_impl).exists() {
|
||||||
flags.insert(FnFlags::RUSTC_ALLOW_INCOHERENT_IMPLS);
|
flags.insert(FnFlags::RUSTC_ALLOW_INCOHERENT_IMPL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if attrs.by_key(&sym::target_feature).exists() {
|
if attrs.by_key(&sym::target_feature).exists() {
|
||||||
|
|
@ -546,20 +546,20 @@ impl FunctionSignature {
|
||||||
if attrs.by_key(&sym::rustc_deprecated_safe_2024).exists() {
|
if attrs.by_key(&sym::rustc_deprecated_safe_2024).exists() {
|
||||||
flags.insert(FnFlags::DEPRECATED_SAFE_2024);
|
flags.insert(FnFlags::DEPRECATED_SAFE_2024);
|
||||||
} else {
|
} else {
|
||||||
flags.insert(FnFlags::HAS_UNSAFE_KW);
|
flags.insert(FnFlags::UNSAFE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if source.value.async_token().is_some() {
|
if source.value.async_token().is_some() {
|
||||||
flags.insert(FnFlags::HAS_ASYNC_KW);
|
flags.insert(FnFlags::ASYNC);
|
||||||
}
|
}
|
||||||
if source.value.const_token().is_some() {
|
if source.value.const_token().is_some() {
|
||||||
flags.insert(FnFlags::HAS_CONST_KW);
|
flags.insert(FnFlags::CONST);
|
||||||
}
|
}
|
||||||
if source.value.default_token().is_some() {
|
if source.value.default_token().is_some() {
|
||||||
flags.insert(FnFlags::HAS_DEFAULT_KW);
|
flags.insert(FnFlags::DEFAULT);
|
||||||
}
|
}
|
||||||
if source.value.safe_token().is_some() {
|
if source.value.safe_token().is_some() {
|
||||||
flags.insert(FnFlags::HAS_SAFE_KW);
|
flags.insert(FnFlags::EXPLICIT_SAFE);
|
||||||
}
|
}
|
||||||
if source.value.body().is_some() {
|
if source.value.body().is_some() {
|
||||||
flags.insert(FnFlags::HAS_BODY);
|
flags.insert(FnFlags::HAS_BODY);
|
||||||
|
|
@ -575,7 +575,7 @@ impl FunctionSignature {
|
||||||
flags.insert(FnFlags::HAS_SELF_PARAM);
|
flags.insert(FnFlags::HAS_SELF_PARAM);
|
||||||
}
|
}
|
||||||
if variadic {
|
if variadic {
|
||||||
flags.insert(FnFlags::IS_VARARGS);
|
flags.insert(FnFlags::HAS_VARARGS);
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
Arc::new(FunctionSignature {
|
Arc::new(FunctionSignature {
|
||||||
|
|
@ -603,19 +603,19 @@ impl FunctionSignature {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_default(&self) -> bool {
|
pub fn is_default(&self) -> bool {
|
||||||
self.flags.contains(FnFlags::HAS_DEFAULT_KW)
|
self.flags.contains(FnFlags::DEFAULT)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_const(&self) -> bool {
|
pub fn is_const(&self) -> bool {
|
||||||
self.flags.contains(FnFlags::HAS_CONST_KW)
|
self.flags.contains(FnFlags::CONST)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_async(&self) -> bool {
|
pub fn is_async(&self) -> bool {
|
||||||
self.flags.contains(FnFlags::HAS_ASYNC_KW)
|
self.flags.contains(FnFlags::ASYNC)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_unsafe(&self) -> bool {
|
pub fn is_unsafe(&self) -> bool {
|
||||||
self.flags.contains(FnFlags::HAS_UNSAFE_KW)
|
self.flags.contains(FnFlags::UNSAFE)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_deprecated_safe_2024(&self) -> bool {
|
pub fn is_deprecated_safe_2024(&self) -> bool {
|
||||||
|
|
@ -623,11 +623,11 @@ impl FunctionSignature {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_safe(&self) -> bool {
|
pub fn is_safe(&self) -> bool {
|
||||||
self.flags.contains(FnFlags::HAS_SAFE_KW)
|
self.flags.contains(FnFlags::EXPLICIT_SAFE)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_varargs(&self) -> bool {
|
pub fn is_varargs(&self) -> bool {
|
||||||
self.flags.contains(FnFlags::IS_VARARGS)
|
self.flags.contains(FnFlags::HAS_VARARGS)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn has_target_feature(&self) -> bool {
|
pub fn has_target_feature(&self) -> bool {
|
||||||
|
|
@ -637,10 +637,10 @@ impl FunctionSignature {
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
|
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
|
||||||
pub struct TypeAliasFlags: u16 {
|
pub struct TypeAliasFlags: u8 {
|
||||||
const IS_EXTERN = 1 << 7;
|
const RUSTC_HAS_INCOHERENT_INHERENT_IMPL = 1 << 1;
|
||||||
const RUSTC_ALLOW_INCOHERENT_IMPLS = 1 << 8;
|
const IS_EXTERN = 1 << 6;
|
||||||
const RUSTC_HAS_INCOHERENT_INHERENT_IMPLS = 1 << 9;
|
const RUSTC_ALLOW_INCOHERENT_IMPL = 1 << 7;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -669,10 +669,10 @@ impl TypeAliasSignature {
|
||||||
ModItem::from(loc.id.value).into(),
|
ModItem::from(loc.id.value).into(),
|
||||||
);
|
);
|
||||||
if attrs.by_key(&sym::rustc_has_incoherent_inherent_impls).exists() {
|
if attrs.by_key(&sym::rustc_has_incoherent_inherent_impls).exists() {
|
||||||
flags.insert(TypeAliasFlags::RUSTC_HAS_INCOHERENT_INHERENT_IMPLS);
|
flags.insert(TypeAliasFlags::RUSTC_HAS_INCOHERENT_INHERENT_IMPL);
|
||||||
}
|
}
|
||||||
if attrs.by_key(&sym::rustc_allow_incoherent_impl).exists() {
|
if attrs.by_key(&sym::rustc_allow_incoherent_impl).exists() {
|
||||||
flags.insert(TypeAliasFlags::RUSTC_ALLOW_INCOHERENT_IMPLS);
|
flags.insert(TypeAliasFlags::RUSTC_ALLOW_INCOHERENT_IMPL);
|
||||||
}
|
}
|
||||||
if matches!(loc.container, ItemContainerId::ExternBlockId(_)) {
|
if matches!(loc.container, ItemContainerId::ExternBlockId(_)) {
|
||||||
flags.insert(TypeAliasFlags::IS_EXTERN);
|
flags.insert(TypeAliasFlags::IS_EXTERN);
|
||||||
|
|
|
||||||
|
|
@ -674,13 +674,13 @@ pub(crate) fn trait_datum_query(
|
||||||
let generic_params = generics(db, trait_.into());
|
let generic_params = generics(db, trait_.into());
|
||||||
let bound_vars = generic_params.bound_vars_subst(db, DebruijnIndex::INNERMOST);
|
let bound_vars = generic_params.bound_vars_subst(db, DebruijnIndex::INNERMOST);
|
||||||
let flags = rust_ir::TraitFlags {
|
let flags = rust_ir::TraitFlags {
|
||||||
auto: trait_data.flags.contains(TraitFlags::IS_AUTO),
|
auto: trait_data.flags.contains(TraitFlags::AUTO),
|
||||||
upstream: trait_.lookup(db).container.krate() != krate,
|
upstream: trait_.lookup(db).container.krate() != krate,
|
||||||
non_enumerable: true,
|
non_enumerable: true,
|
||||||
coinductive: false, // only relevant for Chalk testing
|
coinductive: false, // only relevant for Chalk testing
|
||||||
// FIXME: set these flags correctly
|
// FIXME: set these flags correctly
|
||||||
marker: false,
|
marker: false,
|
||||||
fundamental: trait_data.flags.contains(TraitFlags::IS_FUNDAMENTAL),
|
fundamental: trait_data.flags.contains(TraitFlags::FUNDAMENTAL),
|
||||||
};
|
};
|
||||||
let where_clauses = convert_where_clauses(db, trait_.into(), &bound_vars);
|
let where_clauses = convert_where_clauses(db, trait_.into(), &bound_vars);
|
||||||
let associated_ty_ids =
|
let associated_ty_ids =
|
||||||
|
|
@ -761,10 +761,7 @@ pub(crate) fn adt_datum_query(
|
||||||
let (fundamental, phantom_data) = match adt_id {
|
let (fundamental, phantom_data) = match adt_id {
|
||||||
hir_def::AdtId::StructId(s) => {
|
hir_def::AdtId::StructId(s) => {
|
||||||
let flags = db.struct_signature(s).flags;
|
let flags = db.struct_signature(s).flags;
|
||||||
(
|
(flags.contains(StructFlags::FUNDAMENTAL), flags.contains(StructFlags::IS_PHANTOM_DATA))
|
||||||
flags.contains(StructFlags::IS_FUNDAMENTAL),
|
|
||||||
flags.contains(StructFlags::IS_PHANTOM_DATA),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
// FIXME set fundamental flags correctly
|
// FIXME set fundamental flags correctly
|
||||||
hir_def::AdtId::UnionId(_) => (false, false),
|
hir_def::AdtId::UnionId(_) => (false, false),
|
||||||
|
|
@ -851,7 +848,7 @@ fn impl_def_datum(db: &dyn HirDatabase, krate: Crate, impl_id: hir_def::ImplId)
|
||||||
rust_ir::ImplType::External
|
rust_ir::ImplType::External
|
||||||
};
|
};
|
||||||
let where_clauses = convert_where_clauses(db, impl_id.into(), &bound_vars);
|
let where_clauses = convert_where_clauses(db, impl_id.into(), &bound_vars);
|
||||||
let negative = impl_data.flags.contains(ImplFlags::IS_NEGATIVE);
|
let negative = impl_data.flags.contains(ImplFlags::NEGATIVE);
|
||||||
let polarity = if negative { rust_ir::Polarity::Negative } else { rust_ir::Polarity::Positive };
|
let polarity = if negative { rust_ir::Polarity::Negative } else { rust_ir::Polarity::Positive };
|
||||||
|
|
||||||
let impl_datum_bound = rust_ir::ImplDatumBound { trait_ref, where_clauses };
|
let impl_datum_bound = rust_ir::ImplDatumBound { trait_ref, where_clauses };
|
||||||
|
|
|
||||||
|
|
@ -560,7 +560,7 @@ impl<'a> DeclValidator<'a> {
|
||||||
|
|
||||||
fn validate_static(&mut self, static_id: StaticId) {
|
fn validate_static(&mut self, static_id: StaticId) {
|
||||||
let data = self.db.static_signature(static_id);
|
let data = self.db.static_signature(static_id);
|
||||||
if data.flags.contains(StaticFlags::IS_EXTERN) {
|
if data.flags.contains(StaticFlags::EXTERN) {
|
||||||
cov_mark::hit!(extern_static_incorrect_case_ignored);
|
cov_mark::hit!(extern_static_incorrect_case_ignored);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -361,8 +361,8 @@ impl<'a> UnsafeVisitor<'a> {
|
||||||
let static_data = self.db.static_signature(id);
|
let static_data = self.db.static_signature(id);
|
||||||
if static_data.flags.contains(StaticFlags::MUTABLE) {
|
if static_data.flags.contains(StaticFlags::MUTABLE) {
|
||||||
self.on_unsafe_op(node, UnsafetyReason::MutableStatic);
|
self.on_unsafe_op(node, UnsafetyReason::MutableStatic);
|
||||||
} else if static_data.flags.contains(StaticFlags::IS_EXTERN)
|
} else if static_data.flags.contains(StaticFlags::EXTERN)
|
||||||
&& !static_data.flags.contains(StaticFlags::HAS_SAFE)
|
&& !static_data.flags.contains(StaticFlags::EXPLICIT_SAFE)
|
||||||
{
|
{
|
||||||
self.on_unsafe_op(node, UnsafetyReason::ExternStatic);
|
self.on_unsafe_op(node, UnsafetyReason::ExternStatic);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -429,7 +429,7 @@ where
|
||||||
// Allow `impl AutoTrait` predicates
|
// Allow `impl AutoTrait` predicates
|
||||||
if let WhereClause::Implemented(TraitRef { trait_id, substitution }) = pred {
|
if let WhereClause::Implemented(TraitRef { trait_id, substitution }) = pred {
|
||||||
let trait_data = db.trait_signature(from_chalk_trait_id(*trait_id));
|
let trait_data = db.trait_signature(from_chalk_trait_id(*trait_id));
|
||||||
if trait_data.flags.contains(TraitFlags::IS_AUTO)
|
if trait_data.flags.contains(TraitFlags::AUTO)
|
||||||
&& substitution
|
&& substitution
|
||||||
.as_slice(Interner)
|
.as_slice(Interner)
|
||||||
.first()
|
.first()
|
||||||
|
|
|
||||||
|
|
@ -586,13 +586,13 @@ impl<'a> TyLoweringContext<'a> {
|
||||||
.db
|
.db
|
||||||
.trait_signature(from_chalk_trait_id(lhs_id))
|
.trait_signature(from_chalk_trait_id(lhs_id))
|
||||||
.flags
|
.flags
|
||||||
.contains(TraitFlags::IS_AUTO);
|
.contains(TraitFlags::AUTO);
|
||||||
let rhs_id = rhs.trait_id;
|
let rhs_id = rhs.trait_id;
|
||||||
let rhs_is_auto = ctx
|
let rhs_is_auto = ctx
|
||||||
.db
|
.db
|
||||||
.trait_signature(from_chalk_trait_id(rhs_id))
|
.trait_signature(from_chalk_trait_id(rhs_id))
|
||||||
.flags
|
.flags
|
||||||
.contains(TraitFlags::IS_AUTO);
|
.contains(TraitFlags::AUTO);
|
||||||
|
|
||||||
if !lhs_is_auto && !rhs_is_auto {
|
if !lhs_is_auto && !rhs_is_auto {
|
||||||
multiple_regular_traits = true;
|
multiple_regular_traits = true;
|
||||||
|
|
|
||||||
|
|
@ -386,15 +386,15 @@ pub fn def_crates(db: &dyn HirDatabase, ty: &Ty, cur_crate: Crate) -> Option<Sma
|
||||||
hir_def::AdtId::StructId(id) => db
|
hir_def::AdtId::StructId(id) => db
|
||||||
.struct_signature(id)
|
.struct_signature(id)
|
||||||
.flags
|
.flags
|
||||||
.contains(StructFlags::IS_RUSTC_HAS_INCOHERENT_INHERENT_IMPLS),
|
.contains(StructFlags::RUSTC_HAS_INCOHERENT_INHERENT_IMPLS),
|
||||||
hir_def::AdtId::UnionId(id) => db
|
hir_def::AdtId::UnionId(id) => db
|
||||||
.union_signature(id)
|
.union_signature(id)
|
||||||
.flags
|
.flags
|
||||||
.contains(StructFlags::IS_RUSTC_HAS_INCOHERENT_INHERENT_IMPLS),
|
.contains(StructFlags::RUSTC_HAS_INCOHERENT_INHERENT_IMPLS),
|
||||||
hir_def::AdtId::EnumId(id) => db
|
hir_def::AdtId::EnumId(id) => db
|
||||||
.enum_signature(id)
|
.enum_signature(id)
|
||||||
.flags
|
.flags
|
||||||
.contains(EnumFlags::IS_RUSTC_HAS_INCOHERENT_INHERENT_IMPLS),
|
.contains(EnumFlags::RUSTC_HAS_INCOHERENT_INHERENT_IMPLS),
|
||||||
};
|
};
|
||||||
Some(if rustc_has_incoherent_inherent_impls {
|
Some(if rustc_has_incoherent_inherent_impls {
|
||||||
db.incoherent_inherent_impl_crates(cur_crate, TyFingerprint::Adt(def_id))
|
db.incoherent_inherent_impl_crates(cur_crate, TyFingerprint::Adt(def_id))
|
||||||
|
|
@ -408,7 +408,7 @@ pub fn def_crates(db: &dyn HirDatabase, ty: &Ty, cur_crate: Crate) -> Option<Sma
|
||||||
if db
|
if db
|
||||||
.type_alias_signature(alias)
|
.type_alias_signature(alias)
|
||||||
.flags
|
.flags
|
||||||
.contains(TypeAliasFlags::RUSTC_HAS_INCOHERENT_INHERENT_IMPLS)
|
.contains(TypeAliasFlags::RUSTC_HAS_INCOHERENT_INHERENT_IMPL)
|
||||||
{
|
{
|
||||||
db.incoherent_inherent_impl_crates(cur_crate, TyFingerprint::ForeignType(id))
|
db.incoherent_inherent_impl_crates(cur_crate, TyFingerprint::ForeignType(id))
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -831,15 +831,15 @@ fn is_inherent_impl_coherent(
|
||||||
hir_def::AdtId::StructId(id) => db
|
hir_def::AdtId::StructId(id) => db
|
||||||
.struct_signature(id)
|
.struct_signature(id)
|
||||||
.flags
|
.flags
|
||||||
.contains(StructFlags::IS_RUSTC_HAS_INCOHERENT_INHERENT_IMPLS),
|
.contains(StructFlags::RUSTC_HAS_INCOHERENT_INHERENT_IMPLS),
|
||||||
hir_def::AdtId::UnionId(id) => db
|
hir_def::AdtId::UnionId(id) => db
|
||||||
.union_signature(id)
|
.union_signature(id)
|
||||||
.flags
|
.flags
|
||||||
.contains(StructFlags::IS_RUSTC_HAS_INCOHERENT_INHERENT_IMPLS),
|
.contains(StructFlags::RUSTC_HAS_INCOHERENT_INHERENT_IMPLS),
|
||||||
hir_def::AdtId::EnumId(it) => db
|
hir_def::AdtId::EnumId(it) => db
|
||||||
.enum_signature(it)
|
.enum_signature(it)
|
||||||
.flags
|
.flags
|
||||||
.contains(EnumFlags::IS_RUSTC_HAS_INCOHERENT_INHERENT_IMPLS),
|
.contains(EnumFlags::RUSTC_HAS_INCOHERENT_INHERENT_IMPLS),
|
||||||
},
|
},
|
||||||
TyKind::Dyn(it) => it.principal_id().is_some_and(|trait_id| {
|
TyKind::Dyn(it) => it.principal_id().is_some_and(|trait_id| {
|
||||||
db.trait_signature(from_chalk_trait_id(trait_id))
|
db.trait_signature(from_chalk_trait_id(trait_id))
|
||||||
|
|
@ -854,7 +854,7 @@ fn is_inherent_impl_coherent(
|
||||||
&& !items.items.is_empty()
|
&& !items.items.is_empty()
|
||||||
&& items.items.iter().all(|&(_, assoc)| match assoc {
|
&& items.items.iter().all(|&(_, assoc)| match assoc {
|
||||||
AssocItemId::FunctionId(it) => {
|
AssocItemId::FunctionId(it) => {
|
||||||
db.function_signature(it).flags.contains(FnFlags::RUSTC_ALLOW_INCOHERENT_IMPLS)
|
db.function_signature(it).flags.contains(FnFlags::RUSTC_ALLOW_INCOHERENT_IMPL)
|
||||||
}
|
}
|
||||||
AssocItemId::ConstId(it) => {
|
AssocItemId::ConstId(it) => {
|
||||||
db.const_signature(it).flags.contains(ConstFlags::RUSTC_ALLOW_INCOHERENT_IMPL)
|
db.const_signature(it).flags.contains(ConstFlags::RUSTC_ALLOW_INCOHERENT_IMPL)
|
||||||
|
|
@ -862,7 +862,7 @@ fn is_inherent_impl_coherent(
|
||||||
AssocItemId::TypeAliasId(it) => db
|
AssocItemId::TypeAliasId(it) => db
|
||||||
.type_alias_signature(it)
|
.type_alias_signature(it)
|
||||||
.flags
|
.flags
|
||||||
.contains(TypeAliasFlags::RUSTC_ALLOW_INCOHERENT_IMPLS),
|
.contains(TypeAliasFlags::RUSTC_ALLOW_INCOHERENT_IMPL),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -898,7 +898,7 @@ pub fn check_orphan_rules(db: &dyn HirDatabase, impl_: ImplId) -> bool {
|
||||||
TyKind::Ref(_, _, referenced) => ty = referenced.clone(),
|
TyKind::Ref(_, _, referenced) => ty = referenced.clone(),
|
||||||
&TyKind::Adt(AdtId(hir_def::AdtId::StructId(s)), ref subs) => {
|
&TyKind::Adt(AdtId(hir_def::AdtId::StructId(s)), ref subs) => {
|
||||||
let struct_signature = db.struct_signature(s);
|
let struct_signature = db.struct_signature(s);
|
||||||
if struct_signature.flags.contains(StructFlags::IS_FUNDAMENTAL) {
|
if struct_signature.flags.contains(StructFlags::FUNDAMENTAL) {
|
||||||
let next = subs.type_parameters(Interner).next();
|
let next = subs.type_parameters(Interner).next();
|
||||||
match next {
|
match next {
|
||||||
Some(it) => ty = it,
|
Some(it) => ty = it,
|
||||||
|
|
|
||||||
|
|
@ -2754,7 +2754,7 @@ impl Evaluator<'_> {
|
||||||
return Ok(*o);
|
return Ok(*o);
|
||||||
};
|
};
|
||||||
let static_data = self.db.static_signature(st);
|
let static_data = self.db.static_signature(st);
|
||||||
let result = if !static_data.flags.contains(StaticFlags::IS_EXTERN) {
|
let result = if !static_data.flags.contains(StaticFlags::EXTERN) {
|
||||||
let konst = self.db.const_eval_static(st).map_err(|e| {
|
let konst = self.db.const_eval_static(st).map_err(|e| {
|
||||||
MirEvalError::ConstEvalError(static_data.name.as_str().to_owned(), Box::new(e))
|
MirEvalError::ConstEvalError(static_data.name.as_str().to_owned(), Box::new(e))
|
||||||
})?;
|
})?;
|
||||||
|
|
|
||||||
|
|
@ -794,10 +794,10 @@ impl HirDisplay for Trait {
|
||||||
fn write_trait_header(trait_: &Trait, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
|
fn write_trait_header(trait_: &Trait, f: &mut HirFormatter<'_>) -> Result<(), HirDisplayError> {
|
||||||
write_visibility(trait_.module(f.db).id, trait_.visibility(f.db), f)?;
|
write_visibility(trait_.module(f.db).id, trait_.visibility(f.db), f)?;
|
||||||
let data = f.db.trait_signature(trait_.id);
|
let data = f.db.trait_signature(trait_.id);
|
||||||
if data.flags.contains(TraitFlags::IS_UNSAFE) {
|
if data.flags.contains(TraitFlags::UNSAFE) {
|
||||||
f.write_str("unsafe ")?;
|
f.write_str("unsafe ")?;
|
||||||
}
|
}
|
||||||
if data.flags.contains(TraitFlags::IS_AUTO) {
|
if data.flags.contains(TraitFlags::AUTO) {
|
||||||
f.write_str("auto ")?;
|
f.write_str("auto ")?;
|
||||||
}
|
}
|
||||||
write!(f, "trait {}", data.name.display(f.db, f.edition()))?;
|
write!(f, "trait {}", data.name.display(f.db, f.edition()))?;
|
||||||
|
|
|
||||||
|
|
@ -2898,11 +2898,11 @@ impl Trait {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_auto(self, db: &dyn HirDatabase) -> bool {
|
pub fn is_auto(self, db: &dyn HirDatabase) -> bool {
|
||||||
db.trait_signature(self.id).flags.contains(TraitFlags::IS_AUTO)
|
db.trait_signature(self.id).flags.contains(TraitFlags::AUTO)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_unsafe(&self, db: &dyn HirDatabase) -> bool {
|
pub fn is_unsafe(&self, db: &dyn HirDatabase) -> bool {
|
||||||
db.trait_signature(self.id).flags.contains(TraitFlags::IS_UNSAFE)
|
db.trait_signature(self.id).flags.contains(TraitFlags::UNSAFE)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn type_or_const_param_count(
|
pub fn type_or_const_param_count(
|
||||||
|
|
@ -4454,11 +4454,11 @@ impl Impl {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_negative(self, db: &dyn HirDatabase) -> bool {
|
pub fn is_negative(self, db: &dyn HirDatabase) -> bool {
|
||||||
db.impl_signature(self.id).flags.contains(ImplFlags::IS_NEGATIVE)
|
db.impl_signature(self.id).flags.contains(ImplFlags::NEGATIVE)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_unsafe(self, db: &dyn HirDatabase) -> bool {
|
pub fn is_unsafe(self, db: &dyn HirDatabase) -> bool {
|
||||||
db.impl_signature(self.id).flags.contains(ImplFlags::IS_UNSAFE)
|
db.impl_signature(self.id).flags.contains(ImplFlags::UNSAFE)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn module(self, db: &dyn HirDatabase) -> Module {
|
pub fn module(self, db: &dyn HirDatabase) -> Module {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue