diff options
| author | William Bain <bain.william.a@gmail.com> | 2020-12-29 00:10:13 -0500 |
|---|---|---|
| committer | William Bain <bain.william.a@gmail.com> | 2021-01-10 19:47:57 -0500 |
| commit | 0496fdee4fa65b38f540b5a7aa7ea86eb5ca890e (patch) | |
| tree | e2901044d22af6f689d998a9d362429bb0e9d7b3 /compiler/rustc_trait_selection/src/traits | |
| parent | c97f11af7bc4a6d3578f6a953be04ab2449a5728 (diff) | |
| download | rust-0496fdee4fa65b38f540b5a7aa7ea86eb5ca890e.tar.gz rust-0496fdee4fa65b38f540b5a7aa7ea86eb5ca890e.zip | |
Note inference failures using `?` conversion
Diffstat (limited to 'compiler/rustc_trait_selection/src/traits')
| -rw-r--r-- | compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index a439bb892f8..0186d164a4c 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -280,18 +280,10 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { let OnUnimplementedNote { message, label, note, enclosing_scope } = self.on_unimplemented_note(trait_ref, obligation); let have_alt_message = message.is_some() || label.is_some(); - let is_try = self - .tcx - .sess - .source_map() - .span_to_snippet(span) - .map(|s| &s == "?") - .unwrap_or(false); - let is_from = self.tcx.get_diagnostic_item(sym::from_trait) - == Some(trait_ref.def_id()); + let is_try_conversion = self.is_try_conversion(span, trait_ref.def_id()); let is_unsize = { Some(trait_ref.def_id()) == self.tcx.lang_items().unsize_trait() }; - let (message, note) = if is_try && is_from { + let (message, note) = if is_try_conversion { ( Some(format!( "`?` couldn't convert the error to `{}`", @@ -319,7 +311,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> { )) ); - if is_try && is_from { + if is_try_conversion { let none_error = self .tcx .get_diagnostic_item(sym::none_error) |
