Skip to content

Commit 29cb86c

Browse files
committed
renaming test cases
1 parent 877458b commit 29cb86c

File tree

4 files changed

+13
-52
lines changed

4 files changed

+13
-52
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

-39
Original file line numberDiff line numberDiff line change
@@ -1800,45 +1800,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
18001800
}
18011801
}
18021802

1803-
/// A common error is to add an extra semicolon:
1804-
///
1805-
/// ```compile_fail,E0308
1806-
/// fn foo() -> usize {
1807-
/// 22;
1808-
/// }
1809-
/// ```
1810-
///
1811-
/// This routine checks if the final statement in a block is an
1812-
/// expression with an explicit semicolon whose type is compatible
1813-
/// with `expected_ty`. If so, it suggests removing the semicolon.
1814-
pub(crate) fn consider_removing_semicolon(
1815-
&self,
1816-
blk: &'tcx hir::Block<'tcx>,
1817-
expected_ty: Ty<'tcx>,
1818-
err: &mut DiagnosticBuilder<'_>,
1819-
) -> bool {
1820-
if let Some((span_semi, boxed)) = self.err_ctxt().could_remove_semicolon(blk, expected_ty) {
1821-
if let StatementAsExpression::NeedsBoxing = boxed {
1822-
err.span_suggestion_verbose(
1823-
span_semi,
1824-
"consider removing this semicolon and boxing the expression",
1825-
"",
1826-
Applicability::HasPlaceholders,
1827-
);
1828-
} else {
1829-
err.span_suggestion_short(
1830-
span_semi,
1831-
"remove this semicolon to return this value",
1832-
"",
1833-
Applicability::MachineApplicable,
1834-
);
1835-
}
1836-
true
1837-
} else {
1838-
false
1839-
}
1840-
}
1841-
18421803
pub(crate) fn is_field_suggestable(
18431804
&self,
18441805
field: &ty::FieldDef,

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
302302
&self,
303303
cause: &ObligationCause<'tcx>,
304304
exp_found: &ty::error::ExpectedFound<Ty<'tcx>>,
305-
diag: &mut Diagnostic,
305+
diag: &mut DiagnosticBuilder<'_>,
306306
) {
307307
let ty::error::ExpectedFound { expected, found } = exp_found;
308308
if !found.peel_refs().is_unit() {
@@ -365,18 +365,18 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
365365
&self,
366366
blk: &'tcx hir::Block<'tcx>,
367367
expected_ty: Ty<'tcx>,
368-
err: &mut Diagnostic,
368+
diag: &mut DiagnosticBuilder<'_>,
369369
) -> bool {
370370
if let Some((span_semi, boxed)) = self.could_remove_semicolon(blk, expected_ty) {
371371
if let StatementAsExpression::NeedsBoxing = boxed {
372-
err.span_suggestion_verbose(
372+
diag.span_suggestion_verbose(
373373
span_semi,
374374
"consider removing this semicolon and boxing the expression",
375375
"",
376376
Applicability::HasPlaceholders,
377377
);
378378
} else {
379-
err.span_suggestion_short(
379+
diag.span_suggestion_short(
380380
span_semi,
381381
"remove this semicolon to return this value",
382382
"",

tests/ui/inference/issue-105431-stmts-as-exp.stderr renamed to tests/ui/inference/stmts-as-exp-105431.stderr

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/issue-105431-stmts-as-exp.rs:11:5
2+
--> $DIR/stmts-as-exp-105431.rs:11:5
33
|
44
LL | fn test_if() -> i32 {
55
| --- expected `i32` because of return type
@@ -19,7 +19,7 @@ LL + 4
1919
|
2020

2121
error[E0308]: mismatched types
22-
--> $DIR/issue-105431-stmts-as-exp.rs:15:13
22+
--> $DIR/stmts-as-exp-105431.rs:15:13
2323
|
2424
LL | if true {
2525
| _____________^
@@ -30,7 +30,7 @@ LL | | }
3030
| |_____^ expected `i32`, found `()`
3131

3232
error[E0308]: mismatched types
33-
--> $DIR/issue-105431-stmts-as-exp.rs:19:10
33+
--> $DIR/stmts-as-exp-105431.rs:19:10
3434
|
3535
LL | else {
3636
| __________^
@@ -40,7 +40,7 @@ LL | | }
4040
| |_____^ expected `i32`, found `()`
4141

4242
error[E0308]: mismatched types
43-
--> $DIR/issue-105431-stmts-as-exp.rs:30:5
43+
--> $DIR/stmts-as-exp-105431.rs:30:5
4444
|
4545
LL | fn test_match() -> i32 {
4646
| --- expected `i32` because of return type
@@ -60,7 +60,7 @@ LL + _ => { 2 }
6060
|
6161

6262
error[E0308]: mismatched types
63-
--> $DIR/issue-105431-stmts-as-exp.rs:36:14
63+
--> $DIR/stmts-as-exp-105431.rs:36:14
6464
|
6565
LL | 1 => { 1; }
6666
| ^^^-^^
@@ -69,7 +69,7 @@ LL | 1 => { 1; }
6969
| expected `i32`, found `()`
7070

7171
error[E0308]: mismatched types
72-
--> $DIR/issue-105431-stmts-as-exp.rs:37:14
72+
--> $DIR/stmts-as-exp-105431.rs:37:14
7373
|
7474
LL | _ => { 2; }
7575
| ^^^-^^
@@ -78,7 +78,7 @@ LL | _ => { 2; }
7878
| expected `i32`, found `()`
7979

8080
error[E0308]: `match` arms have incompatible types
81-
--> $DIR/issue-105431-stmts-as-exp.rs:45:16
81+
--> $DIR/stmts-as-exp-105431.rs:45:16
8282
|
8383
LL | let res = match v {
8484
| _______________-
@@ -93,7 +93,7 @@ LL | | };
9393
| |_____- `match` arms have incompatible types
9494

9595
error[E0308]: mismatched types
96-
--> $DIR/issue-105431-stmts-as-exp.rs:59:5
96+
--> $DIR/stmts-as-exp-105431.rs:59:5
9797
|
9898
LL | fn test_if_match_mixed() -> i32 {
9999
| --- expected `i32` because of return type
@@ -113,7 +113,7 @@ LL + }
113113
|
114114

115115
error[E0308]: mismatched types
116-
--> $DIR/issue-105431-stmts-as-exp.rs:72:5
116+
--> $DIR/stmts-as-exp-105431.rs:72:5
117117
|
118118
LL | fn test_if_match_mixed_failed() -> i32 {
119119
| --- expected `i32` because of return type

0 commit comments

Comments
 (0)