Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b96c3ca

Browse files
committed
Auto merge of rust-lang#5259 - flip1995:lang_items, r=phansch
Use lang items instead of get_trait_def_id where possible changelog: none
2 parents f44181e + 91042db commit b96c3ca

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

clippy_lints/src/doc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::utils::{get_trait_def_id, implements_trait, is_entrypoint_fn, match_type, paths, return_ty, span_lint};
1+
use crate::utils::{implements_trait, is_entrypoint_fn, match_type, paths, return_ty, span_lint};
22
use if_chain::if_chain;
33
use itertools::Itertools;
44
use rustc::lint::in_external_macro;
@@ -227,7 +227,7 @@ fn lint_for_missing_headers<'a, 'tcx>(
227227
} else {
228228
if_chain! {
229229
if let Some(body_id) = body_id;
230-
if let Some(future) = get_trait_def_id(cx, &paths::FUTURE);
230+
if let Some(future) = cx.tcx.lang_items().future_trait();
231231
let def_id = cx.tcx.hir().body_owner_def_id(body_id);
232232
let mir = cx.tcx.optimized_mir(def_id);
233233
let ret_ty = mir.return_ty();

clippy_lints/src/inherent_to_string.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InherentToString {
120120
}
121121

122122
fn show_lint(cx: &LateContext<'_, '_>, item: &ImplItem<'_>) {
123-
let display_trait_id =
124-
get_trait_def_id(cx, &["core", "fmt", "Display"]).expect("Failed to get trait ID of `Display`!");
123+
let display_trait_id = get_trait_def_id(cx, &paths::DISPLAY_TRAIT).expect("Failed to get trait ID of `Display`!");
125124

126125
// Get the real type of 'self'
127126
let fn_def_id = cx.tcx.hir().local_def_id(item.hir_id);

clippy_lints/src/neg_cmp_op_on_partial_ord.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NoNegCompOpForPartialOrd {
6767
};
6868

6969
let implements_partial_ord = {
70-
if let Some(id) = utils::get_trait_def_id(cx, &paths::PARTIAL_ORD) {
70+
if let Some(id) = cx.tcx.lang_items().partial_ord_trait() {
7171
utils::implements_trait(cx, ty, id, &[])
7272
} else {
7373
return;

clippy_lints/src/utils/paths.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub const DEFAULT_TRAIT_METHOD: [&str; 4] = ["core", "default", "Default", "defa
2424
pub const DEREF_MUT_TRAIT_METHOD: [&str; 5] = ["core", "ops", "deref", "DerefMut", "deref_mut"];
2525
pub const DEREF_TRAIT_METHOD: [&str; 5] = ["core", "ops", "deref", "Deref", "deref"];
2626
pub const DISPLAY_FMT_METHOD: [&str; 4] = ["core", "fmt", "Display", "fmt"];
27+
pub const DISPLAY_TRAIT: [&str; 3] = ["core", "fmt", "Display"];
2728
pub const DOUBLE_ENDED_ITERATOR: [&str; 4] = ["core", "iter", "traits", "DoubleEndedIterator"];
2829
pub const DROP: [&str; 3] = ["core", "mem", "drop"];
2930
pub const DROP_TRAIT: [&str; 4] = ["core", "ops", "drop", "Drop"];
@@ -36,7 +37,6 @@ pub const FMT_ARGUMENTS_NEW_V1_FORMATTED: [&str; 4] = ["core", "fmt", "Arguments
3637
pub const FMT_ARGUMENTV1_NEW: [&str; 4] = ["core", "fmt", "ArgumentV1", "new"];
3738
pub const FROM_FROM: [&str; 4] = ["core", "convert", "From", "from"];
3839
pub const FROM_TRAIT: [&str; 3] = ["core", "convert", "From"];
39-
pub const FUTURE: [&str; 3] = ["std", "future", "Future"];
4040
pub const HASH: [&str; 2] = ["hash", "Hash"];
4141
pub const HASHMAP: [&str; 5] = ["std", "collections", "hash", "map", "HashMap"];
4242
pub const HASHMAP_ENTRY: [&str; 5] = ["std", "collections", "hash", "map", "Entry"];
@@ -69,7 +69,6 @@ pub const ORD: [&str; 3] = ["core", "cmp", "Ord"];
6969
pub const OS_STRING: [&str; 4] = ["std", "ffi", "os_str", "OsString"];
7070
pub const OS_STRING_AS_OS_STR: [&str; 5] = ["std", "ffi", "os_str", "OsString", "as_os_str"];
7171
pub const OS_STR_TO_OS_STRING: [&str; 5] = ["std", "ffi", "os_str", "OsStr", "to_os_string"];
72-
pub const PARTIAL_ORD: [&str; 3] = ["core", "cmp", "PartialOrd"];
7372
pub const PATH: [&str; 3] = ["std", "path", "Path"];
7473
pub const PATH_BUF: [&str; 3] = ["std", "path", "PathBuf"];
7574
pub const PATH_BUF_AS_PATH: [&str; 4] = ["std", "path", "PathBuf", "as_path"];

0 commit comments

Comments
 (0)