Skip to content

Commit f9dd7bb

Browse files
Remove unreachable-code feature (#9463)
## Summary We haven't found time to flip this on, so feels like it's best to remove it for now -- can always restore from source when we get back to it.
1 parent 350dcb8 commit f9dd7bb

18 files changed

+22
-4318
lines changed

crates/ruff_linter/Cargo.toml

-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ tempfile = { workspace = true }
8585
[features]
8686
default = []
8787
schemars = ["dep:schemars"]
88-
# Enables the UnreachableCode rule
89-
unreachable-code = []
9088

9189
[lints]
9290
workspace = true

crates/ruff_linter/resources/test/fixtures/ruff/RUF014.py

-185
This file was deleted.

crates/ruff_linter/src/checkers/ast/analyze/statement.rs

-6
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,6 @@ pub(crate) fn statement(stmt: &Stmt, checker: &mut Checker) {
355355
if checker.enabled(Rule::TrioAsyncFunctionWithTimeout) {
356356
flake8_trio::rules::async_function_with_timeout(checker, function_def);
357357
}
358-
#[cfg(feature = "unreachable-code")]
359-
if checker.enabled(Rule::UnreachableCode) {
360-
checker
361-
.diagnostics
362-
.extend(ruff::rules::unreachable::in_function(name, body));
363-
}
364358
if checker.enabled(Rule::ReimplementedOperator) {
365359
refurb::rules::reimplemented_operator(checker, &function_def.into());
366360
}

crates/ruff_linter/src/codes.rs

-3
Original file line numberDiff line numberDiff line change
@@ -914,9 +914,6 @@ pub fn code_to_rule(linter: Linter, code: &str) -> Option<(RuleGroup, Rule)> {
914914
(Ruff, "011") => (RuleGroup::Stable, rules::ruff::rules::StaticKeyDictComprehension),
915915
(Ruff, "012") => (RuleGroup::Stable, rules::ruff::rules::MutableClassDefault),
916916
(Ruff, "013") => (RuleGroup::Stable, rules::ruff::rules::ImplicitOptional),
917-
#[cfg(feature = "unreachable-code")] // When removing this feature gate, also update rules_selector.rs
918-
#[allow(deprecated)]
919-
(Ruff, "014") => (RuleGroup::Nursery, rules::ruff::rules::UnreachableCode),
920917
(Ruff, "015") => (RuleGroup::Stable, rules::ruff::rules::UnnecessaryIterableAllocationForFirstElement),
921918
(Ruff, "016") => (RuleGroup::Stable, rules::ruff::rules::InvalidIndexType),
922919
#[allow(deprecated)]

crates/ruff_linter/src/rule_selector.rs

+22-37
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,6 @@ mod schema {
289289
(!prefix.is_empty()).then(|| prefix.to_string())
290290
})),
291291
)
292-
// Filter out rule gated behind `#[cfg(feature = "unreachable-code")]`, which is
293-
// off-by-default
294-
.filter(|prefix| prefix != "RUF014")
295292
.sorted()
296293
.map(Value::String)
297294
.collect(),
@@ -407,40 +404,28 @@ pub mod clap_completion {
407404
let prefix = l.common_prefix();
408405
(!prefix.is_empty()).then(|| PossibleValue::new(prefix).help(l.name()))
409406
})
410-
.chain(
411-
RuleCodePrefix::iter()
412-
// Filter out rule gated behind `#[cfg(feature = "unreachable-code")]`, which is
413-
// off-by-default
414-
.filter(|prefix| {
415-
format!(
416-
"{}{}",
417-
prefix.linter().common_prefix(),
418-
prefix.short_code()
419-
) != "RUF014"
420-
})
421-
.filter_map(|prefix| {
422-
// Ex) `UP`
423-
if prefix.short_code().is_empty() {
424-
let code = prefix.linter().common_prefix();
425-
let name = prefix.linter().name();
426-
return Some(PossibleValue::new(code).help(name));
427-
}
428-
429-
// Ex) `UP004`
430-
if is_single_rule_selector(&prefix) {
431-
let rule = prefix.rules().next()?;
432-
let code = format!(
433-
"{}{}",
434-
prefix.linter().common_prefix(),
435-
prefix.short_code()
436-
);
437-
let name: &'static str = rule.into();
438-
return Some(PossibleValue::new(code).help(name));
439-
}
440-
441-
None
442-
}),
443-
),
407+
.chain(RuleCodePrefix::iter().filter_map(|prefix| {
408+
// Ex) `UP`
409+
if prefix.short_code().is_empty() {
410+
let code = prefix.linter().common_prefix();
411+
let name = prefix.linter().name();
412+
return Some(PossibleValue::new(code).help(name));
413+
}
414+
415+
// Ex) `UP004`
416+
if is_single_rule_selector(&prefix) {
417+
let rule = prefix.rules().next()?;
418+
let code = format!(
419+
"{}{}",
420+
prefix.linter().common_prefix(),
421+
prefix.short_code()
422+
);
423+
let name: &'static str = rule.into();
424+
return Some(PossibleValue::new(code).help(name));
425+
}
426+
427+
None
428+
})),
444429
),
445430
))
446431
}

crates/ruff_linter/src/rules/ruff/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ mod tests {
3737
Path::new("RUF015.py")
3838
)]
3939
#[test_case(Rule::InvalidIndexType, Path::new("RUF016.py"))]
40-
#[cfg_attr(
41-
feature = "unreachable-code",
42-
test_case(Rule::UnreachableCode, Path::new("RUF014.py"))
43-
)]
4440
#[test_case(Rule::QuadraticListSummation, Path::new("RUF017_1.py"))]
4541
#[test_case(Rule::QuadraticListSummation, Path::new("RUF017_0.py"))]
4642
#[test_case(Rule::AssignmentInAssert, Path::new("RUF018.py"))]

crates/ruff_linter/src/rules/ruff/rules/mod.rs

-4
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ pub(crate) use quadratic_list_summation::*;
1616
pub(crate) use static_key_dict_comprehension::*;
1717
pub(crate) use unnecessary_iterable_allocation_for_first_element::*;
1818
pub(crate) use unnecessary_key_check::*;
19-
#[cfg(feature = "unreachable-code")]
20-
pub(crate) use unreachable::*;
2119
pub(crate) use unused_noqa::*;
2220

2321
mod ambiguous_unicode_character;
@@ -39,8 +37,6 @@ mod parenthesize_logical_operators;
3937
mod static_key_dict_comprehension;
4038
mod unnecessary_iterable_allocation_for_first_element;
4139
mod unnecessary_key_check;
42-
#[cfg(feature = "unreachable-code")]
43-
pub(crate) mod unreachable;
4440
mod unused_noqa;
4541

4642
#[derive(Clone, Copy)]

0 commit comments

Comments
 (0)