Auto merge of #10426 - oli-obk:ui_test, r=Manishearth

Port clippy away from compiletest to ui_test

Reasons to do this:

* runs completely on stable Rust
* is easier to extend with new features
* has its own dogfood test suite, so changes can be tested in [the `ui_test` repo](https://github.com/oli-obk/ui_test)
* supports dependencies from crates.io without having to manually fiddle with command line flags
* supports `ui-cargo`, `ui`, `ui-toml` out of the box, no need to find and run the tests ourselves

One thing that is a big difference to `compiletest` is that if a test emits *any* error, you need to mark all of them with `//~ ERROR:` annotations. Since many clippy tests did not have annotations, I changed many lints to be `warn` in their test so that only the `stderr` output is tested.

TODO:

* [ ] check that this still works as a subtree in the rustc repo

changelog: none
<!-- changelog_checked -->

Note: at present the latest changes needed for clippy are only available as a git dependency, but I expect to publish a new crates.io version soon
This commit is contained in:
bors 2023-06-26 17:32:51 +00:00
commit 15ed281699
272 changed files with 1949 additions and 1455 deletions

View file

@ -1,5 +1,5 @@
//@run-rustfix
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![allow(unused)]
#![warn(clippy::allow_attributes)]
#![feature(lint_reasons)]

View file

@ -1,5 +1,5 @@
//@run-rustfix
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![allow(unused)]
#![warn(clippy::allow_attributes)]
#![feature(lint_reasons)]

View file

@ -1,4 +1,4 @@
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![feature(lint_reasons)]
#![deny(clippy::allow_attributes_without_reason)]
#![allow(unfulfilled_lint_expectations)]

View file

@ -1,6 +1,6 @@
//@run-rustfix
//@edition:2018
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![feature(exclusive_range_pattern)]
#![feature(stmt_expr_attributes)]

View file

@ -1,6 +1,6 @@
//@run-rustfix
//@edition:2018
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![feature(exclusive_range_pattern)]
#![feature(stmt_expr_attributes)]

View file

@ -1,4 +1,4 @@
//@aux-build:proc_macro_derive.rs
//@aux-build:proc_macro_derive.rs:proc-macro
#![allow(
clippy::assign_op_pattern,

View file

@ -1,4 +1,4 @@
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![warn(clippy::as_conversions)]
#![allow(clippy::borrow_as_ptr, unused)]

View file

@ -1,5 +1,5 @@
//@only-x86_64
//@ignore-aarch64
//@only-target-x86_64
//@ignore-target-aarch64
#[warn(clippy::inline_asm_x86_intel_syntax)]
mod warn_intel {

View file

@ -1,3 +1,5 @@
//@aux-build:macro_rules.rs
extern crate macro_rules;
// STMT

View file

@ -1,7 +1,3 @@
//@compile-flags: --emit=link
//@no-prefer-dynamic
#![crate_type = "proc-macro"]
#![feature(repr128, proc_macro_hygiene, proc_macro_quote, box_patterns)]
#![allow(incomplete_features)]
#![allow(clippy::useless_conversion, clippy::uninlined_format_args)]

View file

@ -1,7 +1,3 @@
//@compile-flags: --emit=link
//@no-prefer-dynamic
#![crate_type = "proc-macro"]
#![feature(repr128, proc_macro_quote)]
#![allow(incomplete_features)]
#![allow(clippy::field_reassign_with_default)]

View file

@ -1,8 +1,3 @@
//@compile-flags: --emit=link
//@no-prefer-dynamic
#![crate_type = "proc-macro"]
extern crate proc_macro;
use proc_macro::{token_stream, Delimiter, Group, Ident, Span, TokenStream, TokenTree};

View file

@ -1,8 +1,3 @@
//@compile-flags: --emit=link
//@no-prefer-dynamic
#![crate_type = "proc-macro"]
extern crate proc_macro;
use proc_macro::{Delimiter, Group, Ident, TokenStream, TokenTree};

View file

@ -1,7 +1,3 @@
//@compile-flags: --emit=link
//@no-prefer-dynamic
#![crate_type = "proc-macro"]
#![feature(let_chains)]
#![feature(proc_macro_span)]
#![allow(clippy::needless_if, dead_code)]

View file

@ -1,5 +1,5 @@
//@run-rustfix
//@aux-build: proc_macros.rs
//@aux-build: proc_macros.rs:proc-macro
#![allow(dead_code, unused_variables)]

View file

@ -1,5 +1,5 @@
//@run-rustfix
//@aux-build: proc_macros.rs
//@aux-build: proc_macros.rs:proc-macro
#![allow(dead_code, unused_variables)]

View file

@ -1,6 +1,6 @@
//@aux-build:helper.rs
#![warn(clippy::borrow_interior_mutable_const)]
#![deny(clippy::borrow_interior_mutable_const)]
#![allow(clippy::declare_interior_mutable_const)]
// this file (mostly) replicates its `declare` counterpart. Please see it for more discussions.
@ -19,7 +19,7 @@ const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(true));
const FROZEN_VARIANT: OptionalCell = OptionalCell::Frozen;
fn borrow_optional_cell() {
let _ = &UNFROZEN_VARIANT; //~ ERROR interior mutability
let _ = &UNFROZEN_VARIANT; //~ ERROR: interior mutability
let _ = &FROZEN_VARIANT;
}
@ -34,11 +34,11 @@ trait AssocConsts {
// This is the "suboptimal behavior" mentioned in `is_value_unfrozen`
// caused by a similar reason to unfrozen types without any default values
// get linted even if it has frozen variants'.
let _ = &Self::TO_BE_FROZEN_VARIANT; //~ ERROR interior mutable
let _ = &Self::TO_BE_FROZEN_VARIANT; //~ ERROR: interior mutability
// The lint ignores default values because an impl of this trait can set
// an unfrozen variant to `DEFAULTED_ON_FROZEN_VARIANT` and use the default impl for `function`.
let _ = &Self::DEFAULTED_ON_FROZEN_VARIANT; //~ ERROR interior mutable
let _ = &Self::DEFAULTED_ON_FROZEN_VARIANT; //~ ERROR: interior mutability
}
}
@ -47,9 +47,9 @@ impl AssocConsts for u64 {
const TO_BE_FROZEN_VARIANT: OptionalCell = OptionalCell::Frozen;
fn function() {
let _ = &<Self as AssocConsts>::TO_BE_UNFROZEN_VARIANT; //~ ERROR interior mutable
let _ = &<Self as AssocConsts>::TO_BE_UNFROZEN_VARIANT; //~ ERROR: interior mutability
let _ = &<Self as AssocConsts>::TO_BE_FROZEN_VARIANT;
let _ = &Self::DEFAULTED_ON_UNFROZEN_VARIANT; //~ ERROR interior mutable
let _ = &Self::DEFAULTED_ON_UNFROZEN_VARIANT; //~ ERROR: interior mutability
let _ = &Self::DEFAULTED_ON_FROZEN_VARIANT;
}
}
@ -67,11 +67,11 @@ trait AssocTypes {
impl AssocTypes for u64 {
type ToBeUnfrozen = AtomicUsize;
const TO_BE_UNFROZEN_VARIANT: Option<Self::ToBeUnfrozen> = Some(Self::ToBeUnfrozen::new(4)); //~ ERROR interior mutable
const TO_BE_UNFROZEN_VARIANT: Option<Self::ToBeUnfrozen> = Some(Self::ToBeUnfrozen::new(4));
const TO_BE_FROZEN_VARIANT: Option<Self::ToBeUnfrozen> = None;
fn function() {
let _ = &<Self as AssocTypes>::TO_BE_UNFROZEN_VARIANT; //~ ERROR interior mutable
let _ = &<Self as AssocTypes>::TO_BE_UNFROZEN_VARIANT; //~ ERROR: interior mutability
let _ = &<Self as AssocTypes>::TO_BE_FROZEN_VARIANT;
}
}
@ -83,19 +83,19 @@ enum BothOfCellAndGeneric<T> {
}
impl<T> BothOfCellAndGeneric<T> {
const UNFROZEN_VARIANT: BothOfCellAndGeneric<T> = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); //~ ERROR interior mutable
const GENERIC_VARIANT: BothOfCellAndGeneric<T> = BothOfCellAndGeneric::Generic(std::ptr::null()); //~ ERROR interior mutable
const UNFROZEN_VARIANT: BothOfCellAndGeneric<T> = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null()));
const GENERIC_VARIANT: BothOfCellAndGeneric<T> = BothOfCellAndGeneric::Generic(std::ptr::null());
const FROZEN_VARIANT: BothOfCellAndGeneric<T> = BothOfCellAndGeneric::Frozen(5);
fn function() {
let _ = &Self::UNFROZEN_VARIANT; //~ ERROR interior mutability
let _ = &Self::GENERIC_VARIANT; //~ ERROR interior mutability
let _ = &Self::UNFROZEN_VARIANT; //~ ERROR: interior mutability
let _ = &Self::GENERIC_VARIANT; //~ ERROR: interior mutability
let _ = &Self::FROZEN_VARIANT;
}
}
fn main() {
// constants defined in foreign crates
let _ = &helper::WRAPPED_PRIVATE_UNFROZEN_VARIANT; //~ ERROR interior mutability
let _ = &helper::WRAPPED_PRIVATE_UNFROZEN_VARIANT; //~ ERROR: interior mutability
let _ = &helper::WRAPPED_PRIVATE_FROZEN_VARIANT;
}

View file

@ -1,16 +1,20 @@
error: a `const` item with interior mutability should not be borrowed
--> $DIR/enums.rs:22:14
|
LL | let _ = &UNFROZEN_VARIANT; //~ ERROR interior mutability
LL | let _ = &UNFROZEN_VARIANT;
| ^^^^^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
= note: `-D clippy::borrow-interior-mutable-const` implied by `-D warnings`
note: the lint level is defined here
--> $DIR/enums.rs:3:9
|
LL | #![deny(clippy::borrow_interior_mutable_const)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item with interior mutability should not be borrowed
--> $DIR/enums.rs:37:18
|
LL | let _ = &Self::TO_BE_FROZEN_VARIANT; //~ ERROR interior mutable
LL | let _ = &Self::TO_BE_FROZEN_VARIANT;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -18,7 +22,7 @@ LL | let _ = &Self::TO_BE_FROZEN_VARIANT; //~ ERROR interior mutable
error: a `const` item with interior mutability should not be borrowed
--> $DIR/enums.rs:41:18
|
LL | let _ = &Self::DEFAULTED_ON_FROZEN_VARIANT; //~ ERROR interior mutable
LL | let _ = &Self::DEFAULTED_ON_FROZEN_VARIANT;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -26,7 +30,7 @@ LL | let _ = &Self::DEFAULTED_ON_FROZEN_VARIANT; //~ ERROR interior muta
error: a `const` item with interior mutability should not be borrowed
--> $DIR/enums.rs:50:18
|
LL | let _ = &<Self as AssocConsts>::TO_BE_UNFROZEN_VARIANT; //~ ERROR interior mutable
LL | let _ = &<Self as AssocConsts>::TO_BE_UNFROZEN_VARIANT;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -34,7 +38,7 @@ LL | let _ = &<Self as AssocConsts>::TO_BE_UNFROZEN_VARIANT; //~ ERROR i
error: a `const` item with interior mutability should not be borrowed
--> $DIR/enums.rs:52:18
|
LL | let _ = &Self::DEFAULTED_ON_UNFROZEN_VARIANT; //~ ERROR interior mutable
LL | let _ = &Self::DEFAULTED_ON_UNFROZEN_VARIANT;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -42,7 +46,7 @@ LL | let _ = &Self::DEFAULTED_ON_UNFROZEN_VARIANT; //~ ERROR interior mu
error: a `const` item with interior mutability should not be borrowed
--> $DIR/enums.rs:74:18
|
LL | let _ = &<Self as AssocTypes>::TO_BE_UNFROZEN_VARIANT; //~ ERROR interior mutable
LL | let _ = &<Self as AssocTypes>::TO_BE_UNFROZEN_VARIANT;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -50,7 +54,7 @@ LL | let _ = &<Self as AssocTypes>::TO_BE_UNFROZEN_VARIANT; //~ ERROR in
error: a `const` item with interior mutability should not be borrowed
--> $DIR/enums.rs:91:18
|
LL | let _ = &Self::UNFROZEN_VARIANT; //~ ERROR interior mutability
LL | let _ = &Self::UNFROZEN_VARIANT;
| ^^^^^^^^^^^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -58,7 +62,7 @@ LL | let _ = &Self::UNFROZEN_VARIANT; //~ ERROR interior mutability
error: a `const` item with interior mutability should not be borrowed
--> $DIR/enums.rs:92:18
|
LL | let _ = &Self::GENERIC_VARIANT; //~ ERROR interior mutability
LL | let _ = &Self::GENERIC_VARIANT;
| ^^^^^^^^^^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -66,7 +70,7 @@ LL | let _ = &Self::GENERIC_VARIANT; //~ ERROR interior mutability
error: a `const` item with interior mutability should not be borrowed
--> $DIR/enums.rs:99:14
|
LL | let _ = &helper::WRAPPED_PRIVATE_UNFROZEN_VARIANT; //~ ERROR interior mutability
LL | let _ = &helper::WRAPPED_PRIVATE_UNFROZEN_VARIANT;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here

View file

@ -1,4 +1,4 @@
#![warn(clippy::borrow_interior_mutable_const)]
#![deny(clippy::borrow_interior_mutable_const)]
#![allow(clippy::declare_interior_mutable_const, clippy::needless_borrow)]
#![allow(const_item_mutation)]
@ -51,14 +51,14 @@ impl<T> std::ops::Deref for StaticRef<T> {
const CELL_REF: StaticRef<(UnsafeCell<u32>,)> = unsafe { StaticRef::new(std::ptr::null()) };
fn main() {
ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability
assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutability
ATOMIC.store(1, Ordering::SeqCst); //~ ERROR: interior mutability
assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR: interior mutability
let _once = ONCE_INIT;
let _once_ref = &ONCE_INIT; //~ ERROR interior mutability
let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability
let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability
let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability
let _once_ref = &ONCE_INIT; //~ ERROR: interior mutability
let _once_ref_2 = &&ONCE_INIT; //~ ERROR: interior mutability
let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR: interior mutability
let _once_mut = &mut ONCE_INIT; //~ ERROR: interior mutability
let _atomic_into_inner = ATOMIC.into_inner();
// these should be all fine.
let _twice = (ONCE_INIT, ONCE_INIT);
@ -69,23 +69,23 @@ fn main() {
let _ref_array_once = &[ONCE_INIT, ONCE_INIT][0];
// referencing projection is still bad.
let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability
let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability
let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability
let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability
let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mutability
let _ = &ATOMIC_TUPLE; //~ ERROR: interior mutability
let _ = &ATOMIC_TUPLE.0; //~ ERROR: interior mutability
let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR: interior mutability
let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR: interior mutability
let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR: interior mutability
let _ = &*ATOMIC_TUPLE.1;
let _ = &ATOMIC_TUPLE.2;
let _ = (&&&&ATOMIC_TUPLE).0;
let _ = (&&&&ATOMIC_TUPLE).2;
let _ = ATOMIC_TUPLE.0;
let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability
let _ = ATOMIC_TUPLE.0[0]; //~ ERROR: interior mutability
let _ = ATOMIC_TUPLE.1.into_iter();
let _ = ATOMIC_TUPLE.2;
let _ = &{ ATOMIC_TUPLE };
CELL.set(2); //~ ERROR interior mutability
assert_eq!(CELL.get(), 6); //~ ERROR interior mutability
CELL.set(2); //~ ERROR: interior mutability
assert_eq!(CELL.get(), 6); //~ ERROR: interior mutability
assert_eq!(INTEGER, 8);
assert!(STRING.is_empty());

View file

@ -1,16 +1,20 @@
error: a `const` item with interior mutability should not be borrowed
--> $DIR/others.rs:54:5
|
LL | ATOMIC.store(1, Ordering::SeqCst); //~ ERROR interior mutability
LL | ATOMIC.store(1, Ordering::SeqCst);
| ^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
= note: `-D clippy::borrow-interior-mutable-const` implied by `-D warnings`
note: the lint level is defined here
--> $DIR/others.rs:1:9
|
LL | #![deny(clippy::borrow_interior_mutable_const)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item with interior mutability should not be borrowed
--> $DIR/others.rs:55:16
|
LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutability
LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5);
| ^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -18,7 +22,7 @@ LL | assert_eq!(ATOMIC.load(Ordering::SeqCst), 5); //~ ERROR interior mutabi
error: a `const` item with interior mutability should not be borrowed
--> $DIR/others.rs:58:22
|
LL | let _once_ref = &ONCE_INIT; //~ ERROR interior mutability
LL | let _once_ref = &ONCE_INIT;
| ^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -26,7 +30,7 @@ LL | let _once_ref = &ONCE_INIT; //~ ERROR interior mutability
error: a `const` item with interior mutability should not be borrowed
--> $DIR/others.rs:59:25
|
LL | let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability
LL | let _once_ref_2 = &&ONCE_INIT;
| ^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -34,7 +38,7 @@ LL | let _once_ref_2 = &&ONCE_INIT; //~ ERROR interior mutability
error: a `const` item with interior mutability should not be borrowed
--> $DIR/others.rs:60:27
|
LL | let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability
LL | let _once_ref_4 = &&&&ONCE_INIT;
| ^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -42,7 +46,7 @@ LL | let _once_ref_4 = &&&&ONCE_INIT; //~ ERROR interior mutability
error: a `const` item with interior mutability should not be borrowed
--> $DIR/others.rs:61:26
|
LL | let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability
LL | let _once_mut = &mut ONCE_INIT;
| ^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -50,7 +54,7 @@ LL | let _once_mut = &mut ONCE_INIT; //~ ERROR interior mutability
error: a `const` item with interior mutability should not be borrowed
--> $DIR/others.rs:72:14
|
LL | let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability
LL | let _ = &ATOMIC_TUPLE;
| ^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -58,7 +62,7 @@ LL | let _ = &ATOMIC_TUPLE; //~ ERROR interior mutability
error: a `const` item with interior mutability should not be borrowed
--> $DIR/others.rs:73:14
|
LL | let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability
LL | let _ = &ATOMIC_TUPLE.0;
| ^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -66,7 +70,7 @@ LL | let _ = &ATOMIC_TUPLE.0; //~ ERROR interior mutability
error: a `const` item with interior mutability should not be borrowed
--> $DIR/others.rs:74:19
|
LL | let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability
LL | let _ = &(&&&&ATOMIC_TUPLE).0;
| ^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -74,7 +78,7 @@ LL | let _ = &(&&&&ATOMIC_TUPLE).0; //~ ERROR interior mutability
error: a `const` item with interior mutability should not be borrowed
--> $DIR/others.rs:75:14
|
LL | let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability
LL | let _ = &ATOMIC_TUPLE.0[0];
| ^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -82,7 +86,7 @@ LL | let _ = &ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability
error: a `const` item with interior mutability should not be borrowed
--> $DIR/others.rs:76:13
|
LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mutability
LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst);
| ^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -90,7 +94,7 @@ LL | let _ = ATOMIC_TUPLE.0[0].load(Ordering::SeqCst); //~ ERROR interior mu
error: a `const` item with interior mutability should not be borrowed
--> $DIR/others.rs:82:13
|
LL | let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability
LL | let _ = ATOMIC_TUPLE.0[0];
| ^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -98,7 +102,7 @@ LL | let _ = ATOMIC_TUPLE.0[0]; //~ ERROR interior mutability
error: a `const` item with interior mutability should not be borrowed
--> $DIR/others.rs:87:5
|
LL | CELL.set(2); //~ ERROR interior mutability
LL | CELL.set(2);
| ^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -106,7 +110,7 @@ LL | CELL.set(2); //~ ERROR interior mutability
error: a `const` item with interior mutability should not be borrowed
--> $DIR/others.rs:88:16
|
LL | assert_eq!(CELL.get(), 6); //~ ERROR interior mutability
LL | assert_eq!(CELL.get(), 6);
| ^^^^
|
= help: assign this const to a local or static variable, and use the variable here

View file

@ -1,4 +1,4 @@
#![warn(clippy::borrow_interior_mutable_const)]
#![deny(clippy::borrow_interior_mutable_const)]
#![allow(clippy::declare_interior_mutable_const)]
// this file replicates its `declare` counterpart. Please see it for more discussions.
@ -12,7 +12,7 @@ trait ConcreteTypes {
const STRING: String;
fn function() {
let _ = &Self::ATOMIC; //~ ERROR interior mutable
let _ = &Self::ATOMIC; //~ ERROR: interior mutability
let _ = &Self::STRING;
}
}
@ -23,7 +23,7 @@ impl ConcreteTypes for u64 {
fn function() {
// Lint this again since implementers can choose not to borrow it.
let _ = &Self::ATOMIC; //~ ERROR interior mutable
let _ = &Self::ATOMIC; //~ ERROR: interior mutability
let _ = &Self::STRING;
}
}
@ -48,7 +48,7 @@ impl<T: ConstDefault> GenericTypes<T, AtomicUsize> for Vec<T> {
fn function() {
let _ = &Self::TO_REMAIN_GENERIC;
let _ = &Self::TO_BE_CONCRETE; //~ ERROR interior mutable
let _ = &Self::TO_BE_CONCRETE; //~ ERROR: interior mutability
}
}
@ -83,8 +83,8 @@ impl<T: ConstDefault> AssocTypes for Vec<T> {
fn function() {
let _ = &Self::TO_BE_FROZEN;
let _ = &Self::TO_BE_UNFROZEN; //~ ERROR interior mutable
let _ = &Self::WRAPPED_TO_BE_UNFROZEN; //~ ERROR interior mutable
let _ = &Self::TO_BE_UNFROZEN; //~ ERROR: interior mutability
let _ = &Self::WRAPPED_TO_BE_UNFROZEN; //~ ERROR: interior mutability
let _ = &Self::WRAPPED_TO_BE_GENERIC_PARAM;
}
}
@ -106,7 +106,7 @@ where
fn function() {
let _ = &Self::NOT_BOUNDED;
let _ = &Self::BOUNDED; //~ ERROR interior mutable
let _ = &Self::BOUNDED; //~ ERROR: interior mutability
}
}
@ -119,7 +119,7 @@ where
fn function() {
let _ = &Self::NOT_BOUNDED;
let _ = &Self::BOUNDED; //~ ERROR interior mutable
let _ = &Self::BOUNDED; //~ ERROR: interior mutability
}
}
@ -148,8 +148,8 @@ impl SelfType for AtomicUsize {
const WRAPPED_SELF: Option<Self> = Some(AtomicUsize::new(21));
fn function() {
let _ = &Self::SELF; //~ ERROR interior mutable
let _ = &Self::WRAPPED_SELF; //~ ERROR interior mutable
let _ = &Self::SELF; //~ ERROR: interior mutability
let _ = &Self::WRAPPED_SELF; //~ ERROR: interior mutability
}
}
@ -159,7 +159,7 @@ trait BothOfCellAndGeneric<T> {
fn function() {
let _ = &Self::DIRECT;
let _ = &Self::INDIRECT; //~ ERROR interior mutable
let _ = &Self::INDIRECT; //~ ERROR: interior mutability
}
}
@ -169,7 +169,7 @@ impl<T: ConstDefault> BothOfCellAndGeneric<T> for Vec<T> {
fn function() {
let _ = &Self::DIRECT;
let _ = &Self::INDIRECT; //~ ERROR interior mutable
let _ = &Self::INDIRECT; //~ ERROR: interior mutability
}
}
@ -188,15 +188,15 @@ where
const BOUNDED_ASSOC_TYPE: T::ToBeBounded = AtomicUsize::new(19);
fn function() {
let _ = &Self::ATOMIC; //~ ERROR interior mutable
let _ = &Self::ATOMIC; //~ ERROR: interior mutability
let _ = &Self::COW;
let _ = &Self::GENERIC_TYPE;
let _ = &Self::ASSOC_TYPE;
let _ = &Self::BOUNDED_ASSOC_TYPE; //~ ERROR interior mutable
let _ = &Self::BOUNDED_ASSOC_TYPE; //~ ERROR: interior mutability
}
}
fn main() {
u64::ATOMIC.store(5, Ordering::SeqCst); //~ ERROR interior mutability
assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); //~ ERROR interior mutability
u64::ATOMIC.store(5, Ordering::SeqCst); //~ ERROR: interior mutability
assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); //~ ERROR: interior mutability
}

View file

@ -1,16 +1,20 @@
error: a `const` item with interior mutability should not be borrowed
--> $DIR/traits.rs:15:18
|
LL | let _ = &Self::ATOMIC; //~ ERROR interior mutable
LL | let _ = &Self::ATOMIC;
| ^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
= note: `-D clippy::borrow-interior-mutable-const` implied by `-D warnings`
note: the lint level is defined here
--> $DIR/traits.rs:1:9
|
LL | #![deny(clippy::borrow_interior_mutable_const)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item with interior mutability should not be borrowed
--> $DIR/traits.rs:26:18
|
LL | let _ = &Self::ATOMIC; //~ ERROR interior mutable
LL | let _ = &Self::ATOMIC;
| ^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -18,7 +22,7 @@ LL | let _ = &Self::ATOMIC; //~ ERROR interior mutable
error: a `const` item with interior mutability should not be borrowed
--> $DIR/traits.rs:51:18
|
LL | let _ = &Self::TO_BE_CONCRETE; //~ ERROR interior mutable
LL | let _ = &Self::TO_BE_CONCRETE;
| ^^^^^^^^^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -26,7 +30,7 @@ LL | let _ = &Self::TO_BE_CONCRETE; //~ ERROR interior mutable
error: a `const` item with interior mutability should not be borrowed
--> $DIR/traits.rs:86:18
|
LL | let _ = &Self::TO_BE_UNFROZEN; //~ ERROR interior mutable
LL | let _ = &Self::TO_BE_UNFROZEN;
| ^^^^^^^^^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -34,7 +38,7 @@ LL | let _ = &Self::TO_BE_UNFROZEN; //~ ERROR interior mutable
error: a `const` item with interior mutability should not be borrowed
--> $DIR/traits.rs:87:18
|
LL | let _ = &Self::WRAPPED_TO_BE_UNFROZEN; //~ ERROR interior mutable
LL | let _ = &Self::WRAPPED_TO_BE_UNFROZEN;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -42,7 +46,7 @@ LL | let _ = &Self::WRAPPED_TO_BE_UNFROZEN; //~ ERROR interior mutable
error: a `const` item with interior mutability should not be borrowed
--> $DIR/traits.rs:109:18
|
LL | let _ = &Self::BOUNDED; //~ ERROR interior mutable
LL | let _ = &Self::BOUNDED;
| ^^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -50,7 +54,7 @@ LL | let _ = &Self::BOUNDED; //~ ERROR interior mutable
error: a `const` item with interior mutability should not be borrowed
--> $DIR/traits.rs:122:18
|
LL | let _ = &Self::BOUNDED; //~ ERROR interior mutable
LL | let _ = &Self::BOUNDED;
| ^^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -58,7 +62,7 @@ LL | let _ = &Self::BOUNDED; //~ ERROR interior mutable
error: a `const` item with interior mutability should not be borrowed
--> $DIR/traits.rs:151:18
|
LL | let _ = &Self::SELF; //~ ERROR interior mutable
LL | let _ = &Self::SELF;
| ^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -66,7 +70,7 @@ LL | let _ = &Self::SELF; //~ ERROR interior mutable
error: a `const` item with interior mutability should not be borrowed
--> $DIR/traits.rs:152:18
|
LL | let _ = &Self::WRAPPED_SELF; //~ ERROR interior mutable
LL | let _ = &Self::WRAPPED_SELF;
| ^^^^^^^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -74,7 +78,7 @@ LL | let _ = &Self::WRAPPED_SELF; //~ ERROR interior mutable
error: a `const` item with interior mutability should not be borrowed
--> $DIR/traits.rs:162:18
|
LL | let _ = &Self::INDIRECT; //~ ERROR interior mutable
LL | let _ = &Self::INDIRECT;
| ^^^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -82,7 +86,7 @@ LL | let _ = &Self::INDIRECT; //~ ERROR interior mutable
error: a `const` item with interior mutability should not be borrowed
--> $DIR/traits.rs:172:18
|
LL | let _ = &Self::INDIRECT; //~ ERROR interior mutable
LL | let _ = &Self::INDIRECT;
| ^^^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -90,7 +94,7 @@ LL | let _ = &Self::INDIRECT; //~ ERROR interior mutable
error: a `const` item with interior mutability should not be borrowed
--> $DIR/traits.rs:191:18
|
LL | let _ = &Self::ATOMIC; //~ ERROR interior mutable
LL | let _ = &Self::ATOMIC;
| ^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -98,7 +102,7 @@ LL | let _ = &Self::ATOMIC; //~ ERROR interior mutable
error: a `const` item with interior mutability should not be borrowed
--> $DIR/traits.rs:195:18
|
LL | let _ = &Self::BOUNDED_ASSOC_TYPE; //~ ERROR interior mutable
LL | let _ = &Self::BOUNDED_ASSOC_TYPE;
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -106,7 +110,7 @@ LL | let _ = &Self::BOUNDED_ASSOC_TYPE; //~ ERROR interior mutable
error: a `const` item with interior mutability should not be borrowed
--> $DIR/traits.rs:200:5
|
LL | u64::ATOMIC.store(5, Ordering::SeqCst); //~ ERROR interior mutability
LL | u64::ATOMIC.store(5, Ordering::SeqCst);
| ^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here
@ -114,7 +118,7 @@ LL | u64::ATOMIC.store(5, Ordering::SeqCst); //~ ERROR interior mutability
error: a `const` item with interior mutability should not be borrowed
--> $DIR/traits.rs:201:16
|
LL | assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9); //~ ERROR interior mutability
LL | assert_eq!(u64::ATOMIC.load(Ordering::SeqCst), 9);
| ^^^^^^^^^^^
|
= help: assign this const to a local or static variable, and use the variable here

View file

@ -3,7 +3,7 @@
fn foo<u32>(a: u32) -> u32 {
42
// ^ rustc's type error
//~^ ERROR: mismatched types
}
fn main() {}

View file

@ -31,7 +31,7 @@ struct Foo;
impl PartialEq for Foo {
// Allow this here, because it emits the lint
// without a suggestion. This is tested in
// `tests/ui/cmp_owned/without_suggestion.rs`
// `$DIR/without_suggestion.rs`
#[allow(clippy::cmp_owned)]
fn eq(&self, other: &Self) -> bool {
self.to_owned() == *other

View file

@ -39,6 +39,14 @@ LL | fn bar() {
|
= help: you could split it up into multiple smaller functions
error: the function has a cognitive complexity of (2/1)
--> $DIR/cognitive_complexity.rs:178:4
|
LL | fn dont_warn_on_tests() {
| ^^^^^^^^^^^^^^^^^^
|
= help: you could split it up into multiple smaller functions
error: the function has a cognitive complexity of (2/1)
--> $DIR/cognitive_complexity.rs:186:4
|
@ -151,5 +159,5 @@ LL | pub async fn async_method() {
|
= help: you could split it up into multiple smaller functions
error: aborting due to 19 previous errors
error: aborting due to 20 previous errors

View file

@ -1,13 +1,5 @@
//@compile-flags: --emit=link
//@no-prefer-dynamic
// ^ compiletest by default builds all aux files as dylibs, but we don't want that for proc-macro
// crates. If we don't set this, compiletest will override the `crate_type` attribute below and
// compile this as dylib. Removing this then causes the test to fail because a `dylib` crate can't
// contain a proc-macro.
#![feature(repr128)]
#![allow(incomplete_features)]
#![crate_type = "proc-macro"]
extern crate proc_macro;

View file

@ -1,4 +1,4 @@
//@aux-build:../../auxiliary/proc_macros.rs
//@aux-build:../auxiliary/proc_macros.rs:proc-macro
extern crate proc_macros;

View file

@ -1,4 +1,4 @@
//@aux-build:proc_macro_crash.rs
//@aux-build:proc_macro_crash.rs:proc-macro
#![warn(clippy::suspicious_else_formatting)]

View file

@ -7,5 +7,5 @@ pub trait Foo {
impl<T: Foo> Foo for Vec<T> {
const OOB: i32 = [1][1] + T::OOB;
//~^ ERROR operation will panic
//~^ ERROR: operation will panic
}

View file

@ -1,9 +1,3 @@
error[E0601]: `main` function not found in crate `ice_6250`
--> $DIR/ice-6250.rs:16:2
|
LL | }
| ^ consider adding a `main` function to `$DIR/ice-6250.rs`
error[E0308]: mismatched types
--> $DIR/ice-6250.rs:12:14
|
@ -29,7 +23,6 @@ help: consider adding `let`
LL | let Some(reference) = cache.data.get(key) {
| +++
error: aborting due to 3 previous errors
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0308, E0601.
For more information about an error, try `rustc --explain E0308`.
For more information about this error, try `rustc --explain E0308`.

View file

@ -1,9 +1,3 @@
error[E0601]: `main` function not found in crate `ice_6251`
--> $DIR/ice-6251.rs:6:2
|
LL | }
| ^ consider adding a `main` function to `$DIR/ice-6251.rs`
error[E0277]: the size for values of type `[u8]` cannot be known at compilation time
--> $DIR/ice-6251.rs:4:45
|
@ -35,7 +29,7 @@ LL | fn bug<T>() -> impl Iterator<Item = [(); { |x: [u8]| x }]> {
= note: expected type `usize`
found closure `[closure@$DIR/ice-6251.rs:4:44: 4:53]`
error: aborting due to 4 previous errors
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0277, E0308, E0601.
Some errors have detailed explanations: E0277, E0308.
For more information about an error, try `rustc --explain E0277`.

View file

@ -4,7 +4,6 @@
macro_rules! define_other_core {
( ) => {
extern crate std as core;
//~^ ERROR macro-expanded `extern crate` items cannot shadow names passed with `--extern`
};
}
@ -13,3 +12,4 @@ fn main() {
}
define_other_core!();
//~^ ERROR: macro-expanded `extern crate` items cannot shadow names passed with `--extern`

View file

@ -10,6 +10,6 @@ impl dyn TT {
#[rustfmt::skip]
fn main() {
let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types
//[nll]~^ ERROR: borrowed data escapes outside of closure
let f = |x: &dyn TT| x.func();
//~^ ERROR: borrowed data escapes outside of closure
}

View file

@ -1,7 +1,7 @@
error[E0521]: borrowed data escapes outside of closure
--> $DIR/ice-6256.rs:13:26
|
LL | let f = |x: &dyn TT| x.func(); //[default]~ ERROR: mismatched types
LL | let f = |x: &dyn TT| x.func();
| - - ^^^^^^^^
| | | |
| | | `x` escapes the closure body here

View file

@ -1,6 +1,6 @@
//@compile-flags: -Clink-arg=-nostartfiles
//@ignore-macos
//@ignore-windows
//@ignore-target-apple
//@ignore-target-windows
#![feature(lang_items, start, libc)]
#![no_std]

View file

@ -4,7 +4,7 @@ macro_rules! foo {
};
}
#[path = foo!()] //~ ERROR malformed `path` attribute
#[path = foo!()] //~ ERROR: malformed `path` attribute
mod abc {}
fn main() {}

View file

@ -1,7 +1,7 @@
error: malformed `path` attribute input
--> $DIR/ice-96721.rs:7:1
|
LL | #[path = foo!()] //~ ERROR malformed `path` attribute
LL | #[path = foo!()]
| ^^^^^^^^^^^^^^^^ help: must be of the form: `#[path = "file"]`
error: aborting due to previous error

View file

@ -1,4 +1,4 @@
//@ignore-macos
//@ignore-target-apple
#![feature(rustc_attrs)]

View file

@ -1,11 +0,0 @@
error: recursing into entrypoint `a`
--> $DIR/entrypoint_recursion.rs:10:5
|
LL | a();
| ^
|
= help: consider using another function for this recursion
= note: `-D clippy::main-recursion` implied by `-D warnings`
error: aborting due to previous error

View file

@ -1,5 +1,5 @@
//@compile-flags: -Clink-arg=-nostartfiles
//@ignore-macos
//@ignore-target-apple
#![feature(lang_items, start, libc)]
#![no_std]

View file

@ -1,4 +1,3 @@
//@compile-flags: --test
#![warn(clippy::dbg_macro)]
fn foo(n: u32) -> u32 {

View file

@ -1,5 +1,5 @@
error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:5:22
--> $DIR/dbg_macro.rs:4:22
|
LL | if let Some(n) = dbg!(n.checked_sub(4)) { n } else { n }
| ^^^^^^^^^^^^^^^^^^^^^^
@ -11,7 +11,7 @@ LL | if let Some(n) = n.checked_sub(4) { n } else { n }
| ~~~~~~~~~~~~~~~~
error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:10:8
--> $DIR/dbg_macro.rs:9:8
|
LL | if dbg!(n <= 1) {
| ^^^^^^^^^^^^
@ -22,7 +22,7 @@ LL | if n <= 1 {
| ~~~~~~
error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:11:9
--> $DIR/dbg_macro.rs:10:9
|
LL | dbg!(1)
| ^^^^^^^
@ -33,7 +33,7 @@ LL | 1
|
error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:13:9
--> $DIR/dbg_macro.rs:12:9
|
LL | dbg!(n * factorial(n - 1))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
@ -44,7 +44,7 @@ LL | n * factorial(n - 1)
|
error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:18:5
--> $DIR/dbg_macro.rs:17:5
|
LL | dbg!(42);
| ^^^^^^^^
@ -55,7 +55,7 @@ LL | 42;
| ~~
error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:19:5
--> $DIR/dbg_macro.rs:18:5
|
LL | dbg!(dbg!(dbg!(42)));
| ^^^^^^^^^^^^^^^^^^^^
@ -66,7 +66,7 @@ LL | dbg!(dbg!(42));
| ~~~~~~~~~~~~~~
error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:20:14
--> $DIR/dbg_macro.rs:19:14
|
LL | foo(3) + dbg!(factorial(4));
| ^^^^^^^^^^^^^^^^^^
@ -77,7 +77,7 @@ LL | foo(3) + factorial(4);
| ~~~~~~~~~~~~
error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:21:5
--> $DIR/dbg_macro.rs:20:5
|
LL | dbg!(1, 2, dbg!(3, 4));
| ^^^^^^^^^^^^^^^^^^^^^^
@ -88,7 +88,7 @@ LL | (1, 2, dbg!(3, 4));
| ~~~~~~~~~~~~~~~~~~
error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:22:5
--> $DIR/dbg_macro.rs:21:5
|
LL | dbg!(1, 2, 3, 4, 5);
| ^^^^^^^^^^^^^^^^^^^
@ -99,7 +99,7 @@ LL | (1, 2, 3, 4, 5);
| ~~~~~~~~~~~~~~~
error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:42:5
--> $DIR/dbg_macro.rs:41:5
|
LL | dbg!();
| ^^^^^^^
@ -111,7 +111,7 @@ LL +
|
error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:44:13
--> $DIR/dbg_macro.rs:43:13
|
LL | let _ = dbg!();
| ^^^^^^
@ -122,7 +122,7 @@ LL | let _ = ();
| ~~
error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:45:9
--> $DIR/dbg_macro.rs:44:9
|
LL | bar(dbg!());
| ^^^^^^
@ -133,7 +133,7 @@ LL | bar(());
| ~~
error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:46:10
--> $DIR/dbg_macro.rs:45:10
|
LL | foo!(dbg!());
| ^^^^^^
@ -144,7 +144,7 @@ LL | foo!(());
| ~~
error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:47:16
--> $DIR/dbg_macro.rs:46:16
|
LL | foo2!(foo!(dbg!()));
| ^^^^^^
@ -155,7 +155,7 @@ LL | foo2!(foo!(()));
| ~~
error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:68:9
--> $DIR/dbg_macro.rs:67:9
|
LL | dbg!(2);
| ^^^^^^^
@ -166,7 +166,7 @@ LL | 2;
| ~
error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:74:5
--> $DIR/dbg_macro.rs:73:5
|
LL | dbg!(1);
| ^^^^^^^
@ -177,7 +177,7 @@ LL | 1;
| ~
error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:79:5
--> $DIR/dbg_macro.rs:78:5
|
LL | dbg!(1);
| ^^^^^^^
@ -188,7 +188,7 @@ LL | 1;
| ~
error: the `dbg!` macro is intended as a debugging tool
--> $DIR/dbg_macro.rs:85:9
--> $DIR/dbg_macro.rs:84:9
|
LL | dbg!(1);
| ^^^^^^^

View file

@ -9,7 +9,7 @@ enum OptionalCell {
}
// a constant with enums should be linted only when the used variant is unfrozen (#3962).
const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(true)); //~ ERROR interior mutable
const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(true)); //~ ERROR: interior mutable
const FROZEN_VARIANT: OptionalCell = OptionalCell::Frozen;
const fn unfrozen_variant() -> OptionalCell {
@ -20,7 +20,7 @@ const fn frozen_variant() -> OptionalCell {
OptionalCell::Frozen
}
const UNFROZEN_VARIANT_FROM_FN: OptionalCell = unfrozen_variant(); //~ ERROR interior mutable
const UNFROZEN_VARIANT_FROM_FN: OptionalCell = unfrozen_variant(); //~ ERROR: interior mutable
const FROZEN_VARIANT_FROM_FN: OptionalCell = frozen_variant();
enum NestedInnermost {
@ -43,10 +43,11 @@ struct NestedOutermost {
// a constant with enums should be linted according to its value, no matter how structs involve.
const NESTED_UNFROZEN_VARIANT: NestedOutermost = NestedOutermost {
//~^ ERROR: interior mutable
outer: NestedOuter::NestedInner(NestedInner {
inner: NestedInnermost::Unfrozen(AtomicUsize::new(2)),
}),
}; //~ ERROR interior mutable
};
const NESTED_FROZEN_VARIANT: NestedOutermost = NestedOutermost {
outer: NestedOuter::NestedInner(NestedInner {
inner: NestedInnermost::Frozen,
@ -56,11 +57,11 @@ const NESTED_FROZEN_VARIANT: NestedOutermost = NestedOutermost {
trait AssocConsts {
// When there's no default value, lint it only according to its type.
// Further details are on the corresponding code (`NonCopyConst::check_trait_item`).
const TO_BE_UNFROZEN_VARIANT: OptionalCell; //~ ERROR interior mutable
const TO_BE_FROZEN_VARIANT: OptionalCell; //~ ERROR interior mutable
const TO_BE_UNFROZEN_VARIANT: OptionalCell; //~ ERROR: interior mutable
const TO_BE_FROZEN_VARIANT: OptionalCell; //~ ERROR: interior mutable
// Lint default values accordingly.
const DEFAULTED_ON_UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(false)); //~ ERROR interior mutable
const DEFAULTED_ON_UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(false)); //~ ERROR: interior mutable
const DEFAULTED_ON_FROZEN_VARIANT: OptionalCell = OptionalCell::Frozen;
}
@ -86,7 +87,7 @@ trait AssocTypes {
impl AssocTypes for u64 {
type ToBeUnfrozen = AtomicUsize;
const TO_BE_UNFROZEN_VARIANT: Option<Self::ToBeUnfrozen> = Some(Self::ToBeUnfrozen::new(4)); //~ ERROR interior mutable
const TO_BE_UNFROZEN_VARIANT: Option<Self::ToBeUnfrozen> = Some(Self::ToBeUnfrozen::new(4)); //~ ERROR: interior mutable
const TO_BE_FROZEN_VARIANT: Option<Self::ToBeUnfrozen> = None;
}
@ -98,25 +99,25 @@ enum BothOfCellAndGeneric<T> {
}
impl<T> BothOfCellAndGeneric<T> {
const UNFROZEN_VARIANT: BothOfCellAndGeneric<T> = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); //~ ERROR interior mutable
const UNFROZEN_VARIANT: BothOfCellAndGeneric<T> = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); //~ ERROR: interior mutable
// This is a false positive. The argument about this is on `is_value_unfrozen_raw`
const GENERIC_VARIANT: BothOfCellAndGeneric<T> = BothOfCellAndGeneric::Generic(std::ptr::null()); //~ ERROR interior mutable
const GENERIC_VARIANT: BothOfCellAndGeneric<T> = BothOfCellAndGeneric::Generic(std::ptr::null()); //~ ERROR: interior mutable
const FROZEN_VARIANT: BothOfCellAndGeneric<T> = BothOfCellAndGeneric::Frozen(5);
// This is what is likely to be a false negative when one tries to fix
// the `GENERIC_VARIANT` false positive.
const NO_ENUM: Cell<*const T> = Cell::new(std::ptr::null()); //~ ERROR interior mutable
const NO_ENUM: Cell<*const T> = Cell::new(std::ptr::null()); //~ ERROR: interior mutable
}
// associated types here is basically the same as the one above.
trait BothOfCellAndGenericWithAssocType {
type AssocType;
const UNFROZEN_VARIANT: BothOfCellAndGeneric<Self::AssocType> =
BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); //~ ERROR interior mutable
const GENERIC_VARIANT: BothOfCellAndGeneric<Self::AssocType> = BothOfCellAndGeneric::Generic(std::ptr::null()); //~ ERROR interior mutable
const UNFROZEN_VARIANT: BothOfCellAndGeneric<Self::AssocType> = //~ ERROR: interior mutable
BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null()));
const GENERIC_VARIANT: BothOfCellAndGeneric<Self::AssocType> = BothOfCellAndGeneric::Generic(std::ptr::null()); //~ ERROR: interior mutable
const FROZEN_VARIANT: BothOfCellAndGeneric<Self::AssocType> = BothOfCellAndGeneric::Frozen(5);
}

View file

@ -1,7 +1,7 @@
error: a `const` item should never be interior mutable
--> $DIR/enums.rs:12:1
|
LL | const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(true)); //~ ERROR interior mutable
LL | const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(true));
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| make this a static item (maybe with lazy_static)
@ -11,7 +11,7 @@ LL | const UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(tru
error: a `const` item should never be interior mutable
--> $DIR/enums.rs:23:1
|
LL | const UNFROZEN_VARIANT_FROM_FN: OptionalCell = unfrozen_variant(); //~ ERROR interior mutable
LL | const UNFROZEN_VARIANT_FROM_FN: OptionalCell = unfrozen_variant();
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| make this a static item (maybe with lazy_static)
@ -24,65 +24,66 @@ LL | const NESTED_UNFROZEN_VARIANT: NestedOutermost = NestedOutermost {
| |
| _make this a static item (maybe with lazy_static)
| |
LL | |
LL | | outer: NestedOuter::NestedInner(NestedInner {
LL | | inner: NestedInnermost::Unfrozen(AtomicUsize::new(2)),
LL | | }),
LL | | }; //~ ERROR interior mutable
LL | | };
| |__^
error: a `const` item should never be interior mutable
--> $DIR/enums.rs:59:5
|
LL | const TO_BE_UNFROZEN_VARIANT: OptionalCell; //~ ERROR interior mutable
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item should never be interior mutable
--> $DIR/enums.rs:60:5
|
LL | const TO_BE_FROZEN_VARIANT: OptionalCell; //~ ERROR interior mutable
LL | const TO_BE_UNFROZEN_VARIANT: OptionalCell;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item should never be interior mutable
--> $DIR/enums.rs:61:5
|
LL | const TO_BE_FROZEN_VARIANT: OptionalCell;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item should never be interior mutable
--> $DIR/enums.rs:63:5
--> $DIR/enums.rs:64:5
|
LL | const DEFAULTED_ON_UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(false)); //~ ERROR interior mutable
LL | const DEFAULTED_ON_UNFROZEN_VARIANT: OptionalCell = OptionalCell::Unfrozen(Cell::new(false));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item should never be interior mutable
--> $DIR/enums.rs:89:5
--> $DIR/enums.rs:90:5
|
LL | const TO_BE_UNFROZEN_VARIANT: Option<Self::ToBeUnfrozen> = Some(Self::ToBeUnfrozen::new(4)); //~ ERROR interior mutable
LL | const TO_BE_UNFROZEN_VARIANT: Option<Self::ToBeUnfrozen> = Some(Self::ToBeUnfrozen::new(4));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item should never be interior mutable
--> $DIR/enums.rs:101:5
--> $DIR/enums.rs:102:5
|
LL | const UNFROZEN_VARIANT: BothOfCellAndGeneric<T> = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); //~ ERROR interior mut...
LL | const UNFROZEN_VARIANT: BothOfCellAndGeneric<T> = BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null()));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item should never be interior mutable
--> $DIR/enums.rs:104:5
--> $DIR/enums.rs:105:5
|
LL | const GENERIC_VARIANT: BothOfCellAndGeneric<T> = BothOfCellAndGeneric::Generic(std::ptr::null()); //~ ERROR interior mutable
LL | const GENERIC_VARIANT: BothOfCellAndGeneric<T> = BothOfCellAndGeneric::Generic(std::ptr::null());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item should never be interior mutable
--> $DIR/enums.rs:110:5
--> $DIR/enums.rs:111:5
|
LL | const NO_ENUM: Cell<*const T> = Cell::new(std::ptr::null()); //~ ERROR interior mutable
LL | const NO_ENUM: Cell<*const T> = Cell::new(std::ptr::null());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item should never be interior mutable
--> $DIR/enums.rs:117:5
--> $DIR/enums.rs:118:5
|
LL | / const UNFROZEN_VARIANT: BothOfCellAndGeneric<Self::AssocType> =
LL | | BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null())); //~ ERROR interior mutable
LL | | BothOfCellAndGeneric::Unfrozen(Cell::new(std::ptr::null()));
| |____________________________________________________________________^
error: a `const` item should never be interior mutable
--> $DIR/enums.rs:119:5
--> $DIR/enums.rs:120:5
|
LL | const GENERIC_VARIANT: BothOfCellAndGeneric<Self::AssocType> = BothOfCellAndGeneric::Generic(std::ptr::null()); //~ ERROR interior mu...
LL | const GENERIC_VARIANT: BothOfCellAndGeneric<Self::AssocType> = BothOfCellAndGeneric::Generic(std::ptr::null());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 12 previous errors

View file

@ -6,17 +6,17 @@ use std::fmt::Display;
use std::sync::atomic::AtomicUsize;
use std::sync::Once;
const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable
const CELL: Cell<usize> = Cell::new(6); //~ ERROR interior mutable
const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR: interior mutable
const CELL: Cell<usize> = Cell::new(6); //~ ERROR: interior mutable
const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec<AtomicUsize>, u8) = ([ATOMIC], Vec::new(), 7);
//~^ ERROR interior mutable
//~^ ERROR: interior mutable
macro_rules! declare_const {
($name:ident: $ty:ty = $e:expr) => {
const $name: $ty = $e;
};
}
declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable
declare_const!(_ONCE: Once = Once::new()); //~ ERROR: interior mutable
// const ATOMIC_REF: &AtomicUsize = &AtomicUsize::new(7); // This will simply trigger E0492.
@ -24,12 +24,12 @@ const INTEGER: u8 = 8;
const STRING: String = String::new();
const STR: &str = "012345";
const COW: Cow<str> = Cow::Borrowed("abcdef");
//^ note: a const item of Cow is used in the `postgres` package.
// note: a const item of Cow is used in the `postgres` package.
const NO_ANN: &dyn Display = &70;
static STATIC_TUPLE: (AtomicUsize, String) = (ATOMIC, STRING);
//^ there should be no lints on this line
// there should be no lints on the line above line
mod issue_8493 {
use std::cell::Cell;
@ -40,7 +40,7 @@ mod issue_8493 {
macro_rules! issue_8493 {
() => {
const _BAZ: Cell<usize> = Cell::new(0); //~ ERROR interior mutable
const _BAZ: Cell<usize> = Cell::new(0);
static _FOOBAR: () = {
thread_local! {
static _VAR: Cell<i32> = const { Cell::new(0) };
@ -49,7 +49,7 @@ mod issue_8493 {
};
}
issue_8493!();
issue_8493!(); //~ ERROR: interior mutable
}
fn main() {}

View file

@ -1,7 +1,7 @@
error: a `const` item should never be interior mutable
--> $DIR/others.rs:9:1
|
LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable
LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5);
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| make this a static item (maybe with lazy_static)
@ -11,7 +11,7 @@ LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable
error: a `const` item should never be interior mutable
--> $DIR/others.rs:10:1
|
LL | const CELL: Cell<usize> = Cell::new(6); //~ ERROR interior mutable
LL | const CELL: Cell<usize> = Cell::new(6);
| -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| make this a static item (maybe with lazy_static)
@ -30,7 +30,7 @@ error: a `const` item should never be interior mutable
LL | const $name: $ty = $e;
| ^^^^^^^^^^^^^^^^^^^^^^
...
LL | declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable
LL | declare_const!(_ONCE: Once = Once::new());
| ----------------------------------------- in this macro invocation
|
= note: this error originates in the macro `declare_const` (in Nightly builds, run with -Z macro-backtrace for more info)
@ -38,7 +38,7 @@ LL | declare_const!(_ONCE: Once = Once::new()); //~ ERROR interior mutable
error: a `const` item should never be interior mutable
--> $DIR/others.rs:43:13
|
LL | const _BAZ: Cell<usize> = Cell::new(0); //~ ERROR interior mutable
LL | const _BAZ: Cell<usize> = Cell::new(0);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
LL | issue_8493!();

View file

@ -12,10 +12,10 @@ macro_rules! declare_const {
// a constant whose type is a concrete type should be linted at the definition site.
trait ConcreteTypes {
const ATOMIC: AtomicUsize; //~ ERROR interior mutable
const ATOMIC: AtomicUsize; //~ ERROR: interior mutable
const INTEGER: u64;
const STRING: String;
declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC); //~ ERROR interior mutable
declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC); //~ ERROR: interior mutable
}
impl ConcreteTypes for u64 {
@ -40,7 +40,7 @@ trait GenericTypes<T, U> {
impl<T: ConstDefault> GenericTypes<T, AtomicUsize> for u64 {
const TO_REMAIN_GENERIC: T = T::DEFAULT;
const TO_BE_CONCRETE: AtomicUsize = AtomicUsize::new(11); //~ ERROR interior mutable
const TO_BE_CONCRETE: AtomicUsize = AtomicUsize::new(11); //~ ERROR: interior mutable
}
// a helper type used below
@ -65,8 +65,8 @@ impl<T: ConstDefault> AssocTypes for Vec<T> {
type ToBeGenericParam = T;
const TO_BE_FROZEN: Self::ToBeFrozen = 12;
const TO_BE_UNFROZEN: Self::ToBeUnfrozen = AtomicUsize::new(13); //~ ERROR interior mutable
const WRAPPED_TO_BE_UNFROZEN: Wrapper<Self::ToBeUnfrozen> = Wrapper(AtomicUsize::new(14)); //~ ERROR interior mutable
const TO_BE_UNFROZEN: Self::ToBeUnfrozen = AtomicUsize::new(13); //~ ERROR: interior mutable
const WRAPPED_TO_BE_UNFROZEN: Wrapper<Self::ToBeUnfrozen> = Wrapper(AtomicUsize::new(14)); //~ ERROR: interior mutable
const WRAPPED_TO_BE_GENERIC_PARAM: Wrapper<Self::ToBeGenericParam> = Wrapper(T::DEFAULT);
}
@ -85,7 +85,7 @@ where
T: AssocTypesHelper<ToBeBounded = AtomicUsize>,
{
const NOT_BOUNDED: T::NotToBeBounded;
const BOUNDED: T::ToBeBounded; //~ ERROR interior mutable
const BOUNDED: T::ToBeBounded; //~ ERROR: interior mutable
}
impl<T> AssocTypesFromGenericParam<T> for u64
@ -113,8 +113,8 @@ impl SelfType for u64 {
impl SelfType for AtomicUsize {
// this (interior mutable `Self` const) exists in `parking_lot`.
// `const_trait_impl` will replace it in the future, hopefully.
const SELF: Self = AtomicUsize::new(17); //~ ERROR interior mutable
const WRAPPED_SELF: Option<Self> = Some(AtomicUsize::new(21)); //~ ERROR interior mutable
const SELF: Self = AtomicUsize::new(17); //~ ERROR: interior mutable
const WRAPPED_SELF: Option<Self> = Some(AtomicUsize::new(21)); //~ ERROR: interior mutable
}
// Even though a constant contains a generic type, if it also have an interior mutable type,
@ -122,7 +122,7 @@ impl SelfType for AtomicUsize {
trait BothOfCellAndGeneric<T> {
// this is a false negative in the current implementation.
const DIRECT: Cell<T>;
const INDIRECT: Cell<*const T>; //~ ERROR interior mutable
const INDIRECT: Cell<*const T>; //~ ERROR: interior mutable
}
impl<T: ConstDefault> BothOfCellAndGeneric<T> for u64 {
@ -138,13 +138,13 @@ impl<T> Local<T>
where
T: ConstDefault + AssocTypesHelper<ToBeBounded = AtomicUsize>,
{
const ATOMIC: AtomicUsize = AtomicUsize::new(18); //~ ERROR interior mutable
const ATOMIC: AtomicUsize = AtomicUsize::new(18); //~ ERROR: interior mutable
const COW: Cow<'static, str> = Cow::Borrowed("tuvwxy");
const GENERIC_TYPE: T = T::DEFAULT;
const ASSOC_TYPE: T::NotToBeBounded = T::NOT_TO_BE_BOUNDED;
const BOUNDED_ASSOC_TYPE: T::ToBeBounded = AtomicUsize::new(19); //~ ERROR interior mutable
const BOUNDED_ASSOC_TYPE: T::ToBeBounded = AtomicUsize::new(19); //~ ERROR: interior mutable
}
fn main() {}

View file

@ -1,7 +1,7 @@
error: a `const` item should never be interior mutable
--> $DIR/traits.rs:15:5
|
LL | const ATOMIC: AtomicUsize; //~ ERROR interior mutable
LL | const ATOMIC: AtomicUsize;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::declare-interior-mutable-const` implied by `-D warnings`
@ -12,7 +12,7 @@ error: a `const` item should never be interior mutable
LL | const $name: $ty = $e;
| ^^^^^^^^^^^^^^^^^^^^^^
...
LL | declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC); //~ ERROR interior mutable
LL | declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC);
| ---------------------------------------------------------- in this macro invocation
|
= note: this error originates in the macro `declare_const` (in Nightly builds, run with -Z macro-backtrace for more info)
@ -20,55 +20,55 @@ LL | declare_const!(ANOTHER_ATOMIC: AtomicUsize = Self::ATOMIC); //~ ERROR i
error: a `const` item should never be interior mutable
--> $DIR/traits.rs:43:5
|
LL | const TO_BE_CONCRETE: AtomicUsize = AtomicUsize::new(11); //~ ERROR interior mutable
LL | const TO_BE_CONCRETE: AtomicUsize = AtomicUsize::new(11);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item should never be interior mutable
--> $DIR/traits.rs:68:5
|
LL | const TO_BE_UNFROZEN: Self::ToBeUnfrozen = AtomicUsize::new(13); //~ ERROR interior mutable
LL | const TO_BE_UNFROZEN: Self::ToBeUnfrozen = AtomicUsize::new(13);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item should never be interior mutable
--> $DIR/traits.rs:69:5
|
LL | const WRAPPED_TO_BE_UNFROZEN: Wrapper<Self::ToBeUnfrozen> = Wrapper(AtomicUsize::new(14)); //~ ERROR interior mutable
LL | const WRAPPED_TO_BE_UNFROZEN: Wrapper<Self::ToBeUnfrozen> = Wrapper(AtomicUsize::new(14));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item should never be interior mutable
--> $DIR/traits.rs:88:5
|
LL | const BOUNDED: T::ToBeBounded; //~ ERROR interior mutable
LL | const BOUNDED: T::ToBeBounded;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item should never be interior mutable
--> $DIR/traits.rs:116:5
|
LL | const SELF: Self = AtomicUsize::new(17); //~ ERROR interior mutable
LL | const SELF: Self = AtomicUsize::new(17);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item should never be interior mutable
--> $DIR/traits.rs:117:5
|
LL | const WRAPPED_SELF: Option<Self> = Some(AtomicUsize::new(21)); //~ ERROR interior mutable
LL | const WRAPPED_SELF: Option<Self> = Some(AtomicUsize::new(21));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item should never be interior mutable
--> $DIR/traits.rs:125:5
|
LL | const INDIRECT: Cell<*const T>; //~ ERROR interior mutable
LL | const INDIRECT: Cell<*const T>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item should never be interior mutable
--> $DIR/traits.rs:141:5
|
LL | const ATOMIC: AtomicUsize = AtomicUsize::new(18); //~ ERROR interior mutable
LL | const ATOMIC: AtomicUsize = AtomicUsize::new(18);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: a `const` item should never be interior mutable
--> $DIR/traits.rs:147:5
|
LL | const BOUNDED_ASSOC_TYPE: T::ToBeBounded = AtomicUsize::new(19); //~ ERROR interior mutable
LL | const BOUNDED_ASSOC_TYPE: T::ToBeBounded = AtomicUsize::new(19);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to 11 previous errors

View file

@ -1,4 +1,4 @@
//@ignore-macos
//@ignore-target-apple
#![feature(no_core, lang_items, start)]
#![no_core]

View file

@ -1,5 +1,5 @@
//@run-rustfix
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![warn(clippy::default_numeric_fallback)]
#![allow(

View file

@ -1,5 +1,5 @@
//@run-rustfix
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![warn(clippy::default_numeric_fallback)]
#![allow(

View file

@ -1,5 +1,5 @@
//@run-rustfix
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![feature(lint_reasons)]
#![warn(clippy::default_numeric_fallback)]

View file

@ -1,5 +1,5 @@
//@run-rustfix
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![feature(lint_reasons)]
#![warn(clippy::default_numeric_fallback)]

View file

@ -1,5 +1,5 @@
//@run-rustfix
//@aux-build: proc_macros.rs
//@aux-build: proc_macros.rs:proc-macro
#![deny(clippy::default_trait_access)]
#![allow(dead_code, unused_imports)]
#![allow(clippy::uninlined_format_args)]

View file

@ -1,5 +1,5 @@
//@run-rustfix
//@aux-build: proc_macros.rs
//@aux-build: proc_macros.rs:proc-macro
#![deny(clippy::default_trait_access)]
#![allow(dead_code, unused_imports)]
#![allow(clippy::uninlined_format_args)]

View file

@ -1,5 +1,5 @@
//@run-rustfix
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![allow(clippy::return_self_not_must_use, clippy::useless_vec)]
#![warn(clippy::deref_addrof)]

View file

@ -1,5 +1,5 @@
//@run-rustfix
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![allow(clippy::return_self_not_must_use, clippy::useless_vec)]
#![warn(clippy::deref_addrof)]

View file

@ -1,4 +1,4 @@
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![warn(clippy::deref_addrof)]

View file

@ -1,4 +1,4 @@
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![allow(clippy::let_unit_value)]

View file

@ -43,7 +43,7 @@ fn main() {
if bla1() {
println!("if");
} else if bla2() {
//~ ERROR else if without else
//~^ ERROR: `if` expression with an `else if`, but without a final `else`
println!("else if");
}
@ -52,7 +52,7 @@ fn main() {
} else if bla2() {
println!("else if 1");
} else if bla3() {
//~ ERROR else if without else
//~^ ERROR: `if` expression with an `else if`, but without a final `else`
println!("else if 2");
}
}

View file

@ -3,7 +3,7 @@ error: `if` expression with an `else if`, but without a final `else`
|
LL | } else if bla2() {
| ____________^
LL | | //~ ERROR else if without else
LL | |
LL | | println!("else if");
LL | | }
| |_____^
@ -16,7 +16,7 @@ error: `if` expression with an `else if`, but without a final `else`
|
LL | } else if bla3() {
| ____________^
LL | | //~ ERROR else if without else
LL | |
LL | | println!("else if 2");
LL | | }
| |_____^

View file

@ -1,4 +1,4 @@
//@aux-build:proc_macro_attr.rs
//@aux-build:proc_macro_attr.rs:proc-macro
#![warn(clippy::empty_line_after_doc_comments)]
#![allow(clippy::assertions_on_constants)]
#![feature(custom_inner_attributes)]

View file

@ -1,4 +1,4 @@
//@aux-build:proc_macro_attr.rs
//@aux-build:proc_macro_attr.rs:proc-macro
#![warn(clippy::empty_line_after_outer_attr)]
#![allow(clippy::assertions_on_constants)]
#![feature(custom_inner_attributes)]

View file

@ -1,4 +1,4 @@
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![warn(clippy::empty_loop)]

View file

@ -1,5 +1,5 @@
//@compile-flags: -Clink-arg=-nostartfiles
//@ignore-macos
//@ignore-target-apple
#![warn(clippy::empty_loop)]
#![feature(lang_items, start, libc)]

View file

@ -1,4 +1,4 @@
//@ignore-x86
//@ignore-target-x86
#![warn(clippy::enum_clike_unportable_variant)]
#![allow(unused, non_upper_case_globals)]

View file

@ -44,7 +44,7 @@ fn main() {
// Don't warn on CRLF (#4208)
eprint!("\r\n");
eprint!("foo\r\n");
eprint!("\\r\n"); //~ ERROR
eprint!("\\r\n");
eprint!("foo\rbar\n");
// Ignore expanded format strings

View file

@ -62,13 +62,13 @@ LL + eprintln!();
error: using `eprint!()` with a format string that ends in a single newline
--> $DIR/eprint_with_newline.rs:28:5
|
LL | eprint!("//n"); // should fail
LL | eprint!("///n"); // should fail
| ^^^^^^^^^^^^^^^
|
help: use `eprintln!` instead
|
LL - eprint!("//n"); // should fail
LL + eprintln!("/"); // should fail
LL - eprint!("///n"); // should fail
LL + eprintln!("//"); // should fail
|
error: using `eprint!()` with a format string that ends in a single newline
@ -104,13 +104,13 @@ LL ~
error: using `eprint!()` with a format string that ends in a single newline
--> $DIR/eprint_with_newline.rs:47:5
|
LL | eprint!("/r/n"); //~ ERROR
LL | eprint!("//r/n");
| ^^^^^^^^^^^^^^^^
|
help: use `eprintln!` instead
|
LL - eprint!("/r/n"); //~ ERROR
LL + eprintln!("/r"); //~ ERROR
LL - eprint!("//r/n");
LL + eprintln!("//r");
|
error: aborting due to 9 previous errors

View file

@ -1,5 +1,3 @@
//@compile-flags: --test
#![warn(clippy::eq_op)]
#![allow(clippy::double_parens, clippy::identity_op, clippy::nonminimal_bool)]
#![allow(clippy::suspicious_xor_used_as_pow)]

View file

@ -1,5 +1,5 @@
error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:9:13
--> $DIR/eq_op.rs:7:13
|
LL | let _ = 1 == 1;
| ^^^^^^
@ -7,163 +7,163 @@ LL | let _ = 1 == 1;
= note: `-D clippy::eq-op` implied by `-D warnings`
error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:10:13
--> $DIR/eq_op.rs:8:13
|
LL | let _ = "no" == "no";
| ^^^^^^^^^^^^
error: equal expressions as operands to `!=`
--> $DIR/eq_op.rs:12:13
--> $DIR/eq_op.rs:10:13
|
LL | let _ = false != false;
| ^^^^^^^^^^^^^^
error: equal expressions as operands to `<`
--> $DIR/eq_op.rs:13:13
--> $DIR/eq_op.rs:11:13
|
LL | let _ = 1.5 < 1.5;
| ^^^^^^^^^
error: equal expressions as operands to `>=`
--> $DIR/eq_op.rs:14:13
--> $DIR/eq_op.rs:12:13
|
LL | let _ = 1u64 >= 1u64;
| ^^^^^^^^^^^^
error: equal expressions as operands to `&`
--> $DIR/eq_op.rs:17:13
--> $DIR/eq_op.rs:15:13
|
LL | let _ = (1u32 as u64) & (1u32 as u64);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: equal expressions as operands to `^`
--> $DIR/eq_op.rs:20:17
--> $DIR/eq_op.rs:18:17
|
LL | let _ = 1 ^ ((((((1))))));
| ^^^^^^^^^^^^^^^^^
error: equal expressions as operands to `<`
--> $DIR/eq_op.rs:24:13
--> $DIR/eq_op.rs:22:13
|
LL | let _ = (-(2) < -(2));
| ^^^^^^^^^^^^^
error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:25:13
--> $DIR/eq_op.rs:23:13
|
LL | let _ = ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1));
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: equal expressions as operands to `&`
--> $DIR/eq_op.rs:25:14
--> $DIR/eq_op.rs:23:14
|
LL | let _ = ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1));
| ^^^^^^^^^^^^^^^^^
error: equal expressions as operands to `&`
--> $DIR/eq_op.rs:25:35
--> $DIR/eq_op.rs:23:35
|
LL | let _ = ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1));
| ^^^^^^^^^^^^^^^^^
error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:26:13
--> $DIR/eq_op.rs:24:13
|
LL | let _ = (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: equal expressions as operands to `!=`
--> $DIR/eq_op.rs:29:13
--> $DIR/eq_op.rs:27:13
|
LL | let _ = ([1] != [1]);
| ^^^^^^^^^^^^
error: equal expressions as operands to `!=`
--> $DIR/eq_op.rs:30:13
--> $DIR/eq_op.rs:28:13
|
LL | let _ = ((1, 2) != (1, 2));
| ^^^^^^^^^^^^^^^^^^
error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:34:13
--> $DIR/eq_op.rs:32:13
|
LL | let _ = 1 + 1 == 2;
| ^^^^^^^^^^
error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:35:13
--> $DIR/eq_op.rs:33:13
|
LL | let _ = 1 - 1 == 0;
| ^^^^^^^^^^
error: equal expressions as operands to `-`
--> $DIR/eq_op.rs:35:13
--> $DIR/eq_op.rs:33:13
|
LL | let _ = 1 - 1 == 0;
| ^^^^^
error: equal expressions as operands to `-`
--> $DIR/eq_op.rs:37:13
--> $DIR/eq_op.rs:35:13
|
LL | let _ = 1 - 1;
| ^^^^^
error: equal expressions as operands to `/`
--> $DIR/eq_op.rs:38:13
--> $DIR/eq_op.rs:36:13
|
LL | let _ = 1 / 1;
| ^^^^^
error: equal expressions as operands to `&&`
--> $DIR/eq_op.rs:39:13
--> $DIR/eq_op.rs:37:13
|
LL | let _ = true && true;
| ^^^^^^^^^^^^
error: equal expressions as operands to `||`
--> $DIR/eq_op.rs:41:13
--> $DIR/eq_op.rs:39:13
|
LL | let _ = true || true;
| ^^^^^^^^^^^^
error: equal expressions as operands to `&&`
--> $DIR/eq_op.rs:46:13
--> $DIR/eq_op.rs:44:13
|
LL | let _ = a == b && b == a;
| ^^^^^^^^^^^^^^^^
error: equal expressions as operands to `&&`
--> $DIR/eq_op.rs:47:13
--> $DIR/eq_op.rs:45:13
|
LL | let _ = a != b && b != a;
| ^^^^^^^^^^^^^^^^
error: equal expressions as operands to `&&`
--> $DIR/eq_op.rs:48:13
--> $DIR/eq_op.rs:46:13
|
LL | let _ = a < b && b > a;
| ^^^^^^^^^^^^^^
error: equal expressions as operands to `&&`
--> $DIR/eq_op.rs:49:13
--> $DIR/eq_op.rs:47:13
|
LL | let _ = a <= b && b >= a;
| ^^^^^^^^^^^^^^^^
error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:52:13
--> $DIR/eq_op.rs:50:13
|
LL | let _ = a == a;
| ^^^^^^
error: equal expressions as operands to `/`
--> $DIR/eq_op.rs:62:20
--> $DIR/eq_op.rs:60:20
|
LL | const D: u32 = A / A;
| ^^^^^
error: equal expressions as operands to `==`
--> $DIR/eq_op.rs:93:5
--> $DIR/eq_op.rs:91:5
|
LL | (n1.inner.0).0 == (n1.inner.0).0 && (n1.inner.1).0 == (n2.inner.1).0 && (n1.inner.2).0 == (n2.inner.2).0
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View file

@ -1,5 +1,5 @@
//@run-rustfix
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![allow(
unused_variables,

View file

@ -1,5 +1,5 @@
//@run-rustfix
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![allow(
unused_variables,

View file

@ -1,4 +1,4 @@
//@aux-build:proc_macro_derive.rs
//@aux-build:proc_macro_derive.rs:proc-macro
#![allow(
unused,

View file

@ -1,5 +1,5 @@
//@run-rustfix
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![allow(unused, clippy::needless_lifetimes)]
#![warn(clippy::extra_unused_type_parameters)]

View file

@ -1,5 +1,5 @@
//@run-rustfix
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![allow(unused, clippy::needless_lifetimes)]
#![warn(clippy::extra_unused_type_parameters)]

View file

@ -1,5 +1,5 @@
//@aux-build:proc_macro_derive.rs
//@aux-build:proc_macros.rs
//@aux-build:proc_macro_derive.rs:proc-macro
//@aux-build:proc_macros.rs:proc-macro
#![warn(clippy::field_reassign_with_default)]

View file

@ -76,14 +76,14 @@ mod issue9909 {
fn reduced() {
let f = &[1, 2, 3];
// include a borrow in the suggestion, even if the argument is not just a numeric literal
let _x: &i32 = &f[1 + 2];
// ^ include a borrow in the suggestion, even if the argument is not just a numeric literal
// don't include a borrow here
let _x = f[1 + 2].to_string();
// ^ don't include a borrow here
// don't include a borrow here
let _x = f[1 + 2].abs();
// ^ don't include a borrow here
}
// original code:

View file

@ -76,14 +76,14 @@ mod issue9909 {
fn reduced() {
let f = &[1, 2, 3];
// include a borrow in the suggestion, even if the argument is not just a numeric literal
let _x: &i32 = f.get(1 + 2).unwrap();
// ^ include a borrow in the suggestion, even if the argument is not just a numeric literal
// don't include a borrow here
let _x = f.get(1 + 2).unwrap().to_string();
// ^ don't include a borrow here
// don't include a borrow here
let _x = f.get(1 + 2).unwrap().abs();
// ^ don't include a borrow here
}
// original code:

View file

@ -188,19 +188,19 @@ LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec();
= help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
--> $DIR/get_unwrap.rs:79:24
--> $DIR/get_unwrap.rs:80:24
|
LL | let _x: &i32 = f.get(1 + 2).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^ help: try this: `&f[1 + 2]`
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
--> $DIR/get_unwrap.rs:82:18
--> $DIR/get_unwrap.rs:83:18
|
LL | let _x = f.get(1 + 2).unwrap().to_string();
| ^^^^^^^^^^^^^^^^^^^^^ help: try this: `f[1 + 2]`
error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise
--> $DIR/get_unwrap.rs:85:18
--> $DIR/get_unwrap.rs:86:18
|
LL | let _x = f.get(1 + 2).unwrap().abs();
| ^^^^^^^^^^^^^^^^^^^^^ help: try this: `f[1 + 2]`

View file

@ -21,6 +21,7 @@ fn foo() -> bool {
fn if_same_then_else() {
if true {
//~^ ERROR: this `if` has identical blocks
Foo { bar: 42 };
0..10;
..;
@ -29,7 +30,6 @@ fn if_same_then_else() {
0..=10;
foo();
} else {
//~ ERROR same body as `if` block
Foo { bar: 42 };
0..10;
..;
@ -65,16 +65,16 @@ fn if_same_then_else() {
}
let _ = if true {
//~^ ERROR: this `if` has identical blocks
0.0
} else {
//~ ERROR same body as `if` block
0.0
};
let _ = if true {
//~^ ERROR: this `if` has identical blocks
-0.0
} else {
//~ ERROR same body as `if` block
-0.0
};
@ -88,13 +88,14 @@ fn if_same_then_else() {
}
let _ = if true {
//~^ ERROR: this `if` has identical blocks
42
} else {
//~ ERROR same body as `if` block
42
};
if true {
//~^ ERROR: this `if` has identical blocks
let bar = if true { 42 } else { 43 };
while foo() {
@ -102,7 +103,6 @@ fn if_same_then_else() {
}
bar + 1;
} else {
//~ ERROR same body as `if` block
let bar = if true { 42 } else { 43 };
while foo() {

View file

@ -3,22 +3,22 @@ error: this `if` has identical blocks
|
LL | if true {
| _____________^
LL | |
LL | | Foo { bar: 42 };
LL | | 0..10;
LL | | ..;
... |
LL | | foo();
LL | | } else {
| |_____^
|
note: same as this
--> $DIR/if_same_then_else.rs:31:12
--> $DIR/if_same_then_else.rs:32:12
|
LL | } else {
| ____________^
LL | | //~ ERROR same body as `if` block
LL | | Foo { bar: 42 };
LL | | 0..10;
LL | | ..;
... |
LL | | foo();
LL | | }
@ -30,16 +30,16 @@ error: this `if` has identical blocks
|
LL | let _ = if true {
| _____________________^
LL | |
LL | | 0.0
LL | | } else {
| |_____^
|
note: same as this
--> $DIR/if_same_then_else.rs:69:12
--> $DIR/if_same_then_else.rs:70:12
|
LL | } else {
| ____________^
LL | | //~ ERROR same body as `if` block
LL | | 0.0
LL | | };
| |_____^
@ -49,16 +49,16 @@ error: this `if` has identical blocks
|
LL | let _ = if true {
| _____________________^
LL | |
LL | | -0.0
LL | | } else {
| |_____^
|
note: same as this
--> $DIR/if_same_then_else.rs:76:12
--> $DIR/if_same_then_else.rs:77:12
|
LL | } else {
| ____________^
LL | | //~ ERROR same body as `if` block
LL | | -0.0
LL | | };
| |_____^
@ -68,16 +68,16 @@ error: this `if` has identical blocks
|
LL | let _ = if true {
| _____________________^
LL | |
LL | | 42
LL | | } else {
| |_____^
|
note: same as this
--> $DIR/if_same_then_else.rs:92:12
--> $DIR/if_same_then_else.rs:93:12
|
LL | } else {
| ____________^
LL | | //~ ERROR same body as `if` block
LL | | 42
LL | | };
| |_____^
@ -87,22 +87,22 @@ error: this `if` has identical blocks
|
LL | if true {
| _____________^
LL | |
LL | | let bar = if true { 42 } else { 43 };
LL | |
LL | | while foo() {
... |
LL | | bar + 1;
LL | | } else {
| |_____^
|
note: same as this
--> $DIR/if_same_then_else.rs:104:12
--> $DIR/if_same_then_else.rs:105:12
|
LL | } else {
| ____________^
LL | | //~ ERROR same body as `if` block
LL | | let bar = if true { 42 } else { 43 };
LL | |
LL | | while foo() {
... |
LL | | bar + 1;
LL | | }

View file

@ -13,6 +13,7 @@
fn if_same_then_else2() -> Result<&'static str, ()> {
if true {
//~^ ERROR: this `if` has identical blocks
for _ in &[42] {
let foo: &Option<_> = &Some::<u8>(42);
if foo.is_some() {
@ -22,7 +23,6 @@ fn if_same_then_else2() -> Result<&'static str, ()> {
}
}
} else {
//~ ERROR same body as `if` block
for _ in &[42] {
let bar: &Option<_> = &Some::<u8>(42);
if bar.is_some() {
@ -34,16 +34,16 @@ fn if_same_then_else2() -> Result<&'static str, ()> {
}
if true {
//~^ ERROR: this `if` has identical blocks
if let Some(a) = Some(42) {}
} else {
//~ ERROR same body as `if` block
if let Some(a) = Some(42) {}
}
if true {
//~^ ERROR: this `if` has identical blocks
if let (1, .., 3) = (1, 2, 3) {}
} else {
//~ ERROR same body as `if` block
if let (1, .., 3) = (1, 2, 3) {}
}
@ -91,16 +91,16 @@ fn if_same_then_else2() -> Result<&'static str, ()> {
// Same NaNs
let _ = if true {
//~^ ERROR: this `if` has identical blocks
f32::NAN
} else {
//~ ERROR same body as `if` block
f32::NAN
};
if true {
//~^ ERROR: this `if` has identical blocks
Ok("foo")?;
} else {
//~ ERROR same body as `if` block
Ok("foo")?;
}
@ -122,6 +122,7 @@ fn if_same_then_else2() -> Result<&'static str, ()> {
let foo = "bar";
return Ok(&foo[0..]);
} else if true {
//~^ ERROR: this `if` has identical blocks
let foo = "";
return Ok(&foo[0..]);
} else {

View file

@ -3,22 +3,22 @@ error: this `if` has identical blocks
|
LL | if true {
| _____________^
LL | |
LL | | for _ in &[42] {
LL | | let foo: &Option<_> = &Some::<u8>(42);
LL | | if foo.is_some() {
... |
LL | | }
LL | | } else {
| |_____^
|
note: same as this
--> $DIR/if_same_then_else2.rs:24:12
--> $DIR/if_same_then_else2.rs:25:12
|
LL | } else {
| ____________^
LL | | //~ ERROR same body as `if` block
LL | | for _ in &[42] {
LL | | let bar: &Option<_> = &Some::<u8>(42);
LL | | if bar.is_some() {
... |
LL | | }
LL | | }
@ -30,16 +30,16 @@ error: this `if` has identical blocks
|
LL | if true {
| _____________^
LL | |
LL | | if let Some(a) = Some(42) {}
LL | | } else {
| |_____^
|
note: same as this
--> $DIR/if_same_then_else2.rs:38:12
--> $DIR/if_same_then_else2.rs:39:12
|
LL | } else {
| ____________^
LL | | //~ ERROR same body as `if` block
LL | | if let Some(a) = Some(42) {}
LL | | }
| |_____^
@ -49,16 +49,16 @@ error: this `if` has identical blocks
|
LL | if true {
| _____________^
LL | |
LL | | if let (1, .., 3) = (1, 2, 3) {}
LL | | } else {
| |_____^
|
note: same as this
--> $DIR/if_same_then_else2.rs:45:12
--> $DIR/if_same_then_else2.rs:46:12
|
LL | } else {
| ____________^
LL | | //~ ERROR same body as `if` block
LL | | if let (1, .., 3) = (1, 2, 3) {}
LL | | }
| |_____^
@ -68,16 +68,16 @@ error: this `if` has identical blocks
|
LL | let _ = if true {
| _____________________^
LL | |
LL | | f32::NAN
LL | | } else {
| |_____^
|
note: same as this
--> $DIR/if_same_then_else2.rs:95:12
--> $DIR/if_same_then_else2.rs:96:12
|
LL | } else {
| ____________^
LL | | //~ ERROR same body as `if` block
LL | | f32::NAN
LL | | };
| |_____^
@ -87,16 +87,16 @@ error: this `if` has identical blocks
|
LL | if true {
| _____________^
LL | |
LL | | Ok("foo")?;
LL | | } else {
| |_____^
|
note: same as this
--> $DIR/if_same_then_else2.rs:102:12
--> $DIR/if_same_then_else2.rs:103:12
|
LL | } else {
| ____________^
LL | | //~ ERROR same body as `if` block
LL | | Ok("foo")?;
LL | | }
| |_____^
@ -106,13 +106,14 @@ error: this `if` has identical blocks
|
LL | } else if true {
| ____________________^
LL | |
LL | | let foo = "";
LL | | return Ok(&foo[0..]);
LL | | } else {
| |_____^
|
note: same as this
--> $DIR/if_same_then_else2.rs:127:12
--> $DIR/if_same_then_else2.rs:128:12
|
LL | } else {
| ____________^

View file

@ -12,18 +12,18 @@ fn ifs_same_cond() {
if b {
} else if b {
//~ ERROR ifs same condition
//~^ ERROR: this `if` has the same condition as a previous `if`
}
if a == 1 {
} else if a == 1 {
//~ ERROR ifs same condition
//~^ ERROR: this `if` has the same condition as a previous `if`
}
if 2 * a == 1 {
} else if 2 * a == 2 {
} else if 2 * a == 1 {
//~ ERROR ifs same condition
//~^ ERROR: this `if` has the same condition as a previous `if`
} else if a == 1 {
}
@ -52,6 +52,7 @@ fn issue10272() {
let a = String::from("ha");
if a.contains("ah") {
} else if a.contains("ah") {
//~^ ERROR: this `if` has the same condition as a previous `if`
// Trigger this lint
} else if a.contains("ha") {
} else if a == "wow" {

View file

@ -1,4 +1,4 @@
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![deny(clippy::implicit_hasher)]
#![allow(unused)]

View file

@ -1,5 +1,5 @@
//@run-rustfix
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![warn(clippy::inconsistent_struct_constructor)]
#![allow(clippy::redundant_field_names)]

View file

@ -1,5 +1,5 @@
//@run-rustfix
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![warn(clippy::inconsistent_struct_constructor)]
#![allow(clippy::redundant_field_names)]

View file

@ -11,35 +11,35 @@ fn main() {
for _ in &vec![X, X] {}
let _ = vec![1, 2, 3].into_iter();
let _ = (&vec![1, 2, 3]).iter(); //~ WARN equivalent to .iter()
let _ = vec![1, 2, 3].into_boxed_slice().iter(); //~ WARN equivalent to .iter()
let _ = std::rc::Rc::from(&[X][..]).iter(); //~ WARN equivalent to .iter()
let _ = std::sync::Arc::from(&[X][..]).iter(); //~ WARN equivalent to .iter()
let _ = (&vec![1, 2, 3]).iter(); //~ ERROR: equivalent to `.iter()
let _ = vec![1, 2, 3].into_boxed_slice().iter(); //~ ERROR: equivalent to `.iter()
let _ = std::rc::Rc::from(&[X][..]).iter(); //~ ERROR: equivalent to `.iter()
let _ = std::sync::Arc::from(&[X][..]).iter(); //~ ERROR: equivalent to `.iter()
let _ = (&&&&&&&[1, 2, 3]).iter(); //~ ERROR equivalent to .iter()
let _ = (&&&&mut &&&[1, 2, 3]).iter(); //~ ERROR equivalent to .iter()
let _ = (&mut &mut &mut [1, 2, 3]).iter_mut(); //~ ERROR equivalent to .iter_mut()
let _ = (&&&&&&&[1, 2, 3]).iter(); //~ ERROR: equivalent to `.iter()
let _ = (&&&&mut &&&[1, 2, 3]).iter(); //~ ERROR: equivalent to `.iter()
let _ = (&mut &mut &mut [1, 2, 3]).iter_mut(); //~ ERROR: equivalent to `.iter_mut()
let _ = (&Some(4)).iter(); //~ WARN equivalent to .iter()
let _ = (&mut Some(5)).iter_mut(); //~ WARN equivalent to .iter_mut()
let _ = (&Ok::<_, i32>(6)).iter(); //~ WARN equivalent to .iter()
let _ = (&mut Err::<i32, _>(7)).iter_mut(); //~ WARN equivalent to .iter_mut()
let _ = (&Vec::<i32>::new()).iter(); //~ WARN equivalent to .iter()
let _ = (&mut Vec::<i32>::new()).iter_mut(); //~ WARN equivalent to .iter_mut()
let _ = (&BTreeMap::<i32, u64>::new()).iter(); //~ WARN equivalent to .iter()
let _ = (&mut BTreeMap::<i32, u64>::new()).iter_mut(); //~ WARN equivalent to .iter_mut()
let _ = (&VecDeque::<i32>::new()).iter(); //~ WARN equivalent to .iter()
let _ = (&mut VecDeque::<i32>::new()).iter_mut(); //~ WARN equivalent to .iter_mut()
let _ = (&LinkedList::<i32>::new()).iter(); //~ WARN equivalent to .iter()
let _ = (&mut LinkedList::<i32>::new()).iter_mut(); //~ WARN equivalent to .iter_mut()
let _ = (&HashMap::<i32, u64>::new()).iter(); //~ WARN equivalent to .iter()
let _ = (&mut HashMap::<i32, u64>::new()).iter_mut(); //~ WARN equivalent to .iter_mut()
let _ = (&Some(4)).iter(); //~ ERROR: equivalent to `.iter()
let _ = (&mut Some(5)).iter_mut(); //~ ERROR: equivalent to `.iter_mut()
let _ = (&Ok::<_, i32>(6)).iter(); //~ ERROR: equivalent to `.iter()
let _ = (&mut Err::<i32, _>(7)).iter_mut(); //~ ERROR: equivalent to `.iter_mut()
let _ = (&Vec::<i32>::new()).iter(); //~ ERROR: equivalent to `.iter()
let _ = (&mut Vec::<i32>::new()).iter_mut(); //~ ERROR: equivalent to `.iter_mut()
let _ = (&BTreeMap::<i32, u64>::new()).iter(); //~ ERROR: equivalent to `.iter()
let _ = (&mut BTreeMap::<i32, u64>::new()).iter_mut(); //~ ERROR: equivalent to `.iter_mut()
let _ = (&VecDeque::<i32>::new()).iter(); //~ ERROR: equivalent to `.iter()
let _ = (&mut VecDeque::<i32>::new()).iter_mut(); //~ ERROR: equivalent to `.iter_mut()
let _ = (&LinkedList::<i32>::new()).iter(); //~ ERROR: equivalent to `.iter()
let _ = (&mut LinkedList::<i32>::new()).iter_mut(); //~ ERROR: equivalent to `.iter_mut()
let _ = (&HashMap::<i32, u64>::new()).iter(); //~ ERROR: equivalent to `.iter()
let _ = (&mut HashMap::<i32, u64>::new()).iter_mut(); //~ ERROR: equivalent to `.iter_mut()
let _ = (&BTreeSet::<i32>::new()).iter(); //~ WARN equivalent to .iter()
let _ = (&BinaryHeap::<i32>::new()).iter(); //~ WARN equivalent to .iter()
let _ = (&HashSet::<i32>::new()).iter(); //~ WARN equivalent to .iter()
let _ = std::path::Path::new("12/34").iter(); //~ WARN equivalent to .iter()
let _ = std::path::PathBuf::from("12/34").iter(); //~ ERROR equivalent to .iter()
let _ = (&BTreeSet::<i32>::new()).iter(); //~ ERROR: equivalent to `.iter()
let _ = (&BinaryHeap::<i32>::new()).iter(); //~ ERROR: equivalent to `.iter()
let _ = (&HashSet::<i32>::new()).iter(); //~ ERROR: equivalent to `.iter()
let _ = std::path::Path::new("12/34").iter(); //~ ERROR: equivalent to `.iter()
let _ = std::path::PathBuf::from("12/34").iter(); //~ ERROR: equivalent to `.iter()
let _ = (&[1, 2, 3]).iter().next(); //~ WARN equivalent to .iter()
let _ = (&[1, 2, 3]).iter().next(); //~ ERROR: equivalent to `.iter()
}

View file

@ -11,35 +11,35 @@ fn main() {
for _ in &vec![X, X] {}
let _ = vec![1, 2, 3].into_iter();
let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter()
let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter()
let _ = std::rc::Rc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter()
let _ = std::sync::Arc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter()
let _ = (&vec![1, 2, 3]).into_iter(); //~ ERROR: equivalent to `.iter()
let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ ERROR: equivalent to `.iter()
let _ = std::rc::Rc::from(&[X][..]).into_iter(); //~ ERROR: equivalent to `.iter()
let _ = std::sync::Arc::from(&[X][..]).into_iter(); //~ ERROR: equivalent to `.iter()
let _ = (&&&&&&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter()
let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter()
let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter_mut()
let _ = (&&&&&&&[1, 2, 3]).into_iter(); //~ ERROR: equivalent to `.iter()
let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); //~ ERROR: equivalent to `.iter()
let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); //~ ERROR: equivalent to `.iter_mut()
let _ = (&Some(4)).into_iter(); //~ WARN equivalent to .iter()
let _ = (&mut Some(5)).into_iter(); //~ WARN equivalent to .iter_mut()
let _ = (&Ok::<_, i32>(6)).into_iter(); //~ WARN equivalent to .iter()
let _ = (&mut Err::<i32, _>(7)).into_iter(); //~ WARN equivalent to .iter_mut()
let _ = (&Vec::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
let _ = (&mut Vec::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
let _ = (&BTreeMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter()
let _ = (&mut BTreeMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
let _ = (&VecDeque::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
let _ = (&mut VecDeque::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
let _ = (&LinkedList::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
let _ = (&mut LinkedList::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
let _ = (&HashMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter()
let _ = (&mut HashMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
let _ = (&Some(4)).into_iter(); //~ ERROR: equivalent to `.iter()
let _ = (&mut Some(5)).into_iter(); //~ ERROR: equivalent to `.iter_mut()
let _ = (&Ok::<_, i32>(6)).into_iter(); //~ ERROR: equivalent to `.iter()
let _ = (&mut Err::<i32, _>(7)).into_iter(); //~ ERROR: equivalent to `.iter_mut()
let _ = (&Vec::<i32>::new()).into_iter(); //~ ERROR: equivalent to `.iter()
let _ = (&mut Vec::<i32>::new()).into_iter(); //~ ERROR: equivalent to `.iter_mut()
let _ = (&BTreeMap::<i32, u64>::new()).into_iter(); //~ ERROR: equivalent to `.iter()
let _ = (&mut BTreeMap::<i32, u64>::new()).into_iter(); //~ ERROR: equivalent to `.iter_mut()
let _ = (&VecDeque::<i32>::new()).into_iter(); //~ ERROR: equivalent to `.iter()
let _ = (&mut VecDeque::<i32>::new()).into_iter(); //~ ERROR: equivalent to `.iter_mut()
let _ = (&LinkedList::<i32>::new()).into_iter(); //~ ERROR: equivalent to `.iter()
let _ = (&mut LinkedList::<i32>::new()).into_iter(); //~ ERROR: equivalent to `.iter_mut()
let _ = (&HashMap::<i32, u64>::new()).into_iter(); //~ ERROR: equivalent to `.iter()
let _ = (&mut HashMap::<i32, u64>::new()).into_iter(); //~ ERROR: equivalent to `.iter_mut()
let _ = (&BTreeSet::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
let _ = (&BinaryHeap::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
let _ = (&HashSet::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
let _ = std::path::Path::new("12/34").into_iter(); //~ WARN equivalent to .iter()
let _ = std::path::PathBuf::from("12/34").into_iter(); //~ ERROR equivalent to .iter()
let _ = (&BTreeSet::<i32>::new()).into_iter(); //~ ERROR: equivalent to `.iter()
let _ = (&BinaryHeap::<i32>::new()).into_iter(); //~ ERROR: equivalent to `.iter()
let _ = (&HashSet::<i32>::new()).into_iter(); //~ ERROR: equivalent to `.iter()
let _ = std::path::Path::new("12/34").into_iter(); //~ ERROR: equivalent to `.iter()
let _ = std::path::PathBuf::from("12/34").into_iter(); //~ ERROR: equivalent to `.iter()
let _ = (&[1, 2, 3]).into_iter().next(); //~ WARN equivalent to .iter()
let _ = (&[1, 2, 3]).into_iter().next(); //~ ERROR: equivalent to `.iter()
}

View file

@ -1,7 +1,7 @@
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Vec`
--> $DIR/into_iter_on_ref.rs:14:30
|
LL | let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter()
LL | let _ = (&vec![1, 2, 3]).into_iter();
| ^^^^^^^^^ help: call directly: `iter`
|
= note: `-D clippy::into-iter-on-ref` implied by `-D warnings`
@ -9,157 +9,157 @@ LL | let _ = (&vec![1, 2, 3]).into_iter(); //~ WARN equivalent to .iter()
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice`
--> $DIR/into_iter_on_ref.rs:15:46
|
LL | let _ = vec![1, 2, 3].into_boxed_slice().into_iter(); //~ WARN equivalent to .iter()
LL | let _ = vec![1, 2, 3].into_boxed_slice().into_iter();
| ^^^^^^^^^ help: call directly: `iter`
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice`
--> $DIR/into_iter_on_ref.rs:16:41
|
LL | let _ = std::rc::Rc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter()
LL | let _ = std::rc::Rc::from(&[X][..]).into_iter();
| ^^^^^^^^^ help: call directly: `iter`
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `slice`
--> $DIR/into_iter_on_ref.rs:17:44
|
LL | let _ = std::sync::Arc::from(&[X][..]).into_iter(); //~ WARN equivalent to .iter()
LL | let _ = std::sync::Arc::from(&[X][..]).into_iter();
| ^^^^^^^^^ help: call directly: `iter`
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `array`
--> $DIR/into_iter_on_ref.rs:19:32
|
LL | let _ = (&&&&&&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter()
LL | let _ = (&&&&&&&[1, 2, 3]).into_iter();
| ^^^^^^^^^ help: call directly: `iter`
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `array`
--> $DIR/into_iter_on_ref.rs:20:36
|
LL | let _ = (&&&&mut &&&[1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter()
LL | let _ = (&&&&mut &&&[1, 2, 3]).into_iter();
| ^^^^^^^^^ help: call directly: `iter`
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `array`
--> $DIR/into_iter_on_ref.rs:21:40
|
LL | let _ = (&mut &mut &mut [1, 2, 3]).into_iter(); //~ ERROR equivalent to .iter_mut()
LL | let _ = (&mut &mut &mut [1, 2, 3]).into_iter();
| ^^^^^^^^^ help: call directly: `iter_mut`
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Option`
--> $DIR/into_iter_on_ref.rs:23:24
|
LL | let _ = (&Some(4)).into_iter(); //~ WARN equivalent to .iter()
LL | let _ = (&Some(4)).into_iter();
| ^^^^^^^^^ help: call directly: `iter`
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `Option`
--> $DIR/into_iter_on_ref.rs:24:28
|
LL | let _ = (&mut Some(5)).into_iter(); //~ WARN equivalent to .iter_mut()
LL | let _ = (&mut Some(5)).into_iter();
| ^^^^^^^^^ help: call directly: `iter_mut`
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Result`
--> $DIR/into_iter_on_ref.rs:25:32
|
LL | let _ = (&Ok::<_, i32>(6)).into_iter(); //~ WARN equivalent to .iter()
LL | let _ = (&Ok::<_, i32>(6)).into_iter();
| ^^^^^^^^^ help: call directly: `iter`
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `Result`
--> $DIR/into_iter_on_ref.rs:26:37
|
LL | let _ = (&mut Err::<i32, _>(7)).into_iter(); //~ WARN equivalent to .iter_mut()
LL | let _ = (&mut Err::<i32, _>(7)).into_iter();
| ^^^^^^^^^ help: call directly: `iter_mut`
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Vec`
--> $DIR/into_iter_on_ref.rs:27:34
|
LL | let _ = (&Vec::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
LL | let _ = (&Vec::<i32>::new()).into_iter();
| ^^^^^^^^^ help: call directly: `iter`
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `Vec`
--> $DIR/into_iter_on_ref.rs:28:38
|
LL | let _ = (&mut Vec::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
LL | let _ = (&mut Vec::<i32>::new()).into_iter();
| ^^^^^^^^^ help: call directly: `iter_mut`
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `BTreeMap`
--> $DIR/into_iter_on_ref.rs:29:44
|
LL | let _ = (&BTreeMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter()
LL | let _ = (&BTreeMap::<i32, u64>::new()).into_iter();
| ^^^^^^^^^ help: call directly: `iter`
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `BTreeMap`
--> $DIR/into_iter_on_ref.rs:30:48
|
LL | let _ = (&mut BTreeMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
LL | let _ = (&mut BTreeMap::<i32, u64>::new()).into_iter();
| ^^^^^^^^^ help: call directly: `iter_mut`
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `VecDeque`
--> $DIR/into_iter_on_ref.rs:31:39
|
LL | let _ = (&VecDeque::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
LL | let _ = (&VecDeque::<i32>::new()).into_iter();
| ^^^^^^^^^ help: call directly: `iter`
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `VecDeque`
--> $DIR/into_iter_on_ref.rs:32:43
|
LL | let _ = (&mut VecDeque::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
LL | let _ = (&mut VecDeque::<i32>::new()).into_iter();
| ^^^^^^^^^ help: call directly: `iter_mut`
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `LinkedList`
--> $DIR/into_iter_on_ref.rs:33:41
|
LL | let _ = (&LinkedList::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
LL | let _ = (&LinkedList::<i32>::new()).into_iter();
| ^^^^^^^^^ help: call directly: `iter`
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `LinkedList`
--> $DIR/into_iter_on_ref.rs:34:45
|
LL | let _ = (&mut LinkedList::<i32>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
LL | let _ = (&mut LinkedList::<i32>::new()).into_iter();
| ^^^^^^^^^ help: call directly: `iter_mut`
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `HashMap`
--> $DIR/into_iter_on_ref.rs:35:43
|
LL | let _ = (&HashMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter()
LL | let _ = (&HashMap::<i32, u64>::new()).into_iter();
| ^^^^^^^^^ help: call directly: `iter`
error: this `.into_iter()` call is equivalent to `.iter_mut()` and will not consume the `HashMap`
--> $DIR/into_iter_on_ref.rs:36:47
|
LL | let _ = (&mut HashMap::<i32, u64>::new()).into_iter(); //~ WARN equivalent to .iter_mut()
LL | let _ = (&mut HashMap::<i32, u64>::new()).into_iter();
| ^^^^^^^^^ help: call directly: `iter_mut`
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `BTreeSet`
--> $DIR/into_iter_on_ref.rs:38:39
|
LL | let _ = (&BTreeSet::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
LL | let _ = (&BTreeSet::<i32>::new()).into_iter();
| ^^^^^^^^^ help: call directly: `iter`
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `BinaryHeap`
--> $DIR/into_iter_on_ref.rs:39:41
|
LL | let _ = (&BinaryHeap::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
LL | let _ = (&BinaryHeap::<i32>::new()).into_iter();
| ^^^^^^^^^ help: call directly: `iter`
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `HashSet`
--> $DIR/into_iter_on_ref.rs:40:38
|
LL | let _ = (&HashSet::<i32>::new()).into_iter(); //~ WARN equivalent to .iter()
LL | let _ = (&HashSet::<i32>::new()).into_iter();
| ^^^^^^^^^ help: call directly: `iter`
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `Path`
--> $DIR/into_iter_on_ref.rs:41:43
|
LL | let _ = std::path::Path::new("12/34").into_iter(); //~ WARN equivalent to .iter()
LL | let _ = std::path::Path::new("12/34").into_iter();
| ^^^^^^^^^ help: call directly: `iter`
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `PathBuf`
--> $DIR/into_iter_on_ref.rs:42:47
|
LL | let _ = std::path::PathBuf::from("12/34").into_iter(); //~ ERROR equivalent to .iter()
LL | let _ = std::path::PathBuf::from("12/34").into_iter();
| ^^^^^^^^^ help: call directly: `iter`
error: this `.into_iter()` call is equivalent to `.iter()` and will not consume the `array`
--> $DIR/into_iter_on_ref.rs:44:26
|
LL | let _ = (&[1, 2, 3]).into_iter().next(); //~ WARN equivalent to .iter()
LL | let _ = (&[1, 2, 3]).into_iter().next();
| ^^^^^^^^^ help: call directly: `iter`
error: aborting due to 27 previous errors

View file

@ -1,3 +1,3 @@
fn main() {
println!("{}" a); //~ERROR expected `,`, found `a`
println!("{}" a); //~ERROR: expected `,`, found `a`
}

View file

@ -1,7 +1,7 @@
error: expected `,`, found `a`
--> $DIR/issue-3145.rs:2:19
|
LL | println!("{}" a); //~ERROR expected `,`, found `a`
LL | println!("{}" a);
| ^ expected `,`
error: aborting due to previous error

View file

@ -1,17 +1,2 @@
error: items were found after the testing module
--> $DIR/block_module.rs:13:1
|
LL | / mod tests {
LL | | #[test]
LL | | fn hi() {}
LL | | }
... |
LL | | () => {};
LL | | }
| |_^
|
= help: move the items to before the testing module was defined
= note: `-D clippy::items-after-test-module` implied by `-D warnings`
error: aborting due to previous error
error: Option 'test' given more than once

View file

@ -1,4 +1,4 @@
//@aux-build:proc_macros.rs
//@aux-build:proc_macros.rs:proc-macro
#![allow(dead_code)]
#![allow(unused_variables)]

View file

@ -1,4 +1,4 @@
//@aux-build: proc_macros.rs
//@aux-build: proc_macros.rs:proc-macro
#![allow(unused)]
#![warn(clippy::let_underscore_untyped)]

View file

@ -1,4 +1,4 @@
//@aux-build: proc_macros.rs
//@aux-build: proc_macros.rs:proc-macro
#![allow(unused)]
#![warn(clippy::let_with_type_underscore)]
#![allow(clippy::let_unit_value, clippy::needless_late_init)]

View file

@ -1,6 +1,6 @@
//@aux-build:macro_rules.rs
//@aux-build:macro_use_helper.rs
//@aux-build:proc_macro_derive.rs
//@aux-build:proc_macro_derive.rs:proc-macro
//@run-rustfix
//@ignore-32bit

View file

@ -1,6 +1,6 @@
//@aux-build:macro_rules.rs
//@aux-build:macro_use_helper.rs
//@aux-build:proc_macro_derive.rs
//@aux-build:proc_macro_derive.rs:proc-macro
//@run-rustfix
//@ignore-32bit

View file

@ -1,17 +1,11 @@
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
--> $DIR/macro_use_imports.rs:25:5
--> $DIR/macro_use_imports.rs:19:5
|
LL | #[macro_use]
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::inner::nested::string_add;`
| ^^^^^^^^^^^^ 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};`
|
= note: `-D clippy::macro-use-imports` implied by `-D warnings`
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
--> $DIR/macro_use_imports.rs:21:5
|
LL | #[macro_use]
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mini_mac::ClippyMiniMacroTest;`
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
--> $DIR/macro_use_imports.rs:23:5
|
@ -19,10 +13,16 @@ 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
--> $DIR/macro_use_imports.rs:19:5
--> $DIR/macro_use_imports.rs:25: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};`
| ^^^^^^^^^^^^ 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
--> $DIR/macro_use_imports.rs:21:5
|
LL | #[macro_use]
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mini_mac::ClippyMiniMacroTest;`
error: aborting due to 4 previous errors

View file

@ -1,6 +1,6 @@
//@aux-build:macro_rules.rs
//@aux-build:macro_use_helper.rs
//@aux-build:proc_macro_derive.rs
//@aux-build:proc_macro_derive.rs:proc-macro
//@ignore-32bit
#![feature(lint_reasons)]

Some files were not shown because too many files have changed in this diff Show more