Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
change span.hi if exists default.

Diagnostic suggests adding : ?Sized in an incorrect place if a type parameter default is present
  • Loading branch information
OdenShirataki committed Feb 11, 2024
1 parent 42752cb commit dbbef30
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use rustc_hir as hir;
use rustc_hir::def::{DefKind, Namespace, Res};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::intravisit::Visitor;
use rustc_hir::{GenericParam, Item, Node};
use rustc_hir::{GenericParam, GenericParamKind, Item, Node};
use rustc_infer::infer::error_reporting::TypeErrCtxt;
use rustc_infer::infer::{InferOk, TypeTrace};
use rustc_middle::traits::select::OverflowError;
Expand Down Expand Up @@ -2993,7 +2993,16 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
{
(s, " +")
} else {
(span.shrink_to_hi(), ":")
(
if let GenericParamKind::Type { default: Some(default), synthetic: _ } = param.kind
{
span.data().with_hi(default.span.lo() - rustc_span::BytePos(3))
} else {
span
}
.shrink_to_hi(),
":",
)
};
err.span_suggestion_verbose(
span,
Expand Down

0 comments on commit dbbef30

Please sign in to comment.