Skip to content

Commit d5d2fb6

Browse files
committed
Some more fixes
1 parent ce9c34f commit d5d2fb6

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

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

+9-6
Original file line numberDiff line numberDiff line change
@@ -717,9 +717,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
717717
err.multipart_suggestion(
718718
"consider removing this semicolon and boxing the expressions",
719719
vec![
720-
(prior_arm.shrink_to_lo(), "box (".to_string()),
720+
(prior_arm.shrink_to_lo(), "Box::new(".to_string()),
721721
(prior_arm.shrink_to_hi(), ")".to_string()),
722-
(arm_span.shrink_to_lo(), "box (".to_string()),
722+
(arm_span.shrink_to_lo(), "Box::new(".to_string()),
723723
(arm_span.shrink_to_hi(), ")".to_string()),
724724
(sp, String::new()),
725725
],
@@ -767,9 +767,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
767767
err.multipart_suggestion(
768768
"consider removing this semicolon and boxing the expression",
769769
vec![
770-
(then.shrink_to_lo(), "box (".to_string()),
770+
(then.shrink_to_lo(), "Box::new(".to_string()),
771771
(then.shrink_to_hi(), ")".to_string()),
772-
(else_sp.shrink_to_lo(), "box (".to_string()),
772+
(else_sp.shrink_to_lo(), "Box::new(".to_string()),
773773
(else_sp.shrink_to_hi(), ")".to_string()),
774774
(sp, String::new()),
775775
],
@@ -812,8 +812,11 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
812812
);
813813
let sugg = arm_spans
814814
.flat_map(|sp| {
815-
vec![(sp.shrink_to_lo(), "box (".to_string()), (sp.shrink_to_hi(), ")".to_string())]
816-
.into_iter()
815+
vec![
816+
(sp.shrink_to_lo(), "Box::new(".to_string()),
817+
(sp.shrink_to_hi(), ")".to_string()),
818+
]
819+
.into_iter()
817820
})
818821
.collect::<Vec<_>>();
819822
err.multipart_suggestion(

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1157,14 +1157,14 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
11571157
err.note(impl_trait_msg);
11581158
} else {
11591159
if is_object_safe {
1160-
// Suggest `-> Box<dyn Trait>` and `box (returned_value)`.
1160+
// Suggest `-> Box<dyn Trait>` and `Box::new(returned_value)`.
11611161
// Get all the return values and collect their span and suggestion.
11621162
let mut suggestions: Vec<_> = visitor
11631163
.returns
11641164
.iter()
11651165
.flat_map(|expr| {
11661166
vec![
1167-
(expr.span.shrink_to_lo(), "box (".to_string()),
1167+
(expr.span.shrink_to_lo(), "Box::new(".to_string()),
11681168
(expr.span.shrink_to_hi(), ")".to_string()),
11691169
]
11701170
.into_iter()

compiler/rustc_typeck/src/check/coercion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
16081608
.into_iter()
16091609
.flat_map(|sp| {
16101610
vec![
1611-
(sp.shrink_to_lo(), "box (".to_string()),
1611+
(sp.shrink_to_lo(), "Box::new(".to_string()),
16121612
(sp.shrink_to_hi(), ")".to_string()),
16131613
]
16141614
.into_iter()

0 commit comments

Comments
 (0)