Skip to content

Commit 2328622

Browse files
committed
Rename deprecated_safe lint to deprecated_safe_2024
Create a lint group `deprecated_safe` that includes `deprecated_safe_2024`. Addresses #124866 (comment).
1 parent 8768db9 commit 2328622

File tree

6 files changed

+14
-12
lines changed

6 files changed

+14
-12
lines changed

compiler/rustc_lint/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,8 @@ fn register_builtins(store: &mut LintStore) {
316316
REFINING_IMPL_TRAIT_INTERNAL
317317
);
318318

319+
add_lint_group!("deprecated_safe", DEPRECATED_SAFE_2024);
320+
319321
// Register renamed and removed lints.
320322
store.register_renamed("single_use_lifetime", "single_use_lifetimes");
321323
store.register_renamed("elided_lifetime_in_path", "elided_lifetimes_in_paths");

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ declare_lint_pass! {
3737
DEPRECATED,
3838
DEPRECATED_CFG_ATTR_CRATE_TYPE_NAME,
3939
DEPRECATED_IN_FUTURE,
40-
DEPRECATED_SAFE,
40+
DEPRECATED_SAFE_2024,
4141
DEPRECATED_WHERE_CLAUSE_LOCATION,
4242
DUPLICATE_MACRO_ATTRIBUTES,
4343
ELIDED_LIFETIMES_IN_ASSOCIATED_CONSTANT,
@@ -4847,8 +4847,8 @@ declare_lint! {
48474847
}
48484848

48494849
declare_lint! {
4850-
/// The `deprecated_safe` lint detects unsafe functions being used as safe
4851-
/// functions.
4850+
/// The `deprecated_safe_2024` lint detects unsafe functions being used as
4851+
/// safe functions.
48524852
///
48534853
/// ### Example
48544854
///
@@ -4867,8 +4867,8 @@ declare_lint! {
48674867
///
48684868
/// Rust [editions] allow the language to evolve without breaking backward
48694869
/// compatibility. This lint catches code that uses `unsafe` functions that
4870-
/// were declared as safe (non-`unsafe`) in earlier editions. If you switch
4871-
/// the compiler to a new edition without updating the code, then it
4870+
/// were declared as safe (non-`unsafe`) in editions prior to Rust 2024. If
4871+
/// you switch the compiler to Rust 2024 without updating the code, then it
48724872
/// will fail to compile if you are using a function previously marked as
48734873
/// safe.
48744874
///
@@ -4885,7 +4885,7 @@ declare_lint! {
48854885
/// future.
48864886
///
48874887
/// [editions]: https://doc.rust-lang.org/edition-guide/
4888-
pub DEPRECATED_SAFE,
4888+
pub DEPRECATED_SAFE_2024,
48894889
Allow,
48904890
"detects unsafe functions being used as safe functions",
48914891
@future_incompatible = FutureIncompatibleInfo {

compiler/rustc_mir_build/src/check_unsafety.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_middle::thir::visit::Visitor;
99
use rustc_middle::thir::*;
1010
use rustc_middle::ty::print::with_no_trimmed_paths;
1111
use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt};
12-
use rustc_session::lint::builtin::{DEPRECATED_SAFE, UNSAFE_OP_IN_UNSAFE_FN, UNUSED_UNSAFE};
12+
use rustc_session::lint::builtin::{DEPRECATED_SAFE_2024, UNSAFE_OP_IN_UNSAFE_FN, UNUSED_UNSAFE};
1313
use rustc_session::lint::Level;
1414
use rustc_span::def_id::{DefId, LocalDefId};
1515
use rustc_span::symbol::Symbol;
@@ -118,7 +118,7 @@ impl<'tcx> UnsafetyVisitor<'_, 'tcx> {
118118
&& self.tcx.has_attr(id, sym::rustc_deprecated_safe_2024) =>
119119
{
120120
self.tcx.emit_node_span_lint(
121-
DEPRECATED_SAFE,
121+
DEPRECATED_SAFE_2024,
122122
self.hir_context,
123123
span,
124124
CallToDeprecatedSafeFnRequiresUnsafe {

tests/ui/rust-2024/unsafe-env-suggestion.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ run-rustfix
22

3-
#![deny(deprecated_safe)]
3+
#![deny(deprecated_safe_2024)]
44

55
use std::env;
66

tests/ui/rust-2024/unsafe-env-suggestion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ run-rustfix
22

3-
#![deny(deprecated_safe)]
3+
#![deny(deprecated_safe_2024)]
44

55
use std::env;
66

tests/ui/rust-2024/unsafe-env-suggestion.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ LL | env::set_var("FOO", "BAR");
99
note: the lint level is defined here
1010
--> $DIR/unsafe-env-suggestion.rs:3:9
1111
|
12-
LL | #![deny(deprecated_safe)]
13-
| ^^^^^^^^^^^^^^^
12+
LL | #![deny(deprecated_safe_2024)]
13+
| ^^^^^^^^^^^^^^^^^^^^
1414
help: you can wrap the call in an `unsafe` block if you can guarantee the code is only ever called from single-threaded code
1515
|
1616
LL | unsafe { env::set_var("FOO", "BAR") };

0 commit comments

Comments
 (0)