Skip to content

Commit 42a1901

Browse files
authored
Rollup merge of rust-lang#101192 - TaKO8Ki:remove-path-string, r=compiler-errors
Remove path string
2 parents 60e8550 + f6252a4 commit 42a1901

File tree

1 file changed

+13
-13
lines changed
  • compiler/rustc_infer/src/infer/error_reporting

1 file changed

+13
-13
lines changed

compiler/rustc_infer/src/infer/error_reporting/mod.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -2055,22 +2055,22 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
20552055
(exp_found.expected.kind(), exp_found.found.kind())
20562056
{
20572057
if let ty::Adt(found_def, found_substs) = *found_ty.kind() {
2058-
let path_str = format!("{:?}", exp_def);
20592058
if exp_def == &found_def {
2060-
let opt_msg = "you can convert from `&Option<T>` to `Option<&T>` using \
2061-
`.as_ref()`";
2062-
let result_msg = "you can convert from `&Result<T, E>` to \
2063-
`Result<&T, &E>` using `.as_ref()`";
20642059
let have_as_ref = &[
2065-
("std::option::Option", opt_msg),
2066-
("core::option::Option", opt_msg),
2067-
("std::result::Result", result_msg),
2068-
("core::result::Result", result_msg),
2060+
(
2061+
sym::Option,
2062+
"you can convert from `&Option<T>` to `Option<&T>` using \
2063+
`.as_ref()`",
2064+
),
2065+
(
2066+
sym::Result,
2067+
"you can convert from `&Result<T, E>` to \
2068+
`Result<&T, &E>` using `.as_ref()`",
2069+
),
20692070
];
2070-
if let Some(msg) = have_as_ref
2071-
.iter()
2072-
.find_map(|(path, msg)| (&path_str == path).then_some(msg))
2073-
{
2071+
if let Some(msg) = have_as_ref.iter().find_map(|(name, msg)| {
2072+
self.tcx.is_diagnostic_item(*name, exp_def.did()).then_some(msg)
2073+
}) {
20742074
let mut show_suggestion = true;
20752075
for (exp_ty, found_ty) in
20762076
iter::zip(exp_substs.types(), found_substs.types())

0 commit comments

Comments
 (0)