diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index bcb714ae4ce2a..a28aa493477aa 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -316,6 +316,8 @@ fn register_builtins(store: &mut LintStore) { REFINING_IMPL_TRAIT_INTERNAL ); + add_lint_group!("deprecated_safe", DEPRECATED_SAFE_2024); + // Register renamed and removed lints. store.register_renamed("single_use_lifetime", "single_use_lifetimes"); store.register_renamed("elided_lifetime_in_path", "elided_lifetimes_in_paths"); diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 93995fe60a365..9b21b06e38731 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -37,7 +37,7 @@ declare_lint_pass! { DEPRECATED, DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME, DEPRECATED_IN_FUTURE, - DEPRECATED_SAFE, + DEPRECATED_SAFE_2024, DEPRECATED_WHERE_CLAUSE_LOCATION, DUPLICATE_MACRO_ATTRIBUTES, ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT, @@ -4847,8 +4847,8 @@ declare_lint! { } declare_lint! { - /// The `deprecated_safe` lint detects unsafe functions being used as safe - /// functions. + /// The `deprecated_safe_2024` lint detects unsafe functions being used as + /// safe functions. /// /// ### Example /// @@ -4867,8 +4867,8 @@ declare_lint! { /// /// Rust [editions] allow the language to evolve without breaking backward /// compatibility. This lint catches code that uses `unsafe` functions that - /// were declared as safe (non-`unsafe`) in earlier editions. If you switch - /// the compiler to a new edition without updating the code, then it + /// were declared as safe (non-`unsafe`) in editions prior to Rust 2024. If + /// you switch the compiler to Rust 2024 without updating the code, then it /// will fail to compile if you are using a function previously marked as /// safe. /// @@ -4885,7 +4885,7 @@ declare_lint! { /// future. /// /// [editions]: https://doc.rust-lang.org/edition-guide/ - pub DEPRECATED_SAFE, + pub DEPRECATED_SAFE_2024, Allow, "detects unsafe functions being used as safe functions", @future_incompatible = FutureIncompatibleInfo { diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index 24098282d93b1..4ac6367ddf560 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -9,7 +9,7 @@ use rustc_middle::thir::visit::Visitor; use rustc_middle::thir::*; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt}; -use rustc_session::lint::builtin::{DEPRECATED_SAFE, UNSAFE_OP_IN_UNSAFE_FN, UNUSED_UNSAFE}; +use rustc_session::lint::builtin::{DEPRECATED_SAFE_2024, UNSAFE_OP_IN_UNSAFE_FN, UNUSED_UNSAFE}; use rustc_session::lint::Level; use rustc_span::def_id::{DefId, LocalDefId}; use rustc_span::symbol::Symbol; @@ -118,7 +118,7 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> { && self.tcx.has_attr(id, sym::rustc_deprecated_safe_2024) => { self.tcx.emit_node_span_lint( - DEPRECATED_SAFE, + DEPRECATED_SAFE_2024, self.hir_context, span, CallToDeprecatedSafeFnRequiresUnsafe { diff --git a/tests/ui/rust-2024/unsafe-env-suggestion.fixed b/tests/ui/rust-2024/unsafe-env-suggestion.fixed index d9c738edfacbd..b08bd67daa7da 100644 --- a/tests/ui/rust-2024/unsafe-env-suggestion.fixed +++ b/tests/ui/rust-2024/unsafe-env-suggestion.fixed @@ -1,6 +1,6 @@ //@ run-rustfix -#![deny(deprecated_safe)] +#![deny(deprecated_safe_2024)] use std::env; diff --git a/tests/ui/rust-2024/unsafe-env-suggestion.rs b/tests/ui/rust-2024/unsafe-env-suggestion.rs index 3bd169973e381..c039d7f258391 100644 --- a/tests/ui/rust-2024/unsafe-env-suggestion.rs +++ b/tests/ui/rust-2024/unsafe-env-suggestion.rs @@ -1,6 +1,6 @@ //@ run-rustfix -#![deny(deprecated_safe)] +#![deny(deprecated_safe_2024)] use std::env; diff --git a/tests/ui/rust-2024/unsafe-env-suggestion.stderr b/tests/ui/rust-2024/unsafe-env-suggestion.stderr index 90c91c2a474a6..a248d20b77595 100644 --- a/tests/ui/rust-2024/unsafe-env-suggestion.stderr +++ b/tests/ui/rust-2024/unsafe-env-suggestion.stderr @@ -9,8 +9,8 @@ LL | env::set_var("FOO", "BAR"); note: the lint level is defined here --> $DIR/unsafe-env-suggestion.rs:3:9 | -LL | #![deny(deprecated_safe)] - | ^^^^^^^^^^^^^^^ +LL | #![deny(deprecated_safe_2024)] + | ^^^^^^^^^^^^^^^^^^^^ help: you can wrap the call in an `unsafe` block if you can guarantee the code is only ever called from single-threaded code | LL | unsafe { env::set_var("FOO", "BAR") };