Skip to content

Commit cb3aa74

Browse files
committed
Fix path_qualified
As suggested by eddyb
1 parent 9b7ff50 commit cb3aa74

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

clippy_lints/src/utils/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ impl<'tcx> Printer<'tcx, 'tcx> for AbsolutePathPrinter<'_, 'tcx> {
141141
self_ty: Ty<'tcx>,
142142
trait_ref: Option<ty::TraitRef<'tcx>>,
143143
) -> Result<Self::Path, Self::Error> {
144+
if trait_ref.is_none() {
145+
if let ty::Adt(def, substs) = self_ty.sty {
146+
return self.print_def_path(def.did, substs);
147+
}
148+
}
149+
144150
// This shouldn't ever be needed, but just in case:
145151
Ok(vec![match trait_ref {
146152
Some(trait_ref) => Symbol::intern(&format!("{:?}", trait_ref)).as_str(),

clippy_lints/src/utils/paths.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub const CLONE_TRAIT_METHOD: [&str; 4] = ["core", "clone", "Clone", "clone"];
1717
pub const CMP_MAX: [&str; 3] = ["core", "cmp", "max"];
1818
pub const CMP_MIN: [&str; 3] = ["core", "cmp", "min"];
1919
pub const COW: [&str; 3] = ["alloc", "borrow", "Cow"];
20-
pub const CSTRING_NEW: [&str; 2] = ["<std::ffi::CString>", "new"];
20+
pub const CSTRING_NEW: [&str; 5] = ["std", "ffi", "c_str", "CString", "new"];
2121
pub const DEFAULT_TRAIT: [&str; 3] = ["core", "default", "Default"];
2222
pub const DEFAULT_TRAIT_METHOD: [&str; 4] = ["core", "default", "Default", "default"];
2323
pub const DEREF_TRAIT_METHOD: [&str; 5] = ["core", "ops", "deref", "Deref", "deref"];
@@ -27,8 +27,8 @@ pub const DROP: [&str; 3] = ["core", "mem", "drop"];
2727
pub const DROP_TRAIT: [&str; 4] = ["core", "ops", "drop", "Drop"];
2828
pub const DURATION: [&str; 3] = ["core", "time", "Duration"];
2929
pub const EARLY_CONTEXT: [&str; 4] = ["rustc", "lint", "context", "EarlyContext"];
30-
pub const FMT_ARGUMENTS_NEWV1: [&str; 2] = ["<std::fmt::Arguments<'a>>", "new_v1"];
31-
pub const FMT_ARGUMENTS_NEWV1FORMATTED: [&str; 2] = ["<std::fmt::Arguments<'a>>", "new_v1_formatted"];
30+
pub const FMT_ARGUMENTS_NEWV1: [&str; 4] = ["core", "fmt", "Arguments", "new_v1"];
31+
pub const FMT_ARGUMENTS_NEWV1FORMATTED: [&str; 4] = ["core", "fmt", "Arguments", "new_v1_formatted"];
3232
pub const FROM_FROM: [&str; 4] = ["core", "convert", "From", "from"];
3333
pub const FROM_TRAIT: [&str; 3] = ["core", "convert", "From"];
3434
pub const HASH: [&str; 2] = ["hash", "Hash"];
@@ -60,11 +60,11 @@ pub const OPTION_NONE: [&str; 4] = ["core", "option", "Option", "None"];
6060
pub const OPTION_SOME: [&str; 4] = ["core", "option", "Option", "Some"];
6161
pub const ORD: [&str; 3] = ["core", "cmp", "Ord"];
6262
pub const OS_STRING: [&str; 4] = ["std", "ffi", "os_str", "OsString"];
63-
pub const OS_STR_TO_OS_STRING: [&str; 2] = ["<std::ffi::OsStr>", "to_os_string"];
63+
pub const OS_STR_TO_OS_STRING: [&str; 5] = ["std", "ffi", "os_str", "OsStr", "to_os_string"];
6464
pub const PARTIAL_ORD: [&str; 3] = ["core", "cmp", "PartialOrd"];
6565
pub const PATH: [&str; 3] = ["std", "path", "Path"];
6666
pub const PATH_BUF: [&str; 3] = ["std", "path", "PathBuf"];
67-
pub const PATH_TO_PATH_BUF: [&str; 2] = ["<std::path::Path>", "to_path_buf"];
67+
pub const PATH_TO_PATH_BUF: [&str; 4] = ["std", "path", "Path", "to_path_buf"];
6868
pub const PTR_NULL: [&str; 2] = ["ptr", "null"];
6969
pub const PTR_NULL_MUT: [&str; 2] = ["ptr", "null_mut"];
7070
pub const RANGE: [&str; 3] = ["core", "ops", "Range"];
@@ -83,12 +83,12 @@ pub const RANGE_TO_STD: [&str; 3] = ["std", "ops", "RangeTo"];
8383
pub const RC: [&str; 3] = ["alloc", "rc", "Rc"];
8484
pub const RECEIVER: [&str; 4] = ["std", "sync", "mpsc", "Receiver"];
8585
pub const REGEX: [&str; 3] = ["regex", "re_unicode", "Regex"];
86-
pub const REGEX_BUILDER_NEW: [&str; 2] = ["<regex::RegexBuilder>", "new"];
87-
pub const REGEX_BYTES_BUILDER_NEW: [&str; 2] = ["<regex::bytes::RegexBuilder>", "new"];
88-
pub const REGEX_BYTES_NEW: [&str; 2] = ["<regex::bytes::Regex>", "new"];
89-
pub const REGEX_BYTES_SET_NEW: [&str; 2] = ["<regex::bytes::RegexSet>", "new"];
90-
pub const REGEX_NEW: [&str; 2] = ["<regex::Regex>", "new"];
91-
pub const REGEX_SET_NEW: [&str; 2] = ["<regex::RegexSet>", "new"];
86+
pub const REGEX_BUILDER_NEW: [&str; 5] = ["regex", "re_builder", "unicode", "RegexBuilder", "new"];
87+
pub const REGEX_BYTES_BUILDER_NEW: [&str; 5] = ["regex", "re_builder", "bytes", "RegexBuilder", "new"];
88+
pub const REGEX_BYTES_NEW: [&str; 4] = ["regex", "re_bytes", "Regex", "new"];
89+
pub const REGEX_BYTES_SET_NEW: [&str; 5] = ["regex", "re_set", "bytes", "RegexSet", "new"];
90+
pub const REGEX_NEW: [&str; 4] = ["regex", "re_unicode", "Regex", "new"];
91+
pub const REGEX_SET_NEW: [&str; 5] = ["regex", "re_set", "unicode", "RegexSet", "new"];
9292
pub const REPEAT: [&str; 3] = ["core", "iter", "repeat"];
9393
pub const RESULT: [&str; 3] = ["core", "result", "Result"];
9494
pub const RESULT_ERR: [&str; 4] = ["core", "result", "Result", "Err"];

0 commit comments

Comments
 (0)