Auto merge of #17859 - Veykril:rustc_deprecated_safe_2024, r=Veykril

fix: Correctly support `#[rustc_deprecated_safe_2024]`

Fixes https://github.com/rust-lang/rust-analyzer/issues/17852
This commit is contained in:
bors 2024-08-12 08:59:08 +00:00
commit e2fd1db609
8 changed files with 44 additions and 19 deletions

View file

@ -158,7 +158,7 @@ impl Body {
}),
)
});
is_async_fn = data.has_async_kw();
is_async_fn = data.is_async();
src.map(|it| it.body().map(ast::Expr::from))
}
DefWithBodyId::ConstId(c) => {

View file

@ -94,6 +94,12 @@ impl FunctionData {
.filter(|it| !it.is_empty())
.map(Box::new);
let rustc_allow_incoherent_impl = attrs.by_key(&sym::rustc_allow_incoherent_impl).exists();
if flags.contains(FnFlags::HAS_UNSAFE_KW)
&& !crate_graph[krate].edition.at_least_2024()
&& attrs.by_key(&sym::rustc_deprecated_safe_2024).exists()
{
flags.remove(FnFlags::HAS_UNSAFE_KW);
}
Arc::new(FunctionData {
name: func.name.clone(),
@ -126,19 +132,19 @@ impl FunctionData {
self.flags.contains(FnFlags::HAS_SELF_PARAM)
}
pub fn has_default_kw(&self) -> bool {
pub fn is_default(&self) -> bool {
self.flags.contains(FnFlags::HAS_DEFAULT_KW)
}
pub fn has_const_kw(&self) -> bool {
pub fn is_const(&self) -> bool {
self.flags.contains(FnFlags::HAS_CONST_KW)
}
pub fn has_async_kw(&self) -> bool {
pub fn is_async(&self) -> bool {
self.flags.contains(FnFlags::HAS_ASYNC_KW)
}
pub fn has_unsafe_kw(&self) -> bool {
pub fn is_unsafe(&self) -> bool {
self.flags.contains(FnFlags::HAS_UNSAFE_KW)
}