Skip to content

Commit

Permalink
Allow newly added non_local_definitions lint in clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Jan 26, 2024
1 parent 9b82bdd commit c6f8d02
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/tools/clippy/tests/ui/crashes/ice-4760.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(non_local_definitions)]

const COUNT: usize = 2;
struct Thing;
trait Dummy {}
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/tests/ui/crashes/ice-6179.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#![warn(clippy::use_self)]
#![allow(dead_code, clippy::let_with_type_underscore)]
#![allow(non_local_definitions)]

struct Foo;

Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/tests/ui/from_over_into.fixed
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![feature(type_alias_impl_trait)]
#![warn(clippy::from_over_into)]
#![allow(non_local_definitions)]
#![allow(unused)]

// this should throw an error
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/tests/ui/from_over_into.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![feature(type_alias_impl_trait)]
#![warn(clippy::from_over_into)]
#![allow(non_local_definitions)]
#![allow(unused)]

// this should throw an error
Expand Down
14 changes: 7 additions & 7 deletions src/tools/clippy/tests/ui/from_over_into.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
--> $DIR/from_over_into.rs:8:1
--> $DIR/from_over_into.rs:9:1
|
LL | impl Into<StringWrapper> for String {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -14,7 +14,7 @@ LL ~ StringWrapper(val)
|

error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
--> $DIR/from_over_into.rs:16:1
--> $DIR/from_over_into.rs:17:1
|
LL | impl Into<SelfType> for String {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -27,7 +27,7 @@ LL ~ SelfType(String::new())
|

error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
--> $DIR/from_over_into.rs:31:1
--> $DIR/from_over_into.rs:32:1
|
LL | impl Into<SelfKeywords> for X {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -42,7 +42,7 @@ LL ~ let _: X = val;
|

error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
--> $DIR/from_over_into.rs:43:1
--> $DIR/from_over_into.rs:44:1
|
LL | impl core::convert::Into<bool> for crate::ExplicitPaths {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -60,7 +60,7 @@ LL ~ val.0
|

error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
--> $DIR/from_over_into.rs:63:1
--> $DIR/from_over_into.rs:64:1
|
LL | impl Into<String> for PathInExpansion {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -74,7 +74,7 @@ LL ~ fn from(val: PathInExpansion) -> Self {
|

error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
--> $DIR/from_over_into.rs:85:5
--> $DIR/from_over_into.rs:86:5
|
LL | impl<T> Into<FromOverInto<T>> for Vec<T> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -87,7 +87,7 @@ LL ~ FromOverInto(val)
|

error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true
--> $DIR/from_over_into.rs:95:5
--> $DIR/from_over_into.rs:96:5
|
LL | impl Into<()> for Hello {
| ^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/tests/ui/manual_str_repeat.fixed
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
#![warn(clippy::manual_str_repeat)]

use std::borrow::Cow;
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/tests/ui/manual_str_repeat.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![allow(non_local_definitions)]
#![warn(clippy::manual_str_repeat)]

use std::borrow::Cow;
Expand Down
20 changes: 10 additions & 10 deletions src/tools/clippy/tests/ui/manual_str_repeat.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:7:21
--> $DIR/manual_str_repeat.rs:8:21
|
LL | let _: String = std::iter::repeat("test").take(10).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"test".repeat(10)`
Expand All @@ -8,55 +8,55 @@ LL | let _: String = std::iter::repeat("test").take(10).collect();
= help: to override `-D warnings` add `#[allow(clippy::manual_str_repeat)]`

error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:8:21
--> $DIR/manual_str_repeat.rs:9:21
|
LL | let _: String = std::iter::repeat('x').take(10).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"x".repeat(10)`

error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:9:21
--> $DIR/manual_str_repeat.rs:10:21
|
LL | let _: String = std::iter::repeat('\'').take(10).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"'".repeat(10)`

error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:10:21
--> $DIR/manual_str_repeat.rs:11:21
|
LL | let _: String = std::iter::repeat('"').take(10).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"\"".repeat(10)`

error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:14:13
--> $DIR/manual_str_repeat.rs:15:13
|
LL | let _ = repeat(x).take(count + 2).collect::<String>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.repeat(count + 2)`

error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:23:21
--> $DIR/manual_str_repeat.rs:24:21
|
LL | let _: String = repeat(*x).take(count).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(*x).repeat(count)`

error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:32:21
--> $DIR/manual_str_repeat.rs:33:21
|
LL | let _: String = repeat(x).take(count).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.repeat(count)`

error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:44:21
--> $DIR/manual_str_repeat.rs:45:21
|
LL | let _: String = repeat(Cow::Borrowed("test")).take(count).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Cow::Borrowed("test").repeat(count)`

error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:47:21
--> $DIR/manual_str_repeat.rs:48:21
|
LL | let _: String = repeat(x).take(count).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `x.repeat(count)`

error: manual implementation of `str::repeat` using iterators
--> $DIR/manual_str_repeat.rs:62:21
--> $DIR/manual_str_repeat.rs:63:21
|
LL | let _: String = std::iter::repeat("test").take(10).collect();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `"test".repeat(10)`
Expand Down

0 comments on commit c6f8d02

Please sign in to comment.