Merge from rustc

This commit is contained in:
The Miri Cronjob Bot 2024-06-27 05:01:59 +00:00
commit a4e601ff40
309 changed files with 5872 additions and 2695 deletions

View file

@ -211,6 +211,13 @@ pub fn prepare_tool_cargo(
// See https://github.com/rust-lang/rust/issues/116538
cargo.rustflag("-Zunstable-options");
// `-Zon-broken-pipe=kill` breaks cargo tests
if !path.ends_with("cargo") {
// If the output is piped to e.g. `head -n1` we want the process to be killed,
// rather than having an error bubble up and cause a panic.
cargo.rustflag("-Zon-broken-pipe=kill");
}
cargo
}
@ -575,7 +582,8 @@ impl Step for Rustdoc {
features.push("jemalloc".to_string());
}
let mut cargo = prepare_tool_cargo(
// NOTE: Never modify the rustflags here, it breaks the build cache for other tools!
let cargo = prepare_tool_cargo(
builder,
build_compiler,
Mode::ToolRustc,
@ -586,11 +594,6 @@ impl Step for Rustdoc {
features.as_slice(),
);
// If the rustdoc output is piped to e.g. `head -n1` we want the process
// to be killed, rather than having an error bubble up and cause a
// panic.
cargo.rustflag("-Zon-broken-pipe=kill");
let _guard = builder.msg_tool(
Kind::Build,
Mode::ToolRustc,

View file

@ -35,4 +35,4 @@ COPY host-x86_64/mingw-check/validate-error-codes.sh /scripts/
# NOTE: intentionally uses python2 for x.py so we can test it still works.
# validate-toolstate only runs in our CI, so it's ok for it to only support python3.
ENV SCRIPT TIDY_PRINT_DIFF=1 python2.7 ../x.py test \
--stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint
--stage 0 src/tools/tidy tidyselftest --extra-checks=py:lint,cpp:fmt

View file

@ -1,12 +1,13 @@
# Lint Levels
In `rustc`, lints are divided into five *levels*:
In `rustc`, lints are divided into six *levels*:
1. allow
2. warn
3. force-warn
4. deny
5. forbid
2. expect
3. warn
4. force-warn
5. deny
6. forbid
Each lint has a default level (explained in the lint listing later in this
chapter), and the compiler has a default warning level. First, let's explain
@ -33,6 +34,40 @@ But this code violates the `missing_docs` lint.
These lints exist mostly to be manually turned on via configuration, as we'll
talk about later in this section.
## expect
Sometimes, it can be helpful to suppress lints, but at the same time ensure that
the code in question still emits them. The 'expect' level does exactly this. If
the lint in question is not emitted, the `unfulfilled_lint_expectation` lint
triggers on the `expect` attribute, notifying you that the expectation is no
longer fulfilled.
```rust
fn main() {
#[expect(unused_variables)]
let unused = "Everyone ignores me";
#[expect(unused_variables)] // `unused_variables` lint is not emitted
let used = "I'm useful"; // the expectation is therefore unfulfilled
println!("The `used` value is equal to: {:?}", used);
}
```
This will produce the following warning:
```txt
warning: this lint expectation is unfulfilled
--> src/main.rs:7:14
|
7 | #[expect(unused_variables)]
| ^^^^^^^^^^^^^^^^
|
= note: `#[warn(unfulfilled_lint_expectations)]` on by default
```
This level can only be defined via the `#[expect]` attribute, there is no equivalent
flag. Lints with the special 'force-warn' level will still be emitted as usual.
## warn
The 'warn' lint level will produce a warning if you violate the lint. For example,
@ -240,6 +275,21 @@ And use multiple attributes together:
pub fn foo() {}
```
All lint attributes support an additional `reason` parameter, to give context why
a certain attribute was added. This reason will be displayed as part of the lint
message, if the lint is emitted at the defined level.
```rust
use std::path::PathBuf;
pub fn get_path() -> PathBuf {
#[allow(unused_mut, reason = "this is only modified on some platforms")]
let mut file_name = PathBuf::from("git");
#[cfg(target_os = "windows")]
file_name.set_extension("exe");
file_name
}
```
### Capping lints
`rustc` supports a flag, `--cap-lints LEVEL` that sets the "lint cap level."

@ -1 +1 @@
Subproject commit bc89bffa5987d4af8f71011c7557119b39e44a65
Subproject commit 4ed7bee47f7dd4416b36fada1909e9a62c546246

View file

@ -1943,7 +1943,7 @@ Released 2022-05-19
[#8218](https://github.com/rust-lang/rust-clippy/pull/8218)
* [`needless_match`]
[#8471](https://github.com/rust-lang/rust-clippy/pull/8471)
* [`allow_attributes_without_reason`] (Requires `#![feature(lint_reasons)]`)
* [`allow_attributes_without_reason`]
[#8504](https://github.com/rust-lang/rust-clippy/pull/8504)
* [`print_in_format_impl`]
[#8253](https://github.com/rust-lang/rust-clippy/pull/8253)

View file

@ -669,6 +669,8 @@ The minimum rust version that the project supports. Defaults to the `rust-versio
---
**Affected lints:**
* [`allow_attributes`](https://rust-lang.github.io/rust-clippy/master/index.html#allow_attributes)
* [`allow_attributes_without_reason`](https://rust-lang.github.io/rust-clippy/master/index.html#allow_attributes_without_reason)
* [`almost_complete_range`](https://rust-lang.github.io/rust-clippy/master/index.html#almost_complete_range)
* [`approx_constant`](https://rust-lang.github.io/rust-clippy/master/index.html#approx_constant)
* [`assigning_clones`](https://rust-lang.github.io/rust-clippy/master/index.html#assigning_clones)

View file

@ -265,7 +265,7 @@ define_Conf! {
///
/// Suppress lints whenever the suggested change would cause breakage for other crates.
(avoid_breaking_exported_api: bool = true),
/// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS, TUPLE_ARRAY_CONVERSIONS, MANUAL_TRY_FOLD, MANUAL_HASH_ONE, ITER_KV_MAP, MANUAL_C_STR_LITERALS, ASSIGNING_CLONES, LEGACY_NUMERIC_CONSTANTS.
/// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS, TUPLE_ARRAY_CONVERSIONS, MANUAL_TRY_FOLD, MANUAL_HASH_ONE, ITER_KV_MAP, MANUAL_C_STR_LITERALS, ASSIGNING_CLONES, LEGACY_NUMERIC_CONSTANTS, ALLOW_ATTRIBUTES, ALLOW_ATTRIBUTES_WITHOUT_REASON.
///
/// The minimum rust version that the project supports. Defaults to the `rust-version` field in `Cargo.toml`
#[default_text = ""]

View file

@ -17,6 +17,7 @@ macro_rules! msrv_aliases {
// names may refer to stabilized feature flags or library items
msrv_aliases! {
1,81,0 { LINT_REASONS_STABILIZATION }
1,77,0 { C_STR_LITERALS }
1,76,0 { PTR_FROM_REF }
1,71,0 { TUPLE_ARRAY_CONVERSIONS, BUILD_HASHER_HASH_ONE }

View file

@ -1,74 +0,0 @@
use ast::{AttrStyle, Attribute};
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::is_from_proc_macro;
use rustc_ast as ast;
use rustc_errors::Applicability;
use rustc_lint::{LateContext, LateLintPass, LintContext};
use rustc_middle::lint::in_external_macro;
use rustc_session::declare_lint_pass;
declare_clippy_lint! {
/// ### What it does
/// Checks for usage of the `#[allow]` attribute and suggests replacing it with
/// the `#[expect]` (See [RFC 2383](https://rust-lang.github.io/rfcs/2383-lint-reasons.html))
///
/// The expect attribute is still unstable and requires the `lint_reasons`
/// on nightly. It can be enabled by adding `#![feature(lint_reasons)]` to
/// the crate root.
///
/// This lint only warns outer attributes (`#[allow]`), as inner attributes
/// (`#![allow]`) are usually used to enable or disable lints on a global scale.
///
/// ### Why restrict this?
/// `#[allow]` attributes can linger after their reason for existence is gone.
/// `#[expect]` attributes suppress the lint emission, but emit a warning if
/// the expectation is unfulfilled. This can be useful to be notified when the
/// lint is no longer triggered, which may indicate the attribute can be removed.
///
/// ### Example
/// ```rust,ignore
/// #[allow(unused_mut)]
/// fn foo() -> usize {
/// let mut a = Vec::new();
/// a.len()
/// }
/// ```
/// Use instead:
/// ```rust,ignore
/// #![feature(lint_reasons)]
/// #[expect(unused_mut)]
/// fn foo() -> usize {
/// let mut a = Vec::new();
/// a.len()
/// }
/// ```
#[clippy::version = "1.70.0"]
pub ALLOW_ATTRIBUTES,
restriction,
"`#[allow]` will not trigger if a warning isn't found. `#[expect]` triggers if there are no warnings."
}
declare_lint_pass!(AllowAttribute => [ALLOW_ATTRIBUTES]);
impl LateLintPass<'_> for AllowAttribute {
// Separate each crate's features.
fn check_attribute<'cx>(&mut self, cx: &LateContext<'cx>, attr: &'cx Attribute) {
if !in_external_macro(cx.sess(), attr.span)
&& cx.tcx.features().lint_reasons
&& let AttrStyle::Outer = attr.style
&& let Some(ident) = attr.ident()
&& ident.name == rustc_span::symbol::sym::allow
&& !is_from_proc_macro(cx, &attr)
{
span_lint_and_sugg(
cx,
ALLOW_ATTRIBUTES,
ident.span,
"#[allow] attribute found",
"replace it with",
"expect".into(),
Applicability::MachineApplicable,
);
}
}
}

View file

@ -0,0 +1,26 @@
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::is_from_proc_macro;
use rustc_ast::{AttrStyle, Attribute};
use rustc_errors::Applicability;
use rustc_lint::{LateContext, LintContext};
use rustc_middle::lint::in_external_macro;
use super::ALLOW_ATTRIBUTES;
// Separate each crate's features.
pub fn check<'cx>(cx: &LateContext<'cx>, attr: &'cx Attribute) {
if !in_external_macro(cx.sess(), attr.span)
&& let AttrStyle::Outer = attr.style
&& let Some(ident) = attr.ident()
&& !is_from_proc_macro(cx, &attr)
{
span_lint_and_sugg(
cx,
ALLOW_ATTRIBUTES,
ident.span,
"#[allow] attribute found",
"replace it with",
"expect".into(),
Applicability::MachineApplicable,
);
}
}

View file

@ -8,11 +8,6 @@ use rustc_span::sym;
use rustc_span::symbol::Symbol;
pub(super) fn check<'cx>(cx: &LateContext<'cx>, name: Symbol, items: &[NestedMetaItem], attr: &'cx Attribute) {
// Check for the feature
if !cx.tcx.features().lint_reasons {
return;
}
// Check if the reason is present
if let Some(item) = items.last().and_then(NestedMetaItem::meta_item)
&& let MetaItemKind::NameValue(_) = &item.kind

View file

@ -1,6 +1,7 @@
//! checks for attributes
mod allow_attributes_without_reason;
mod allow_attributes;
mod blanket_clippy_restriction_lints;
mod deprecated_cfg_attr;
mod deprecated_semver;
@ -14,11 +15,11 @@ mod unnecessary_clippy_cfg;
mod useless_attribute;
mod utils;
use clippy_config::msrvs::Msrv;
use clippy_config::msrvs::{self, Msrv};
use rustc_ast::{Attribute, MetaItemKind, NestedMetaItem};
use rustc_hir::{ImplItem, Item, ItemKind, TraitItem};
use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, impl_lint_pass};
use rustc_session::impl_lint_pass;
use rustc_span::sym;
use utils::{is_lint_level, is_relevant_impl, is_relevant_item, is_relevant_trait};
@ -272,23 +273,17 @@ declare_clippy_lint! {
/// ### What it does
/// Checks for attributes that allow lints without a reason.
///
/// (This requires the `lint_reasons` feature)
///
/// ### Why restrict this?
/// Justifying each `allow` helps readers understand the reasoning,
/// and may allow removing `allow` attributes if their purpose is obsolete.
///
/// ### Example
/// ```no_run
/// #![feature(lint_reasons)]
///
/// #![allow(clippy::some_lint)]
/// ```
///
/// Use instead:
/// ```no_run
/// #![feature(lint_reasons)]
///
/// #![allow(clippy::some_lint, reason = "False positive rust-lang/rust-clippy#1002020")]
/// ```
#[clippy::version = "1.61.0"]
@ -297,6 +292,41 @@ declare_clippy_lint! {
"ensures that all `allow` and `expect` attributes have a reason"
}
declare_clippy_lint! {
/// ### What it does
/// Checks for usage of the `#[allow]` attribute and suggests replacing it with
/// the `#[expect]` (See [RFC 2383](https://rust-lang.github.io/rfcs/2383-lint-reasons.html))
///
/// This lint only warns outer attributes (`#[allow]`), as inner attributes
/// (`#![allow]`) are usually used to enable or disable lints on a global scale.
///
/// ### Why is this bad?
/// `#[expect]` attributes suppress the lint emission, but emit a warning, if
/// the expectation is unfulfilled. This can be useful to be notified when the
/// lint is no longer triggered.
///
/// ### Example
/// ```rust,ignore
/// #[allow(unused_mut)]
/// fn foo() -> usize {
/// let mut a = Vec::new();
/// a.len()
/// }
/// ```
/// Use instead:
/// ```rust,ignore
/// #[expect(unused_mut)]
/// fn foo() -> usize {
/// let mut a = Vec::new();
/// a.len()
/// }
/// ```
#[clippy::version = "1.70.0"]
pub ALLOW_ATTRIBUTES,
restriction,
"`#[allow]` will not trigger if a warning isn't found. `#[expect]` triggers if there are no warnings."
}
declare_clippy_lint! {
/// ### What it does
/// Checks for `#[should_panic]` attributes without specifying the expected panic message.
@ -469,7 +499,12 @@ declare_clippy_lint! {
"duplicated attribute"
}
declare_lint_pass!(Attributes => [
#[derive(Clone)]
pub struct Attributes {
msrv: Msrv,
}
impl_lint_pass!(Attributes => [
ALLOW_ATTRIBUTES_WITHOUT_REASON,
INLINE_ALWAYS,
DEPRECATED_SEMVER,
@ -480,6 +515,13 @@ declare_lint_pass!(Attributes => [
DUPLICATED_ATTRIBUTES,
]);
impl Attributes {
#[must_use]
pub fn new(msrv: Msrv) -> Self {
Self { msrv }
}
}
impl<'tcx> LateLintPass<'tcx> for Attributes {
fn check_crate(&mut self, cx: &LateContext<'tcx>) {
blanket_clippy_restriction_lints::check_command_line(cx);
@ -492,8 +534,15 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
if is_lint_level(ident.name, attr.id) {
blanket_clippy_restriction_lints::check(cx, ident.name, items);
}
if matches!(ident.name, sym::allow) {
if self.msrv.meets(msrvs::LINT_REASONS_STABILIZATION) {
allow_attributes::check(cx, attr);
}
}
if matches!(ident.name, sym::allow | sym::expect) {
allow_attributes_without_reason::check(cx, ident.name, items, attr);
if 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;
@ -537,6 +586,8 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
inline_always::check(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()));
}
}
extract_msrv_attr!(LateContext);
}
pub struct EarlyAttributes {

View file

@ -38,7 +38,6 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
#[cfg(feature = "internal")]
crate::utils::internal_lints::unsorted_clippy_utils_paths::UNSORTED_CLIPPY_UTILS_PATHS_INFO,
crate::absolute_paths::ABSOLUTE_PATHS_INFO,
crate::allow_attributes::ALLOW_ATTRIBUTES_INFO,
crate::almost_complete_range::ALMOST_COMPLETE_RANGE_INFO,
crate::approx_const::APPROX_CONSTANT_INFO,
crate::arc_with_non_send_sync::ARC_WITH_NON_SEND_SYNC_INFO,
@ -49,6 +48,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
crate::assertions_on_result_states::ASSERTIONS_ON_RESULT_STATES_INFO,
crate::assigning_clones::ASSIGNING_CLONES_INFO,
crate::async_yields_async::ASYNC_YIELDS_ASYNC_INFO,
crate::attrs::ALLOW_ATTRIBUTES_INFO,
crate::attrs::ALLOW_ATTRIBUTES_WITHOUT_REASON_INFO,
crate::attrs::BLANKET_CLIPPY_RESTRICTION_LINTS_INFO,
crate::attrs::DEPRECATED_CFG_ATTR_INFO,

View file

@ -6,7 +6,7 @@ use clippy_utils::{
expr_use_ctxt, get_parent_expr, is_block_like, is_lint_allowed, path_to_local, DefinedTy, ExprUseNode,
};
use core::mem;
use rustc_ast::util::parser::{PREC_POSTFIX, PREC_PREFIX};
use rustc_ast::util::parser::{PREC_UNAMBIGUOUS, PREC_PREFIX};
use rustc_data_structures::fx::FxIndexMap;
use rustc_errors::Applicability;
use rustc_hir::intravisit::{walk_ty, Visitor};
@ -1013,7 +1013,7 @@ fn report<'tcx>(
let (precedence, calls_field) = match cx.tcx.parent_hir_node(data.first_expr.hir_id) {
Node::Expr(e) => match e.kind {
ExprKind::Call(callee, _) if callee.hir_id != data.first_expr.hir_id => (0, false),
ExprKind::Call(..) => (PREC_POSTFIX, matches!(expr.kind, ExprKind::Field(..))),
ExprKind::Call(..) => (PREC_UNAMBIGUOUS, matches!(expr.kind, ExprKind::Field(..))),
_ => (e.precedence().order(), false),
},
_ => (0, false),
@ -1160,7 +1160,7 @@ impl<'tcx> Dereferencing<'tcx> {
},
Some(parent) if !parent.span.from_expansion() => {
// Double reference might be needed at this point.
if parent.precedence().order() == PREC_POSTFIX {
if parent.precedence().order() == PREC_UNAMBIGUOUS {
// Parentheses would be needed here, don't lint.
*outer_pat = None;
} else {

View file

@ -6,7 +6,7 @@
#![feature(if_let_guard)]
#![feature(iter_intersperse)]
#![feature(let_chains)]
#![feature(lint_reasons)]
#![cfg_attr(bootstrap, feature(lint_reasons))]
#![feature(never_type)]
#![feature(rustc_private)]
#![feature(stmt_expr_attributes)]
@ -73,7 +73,6 @@ mod renamed_lints;
// begin lints modules, do not remove this comment, its used in `update_lints`
mod absolute_paths;
mod allow_attributes;
mod almost_complete_range;
mod approx_const;
mod arc_with_non_send_sync;
@ -699,7 +698,7 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
store.register_late_pass(|_| Box::new(mut_reference::UnnecessaryMutPassed));
store.register_late_pass(|_| Box::<significant_drop_tightening::SignificantDropTightening<'_>>::default());
store.register_late_pass(|_| Box::new(len_zero::LenZero));
store.register_late_pass(|_| Box::new(attrs::Attributes));
store.register_late_pass(move |_| Box::new(attrs::Attributes::new(msrv())));
store.register_late_pass(|_| Box::new(blocks_in_conditions::BlocksInConditions));
store.register_late_pass(|_| Box::new(unicode::Unicode));
store.register_late_pass(|_| Box::new(uninit_vec::UninitVec));
@ -1065,7 +1064,6 @@ pub fn register_lints(store: &mut rustc_lint::LintStore, conf: &'static Conf) {
store.register_late_pass(|_| Box::new(needless_maybe_sized::NeedlessMaybeSized));
store.register_late_pass(|_| Box::new(redundant_async_block::RedundantAsyncBlock));
store.register_late_pass(|_| Box::new(let_with_type_underscore::UnderscoreTyped));
store.register_late_pass(|_| Box::new(allow_attributes::AllowAttribute));
store.register_late_pass(move |_| Box::new(manual_main_separator_str::ManualMainSeparatorStr::new(msrv())));
store.register_late_pass(|_| Box::new(unnecessary_struct_initialization::UnnecessaryStruct));
store.register_late_pass(move |_| {

View file

@ -7,7 +7,7 @@ use clippy_utils::{
can_move_expr_to_closure, is_else_clause, is_lint_allowed, is_res_lang_ctor, path_res, path_to_local_id,
peel_blocks, peel_hir_expr_refs, peel_hir_expr_while, CaptureKind,
};
use rustc_ast::util::parser::PREC_POSTFIX;
use rustc_ast::util::parser::PREC_UNAMBIGUOUS;
use rustc_errors::Applicability;
use rustc_hir::def::Res;
use rustc_hir::LangItem::{OptionNone, OptionSome};
@ -117,7 +117,7 @@ where
// it's being passed by value.
let scrutinee = peel_hir_expr_refs(scrutinee).0;
let (scrutinee_str, _) = snippet_with_context(cx, scrutinee.span, expr_ctxt, "..", &mut app);
let scrutinee_str = if scrutinee.span.eq_ctxt(expr.span) && scrutinee.precedence().order() < PREC_POSTFIX {
let scrutinee_str = if scrutinee.span.eq_ctxt(expr.span) && scrutinee.precedence().order() < PREC_UNAMBIGUOUS {
format!("({scrutinee_str})")
} else {
scrutinee_str.into()

View file

@ -5,7 +5,7 @@
#![feature(f16)]
#![feature(if_let_guard)]
#![feature(let_chains)]
#![feature(lint_reasons)]
#![cfg_attr(bootstrap, feature(lint_reasons))]
#![feature(never_type)]
#![feature(rustc_private)]
#![feature(assert_matches)]

View file

@ -2,7 +2,7 @@
#![allow(rustc::untranslatable_diagnostic)]
#![feature(rustc_private)]
#![feature(let_chains)]
#![feature(lint_reasons)]
#![cfg_attr(bootstrap, feature(lint_reasons))]
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
// warn on lints, that are included in `rust-lang/rust`s bootstrap
#![warn(rust_2018_idioms, unused_lifetimes)]

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
mod a;

View file

@ -1,5 +1,5 @@
//! Tests macro_metavars_in_unsafe with default configuration
#![feature(decl_macro, lint_reasons)]
#![feature(decl_macro)]
#![warn(clippy::macro_metavars_in_unsafe)]
#![allow(clippy::no_effect)]

View file

@ -1,5 +1,5 @@
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:271:19
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:270:19
|
LL | /* Safety: */ unsafe {}
| ^^^^^^^^^
@ -9,7 +9,7 @@ LL | /* Safety: */ unsafe {}
= help: to override `-D warnings` add `#[allow(clippy::undocumented_unsafe_blocks)]`
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:275:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:5
|
LL | unsafe {}
| ^^^^^^^^^
@ -17,7 +17,7 @@ LL | unsafe {}
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:279:14
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:278:14
|
LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }];
| ^^^^^^^^^^^^^
@ -25,7 +25,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }];
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:279:29
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:278:29
|
LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }];
| ^^^^^^^^^^^^^
@ -33,7 +33,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }];
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:279:48
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:278:48
|
LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }];
| ^^^^^^^^^^^^^
@ -41,7 +41,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }];
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:283:18
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:282:18
|
LL | let _ = (42, unsafe {}, "test", unsafe {});
| ^^^^^^^^^
@ -49,7 +49,7 @@ LL | let _ = (42, unsafe {}, "test", unsafe {});
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:283:37
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:282:37
|
LL | let _ = (42, unsafe {}, "test", unsafe {});
| ^^^^^^^^^
@ -57,7 +57,7 @@ LL | let _ = (42, unsafe {}, "test", unsafe {});
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:287:14
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:286:14
|
LL | let _ = *unsafe { &42 };
| ^^^^^^^^^^^^^^
@ -65,7 +65,7 @@ LL | let _ = *unsafe { &42 };
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:292:19
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:291:19
|
LL | let _ = match unsafe {} {
| ^^^^^^^^^
@ -73,7 +73,7 @@ LL | let _ = match unsafe {} {
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:298:14
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:297:14
|
LL | let _ = &unsafe {};
| ^^^^^^^^^
@ -81,7 +81,7 @@ LL | let _ = &unsafe {};
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:302:14
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:301:14
|
LL | let _ = [unsafe {}; 5];
| ^^^^^^^^^
@ -89,7 +89,7 @@ LL | let _ = [unsafe {}; 5];
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:306:13
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:305:13
|
LL | let _ = unsafe {};
| ^^^^^^^^^
@ -97,7 +97,7 @@ LL | let _ = unsafe {};
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:316:8
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:315:8
|
LL | t!(unsafe {});
| ^^^^^^^^^
@ -105,7 +105,7 @@ LL | t!(unsafe {});
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:322:13
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:321:13
|
LL | unsafe {}
| ^^^^^^^^^
@ -117,7 +117,7 @@ LL | t!();
= note: this error originates in the macro `t` (in Nightly builds, run with -Z macro-backtrace for more info)
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:330:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:329:5
|
LL | unsafe {} // SAFETY:
| ^^^^^^^^^
@ -125,7 +125,7 @@ LL | unsafe {} // SAFETY:
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:334:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:333:5
|
LL | unsafe {
| ^^^^^^^^
@ -133,7 +133,7 @@ LL | unsafe {
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:344:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:343:5
|
LL | unsafe {};
| ^^^^^^^^^
@ -141,7 +141,7 @@ LL | unsafe {};
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:348:20
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:347:20
|
LL | println!("{}", unsafe { String::from_utf8_unchecked(vec![]) });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -149,7 +149,7 @@ LL | println!("{}", unsafe { String::from_utf8_unchecked(vec![]) });
= help: consider adding a safety comment on the preceding line
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:355:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:354:5
|
LL | unsafe impl A for () {}
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -157,7 +157,7 @@ LL | unsafe impl A for () {}
= help: consider adding a safety comment on the preceding line
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:362:9
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:361:9
|
LL | unsafe impl B for (u32) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -165,7 +165,7 @@ LL | unsafe impl B for (u32) {}
= help: consider adding a safety comment on the preceding line
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:383:13
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:382:13
|
LL | unsafe impl T for $t {}
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -177,7 +177,7 @@ LL | no_safety_comment!(());
= note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info)
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:408:13
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:407:13
|
LL | unsafe impl T for $t {}
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -189,7 +189,7 @@ LL | no_safety_comment!(());
= note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info)
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:416:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:415:5
|
LL | unsafe impl T for (i32) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -197,7 +197,7 @@ LL | unsafe impl T for (i32) {}
= help: consider adding a safety comment on the preceding line
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:408:13
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:407:13
|
LL | unsafe impl T for $t {}
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -209,7 +209,7 @@ LL | no_safety_comment!(u32);
= note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info)
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:422:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:421:5
|
LL | unsafe impl T for (bool) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -217,7 +217,7 @@ LL | unsafe impl T for (bool) {}
= help: consider adding a safety comment on the preceding line
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:468:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:467:5
|
LL | unsafe impl NoComment for () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -225,7 +225,7 @@ LL | unsafe impl NoComment for () {}
= help: consider adding a safety comment on the preceding line
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:472:19
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:471:19
|
LL | /* SAFETY: */ unsafe impl InlineComment for () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -233,7 +233,7 @@ LL | /* SAFETY: */ unsafe impl InlineComment for () {}
= help: consider adding a safety comment on the preceding line
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:476:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:475:5
|
LL | unsafe impl TrailingComment for () {} // SAFETY:
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -241,13 +241,13 @@ LL | unsafe impl TrailingComment for () {} // SAFETY:
= help: consider adding a safety comment on the preceding line
error: constant item has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:480:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:479:5
|
LL | const BIG_NUMBER: i32 = 1000000;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:479:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:478:5
|
LL | // SAFETY:
| ^^^^^^^^^^
@ -255,7 +255,7 @@ LL | // SAFETY:
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_safety_comment)]`
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:481:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:480:5
|
LL | unsafe impl Interference for () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -263,7 +263,7 @@ LL | unsafe impl Interference for () {}
= help: consider adding a safety comment on the preceding line
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:488:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:487:5
|
LL | unsafe impl ImplInFn for () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -271,7 +271,7 @@ LL | unsafe impl ImplInFn for () {}
= help: consider adding a safety comment on the preceding line
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:497:1
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:496:1
|
LL | unsafe impl CrateRoot for () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -279,7 +279,7 @@ LL | unsafe impl CrateRoot for () {}
= help: consider adding a safety comment on the preceding line
error: statement has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:510:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:509:5
|
LL | / let _ = {
LL | | if unsafe { true } {
@ -291,13 +291,13 @@ LL | | };
| |______^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:509:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:508:5
|
LL | // SAFETY: this is more than one level away, so it should warn
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:511:12
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:510:12
|
LL | if unsafe { true } {
| ^^^^^^^^^^^^^^^
@ -305,7 +305,7 @@ LL | if unsafe { true } {
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:514:23
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:513:23
|
LL | let bar = unsafe {};
| ^^^^^^^^^

View file

@ -1,5 +1,5 @@
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:271:19
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:270:19
|
LL | /* Safety: */ unsafe {}
| ^^^^^^^^^
@ -9,7 +9,7 @@ LL | /* Safety: */ unsafe {}
= help: to override `-D warnings` add `#[allow(clippy::undocumented_unsafe_blocks)]`
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:275:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:274:5
|
LL | unsafe {}
| ^^^^^^^^^
@ -17,7 +17,7 @@ LL | unsafe {}
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:279:14
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:278:14
|
LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }];
| ^^^^^^^^^^^^^
@ -25,7 +25,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }];
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:279:29
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:278:29
|
LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }];
| ^^^^^^^^^^^^^
@ -33,7 +33,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }];
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:279:48
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:278:48
|
LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }];
| ^^^^^^^^^^^^^
@ -41,7 +41,7 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }];
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:283:18
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:282:18
|
LL | let _ = (42, unsafe {}, "test", unsafe {});
| ^^^^^^^^^
@ -49,7 +49,7 @@ LL | let _ = (42, unsafe {}, "test", unsafe {});
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:283:37
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:282:37
|
LL | let _ = (42, unsafe {}, "test", unsafe {});
| ^^^^^^^^^
@ -57,7 +57,7 @@ LL | let _ = (42, unsafe {}, "test", unsafe {});
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:287:14
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:286:14
|
LL | let _ = *unsafe { &42 };
| ^^^^^^^^^^^^^^
@ -65,7 +65,7 @@ LL | let _ = *unsafe { &42 };
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:292:19
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:291:19
|
LL | let _ = match unsafe {} {
| ^^^^^^^^^
@ -73,7 +73,7 @@ LL | let _ = match unsafe {} {
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:298:14
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:297:14
|
LL | let _ = &unsafe {};
| ^^^^^^^^^
@ -81,7 +81,7 @@ LL | let _ = &unsafe {};
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:302:14
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:301:14
|
LL | let _ = [unsafe {}; 5];
| ^^^^^^^^^
@ -89,7 +89,7 @@ LL | let _ = [unsafe {}; 5];
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:306:13
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:305:13
|
LL | let _ = unsafe {};
| ^^^^^^^^^
@ -97,7 +97,7 @@ LL | let _ = unsafe {};
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:316:8
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:315:8
|
LL | t!(unsafe {});
| ^^^^^^^^^
@ -105,7 +105,7 @@ LL | t!(unsafe {});
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:322:13
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:321:13
|
LL | unsafe {}
| ^^^^^^^^^
@ -117,7 +117,7 @@ LL | t!();
= note: this error originates in the macro `t` (in Nightly builds, run with -Z macro-backtrace for more info)
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:330:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:329:5
|
LL | unsafe {} // SAFETY:
| ^^^^^^^^^
@ -125,7 +125,7 @@ LL | unsafe {} // SAFETY:
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:334:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:333:5
|
LL | unsafe {
| ^^^^^^^^
@ -133,7 +133,7 @@ LL | unsafe {
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:344:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:343:5
|
LL | unsafe {};
| ^^^^^^^^^
@ -141,7 +141,7 @@ LL | unsafe {};
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:348:20
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:347:20
|
LL | println!("{}", unsafe { String::from_utf8_unchecked(vec![]) });
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -149,7 +149,7 @@ LL | println!("{}", unsafe { String::from_utf8_unchecked(vec![]) });
= help: consider adding a safety comment on the preceding line
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:355:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:354:5
|
LL | unsafe impl A for () {}
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -157,7 +157,7 @@ LL | unsafe impl A for () {}
= help: consider adding a safety comment on the preceding line
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:362:9
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:361:9
|
LL | unsafe impl B for (u32) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -165,7 +165,7 @@ LL | unsafe impl B for (u32) {}
= help: consider adding a safety comment on the preceding line
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:383:13
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:382:13
|
LL | unsafe impl T for $t {}
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -177,7 +177,7 @@ LL | no_safety_comment!(());
= note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info)
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:408:13
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:407:13
|
LL | unsafe impl T for $t {}
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -189,7 +189,7 @@ LL | no_safety_comment!(());
= note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info)
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:416:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:415:5
|
LL | unsafe impl T for (i32) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -197,7 +197,7 @@ LL | unsafe impl T for (i32) {}
= help: consider adding a safety comment on the preceding line
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:408:13
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:407:13
|
LL | unsafe impl T for $t {}
| ^^^^^^^^^^^^^^^^^^^^^^^
@ -209,7 +209,7 @@ LL | no_safety_comment!(u32);
= note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info)
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:422:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:421:5
|
LL | unsafe impl T for (bool) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -217,7 +217,7 @@ LL | unsafe impl T for (bool) {}
= help: consider adding a safety comment on the preceding line
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:468:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:467:5
|
LL | unsafe impl NoComment for () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -225,7 +225,7 @@ LL | unsafe impl NoComment for () {}
= help: consider adding a safety comment on the preceding line
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:472:19
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:471:19
|
LL | /* SAFETY: */ unsafe impl InlineComment for () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -233,7 +233,7 @@ LL | /* SAFETY: */ unsafe impl InlineComment for () {}
= help: consider adding a safety comment on the preceding line
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:476:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:475:5
|
LL | unsafe impl TrailingComment for () {} // SAFETY:
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -241,13 +241,13 @@ LL | unsafe impl TrailingComment for () {} // SAFETY:
= help: consider adding a safety comment on the preceding line
error: constant item has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:480:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:479:5
|
LL | const BIG_NUMBER: i32 = 1000000;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:479:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:478:5
|
LL | // SAFETY:
| ^^^^^^^^^^
@ -255,7 +255,7 @@ LL | // SAFETY:
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_safety_comment)]`
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:481:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:480:5
|
LL | unsafe impl Interference for () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -263,7 +263,7 @@ LL | unsafe impl Interference for () {}
= help: consider adding a safety comment on the preceding line
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:488:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:487:5
|
LL | unsafe impl ImplInFn for () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -271,7 +271,7 @@ LL | unsafe impl ImplInFn for () {}
= help: consider adding a safety comment on the preceding line
error: unsafe impl missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:497:1
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:496:1
|
LL | unsafe impl CrateRoot for () {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -279,7 +279,7 @@ LL | unsafe impl CrateRoot for () {}
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:507:9
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:506:9
|
LL | unsafe {};
| ^^^^^^^^^
@ -287,7 +287,7 @@ LL | unsafe {};
= help: consider adding a safety comment on the preceding line
error: statement has unnecessary safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:510:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:509:5
|
LL | / let _ = {
LL | | if unsafe { true } {
@ -299,13 +299,13 @@ LL | | };
| |______^
|
help: consider removing the safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:509:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:508:5
|
LL | // SAFETY: this is more than one level away, so it should warn
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:511:12
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:510:12
|
LL | if unsafe { true } {
| ^^^^^^^^^^^^^^^
@ -313,7 +313,7 @@ LL | if unsafe { true } {
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:514:23
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:513:23
|
LL | let bar = unsafe {};
| ^^^^^^^^^
@ -321,7 +321,7 @@ LL | let bar = unsafe {};
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:532:9
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:531:9
|
LL | unsafe { a_function_with_a_very_long_name_to_break_the_line() };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -329,7 +329,7 @@ LL | unsafe { a_function_with_a_very_long_name_to_break_the_line() };
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:536:9
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:535:9
|
LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -337,7 +337,7 @@ LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line()
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:540:9
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:539:9
|
LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -345,7 +345,7 @@ LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line()
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:546:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:545:5
|
LL | unsafe {}
| ^^^^^^^^^
@ -353,7 +353,7 @@ LL | unsafe {}
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:550:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:549:5
|
LL | unsafe {
| ^^^^^^^^
@ -361,7 +361,7 @@ LL | unsafe {
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:557:9
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:556:9
|
LL | unsafe { a_function_with_a_very_long_name_to_break_the_line() };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -369,7 +369,7 @@ LL | unsafe { a_function_with_a_very_long_name_to_break_the_line() };
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:562:9
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:561:9
|
LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -377,7 +377,7 @@ LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line()
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:568:9
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:567:9
|
LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -385,7 +385,7 @@ LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line()
= help: consider adding a safety comment on the preceding line
error: unsafe block missing a safety comment
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:573:5
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:572:5
|
LL | unsafe {}
| ^^^^^^^^^

View file

@ -10,7 +10,6 @@
clippy::let_unit_value,
clippy::missing_safety_doc
)]
#![feature(lint_reasons)]
extern crate proc_macro_unsafe;

View file

@ -1,7 +1,6 @@
//@aux-build:proc_macros.rs
#![allow(unused)]
#![warn(clippy::allow_attributes)]
#![feature(lint_reasons)]
#![no_main]
extern crate proc_macros;
@ -47,3 +46,15 @@ fn ignore_proc_macro() {
fn ignore_inner_attr() {
#![allow(unused)] // Should not lint
}
#[clippy::msrv = "1.81"]
fn msrv_1_81() {
#[expect(unused)]
let x = 1;
}
#[clippy::msrv = "1.80"]
fn msrv_1_80() {
#[allow(unused)]
let x = 1;
}

View file

@ -1,7 +1,6 @@
//@aux-build:proc_macros.rs
#![allow(unused)]
#![warn(clippy::allow_attributes)]
#![feature(lint_reasons)]
#![no_main]
extern crate proc_macros;
@ -47,3 +46,15 @@ fn ignore_proc_macro() {
fn ignore_inner_attr() {
#![allow(unused)] // Should not lint
}
#[clippy::msrv = "1.81"]
fn msrv_1_81() {
#[allow(unused)]
let x = 1;
}
#[clippy::msrv = "1.80"]
fn msrv_1_80() {
#[allow(unused)]
let x = 1;
}

View file

@ -1,5 +1,5 @@
error: #[allow] attribute found
--> tests/ui/allow_attributes.rs:13:3
--> tests/ui/allow_attributes.rs:12:3
|
LL | #[allow(dead_code)]
| ^^^^^ help: replace it with: `expect`
@ -8,10 +8,24 @@ LL | #[allow(dead_code)]
= help: to override `-D warnings` add `#[allow(clippy::allow_attributes)]`
error: #[allow] attribute found
--> tests/ui/allow_attributes.rs:22:30
--> tests/ui/allow_attributes.rs:21:30
|
LL | #[cfg_attr(panic = "unwind", allow(dead_code))]
| ^^^^^ help: replace it with: `expect`
error: aborting due to 2 previous errors
error: #[allow] attribute found
--> tests/ui/allow_attributes.rs:52:7
|
LL | #[allow(unused)]
| ^^^^^ help: replace it with: `expect`
error: #[allow] attribute found
--> tests/ui/allow_attributes.rs:52:7
|
LL | #[allow(unused)]
| ^^^^^ help: replace it with: `expect`
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 4 previous errors

View file

@ -1,5 +1,4 @@
//@aux-build:proc_macros.rs
#![feature(lint_reasons)]
#![deny(clippy::allow_attributes_without_reason)]
#![allow(unfulfilled_lint_expectations, clippy::duplicated_attributes)]
@ -42,3 +41,15 @@ pub fn trigger_fp_result() -> Result<(), &'static str> {
Err("asdf")?;
Ok(())
}
#[clippy::msrv = "1.81"]
fn msrv_1_81() {
#[allow(unused)]
let _ = 1;
}
#[clippy::msrv = "1.80"]
fn msrv_1_80() {
#[allow(unused)]
let _ = 1;
}

View file

@ -1,18 +1,18 @@
error: `allow` attribute without specifying a reason
--> tests/ui/allow_attributes_without_reason.rs:4:1
--> tests/ui/allow_attributes_without_reason.rs:3:1
|
LL | #![allow(unfulfilled_lint_expectations, clippy::duplicated_attributes)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: try adding a reason at the end with `, reason = ".."`
note: the lint level is defined here
--> tests/ui/allow_attributes_without_reason.rs:3:9
--> tests/ui/allow_attributes_without_reason.rs:2:9
|
LL | #![deny(clippy::allow_attributes_without_reason)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: `allow` attribute without specifying a reason
--> tests/ui/allow_attributes_without_reason.rs:10:1
--> tests/ui/allow_attributes_without_reason.rs:9:1
|
LL | #[allow(dead_code)]
| ^^^^^^^^^^^^^^^^^^^
@ -20,7 +20,7 @@ LL | #[allow(dead_code)]
= help: try adding a reason at the end with `, reason = ".."`
error: `allow` attribute without specifying a reason
--> tests/ui/allow_attributes_without_reason.rs:11:1
--> tests/ui/allow_attributes_without_reason.rs:10:1
|
LL | #[allow(dead_code, deprecated)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -28,12 +28,29 @@ LL | #[allow(dead_code, deprecated)]
= help: try adding a reason at the end with `, reason = ".."`
error: `expect` attribute without specifying a reason
--> tests/ui/allow_attributes_without_reason.rs:12:1
--> tests/ui/allow_attributes_without_reason.rs:11:1
|
LL | #[expect(dead_code)]
| ^^^^^^^^^^^^^^^^^^^^
|
= help: try adding a reason at the end with `, reason = ".."`
error: aborting due to 4 previous errors
error: `allow` attribute without specifying a reason
--> tests/ui/allow_attributes_without_reason.rs:47:5
|
LL | #[allow(unused)]
| ^^^^^^^^^^^^^^^^
|
= help: try adding a reason at the end with `, reason = ".."`
error: `allow` attribute without specifying a reason
--> tests/ui/allow_attributes_without_reason.rs:47:5
|
LL | #[allow(unused)]
| ^^^^^^^^^^^^^^^^
|
= help: try adding a reason at the end with `, reason = ".."`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 6 previous errors

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![feature(async_closure)]
#![warn(clippy::async_yields_async)]
#![allow(clippy::redundant_async_block)]

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![feature(async_closure)]
#![warn(clippy::async_yields_async)]
#![allow(clippy::redundant_async_block)]

View file

@ -1,5 +1,5 @@
error: an async construct yields a type which is itself awaitable
--> tests/ui/async_yields_async.rs:39:9
--> tests/ui/async_yields_async.rs:38:9
|
LL | let _h = async {
| _____________________-
@ -20,7 +20,7 @@ LL + }.await
|
error: an async construct yields a type which is itself awaitable
--> tests/ui/async_yields_async.rs:44:9
--> tests/ui/async_yields_async.rs:43:9
|
LL | let _i = async {
| ____________________-
@ -33,7 +33,7 @@ LL | | };
| |_____- outer async construct
error: an async construct yields a type which is itself awaitable
--> tests/ui/async_yields_async.rs:50:9
--> tests/ui/async_yields_async.rs:49:9
|
LL | let _j = async || {
| ________________________-
@ -52,7 +52,7 @@ LL + }.await
|
error: an async construct yields a type which is itself awaitable
--> tests/ui/async_yields_async.rs:55:9
--> tests/ui/async_yields_async.rs:54:9
|
LL | let _k = async || {
| _______________________-
@ -65,7 +65,7 @@ LL | | };
| |_____- outer async construct
error: an async construct yields a type which is itself awaitable
--> tests/ui/async_yields_async.rs:57:23
--> tests/ui/async_yields_async.rs:56:23
|
LL | let _l = async || CustomFutureType;
| ^^^^^^^^^^^^^^^^
@ -75,7 +75,7 @@ LL | let _l = async || CustomFutureType;
| help: consider awaiting this value: `CustomFutureType.await`
error: an async construct yields a type which is itself awaitable
--> tests/ui/async_yields_async.rs:63:9
--> tests/ui/async_yields_async.rs:62:9
|
LL | let _m = async || {
| _______________________-

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![allow(
clippy::borrowed_box,
clippy::needless_pass_by_value,

View file

@ -1,5 +1,5 @@
error: local variable doesn't need to be boxed here
--> tests/ui/boxed_local.rs:40:13
--> tests/ui/boxed_local.rs:39:13
|
LL | fn warn_arg(x: Box<A>) {
| ^
@ -8,19 +8,19 @@ LL | fn warn_arg(x: Box<A>) {
= help: to override `-D warnings` add `#[allow(clippy::boxed_local)]`
error: local variable doesn't need to be boxed here
--> tests/ui/boxed_local.rs:123:12
--> tests/ui/boxed_local.rs:122:12
|
LL | pub fn new(_needs_name: Box<PeekableSeekable<&()>>) -> () {}
| ^^^^^^^^^^^
error: local variable doesn't need to be boxed here
--> tests/ui/boxed_local.rs:188:44
--> tests/ui/boxed_local.rs:187:44
|
LL | fn default_impl_x(self: Box<Self>, x: Box<u32>) -> u32 {
| ^
error: local variable doesn't need to be boxed here
--> tests/ui/boxed_local.rs:196:16
--> tests/ui/boxed_local.rs:195:16
|
LL | fn foo(x: Box<u32>) {}
| ^

View file

@ -1,5 +1,4 @@
//@no-rustfix: overlapping suggestions
#![feature(lint_reasons)]
#![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
#![allow(
clippy::if_same_then_else,

View file

@ -1,5 +1,5 @@
error: called `unwrap` on `x` after checking its variant with `is_some`
--> tests/ui/checked_unwrap/simple_conditionals.rs:47:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:46:9
|
LL | if x.is_some() {
| -------------- help: try: `if let Some(..) = x`
@ -8,13 +8,13 @@ LL | x.unwrap();
| ^^^^^^^^^^
|
note: the lint level is defined here
--> tests/ui/checked_unwrap/simple_conditionals.rs:3:35
--> tests/ui/checked_unwrap/simple_conditionals.rs:2:35
|
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: called `expect` on `x` after checking its variant with `is_some`
--> tests/ui/checked_unwrap/simple_conditionals.rs:50:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:49:9
|
LL | if x.is_some() {
| -------------- help: try: `if let Some(..) = x`
@ -23,7 +23,7 @@ LL | x.expect("an error message");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this call to `unwrap()` will always panic
--> tests/ui/checked_unwrap/simple_conditionals.rs:54:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:53:9
|
LL | if x.is_some() {
| ----------- because of this check
@ -32,13 +32,13 @@ LL | x.unwrap();
| ^^^^^^^^^^
|
note: the lint level is defined here
--> tests/ui/checked_unwrap/simple_conditionals.rs:3:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:2:9
|
LL | #![deny(clippy::panicking_unwrap, clippy::unnecessary_unwrap)]
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: this call to `expect()` will always panic
--> tests/ui/checked_unwrap/simple_conditionals.rs:57:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:56:9
|
LL | if x.is_some() {
| ----------- because of this check
@ -47,7 +47,7 @@ LL | x.expect("an error message");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this call to `unwrap()` will always panic
--> tests/ui/checked_unwrap/simple_conditionals.rs:62:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:61:9
|
LL | if x.is_none() {
| ----------- because of this check
@ -56,7 +56,7 @@ LL | x.unwrap();
| ^^^^^^^^^^
error: called `unwrap` on `x` after checking its variant with `is_none`
--> tests/ui/checked_unwrap/simple_conditionals.rs:66:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:65:9
|
LL | if x.is_none() {
| -------------- help: try: `if let Some(..) = x`
@ -65,7 +65,7 @@ LL | x.unwrap();
| ^^^^^^^^^^
error: called `unwrap` on `x` after checking its variant with `is_some`
--> tests/ui/checked_unwrap/simple_conditionals.rs:14:13
--> tests/ui/checked_unwrap/simple_conditionals.rs:13:13
|
LL | if $a.is_some() {
| --------------- help: try: `if let Some(..) = x`
@ -79,7 +79,7 @@ LL | m!(x);
= note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
error: called `unwrap` on `x` after checking its variant with `is_ok`
--> tests/ui/checked_unwrap/simple_conditionals.rs:79:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:78:9
|
LL | if x.is_ok() {
| ------------ help: try: `if let Ok(..) = x`
@ -88,7 +88,7 @@ LL | x.unwrap();
| ^^^^^^^^^^
error: called `expect` on `x` after checking its variant with `is_ok`
--> tests/ui/checked_unwrap/simple_conditionals.rs:82:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:81:9
|
LL | if x.is_ok() {
| ------------ help: try: `if let Ok(..) = x`
@ -97,7 +97,7 @@ LL | x.expect("an error message");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: this call to `unwrap_err()` will always panic
--> tests/ui/checked_unwrap/simple_conditionals.rs:85:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:84:9
|
LL | if x.is_ok() {
| --------- because of this check
@ -106,7 +106,7 @@ LL | x.unwrap_err();
| ^^^^^^^^^^^^^^
error: this call to `unwrap()` will always panic
--> tests/ui/checked_unwrap/simple_conditionals.rs:89:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:88:9
|
LL | if x.is_ok() {
| --------- because of this check
@ -115,7 +115,7 @@ LL | x.unwrap();
| ^^^^^^^^^^
error: this call to `expect()` will always panic
--> tests/ui/checked_unwrap/simple_conditionals.rs:92:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:91:9
|
LL | if x.is_ok() {
| --------- because of this check
@ -124,7 +124,7 @@ LL | x.expect("an error message");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: called `unwrap_err` on `x` after checking its variant with `is_ok`
--> tests/ui/checked_unwrap/simple_conditionals.rs:95:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:94:9
|
LL | if x.is_ok() {
| ------------ help: try: `if let Err(..) = x`
@ -133,7 +133,7 @@ LL | x.unwrap_err();
| ^^^^^^^^^^^^^^
error: this call to `unwrap()` will always panic
--> tests/ui/checked_unwrap/simple_conditionals.rs:100:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:99:9
|
LL | if x.is_err() {
| ---------- because of this check
@ -142,7 +142,7 @@ LL | x.unwrap();
| ^^^^^^^^^^
error: called `unwrap_err` on `x` after checking its variant with `is_err`
--> tests/ui/checked_unwrap/simple_conditionals.rs:103:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:102:9
|
LL | if x.is_err() {
| ------------- help: try: `if let Err(..) = x`
@ -151,7 +151,7 @@ LL | x.unwrap_err();
| ^^^^^^^^^^^^^^
error: called `unwrap` on `x` after checking its variant with `is_err`
--> tests/ui/checked_unwrap/simple_conditionals.rs:107:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:106:9
|
LL | if x.is_err() {
| ------------- help: try: `if let Ok(..) = x`
@ -160,7 +160,7 @@ LL | x.unwrap();
| ^^^^^^^^^^
error: this call to `unwrap_err()` will always panic
--> tests/ui/checked_unwrap/simple_conditionals.rs:110:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:109:9
|
LL | if x.is_err() {
| ---------- because of this check
@ -169,7 +169,7 @@ LL | x.unwrap_err();
| ^^^^^^^^^^^^^^
error: called `unwrap` on `option` after checking its variant with `is_some`
--> tests/ui/checked_unwrap/simple_conditionals.rs:135:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:134:9
|
LL | if option.is_some() {
| ------------------- help: try: `if let Some(..) = &option`
@ -177,7 +177,7 @@ LL | option.as_ref().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: this call to `unwrap()` will always panic
--> tests/ui/checked_unwrap/simple_conditionals.rs:138:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:137:9
|
LL | if option.is_some() {
| ---------------- because of this check
@ -186,7 +186,7 @@ LL | option.as_ref().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: called `unwrap` on `result` after checking its variant with `is_ok`
--> tests/ui/checked_unwrap/simple_conditionals.rs:145:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:144:9
|
LL | if result.is_ok() {
| ----------------- help: try: `if let Ok(..) = &result`
@ -194,7 +194,7 @@ LL | result.as_ref().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: this call to `unwrap()` will always panic
--> tests/ui/checked_unwrap/simple_conditionals.rs:148:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:147:9
|
LL | if result.is_ok() {
| -------------- because of this check
@ -203,7 +203,7 @@ LL | result.as_ref().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: called `unwrap` on `option` after checking its variant with `is_some`
--> tests/ui/checked_unwrap/simple_conditionals.rs:154:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:153:9
|
LL | if option.is_some() {
| ------------------- help: try: `if let Some(..) = &mut option`
@ -211,7 +211,7 @@ LL | option.as_mut().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: this call to `unwrap()` will always panic
--> tests/ui/checked_unwrap/simple_conditionals.rs:157:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:156:9
|
LL | if option.is_some() {
| ---------------- because of this check
@ -220,7 +220,7 @@ LL | option.as_mut().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: called `unwrap` on `result` after checking its variant with `is_ok`
--> tests/ui/checked_unwrap/simple_conditionals.rs:163:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:162:9
|
LL | if result.is_ok() {
| ----------------- help: try: `if let Ok(..) = &mut result`
@ -228,7 +228,7 @@ LL | result.as_mut().unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: this call to `unwrap()` will always panic
--> tests/ui/checked_unwrap/simple_conditionals.rs:166:9
--> tests/ui/checked_unwrap/simple_conditionals.rs:165:9
|
LL | if result.is_ok() {
| -------------- because of this check

View file

@ -1,6 +1,5 @@
//@aux-build:proc_macros.rs
#![feature(lint_reasons)]
#![warn(clippy::default_numeric_fallback)]
#![allow(
unused,

View file

@ -1,6 +1,5 @@
//@aux-build:proc_macros.rs
#![feature(lint_reasons)]
#![warn(clippy::default_numeric_fallback)]
#![allow(
unused,

View file

@ -1,5 +1,5 @@
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:21:17
--> tests/ui/default_numeric_fallback_i32.rs:20:17
|
LL | let x = 22;
| ^^ help: consider adding suffix: `22_i32`
@ -8,145 +8,145 @@ LL | let x = 22;
= help: to override `-D warnings` add `#[allow(clippy::default_numeric_fallback)]`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:22:18
--> tests/ui/default_numeric_fallback_i32.rs:21:18
|
LL | let x = [1, 2, 3];
| ^ help: consider adding suffix: `1_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:22:21
--> tests/ui/default_numeric_fallback_i32.rs:21:21
|
LL | let x = [1, 2, 3];
| ^ help: consider adding suffix: `2_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:22:24
--> tests/ui/default_numeric_fallback_i32.rs:21:24
|
LL | let x = [1, 2, 3];
| ^ help: consider adding suffix: `3_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:23:28
--> tests/ui/default_numeric_fallback_i32.rs:22:28
|
LL | let x = if true { (1, 2) } else { (3, 4) };
| ^ help: consider adding suffix: `1_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:23:31
--> tests/ui/default_numeric_fallback_i32.rs:22:31
|
LL | let x = if true { (1, 2) } else { (3, 4) };
| ^ help: consider adding suffix: `2_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:23:44
--> tests/ui/default_numeric_fallback_i32.rs:22:44
|
LL | let x = if true { (1, 2) } else { (3, 4) };
| ^ help: consider adding suffix: `3_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:23:47
--> tests/ui/default_numeric_fallback_i32.rs:22:47
|
LL | let x = if true { (1, 2) } else { (3, 4) };
| ^ help: consider adding suffix: `4_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:24:23
--> tests/ui/default_numeric_fallback_i32.rs:23:23
|
LL | let x = match 1 {
| ^ help: consider adding suffix: `1_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:25:13
--> tests/ui/default_numeric_fallback_i32.rs:24:13
|
LL | 1 => 1,
| ^ help: consider adding suffix: `1_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:25:18
--> tests/ui/default_numeric_fallback_i32.rs:24:18
|
LL | 1 => 1,
| ^ help: consider adding suffix: `1_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:26:18
--> tests/ui/default_numeric_fallback_i32.rs:25:18
|
LL | _ => 2,
| ^ help: consider adding suffix: `2_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:45:21
--> tests/ui/default_numeric_fallback_i32.rs:44:21
|
LL | let y = 1;
| ^ help: consider adding suffix: `1_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:53:21
--> tests/ui/default_numeric_fallback_i32.rs:52:21
|
LL | let y = 1;
| ^ help: consider adding suffix: `1_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:59:21
--> tests/ui/default_numeric_fallback_i32.rs:58:21
|
LL | let y = 1;
| ^ help: consider adding suffix: `1_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:67:21
--> tests/ui/default_numeric_fallback_i32.rs:66:21
|
LL | let y = 1;
| ^ help: consider adding suffix: `1_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:83:27
--> tests/ui/default_numeric_fallback_i32.rs:82:27
|
LL | let f = || -> _ { 1 };
| ^ help: consider adding suffix: `1_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:87:29
--> tests/ui/default_numeric_fallback_i32.rs:86:29
|
LL | let f = || -> i32 { 1 };
| ^ help: consider adding suffix: `1_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:101:21
--> tests/ui/default_numeric_fallback_i32.rs:100:21
|
LL | generic_arg(1);
| ^ help: consider adding suffix: `1_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:104:32
--> tests/ui/default_numeric_fallback_i32.rs:103:32
|
LL | let x: _ = generic_arg(1);
| ^ help: consider adding suffix: `1_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:122:28
--> tests/ui/default_numeric_fallback_i32.rs:121:28
|
LL | GenericStruct { x: 1 };
| ^ help: consider adding suffix: `1_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:125:36
--> tests/ui/default_numeric_fallback_i32.rs:124:36
|
LL | let _ = GenericStruct { x: 1 };
| ^ help: consider adding suffix: `1_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:143:24
--> tests/ui/default_numeric_fallback_i32.rs:142:24
|
LL | GenericEnum::X(1);
| ^ help: consider adding suffix: `1_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:163:23
--> tests/ui/default_numeric_fallback_i32.rs:162:23
|
LL | s.generic_arg(1);
| ^ help: consider adding suffix: `1_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:173:25
--> tests/ui/default_numeric_fallback_i32.rs:172:25
|
LL | inline!(let x = 22;);
| ^^ help: consider adding suffix: `22_i32`
@ -154,19 +154,19 @@ LL | inline!(let x = 22;);
= note: this error originates in the macro `__inline_mac_fn_internal` (in Nightly builds, run with -Z macro-backtrace for more info)
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:215:29
--> tests/ui/default_numeric_fallback_i32.rs:214:29
|
LL | let data_i32 = vec![1, 2, 3];
| ^ help: consider adding suffix: `1_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:215:32
--> tests/ui/default_numeric_fallback_i32.rs:214:32
|
LL | let data_i32 = vec![1, 2, 3];
| ^ help: consider adding suffix: `2_i32`
error: default numeric fallback might occur
--> tests/ui/default_numeric_fallback_i32.rs:215:35
--> tests/ui/default_numeric_fallback_i32.rs:214:35
|
LL | let data_i32 = vec![1, 2, 3];
| ^ help: consider adding suffix: `3_i32`

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![allow(unused)]
#![warn(clippy::derive_partial_eq_without_eq)]

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![allow(unused)]
#![warn(clippy::derive_partial_eq_without_eq)]

View file

@ -1,5 +1,5 @@
error: you are deriving `PartialEq` and can implement `Eq`
--> tests/ui/derive_partial_eq_without_eq.rs:12:17
--> tests/ui/derive_partial_eq_without_eq.rs:11:17
|
LL | #[derive(Debug, PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
@ -8,73 +8,73 @@ LL | #[derive(Debug, PartialEq)]
= help: to override `-D warnings` add `#[allow(clippy::derive_partial_eq_without_eq)]`
error: you are deriving `PartialEq` and can implement `Eq`
--> tests/ui/derive_partial_eq_without_eq.rs:70:10
--> tests/ui/derive_partial_eq_without_eq.rs:69:10
|
LL | #[derive(PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
error: you are deriving `PartialEq` and can implement `Eq`
--> tests/ui/derive_partial_eq_without_eq.rs:76:10
--> tests/ui/derive_partial_eq_without_eq.rs:75:10
|
LL | #[derive(PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
error: you are deriving `PartialEq` and can implement `Eq`
--> tests/ui/derive_partial_eq_without_eq.rs:82:10
--> tests/ui/derive_partial_eq_without_eq.rs:81:10
|
LL | #[derive(PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
error: you are deriving `PartialEq` and can implement `Eq`
--> tests/ui/derive_partial_eq_without_eq.rs:85:10
--> tests/ui/derive_partial_eq_without_eq.rs:84:10
|
LL | #[derive(PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
error: you are deriving `PartialEq` and can implement `Eq`
--> tests/ui/derive_partial_eq_without_eq.rs:91:10
--> tests/ui/derive_partial_eq_without_eq.rs:90:10
|
LL | #[derive(PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
error: you are deriving `PartialEq` and can implement `Eq`
--> tests/ui/derive_partial_eq_without_eq.rs:97:10
--> tests/ui/derive_partial_eq_without_eq.rs:96:10
|
LL | #[derive(PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
error: you are deriving `PartialEq` and can implement `Eq`
--> tests/ui/derive_partial_eq_without_eq.rs:110:17
--> tests/ui/derive_partial_eq_without_eq.rs:109:17
|
LL | #[derive(Debug, PartialEq, Clone)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
error: you are deriving `PartialEq` and can implement `Eq`
--> tests/ui/derive_partial_eq_without_eq.rs:113:10
--> tests/ui/derive_partial_eq_without_eq.rs:112:10
|
LL | #[derive(PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
error: you are deriving `PartialEq` and can implement `Eq`
--> tests/ui/derive_partial_eq_without_eq.rs:120:14
--> tests/ui/derive_partial_eq_without_eq.rs:119:14
|
LL | #[derive(PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
error: you are deriving `PartialEq` and can implement `Eq`
--> tests/ui/derive_partial_eq_without_eq.rs:123:14
--> tests/ui/derive_partial_eq_without_eq.rs:122:14
|
LL | #[derive(PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
error: you are deriving `PartialEq` and can implement `Eq`
--> tests/ui/derive_partial_eq_without_eq.rs:183:14
--> tests/ui/derive_partial_eq_without_eq.rs:182:14
|
LL | #[derive(PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`
error: you are deriving `PartialEq` and can implement `Eq`
--> tests/ui/derive_partial_eq_without_eq.rs:191:14
--> tests/ui/derive_partial_eq_without_eq.rs:190:14
|
LL | #[derive(PartialEq)]
| ^^^^^^^^^ help: consider deriving `Eq` as well: `PartialEq, Eq`

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
//! This file tests the `#[expect]` attribute implementation for tool lints. The same
//! file is used to test clippy and rustdoc. Any changes to this file should be synced
//! to the other test files as well.

View file

@ -1,5 +1,5 @@
error: this lint expectation is unfulfilled
--> tests/ui/expect_tool_lint_rfc_2383.rs:31:14
--> tests/ui/expect_tool_lint_rfc_2383.rs:30:14
|
LL | #[expect(dead_code)]
| ^^^^^^^^^
@ -8,31 +8,31 @@ LL | #[expect(dead_code)]
= help: to override `-D warnings` add `#[allow(unfulfilled_lint_expectations)]`
error: this lint expectation is unfulfilled
--> tests/ui/expect_tool_lint_rfc_2383.rs:37:18
--> tests/ui/expect_tool_lint_rfc_2383.rs:36:18
|
LL | #[expect(invalid_nan_comparisons)]
| ^^^^^^^^^^^^^^^^^^^^^^^
error: this lint expectation is unfulfilled
--> tests/ui/expect_tool_lint_rfc_2383.rs:108:14
--> tests/ui/expect_tool_lint_rfc_2383.rs:107:14
|
LL | #[expect(clippy::almost_swapped)]
| ^^^^^^^^^^^^^^^^^^^^^^
error: this lint expectation is unfulfilled
--> tests/ui/expect_tool_lint_rfc_2383.rs:116:14
--> tests/ui/expect_tool_lint_rfc_2383.rs:115:14
|
LL | #[expect(clippy::bytes_nth)]
| ^^^^^^^^^^^^^^^^^
error: this lint expectation is unfulfilled
--> tests/ui/expect_tool_lint_rfc_2383.rs:122:14
--> tests/ui/expect_tool_lint_rfc_2383.rs:121:14
|
LL | #[expect(clippy::if_same_then_else)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
error: this lint expectation is unfulfilled
--> tests/ui/expect_tool_lint_rfc_2383.rs:128:14
--> tests/ui/expect_tool_lint_rfc_2383.rs:127:14
|
LL | #[expect(clippy::overly_complex_bool_expr)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![warn(clippy::implicit_return)]
#![allow(clippy::needless_return, clippy::needless_bool, unused, clippy::never_loop)]

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![warn(clippy::implicit_return)]
#![allow(clippy::needless_return, clippy::needless_bool, unused, clippy::never_loop)]

View file

@ -1,5 +1,5 @@
error: missing `return` statement
--> tests/ui/implicit_return.rs:11:5
--> tests/ui/implicit_return.rs:10:5
|
LL | true
| ^^^^ help: add `return` as shown: `return true`
@ -8,85 +8,85 @@ LL | true
= help: to override `-D warnings` add `#[allow(clippy::implicit_return)]`
error: missing `return` statement
--> tests/ui/implicit_return.rs:15:15
--> tests/ui/implicit_return.rs:14:15
|
LL | if true { true } else { false }
| ^^^^ help: add `return` as shown: `return true`
error: missing `return` statement
--> tests/ui/implicit_return.rs:15:29
--> tests/ui/implicit_return.rs:14:29
|
LL | if true { true } else { false }
| ^^^^^ help: add `return` as shown: `return false`
error: missing `return` statement
--> tests/ui/implicit_return.rs:21:17
--> tests/ui/implicit_return.rs:20:17
|
LL | true => false,
| ^^^^^ help: add `return` as shown: `return false`
error: missing `return` statement
--> tests/ui/implicit_return.rs:22:20
--> tests/ui/implicit_return.rs:21:20
|
LL | false => { true },
| ^^^^ help: add `return` as shown: `return true`
error: missing `return` statement
--> tests/ui/implicit_return.rs:35:9
--> tests/ui/implicit_return.rs:34:9
|
LL | break true;
| ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`
error: missing `return` statement
--> tests/ui/implicit_return.rs:42:13
--> tests/ui/implicit_return.rs:41:13
|
LL | break true;
| ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`
error: missing `return` statement
--> tests/ui/implicit_return.rs:50:13
--> tests/ui/implicit_return.rs:49:13
|
LL | break true;
| ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`
error: missing `return` statement
--> tests/ui/implicit_return.rs:68:18
--> tests/ui/implicit_return.rs:67:18
|
LL | let _ = || { true };
| ^^^^ help: add `return` as shown: `return true`
error: missing `return` statement
--> tests/ui/implicit_return.rs:69:16
--> tests/ui/implicit_return.rs:68:16
|
LL | let _ = || true;
| ^^^^ help: add `return` as shown: `return true`
error: missing `return` statement
--> tests/ui/implicit_return.rs:77:5
--> tests/ui/implicit_return.rs:76:5
|
LL | format!("test {}", "test")
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add `return` as shown: `return format!("test {}", "test")`
error: missing `return` statement
--> tests/ui/implicit_return.rs:86:5
--> tests/ui/implicit_return.rs:85:5
|
LL | m!(true, false)
| ^^^^^^^^^^^^^^^ help: add `return` as shown: `return m!(true, false)`
error: missing `return` statement
--> tests/ui/implicit_return.rs:92:13
--> tests/ui/implicit_return.rs:91:13
|
LL | break true;
| ^^^^^^^^^^ help: change `break` to `return` as shown: `return true`
error: missing `return` statement
--> tests/ui/implicit_return.rs:97:17
--> tests/ui/implicit_return.rs:96:17
|
LL | break 'outer false;
| ^^^^^^^^^^^^^^^^^^ help: change `break` to `return` as shown: `return false`
error: missing `return` statement
--> tests/ui/implicit_return.rs:112:5
--> tests/ui/implicit_return.rs:111:5
|
LL | / loop {
LL | | m!(true);
@ -101,7 +101,7 @@ LL + }
|
error: missing `return` statement
--> tests/ui/implicit_return.rs:126:5
--> tests/ui/implicit_return.rs:125:5
|
LL | true
| ^^^^ help: add `return` as shown: `return true`

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![warn(clippy::let_unit_value)]
#![allow(unused, clippy::no_effect, clippy::needless_late_init, path_statements)]

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![warn(clippy::let_unit_value)]
#![allow(unused, clippy::no_effect, clippy::needless_late_init, path_statements)]

View file

@ -1,5 +1,5 @@
error: this let-binding has unit value
--> tests/ui/let_unit.rs:12:5
--> tests/ui/let_unit.rs:11:5
|
LL | let _x = println!("x");
| ^^^^^^^^^^^^^^^^^^^^^^^ help: omit the `let` binding: `println!("x");`
@ -8,7 +8,7 @@ LL | let _x = println!("x");
= help: to override `-D warnings` add `#[allow(clippy::let_unit_value)]`
error: this let-binding has unit value
--> tests/ui/let_unit.rs:60:5
--> tests/ui/let_unit.rs:59:5
|
LL | / let _ = v
LL | | .into_iter()
@ -31,7 +31,7 @@ LL + .unwrap();
|
error: this let-binding has unit value
--> tests/ui/let_unit.rs:109:5
--> tests/ui/let_unit.rs:108:5
|
LL | / let x = match Some(0) {
LL | | None => f2(1),
@ -52,7 +52,7 @@ LL + };
|
error: this let-binding has unit value
--> tests/ui/let_unit.rs:190:9
--> tests/ui/let_unit.rs:189:9
|
LL | let res = returns_unit();
| ^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -4,7 +4,6 @@
//@ignore-32bit
#![feature(lint_reasons)]
#![allow(unused_imports, unreachable_code, unused_variables, dead_code, unused_attributes)]
#![allow(clippy::single_component_path_imports)]
#![warn(clippy::macro_use_imports)]

View file

@ -4,7 +4,6 @@
//@ignore-32bit
#![feature(lint_reasons)]
#![allow(unused_imports, unreachable_code, unused_variables, dead_code, unused_attributes)]
#![allow(clippy::single_component_path_imports)]
#![warn(clippy::macro_use_imports)]

View file

@ -1,5 +1,5 @@
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
--> tests/ui/macro_use_imports.rs:19:5
--> tests/ui/macro_use_imports.rs:18:5
|
LL | #[macro_use]
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{pub_macro, inner_mod_macro, function_macro, ty_macro, pub_in_private_macro};`
@ -8,19 +8,19 @@ LL | #[macro_use]
= help: to override `-D warnings` add `#[allow(clippy::macro_use_imports)]`
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
--> tests/ui/macro_use_imports.rs:23:5
--> tests/ui/macro_use_imports.rs:22:5
|
LL | #[macro_use]
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{inner::mut_mut, inner::try_err};`
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
--> tests/ui/macro_use_imports.rs:25:5
--> tests/ui/macro_use_imports.rs:24:5
|
LL | #[macro_use]
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::inner::nested::string_add;`
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
--> tests/ui/macro_use_imports.rs:21:5
--> tests/ui/macro_use_imports.rs:20:5
|
LL | #[macro_use]
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mini_mac::ClippyMiniMacroTest;`

View file

@ -3,7 +3,6 @@
//@aux-build:proc_macro_derive.rs
//@ignore-32bit
#![feature(lint_reasons)]
#![allow(unused_imports, unreachable_code, unused_variables, dead_code, unused_attributes)]
#![allow(clippy::single_component_path_imports)]
#![warn(clippy::macro_use_imports)]

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![warn(clippy::manual_non_exhaustive)]
#![allow(unused)]
//@no-rustfix

View file

@ -1,5 +1,5 @@
error: this seems like a manual implementation of the non-exhaustive pattern
--> tests/ui/manual_non_exhaustive_enum.rs:5:1
--> tests/ui/manual_non_exhaustive_enum.rs:4:1
|
LL | enum E {
| ^-----
@ -15,7 +15,7 @@ LL | | }
| |_^
|
help: remove this variant
--> tests/ui/manual_non_exhaustive_enum.rs:10:5
--> tests/ui/manual_non_exhaustive_enum.rs:9:5
|
LL | _C,
| ^^
@ -23,7 +23,7 @@ LL | _C,
= help: to override `-D warnings` add `#[allow(clippy::manual_non_exhaustive)]`
error: this seems like a manual implementation of the non-exhaustive pattern
--> tests/ui/manual_non_exhaustive_enum.rs:30:1
--> tests/ui/manual_non_exhaustive_enum.rs:29:1
|
LL | enum NoUnderscore {
| ^----------------
@ -38,7 +38,7 @@ LL | | }
| |_^
|
help: remove this variant
--> tests/ui/manual_non_exhaustive_enum.rs:34:5
--> tests/ui/manual_non_exhaustive_enum.rs:33:5
|
LL | C,
| ^

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![allow(
unused,
non_local_definitions,

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![allow(
unused,
non_local_definitions,

View file

@ -1,5 +1,5 @@
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:16:15
--> tests/ui/needless_borrow.rs:15:15
|
LL | let _ = x(&&a); // warn
| ^^^ help: change this to: `&a`
@ -8,163 +8,163 @@ LL | let _ = x(&&a); // warn
= help: to override `-D warnings` add `#[allow(clippy::needless_borrow)]`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:20:13
--> tests/ui/needless_borrow.rs:19:13
|
LL | mut_ref(&mut &mut b); // warn
| ^^^^^^^^^^^ help: change this to: `&mut b`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:32:13
--> tests/ui/needless_borrow.rs:31:13
|
LL | &&a
| ^^^ help: change this to: `&a`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:34:15
--> tests/ui/needless_borrow.rs:33:15
|
LL | 46 => &&a,
| ^^^ help: change this to: `&a`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:40:27
--> tests/ui/needless_borrow.rs:39:27
|
LL | break &ref_a;
| ^^^^^^ help: change this to: `ref_a`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:47:15
--> tests/ui/needless_borrow.rs:46:15
|
LL | let _ = x(&&&a);
| ^^^^ help: change this to: `&a`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:48:15
--> tests/ui/needless_borrow.rs:47:15
|
LL | let _ = x(&mut &&a);
| ^^^^^^^^ help: change this to: `&a`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:49:15
--> tests/ui/needless_borrow.rs:48:15
|
LL | let _ = x(&&&mut b);
| ^^^^^^^^ help: change this to: `&mut b`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:50:15
--> tests/ui/needless_borrow.rs:49:15
|
LL | let _ = x(&&ref_a);
| ^^^^^^^ help: change this to: `ref_a`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:53:11
--> tests/ui/needless_borrow.rs:52:11
|
LL | x(&b);
| ^^ help: change this to: `b`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:60:13
--> tests/ui/needless_borrow.rs:59:13
|
LL | mut_ref(&mut x);
| ^^^^^^ help: change this to: `x`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:61:13
--> tests/ui/needless_borrow.rs:60:13
|
LL | mut_ref(&mut &mut x);
| ^^^^^^^^^^^ help: change this to: `x`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:62:23
--> tests/ui/needless_borrow.rs:61:23
|
LL | let y: &mut i32 = &mut x;
| ^^^^^^ help: change this to: `x`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:63:23
--> tests/ui/needless_borrow.rs:62:23
|
LL | let y: &mut i32 = &mut &mut x;
| ^^^^^^^^^^^ help: change this to: `x`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:72:14
--> tests/ui/needless_borrow.rs:71:14
|
LL | 0 => &mut x,
| ^^^^^^ help: change this to: `x`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:78:14
--> tests/ui/needless_borrow.rs:77:14
|
LL | 0 => &mut x,
| ^^^^^^ help: change this to: `x`
error: this expression borrows a value the compiler would automatically borrow
--> tests/ui/needless_borrow.rs:90:13
--> tests/ui/needless_borrow.rs:89:13
|
LL | let _ = (&x).0;
| ^^^^ help: change this to: `x`
error: this expression borrows a value the compiler would automatically borrow
--> tests/ui/needless_borrow.rs:92:22
--> tests/ui/needless_borrow.rs:91:22
|
LL | let _ = unsafe { (&*x).0 };
| ^^^^^ help: change this to: `(*x)`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:102:5
--> tests/ui/needless_borrow.rs:101:5
|
LL | (&&()).foo();
| ^^^^^^ help: change this to: `(&())`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:111:5
--> tests/ui/needless_borrow.rs:110:5
|
LL | (&&5).foo();
| ^^^^^ help: change this to: `(&5)`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:137:23
--> tests/ui/needless_borrow.rs:136:23
|
LL | let x: (&str,) = (&"",);
| ^^^ help: change this to: `""`
error: this expression borrows a value the compiler would automatically borrow
--> tests/ui/needless_borrow.rs:179:13
--> tests/ui/needless_borrow.rs:178:13
|
LL | (&self.f)()
| ^^^^^^^^^ help: change this to: `(self.f)`
error: this expression borrows a value the compiler would automatically borrow
--> tests/ui/needless_borrow.rs:188:13
--> tests/ui/needless_borrow.rs:187:13
|
LL | (&mut self.f)()
| ^^^^^^^^^^^^^ help: change this to: `(self.f)`
error: this expression borrows a value the compiler would automatically borrow
--> tests/ui/needless_borrow.rs:225:22
--> tests/ui/needless_borrow.rs:224:22
|
LL | let _ = &mut (&mut { x.u }).x;
| ^^^^^^^^^^^^^^ help: change this to: `{ x.u }`
error: this expression borrows a value the compiler would automatically borrow
--> tests/ui/needless_borrow.rs:232:22
--> tests/ui/needless_borrow.rs:231:22
|
LL | let _ = &mut (&mut { x.u }).x;
| ^^^^^^^^^^^^^^ help: change this to: `{ x.u }`
error: this expression borrows a value the compiler would automatically borrow
--> tests/ui/needless_borrow.rs:236:22
--> tests/ui/needless_borrow.rs:235:22
|
LL | let _ = &mut (&mut x.u).x;
| ^^^^^^^^^^ help: change this to: `x.u`
error: this expression borrows a value the compiler would automatically borrow
--> tests/ui/needless_borrow.rs:237:22
--> tests/ui/needless_borrow.rs:236:22
|
LL | let _ = &mut (&mut { x.u }).x;
| ^^^^^^^^^^^^^^ help: change this to: `{ x.u }`
error: this expression creates a reference which is immediately dereferenced by the compiler
--> tests/ui/needless_borrow.rs:258:23
--> tests/ui/needless_borrow.rs:257:23
|
LL | option.unwrap_or((&x.0,));
| ^^^^ help: change this to: `x.0`

View file

@ -5,7 +5,6 @@
clippy::ptr_arg
)]
#![warn(clippy::needless_pass_by_ref_mut)]
#![feature(lint_reasons)]
//@no-rustfix
use std::ptr::NonNull;

View file

@ -1,5 +1,5 @@
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:12:11
--> tests/ui/needless_pass_by_ref_mut.rs:11:11
|
LL | fn foo(s: &mut Vec<u32>, b: &u32, x: &mut u32) {
| ^^^^^^^^^^^^^ help: consider changing to: `&Vec<u32>`
@ -8,79 +8,79 @@ LL | fn foo(s: &mut Vec<u32>, b: &u32, x: &mut u32) {
= help: to override `-D warnings` add `#[allow(clippy::needless_pass_by_ref_mut)]`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:37:12
--> tests/ui/needless_pass_by_ref_mut.rs:36:12
|
LL | fn foo6(s: &mut Vec<u32>) {
| ^^^^^^^^^^^^^ help: consider changing to: `&Vec<u32>`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:47:12
--> tests/ui/needless_pass_by_ref_mut.rs:46:12
|
LL | fn bar(&mut self) {}
| ^^^^^^^^^ help: consider changing to: `&self`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:50:29
--> tests/ui/needless_pass_by_ref_mut.rs:49:29
|
LL | fn mushroom(&self, vec: &mut Vec<i32>) -> usize {
| ^^^^^^^^^^^^^ help: consider changing to: `&Vec<i32>`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:127:16
--> tests/ui/needless_pass_by_ref_mut.rs:126:16
|
LL | async fn a1(x: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:131:16
--> tests/ui/needless_pass_by_ref_mut.rs:130:16
|
LL | async fn a2(x: &mut i32, y: String) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:135:16
--> tests/ui/needless_pass_by_ref_mut.rs:134:16
|
LL | async fn a3(x: &mut i32, y: String, z: String) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:139:16
--> tests/ui/needless_pass_by_ref_mut.rs:138:16
|
LL | async fn a4(x: &mut i32, y: i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:143:24
--> tests/ui/needless_pass_by_ref_mut.rs:142:24
|
LL | async fn a5(x: i32, y: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:147:24
--> tests/ui/needless_pass_by_ref_mut.rs:146:24
|
LL | async fn a6(x: i32, y: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:151:32
--> tests/ui/needless_pass_by_ref_mut.rs:150:32
|
LL | async fn a7(x: i32, y: i32, z: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:155:24
--> tests/ui/needless_pass_by_ref_mut.rs:154:24
|
LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:155:45
--> tests/ui/needless_pass_by_ref_mut.rs:154:45
|
LL | async fn a8(x: i32, a: &mut i32, y: i32, z: &mut i32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:189:16
--> tests/ui/needless_pass_by_ref_mut.rs:188:16
|
LL | fn cfg_warn(s: &mut u32) {}
| ^^^^^^^^ help: consider changing to: `&u32`
@ -88,7 +88,7 @@ LL | fn cfg_warn(s: &mut u32) {}
= note: this is cfg-gated and may require further changes
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:195:20
--> tests/ui/needless_pass_by_ref_mut.rs:194:20
|
LL | fn cfg_warn(s: &mut u32) {}
| ^^^^^^^^ help: consider changing to: `&u32`
@ -96,19 +96,19 @@ LL | fn cfg_warn(s: &mut u32) {}
= note: this is cfg-gated and may require further changes
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:209:39
--> tests/ui/needless_pass_by_ref_mut.rs:208:39
|
LL | async fn inner_async2(x: &mut i32, y: &mut u32) {
| ^^^^^^^^ help: consider changing to: `&u32`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:217:26
--> tests/ui/needless_pass_by_ref_mut.rs:216:26
|
LL | async fn inner_async3(x: &mut i32, y: &mut u32) {
| ^^^^^^^^ help: consider changing to: `&i32`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:236:34
--> tests/ui/needless_pass_by_ref_mut.rs:235:34
|
LL | pub async fn call_in_closure1(n: &mut str) {
| ^^^^^^^^ help: consider changing to: `&str`
@ -116,7 +116,7 @@ LL | pub async fn call_in_closure1(n: &mut str) {
= warning: changing this function will impact semver compatibility
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:255:20
--> tests/ui/needless_pass_by_ref_mut.rs:254:20
|
LL | pub fn closure2(n: &mut usize) -> impl '_ + FnMut() -> usize {
| ^^^^^^^^^^ help: consider changing to: `&usize`
@ -124,7 +124,7 @@ LL | pub fn closure2(n: &mut usize) -> impl '_ + FnMut() -> usize {
= warning: changing this function will impact semver compatibility
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:266:26
--> tests/ui/needless_pass_by_ref_mut.rs:265:26
|
LL | pub async fn closure4(n: &mut usize) {
| ^^^^^^^^^^ help: consider changing to: `&usize`
@ -132,85 +132,85 @@ LL | pub async fn closure4(n: &mut usize) {
= warning: changing this function will impact semver compatibility
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:315:12
--> tests/ui/needless_pass_by_ref_mut.rs:314:12
|
LL | fn bar(&mut self) {}
| ^^^^^^^^^ help: consider changing to: `&self`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:317:18
--> tests/ui/needless_pass_by_ref_mut.rs:316:18
|
LL | async fn foo(&mut self, u: &mut i32, v: &mut u32) {
| ^^^^^^^^^ help: consider changing to: `&self`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:317:45
--> tests/ui/needless_pass_by_ref_mut.rs:316:45
|
LL | async fn foo(&mut self, u: &mut i32, v: &mut u32) {
| ^^^^^^^^ help: consider changing to: `&u32`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:325:46
--> tests/ui/needless_pass_by_ref_mut.rs:324:46
|
LL | async fn foo2(&mut self, u: &mut i32, v: &mut u32) {
| ^^^^^^^^ help: consider changing to: `&u32`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:341:18
--> tests/ui/needless_pass_by_ref_mut.rs:340:18
|
LL | fn _empty_tup(x: &mut (())) {}
| ^^^^^^^^^ help: consider changing to: `&()`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:342:19
--> tests/ui/needless_pass_by_ref_mut.rs:341:19
|
LL | fn _single_tup(x: &mut ((i32,))) {}
| ^^^^^^^^^^^^^ help: consider changing to: `&(i32,)`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:343:18
--> tests/ui/needless_pass_by_ref_mut.rs:342:18
|
LL | fn _multi_tup(x: &mut ((i32, u32))) {}
| ^^^^^^^^^^^^^^^^^ help: consider changing to: `&(i32, u32)`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:344:11
--> tests/ui/needless_pass_by_ref_mut.rs:343:11
|
LL | fn _fn(x: &mut (fn())) {}
| ^^^^^^^^^^^ help: consider changing to: `&fn()`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:346:23
--> tests/ui/needless_pass_by_ref_mut.rs:345:23
|
LL | fn _extern_rust_fn(x: &mut extern "Rust" fn()) {}
| ^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&extern "Rust" fn()`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:347:20
--> tests/ui/needless_pass_by_ref_mut.rs:346:20
|
LL | fn _extern_c_fn(x: &mut extern "C" fn()) {}
| ^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&extern "C" fn()`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:348:18
--> tests/ui/needless_pass_by_ref_mut.rs:347:18
|
LL | fn _unsafe_fn(x: &mut unsafe fn()) {}
| ^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe fn()`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:349:25
--> tests/ui/needless_pass_by_ref_mut.rs:348:25
|
LL | fn _unsafe_extern_fn(x: &mut unsafe extern "C" fn()) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe extern "C" fn()`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:350:20
--> tests/ui/needless_pass_by_ref_mut.rs:349:20
|
LL | fn _fn_with_arg(x: &mut unsafe extern "C" fn(i32)) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe extern "C" fn(i32)`
error: this argument is a mutable reference, but not used mutably
--> tests/ui/needless_pass_by_ref_mut.rs:351:20
--> tests/ui/needless_pass_by_ref_mut.rs:350:20
|
LL | fn _fn_with_ret(x: &mut unsafe extern "C" fn() -> (i32)) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider changing to: `&unsafe extern "C" fn() -> (i32)`

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![feature(yeet_expr)]
#![allow(unused)]
#![allow(

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![feature(yeet_expr)]
#![allow(unused)]
#![allow(

View file

@ -1,5 +1,5 @@
error: unneeded `return` statement
--> tests/ui/needless_return.rs:26:5
--> tests/ui/needless_return.rs:25:5
|
LL | return true;
| ^^^^^^^^^^^
@ -13,7 +13,7 @@ LL + true
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:30:5
--> tests/ui/needless_return.rs:29:5
|
LL | return true;
| ^^^^^^^^^^^
@ -25,7 +25,7 @@ LL + true
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:35:5
--> tests/ui/needless_return.rs:34:5
|
LL | return true;;;
| ^^^^^^^^^^^
@ -37,7 +37,7 @@ LL + true
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:40:5
--> tests/ui/needless_return.rs:39:5
|
LL | return true;; ; ;
| ^^^^^^^^^^^
@ -49,7 +49,7 @@ LL + true
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:45:9
--> tests/ui/needless_return.rs:44:9
|
LL | return true;
| ^^^^^^^^^^^
@ -61,7 +61,7 @@ LL + true
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:47:9
--> tests/ui/needless_return.rs:46:9
|
LL | return false;
| ^^^^^^^^^^^^
@ -73,7 +73,7 @@ LL + false
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:53:17
--> tests/ui/needless_return.rs:52:17
|
LL | true => return false,
| ^^^^^^^^^^^^
@ -84,7 +84,7 @@ LL | true => false,
| ~~~~~
error: unneeded `return` statement
--> tests/ui/needless_return.rs:55:13
--> tests/ui/needless_return.rs:54:13
|
LL | return true;
| ^^^^^^^^^^^
@ -96,7 +96,7 @@ LL + true
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:62:9
--> tests/ui/needless_return.rs:61:9
|
LL | return true;
| ^^^^^^^^^^^
@ -108,7 +108,7 @@ LL + true
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:64:16
--> tests/ui/needless_return.rs:63:16
|
LL | let _ = || return true;
| ^^^^^^^^^^^
@ -119,7 +119,7 @@ LL | let _ = || true;
| ~~~~
error: unneeded `return` statement
--> tests/ui/needless_return.rs:68:5
--> tests/ui/needless_return.rs:67:5
|
LL | return the_answer!();
| ^^^^^^^^^^^^^^^^^^^^
@ -131,7 +131,7 @@ LL + the_answer!()
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:71:21
--> tests/ui/needless_return.rs:70:21
|
LL | fn test_void_fun() {
| _____________________^
@ -146,7 +146,7 @@ LL + fn test_void_fun() {
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:76:11
--> tests/ui/needless_return.rs:75:11
|
LL | if b {
| ___________^
@ -161,7 +161,7 @@ LL + if b {
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:78:13
--> tests/ui/needless_return.rs:77:13
|
LL | } else {
| _____________^
@ -176,7 +176,7 @@ LL + } else {
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:86:14
--> tests/ui/needless_return.rs:85:14
|
LL | _ => return,
| ^^^^^^
@ -187,7 +187,7 @@ LL | _ => (),
| ~~
error: unneeded `return` statement
--> tests/ui/needless_return.rs:94:24
--> tests/ui/needless_return.rs:93:24
|
LL | let _ = 42;
| ________________________^
@ -202,7 +202,7 @@ LL + let _ = 42;
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:97:14
--> tests/ui/needless_return.rs:96:14
|
LL | _ => return,
| ^^^^^^
@ -213,7 +213,7 @@ LL | _ => (),
| ~~
error: unneeded `return` statement
--> tests/ui/needless_return.rs:110:9
--> tests/ui/needless_return.rs:109:9
|
LL | return String::from("test");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -225,7 +225,7 @@ LL + String::from("test")
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:112:9
--> tests/ui/needless_return.rs:111:9
|
LL | return String::new();
| ^^^^^^^^^^^^^^^^^^^^
@ -237,7 +237,7 @@ LL + String::new()
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:134:32
--> tests/ui/needless_return.rs:133:32
|
LL | bar.unwrap_or_else(|_| return)
| ^^^^^^
@ -248,7 +248,7 @@ LL | bar.unwrap_or_else(|_| {})
| ~~
error: unneeded `return` statement
--> tests/ui/needless_return.rs:138:21
--> tests/ui/needless_return.rs:137:21
|
LL | let _ = || {
| _____________________^
@ -263,7 +263,7 @@ LL + let _ = || {
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:141:20
--> tests/ui/needless_return.rs:140:20
|
LL | let _ = || return;
| ^^^^^^
@ -274,7 +274,7 @@ LL | let _ = || {};
| ~~
error: unneeded `return` statement
--> tests/ui/needless_return.rs:147:32
--> tests/ui/needless_return.rs:146:32
|
LL | res.unwrap_or_else(|_| return Foo)
| ^^^^^^^^^^
@ -285,7 +285,7 @@ LL | res.unwrap_or_else(|_| Foo)
| ~~~
error: unneeded `return` statement
--> tests/ui/needless_return.rs:156:5
--> tests/ui/needless_return.rs:155:5
|
LL | return true;
| ^^^^^^^^^^^
@ -297,7 +297,7 @@ LL + true
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:160:5
--> tests/ui/needless_return.rs:159:5
|
LL | return true;
| ^^^^^^^^^^^
@ -309,7 +309,7 @@ LL + true
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:165:9
--> tests/ui/needless_return.rs:164:9
|
LL | return true;
| ^^^^^^^^^^^
@ -321,7 +321,7 @@ LL + true
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:167:9
--> tests/ui/needless_return.rs:166:9
|
LL | return false;
| ^^^^^^^^^^^^
@ -333,7 +333,7 @@ LL + false
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:173:17
--> tests/ui/needless_return.rs:172:17
|
LL | true => return false,
| ^^^^^^^^^^^^
@ -344,7 +344,7 @@ LL | true => false,
| ~~~~~
error: unneeded `return` statement
--> tests/ui/needless_return.rs:175:13
--> tests/ui/needless_return.rs:174:13
|
LL | return true;
| ^^^^^^^^^^^
@ -356,7 +356,7 @@ LL + true
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:182:9
--> tests/ui/needless_return.rs:181:9
|
LL | return true;
| ^^^^^^^^^^^
@ -368,7 +368,7 @@ LL + true
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:184:16
--> tests/ui/needless_return.rs:183:16
|
LL | let _ = || return true;
| ^^^^^^^^^^^
@ -379,7 +379,7 @@ LL | let _ = || true;
| ~~~~
error: unneeded `return` statement
--> tests/ui/needless_return.rs:188:5
--> tests/ui/needless_return.rs:187:5
|
LL | return the_answer!();
| ^^^^^^^^^^^^^^^^^^^^
@ -391,7 +391,7 @@ LL + the_answer!()
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:191:33
--> tests/ui/needless_return.rs:190:33
|
LL | async fn async_test_void_fun() {
| _________________________________^
@ -406,7 +406,7 @@ LL + async fn async_test_void_fun() {
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:196:11
--> tests/ui/needless_return.rs:195:11
|
LL | if b {
| ___________^
@ -421,7 +421,7 @@ LL + if b {
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:198:13
--> tests/ui/needless_return.rs:197:13
|
LL | } else {
| _____________^
@ -436,7 +436,7 @@ LL + } else {
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:206:14
--> tests/ui/needless_return.rs:205:14
|
LL | _ => return,
| ^^^^^^
@ -447,7 +447,7 @@ LL | _ => (),
| ~~
error: unneeded `return` statement
--> tests/ui/needless_return.rs:219:9
--> tests/ui/needless_return.rs:218:9
|
LL | return String::from("test");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -459,7 +459,7 @@ LL + String::from("test")
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:221:9
--> tests/ui/needless_return.rs:220:9
|
LL | return String::new();
| ^^^^^^^^^^^^^^^^^^^^
@ -471,7 +471,7 @@ LL + String::new()
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:237:5
--> tests/ui/needless_return.rs:236:5
|
LL | return format!("Hello {}", "world!");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -483,7 +483,7 @@ LL + format!("Hello {}", "world!")
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:249:9
--> tests/ui/needless_return.rs:248:9
|
LL | return true;
| ^^^^^^^^^^^
@ -497,7 +497,7 @@ LL ~ }
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:251:9
--> tests/ui/needless_return.rs:250:9
|
LL | return false;
| ^^^^^^^^^^^^
@ -509,7 +509,7 @@ LL ~ }
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:258:13
--> tests/ui/needless_return.rs:257:13
|
LL | return 10;
| ^^^^^^^^^
@ -524,7 +524,7 @@ LL ~ }
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:261:13
--> tests/ui/needless_return.rs:260:13
|
LL | return 100;
| ^^^^^^^^^^
@ -537,7 +537,7 @@ LL ~ }
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:269:9
--> tests/ui/needless_return.rs:268:9
|
LL | return 0;
| ^^^^^^^^
@ -549,7 +549,7 @@ LL ~ }
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:276:13
--> tests/ui/needless_return.rs:275:13
|
LL | return *(x as *const isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -564,7 +564,7 @@ LL ~ }
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:278:13
--> tests/ui/needless_return.rs:277:13
|
LL | return !*(x as *const isize);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -577,7 +577,7 @@ LL ~ }
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:285:20
--> tests/ui/needless_return.rs:284:20
|
LL | let _ = 42;
| ____________________^
@ -594,7 +594,7 @@ LL + let _ = 42;
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:292:20
--> tests/ui/needless_return.rs:291:20
|
LL | let _ = 42; return;
| ^^^^^^^
@ -606,7 +606,7 @@ LL + let _ = 42;
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:304:9
--> tests/ui/needless_return.rs:303:9
|
LL | return Ok(format!("ok!"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^
@ -618,7 +618,7 @@ LL + Ok(format!("ok!"))
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:306:9
--> tests/ui/needless_return.rs:305:9
|
LL | return Err(format!("err!"));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -630,7 +630,7 @@ LL + Err(format!("err!"))
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:312:9
--> tests/ui/needless_return.rs:311:9
|
LL | return if true { 1 } else { 2 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -642,7 +642,7 @@ LL + if true { 1 } else { 2 }
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:316:9
--> tests/ui/needless_return.rs:315:9
|
LL | return if b1 { 0 } else { 1 } | if b2 { 2 } else { 3 } | if b3 { 4 } else { 5 };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -654,7 +654,7 @@ LL + (if b1 { 0 } else { 1 } | if b2 { 2 } else { 3 } | if b3 { 4 } else
|
error: unneeded `return` statement
--> tests/ui/needless_return.rs:337:5
--> tests/ui/needless_return.rs:336:5
|
LL | return { "a".to_string() } + "b" + { "c" };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,6 +1,4 @@
//@no-rustfix: overlapping suggestions
#![feature(lint_reasons)]
#![allow(
unused,
clippy::diverging_sub_expression,

View file

@ -1,5 +1,5 @@
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:19:13
--> tests/ui/nonminimal_bool.rs:17:13
|
LL | let _ = !true;
| ^^^^^ help: try: `false`
@ -8,43 +8,43 @@ LL | let _ = !true;
= help: to override `-D warnings` add `#[allow(clippy::nonminimal_bool)]`
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:22:13
--> tests/ui/nonminimal_bool.rs:20:13
|
LL | let _ = !false;
| ^^^^^^ help: try: `true`
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:24:13
--> tests/ui/nonminimal_bool.rs:22:13
|
LL | let _ = !!a;
| ^^^ help: try: `a`
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:26:13
--> tests/ui/nonminimal_bool.rs:24:13
|
LL | let _ = false || a;
| ^^^^^^^^^^ help: try: `a`
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:31:13
--> tests/ui/nonminimal_bool.rs:29:13
|
LL | let _ = !(!a && b);
| ^^^^^^^^^^ help: try: `a || !b`
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:33:13
--> tests/ui/nonminimal_bool.rs:31:13
|
LL | let _ = !(!a || b);
| ^^^^^^^^^^ help: try: `a && !b`
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:35:13
--> tests/ui/nonminimal_bool.rs:33:13
|
LL | let _ = !a && !(b && c);
| ^^^^^^^^^^^^^^^ help: try: `!(a || b && c)`
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:44:13
--> tests/ui/nonminimal_bool.rs:42:13
|
LL | let _ = a == b && c == 5 && a == b;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -57,7 +57,7 @@ LL | let _ = a == b && c == 5;
| ~~~~~~~~~~~~~~~~
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:46:13
--> tests/ui/nonminimal_bool.rs:44:13
|
LL | let _ = a == b || c == 5 || a == b;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -70,7 +70,7 @@ LL | let _ = a == b || c == 5;
| ~~~~~~~~~~~~~~~~
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:48:13
--> tests/ui/nonminimal_bool.rs:46:13
|
LL | let _ = a == b && c == 5 && b == a;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -83,7 +83,7 @@ LL | let _ = a == b && c == 5;
| ~~~~~~~~~~~~~~~~
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:50:13
--> tests/ui/nonminimal_bool.rs:48:13
|
LL | let _ = a != b || !(a != b || c == d);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -96,7 +96,7 @@ LL | let _ = a != b || c != d;
| ~~~~~~~~~~~~~~~~
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:52:13
--> tests/ui/nonminimal_bool.rs:50:13
|
LL | let _ = a != b && !(a != b && c == d);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -109,43 +109,43 @@ LL | let _ = a != b && c != d;
| ~~~~~~~~~~~~~~~~
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:83:8
--> tests/ui/nonminimal_bool.rs:81:8
|
LL | if matches!(true, true) && true {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `matches!(true, true)`
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:163:8
--> tests/ui/nonminimal_bool.rs:161:8
|
LL | if !(12 == a) {}
| ^^^^^^^^^^ help: try: `12 != a`
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:164:8
--> tests/ui/nonminimal_bool.rs:162:8
|
LL | if !(a == 12) {}
| ^^^^^^^^^^ help: try: `a != 12`
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:165:8
--> tests/ui/nonminimal_bool.rs:163:8
|
LL | if !(12 != a) {}
| ^^^^^^^^^^ help: try: `12 == a`
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:166:8
--> tests/ui/nonminimal_bool.rs:164:8
|
LL | if !(a != 12) {}
| ^^^^^^^^^^ help: try: `a == 12`
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:170:8
--> tests/ui/nonminimal_bool.rs:168:8
|
LL | if !b == true {}
| ^^^^^^^^^^ help: try: `b != true`
error: this comparison might be written more concisely
--> tests/ui/nonminimal_bool.rs:170:8
--> tests/ui/nonminimal_bool.rs:168:8
|
LL | if !b == true {}
| ^^^^^^^^^^ help: try simplifying it as shown: `b != true`
@ -154,61 +154,61 @@ LL | if !b == true {}
= help: to override `-D warnings` add `#[allow(clippy::bool_comparison)]`
error: equality checks against true are unnecessary
--> tests/ui/nonminimal_bool.rs:170:8
--> tests/ui/nonminimal_bool.rs:168:8
|
LL | if !b == true {}
| ^^^^^^^^^^ help: try simplifying it as shown: `!b`
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:171:8
--> tests/ui/nonminimal_bool.rs:169:8
|
LL | if !b != true {}
| ^^^^^^^^^^ help: try: `b == true`
error: inequality checks against true can be replaced by a negation
--> tests/ui/nonminimal_bool.rs:171:8
--> tests/ui/nonminimal_bool.rs:169:8
|
LL | if !b != true {}
| ^^^^^^^^^^ help: try simplifying it as shown: `!(!b)`
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:172:8
--> tests/ui/nonminimal_bool.rs:170:8
|
LL | if true == !b {}
| ^^^^^^^^^^ help: try: `true != b`
error: this comparison might be written more concisely
--> tests/ui/nonminimal_bool.rs:172:8
--> tests/ui/nonminimal_bool.rs:170:8
|
LL | if true == !b {}
| ^^^^^^^^^^ help: try simplifying it as shown: `true != b`
error: equality checks against true are unnecessary
--> tests/ui/nonminimal_bool.rs:172:8
--> tests/ui/nonminimal_bool.rs:170:8
|
LL | if true == !b {}
| ^^^^^^^^^^ help: try simplifying it as shown: `!b`
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:173:8
--> tests/ui/nonminimal_bool.rs:171:8
|
LL | if true != !b {}
| ^^^^^^^^^^ help: try: `true == b`
error: inequality checks against true can be replaced by a negation
--> tests/ui/nonminimal_bool.rs:173:8
--> tests/ui/nonminimal_bool.rs:171:8
|
LL | if true != !b {}
| ^^^^^^^^^^ help: try simplifying it as shown: `!(!b)`
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:174:8
--> tests/ui/nonminimal_bool.rs:172:8
|
LL | if !b == !c {}
| ^^^^^^^^ help: try: `b == c`
error: this boolean expression can be simplified
--> tests/ui/nonminimal_bool.rs:175:8
--> tests/ui/nonminimal_bool.rs:173:8
|
LL | if !b != !c {}
| ^^^^^^^^ help: try: `b != c`

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![allow(unused, clippy::diverging_sub_expression)]
#![warn(clippy::overly_complex_bool_expr)]

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![allow(unused, clippy::diverging_sub_expression)]
#![warn(clippy::overly_complex_bool_expr)]

View file

@ -1,11 +1,11 @@
error: this boolean expression contains a logic bug
--> tests/ui/overly_complex_bool_expr.rs:11:13
--> tests/ui/overly_complex_bool_expr.rs:10:13
|
LL | let _ = a && b || a;
| ^^^^^^^^^^^ help: it would look like the following: `a`
|
help: this expression can be optimized out by applying boolean operations to the outer expression
--> tests/ui/overly_complex_bool_expr.rs:11:18
--> tests/ui/overly_complex_bool_expr.rs:10:18
|
LL | let _ = a && b || a;
| ^
@ -13,49 +13,49 @@ LL | let _ = a && b || a;
= help: to override `-D warnings` add `#[allow(clippy::overly_complex_bool_expr)]`
error: this boolean expression contains a logic bug
--> tests/ui/overly_complex_bool_expr.rs:14:13
--> tests/ui/overly_complex_bool_expr.rs:13:13
|
LL | let _ = false && a;
| ^^^^^^^^^^ help: it would look like the following: `false`
|
help: this expression can be optimized out by applying boolean operations to the outer expression
--> tests/ui/overly_complex_bool_expr.rs:14:22
--> tests/ui/overly_complex_bool_expr.rs:13:22
|
LL | let _ = false && a;
| ^
error: this boolean expression contains a logic bug
--> tests/ui/overly_complex_bool_expr.rs:25:13
--> tests/ui/overly_complex_bool_expr.rs:24:13
|
LL | let _ = a == b && a != b;
| ^^^^^^^^^^^^^^^^ help: it would look like the following: `false`
|
help: this expression can be optimized out by applying boolean operations to the outer expression
--> tests/ui/overly_complex_bool_expr.rs:25:13
--> tests/ui/overly_complex_bool_expr.rs:24:13
|
LL | let _ = a == b && a != b;
| ^^^^^^
error: this boolean expression contains a logic bug
--> tests/ui/overly_complex_bool_expr.rs:27:13
--> tests/ui/overly_complex_bool_expr.rs:26:13
|
LL | let _ = a < b && a >= b;
| ^^^^^^^^^^^^^^^ help: it would look like the following: `false`
|
help: this expression can be optimized out by applying boolean operations to the outer expression
--> tests/ui/overly_complex_bool_expr.rs:27:13
--> tests/ui/overly_complex_bool_expr.rs:26:13
|
LL | let _ = a < b && a >= b;
| ^^^^^
error: this boolean expression contains a logic bug
--> tests/ui/overly_complex_bool_expr.rs:29:13
--> tests/ui/overly_complex_bool_expr.rs:28:13
|
LL | let _ = a > b && a <= b;
| ^^^^^^^^^^^^^^^ help: it would look like the following: `false`
|
help: this expression can be optimized out by applying boolean operations to the outer expression
--> tests/ui/overly_complex_bool_expr.rs:29:13
--> tests/ui/overly_complex_bool_expr.rs:28:13
|
LL | let _ = a > b && a <= b;
| ^^^^^

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![allow(
unused,
clippy::many_single_char_names,

View file

@ -1,5 +1,5 @@
error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:14:14
--> tests/ui/ptr_arg.rs:13:14
|
LL | fn do_vec(x: &Vec<i64>) {
| ^^^^^^^^^ help: change this to: `&[i64]`
@ -8,49 +8,49 @@ LL | fn do_vec(x: &Vec<i64>) {
= help: to override `-D warnings` add `#[allow(clippy::ptr_arg)]`
error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:20:18
--> tests/ui/ptr_arg.rs:19:18
|
LL | fn do_vec_mut(x: &mut Vec<i64>) {
| ^^^^^^^^^^^^^ help: change this to: `&mut [i64]`
error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:25:19
--> tests/ui/ptr_arg.rs:24:19
|
LL | fn do_vec_mut2(x: &mut Vec<i64>) {
| ^^^^^^^^^^^^^ help: change this to: `&mut [i64]`
error: writing `&String` instead of `&str` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:31:14
--> tests/ui/ptr_arg.rs:30:14
|
LL | fn do_str(x: &String) {
| ^^^^^^^ help: change this to: `&str`
error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:36:18
--> tests/ui/ptr_arg.rs:35:18
|
LL | fn do_str_mut(x: &mut String) {
| ^^^^^^^^^^^ help: change this to: `&mut str`
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:41:15
--> tests/ui/ptr_arg.rs:40:15
|
LL | fn do_path(x: &PathBuf) {
| ^^^^^^^^ help: change this to: `&Path`
error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:46:19
--> tests/ui/ptr_arg.rs:45:19
|
LL | fn do_path_mut(x: &mut PathBuf) {
| ^^^^^^^^^^^^ help: change this to: `&mut Path`
error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:55:18
--> tests/ui/ptr_arg.rs:54:18
|
LL | fn do_vec(x: &Vec<i64>);
| ^^^^^^^^^ help: change this to: `&[i64]`
error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:69:14
--> tests/ui/ptr_arg.rs:68:14
|
LL | fn cloned(x: &Vec<u8>) -> Vec<u8> {
| ^^^^^^^^
@ -68,7 +68,7 @@ LL ~ x.to_owned()
|
error: writing `&String` instead of `&str` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:79:18
--> tests/ui/ptr_arg.rs:78:18
|
LL | fn str_cloned(x: &String) -> String {
| ^^^^^^^
@ -85,7 +85,7 @@ LL ~ x.to_owned()
|
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:88:19
--> tests/ui/ptr_arg.rs:87:19
|
LL | fn path_cloned(x: &PathBuf) -> PathBuf {
| ^^^^^^^^
@ -102,7 +102,7 @@ LL ~ x.to_path_buf()
|
error: writing `&String` instead of `&str` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:97:44
--> tests/ui/ptr_arg.rs:96:44
|
LL | fn false_positive_capacity(x: &Vec<u8>, y: &String) {
| ^^^^^^^
@ -117,19 +117,19 @@ LL ~ let c = y;
|
error: using a reference to `Cow` is not recommended
--> tests/ui/ptr_arg.rs:112:25
--> tests/ui/ptr_arg.rs:111:25
|
LL | fn test_cow_with_ref(c: &Cow<[i32]>) {}
| ^^^^^^^^^^^ help: change this to: `&[i32]`
error: writing `&String` instead of `&str` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:142:66
--> tests/ui/ptr_arg.rs:141:66
|
LL | fn some_allowed(#[allow(clippy::ptr_arg)] _v: &Vec<u32>, _s: &String) {}
| ^^^^^^^ help: change this to: `&str`
error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:172:21
--> tests/ui/ptr_arg.rs:171:21
|
LL | fn foo_vec(vec: &Vec<u8>) {
| ^^^^^^^^
@ -143,7 +143,7 @@ LL ~ let _ = vec.to_owned().clone();
|
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:178:23
--> tests/ui/ptr_arg.rs:177:23
|
LL | fn foo_path(path: &PathBuf) {
| ^^^^^^^^
@ -157,7 +157,7 @@ LL ~ let _ = path.to_path_buf().clone();
|
error: writing `&PathBuf` instead of `&Path` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:184:21
--> tests/ui/ptr_arg.rs:183:21
|
LL | fn foo_str(str: &PathBuf) {
| ^^^^^^^^
@ -171,43 +171,43 @@ LL ~ let _ = str.to_path_buf().clone();
|
error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:191:29
--> tests/ui/ptr_arg.rs:190:29
|
LL | fn mut_vec_slice_methods(v: &mut Vec<u32>) {
| ^^^^^^^^^^^^^ help: change this to: `&mut [u32]`
error: writing `&mut Vec` instead of `&mut [_]` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:254:17
--> tests/ui/ptr_arg.rs:253:17
|
LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
| ^^^^^^^^^^^^^ help: change this to: `&mut [u32]`
error: writing `&mut String` instead of `&mut str` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:254:35
--> tests/ui/ptr_arg.rs:253:35
|
LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
| ^^^^^^^^^^^ help: change this to: `&mut str`
error: writing `&mut PathBuf` instead of `&mut Path` involves a new object where a slice will do
--> tests/ui/ptr_arg.rs:254:51
--> tests/ui/ptr_arg.rs:253:51
|
LL | fn dyn_trait(a: &mut Vec<u32>, b: &mut String, c: &mut PathBuf) {
| ^^^^^^^^^^^^ help: change this to: `&mut Path`
error: using a reference to `Cow` is not recommended
--> tests/ui/ptr_arg.rs:280:39
--> tests/ui/ptr_arg.rs:279:39
|
LL | fn cow_elided_lifetime<'a>(input: &'a Cow<str>) -> &'a str {
| ^^^^^^^^^^^^ help: change this to: `&str`
error: using a reference to `Cow` is not recommended
--> tests/ui/ptr_arg.rs:286:36
--> tests/ui/ptr_arg.rs:285:36
|
LL | fn cow_bad_ret_ty_1<'a>(input: &'a Cow<'a, str>) -> &'static str {
| ^^^^^^^^^^^^^^^^ help: change this to: `&str`
error: using a reference to `Cow` is not recommended
--> tests/ui/ptr_arg.rs:290:40
--> tests/ui/ptr_arg.rs:289:40
|
LL | fn cow_bad_ret_ty_2<'a, 'b>(input: &'a Cow<'a, str>) -> &'b str {
| ^^^^^^^^^^^^^^^^ help: change this to: `&str`

View file

@ -1,5 +1,4 @@
// rustfix-only-machine-applicable
#![feature(lint_reasons)]
#![warn(clippy::redundant_clone)]
#![allow(
clippy::drop_non_drop,

View file

@ -1,5 +1,4 @@
// rustfix-only-machine-applicable
#![feature(lint_reasons)]
#![warn(clippy::redundant_clone)]
#![allow(
clippy::drop_non_drop,

View file

@ -1,11 +1,11 @@
error: redundant clone
--> tests/ui/redundant_clone.rs:15:42
--> tests/ui/redundant_clone.rs:14:42
|
LL | let _s = ["lorem", "ipsum"].join(" ").to_string();
| ^^^^^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> tests/ui/redundant_clone.rs:15:14
--> tests/ui/redundant_clone.rs:14:14
|
LL | let _s = ["lorem", "ipsum"].join(" ").to_string();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -13,169 +13,169 @@ LL | let _s = ["lorem", "ipsum"].join(" ").to_string();
= help: to override `-D warnings` add `#[allow(clippy::redundant_clone)]`
error: redundant clone
--> tests/ui/redundant_clone.rs:18:15
--> tests/ui/redundant_clone.rs:17:15
|
LL | let _s = s.clone();
| ^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> tests/ui/redundant_clone.rs:18:14
--> tests/ui/redundant_clone.rs:17:14
|
LL | let _s = s.clone();
| ^
error: redundant clone
--> tests/ui/redundant_clone.rs:21:15
--> tests/ui/redundant_clone.rs:20:15
|
LL | let _s = s.to_string();
| ^^^^^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> tests/ui/redundant_clone.rs:21:14
--> tests/ui/redundant_clone.rs:20:14
|
LL | let _s = s.to_string();
| ^
error: redundant clone
--> tests/ui/redundant_clone.rs:24:15
--> tests/ui/redundant_clone.rs:23:15
|
LL | let _s = s.to_owned();
| ^^^^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> tests/ui/redundant_clone.rs:24:14
--> tests/ui/redundant_clone.rs:23:14
|
LL | let _s = s.to_owned();
| ^
error: redundant clone
--> tests/ui/redundant_clone.rs:26:42
--> tests/ui/redundant_clone.rs:25:42
|
LL | let _s = Path::new("/a/b/").join("c").to_owned();
| ^^^^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> tests/ui/redundant_clone.rs:26:14
--> tests/ui/redundant_clone.rs:25:14
|
LL | let _s = Path::new("/a/b/").join("c").to_owned();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: redundant clone
--> tests/ui/redundant_clone.rs:28:42
--> tests/ui/redundant_clone.rs:27:42
|
LL | let _s = Path::new("/a/b/").join("c").to_path_buf();
| ^^^^^^^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> tests/ui/redundant_clone.rs:28:14
--> tests/ui/redundant_clone.rs:27:14
|
LL | let _s = Path::new("/a/b/").join("c").to_path_buf();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: redundant clone
--> tests/ui/redundant_clone.rs:30:29
--> tests/ui/redundant_clone.rs:29:29
|
LL | let _s = OsString::new().to_owned();
| ^^^^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> tests/ui/redundant_clone.rs:30:14
--> tests/ui/redundant_clone.rs:29:14
|
LL | let _s = OsString::new().to_owned();
| ^^^^^^^^^^^^^^^
error: redundant clone
--> tests/ui/redundant_clone.rs:32:29
--> tests/ui/redundant_clone.rs:31:29
|
LL | let _s = OsString::new().to_os_string();
| ^^^^^^^^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> tests/ui/redundant_clone.rs:32:14
--> tests/ui/redundant_clone.rs:31:14
|
LL | let _s = OsString::new().to_os_string();
| ^^^^^^^^^^^^^^^
error: redundant clone
--> tests/ui/redundant_clone.rs:43:19
--> tests/ui/redundant_clone.rs:42:19
|
LL | let _t = tup.0.clone();
| ^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> tests/ui/redundant_clone.rs:43:14
--> tests/ui/redundant_clone.rs:42:14
|
LL | let _t = tup.0.clone();
| ^^^^^
error: redundant clone
--> tests/ui/redundant_clone.rs:75:25
--> tests/ui/redundant_clone.rs:74:25
|
LL | if b { (a.clone(), a.clone()) } else { (Alpha, a) }
| ^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> tests/ui/redundant_clone.rs:75:24
--> tests/ui/redundant_clone.rs:74:24
|
LL | if b { (a.clone(), a.clone()) } else { (Alpha, a) }
| ^
error: redundant clone
--> tests/ui/redundant_clone.rs:132:15
--> tests/ui/redundant_clone.rs:131:15
|
LL | let _s = s.clone();
| ^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> tests/ui/redundant_clone.rs:131:14
|
LL | let _s = s.clone();
| ^
error: redundant clone
--> tests/ui/redundant_clone.rs:132:15
|
LL | let _t = t.clone();
| ^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> tests/ui/redundant_clone.rs:132:14
|
LL | let _s = s.clone();
| ^
error: redundant clone
--> tests/ui/redundant_clone.rs:133:15
|
LL | let _t = t.clone();
| ^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> tests/ui/redundant_clone.rs:133:14
|
LL | let _t = t.clone();
| ^
error: redundant clone
--> tests/ui/redundant_clone.rs:143:19
--> tests/ui/redundant_clone.rs:142:19
|
LL | let _f = f.clone();
| ^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> tests/ui/redundant_clone.rs:143:18
--> tests/ui/redundant_clone.rs:142:18
|
LL | let _f = f.clone();
| ^
error: redundant clone
--> tests/ui/redundant_clone.rs:155:14
--> tests/ui/redundant_clone.rs:154:14
|
LL | let y = x.clone().join("matthias");
| ^^^^^^^^ help: remove this
|
note: cloned value is neither consumed nor mutated
--> tests/ui/redundant_clone.rs:155:13
--> tests/ui/redundant_clone.rs:154:13
|
LL | let y = x.clone().join("matthias");
| ^^^^^^^^^
error: redundant clone
--> tests/ui/redundant_clone.rs:209:11
--> tests/ui/redundant_clone.rs:208:11
|
LL | foo(&x.clone(), move || {
| ^^^^^^^^ help: remove this
|
note: this value is dropped without further use
--> tests/ui/redundant_clone.rs:209:10
--> tests/ui/redundant_clone.rs:208:10
|
LL | foo(&x.clone(), move || {
| ^

View file

@ -1,6 +1,5 @@
// FIXME: run-rustfix waiting on multi-span suggestions
//@no-rustfix
#![feature(lint_reasons)]
#![warn(clippy::ref_binding_to_reference)]
#![allow(clippy::needless_borrowed_reference, clippy::explicit_auto_deref)]

View file

@ -1,5 +1,5 @@
error: this pattern creates a reference to a reference
--> tests/ui/ref_binding_to_reference.rs:31:14
--> tests/ui/ref_binding_to_reference.rs:30:14
|
LL | Some(ref x) => x,
| ^^^^^
@ -12,7 +12,7 @@ LL | Some(x) => &x,
| ~ ~~
error: this pattern creates a reference to a reference
--> tests/ui/ref_binding_to_reference.rs:39:14
--> tests/ui/ref_binding_to_reference.rs:38:14
|
LL | Some(ref x) => {
| ^^^^^
@ -27,7 +27,7 @@ LL ~ &x
|
error: this pattern creates a reference to a reference
--> tests/ui/ref_binding_to_reference.rs:50:14
--> tests/ui/ref_binding_to_reference.rs:49:14
|
LL | Some(ref x) => m2!(x),
| ^^^^^
@ -38,7 +38,7 @@ LL | Some(x) => m2!(&x),
| ~ ~~
error: this pattern creates a reference to a reference
--> tests/ui/ref_binding_to_reference.rs:56:15
--> tests/ui/ref_binding_to_reference.rs:55:15
|
LL | let _ = |&ref x: &&String| {
| ^^^^^
@ -51,7 +51,7 @@ LL ~ let _: &&String = &x;
|
error: this pattern creates a reference to a reference
--> tests/ui/ref_binding_to_reference.rs:63:12
--> tests/ui/ref_binding_to_reference.rs:62:12
|
LL | fn f2<'a>(&ref x: &&'a String) -> &'a String {
| ^^^^^
@ -65,7 +65,7 @@ LL ~ x
|
error: this pattern creates a reference to a reference
--> tests/ui/ref_binding_to_reference.rs:71:11
--> tests/ui/ref_binding_to_reference.rs:70:11
|
LL | fn f(&ref x: &&String) {
| ^^^^^
@ -78,7 +78,7 @@ LL ~ let _: &&String = &x;
|
error: this pattern creates a reference to a reference
--> tests/ui/ref_binding_to_reference.rs:80:11
--> tests/ui/ref_binding_to_reference.rs:79:11
|
LL | fn f(&ref x: &&String) {
| ^^^^^

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![warn(clippy::same_name_method)]
#![allow(dead_code, non_camel_case_types)]

View file

@ -1,11 +1,11 @@
error: method's name is the same as an existing method in a trait
--> tests/ui/same_name_method.rs:21:13
--> tests/ui/same_name_method.rs:20:13
|
LL | fn foo() {}
| ^^^^^^^^^^^
|
note: existing `foo` defined here
--> tests/ui/same_name_method.rs:26:13
--> tests/ui/same_name_method.rs:25:13
|
LL | fn foo() {}
| ^^^^^^^^^^^
@ -13,62 +13,62 @@ LL | fn foo() {}
= help: to override `-D warnings` add `#[allow(clippy::same_name_method)]`
error: method's name is the same as an existing method in a trait
--> tests/ui/same_name_method.rs:36:13
--> tests/ui/same_name_method.rs:35:13
|
LL | fn clone() {}
| ^^^^^^^^^^^^^
|
note: existing `clone` defined here
--> tests/ui/same_name_method.rs:32:18
--> tests/ui/same_name_method.rs:31:18
|
LL | #[derive(Clone)]
| ^^^^^
= note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info)
error: method's name is the same as an existing method in a trait
--> tests/ui/same_name_method.rs:47:13
--> tests/ui/same_name_method.rs:46:13
|
LL | fn foo() {}
| ^^^^^^^^^^^
|
note: existing `foo` defined here
--> tests/ui/same_name_method.rs:52:13
--> tests/ui/same_name_method.rs:51:13
|
LL | fn foo() {}
| ^^^^^^^^^^^
error: method's name is the same as an existing method in a trait
--> tests/ui/same_name_method.rs:62:13
--> tests/ui/same_name_method.rs:61:13
|
LL | fn foo() {}
| ^^^^^^^^^^^
|
note: existing `foo` defined here
--> tests/ui/same_name_method.rs:66:9
--> tests/ui/same_name_method.rs:65:9
|
LL | impl T1 for S {}
| ^^^^^^^^^^^^^^^^
error: method's name is the same as an existing method in a trait
--> tests/ui/same_name_method.rs:75:13
--> tests/ui/same_name_method.rs:74:13
|
LL | fn foo() {}
| ^^^^^^^^^^^
|
note: existing `foo` defined here
--> tests/ui/same_name_method.rs:80:9
--> tests/ui/same_name_method.rs:79:9
|
LL | impl T1 for S {}
| ^^^^^^^^^^^^^^^^
error: method's name is the same as an existing method in a trait
--> tests/ui/same_name_method.rs:75:13
--> tests/ui/same_name_method.rs:74:13
|
LL | fn foo() {}
| ^^^^^^^^^^^
|
note: existing `foo` defined here
--> tests/ui/same_name_method.rs:82:9
--> tests/ui/same_name_method.rs:81:9
|
LL | impl T2 for S {}
| ^^^^^^^^^^^^^^^^

View file

@ -1,4 +1,3 @@
#![feature(lint_reasons)]
#![warn(clippy::unsafe_derive_deserialize)]
#![allow(unused, clippy::missing_safety_doc)]

View file

@ -1,5 +1,5 @@
error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
--> tests/ui/unsafe_derive_deserialize.rs:9:10
--> tests/ui/unsafe_derive_deserialize.rs:8:10
|
LL | #[derive(Deserialize)]
| ^^^^^^^^^^^
@ -10,7 +10,7 @@ LL | #[derive(Deserialize)]
= note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
--> tests/ui/unsafe_derive_deserialize.rs:18:10
--> tests/ui/unsafe_derive_deserialize.rs:17:10
|
LL | #[derive(Deserialize)]
| ^^^^^^^^^^^
@ -19,7 +19,7 @@ LL | #[derive(Deserialize)]
= note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
--> tests/ui/unsafe_derive_deserialize.rs:25:10
--> tests/ui/unsafe_derive_deserialize.rs:24:10
|
LL | #[derive(Deserialize)]
| ^^^^^^^^^^^
@ -28,7 +28,7 @@ LL | #[derive(Deserialize)]
= note: this error originates in the derive macro `Deserialize` (in Nightly builds, run with -Z macro-backtrace for more info)
error: you are deriving `serde::Deserialize` on a type that has methods using `unsafe`
--> tests/ui/unsafe_derive_deserialize.rs:34:10
--> tests/ui/unsafe_derive_deserialize.rs:33:10
|
LL | #[derive(Deserialize)]
| ^^^^^^^^^^^

View file

@ -1,5 +1,5 @@
//@aux-build:proc_macro_derive.rs
#![feature(rustc_private, lint_reasons)]
#![feature(rustc_private)]
#![warn(clippy::used_underscore_binding)]
#![allow(clippy::disallowed_names, clippy::eq_op, clippy::uninlined_format_args)]

View file

@ -10,7 +10,7 @@
#![feature(yeet_expr)]
#![feature(nonzero_ops)]
#![feature(let_chains)]
#![feature(lint_reasons)]
#![cfg_attr(bootstrap, feature(lint_reasons))]
#![feature(trait_upcasting)]
#![feature(strict_overflow_ops)]
#![feature(is_none_or)]

View file

@ -0,0 +1,16 @@
//! Ensure that we call Windows TLS callbacks in the local crate.
//@only-target-windows
// Calling eprintln in the callback seems to (re-)initialize some thread-local storage
// and then leak the memory allocated for that. Let's just ignore these leaks,
// that's not what this test is about.
//@compile-flags: -Zmiri-ignore-leaks
#[link_section = ".CRT$XLB"]
#[used] // Miri only considers explicitly `#[used]` statics for `lookup_link_section`
pub static CALLBACK: unsafe extern "system" fn(*const (), u32, *const ()) = tls_callback;
unsafe extern "system" fn tls_callback(_h: *const (), _dw_reason: u32, _pv: *const ()) {
eprintln!("in tls_callback");
}
fn main() {}

View file

@ -0,0 +1 @@
in tls_callback

View file

@ -142,9 +142,9 @@ pub const INERT_ATTRIBUTES: &[BuiltinAttribute] = &[
allow, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#),
DuplicatesOk, @only_local: true,
),
gated!(
expect, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#), DuplicatesOk,
lint_reasons, experimental!(expect)
ungated!(
expect, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#),
DuplicatesOk, @only_local: true,
),
ungated!(
forbid, Normal, template!(List: r#"lint1, lint2, ..., /*opt*/ reason = "...""#),

View file

@ -15,6 +15,7 @@ semver = "1.0"
termcolor = "1.1.3"
rustc-hash = "1.1.0"
fluent-syntax = "0.11.1"
similar = "2.5.0"
[[bin]]
name = "rust-tidy"

View file

@ -6,5 +6,6 @@
# Note: this generation step should be run with the oldest supported python
# version (currently 3.9) to ensure backward compatibility
black==23.3.0
ruff==0.0.272
black==24.4.2
ruff==0.4.9
clang-format==18.1.7

View file

@ -4,32 +4,46 @@
#
# pip-compile --generate-hashes --strip-extras src/tools/tidy/config/requirements.in
#
black==23.3.0 \
--hash=sha256:064101748afa12ad2291c2b91c960be28b817c0c7eaa35bec09cc63aa56493c5 \
--hash=sha256:0945e13506be58bf7db93ee5853243eb368ace1c08a24c65ce108986eac65915 \
--hash=sha256:11c410f71b876f961d1de77b9699ad19f939094c3a677323f43d7a29855fe326 \
--hash=sha256:1c7b8d606e728a41ea1ccbd7264677e494e87cf630e399262ced92d4a8dac940 \
--hash=sha256:1d06691f1eb8de91cd1b322f21e3bfc9efe0c7ca1f0e1eb1db44ea367dff656b \
--hash=sha256:3238f2aacf827d18d26db07524e44741233ae09a584273aa059066d644ca7b30 \
--hash=sha256:32daa9783106c28815d05b724238e30718f34155653d4d6e125dc7daec8e260c \
--hash=sha256:35d1381d7a22cc5b2be2f72c7dfdae4072a3336060635718cc7e1ede24221d6c \
--hash=sha256:3a150542a204124ed00683f0db1f5cf1c2aaaa9cc3495b7a3b5976fb136090ab \
--hash=sha256:48f9d345675bb7fbc3dd85821b12487e1b9a75242028adad0333ce36ed2a6d27 \
--hash=sha256:50cb33cac881766a5cd9913e10ff75b1e8eb71babf4c7104f2e9c52da1fb7de2 \
--hash=sha256:562bd3a70495facf56814293149e51aa1be9931567474993c7942ff7d3533961 \
--hash=sha256:67de8d0c209eb5b330cce2469503de11bca4085880d62f1628bd9972cc3366b9 \
--hash=sha256:6b39abdfb402002b8a7d030ccc85cf5afff64ee90fa4c5aebc531e3ad0175ddb \
--hash=sha256:6f3c333ea1dd6771b2d3777482429864f8e258899f6ff05826c3a4fcc5ce3f70 \
--hash=sha256:714290490c18fb0126baa0fca0a54ee795f7502b44177e1ce7624ba1c00f2331 \
--hash=sha256:7c3eb7cea23904399866c55826b31c1f55bbcd3890ce22ff70466b907b6775c2 \
--hash=sha256:92c543f6854c28a3c7f39f4d9b7694f9a6eb9d3c5e2ece488c327b6e7ea9b266 \
--hash=sha256:a6f6886c9869d4daae2d1715ce34a19bbc4b95006d20ed785ca00fa03cba312d \
--hash=sha256:a8a968125d0a6a404842fa1bf0b349a568634f856aa08ffaff40ae0dfa52e7c6 \
--hash=sha256:c7ab5790333c448903c4b721b59c0d80b11fe5e9803d8703e84dcb8da56fec1b \
--hash=sha256:e114420bf26b90d4b9daa597351337762b63039752bdf72bf361364c1aa05925 \
--hash=sha256:e198cf27888ad6f4ff331ca1c48ffc038848ea9f031a3b40ba36aced7e22f2c8 \
--hash=sha256:ec751418022185b0c1bb7d7736e6933d40bbb14c14a0abcf9123d1b159f98dd4 \
--hash=sha256:f0bd2f4a58d6666500542b26354978218a9babcdc972722f4bf90779524515f3
black==24.4.2 \
--hash=sha256:257d724c2c9b1660f353b36c802ccece186a30accc7742c176d29c146df6e474 \
--hash=sha256:37aae07b029fa0174d39daf02748b379399b909652a806e5708199bd93899da1 \
--hash=sha256:415e686e87dbbe6f4cd5ef0fbf764af7b89f9057b97c908742b6008cc554b9c0 \
--hash=sha256:48a85f2cb5e6799a9ef05347b476cce6c182d6c71ee36925a6c194d074336ef8 \
--hash=sha256:7768a0dbf16a39aa5e9a3ded568bb545c8c2727396d063bbaf847df05b08cd96 \
--hash=sha256:7e122b1c4fb252fd85df3ca93578732b4749d9be076593076ef4d07a0233c3e1 \
--hash=sha256:88c57dc656038f1ab9f92b3eb5335ee9b021412feaa46330d5eba4e51fe49b04 \
--hash=sha256:8e537d281831ad0e71007dcdcbe50a71470b978c453fa41ce77186bbe0ed6021 \
--hash=sha256:98e123f1d5cfd42f886624d84464f7756f60ff6eab89ae845210631714f6db94 \
--hash=sha256:accf49e151c8ed2c0cdc528691838afd217c50412534e876a19270fea1e28e2d \
--hash=sha256:b1530ae42e9d6d5b670a34db49a94115a64596bc77710b1d05e9801e62ca0a7c \
--hash=sha256:b9176b9832e84308818a99a561e90aa479e73c523b3f77afd07913380ae2eab7 \
--hash=sha256:bdde6f877a18f24844e381d45e9947a49e97933573ac9d4345399be37621e26c \
--hash=sha256:be8bef99eb46d5021bf053114442914baeb3649a89dc5f3a555c88737e5e98fc \
--hash=sha256:bf10f7310db693bb62692609b397e8d67257c55f949abde4c67f9cc574492cc7 \
--hash=sha256:c872b53057f000085da66a19c55d68f6f8ddcac2642392ad3a355878406fbd4d \
--hash=sha256:d36ed1124bb81b32f8614555b34cc4259c3fbc7eec17870e8ff8ded335b58d8c \
--hash=sha256:da33a1a5e49c4122ccdfd56cd021ff1ebc4a1ec4e2d01594fef9b6f267a9e741 \
--hash=sha256:dd1b5a14e417189db4c7b64a6540f31730713d173f0b63e55fabd52d61d8fdce \
--hash=sha256:e151054aa00bad1f4e1f04919542885f89f5f7d086b8a59e5000e6c616896ffb \
--hash=sha256:eaea3008c281f1038edb473c1aa8ed8143a5535ff18f978a318f10302b254063 \
--hash=sha256:ef703f83fc32e131e9bcc0a5094cfe85599e7109f896fe8bc96cc402f3eb4b6e
# via -r src/tools/tidy/config/requirements.in
clang-format==18.1.7 \
--hash=sha256:035204410f65d03f98cb81c9c39d6d193f9987917cc88de9d0dbd01f2aa9c302 \
--hash=sha256:05c482a854287a5d21f7567186c0bd4b8dbd4a871751e655a45849185f30b931 \
--hash=sha256:0b352ec51b291fe04c25a0f0ed15ba1a55b9c9c8eaa7fdf14de3d3585aef4f72 \
--hash=sha256:217526c8189c18fd175e19bb3e4da2d1bdf14a2bf79d97108c9b6a98d9938351 \
--hash=sha256:42d0b580ab7a45348155944adebe0bef53d1de9357b925830a59bbc351a25560 \
--hash=sha256:57090c40a8f0a898e0db8be150a19be2551302d5f5620d2a01de07e7c9220a53 \
--hash=sha256:607772cf474c1ebe0de44f44c1324e57a2d5b45a1d96d4aff166645532d99b43 \
--hash=sha256:a49c44d7cc00431be8285aa120a7a21fa0475786c03c53b04a26882c4e626a43 \
--hash=sha256:a62fca204293893badde0ab004df8b6df1d13eac4d452051554d9684d0a8254e \
--hash=sha256:a914592a51f77c3563563c7a8970f19bc1ed59174ab992f095a78f4e142382ac \
--hash=sha256:b3a0a09428cdd656ed87074543222a80660bc506407ed21b8e4bcb3d6d3a5a3c \
--hash=sha256:c151d42e6ac7c3cc03d7fec61bed3211ce8f75528e1efd8fc64bdb33840987b2 \
--hash=sha256:d6a2f051124d6ae506ba2a68accfe4ea4c8cb90d13b422c3131bb124413bac32 \
--hash=sha256:f4f77ac0f4f9a659213fedda0f2d216886c410132e6e7dd4b13f92b34e925554 \
--hash=sha256:f935d34152a2e11e55120eb9182862f432bc9789ab819f680c9f6db4edebf9e3
# via -r src/tools/tidy/config/requirements.in
click==8.1.3 \
--hash=sha256:7682dc8afb30297001674575ea00d1814d808d6a36af415a82bd481d37ba7b8e \
@ -47,28 +61,28 @@ pathspec==0.11.1 \
--hash=sha256:2798de800fa92780e33acca925945e9a19a133b715067cf165b8866c15a31687 \
--hash=sha256:d8af70af76652554bd134c22b3e8a1cc46ed7d91edcdd721ef1a0c51a84a5293
# via black
platformdirs==3.6.0 \
--hash=sha256:57e28820ca8094678b807ff529196506d7a21e17156cb1cddb3e74cebce54640 \
--hash=sha256:ffa199e3fbab8365778c4a10e1fbf1b9cd50707de826eb304b50e57ec0cc8d38
platformdirs==4.2.2 \
--hash=sha256:2d7a1657e36a80ea911db832a8a6ece5ee53d8de21edd5cc5879af6530b1bfee \
--hash=sha256:38b7b51f512eed9e84a22788b4bce1de17c0adb134d6becb09836e37d8654cd3
# via black
ruff==0.0.272 \
--hash=sha256:06b8ee4eb8711ab119db51028dd9f5384b44728c23586424fd6e241a5b9c4a3b \
--hash=sha256:1609b864a8d7ee75a8c07578bdea0a7db75a144404e75ef3162e0042bfdc100d \
--hash=sha256:19643d448f76b1eb8a764719072e9c885968971bfba872e14e7257e08bc2f2b7 \
--hash=sha256:273a01dc8c3c4fd4c2af7ea7a67c8d39bb09bce466e640dd170034da75d14cab \
--hash=sha256:27b2ea68d2aa69fff1b20b67636b1e3e22a6a39e476c880da1282c3e4bf6ee5a \
--hash=sha256:48eccf225615e106341a641f826b15224b8a4240b84269ead62f0afd6d7e2d95 \
--hash=sha256:677284430ac539bb23421a2b431b4ebc588097ef3ef918d0e0a8d8ed31fea216 \
--hash=sha256:691d72a00a99707a4e0b2846690961157aef7b17b6b884f6b4420a9f25cd39b5 \
--hash=sha256:86bc788245361a8148ff98667da938a01e1606b28a45e50ac977b09d3ad2c538 \
--hash=sha256:905ff8f3d6206ad56fcd70674453527b9011c8b0dc73ead27618426feff6908e \
--hash=sha256:9c4bfb75456a8e1efe14c52fcefb89cfb8f2a0d31ed8d804b82c6cf2dc29c42c \
--hash=sha256:a37ec80e238ead2969b746d7d1b6b0d31aa799498e9ba4281ab505b93e1f4b28 \
--hash=sha256:ae9b57546e118660175d45d264b87e9b4c19405c75b587b6e4d21e6a17bf4fdf \
--hash=sha256:bd2bbe337a3f84958f796c77820d55ac2db1e6753f39d1d1baed44e07f13f96d \
--hash=sha256:d5a208f8ef0e51d4746930589f54f9f92f84bb69a7d15b1de34ce80a7681bc00 \
--hash=sha256:dc406e5d756d932da95f3af082814d2467943631a587339ee65e5a4f4fbe83eb \
--hash=sha256:ee76b4f05fcfff37bd6ac209d1370520d509ea70b5a637bdf0a04d0c99e13dff
ruff==0.4.9 \
--hash=sha256:06b60f91bfa5514bb689b500a25ba48e897d18fea14dce14b48a0c40d1635893 \
--hash=sha256:0e8e7b95673f22e0efd3571fb5b0cf71a5eaaa3cc8a776584f3b2cc878e46bff \
--hash=sha256:2d45ddc6d82e1190ea737341326ecbc9a61447ba331b0a8962869fcada758505 \
--hash=sha256:4555056049d46d8a381f746680db1c46e67ac3b00d714606304077682832998e \
--hash=sha256:5d5460f789ccf4efd43f265a58538a2c24dbce15dbf560676e430375f20a8198 \
--hash=sha256:673bddb893f21ab47a8334c8e0ea7fd6598ecc8e698da75bcd12a7b9d0a3206e \
--hash=sha256:732dd550bfa5d85af8c3c6cbc47ba5b67c6aed8a89e2f011b908fc88f87649db \
--hash=sha256:784d3ec9bd6493c3b720a0b76f741e6c2d7d44f6b2be87f5eef1ae8cc1d54c84 \
--hash=sha256:78de3fdb95c4af084087628132336772b1c5044f6e710739d440fc0bccf4d321 \
--hash=sha256:8064590fd1a50dcf4909c268b0e7c2498253273309ad3d97e4a752bb9df4f521 \
--hash=sha256:88bffe9c6a454bf8529f9ab9091c99490578a593cc9f9822b7fc065ee0712a06 \
--hash=sha256:8c1aff58c31948cc66d0b22951aa19edb5af0a3af40c936340cd32a8b1ab7438 \
--hash=sha256:98ec2775fd2d856dc405635e5ee4ff177920f2141b8e2d9eb5bd6efd50e80317 \
--hash=sha256:b262ed08d036ebe162123170b35703aaf9daffecb698cd367a8d585157732991 \
--hash=sha256:e0a22c4157e53d006530c902107c7f550b9233e9706313ab57b892d7197d8e52 \
--hash=sha256:e91175fbe48f8a2174c9aad70438fe9cb0a5732c4159b2a10a3565fea2d94cde \
--hash=sha256:f1cb0828ac9533ba0135d148d214e284711ede33640465e706772645483427e3
# via -r src/tools/tidy/config/requirements.in
tomli==2.0.1 \
--hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \

View file

@ -1,17 +1,7 @@
# Configuration for ruff python linter, run as part of tidy external tools
# B (bugbear), E (pycodestyle, standard), EXE (executables) F (flakes, standard)
# ERM for error messages would be beneficial at some point
select = ["B", "E", "EXE", "F"]
ignore = [
"E501", # line-too-long
"F403", # undefined-local-with-import-star
"F405", # undefined-local-with-import-star-usage
]
# lowest possible for ruff
target-version = "py37"
target-version = "py39"
# Ignore all submodules
extend-exclude = [
@ -41,3 +31,14 @@ extend-exclude = [
"../library/backtrace/",
"../src/tools/rustc-perf/",
]
[lint]
# B (bugbear), E (pycodestyle, standard), EXE (executables) F (flakes, standard)
# ERM for error messages would be beneficial at some point
select = ["B", "E", "EXE", "F"]
ignore = [
"E501", # line-too-long
"F403", # undefined-local-with-import-star
"F405", # undefined-local-with-import-star-usage
]

View file

@ -55,13 +55,11 @@ run-make/incr-foreign-head-span/Makefile
run-make/interdependent-c-libraries/Makefile
run-make/intrinsic-unreachable/Makefile
run-make/invalid-library/Makefile
run-make/invalid-so/Makefile
run-make/issue-107094/Makefile
run-make/issue-109934-lto-debuginfo/Makefile
run-make/issue-14698/Makefile
run-make/issue-15460/Makefile
run-make/issue-18943/Makefile
run-make/issue-20626/Makefile
run-make/issue-22131/Makefile
run-make/issue-25581/Makefile
run-make/issue-26006/Makefile
@ -97,7 +95,6 @@ run-make/long-linker-command-lines-cmd-exe/Makefile
run-make/long-linker-command-lines/Makefile
run-make/longjmp-across-rust/Makefile
run-make/lto-dylib-dep/Makefile
run-make/lto-empty/Makefile
run-make/lto-linkage-used-attr/Makefile
run-make/lto-no-link-whole-rlib/Makefile
run-make/lto-smoke-c/Makefile

View file

@ -73,6 +73,8 @@ fn check_impl(
let python_fmt = lint_args.contains(&"py:fmt") || python_all;
let shell_all = lint_args.contains(&"shell");
let shell_lint = lint_args.contains(&"shell:lint") || shell_all;
let cpp_all = lint_args.contains(&"cpp");
let cpp_fmt = lint_args.contains(&"cpp:fmt") || cpp_all;
let mut py_path = None;
@ -81,7 +83,7 @@ fn check_impl(
.map(OsStr::new)
.partition(|arg| arg.to_str().is_some_and(|s| s.starts_with('-')));
if python_lint || python_fmt {
if python_lint || python_fmt || cpp_fmt {
let venv_path = outdir.join("venv");
let mut reqs_path = root_path.to_owned();
reqs_path.extend(PIP_REQ_PATH);
@ -110,13 +112,14 @@ fn check_impl(
}
let mut args = merge_args(&cfg_args_ruff, &file_args_ruff);
let res = py_runner(py_path.as_ref().unwrap(), "ruff", &args);
args.insert(0, "check".as_ref());
let res = py_runner(py_path.as_ref().unwrap(), true, None, "ruff", &args);
if res.is_err() && show_diff {
eprintln!("\npython linting failed! Printing diff suggestions:");
args.insert(0, "--diff".as_ref());
let _ = py_runner(py_path.as_ref().unwrap(), "ruff", &args);
args.insert(1, "--diff".as_ref());
let _ = py_runner(py_path.as_ref().unwrap(), true, None, "ruff", &args);
}
// Rethrow error
let _ = res?;
@ -143,13 +146,84 @@ fn check_impl(
}
let mut args = merge_args(&cfg_args_black, &file_args_black);
let res = py_runner(py_path.as_ref().unwrap(), "black", &args);
let res = py_runner(py_path.as_ref().unwrap(), true, None, "black", &args);
if res.is_err() && show_diff {
eprintln!("\npython formatting does not match! Printing diff:");
args.insert(0, "--diff".as_ref());
let _ = py_runner(py_path.as_ref().unwrap(), "black", &args);
let _ = py_runner(py_path.as_ref().unwrap(), true, None, "black", &args);
}
// Rethrow error
let _ = res?;
}
if cpp_fmt {
let mut cfg_args_clang_format = cfg_args.clone();
let mut file_args_clang_format = file_args.clone();
let config_path = root_path.join(".clang-format");
let config_file_arg = format!("file:{}", config_path.display());
cfg_args_clang_format.extend(&["--style".as_ref(), config_file_arg.as_ref()]);
if bless {
eprintln!("formatting C++ files");
cfg_args_clang_format.push("-i".as_ref());
} else {
eprintln!("checking C++ file formatting");
cfg_args_clang_format.extend(&["--dry-run".as_ref(), "--Werror".as_ref()]);
}
let files;
if file_args_clang_format.is_empty() {
let llvm_wrapper = root_path.join("compiler/rustc_llvm/llvm-wrapper");
files = find_with_extension(
root_path,
Some(llvm_wrapper.as_path()),
&[OsStr::new("h"), OsStr::new("cpp")],
)?;
file_args_clang_format.extend(files.iter().map(|p| p.as_os_str()));
}
let args = merge_args(&cfg_args_clang_format, &file_args_clang_format);
let res = py_runner(py_path.as_ref().unwrap(), false, None, "clang-format", &args);
if res.is_err() && show_diff {
eprintln!("\nclang-format linting failed! Printing diff suggestions:");
let mut cfg_args_clang_format_diff = cfg_args.clone();
cfg_args_clang_format_diff.extend(&["--style".as_ref(), config_file_arg.as_ref()]);
for file in file_args_clang_format {
let mut formatted = String::new();
let mut diff_args = cfg_args_clang_format_diff.clone();
diff_args.push(file);
let _ = py_runner(
py_path.as_ref().unwrap(),
false,
Some(&mut formatted),
"clang-format",
&diff_args,
);
if formatted.is_empty() {
eprintln!(
"failed to obtain the formatted content for '{}'",
file.to_string_lossy()
);
continue;
}
let actual = std::fs::read_to_string(file).unwrap_or_else(|e| {
panic!(
"failed to read the C++ file at '{}' due to '{e}'",
file.to_string_lossy()
)
});
if formatted != actual {
let diff = similar::TextDiff::from_lines(&actual, &formatted);
eprintln!(
"{}",
diff.unified_diff().context_radius(4).header(
&format!("{} (actual)", file.to_string_lossy()),
&format!("{} (formatted)", file.to_string_lossy())
)
);
}
}
}
// Rethrow error
let _ = res?;
@ -161,7 +235,7 @@ fn check_impl(
let mut file_args_shc = file_args.clone();
let files;
if file_args_shc.is_empty() {
files = find_with_extension(root_path, "sh")?;
files = find_with_extension(root_path, None, &[OsStr::new("sh")])?;
file_args_shc.extend(files.iter().map(|p| p.as_os_str()));
}
@ -180,8 +254,31 @@ fn merge_args<'a>(cfg_args: &[&'a OsStr], file_args: &[&'a OsStr]) -> Vec<&'a Os
}
/// Run a python command with given arguments. `py_path` should be a virtualenv.
fn py_runner(py_path: &Path, bin: &'static str, args: &[&OsStr]) -> Result<(), Error> {
let status = Command::new(py_path).arg("-m").arg(bin).args(args).status()?;
///
/// Captures `stdout` to a string if provided, otherwise prints the output.
fn py_runner(
py_path: &Path,
as_module: bool,
stdout: Option<&mut String>,
bin: &'static str,
args: &[&OsStr],
) -> Result<(), Error> {
let mut cmd = Command::new(py_path);
if as_module {
cmd.arg("-m").arg(bin).args(args);
} else {
let bin_path = py_path.with_file_name(bin);
cmd.arg(bin_path).args(args);
}
let status = if let Some(stdout) = stdout {
let output = cmd.output()?;
if let Ok(s) = std::str::from_utf8(&output.stdout) {
stdout.push_str(s);
}
output.status
} else {
cmd.status()?
};
if status.success() { Ok(()) } else { Err(Error::FailedCheck(bin)) }
}
@ -356,7 +453,11 @@ fn shellcheck_runner(args: &[&OsStr]) -> Result<(), Error> {
}
/// Check git for tracked files matching an extension
fn find_with_extension(root_path: &Path, extension: &str) -> Result<Vec<PathBuf>, Error> {
fn find_with_extension(
root_path: &Path,
find_dir: Option<&Path>,
extensions: &[&OsStr],
) -> Result<Vec<PathBuf>, Error> {
// Untracked files show up for short status and are indicated with a leading `?`
// -C changes git to be as if run from that directory
let stat_output =
@ -367,15 +468,25 @@ fn find_with_extension(root_path: &Path, extension: &str) -> Result<Vec<PathBuf>
}
let mut output = Vec::new();
let binding = Command::new("git").arg("-C").arg(root_path).args(["ls-files"]).output()?;
let binding = {
let mut command = Command::new("git");
command.arg("-C").arg(root_path).args(["ls-files"]);
if let Some(find_dir) = find_dir {
command.arg(find_dir);
}
command.output()?
};
let tracked = String::from_utf8_lossy(&binding.stdout);
for line in tracked.lines() {
let line = line.trim();
let path = Path::new(line);
if path.extension() == Some(OsStr::new(extension)) {
output.push(path.to_owned());
let Some(ref extension) = path.extension() else {
continue;
};
if extensions.contains(extension) {
output.push(root_path.join(path));
}
}