-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
6 changed files
with
182 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#![feature(rustc_private)] | ||
#![allow(unused)] | ||
#![warn(clippy::unnecessary_def_path)] | ||
|
||
extern crate rustc_hir; | ||
|
||
use rustc_hir::LangItem; | ||
|
||
fn main() { | ||
const DEREF_TRAIT: [&str; 4] = ["core", "ops", "deref", "Deref"]; | ||
const DEREF_MUT_TRAIT: [&str; 4] = ["core", "ops", "deref", "DerefMut"]; | ||
const DEREF_TRAIT_METHOD: [&str; 5] = ["core", "ops", "deref", "Deref", "deref"]; | ||
|
||
// Don't lint, not yet a diagnostic or language item | ||
const DEREF_MUT_TRAIT_METHOD: [&str; 5] = ["core", "ops", "deref", "DerefMut", "deref_mut"]; | ||
} |
27 changes: 27 additions & 0 deletions
27
tests/ui-internal/unnecessary_def_path_hardcoded_path.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,27 @@ | ||
error: hardcoded path to a language item | ||
--> $DIR/unnecessary_def_path_hardcoded_path.rs:11:40 | ||
| | ||
LL | const DEREF_MUT_TRAIT: [&str; 4] = ["core", "ops", "deref", "DerefMut"]; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: convert all references to use `LangItem::DerefMut` | ||
= note: `-D clippy::unnecessary-def-path` implied by `-D warnings` | ||
|
||
error: hardcoded path to a diagnostic item | ||
--> $DIR/unnecessary_def_path_hardcoded_path.rs:12:43 | ||
| | ||
LL | const DEREF_TRAIT_METHOD: [&str; 5] = ["core", "ops", "deref", "Deref", "deref"]; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: convert all references to use `sym::deref_method` | ||
|
||
error: hardcoded path to a diagnostic item | ||
--> $DIR/unnecessary_def_path_hardcoded_path.rs:10:36 | ||
| | ||
LL | const DEREF_TRAIT: [&str; 4] = ["core", "ops", "deref", "Deref"]; | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= help: convert all references to use `sym::Deref` | ||
|
||
error: aborting due to 3 previous errors | ||
|