Skip to content

Commit 67e91e9

Browse files
Format
1 parent a0452d3 commit 67e91e9

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
@@ -639,7 +639,10 @@ impl<'hir> Generics<'hir> {
639639
/// Returns bounds span for suggestions.
640640
/// If the span including lifetime bound needs parentheses, it returns a span to the open parenthese at the second item.
641641
/// e.g. `dyn Future<Output = ()> + 'static` needs parentheses `(dyn Future<Output = ()>) + 'static`
642-
pub fn bounds_span_for_suggestions(&self, param_def_id: LocalDefId) -> Option<(Span, Option<Span>)> {
642+
pub fn bounds_span_for_suggestions(
643+
&self,
644+
param_def_id: LocalDefId,
645+
) -> Option<(Span, Option<Span>)> {
643646
fn get_inner_ty<'a, 'b>(bound: &'a GenericBound<'b>) -> Option<&'a Ty<'b>> {
644647
match bound {
645648
GenericBound::Trait(data, _) => {

compiler/rustc_hir_typeck/src/method/suggest.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -3278,7 +3278,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
32783278
param.name.ident(),
32793279
));
32803280
let bounds_span = ast_generics.bounds_span_for_suggestions(def_id);
3281-
if rcvr_ty.is_ref() && param.is_impl_trait() && let Some((bounds_span, _)) = bounds_span {
3281+
if rcvr_ty.is_ref()
3282+
&& param.is_impl_trait()
3283+
&& let Some((bounds_span, _)) = bounds_span
3284+
{
32823285
err.multipart_suggestions(
32833286
msg,
32843287
candidates.iter().map(|t| {

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

+1-2
Original file line numberDiff line numberDiff line change
@@ -2402,8 +2402,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
24022402
// We do this to avoid suggesting code that ends up as `T: 'a'b`,
24032403
// instead we suggest `T: 'a + 'b` in that case.
24042404
let hir_generics = self.tcx.hir().get_generics(scope).unwrap();
2405-
let sugg_span = match hir_generics.bounds_span_for_suggestions(def_id)
2406-
{
2405+
let sugg_span = match hir_generics.bounds_span_for_suggestions(def_id) {
24072406
Some((span, open_paren_sp)) => Some((span, true, open_paren_sp)),
24082407
// If `param` corresponds to `Self`, no usable suggestion span.
24092408
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
@@ -2931,12 +2931,12 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
29312931
_ => {}
29322932
};
29332933
// Didn't add an indirection suggestion, so add a general suggestion to relax `Sized`.
2934-
let (span, separator) = if let Some((s, _)) = generics.bounds_span_for_suggestions(param.def_id)
2935-
{
2936-
(s, " +")
2937-
} else {
2938-
(param.name.ident().span.shrink_to_hi(), ":")
2939-
};
2934+
let (span, separator) =
2935+
if let Some((s, _)) = generics.bounds_span_for_suggestions(param.def_id) {
2936+
(s, " +")
2937+
} else {
2938+
(param.name.ident().span.shrink_to_hi(), ":")
2939+
};
29402940
err.span_suggestion_verbose(
29412941
span,
29422942
"consider relaxing the implicit `Sized` restriction",

0 commit comments

Comments
 (0)