Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rustup #13639

Merged
merged 53 commits into from
Nov 7, 2024
Merged

Rustup #13639

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
b95aa31
Stabilize `isqrt` feature
ChaiTRex Oct 8, 2024
fea5e77
Merge commit 'a109190d7060236e655fc75533373fa274ec5343' into clippy-s…
flip1995 Oct 18, 2024
91a458f
Hotfix TRAIT_METHODS static->const
flip1995 Oct 18, 2024
6983631
Do not run lints that cannot emit
blyxyas Nov 13, 2023
8f8aa46
Follow review comments (optimize the filtering)
blyxyas Jun 18, 2024
e427a4e
Remove module passes filtering
blyxyas Sep 7, 2024
e518d66
Apply review comments + use `shallow_lint_levels_on`
blyxyas Oct 15, 2024
69b0886
Fix tests
compiler-errors Sep 27, 2024
aab0eee
make unsupported_calling_conventions a hard error
RalfJung Sep 3, 2024
d8b2f93
Rip out old effects var handling code from traits
compiler-errors Oct 20, 2024
1d0dad5
Auto merge of #131988 - matthiaskrgr:rollup-tx173wn, r=matthiaskrgr
bors Oct 21, 2024
3773534
Move COGNITIVE_COMPLEXITY to use macro again
blyxyas Oct 19, 2024
f03f7c6
Auto merge of #129935 - RalfJung:unsupported_calling_conventions, r=c…
bors Oct 22, 2024
2fd8222
terminology: #[feature] *enables* a feature (instead of "declaring" o…
RalfJung Oct 8, 2024
78fc7bb
Auto merge of #131321 - RalfJung:feature-activation, r=nnethercote
bors Oct 22, 2024
088f07a
Represent TraitBoundModifiers as distinct parts in HIR
compiler-errors Oct 20, 2024
54f9bc4
nightly feature tracking: get rid of the per-feature bool fields
RalfJung Oct 9, 2024
eb6026a
Remove associated type based effects logic
compiler-errors Oct 20, 2024
5d681cf
Pass Ident by reference in ast Visitor
maxcabrajac Oct 24, 2024
a1ff955
Rollup merge of #132106 - maxcabrajac:ident_ref, r=petrochenkov
matthiaskrgr Oct 25, 2024
cd21594
tcx.is_const_fn doesn't work the way it is described, remove it
RalfJung Oct 12, 2024
8b9376a
Auto merge of #131349 - RalfJung:const-stability-checks, r=compiler-e…
bors Oct 25, 2024
350d1c4
Effects cleanup
fee1-dead Oct 26, 2024
b75d511
Rollup merge of #132168 - fee1-dead-contrib:fxclean, r=compiler-errors
matthiaskrgr Oct 26, 2024
9e36f89
Auto merge of #125116 - blyxyas:ignore-allowed-lints-final, r=cjgillot
bors Oct 26, 2024
303ab51
Rollup merge of #131391 - ChaiTRex:isqrt, r=scottmcm,tgross35
matthiaskrgr Oct 28, 2024
f286174
New lint: `dangling_pointers_from_temporaries`
GrigorenkoPV Oct 16, 2024
149665a
Auto merge of #128985 - GrigorenkoPV:instantly-dangling-pointer, r=Urgau
bors Oct 29, 2024
353868a
Remove region from adjustments
compiler-errors Oct 29, 2024
8d190cc
update tools
lcnr Oct 24, 2024
ae82c75
Remove `Analysis::into_engine`.
nnethercote Oct 29, 2024
297f28c
Rollup merge of #132338 - nnethercote:rm-Engine, r=nnethercote
matthiaskrgr Oct 30, 2024
d9a0fec
Remap impl-trait lifetimes on HIR instead of AST lowering.
cjgillot Aug 20, 2024
9f89421
Auto merge of #132301 - compiler-errors:adjust, r=lcnr
bors Oct 31, 2024
d30a0b2
`ConstCx` stop using `ParamEnv::reveal`
lcnr Oct 31, 2024
bad3edd
clippy: we've got a `LateContext` use it for `TypingMode`
lcnr Oct 31, 2024
d7850ec
stop using `ParamEnv::reveal` while handling MIR
lcnr Oct 31, 2024
c2db7fa
Rollup merge of #132403 - lcnr:typing-mode, r=compiler-errors
workingjubilee Nov 1, 2024
f0cf996
Rename the FIXMEs, remove a few that dont matter anymore
compiler-errors Nov 1, 2024
b14362f
ty::KContainer -> ty::AssocItemContainer::K
compiler-errors Nov 3, 2024
efeed55
Remove BorrowKind glob, make names longer
compiler-errors Nov 3, 2024
63d0ba9
Move two attribute lints to be early pass (post expansion)
jdonszelmann Nov 4, 2024
d8a3fcc
Auto merge of #132580 - compiler-errors:globs, r=Noratrieb
bors Nov 5, 2024
626406f
Do not filter empty passes & Make CTFE Clippy into lintless pass
blyxyas Nov 5, 2024
4847c40
Rollup merge of #132637 - blyxyas:lint-less-passes, r=flip1995
matthiaskrgr Nov 5, 2024
b816d4e
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Nov 7, 2024
03daf7c
Fix author lint and move it back to tests/ui
flip1995 Nov 7, 2024
4f12b98
Clean up declare_clippy_lint
flip1995 Nov 3, 2024
c64f1e3
Fix lint_without_lint_pass internal lint
flip1995 Nov 3, 2024
b27570b
Fix cargo dev update_lints
flip1995 Nov 3, 2024
a5d6100
Bump nightly version -> 2024-11-07
flip1995 Nov 7, 2024
d583df0
Remove ui/no_lints.rs test
flip1995 Nov 7, 2024
b116696
Remove CI badge from README and book
flip1995 Nov 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Clippy

[![Clippy Test](https://github.com/rust-lang/rust-clippy/workflows/Clippy%20Test%20(bors)/badge.svg?branch=auto&event=push)](https://github.com/rust-lang/rust-clippy/actions?query=workflow%3A%22Clippy+Test+(bors)%22+event%3Apush+branch%3Aauto)
[![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/clippy.svg)](#license)

A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.
Expand Down
1 change: 0 additions & 1 deletion book/src/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Clippy

[![Clippy Test](https://github.com/rust-lang/rust-clippy/workflows/Clippy%20Test%20(bors)/badge.svg?branch=auto&event=push)](https://github.com/rust-lang/rust-clippy/actions?query=workflow%3A%22Clippy+Test+(bors)%22+event%3Apush+branch%3Aauto)
[![License: MIT OR Apache-2.0](https://img.shields.io/crates/l/clippy.svg)](https://github.com/rust-lang/rust-clippy#license)

A collection of lints to catch common mistakes and improve your
Expand Down
20 changes: 13 additions & 7 deletions clippy_dev/src/update_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,13 +762,19 @@ fn parse_contents(contents: &str, module: &str, lints: &mut Vec<Lint>) {
Literal{..}(desc)
);

if let Some(LintDeclSearchResult {
token_kind: TokenKind::CloseBrace,
range,
..
}) = iter.next()
{
lints.push(Lint::new(name, group, desc, module, start..range.end));
if let Some(end) = iter.find_map(|t| {
if let LintDeclSearchResult {
token_kind: TokenKind::CloseBrace,
range,
..
} = t
{
Some(range.end)
} else {
None
}
}) {
lints.push(Lint::new(name, group, desc, module, start..end));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/attrs/allow_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::is_from_proc_macro;
use rustc_ast::{AttrStyle, Attribute};
use rustc_errors::Applicability;
use rustc_lint::{LateContext, LintContext};
use rustc_lint::{EarlyContext, LintContext};
use rustc_middle::lint::in_external_macro;

// Separate each crate's features.
pub fn check<'cx>(cx: &LateContext<'cx>, attr: &'cx Attribute) {
pub fn check<'cx>(cx: &EarlyContext<'cx>, attr: &'cx Attribute) {
if !in_external_macro(cx.sess(), attr.span)
&& let AttrStyle::Outer = attr.style
&& let Some(ident) = attr.ident()
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/attrs/allow_attributes_without_reason.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use super::{ALLOW_ATTRIBUTES_WITHOUT_REASON, Attribute};
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::is_from_proc_macro;
use rustc_ast::{MetaItemInner, MetaItemKind};
use rustc_lint::{LateContext, LintContext};
use rustc_lint::{EarlyContext, LintContext};
use rustc_middle::lint::in_external_macro;
use rustc_span::sym;
use rustc_span::symbol::Symbol;

pub(super) fn check<'cx>(cx: &LateContext<'cx>, name: Symbol, items: &[MetaItemInner], attr: &'cx Attribute) {
pub(super) fn check<'cx>(cx: &EarlyContext<'cx>, name: Symbol, items: &[MetaItemInner], attr: &'cx Attribute) {
// Check if the reason is present
if let Some(item) = items.last().and_then(MetaItemInner::meta_item)
&& let MetaItemKind::NameValue(_) = &item.kind
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/attrs/blanket_clippy_restriction_lints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use super::BLANKET_CLIPPY_RESTRICTION_LINTS;
use super::utils::extract_clippy_lint;
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_then};
use rustc_ast::MetaItemInner;
use rustc_lint::{LateContext, Level, LintContext};
use rustc_lint::{EarlyContext, Level, LintContext};
use rustc_span::symbol::Symbol;
use rustc_span::{DUMMY_SP, sym};

pub(super) fn check(cx: &LateContext<'_>, name: Symbol, items: &[MetaItemInner]) {
pub(super) fn check(cx: &EarlyContext<'_>, name: Symbol, items: &[MetaItemInner]) {
for lint in items {
if let Some(lint_name) = extract_clippy_lint(lint) {
if lint_name.as_str() == "restriction" && name != sym::allow {
Expand All @@ -23,7 +23,7 @@ pub(super) fn check(cx: &LateContext<'_>, name: Symbol, items: &[MetaItemInner])
}
}

pub(super) fn check_command_line(cx: &LateContext<'_>) {
pub(super) fn check_command_line(cx: &EarlyContext<'_>) {
for (name, level) in &cx.sess().opts.lint_opts {
if name == "clippy::restriction" && *level > Level::Allow {
span_lint_and_then(
Expand Down
4 changes: 2 additions & 2 deletions clippy_lints/src/attrs/deprecated_semver.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use super::DEPRECATED_SEMVER;
use clippy_utils::diagnostics::span_lint;
use rustc_ast::{LitKind, MetaItemLit};
use rustc_lint::LateContext;
use rustc_lint::EarlyContext;
use rustc_span::Span;
use semver::Version;

pub(super) fn check(cx: &LateContext<'_>, span: Span, lit: &MetaItemLit) {
pub(super) fn check(cx: &EarlyContext<'_>, span: Span, lit: &MetaItemLit) {
if let LitKind::Str(is, _) = lit.kind {
if is.as_str() == "TBD" || Version::parse(is.as_str()).is_ok() {
return;
Expand Down
8 changes: 4 additions & 4 deletions clippy_lints/src/attrs/duplicated_attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use super::DUPLICATED_ATTRIBUTES;
use clippy_utils::diagnostics::span_lint_and_then;
use rustc_ast::{Attribute, MetaItem};
use rustc_data_structures::fx::FxHashMap;
use rustc_lint::LateContext;
use rustc_lint::EarlyContext;
use rustc_span::{Span, sym};
use std::collections::hash_map::Entry;

fn emit_if_duplicated(
cx: &LateContext<'_>,
cx: &EarlyContext<'_>,
attr: &MetaItem,
attr_paths: &mut FxHashMap<String, Span>,
complete_path: String,
Expand All @@ -26,7 +26,7 @@ fn emit_if_duplicated(
}

fn check_duplicated_attr(
cx: &LateContext<'_>,
cx: &EarlyContext<'_>,
attr: &MetaItem,
attr_paths: &mut FxHashMap<String, Span>,
parent: &mut Vec<String>,
Expand Down Expand Up @@ -65,7 +65,7 @@ fn check_duplicated_attr(
}
}

pub fn check(cx: &LateContext<'_>, attrs: &[Attribute]) {
pub fn check(cx: &EarlyContext<'_>, attrs: &[Attribute]) {
let mut attr_paths = FxHashMap::default();

for attr in attrs {
Expand Down
6 changes: 3 additions & 3 deletions clippy_lints/src/attrs/mixed_attributes_style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint;
use rustc_ast::{AttrKind, AttrStyle, Attribute};
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::sync::Lrc;
use rustc_lint::{LateContext, LintContext};
use rustc_lint::{EarlyContext, LintContext};
use rustc_span::source_map::SourceMap;
use rustc_span::{SourceFile, Span, Symbol};

Expand Down Expand Up @@ -32,7 +32,7 @@ impl From<&AttrKind> for SimpleAttrKind {
}
}

pub(super) fn check(cx: &LateContext<'_>, item_span: Span, attrs: &[Attribute]) {
pub(super) fn check(cx: &EarlyContext<'_>, item_span: Span, attrs: &[Attribute]) {
let mut inner_attr_kind: FxHashSet<SimpleAttrKind> = FxHashSet::default();
let mut outer_attr_kind: FxHashSet<SimpleAttrKind> = FxHashSet::default();

Expand Down Expand Up @@ -64,7 +64,7 @@ pub(super) fn check(cx: &LateContext<'_>, item_span: Span, attrs: &[Attribute])
}
}

fn lint_mixed_attrs(cx: &LateContext<'_>, attrs: &[Attribute]) {
fn lint_mixed_attrs(cx: &EarlyContext<'_>, attrs: &[Attribute]) {
let mut attrs_iter = attrs.iter().filter(|attr| !attr.span.from_expansion());
let span = if let (Some(first), Some(last)) = (attrs_iter.next(), attrs_iter.last()) {
first.span.with_hi(last.span.hi())
Expand Down
128 changes: 76 additions & 52 deletions clippy_lints/src/attrs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ mod utils;

use clippy_config::Conf;
use clippy_config::msrvs::{self, Msrv};
use rustc_ast::{Attribute, MetaItemInner, MetaItemKind};
use rustc_hir::{ImplItem, Item, ItemKind, TraitItem};
use rustc_ast::{self as ast, Attribute, MetaItemInner, MetaItemKind};
use rustc_hir::{ImplItem, Item, TraitItem};
use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass};
use rustc_session::impl_lint_pass;
use rustc_span::sym;
Expand Down Expand Up @@ -414,15 +414,7 @@ pub struct Attributes {
}

impl_lint_pass!(Attributes => [
ALLOW_ATTRIBUTES,
ALLOW_ATTRIBUTES_WITHOUT_REASON,
INLINE_ALWAYS,
DEPRECATED_SEMVER,
USELESS_ATTRIBUTE,
BLANKET_CLIPPY_RESTRICTION_LINTS,
SHOULD_PANIC_WITHOUT_EXPECT,
MIXED_ATTRIBUTES_STYLE,
DUPLICATED_ATTRIBUTES,
]);

impl Attributes {
Expand All @@ -434,53 +426,11 @@ impl Attributes {
}

impl<'tcx> LateLintPass<'tcx> for Attributes {
fn check_crate(&mut self, cx: &LateContext<'tcx>) {
blanket_clippy_restriction_lints::check_command_line(cx);
duplicated_attributes::check(cx, cx.tcx.hir().krate_attrs());
}

fn check_attribute(&mut self, cx: &LateContext<'tcx>, attr: &'tcx Attribute) {
if let Some(items) = &attr.meta_item_list() {
if let Some(ident) = attr.ident() {
if is_lint_level(ident.name, attr.id) {
blanket_clippy_restriction_lints::check(cx, ident.name, items);
}
if matches!(ident.name, sym::allow) && self.msrv.meets(msrvs::LINT_REASONS_STABILIZATION) {
allow_attributes::check(cx, attr);
}
if matches!(ident.name, sym::allow | sym::expect) && self.msrv.meets(msrvs::LINT_REASONS_STABILIZATION)
{
allow_attributes_without_reason::check(cx, ident.name, items, attr);
}
if items.is_empty() || !attr.has_name(sym::deprecated) {
return;
}
for item in items {
if let MetaItemInner::MetaItem(mi) = &item
&& let MetaItemKind::NameValue(lit) = &mi.kind
&& mi.has_name(sym::since)
{
deprecated_semver::check(cx, item.span(), lit);
}
}
}
}
if attr.has_name(sym::should_panic) {
should_panic_without_expect::check(cx, attr);
}
}

fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
let attrs = cx.tcx.hir().attrs(item.hir_id());
if is_relevant_item(cx, item) {
inline_always::check(cx, item.span, item.ident.name, attrs);
}
match item.kind {
ItemKind::ExternCrate(..) | ItemKind::Use(..) => useless_attribute::check(cx, item, attrs),
_ => {},
}
mixed_attributes_style::check(cx, item.span, attrs);
duplicated_attributes::check(cx, attrs);
}

fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
Expand Down Expand Up @@ -526,3 +476,77 @@ impl EarlyLintPass for EarlyAttributes {

extract_msrv_attr!(EarlyContext);
}

pub struct PostExpansionEarlyAttributes {
msrv: Msrv,
}

impl PostExpansionEarlyAttributes {
pub fn new(conf: &'static Conf) -> Self {
Self {
msrv: conf.msrv.clone(),
}
}
}

impl_lint_pass!(PostExpansionEarlyAttributes => [
ALLOW_ATTRIBUTES,
ALLOW_ATTRIBUTES_WITHOUT_REASON,
DEPRECATED_SEMVER,
USELESS_ATTRIBUTE,
BLANKET_CLIPPY_RESTRICTION_LINTS,
SHOULD_PANIC_WITHOUT_EXPECT,
MIXED_ATTRIBUTES_STYLE,
DUPLICATED_ATTRIBUTES,
]);

impl EarlyLintPass for PostExpansionEarlyAttributes {
fn check_crate(&mut self, cx: &EarlyContext<'_>, krate: &ast::Crate) {
blanket_clippy_restriction_lints::check_command_line(cx);
duplicated_attributes::check(cx, &krate.attrs);
}

fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &Attribute) {
if let Some(items) = &attr.meta_item_list() {
if let Some(ident) = attr.ident() {
if matches!(ident.name, sym::allow) && self.msrv.meets(msrvs::LINT_REASONS_STABILIZATION) {
allow_attributes::check(cx, attr);
}
if matches!(ident.name, sym::allow | sym::expect) && self.msrv.meets(msrvs::LINT_REASONS_STABILIZATION)
{
allow_attributes_without_reason::check(cx, ident.name, items, attr);
}
if is_lint_level(ident.name, attr.id) {
blanket_clippy_restriction_lints::check(cx, ident.name, items);
}
if items.is_empty() || !attr.has_name(sym::deprecated) {
return;
}
for item in items {
if let MetaItemInner::MetaItem(mi) = &item
&& let MetaItemKind::NameValue(lit) = &mi.kind
&& mi.has_name(sym::since)
{
deprecated_semver::check(cx, item.span(), lit);
}
}
}
}

if attr.has_name(sym::should_panic) {
should_panic_without_expect::check(cx, attr);
}
}

fn check_item(&mut self, cx: &EarlyContext<'_>, item: &'_ ast::Item) {
match item.kind {
ast::ItemKind::ExternCrate(..) | ast::ItemKind::Use(..) => useless_attribute::check(cx, item, &item.attrs),
_ => {},
}

mixed_attributes_style::check(cx, item.span, &item.attrs);
duplicated_attributes::check(cx, &item.attrs);
}

extract_msrv_attr!(EarlyContext);
}
6 changes: 3 additions & 3 deletions clippy_lints/src/attrs/should_panic_without_expect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use rustc_ast::token::{Token, TokenKind};
use rustc_ast::tokenstream::TokenTree;
use rustc_ast::{AttrArgs, AttrArgsEq, AttrKind};
use rustc_errors::Applicability;
use rustc_lint::LateContext;
use rustc_lint::EarlyContext;
use rustc_span::sym;

pub(super) fn check(cx: &LateContext<'_>, attr: &Attribute) {
pub(super) fn check(cx: &EarlyContext<'_>, attr: &Attribute) {
if let AttrKind::Normal(normal_attr) = &attr.kind {
if let AttrArgs::Eq(_, AttrArgsEq::Hir(_)) = &normal_attr.item.args {
if let AttrArgs::Eq(_, AttrArgsEq::Ast(_)) = &normal_attr.item.args {
// `#[should_panic = ".."]` found, good
return;
}
Expand Down
9 changes: 4 additions & 5 deletions clippy_lints/src/attrs/useless_attribute.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
use super::USELESS_ATTRIBUTE;
use super::utils::{extract_clippy_lint, is_lint_level, is_word};
use super::{Attribute, USELESS_ATTRIBUTE};
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::source::{SpanRangeExt, first_line_of_span};
use rustc_ast::MetaItemInner;
use rustc_ast::{Attribute, Item, ItemKind, MetaItemInner};
use rustc_errors::Applicability;
use rustc_hir::{Item, ItemKind};
use rustc_lint::{LateContext, LintContext};
use rustc_lint::{EarlyContext, LintContext};
use rustc_middle::lint::in_external_macro;
use rustc_span::sym;

pub(super) fn check(cx: &LateContext<'_>, item: &Item<'_>, attrs: &[Attribute]) {
pub(super) fn check(cx: &EarlyContext<'_>, item: &Item, attrs: &[Attribute]) {
let skip_unused_imports = attrs.iter().any(|attr| attr.has_name(sym::macro_use));

for attr in attrs {
Expand Down
3 changes: 2 additions & 1 deletion clippy_lints/src/cognitive_complexity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ declare_clippy_lint! {
#[clippy::version = "1.35.0"]
pub COGNITIVE_COMPLEXITY,
nursery,
"functions that should be split up into multiple functions"
"functions that should be split up into multiple functions",
@eval_always = true
}

pub struct CognitiveComplexity {
Expand Down
26 changes: 26 additions & 0 deletions clippy_lints/src/ctfe.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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().mir_drops_elaborated_and_const_checked(defid); // Lint
}
}
Loading