fix: classify safe
as a contextual kw
This commit is contained in:
parent
1b90ae4892
commit
8183f6b473
@ -273,7 +273,7 @@ pub fn is_fn_unsafe_to_call(db: &dyn HirDatabase, func: FunctionId) -> bool {
|
|||||||
!data.attrs.by_key(&sym::rustc_safe_intrinsic).exists()
|
!data.attrs.by_key(&sym::rustc_safe_intrinsic).exists()
|
||||||
} else {
|
} else {
|
||||||
// Extern items without `safe` modifier are always unsafe
|
// Extern items without `safe` modifier are always unsafe
|
||||||
!db.function_data(func).is_safe()
|
!data.is_safe()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => false,
|
_ => false,
|
||||||
|
@ -554,7 +554,7 @@ fn rustc_deprecated_safe_2024() {
|
|||||||
r#"
|
r#"
|
||||||
//- /ed2021.rs crate:ed2021 edition:2021
|
//- /ed2021.rs crate:ed2021 edition:2021
|
||||||
#[rustc_deprecated_safe_2024]
|
#[rustc_deprecated_safe_2024]
|
||||||
unsafe fn safe_fn() -> u8 {
|
unsafe fn safe() -> u8 {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
//- /ed2024.rs crate:ed2024 edition:2024
|
//- /ed2024.rs crate:ed2024 edition:2024
|
||||||
@ -564,7 +564,7 @@ unsafe fn not_safe() -> u8 {
|
|||||||
}
|
}
|
||||||
//- /main.rs crate:main deps:ed2021,ed2024
|
//- /main.rs crate:main deps:ed2021,ed2024
|
||||||
fn main() {
|
fn main() {
|
||||||
ed2021::safe_fn();
|
ed2021::safe();
|
||||||
ed2024::not_safe();
|
ed2024::not_safe();
|
||||||
//^^^^^^^^^^^^^^^^^^💡 error: this operation is unsafe and requires an unsafe function or block
|
//^^^^^^^^^^^^^^^^^^💡 error: this operation is unsafe and requires an unsafe function or block
|
||||||
}
|
}
|
||||||
|
@ -135,8 +135,8 @@ pub(super) fn opt_item(p: &mut Parser<'_>, m: Marker) -> Result<(), Marker> {
|
|||||||
has_mods = true;
|
has_mods = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.at(T![safe]) {
|
if p.at_contextual_kw(T![safe]) {
|
||||||
p.eat(T![safe]);
|
p.eat_contextual_kw(T![safe]);
|
||||||
has_mods = true;
|
has_mods = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -111,7 +111,7 @@ fn to_tokens(&self, tokens: &mut proc_macro2::TokenStream) {
|
|||||||
// keywords that are keywords only in specific parse contexts
|
// keywords that are keywords only in specific parse contexts
|
||||||
#[doc(alias = "WEAK_KEYWORDS")]
|
#[doc(alias = "WEAK_KEYWORDS")]
|
||||||
const CONTEXTUAL_KEYWORDS: &[&str] =
|
const CONTEXTUAL_KEYWORDS: &[&str] =
|
||||||
&["macro_rules", "union", "default", "raw", "dyn", "auto", "yeet"];
|
&["macro_rules", "union", "default", "raw", "dyn", "auto", "yeet", "safe"];
|
||||||
// keywords we use for special macro expansions
|
// keywords we use for special macro expansions
|
||||||
const CONTEXTUAL_BUILTIN_KEYWORDS: &[&str] = &[
|
const CONTEXTUAL_BUILTIN_KEYWORDS: &[&str] = &[
|
||||||
"asm",
|
"asm",
|
||||||
|
Loading…
Reference in New Issue
Block a user