Skip to content

Commit 9bd62a4

Browse files
committed
Readd backticks around ()
1 parent 3fcdb8b commit 9bd62a4

File tree

5 files changed

+8
-19
lines changed

5 files changed

+8
-19
lines changed

Diff for: src/librustc_typeck/check/mod.rs

+4-15
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ use rustc::middle::region::CodeExtent;
9595
use rustc::ty::subst::{Kind, Subst, Substs};
9696
use rustc::traits::{self, FulfillmentContext, ObligationCause, ObligationCauseCode};
9797
use rustc::ty::{ParamTy, LvaluePreference, NoPreference, PreferMutLvalue};
98-
use rustc::ty::{self, Ty, TyCtxt, Visibility, TypeVariants};
98+
use rustc::ty::{self, Ty, TyCtxt, Visibility};
9999
use rustc::ty::adjustment::{Adjust, Adjustment, AutoBorrow};
100100
use rustc::ty::fold::{BottomUpFolder, TypeFoldable};
101101
use rustc::ty::maps::Providers;
@@ -4315,7 +4315,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
43154315
}
43164316
(&hir::FunctionRetTy::DefaultReturn(span), _, _) => {
43174317
// `fn main()` must return `()`, do not suggest changing return type
4318-
err.span_label(span, "expected () because of default return type");
4318+
err.span_label(span, "expected `()` because of default return type");
43194319
}
43204320
(&hir::FunctionRetTy::Return(ref ty), _, _) => {
43214321
// Only point to return type if the expected type is the return type, as if they
@@ -4326,19 +4326,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
43264326
debug!("suggest_missing_return_type: return type sty {:?}", ty.sty);
43274327
debug!("suggest_missing_return_type: expected type sty {:?}", ty.sty);
43284328
if ty.sty == expected.sty {
4329-
let quote = if let TypeVariants::TyTuple(ref slice, _) = expected.sty {
4330-
if slice.len() == 0 { // don't use backtics for ()
4331-
""
4332-
} else {
4333-
"`"
4334-
}
4335-
} else {
4336-
"`"
4337-
};
4338-
err.span_label(sp, format!("expected {}{}{} because of return type",
4339-
quote,
4340-
expected,
4341-
quote));
4329+
err.span_label(sp, format!("expected `{}` because of return type",
4330+
expected));
43424331
}
43434332
}
43444333
}

Diff for: src/test/ui/block-result/block-must-not-have-result-res.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/block-must-not-have-result-res.rs:15:9
33
|
44
14 | fn drop(&mut self) {
5-
| - expected () because of default return type
5+
| - expected `()` because of default return type
66
15 | true //~ ERROR mismatched types
77
| ^^^^ expected (), found bool
88
|

Diff for: src/test/ui/block-result/issue-13624.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/issue-13624.rs:17:5
33
|
44
16 | pub fn get_enum_struct_variant() -> () {
5-
| -- expected () because of return type
5+
| -- expected `()` because of return type
66
17 | Enum::EnumStructVariant { x: 1, y: 2, z: 3 }
77
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum `a::Enum`
88
|

Diff for: src/test/ui/block-result/issue-22645.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ error[E0308]: mismatched types
1212
--> $DIR/issue-22645.rs:25:3
1313
|
1414
23 | fn main() {
15-
| - expected () because of default return type
15+
| - expected `()` because of default return type
1616
24 | let b = Bob + 3.5;
1717
25 | b + 3 //~ ERROR E0277
1818
| ^^^^^ expected (), found struct `Bob`

Diff for: src/test/ui/block-result/issue-5500.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/issue-5500.rs:12:5
33
|
44
11 | fn main() {
5-
| - expected () because of default return type
5+
| - expected `()` because of default return type
66
12 | &panic!()
77
| ^^^^^^^^^ expected (), found reference
88
|

0 commit comments

Comments
 (0)