-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
232 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
tests/ui/lint/unnecessary-qualification/lint-unnecessary-qualification-issue-121331.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//@ run-rustfix | ||
//@ edition:2021 | ||
#![deny(unused_imports)] | ||
#![deny(unused_qualifications)] | ||
#![feature(coroutines, coroutine_trait)] | ||
|
||
use std::ops::{ | ||
Coroutine, | ||
CoroutineState::{self}, | ||
//~^ ERROR unused import: `*` | ||
}; | ||
use std::pin::Pin; | ||
|
||
#[allow(dead_code)] | ||
fn finish<T>(mut amt: usize, mut t: T) -> T::Return | ||
where T: Coroutine<(), Yield = ()> + Unpin, | ||
{ | ||
loop { | ||
match Pin::new(&mut t).resume(()) { | ||
CoroutineState::Yielded(()) => amt = amt.checked_sub(1).unwrap(), | ||
CoroutineState::Complete(ret) => { | ||
assert_eq!(amt, 0); | ||
return ret | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
mod foo { | ||
pub fn bar() {} | ||
} | ||
|
||
mod baz { | ||
pub fn qux() {} | ||
} | ||
|
||
pub fn main() { | ||
|
||
|
||
//~^ ERROR unused import: `foo::bar` | ||
foo::bar(); | ||
|
||
#[allow(unused_imports)] | ||
use baz::qux; | ||
qux(); | ||
//~^ ERROR unnecessary qualification | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
tests/ui/lint/unnecessary-qualification/lint-unnecessary-qualification-issue-121331.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//@ run-rustfix | ||
//@ edition:2021 | ||
#![deny(unused_imports)] | ||
#![deny(unused_qualifications)] | ||
#![feature(coroutines, coroutine_trait)] | ||
|
||
use std::ops::{ | ||
Coroutine, | ||
CoroutineState::{self, *}, | ||
//~^ ERROR unused import: `*` | ||
}; | ||
use std::pin::Pin; | ||
|
||
#[allow(dead_code)] | ||
fn finish<T>(mut amt: usize, mut t: T) -> T::Return | ||
where T: Coroutine<(), Yield = ()> + Unpin, | ||
{ | ||
loop { | ||
match Pin::new(&mut t).resume(()) { | ||
CoroutineState::Yielded(()) => amt = amt.checked_sub(1).unwrap(), | ||
CoroutineState::Complete(ret) => { | ||
assert_eq!(amt, 0); | ||
return ret | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
mod foo { | ||
pub fn bar() {} | ||
} | ||
|
||
mod baz { | ||
pub fn qux() {} | ||
} | ||
|
||
pub fn main() { | ||
|
||
use foo::bar; | ||
//~^ ERROR unused import: `foo::bar` | ||
foo::bar(); | ||
|
||
#[allow(unused_imports)] | ||
use baz::qux; | ||
baz::qux(); | ||
//~^ ERROR unnecessary qualification | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
tests/ui/lint/unnecessary-qualification/lint-unnecessary-qualification-issue-121331.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
error: unused import: `*` | ||
--> $DIR/lint-unnecessary-qualification-issue-121331.rs:9:28 | ||
| | ||
LL | CoroutineState::{self, *}, | ||
| ^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/lint-unnecessary-qualification-issue-121331.rs:3:9 | ||
| | ||
LL | #![deny(unused_imports)] | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: unused import: `foo::bar` | ||
--> $DIR/lint-unnecessary-qualification-issue-121331.rs:40:9 | ||
| | ||
LL | use foo::bar; | ||
| ^^^^^^^^ | ||
|
||
error: unnecessary qualification | ||
--> $DIR/lint-unnecessary-qualification-issue-121331.rs:46:5 | ||
| | ||
LL | baz::qux(); | ||
| ^^^^^^^^ | ||
| | ||
note: the lint level is defined here | ||
--> $DIR/lint-unnecessary-qualification-issue-121331.rs:4:9 | ||
| | ||
LL | #![deny(unused_qualifications)] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
help: remove the unnecessary path segments | ||
| | ||
LL - baz::qux(); | ||
LL + qux(); | ||
| | ||
|
||
error: aborting due to 3 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
#[allow(unused_imports)] | ||
use std::ops; | ||
#[allow(unused_imports)] | ||
use std::ops::Index; | ||
|
||
pub struct A; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
#[allow(unused_imports)] | ||
use std::ops; | ||
#[allow(unused_imports)] | ||
use std::ops::Index; | ||
|
||
pub struct A; | ||
|
Oops, something went wrong.