Add backticks to various diagnostics
This commit is contained in:
parent
760ce94c69
commit
0c2cf07d6e
|
@ -661,7 +661,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
},
|
},
|
||||||
ObligationCauseCode::IfExpression(box IfExpressionCause { then, outer, semicolon }) => {
|
ObligationCauseCode::IfExpression(box IfExpressionCause { then, outer, semicolon }) => {
|
||||||
err.span_label(then, "expected because of this");
|
err.span_label(then, "expected because of this");
|
||||||
outer.map(|sp| err.span_label(sp, "if and else have incompatible types"));
|
outer.map(|sp| err.span_label(sp, "`if` and `else` have incompatible types"));
|
||||||
if let Some(sp) = semicolon {
|
if let Some(sp) = semicolon {
|
||||||
err.span_suggestion_short(
|
err.span_suggestion_short(
|
||||||
sp,
|
sp,
|
||||||
|
@ -1883,13 +1883,13 @@ impl<'tcx> ObligationCause<'tcx> {
|
||||||
hir::MatchSource::TryDesugar => {
|
hir::MatchSource::TryDesugar => {
|
||||||
"try expression alternatives have incompatible types"
|
"try expression alternatives have incompatible types"
|
||||||
}
|
}
|
||||||
_ => "match arms have incompatible types",
|
_ => "`match` arms have incompatible types",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
IfExpression { .. } => Error0308("if and else have incompatible types"),
|
IfExpression { .. } => Error0308("`if` and `else` have incompatible types"),
|
||||||
IfExpressionWithNoElse => Error0317("if may be missing an else clause"),
|
IfExpressionWithNoElse => Error0317("`if` may be missing an `else` clause"),
|
||||||
MainFunctionType => Error0580("main function has wrong type"),
|
MainFunctionType => Error0580("`main` function has wrong type"),
|
||||||
StartFunctionType => Error0308("start function has wrong type"),
|
StartFunctionType => Error0308("`#[start]` function has wrong type"),
|
||||||
IntrinsicType => Error0308("intrinsic has wrong type"),
|
IntrinsicType => Error0308("intrinsic has wrong type"),
|
||||||
MethodReceiver => Error0308("mismatched `self` parameter type"),
|
MethodReceiver => Error0308("mismatched `self` parameter type"),
|
||||||
|
|
||||||
|
@ -1917,12 +1917,12 @@ impl<'tcx> ObligationCause<'tcx> {
|
||||||
ExprAssignable => "expression is assignable",
|
ExprAssignable => "expression is assignable",
|
||||||
MatchExpressionArm(box MatchExpressionArmCause { source, .. }) => match source {
|
MatchExpressionArm(box MatchExpressionArmCause { source, .. }) => match source {
|
||||||
hir::MatchSource::IfLetDesugar { .. } => "`if let` arms have compatible types",
|
hir::MatchSource::IfLetDesugar { .. } => "`if let` arms have compatible types",
|
||||||
_ => "match arms have compatible types",
|
_ => "`match` arms have compatible types",
|
||||||
},
|
},
|
||||||
IfExpression { .. } => "if and else have incompatible types",
|
IfExpression { .. } => "`if` and `else` have incompatible types",
|
||||||
IfExpressionWithNoElse => "if missing an else returns ()",
|
IfExpressionWithNoElse => "`if` missing an `else` returns `()`",
|
||||||
MainFunctionType => "`main` function has the correct type",
|
MainFunctionType => "`main` function has the correct type",
|
||||||
StartFunctionType => "`start` function has the correct type",
|
StartFunctionType => "`#[start]` function has the correct type",
|
||||||
IntrinsicType => "intrinsic has the correct type",
|
IntrinsicType => "intrinsic has the correct type",
|
||||||
MethodReceiver => "method receiver has the correct type",
|
MethodReceiver => "method receiver has the correct type",
|
||||||
_ => "types are compatible",
|
_ => "types are compatible",
|
||||||
|
|
|
@ -134,7 +134,7 @@ fn find_item(item: &Item<'_>, ctxt: &mut EntryContext<'_, '_>, at_root: bool) {
|
||||||
ctxt.start_fn = Some((item.hir_id, item.span));
|
ctxt.start_fn = Some((item.hir_id, item.span));
|
||||||
} else {
|
} else {
|
||||||
struct_span_err!(ctxt.session, item.span, E0138, "multiple `start` functions")
|
struct_span_err!(ctxt.session, item.span, E0138, "multiple `start` functions")
|
||||||
.span_label(ctxt.start_fn.unwrap().1, "previous `start` function here")
|
.span_label(ctxt.start_fn.unwrap().1, "previous `#[start]` function here")
|
||||||
.span_label(item.span, "multiple `start` functions")
|
.span_label(item.span, "multiple `start` functions")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,7 +81,7 @@ pub fn options() -> TargetOptions {
|
||||||
dynamic_linking: true,
|
dynamic_linking: true,
|
||||||
only_cdylib: true,
|
only_cdylib: true,
|
||||||
|
|
||||||
// This means we'll just embed a `start` function in the wasm module
|
// This means we'll just embed a `#[start]` function in the wasm module
|
||||||
executables: true,
|
executables: true,
|
||||||
|
|
||||||
// relatively self-explanatory!
|
// relatively self-explanatory!
|
||||||
|
|
|
@ -298,7 +298,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// LL || 10u32
|
// LL || 10u32
|
||||||
// || ^^^^^ expected `i32`, found `u32`
|
// || ^^^^^ expected `i32`, found `u32`
|
||||||
// LL || };
|
// LL || };
|
||||||
// ||_____- if and else have incompatible types
|
// ||_____- `if` and `else` have incompatible types
|
||||||
// ```
|
// ```
|
||||||
Some(span)
|
Some(span)
|
||||||
} else {
|
} else {
|
||||||
|
@ -340,7 +340,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
// by not pointing at the entire expression:
|
// by not pointing at the entire expression:
|
||||||
// ```
|
// ```
|
||||||
// 2 | let x = if true {
|
// 2 | let x = if true {
|
||||||
// | ------- if and else have incompatible types
|
// | ------- `if` and `else` have incompatible types
|
||||||
// 3 | 3
|
// 3 | 3
|
||||||
// | - expected because of this
|
// | - expected because of this
|
||||||
// 4 | } else {
|
// 4 | } else {
|
||||||
|
|
|
@ -387,8 +387,8 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
|
||||||
&self,
|
&self,
|
||||||
start,
|
start,
|
||||||
i.span,
|
i.span,
|
||||||
"a `#[start]` function is an experimental \
|
"`#[start]` functions are experimental \
|
||||||
feature whose signature may change \
|
and their signature may change \
|
||||||
over time"
|
over time"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// edition:2018
|
// edition:2018
|
||||||
async fn f() -> i32 {
|
async fn f() -> i32 {
|
||||||
if true { //~ ERROR if may be missing an else clause
|
if true { //~ ERROR `if` may be missing an `else` clause
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
// An `if` block without `else` causes the type table not to have a type for this expr.
|
// An `if` block without `else` causes the type table not to have a type for this expr.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0317]: if may be missing an else clause
|
error[E0317]: `if` may be missing an `else` clause
|
||||||
--> $DIR/issue-66387-if-without-else.rs:3:5
|
--> $DIR/issue-66387-if-without-else.rs:3:5
|
||||||
|
|
|
|
||||||
LL | / if true {
|
LL | / if true {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
mod m1 {}
|
mod m1 {}
|
||||||
|
|
||||||
fn main(arguments: Vec<String>) { //~ ERROR main function has wrong type
|
fn main(arguments: Vec<String>) { //~ ERROR `main` function has wrong type
|
||||||
log(debug, m1::arguments);
|
log(debug, m1::arguments);
|
||||||
//~^ ERROR cannot find function `log` in this scope
|
//~^ ERROR cannot find function `log` in this scope
|
||||||
//~| ERROR cannot find value `debug` in this scope
|
//~| ERROR cannot find value `debug` in this scope
|
||||||
|
|
|
@ -16,7 +16,7 @@ error[E0425]: cannot find value `arguments` in module `m1`
|
||||||
LL | log(debug, m1::arguments);
|
LL | log(debug, m1::arguments);
|
||||||
| ^^^^^^^^^ not found in `m1`
|
| ^^^^^^^^^ not found in `m1`
|
||||||
|
|
||||||
error[E0580]: main function has wrong type
|
error[E0580]: `main` function has wrong type
|
||||||
--> $DIR/bad-expr-path.rs:3:1
|
--> $DIR/bad-expr-path.rs:3:1
|
||||||
|
|
|
|
||||||
LL | fn main(arguments: Vec<String>) {
|
LL | fn main(arguments: Vec<String>) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ mod m1 {
|
||||||
pub mod arguments {}
|
pub mod arguments {}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main(arguments: Vec<String>) { //~ ERROR main function has wrong type
|
fn main(arguments: Vec<String>) { //~ ERROR `main` function has wrong type
|
||||||
log(debug, m1::arguments);
|
log(debug, m1::arguments);
|
||||||
//~^ ERROR cannot find function `log` in this scope
|
//~^ ERROR cannot find function `log` in this scope
|
||||||
//~| ERROR cannot find value `debug` in this scope
|
//~| ERROR cannot find value `debug` in this scope
|
||||||
|
|
|
@ -16,7 +16,7 @@ error[E0423]: expected value, found module `m1::arguments`
|
||||||
LL | log(debug, m1::arguments);
|
LL | log(debug, m1::arguments);
|
||||||
| ^^^^^^^^^^^^^ not a value
|
| ^^^^^^^^^^^^^ not a value
|
||||||
|
|
||||||
error[E0580]: main function has wrong type
|
error[E0580]: `main` function has wrong type
|
||||||
--> $DIR/bad-expr-path2.rs:5:1
|
--> $DIR/bad-expr-path2.rs:5:1
|
||||||
|
|
|
|
||||||
LL | fn main(arguments: Vec<String>) {
|
LL | fn main(arguments: Vec<String>) {
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
fn main(x: isize) { } //~ ERROR: main function has wrong type [E0580]
|
fn main(x: isize) { } //~ ERROR: `main` function has wrong type [E0580]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0580]: main function has wrong type
|
error[E0580]: `main` function has wrong type
|
||||||
--> $DIR/bad-main.rs:1:1
|
--> $DIR/bad-main.rs:1:1
|
||||||
|
|
|
|
||||||
LL | fn main(x: isize) { }
|
LL | fn main(x: isize) { }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0317]: if may be missing an else clause
|
error[E0317]: `if` may be missing an `else` clause
|
||||||
--> $DIR/issue-50577.rs:7:16
|
--> $DIR/issue-50577.rs:7:16
|
||||||
|
|
|
|
||||||
LL | Drop = assert_eq!(1, 1)
|
LL | Drop = assert_eq!(1, 1)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
enum Foo {
|
enum Foo {
|
||||||
Drop = assert_eq!(1, 1)
|
Drop = assert_eq!(1, 1)
|
||||||
//[stock,if_match]~^ ERROR if may be missing an else clause
|
//[stock,if_match]~^ ERROR `if` may be missing an `else` clause
|
||||||
//[stock]~^^ ERROR `match` is not allowed in a `const`
|
//[stock]~^^ ERROR `match` is not allowed in a `const`
|
||||||
//[stock]~| ERROR `match` is not allowed in a `const`
|
//[stock]~| ERROR `match` is not allowed in a `const`
|
||||||
//[stock]~| ERROR `if` is not allowed in a `const`
|
//[stock]~| ERROR `if` is not allowed in a `const`
|
||||||
|
|
|
@ -28,7 +28,7 @@ LL | Drop = assert_eq!(1, 1)
|
||||||
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
|
= help: add `#![feature(const_if_match)]` to the crate attributes to enable
|
||||||
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
|
||||||
|
|
||||||
error[E0317]: if may be missing an else clause
|
error[E0317]: `if` may be missing an `else` clause
|
||||||
--> $DIR/issue-50577.rs:7:16
|
--> $DIR/issue-50577.rs:7:16
|
||||||
|
|
|
|
||||||
LL | Drop = assert_eq!(1, 1)
|
LL | Drop = assert_eq!(1, 1)
|
||||||
|
|
|
@ -2,7 +2,7 @@ error[E0138]: multiple `start` functions
|
||||||
--> $DIR/E0138.rs:7:1
|
--> $DIR/E0138.rs:7:1
|
||||||
|
|
|
|
||||||
LL | fn foo(argc: isize, argv: *const *const u8) -> isize { 0 }
|
LL | fn foo(argc: isize, argv: *const *const u8) -> isize { 0 }
|
||||||
| ---------------------------------------------------------- previous `start` function here
|
| ---------------------------------------------------------- previous `#[start]` function here
|
||||||
...
|
...
|
||||||
LL | fn f(argc: isize, argv: *const *const u8) -> isize { 0 }
|
LL | fn f(argc: isize, argv: *const *const u8) -> isize { 0 }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ multiple `start` functions
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ multiple `start` functions
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
extern fn main() {} //~ ERROR: main function has wrong type [E0580]
|
extern fn main() {} //~ ERROR: `main` function has wrong type [E0580]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0580]: main function has wrong type
|
error[E0580]: `main` function has wrong type
|
||||||
--> $DIR/extern-main-fn.rs:1:1
|
--> $DIR/extern-main-fn.rs:1:1
|
||||||
|
|
|
|
||||||
LL | extern fn main() {}
|
LL | extern fn main() {}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
#[start]
|
#[start]
|
||||||
fn foo(_: isize, _: *const *const u8) -> isize { 0 }
|
fn foo(_: isize, _: *const *const u8) -> isize { 0 }
|
||||||
//~^ ERROR a `#[start]` function is an experimental feature
|
//~^ ERROR `#[start]` functions are experimental
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0658]: a `#[start]` function is an experimental feature whose signature may change over time
|
error[E0658]: `#[start]` functions are experimental and their signature may change over time
|
||||||
--> $DIR/feature-gate-start.rs:2:1
|
--> $DIR/feature-gate-start.rs:2:1
|
||||||
|
|
|
|
||||||
LL | fn foo(_: isize, _: *const *const u8) -> isize { 0 }
|
LL | fn foo(_: isize, _: *const *const u8) -> isize { 0 }
|
||||||
|
|
|
@ -4,43 +4,43 @@ fn main() {
|
||||||
} else {
|
} else {
|
||||||
2u32
|
2u32
|
||||||
};
|
};
|
||||||
//~^^ ERROR if and else have incompatible types
|
//~^^ ERROR `if` and `else` have incompatible types
|
||||||
let _ = if true { 42i32 } else { 42u32 };
|
let _ = if true { 42i32 } else { 42u32 };
|
||||||
//~^ ERROR if and else have incompatible types
|
//~^ ERROR `if` and `else` have incompatible types
|
||||||
let _ = if true {
|
let _ = if true {
|
||||||
3u32;
|
3u32;
|
||||||
} else {
|
} else {
|
||||||
4u32
|
4u32
|
||||||
};
|
};
|
||||||
//~^^ ERROR if and else have incompatible types
|
//~^^ ERROR `if` and `else` have incompatible types
|
||||||
let _ = if true {
|
let _ = if true {
|
||||||
5u32
|
5u32
|
||||||
} else {
|
} else {
|
||||||
6u32;
|
6u32;
|
||||||
};
|
};
|
||||||
//~^^ ERROR if and else have incompatible types
|
//~^^ ERROR `if` and `else` have incompatible types
|
||||||
let _ = if true {
|
let _ = if true {
|
||||||
7i32;
|
7i32;
|
||||||
} else {
|
} else {
|
||||||
8u32
|
8u32
|
||||||
};
|
};
|
||||||
//~^^ ERROR if and else have incompatible types
|
//~^^ ERROR `if` and `else` have incompatible types
|
||||||
let _ = if true {
|
let _ = if true {
|
||||||
9i32
|
9i32
|
||||||
} else {
|
} else {
|
||||||
10u32;
|
10u32;
|
||||||
};
|
};
|
||||||
//~^^ ERROR if and else have incompatible types
|
//~^^ ERROR `if` and `else` have incompatible types
|
||||||
let _ = if true {
|
let _ = if true {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
11u32
|
11u32
|
||||||
};
|
};
|
||||||
//~^^ ERROR if and else have incompatible types
|
//~^^ ERROR `if` and `else` have incompatible types
|
||||||
let _ = if true {
|
let _ = if true {
|
||||||
12i32
|
12i32
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
};
|
};
|
||||||
//~^^^ ERROR if and else have incompatible types
|
//~^^^ ERROR `if` and `else` have incompatible types
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0308]: if and else have incompatible types
|
error[E0308]: `if` and `else` have incompatible types
|
||||||
--> $DIR/if-else-type-mismatch.rs:5:9
|
--> $DIR/if-else-type-mismatch.rs:5:9
|
||||||
|
|
|
|
||||||
LL | let _ = if true {
|
LL | let _ = if true {
|
||||||
|
@ -9,9 +9,9 @@ LL | | } else {
|
||||||
LL | | 2u32
|
LL | | 2u32
|
||||||
| | ^^^^ expected `i32`, found `u32`
|
| | ^^^^ expected `i32`, found `u32`
|
||||||
LL | | };
|
LL | | };
|
||||||
| |_____- if and else have incompatible types
|
| |_____- `if` and `else` have incompatible types
|
||||||
|
|
||||||
error[E0308]: if and else have incompatible types
|
error[E0308]: `if` and `else` have incompatible types
|
||||||
--> $DIR/if-else-type-mismatch.rs:8:38
|
--> $DIR/if-else-type-mismatch.rs:8:38
|
||||||
|
|
|
|
||||||
LL | let _ = if true { 42i32 } else { 42u32 };
|
LL | let _ = if true { 42i32 } else { 42u32 };
|
||||||
|
@ -19,7 +19,7 @@ LL | let _ = if true { 42i32 } else { 42u32 };
|
||||||
| |
|
| |
|
||||||
| expected because of this
|
| expected because of this
|
||||||
|
|
||||||
error[E0308]: if and else have incompatible types
|
error[E0308]: `if` and `else` have incompatible types
|
||||||
--> $DIR/if-else-type-mismatch.rs:13:9
|
--> $DIR/if-else-type-mismatch.rs:13:9
|
||||||
|
|
|
|
||||||
LL | let _ = if true {
|
LL | let _ = if true {
|
||||||
|
@ -33,9 +33,9 @@ LL | | } else {
|
||||||
LL | | 4u32
|
LL | | 4u32
|
||||||
| | ^^^^ expected `()`, found `u32`
|
| | ^^^^ expected `()`, found `u32`
|
||||||
LL | | };
|
LL | | };
|
||||||
| |_____- if and else have incompatible types
|
| |_____- `if` and `else` have incompatible types
|
||||||
|
|
||||||
error[E0308]: if and else have incompatible types
|
error[E0308]: `if` and `else` have incompatible types
|
||||||
--> $DIR/if-else-type-mismatch.rs:19:9
|
--> $DIR/if-else-type-mismatch.rs:19:9
|
||||||
|
|
|
|
||||||
LL | let _ = if true {
|
LL | let _ = if true {
|
||||||
|
@ -49,9 +49,9 @@ LL | | 6u32;
|
||||||
| | | help: consider removing this semicolon
|
| | | help: consider removing this semicolon
|
||||||
| | expected `u32`, found `()`
|
| | expected `u32`, found `()`
|
||||||
LL | | };
|
LL | | };
|
||||||
| |_____- if and else have incompatible types
|
| |_____- `if` and `else` have incompatible types
|
||||||
|
|
||||||
error[E0308]: if and else have incompatible types
|
error[E0308]: `if` and `else` have incompatible types
|
||||||
--> $DIR/if-else-type-mismatch.rs:25:9
|
--> $DIR/if-else-type-mismatch.rs:25:9
|
||||||
|
|
|
|
||||||
LL | let _ = if true {
|
LL | let _ = if true {
|
||||||
|
@ -62,9 +62,9 @@ LL | | } else {
|
||||||
LL | | 8u32
|
LL | | 8u32
|
||||||
| | ^^^^ expected `()`, found `u32`
|
| | ^^^^ expected `()`, found `u32`
|
||||||
LL | | };
|
LL | | };
|
||||||
| |_____- if and else have incompatible types
|
| |_____- `if` and `else` have incompatible types
|
||||||
|
|
||||||
error[E0308]: if and else have incompatible types
|
error[E0308]: `if` and `else` have incompatible types
|
||||||
--> $DIR/if-else-type-mismatch.rs:31:9
|
--> $DIR/if-else-type-mismatch.rs:31:9
|
||||||
|
|
|
|
||||||
LL | let _ = if true {
|
LL | let _ = if true {
|
||||||
|
@ -75,9 +75,9 @@ LL | | } else {
|
||||||
LL | | 10u32;
|
LL | | 10u32;
|
||||||
| | ^^^^^^ expected `i32`, found `()`
|
| | ^^^^^^ expected `i32`, found `()`
|
||||||
LL | | };
|
LL | | };
|
||||||
| |_____- if and else have incompatible types
|
| |_____- `if` and `else` have incompatible types
|
||||||
|
|
||||||
error[E0308]: if and else have incompatible types
|
error[E0308]: `if` and `else` have incompatible types
|
||||||
--> $DIR/if-else-type-mismatch.rs:37:9
|
--> $DIR/if-else-type-mismatch.rs:37:9
|
||||||
|
|
|
|
||||||
LL | let _ = if true {
|
LL | let _ = if true {
|
||||||
|
@ -88,11 +88,11 @@ LL | | } else {
|
||||||
LL | 11u32
|
LL | 11u32
|
||||||
| ^^^^^ expected `()`, found `u32`
|
| ^^^^^ expected `()`, found `u32`
|
||||||
|
|
||||||
error[E0308]: if and else have incompatible types
|
error[E0308]: `if` and `else` have incompatible types
|
||||||
--> $DIR/if-else-type-mismatch.rs:42:12
|
--> $DIR/if-else-type-mismatch.rs:42:12
|
||||||
|
|
|
|
||||||
LL | let _ = if true {
|
LL | let _ = if true {
|
||||||
| ------- if and else have incompatible types
|
| ------- `if` and `else` have incompatible types
|
||||||
LL | 12i32
|
LL | 12i32
|
||||||
| ----- expected because of this
|
| ----- expected because of this
|
||||||
LL | } else {
|
LL | } else {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
let x = if true { 10i32 } else { 10u32 };
|
let x = if true { 10i32 } else { 10u32 };
|
||||||
//~^ ERROR if and else have incompatible types
|
//~^ ERROR `if` and `else` have incompatible types
|
||||||
//~| expected `i32`, found `u32`
|
//~| expected `i32`, found `u32`
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0308]: if and else have incompatible types
|
error[E0308]: `if` and `else` have incompatible types
|
||||||
--> $DIR/if-branch-types.rs:2:38
|
--> $DIR/if-branch-types.rs:2:38
|
||||||
|
|
|
|
||||||
LL | let x = if true { 10i32 } else { 10u32 };
|
LL | let x = if true { 10i32 } else { 10u32 };
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
if let Some(b) = None {
|
if let Some(b) = None {
|
||||||
//~^ NOTE if and else have incompatible types
|
//~^ NOTE `if` and `else` have incompatible types
|
||||||
()
|
()
|
||||||
//~^ NOTE expected because of this
|
//~^ NOTE expected because of this
|
||||||
} else {
|
} else {
|
||||||
1
|
1
|
||||||
};
|
};
|
||||||
//~^^ ERROR: if and else have incompatible types
|
//~^^ ERROR: `if` and `else` have incompatible types
|
||||||
//~| NOTE expected `()`, found integer
|
//~| NOTE expected `()`, found integer
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0308]: if and else have incompatible types
|
error[E0308]: `if` and `else` have incompatible types
|
||||||
--> $DIR/if-let-arm-types.rs:7:9
|
--> $DIR/if-let-arm-types.rs:7:9
|
||||||
|
|
|
|
||||||
LL | / if let Some(b) = None {
|
LL | / if let Some(b) = None {
|
||||||
|
@ -10,7 +10,7 @@ LL | | } else {
|
||||||
LL | | 1
|
LL | | 1
|
||||||
| | ^ expected `()`, found integer
|
| | ^ expected `()`, found integer
|
||||||
LL | | };
|
LL | | };
|
||||||
| |_____- if and else have incompatible types
|
| |_____- `if` and `else` have incompatible types
|
||||||
|
|
||||||
error: aborting due to previous error
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
|
|
@ -2,14 +2,14 @@ fn foo(bar: usize) -> usize {
|
||||||
if bar % 5 == 0 {
|
if bar % 5 == 0 {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
//~^^^ ERROR if may be missing an else clause
|
//~^^^ ERROR `if` may be missing an `else` clause
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo2(bar: usize) -> usize {
|
fn foo2(bar: usize) -> usize {
|
||||||
let x: usize = if bar % 5 == 0 {
|
let x: usize = if bar % 5 == 0 {
|
||||||
return 3;
|
return 3;
|
||||||
};
|
};
|
||||||
//~^^^ ERROR if may be missing an else clause
|
//~^^^ ERROR `if` may be missing an `else` clause
|
||||||
x
|
x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,21 +17,21 @@ fn foo3(bar: usize) -> usize {
|
||||||
if bar % 5 == 0 {
|
if bar % 5 == 0 {
|
||||||
3
|
3
|
||||||
}
|
}
|
||||||
//~^^^ ERROR if may be missing an else clause
|
//~^^^ ERROR `if` may be missing an `else` clause
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo_let(bar: usize) -> usize {
|
fn foo_let(bar: usize) -> usize {
|
||||||
if let 0 = 1 {
|
if let 0 = 1 {
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
//~^^^ ERROR if may be missing an else clause
|
//~^^^ ERROR `if` may be missing an `else` clause
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo2_let(bar: usize) -> usize {
|
fn foo2_let(bar: usize) -> usize {
|
||||||
let x: usize = if let 0 = 1 {
|
let x: usize = if let 0 = 1 {
|
||||||
return 3;
|
return 3;
|
||||||
};
|
};
|
||||||
//~^^^ ERROR if may be missing an else clause
|
//~^^^ ERROR `if` may be missing an `else` clause
|
||||||
x
|
x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ fn foo3_let(bar: usize) -> usize {
|
||||||
if let 0 = 1 {
|
if let 0 = 1 {
|
||||||
3
|
3
|
||||||
}
|
}
|
||||||
//~^^^ ERROR if may be missing an else clause
|
//~^^^ ERROR `if` may be missing an `else` clause
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME(60254): deduplicate first error in favor of second.
|
// FIXME(60254): deduplicate first error in favor of second.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0317]: if may be missing an else clause
|
error[E0317]: `if` may be missing an `else` clause
|
||||||
--> $DIR/if-without-else-as-fn-expr.rs:2:5
|
--> $DIR/if-without-else-as-fn-expr.rs:2:5
|
||||||
|
|
|
|
||||||
LL | fn foo(bar: usize) -> usize {
|
LL | fn foo(bar: usize) -> usize {
|
||||||
|
@ -11,7 +11,7 @@ LL | | }
|
||||||
= note: `if` expressions without `else` evaluate to `()`
|
= note: `if` expressions without `else` evaluate to `()`
|
||||||
= help: consider adding an `else` block that evaluates to the expected type
|
= help: consider adding an `else` block that evaluates to the expected type
|
||||||
|
|
||||||
error[E0317]: if may be missing an else clause
|
error[E0317]: `if` may be missing an `else` clause
|
||||||
--> $DIR/if-without-else-as-fn-expr.rs:9:20
|
--> $DIR/if-without-else-as-fn-expr.rs:9:20
|
||||||
|
|
|
|
||||||
LL | let x: usize = if bar % 5 == 0 {
|
LL | let x: usize = if bar % 5 == 0 {
|
||||||
|
@ -25,7 +25,7 @@ LL | | };
|
||||||
= note: `if` expressions without `else` evaluate to `()`
|
= note: `if` expressions without `else` evaluate to `()`
|
||||||
= help: consider adding an `else` block that evaluates to the expected type
|
= help: consider adding an `else` block that evaluates to the expected type
|
||||||
|
|
||||||
error[E0317]: if may be missing an else clause
|
error[E0317]: `if` may be missing an `else` clause
|
||||||
--> $DIR/if-without-else-as-fn-expr.rs:17:5
|
--> $DIR/if-without-else-as-fn-expr.rs:17:5
|
||||||
|
|
|
|
||||||
LL | fn foo3(bar: usize) -> usize {
|
LL | fn foo3(bar: usize) -> usize {
|
||||||
|
@ -38,7 +38,7 @@ LL | | }
|
||||||
= note: `if` expressions without `else` evaluate to `()`
|
= note: `if` expressions without `else` evaluate to `()`
|
||||||
= help: consider adding an `else` block that evaluates to the expected type
|
= help: consider adding an `else` block that evaluates to the expected type
|
||||||
|
|
||||||
error[E0317]: if may be missing an else clause
|
error[E0317]: `if` may be missing an `else` clause
|
||||||
--> $DIR/if-without-else-as-fn-expr.rs:24:5
|
--> $DIR/if-without-else-as-fn-expr.rs:24:5
|
||||||
|
|
|
|
||||||
LL | fn foo_let(bar: usize) -> usize {
|
LL | fn foo_let(bar: usize) -> usize {
|
||||||
|
@ -51,7 +51,7 @@ LL | | }
|
||||||
= note: `if` expressions without `else` evaluate to `()`
|
= note: `if` expressions without `else` evaluate to `()`
|
||||||
= help: consider adding an `else` block that evaluates to the expected type
|
= help: consider adding an `else` block that evaluates to the expected type
|
||||||
|
|
||||||
error[E0317]: if may be missing an else clause
|
error[E0317]: `if` may be missing an `else` clause
|
||||||
--> $DIR/if-without-else-as-fn-expr.rs:31:20
|
--> $DIR/if-without-else-as-fn-expr.rs:31:20
|
||||||
|
|
|
|
||||||
LL | let x: usize = if let 0 = 1 {
|
LL | let x: usize = if let 0 = 1 {
|
||||||
|
@ -65,7 +65,7 @@ LL | | };
|
||||||
= note: `if` expressions without `else` evaluate to `()`
|
= note: `if` expressions without `else` evaluate to `()`
|
||||||
= help: consider adding an `else` block that evaluates to the expected type
|
= help: consider adding an `else` block that evaluates to the expected type
|
||||||
|
|
||||||
error[E0317]: if may be missing an else clause
|
error[E0317]: `if` may be missing an `else` clause
|
||||||
--> $DIR/if-without-else-as-fn-expr.rs:39:5
|
--> $DIR/if-without-else-as-fn-expr.rs:39:5
|
||||||
|
|
|
|
||||||
LL | fn foo3_let(bar: usize) -> usize {
|
LL | fn foo3_let(bar: usize) -> usize {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
let a = if true { true };
|
let a = if true { true };
|
||||||
//~^ ERROR if may be missing an else clause [E0317]
|
//~^ ERROR `if` may be missing an `else` clause [E0317]
|
||||||
//~| expected `()`, found `bool`
|
//~| expected `()`, found `bool`
|
||||||
println!("{}", a);
|
println!("{}", a);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0317]: if may be missing an else clause
|
error[E0317]: `if` may be missing an `else` clause
|
||||||
--> $DIR/if-without-else-result.rs:2:13
|
--> $DIR/if-without-else-result.rs:2:13
|
||||||
|
|
|
|
||||||
LL | let a = if true { true };
|
LL | let a = if true { true };
|
||||||
|
|
|
@ -6,7 +6,7 @@ fn main() {
|
||||||
Some(2) => true,
|
Some(2) => true,
|
||||||
//~^ NOTE this is found to be of type `bool`
|
//~^ NOTE this is found to be of type `bool`
|
||||||
None => (),
|
None => (),
|
||||||
//~^ ERROR match arms have incompatible types
|
//~^ ERROR `match` arms have incompatible types
|
||||||
//~| NOTE expected `bool`, found `()`
|
//~| NOTE expected `bool`, found `()`
|
||||||
_ => true
|
_ => true
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0308]: match arms have incompatible types
|
error[E0308]: `match` arms have incompatible types
|
||||||
--> $DIR/issue-11319.rs:8:20
|
--> $DIR/issue-11319.rs:8:20
|
||||||
|
|
|
|
||||||
LL | / match Some(10) {
|
LL | / match Some(10) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0308]: match arms have incompatible types
|
error[E0308]: `match` arms have incompatible types
|
||||||
--> $DIR/issue-17728.rs:109:14
|
--> $DIR/issue-17728.rs:109:14
|
||||||
|
|
|
|
||||||
LL | / match to_parse {
|
LL | / match to_parse {
|
||||||
|
|
|
@ -108,7 +108,7 @@ fn str_to_direction(to_parse: &str) -> RoomDirection {
|
||||||
"down" => RoomDirection::Down,
|
"down" => RoomDirection::Down,
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
//~^^ ERROR match arms have incompatible types
|
//~^^ ERROR `match` arms have incompatible types
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
|
@ -9,7 +9,7 @@ LL | fn attemptTraverse(&self, room: &Room, directionStr: &str) -> Result<&R
|
||||||
LL | Some(entry) => Ok(entry),
|
LL | Some(entry) => Ok(entry),
|
||||||
| ^^^^^^^^^ ...but data from `room` is returned here
|
| ^^^^^^^^^ ...but data from `room` is returned here
|
||||||
|
|
||||||
error[E0308]: match arms have incompatible types
|
error[E0308]: `match` arms have incompatible types
|
||||||
--> $DIR/issue-17728.rs:109:14
|
--> $DIR/issue-17728.rs:109:14
|
||||||
|
|
|
|
||||||
LL | / match to_parse {
|
LL | / match to_parse {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
// Test if the sugared if-let construct correctly prints "missing an else clause" when an else
|
// Test if the sugared if-let construct correctly prints "missing an else clause" when an else
|
||||||
// clause does not exist, instead of the unsympathetic "match arms have incompatible types"
|
// clause does not exist, instead of the unsympathetic "`match` arms have incompatible types"
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if let Some(homura) = Some("madoka") { //~ ERROR missing an else clause
|
if let Some(homura) = Some("madoka") { //~ ERROR missing an `else` clause
|
||||||
//~| expected `()`, found integer
|
//~| expected `()`, found integer
|
||||||
765
|
765
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0317]: if may be missing an else clause
|
error[E0317]: `if` may be missing an `else` clause
|
||||||
--> $DIR/issue-19991.rs:5:5
|
--> $DIR/issue-19991.rs:5:5
|
||||||
|
|
|
|
||||||
LL | / if let Some(homura) = Some("madoka") {
|
LL | / if let Some(homura) = Some("madoka") {
|
||||||
|
|
|
@ -10,7 +10,7 @@ fn closure_from_match() {
|
||||||
2 => |c| c - 1,
|
2 => |c| c - 1,
|
||||||
_ => |c| c - 1
|
_ => |c| c - 1
|
||||||
};
|
};
|
||||||
//~^^^ ERROR match arms have incompatible types
|
//~^^^ ERROR `match` arms have incompatible types
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() { }
|
fn main() { }
|
||||||
|
|
|
@ -9,7 +9,7 @@ LL | x = |c| c + 1;
|
||||||
= note: no two closures, even if identical, have the same type
|
= note: no two closures, even if identical, have the same type
|
||||||
= help: consider boxing your closure and/or using it as a trait object
|
= help: consider boxing your closure and/or using it as a trait object
|
||||||
|
|
||||||
error[E0308]: match arms have incompatible types
|
error[E0308]: `match` arms have incompatible types
|
||||||
--> $DIR/issue-24036.rs:10:14
|
--> $DIR/issue-24036.rs:10:14
|
||||||
|
|
|
|
||||||
LL | let x = match 1usize {
|
LL | let x = match 1usize {
|
||||||
|
|
|
@ -2,7 +2,7 @@ fn main() {
|
||||||
let a = if true {
|
let a = if true {
|
||||||
0
|
0
|
||||||
} else if false {
|
} else if false {
|
||||||
//~^ ERROR if may be missing an else clause
|
//~^ ERROR `if` may be missing an `else` clause
|
||||||
//~| expected `()`, found integer
|
//~| expected `()`, found integer
|
||||||
1
|
1
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0317]: if may be missing an else clause
|
error[E0317]: `if` may be missing an `else` clause
|
||||||
--> $DIR/issue-4201.rs:4:12
|
--> $DIR/issue-4201.rs:4:12
|
||||||
|
|
|
|
||||||
LL | } else if false {
|
LL | } else if false {
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
#[start]
|
#[start]
|
||||||
fn start(argc: isize, argv: *const *const u8, crate_map: *const u8) -> isize {
|
fn start(argc: isize, argv: *const *const u8, crate_map: *const u8) -> isize {
|
||||||
//~^ start function has wrong type
|
//~^ `#[start]` function has wrong type
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0308]: start function has wrong type
|
error[E0308]: `#[start]` function has wrong type
|
||||||
--> $DIR/issue-9575.rs:4:1
|
--> $DIR/issue-9575.rs:4:1
|
||||||
|
|
|
|
||||||
LL | fn start(argc: isize, argv: *const *const u8, crate_map: *const u8) -> isize {
|
LL | fn start(argc: isize, argv: *const *const u8, crate_map: *const u8) -> isize {
|
||||||
|
|
|
@ -13,7 +13,7 @@ fn foo(
|
||||||
) {
|
) {
|
||||||
let z = match 22 {
|
let z = match 22 {
|
||||||
0 => x,
|
0 => x,
|
||||||
_ => y, //~ ERROR match arms have incompatible types
|
_ => y, //~ ERROR `match` arms have incompatible types
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0308]: match arms have incompatible types
|
error[E0308]: `match` arms have incompatible types
|
||||||
--> $DIR/old-lub-glb-hr.rs:16:14
|
--> $DIR/old-lub-glb-hr.rs:16:14
|
||||||
|
|
|
|
||||||
LL | let z = match 22 {
|
LL | let z = match 22 {
|
||||||
|
|
|
@ -9,7 +9,7 @@ fn foo(
|
||||||
) {
|
) {
|
||||||
let z = match 22 {
|
let z = match 22 {
|
||||||
0 => x,
|
0 => x,
|
||||||
_ => y, //~ ERROR match arms have incompatible types
|
_ => y, //~ ERROR `match` arms have incompatible types
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0308]: match arms have incompatible types
|
error[E0308]: `match` arms have incompatible types
|
||||||
--> $DIR/old-lub-glb-object.rs:12:14
|
--> $DIR/old-lub-glb-object.rs:12:14
|
||||||
|
|
|
|
||||||
LL | let z = match 22 {
|
LL | let z = match 22 {
|
||||||
|
|
|
@ -4,5 +4,5 @@ struct S {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main(foo: S) {
|
fn main(foo: S) {
|
||||||
//~^ ERROR: main function has wrong type [E0580]
|
//~^ ERROR: `main` function has wrong type [E0580]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0580]: main function has wrong type
|
error[E0580]: `main` function has wrong type
|
||||||
--> $DIR/main-wrong-type.rs:6:1
|
--> $DIR/main-wrong-type.rs:6:1
|
||||||
|
|
|
|
||||||
LL | fn main(foo: S) {
|
LL | fn main(foo: S) {
|
||||||
|
|
|
@ -14,6 +14,6 @@ fn main() {
|
||||||
E::C => 3,
|
E::C => 3,
|
||||||
E::D => 4,
|
E::D => 4,
|
||||||
E::E => unimplemented!(""),
|
E::E => unimplemented!(""),
|
||||||
E::F => "", //~ ERROR match arms have incompatible types
|
E::F => "", //~ ERROR `match` arms have incompatible types
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0308]: match arms have incompatible types
|
error[E0308]: `match` arms have incompatible types
|
||||||
--> $DIR/match-arm-resolving-to-never.rs:17:17
|
--> $DIR/match-arm-resolving-to-never.rs:17:17
|
||||||
|
|
|
|
||||||
LL | / match E::F {
|
LL | / match E::F {
|
||||||
|
|
|
@ -16,7 +16,7 @@ fn test_func2(n: i32) -> i32 {
|
||||||
let x = match n { //~ NOTE `match` arms have incompatible types
|
let x = match n { //~ NOTE `match` arms have incompatible types
|
||||||
12 => 'b', //~ NOTE this is found to be of type `char`
|
12 => 'b', //~ NOTE this is found to be of type `char`
|
||||||
_ => 42,
|
_ => 42,
|
||||||
//~^ ERROR match arms have incompatible types
|
//~^ ERROR `match` arms have incompatible types
|
||||||
//~| NOTE expected `char`, found integer
|
//~| NOTE expected `char`, found integer
|
||||||
};
|
};
|
||||||
x
|
x
|
||||||
|
@ -32,7 +32,7 @@ fn test_func3(n: i32) -> i32 {
|
||||||
6 => 'b',
|
6 => 'b',
|
||||||
//~^ NOTE this and all prior arms are found to be of type `char`
|
//~^ NOTE this and all prior arms are found to be of type `char`
|
||||||
_ => 42,
|
_ => 42,
|
||||||
//~^ ERROR match arms have incompatible types
|
//~^ ERROR `match` arms have incompatible types
|
||||||
//~| NOTE expected `char`, found integer
|
//~| NOTE expected `char`, found integer
|
||||||
};
|
};
|
||||||
x
|
x
|
||||||
|
@ -44,7 +44,7 @@ fn test_func4() {
|
||||||
x //~ NOTE this is found to be of type `u32`
|
x //~ NOTE this is found to be of type `u32`
|
||||||
},
|
},
|
||||||
None => {}
|
None => {}
|
||||||
//~^ ERROR match arms have incompatible types
|
//~^ ERROR `match` arms have incompatible types
|
||||||
//~| NOTE expected `u32`, found `()`
|
//~| NOTE expected `u32`, found `()`
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ LL | match n {
|
||||||
LL | 12 => 'b',
|
LL | 12 => 'b',
|
||||||
| ^^^ expected `i32`, found `char`
|
| ^^^ expected `i32`, found `char`
|
||||||
|
|
||||||
error[E0308]: match arms have incompatible types
|
error[E0308]: `match` arms have incompatible types
|
||||||
--> $DIR/match-type-err-first-arm.rs:18:14
|
--> $DIR/match-type-err-first-arm.rs:18:14
|
||||||
|
|
|
|
||||||
LL | let x = match n {
|
LL | let x = match n {
|
||||||
|
@ -21,7 +21,7 @@ LL | |
|
||||||
LL | | };
|
LL | | };
|
||||||
| |_____- `match` arms have incompatible types
|
| |_____- `match` arms have incompatible types
|
||||||
|
|
||||||
error[E0308]: match arms have incompatible types
|
error[E0308]: `match` arms have incompatible types
|
||||||
--> $DIR/match-type-err-first-arm.rs:34:14
|
--> $DIR/match-type-err-first-arm.rs:34:14
|
||||||
|
|
|
|
||||||
LL | let x = match n {
|
LL | let x = match n {
|
||||||
|
@ -40,7 +40,7 @@ LL | |
|
||||||
LL | | };
|
LL | | };
|
||||||
| |_____- `match` arms have incompatible types
|
| |_____- `match` arms have incompatible types
|
||||||
|
|
||||||
error[E0308]: match arms have incompatible types
|
error[E0308]: `match` arms have incompatible types
|
||||||
--> $DIR/match-type-err-first-arm.rs:46:17
|
--> $DIR/match-type-err-first-arm.rs:46:17
|
||||||
|
|
|
|
||||||
LL | / match Some(0u32) {
|
LL | / match Some(0u32) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ fn qux() -> impl std::fmt::Display {
|
||||||
0i32
|
0i32
|
||||||
} else {
|
} else {
|
||||||
1u32
|
1u32
|
||||||
//~^ ERROR if and else have incompatible types
|
//~^ ERROR `if` and `else` have incompatible types
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ LL | } else {
|
||||||
LL | 1u32
|
LL | 1u32
|
||||||
| ^^^^ expected `i32`, found `u32`
|
| ^^^^ expected `i32`, found `u32`
|
||||||
|
|
||||||
error[E0308]: if and else have incompatible types
|
error[E0308]: `if` and `else` have incompatible types
|
||||||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:31:9
|
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:31:9
|
||||||
|
|
|
|
||||||
LL | / if false {
|
LL | / if false {
|
||||||
|
@ -45,7 +45,7 @@ LL | | 1u32
|
||||||
| | ^^^^ expected `i32`, found `u32`
|
| | ^^^^ expected `i32`, found `u32`
|
||||||
LL | |
|
LL | |
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_____- if and else have incompatible types
|
| |_____- `if` and `else` have incompatible types
|
||||||
|
|
||||||
error[E0308]: mismatched types
|
error[E0308]: mismatched types
|
||||||
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:39:14
|
--> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:39:14
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0308]: if and else have incompatible types
|
error[E0308]: `if` and `else` have incompatible types
|
||||||
--> $DIR/region-invariant-static-error-reporting.rs:17:9
|
--> $DIR/region-invariant-static-error-reporting.rs:17:9
|
||||||
|
|
|
|
||||||
LL | let bad = if x.is_some() {
|
LL | let bad = if x.is_some() {
|
||||||
|
@ -9,7 +9,7 @@ LL | | } else {
|
||||||
LL | | mk_static()
|
LL | | mk_static()
|
||||||
| | ^^^^^^^^^^^ lifetime mismatch
|
| | ^^^^^^^^^^^ lifetime mismatch
|
||||||
LL | | };
|
LL | | };
|
||||||
| |_____- if and else have incompatible types
|
| |_____- `if` and `else` have incompatible types
|
||||||
|
|
|
|
||||||
= note: expected struct `Invariant<'a>`
|
= note: expected struct `Invariant<'a>`
|
||||||
found struct `Invariant<'static>`
|
found struct `Invariant<'static>`
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
let s = "abc";
|
let s = "abc";
|
||||||
let t = if true { s[..2] } else { s };
|
let t = if true { s[..2] } else { s };
|
||||||
//~^ ERROR if and else have incompatible types
|
//~^ ERROR `if` and `else` have incompatible types
|
||||||
let u: &str = if true { s[..2] } else { s };
|
let u: &str = if true { s[..2] } else { s };
|
||||||
//~^ ERROR mismatched types
|
//~^ ERROR mismatched types
|
||||||
let v = s[..2];
|
let v = s[..2];
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0308]: if and else have incompatible types
|
error[E0308]: `if` and `else` have incompatible types
|
||||||
--> $DIR/str-array-assignment.rs:3:37
|
--> $DIR/str-array-assignment.rs:3:37
|
||||||
|
|
|
|
||||||
LL | let t = if true { s[..2] } else { s };
|
LL | let t = if true { s[..2] } else { s };
|
||||||
|
|
|
@ -17,7 +17,7 @@ async fn thing() -> Result<(), ()> {
|
||||||
if true {
|
if true {
|
||||||
thing_one()
|
thing_one()
|
||||||
} else {
|
} else {
|
||||||
thing_two() //~ ERROR if and else have incompatible types
|
thing_two() //~ ERROR `if` and `else` have incompatible types
|
||||||
}.await
|
}.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0308]: if and else have incompatible types
|
error[E0308]: `if` and `else` have incompatible types
|
||||||
--> $DIR/opaque-type-error.rs:20:9
|
--> $DIR/opaque-type-error.rs:20:9
|
||||||
|
|
|
|
||||||
LL | / if true {
|
LL | / if true {
|
||||||
|
@ -8,7 +8,7 @@ LL | | } else {
|
||||||
LL | | thing_two()
|
LL | | thing_two()
|
||||||
| | ^^^^^^^^^^^ expected opaque type, found a different opaque type
|
| | ^^^^^^^^^^^ expected opaque type, found a different opaque type
|
||||||
LL | | }.await
|
LL | | }.await
|
||||||
| |_____- if and else have incompatible types
|
| |_____- `if` and `else` have incompatible types
|
||||||
|
|
|
|
||||||
= note: expected type `impl std::future::Future` (opaque type at <$DIR/opaque-type-error.rs:8:19>)
|
= note: expected type `impl std::future::Future` (opaque type at <$DIR/opaque-type-error.rs:8:19>)
|
||||||
found opaque type `impl std::future::Future` (opaque type at <$DIR/opaque-type-error.rs:12:19>)
|
found opaque type `impl std::future::Future` (opaque type at <$DIR/opaque-type-error.rs:12:19>)
|
||||||
|
|
|
@ -20,7 +20,7 @@ fn main() {
|
||||||
// However, in #67273, we would delay the unification of this arm with the above
|
// However, in #67273, we would delay the unification of this arm with the above
|
||||||
// because we used the hitherto accumulated coercion as opposed to the "initial" type.
|
// because we used the hitherto accumulated coercion as opposed to the "initial" type.
|
||||||
2 => i = 1,
|
2 => i = 1,
|
||||||
//~^ ERROR match arms have incompatible types
|
//~^ ERROR `match` arms have incompatible types
|
||||||
|
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0308]: match arms have incompatible types
|
error[E0308]: `match` arms have incompatible types
|
||||||
--> $DIR/issue-67273-assignment-match-prior-arm-bool-expected-unit.rs:22:14
|
--> $DIR/issue-67273-assignment-match-prior-arm-bool-expected-unit.rs:22:14
|
||||||
|
|
|
|
||||||
LL | / match i {
|
LL | / match i {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
error[E0308]: match arms have incompatible types
|
error[E0308]: `match` arms have incompatible types
|
||||||
--> $DIR/wf-unsafe-trait-obj-match.rs:23:17
|
--> $DIR/wf-unsafe-trait-obj-match.rs:23:17
|
||||||
|
|
|
|
||||||
LL | / match opt() {
|
LL | / match opt() {
|
||||||
|
|
Loading…
Reference in New Issue