Remove ClippyCtfe pass

This commit is contained in:
Alex Macleod 2025-04-30 13:12:29 +00:00
parent 549107dbad
commit d49b8aa7d2
6 changed files with 12 additions and 85 deletions

View file

@ -1,26 +0,0 @@
use rustc_hir::def_id::LocalDefId;
use rustc_hir::intravisit::FnKind;
use rustc_hir::{Body, FnDecl};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::declare_lint_pass;
use rustc_span::Span;
declare_lint_pass! {
/// Ensures that Constant-time Function Evaluation is being done (specifically, MIR lint passes).
/// As Clippy deactivates codegen, this lint ensures that CTFE (used in hard errors) is still ran.
ClippyCtfe => []
}
impl<'tcx> LateLintPass<'tcx> for ClippyCtfe {
fn check_fn(
&mut self,
cx: &LateContext<'_>,
_: FnKind<'tcx>,
_: &'tcx FnDecl<'tcx>,
_: &'tcx Body<'tcx>,
_: Span,
defid: LocalDefId,
) {
cx.tcx.ensure_ok().mir_drops_elaborated_and_const_checked(defid); // Lint
}
}

View file

@ -67,7 +67,6 @@ extern crate clippy_utils;
mod utils;
pub mod ctfe; // Very important lint, do not remove (rust#125116)
pub mod declared_lints;
pub mod deprecated_lints;
@ -583,8 +582,6 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
let attrs = attr_storage.clone();
store.register_early_pass(move || Box::new(AttrCollector::new(attrs.clone())));
store.register_late_pass(|_| Box::new(ctfe::ClippyCtfe));
store.register_late_pass(move |_| Box::new(operators::arithmetic_side_effects::ArithmeticSideEffects::new(conf)));
store.register_late_pass(|_| Box::new(utils::dump_hir::DumpHir));
store.register_late_pass(|_| Box::new(utils::author::Author));

View file

@ -1,8 +1,7 @@
#![deny(arithmetic_overflow)]
//@check-pass
fn main() {
let _x = -1_i32 >> -1;
//~^ ERROR: this arithmetic operation will overflow
#[expect(overflowing_literals)]
let _y = 1u32 >> 10000000000000u32;
//~^ ERROR: this arithmetic operation will overflow
//~| ERROR: literal out of range
}

View file

@ -1,29 +0,0 @@
error: this arithmetic operation will overflow
--> tests/ui/crashes/ice-9463.rs:3:14
|
LL | let _x = -1_i32 >> -1;
| ^^^^^^^^^^^^ attempt to shift right by `-1_i32`, which would overflow
|
note: the lint level is defined here
--> tests/ui/crashes/ice-9463.rs:1:9
|
LL | #![deny(arithmetic_overflow)]
| ^^^^^^^^^^^^^^^^^^^
error: this arithmetic operation will overflow
--> tests/ui/crashes/ice-9463.rs:5:14
|
LL | let _y = 1u32 >> 10000000000000u32;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to shift right by `1316134912_u32`, which would overflow
error: literal out of range for `u32`
--> tests/ui/crashes/ice-9463.rs:5:22
|
LL | let _y = 1u32 >> 10000000000000u32;
| ^^^^^^^^^^^^^^^^^
|
= note: the literal `10000000000000u32` does not fit into the type `u32` whose range is `0..=4294967295`
= note: `#[deny(overflowing_literals)]` on by default
error: aborting due to 3 previous errors

View file

@ -68,7 +68,6 @@ fn main() {
// This should be linted, since `suppress-restriction-lint-in-const` default is false.
const { &ARR[idx4()] };
//~^ ERROR: indexing may panic
//~| ERROR: evaluation of `main
let y = &x;
// Ok, referencing shouldn't affect this lint. See the issue 6021

View file

@ -9,18 +9,6 @@ LL | const REF: &i32 = &ARR[idx()]; // This should be linted, since `suppress-re
= note: `-D clippy::indexing-slicing` implied by `-D warnings`
= help: to override `-D warnings` add `#[allow(clippy::indexing_slicing)]`
error[E0080]: evaluation of `main::{constant#3}` failed
--> tests/ui/indexing_slicing_index.rs:69:14
|
LL | const { &ARR[idx4()] };
| ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4
note: erroneous constant encountered
--> tests/ui/indexing_slicing_index.rs:69:5
|
LL | const { &ARR[idx4()] };
| ^^^^^^^^^^^^^^^^^^^^^^
error: indexing may panic
--> tests/ui/indexing_slicing_index.rs:48:5
|
@ -63,13 +51,13 @@ LL | const { &ARR[idx4()] };
= note: the suggestion might not be applicable in constant blocks
error: index is out of bounds
--> tests/ui/indexing_slicing_index.rs:77:5
--> tests/ui/indexing_slicing_index.rs:76:5
|
LL | y[4];
| ^^^^
error: indexing may panic
--> tests/ui/indexing_slicing_index.rs:81:5
--> tests/ui/indexing_slicing_index.rs:80:5
|
LL | v[0];
| ^^^^
@ -77,7 +65,7 @@ LL | v[0];
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: indexing may panic
--> tests/ui/indexing_slicing_index.rs:83:5
--> tests/ui/indexing_slicing_index.rs:82:5
|
LL | v[10];
| ^^^^^
@ -85,7 +73,7 @@ LL | v[10];
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: indexing may panic
--> tests/ui/indexing_slicing_index.rs:85:5
--> tests/ui/indexing_slicing_index.rs:84:5
|
LL | v[1 << 3];
| ^^^^^^^^^
@ -93,13 +81,13 @@ LL | v[1 << 3];
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: index is out of bounds
--> tests/ui/indexing_slicing_index.rs:93:5
--> tests/ui/indexing_slicing_index.rs:92:5
|
LL | x[N];
| ^^^^
error: indexing may panic
--> tests/ui/indexing_slicing_index.rs:97:5
--> tests/ui/indexing_slicing_index.rs:96:5
|
LL | v[N];
| ^^^^
@ -107,7 +95,7 @@ LL | v[N];
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: indexing may panic
--> tests/ui/indexing_slicing_index.rs:99:5
--> tests/ui/indexing_slicing_index.rs:98:5
|
LL | v[M];
| ^^^^
@ -115,11 +103,10 @@ LL | v[M];
= help: consider using `.get(n)` or `.get_mut(n)` instead
error: index is out of bounds
--> tests/ui/indexing_slicing_index.rs:103:13
--> tests/ui/indexing_slicing_index.rs:102:13
|
LL | let _ = x[4];
| ^^^^
error: aborting due to 15 previous errors
error: aborting due to 14 previous errors
For more information about this error, try `rustc --explain E0080`.