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()
|
||||
} else {
|
||||
// Extern items without `safe` modifier are always unsafe
|
||||
!db.function_data(func).is_safe()
|
||||
!data.is_safe()
|
||||
}
|
||||
}
|
||||
_ => false,
|
||||
|
@ -554,7 +554,7 @@ fn rustc_deprecated_safe_2024() {
|
||||
r#"
|
||||
//- /ed2021.rs crate:ed2021 edition:2021
|
||||
#[rustc_deprecated_safe_2024]
|
||||
unsafe fn safe_fn() -> u8 {
|
||||
unsafe fn safe() -> u8 {
|
||||
0
|
||||
}
|
||||
//- /ed2024.rs crate:ed2024 edition:2024
|
||||
@ -564,7 +564,7 @@ unsafe fn not_safe() -> u8 {
|
||||
}
|
||||
//- /main.rs crate:main deps:ed2021,ed2024
|
||||
fn main() {
|
||||
ed2021::safe_fn();
|
||||
ed2021::safe();
|
||||
ed2024::not_safe();
|
||||
//^^^^^^^^^^^^^^^^^^💡 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;
|
||||
}
|
||||
|
||||
if p.at(T![safe]) {
|
||||
p.eat(T![safe]);
|
||||
if p.at_contextual_kw(T![safe]) {
|
||||
p.eat_contextual_kw(T![safe]);
|
||||
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
|
||||
#[doc(alias = "WEAK_KEYWORDS")]
|
||||
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
|
||||
const CONTEXTUAL_BUILTIN_KEYWORDS: &[&str] = &[
|
||||
"asm",
|
||||
|
Loading…
Reference in New Issue
Block a user