mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-03 21:25:25 +00:00
Don't mark #[rustc_deprecated_safe_2024] functions as unsafe
`std::env::set_var` will be unsafe in edition 2024, but not before it. I couldn't quite figure out how to check for the span properly, so for now we just turn the false positives into false negatives, which are less bad.
This commit is contained in:
parent
6b9baed80e
commit
0e1353bebd
3 changed files with 23 additions and 0 deletions
|
|
@ -534,6 +534,11 @@ fn parent_generic_def(db: &dyn DefDatabase, def: GenericDefId) -> Option<Generic
|
|||
pub fn is_fn_unsafe_to_call(db: &dyn HirDatabase, func: FunctionId) -> bool {
|
||||
let data = db.function_data(func);
|
||||
if data.has_unsafe_kw() {
|
||||
// Functions that are `#[rustc_deprecated_safe_2024]` are safe to call before 2024.
|
||||
if db.attrs(func.into()).by_key("rustc_deprecated_safe_2024").exists() {
|
||||
// FIXME: Properly check the caller span and mark it as unsafe after 2024.
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue