Skip to content

Commit 0a3cb1e

Browse files
authored
Rollup merge of #104381 - mejrs:none_error, r=compiler-errors
Remove dead NoneError diagnostic handling `NoneError` was removed some time ago, so this was dead code.
2 parents 2eee3a6 + 25acee5 commit 0a3cb1e

File tree

2 files changed

+8
-36
lines changed
  • compiler
    • rustc_span/src
    • rustc_trait_selection/src/traits/error_reporting

2 files changed

+8
-36
lines changed

compiler/rustc_span/src/symbol.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,6 @@ symbols! {
10351035
non_exhaustive,
10361036
non_exhaustive_omitted_patterns_lint,
10371037
non_modrs_mods,
1038-
none_error,
10391038
nontemporal_store,
10401039
noop_method_borrow,
10411040
noop_method_clone,

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+8-35
Original file line numberDiff line numberDiff line change
@@ -650,41 +650,14 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
650650
))
651651
);
652652

653-
if is_try_conversion {
654-
let none_error = self
655-
.tcx
656-
.get_diagnostic_item(sym::none_error)
657-
.map(|def_id| tcx.type_of(def_id));
658-
let should_convert_option_to_result =
659-
Some(trait_ref.skip_binder().substs.type_at(1)) == none_error;
660-
let should_convert_result_to_option =
661-
Some(trait_ref.self_ty().skip_binder()) == none_error;
662-
if should_convert_option_to_result {
663-
err.span_suggestion_verbose(
664-
span.shrink_to_lo(),
665-
"consider converting the `Option<T>` into a `Result<T, _>` \
666-
using `Option::ok_or` or `Option::ok_or_else`",
667-
".ok_or_else(|| /* error value */)",
668-
Applicability::HasPlaceholders,
669-
);
670-
} else if should_convert_result_to_option {
671-
err.span_suggestion_verbose(
672-
span.shrink_to_lo(),
673-
"consider converting the `Result<T, _>` into an `Option<T>` \
674-
using `Result::ok`",
675-
".ok()",
676-
Applicability::MachineApplicable,
677-
);
678-
}
679-
if let Some(ret_span) = self.return_type_span(&obligation) {
680-
err.span_label(
681-
ret_span,
682-
&format!(
683-
"expected `{}` because of this",
684-
trait_ref.skip_binder().self_ty()
685-
),
686-
);
687-
}
653+
if is_try_conversion && let Some(ret_span) = self.return_type_span(&obligation) {
654+
err.span_label(
655+
ret_span,
656+
&format!(
657+
"expected `{}` because of this",
658+
trait_ref.skip_binder().self_ty()
659+
),
660+
);
688661
}
689662

690663
if Some(trait_ref.def_id()) == tcx.lang_items().tuple_trait() {

0 commit comments

Comments
 (0)