Readd backticks around ()
This commit is contained in:
parent
3fcdb8ba72
commit
9bd62a4691
@ -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;
|
||||
@ -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
|
||||
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
|
||||
|
@ -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`
|
||||
|
|
||||
|
@ -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`
|
||||
|
@ -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
|
||||
|
|
||||
|
Loading…
x
Reference in New Issue
Block a user