Skip to content

Commit

Permalink
Readd backticks around ()
Browse files Browse the repository at this point in the history
  • Loading branch information
estebank committed Aug 9, 2017
1 parent 3fcdb8b commit 9bd62a4
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 19 deletions.
19 changes: 4 additions & 15 deletions src/librustc_typeck/check/mod.rs
Expand Up @@ -95,7 +95,7 @@ use rustc::middle::region::CodeExtent;
use rustc::ty::subst::{Kind, Subst, Substs};
use rustc::traits::{self, FulfillmentContext, ObligationCause, ObligationCauseCode};
use rustc::ty::{ParamTy, LvaluePreference, NoPreference, PreferMutLvalue};
use rustc::ty::{self, Ty, TyCtxt, Visibility, TypeVariants};
use rustc::ty::{self, Ty, TyCtxt, Visibility};
use rustc::ty::adjustment::{Adjust, Adjustment, AutoBorrow};
use rustc::ty::fold::{BottomUpFolder, TypeFoldable};
use rustc::ty::maps::Providers;
Expand Down Expand Up @@ -4315,7 +4315,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
(&hir::FunctionRetTy::DefaultReturn(span), _, _) => {
// `fn main()` must return `()`, do not suggest changing return type
err.span_label(span, "expected () because of default return type");
err.span_label(span, "expected `()` because of default return type");
}
(&hir::FunctionRetTy::Return(ref ty), _, _) => {
// Only point to return type if the expected type is the return type, as if they
Expand All @@ -4326,19 +4326,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
debug!("suggest_missing_return_type: return type sty {:?}", ty.sty);
debug!("suggest_missing_return_type: expected type sty {:?}", ty.sty);
if ty.sty == expected.sty {
let quote = if let TypeVariants::TyTuple(ref slice, _) = expected.sty {
if slice.len() == 0 { // don't use backtics for ()
""
} else {
"`"
}
} else {
"`"
};
err.span_label(sp, format!("expected {}{}{} because of return type",
quote,
expected,
quote));
err.span_label(sp, format!("expected `{}` because of return type",
expected));
}
}
}
Expand Down
Expand Up @@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/block-must-not-have-result-res.rs:15:9
|
14 | fn drop(&mut self) {
| - expected () because of default return type
| - expected `()` because of default return type
15 | true //~ ERROR mismatched types
| ^^^^ expected (), found bool
|
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/block-result/issue-13624.stderr
Expand Up @@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-13624.rs:17:5
|
16 | pub fn get_enum_struct_variant() -> () {
| -- expected () because of return type
| -- expected `()` because of return type
17 | Enum::EnumStructVariant { x: 1, y: 2, z: 3 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected (), found enum `a::Enum`
|
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/block-result/issue-22645.stderr
Expand Up @@ -12,7 +12,7 @@ error[E0308]: mismatched types
--> $DIR/issue-22645.rs:25:3
|
23 | fn main() {
| - expected () because of default return type
| - expected `()` because of default return type
24 | let b = Bob + 3.5;
25 | b + 3 //~ ERROR E0277
| ^^^^^ expected (), found struct `Bob`
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/block-result/issue-5500.stderr
Expand Up @@ -2,7 +2,7 @@ error[E0308]: mismatched types
--> $DIR/issue-5500.rs:12:5
|
11 | fn main() {
| - expected () because of default return type
| - expected `()` because of default return type
12 | &panic!()
| ^^^^^^^^^ expected (), found reference
|
Expand Down

0 comments on commit 9bd62a4

Please sign in to comment.