Skip to content

Commit

Permalink
Rollup merge of #101192 - TaKO8Ki:remove-path-string, r=compiler-errors
Browse files Browse the repository at this point in the history
Remove path string
  • Loading branch information
JohnTitor authored Aug 30, 2022
2 parents 60e8550 + f6252a4 commit 42a1901
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions compiler/rustc_infer/src/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2055,22 +2055,22 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
(exp_found.expected.kind(), exp_found.found.kind())
{
if let ty::Adt(found_def, found_substs) = *found_ty.kind() {
let path_str = format!("{:?}", exp_def);
if exp_def == &found_def {
let opt_msg = "you can convert from `&Option<T>` to `Option<&T>` using \
`.as_ref()`";
let result_msg = "you can convert from `&Result<T, E>` to \
`Result<&T, &E>` using `.as_ref()`";
let have_as_ref = &[
("std::option::Option", opt_msg),
("core::option::Option", opt_msg),
("std::result::Result", result_msg),
("core::result::Result", result_msg),
(
sym::Option,
"you can convert from `&Option<T>` to `Option<&T>` using \
`.as_ref()`",
),
(
sym::Result,
"you can convert from `&Result<T, E>` to \
`Result<&T, &E>` using `.as_ref()`",
),
];
if let Some(msg) = have_as_ref
.iter()
.find_map(|(path, msg)| (&path_str == path).then_some(msg))
{
if let Some(msg) = have_as_ref.iter().find_map(|(name, msg)| {
self.tcx.is_diagnostic_item(*name, exp_def.did()).then_some(msg)
}) {
let mut show_suggestion = true;
for (exp_ty, found_ty) in
iter::zip(exp_substs.types(), found_substs.types())
Expand Down

0 comments on commit 42a1901

Please sign in to comment.