Skip to content

Commit 4b05128

Browse files
committed
Attach Applicability to multipart_suggestion and span_suggestions
1 parent 2f5cb6d commit 4b05128

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

src/librustc_typeck/check/compare_method.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
801801
.span_to_snippet(trait_m.generics.span)
802802
.ok()?;
803803

804-
err.multipart_suggestion(
804+
err.multipart_suggestion_with_applicability(
805805
"try changing the `impl Trait` argument to a generic parameter",
806806
vec![
807807
// replace `impl Trait` with `T`
@@ -811,6 +811,7 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
811811
// of the generics, but it works for the common case
812812
(generics_span, new_generics),
813813
],
814+
Applicability::Unspecified,
814815
);
815816
Some(())
816817
})();
@@ -872,14 +873,15 @@ fn compare_synthetic_generics<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
872873
.span_to_snippet(bounds)
873874
.ok()?;
874875

875-
err.multipart_suggestion(
876+
err.multipart_suggestion_with_applicability(
876877
"try removing the generic parameter and using `impl Trait` instead",
877878
vec![
878879
// delete generic parameters
879880
(impl_m.generics.span, String::new()),
880881
// replace param usage with `impl Trait`
881882
(span, format!("impl {}", bounds)),
882883
],
884+
Applicability::Unspecified,
883885
);
884886
Some(())
885887
})();

src/librustc_typeck/check/demand.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,11 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
132132
let expr_text = print::to_string(print::NO_ANN, |s| s.print_expr(expr));
133133
let suggestions = compatible_variants.iter()
134134
.map(|v| format!("{}({})", v, expr_text)).collect::<Vec<_>>();
135-
err.span_suggestions(expr.span,
135+
err.span_suggestions_with_applicability(expr.span,
136136
"try using a variant of the expected type",
137-
suggestions);
137+
suggestions,
138+
Applicability::Unspecified,
139+
);
138140
}
139141
}
140142

src/librustc_typeck/check/op.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,12 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
464464
is_assign,
465465
) {
466466
(Ok(l), Ok(r), false) => {
467-
err.multipart_suggestion(msg, vec![
467+
err.multipart_suggestion_with_applicability(msg, vec![
468468
(lhs_expr.span, format!("{}.to_owned()", l)),
469469
(rhs_expr.span, format!("&{}", r)),
470-
]);
470+
],
471+
Applicability::Unspecified,
472+
);
471473
}
472474
_ => {
473475
err.help(msg);

src/libsyntax_ext/format.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -996,9 +996,10 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt,
996996
));
997997
}
998998
if suggestions.len() > 0 {
999-
diag.multipart_suggestion(
999+
diag.multipart_suggestion_with_applicability(
10001000
"format specifiers use curly braces",
10011001
suggestions,
1002+
Applicability::Unspecified,
10021003
);
10031004
}
10041005
}};

0 commit comments

Comments
 (0)