Skip to content

Commit c1ccb05

Browse files
Format
1 parent 71b31c4 commit c1ccb05

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

compiler/rustc_hir/src/hir.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,10 @@ impl<'hir> Generics<'hir> {
647647
/// Returns bounds span for suggestions.
648648
/// If the span including lifetime bound needs parentheses, it returns a span to the open parenthese at the second item.
649649
/// e.g. `dyn Future<Output = ()> + 'static` needs parentheses `(dyn Future<Output = ()>) + 'static`
650-
pub fn bounds_span_for_suggestions(&self, param_def_id: LocalDefId) -> Option<(Span, Option<Span>)> {
650+
pub fn bounds_span_for_suggestions(
651+
&self,
652+
param_def_id: LocalDefId,
653+
) -> Option<(Span, Option<Span>)> {
651654
fn get_inner_ty<'a, 'b>(bound: &'a GenericBound<'b>) -> Option<&'a Ty<'b>> {
652655
match bound {
653656
GenericBound::Trait(data, _) => {

compiler/rustc_hir_typeck/src/method/suggest.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -3275,7 +3275,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
32753275
param.name.ident(),
32763276
));
32773277
let bounds_span = hir_generics.bounds_span_for_suggestions(def_id);
3278-
if rcvr_ty.is_ref() && param.is_impl_trait() && let Some((bounds_span, _)) = bounds_span {
3278+
if rcvr_ty.is_ref()
3279+
&& param.is_impl_trait()
3280+
&& let Some((bounds_span, _)) = bounds_span
3281+
{
32793282
err.multipart_suggestions(
32803283
msg,
32813284
candidates.iter().map(|t| {

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -2403,8 +2403,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
24032403
// We do this to avoid suggesting code that ends up as `T: 'a'b`,
24042404
// instead we suggest `T: 'a + 'b` in that case.
24052405
let hir_generics = self.tcx.hir().get_generics(scope).unwrap();
2406-
let sugg_span = match hir_generics.bounds_span_for_suggestions(def_id)
2407-
{
2406+
let sugg_span = match hir_generics.bounds_span_for_suggestions(def_id) {
24082407
Some((span, open_paren_sp)) => Some((span, true, open_paren_sp)),
24092408
// If `param` corresponds to `Self`, no usable suggestion span.
24102409
None if generics.has_self && param.index == 0 => None,

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -2929,12 +2929,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
29292929
_ => {}
29302930
};
29312931
// Didn't add an indirection suggestion, so add a general suggestion to relax `Sized`.
2932-
let (span, separator) = if let Some((s, _)) = generics.bounds_span_for_suggestions(param.def_id)
2933-
{
2934-
(s, " +")
2935-
} else {
2936-
(param.name.ident().span.shrink_to_hi(), ":")
2937-
};
2932+
let (span, separator) =
2933+
if let Some((s, _)) = generics.bounds_span_for_suggestions(param.def_id) {
2934+
(s, " +")
2935+
} else {
2936+
(param.name.ident().span.shrink_to_hi(), ":")
2937+
};
29382938
err.span_suggestion_verbose(
29392939
span,
29402940
"consider relaxing the implicit `Sized` restriction",

0 commit comments

Comments
 (0)