Skip to content
Permalink
Browse files

Point at type in `let` assignment on type errors

  • Loading branch information
estebank committed Nov 19, 2019
1 parent f11759d commit 34f03c01f688c0653b080914d4ab83461e1cfae2
Showing with 684 additions and 354 deletions.
  1. +22 −6 src/librustc_typeck/check/demand.rs
  2. +3 −1 src/test/rustdoc-ui/failed-doctest-missing-codes.stdout
  3. +6 −2 src/test/ui/array-not-vector.stderr
  4. +3 −1 src/test/ui/associated-types/associated-types-eq-3.stderr
  5. +3 −1 src/test/ui/associated-types/associated-types-path-2.stderr
  6. +6 −2 src/test/ui/c-variadic/variadic-ffi-1.stderr
  7. +3 −1 src/test/ui/closures/closure-no-fn-1.stderr
  8. +3 −1 src/test/ui/closures/closure-no-fn-2.stderr
  9. +3 −1 src/test/ui/coercion/coerce-to-bang.stderr
  10. +5 −4 src/test/ui/coercion/coercion-slice.stderr
  11. +6 −2 src/test/ui/const-generics/fn-const-param-infer.stderr
  12. +3 −1 src/test/ui/const-generics/raw-ptr-const-param.stderr
  13. +9 −3 src/test/ui/const-generics/slice-const-param-mismatch.stderr
  14. +6 −2 src/test/ui/const-generics/types-mismatch-const-args.stderr
  15. +20 −16 src/test/ui/conversion-methods.stderr
  16. +5 −4 src/test/ui/cross/cross-borrow-trait.stderr
  17. +21 −14 src/test/ui/did_you_mean/issue-53280-expected-float-found-integer-literal.stderr
  18. +3 −1 src/test/ui/did_you_mean/recursion_limit_deref.stderr
  19. +6 −2 src/test/ui/dst/dst-bad-coerce1.stderr
  20. +12 −4 src/test/ui/dst/dst-bad-coerce2.stderr
  21. +6 −2 src/test/ui/dst/dst-bad-coerce4.stderr
  22. +25 −13 src/test/ui/dst/dst-bad-coercions.stderr
  23. +8 −5 src/test/ui/float-literal-inference-restrictions.stderr
  24. +9 −3 src/test/ui/fn/fn-trait-formatting.stderr
  25. +18 −6 src/test/ui/generic/generic-type-params-name-repr.stderr
  26. +3 −1 src/test/ui/hrtb/hrtb-exists-forall-fn.stderr
  27. +6 −2 src/test/ui/impl-trait/equality2.stderr
  28. +6 −2 src/test/ui/include-macros/mismatched-types.stderr
  29. +3 −1 src/test/ui/issues/issue-1362.stderr
  30. +3 −1 src/test/ui/issues/issue-22684.stderr
  31. +3 −1 src/test/ui/issues/issue-24322.stderr
  32. +4 −0 src/test/ui/issues/issue-27042.stderr
  33. +3 −1 src/test/ui/issues/issue-3477.stderr
  34. +3 −1 src/test/ui/issues/issue-37665.stderr
  35. +3 −1 src/test/ui/issues/issue-38940.stderr
  36. +3 −1 src/test/ui/issues/issue-5100.stderr
  37. +10 −8 src/test/ui/issues/issue-53692.stderr
  38. +3 −1 src/test/ui/issues/issue-56943.stderr
  39. +4 −4 src/test/ui/json-bom-plus-crlf-multifile.stderr
  40. +4 −4 src/test/ui/json-bom-plus-crlf.stderr
  41. +3 −1 src/test/ui/meta-expected-error-correct-rev.a.stderr
  42. +3 −1 src/test/ui/methods/method-ambig-one-trait-unknown-int-type.stderr
  43. +15 −5 src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr
  44. +3 −1 src/test/ui/mir-unpretty.stderr
  45. +3 −1 src/test/ui/mismatched_types/main.stderr
  46. +3 −1 src/test/ui/never_type/never-assign-wrong-type.stderr
  47. +3 −1 src/test/ui/noexporttypeexe.stderr
  48. +12 −4 src/test/ui/numeric/const-scope.stderr
  49. +9 −3 src/test/ui/numeric/numeric-cast-2.stderr
  50. +3 −1 src/test/ui/or-patterns/issue-64879-trailing-before-guard.stderr
  51. +5 −4 src/test/ui/or-patterns/or-patterns-syntactic-fail.stderr
  52. +3 −1 src/test/ui/parser/lex-bad-char-literals-6.stderr
  53. +3 −1 src/test/ui/parser/numeric-lifetime.stderr
  54. +3 −1 src/test/ui/parser/recover-from-homoglyph.stderr
  55. +6 −2 src/test/ui/parser/recover-missing-semi.stderr
  56. +3 −1 src/test/ui/parser/recover-tuple.stderr
  57. +3 −1 src/test/ui/parser/unclosed-delimiter-in-dep.stderr
  58. +6 −2 src/test/ui/proc-macro/attribute-spans-preserved.stderr
  59. +12 −4 src/test/ui/proc-macro/attribute-with-error.stderr
  60. +6 −2 src/test/ui/proc-macro/nested-item-spans.stderr
  61. +3 −1 src/test/ui/proc-macro/span-preservation.stderr
  62. +9 −3 src/test/ui/ptr-coercion.stderr
  63. +3 −1 src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.nll.stderr
  64. +3 −1 src/test/ui/regions/region-lifetime-bounds-on-fns-where-clause.stderr
  65. +3 −1 src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.nll.stderr
  66. +3 −1 src/test/ui/regions/region-multiple-lifetime-bounds-on-fns-where-clause.stderr
  67. +3 −1 src/test/ui/regions/regions-lifetime-bounds-on-fns.nll.stderr
  68. +3 −1 src/test/ui/regions/regions-lifetime-bounds-on-fns.stderr
  69. +5 −4 src/test/ui/reify-intrinsic.stderr
  70. +15 −12 src/test/ui/resolve/privacy-enum-ctor.stderr
  71. +3 −1 src/test/ui/shift-various-bad-types.stderr
  72. +3 −1 src/test/ui/slice-mut.stderr
  73. +8 −5 src/test/ui/span/coerce-suggestions.stderr
  74. +3 −1 src/test/ui/span/move-closure.stderr
  75. +5 −4 src/test/ui/str/str-array-assignment.stderr
  76. +15 −12 src/test/ui/str/str-lit-type-mismatch.stderr
  77. +3 −1 src/test/ui/struct-literal-variant-in-if.stderr
  78. +20 −16 src/test/ui/substs-ppaux.normal.stderr
  79. +20 −16 src/test/ui/substs-ppaux.verbose.stderr
  80. +11 −6 src/test/ui/suggestions/as-ref.stderr
  81. +70 −56 src/test/ui/suggestions/fn-or-tuple-struct-without-args.stderr
  82. +10 −8 src/test/ui/suggestions/format-borrow.stderr
  83. +15 −12 src/test/ui/suggestions/issue-59819.stderr
  84. +3 −1 src/test/ui/suggestions/mismatched-types-numeric-from.stderr
  85. +6 −2 src/test/ui/suggestions/recover-from-semicolon-trailing-item.stderr
  86. +3 −1 src/test/ui/suggestions/suggest-box.stderr
  87. +3 −1 src/test/ui/tag-that-dare-not-speak-its-name.stderr
  88. +4 −2 src/test/ui/terminal-width/non-whitespace-trimming-2.stderr
  89. +4 −2 src/test/ui/terminal-width/non-whitespace-trimming-unicode.stderr
  90. +4 −2 src/test/ui/terminal-width/non-whitespace-trimming.stderr
  91. +3 −1 src/test/ui/terminal-width/whitespace-trimming.stderr
  92. +3 −1 src/test/ui/type-alias-enum-variants/enum-variant-priority-higher-than-other-inherent.stderr
  93. +3 −1 src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.nll.stderr
  94. +3 −1 src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.stderr
  95. +3 −1 src/test/ui/type-alias-impl-trait/never_reveal_concrete_type.stderr
  96. +3 −1 src/test/ui/type-alias-impl-trait/no_revealing_outside_defining_module.stderr
  97. +3 −1 src/test/ui/type/type-check/assignment-expected-bool.stderr
  98. +6 −2 src/test/ui/type/type-mismatch-multiple.stderr
  99. +3 −1 src/test/ui/type/type-shadow.stderr
  100. +6 −2 src/test/ui/typeck/typeck_type_placeholder_mismatch.stderr
  101. +3 −1 src/test/ui/wrong-mul-method-signature.stderr
@@ -102,12 +102,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// N.B., this code relies on `self.diverges` to be accurate. In
// particular, assignments to `!` will be permitted if the
// diverges flag is currently "always".
pub fn demand_coerce_diag(&self,
expr: &hir::Expr,
checked_ty: Ty<'tcx>,
expected: Ty<'tcx>,
allow_two_phase: AllowTwoPhase)
-> (Ty<'tcx>, Option<DiagnosticBuilder<'tcx>>) {
pub fn demand_coerce_diag(
&self,
expr: &hir::Expr,
checked_ty: Ty<'tcx>,
expected: Ty<'tcx>,
allow_two_phase: AllowTwoPhase,
) -> (Ty<'tcx>, Option<DiagnosticBuilder<'tcx>>) {
let expected = self.resolve_vars_with_obligations(expected);

let e = match self.try_coerce(expr, checked_ty, expected, allow_two_phase) {
@@ -126,6 +127,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
return (expected, None)
}

self.annotate_expected_due_to_let_ty(&mut err, expr);
self.suggest_compatible_variants(&mut err, expr, expected, expr_ty);
self.suggest_ref_or_into(&mut err, expr, expected, expr_ty);
self.suggest_boxing_when_appropriate(&mut err, expr, expected, expr_ty);
@@ -134,6 +136,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
(expected, Some(err))
}

fn annotate_expected_due_to_let_ty(&self, err: &mut DiagnosticBuilder<'_>, expr: &hir::Expr) {
let parent = self.tcx.hir().get_parent_node(expr.hir_id);
if let Some(hir::Node::Local(hir::Local {
ty: Some(ty),
init: Some(init),
..
})) = self.tcx.hir().find(parent) {
if init.hir_id == expr.hir_id {
// Point at `let` assignment type.
err.span_label(ty.span, "expected due to this");
}
}
}

/// Returns whether the expected type is `bool` and the expression is `x = y`.
pub fn is_assign_to_bool(&self, expr: &hir::Expr, expected: Ty<'tcx>) -> bool {
if let hir::ExprKind::Assign(..) = expr.kind {
@@ -9,7 +9,9 @@ error[E0308]: mismatched types
--> $DIR/failed-doctest-missing-codes.rs:9:13
|
LL | let x: () = 5i32;
| ^^^^ expected `()`, found `i32`
| -- ^^^^ expected `()`, found `i32`
| |
| expected due to this

error: aborting due to previous error

@@ -2,13 +2,17 @@ error[E0308]: mismatched types
--> $DIR/array-not-vector.rs:2:19
|
LL | let _x: i32 = [1, 2, 3];
| ^^^^^^^^^ expected `i32`, found array `[{integer}; 3]`
| --- ^^^^^^^^^ expected `i32`, found array `[{integer}; 3]`
| |
| expected due to this

error[E0308]: mismatched types
--> $DIR/array-not-vector.rs:7:20
|
LL | let _y: &i32 = x;
| ^ expected `i32`, found slice `[i32]`
| ---- ^ expected `i32`, found slice `[i32]`
| |
| expected due to this
|
= note: expected reference `&i32`
found reference `&[i32]`
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/associated-types-eq-3.rs:23:18
|
LL | let _: Bar = x.boo();
| ^^^^^^^ expected struct `Bar`, found associated type
| --- ^^^^^^^ expected struct `Bar`, found associated type
| |
| expected due to this
|
= note: expected struct `Bar`
found associated type `<I as Foo>::A`
@@ -43,7 +43,9 @@ error[E0308]: mismatched types
--> $DIR/associated-types-path-2.rs:41:18
|
LL | let _: i32 = f2(2i32);
| ^^^^^^^^ expected `i32`, found `u32`
| --- ^^^^^^^^ expected `i32`, found `u32`
| |
| expected due to this
|
help: you can convert an `u32` to `i32` and panic if the converted value wouldn't fit
|
@@ -26,7 +26,9 @@ error[E0308]: mismatched types
--> $DIR/variadic-ffi-1.rs:19:56
|
LL | let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
| ^^^ expected non-variadic fn, found variadic function
| ------------------------------------- ^^^ expected non-variadic fn, found variadic function
| |
| expected due to this
|
= note: expected fn pointer `unsafe extern "C" fn(isize, u8)`
found fn item `unsafe extern "C" fn(isize, u8, ...) {foo}`
@@ -35,7 +37,9 @@ error[E0308]: mismatched types
--> $DIR/variadic-ffi-1.rs:20:54
|
LL | let y: extern "C" fn(f: isize, x: u8, ...) = bar;
| ^^^ expected variadic fn, found non-variadic function
| ----------------------------------- ^^^ expected variadic fn, found non-variadic function
| |
| expected due to this
|
= note: expected fn pointer `extern "C" fn(isize, u8, ...)`
found fn item `extern "C" fn(isize, u8) {bar}`
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/closure-no-fn-1.rs:6:29
|
LL | let foo: fn(u8) -> u8 = |v: u8| { a += v; a };
| ^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found closure
| ------------ ^^^^^^^^^^^^^^^^^^^^^ expected fn pointer, found closure
| |
| expected due to this
|
= note: expected fn pointer `fn(u8) -> u8`
found closure `[closure@$DIR/closure-no-fn-1.rs:6:29: 6:50 a:_]`
@@ -2,7 +2,9 @@ error[E0308]: mismatched types
--> $DIR/closure-no-fn-2.rs:6:27
|
LL | let bar: fn() -> u8 = || { b };
| ^^^^^^^^ expected fn pointer, found closure
| ---------- ^^^^^^^^ expected fn pointer, found closure
| |
| expected due to this
|
= note: expected fn pointer `fn() -> u8`
found closure `[closure@$DIR/closure-no-fn-2.rs:6:27: 6:35 b:_]`
@@ -47,7 +47,9 @@ error[E0308]: mismatched types
--> $DIR/coerce-to-bang.rs:48:21
|
LL | let x: [!; 2] = [return, 22];
| ^^^^^^^^^^^^ expected `!`, found integer
| ------ ^^^^^^^^^^^^ expected `!`, found integer
| |
| expected due to this
|
= note: expected array `[!; 2]`
found array `[{integer}; 2]`
@@ -2,10 +2,11 @@ error[E0308]: mismatched types
--> $DIR/coercion-slice.rs:4:21
|
LL | let _: &[i32] = [0];
| ^^^
| |
| expected `&[i32]`, found array `[{integer}; 1]`
| help: consider borrowing here: `&[0]`
| ------ ^^^
| | |
| | expected `&[i32]`, found array `[{integer}; 1]`
| | help: consider borrowing here: `&[0]`
| expected due to this

error: aborting due to previous error

@@ -10,7 +10,9 @@ error[E0308]: mismatched types
--> $DIR/fn-const-param-infer.rs:16:31
|
LL | let _: Checked<not_one> = Checked::<not_two>;
| ^^^^^^^^^^^^^^^^^^ expected `not_one`, found `not_two`
| ---------------- ^^^^^^^^^^^^^^^^^^ expected `not_one`, found `not_two`
| |
| expected due to this
|
= note: expected struct `Checked<not_one>`
found struct `Checked<not_two>`
@@ -34,7 +36,9 @@ error[E0308]: mismatched types
--> $DIR/fn-const-param-infer.rs:25:40
|
LL | let _: Checked<{generic::<u32>}> = Checked::<{generic::<u16>}>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `generic::<u32>`, found `generic::<u16>`
| ------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `generic::<u32>`, found `generic::<u16>`
| |
| expected due to this
|
= note: expected struct `Checked<generic::<u32>>`
found struct `Checked<generic::<u16>>`
@@ -10,7 +10,9 @@ error[E0308]: mismatched types
--> $DIR/raw-ptr-const-param.rs:7:38
|
LL | let _: Const<{15 as *const _}> = Const::<{10 as *const _}>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{pointer}`, found `{pointer}`
| ----------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `{pointer}`, found `{pointer}`
| |
| expected due to this
|
= note: expected struct `Const<{pointer}>`
found struct `Const<{pointer}>`
@@ -10,7 +10,9 @@ error[E0308]: mismatched types
--> $DIR/slice-const-param-mismatch.rs:9:35
|
LL | let _: ConstString<"Hello"> = ConstString::<"World">;
| ^^^^^^^^^^^^^^^^^^^^^^ expected `"Hello"`, found `"World"`
| -------------------- ^^^^^^^^^^^^^^^^^^^^^^ expected `"Hello"`, found `"World"`
| |
| expected due to this
|
= note: expected struct `ConstString<"Hello">`
found struct `ConstString<"World">`
@@ -19,7 +21,9 @@ error[E0308]: mismatched types
--> $DIR/slice-const-param-mismatch.rs:11:33
|
LL | let _: ConstString<"ℇ㇈↦"> = ConstString::<"ℇ㇈↥">;
| ^^^^^^^^^^^^^^^^^^^^^ expected `"ℇ㇈↦"`, found `"ℇ㇈↥"`
| ------------------- ^^^^^^^^^^^^^^^^^^^^^ expected `"ℇ㇈↦"`, found `"ℇ㇈↥"`
| |
| expected due to this
|
= note: expected struct `ConstString<"ℇ㇈↦">`
found struct `ConstString<"ℇ㇈↥">`
@@ -28,7 +32,9 @@ error[E0308]: mismatched types
--> $DIR/slice-const-param-mismatch.rs:13:33
|
LL | let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">;
| ^^^^^^^^^^^^^^^^^^^^ expected `b"AAA"`, found `b"BBB"`
| ------------------ ^^^^^^^^^^^^^^^^^^^^ expected `b"AAA"`, found `b"BBB"`
| |
| expected due to this
|
= note: expected struct `ConstBytes<b"AAA">`
found struct `ConstBytes<b"BBB">`
@@ -10,7 +10,9 @@ error[E0308]: mismatched types
--> $DIR/types-mismatch-const-args.rs:13:41
|
LL | let _: A<'a, u32, {2u32}, {3u32}> = A::<'a, u32, {4u32}, {3u32}> { data: PhantomData };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2u32`, found `4u32`
| -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `2u32`, found `4u32`
| |
| expected due to this
|
= note: expected struct `A<'_, _, 2u32, _>`
found struct `A<'_, _, 4u32, _>`
@@ -19,7 +21,9 @@ error[E0308]: mismatched types
--> $DIR/types-mismatch-const-args.rs:15:41
|
LL | let _: A<'a, u16, {2u32}, {3u32}> = A::<'b, u32, {2u32}, {3u32}> { data: PhantomData };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u16`, found `u32`
| -------------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u16`, found `u32`
| |
| expected due to this
|
= note: expected struct `A<'a, u16, _, _>`
found struct `A<'b, u32, _, _>`
@@ -2,37 +2,41 @@ error[E0308]: mismatched types
--> $DIR/conversion-methods.rs:5:41
|
LL | let _tis_an_instants_play: String = "'Tis a fond Ambush—";
| ^^^^^^^^^^^^^^^^^^^^^
| |
| expected struct `std::string::String`, found `&str`
| help: try using a conversion method: `"'Tis a fond Ambush—".to_string()`
| ------ ^^^^^^^^^^^^^^^^^^^^^
| | |
| | expected struct `std::string::String`, found `&str`
| | help: try using a conversion method: `"'Tis a fond Ambush—".to_string()`
| expected due to this

error[E0308]: mismatched types
--> $DIR/conversion-methods.rs:6:40
|
LL | let _just_to_make_bliss: PathBuf = Path::new("/ern/her/own/surprise");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| |
| expected struct `std::path::PathBuf`, found `&std::path::Path`
| help: try using a conversion method: `Path::new("/ern/her/own/surprise").to_path_buf()`
| ------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| | |
| | expected struct `std::path::PathBuf`, found `&std::path::Path`
| | help: try using a conversion method: `Path::new("/ern/her/own/surprise").to_path_buf()`
| expected due to this

error[E0308]: mismatched types
--> $DIR/conversion-methods.rs:9:40
|
LL | let _but_should_the_play: String = 2; // Perhaps surprisingly, we suggest .to_string() here
| ^
| |
| expected struct `std::string::String`, found integer
| help: try using a conversion method: `2.to_string()`
| ------ ^
| | |
| | expected struct `std::string::String`, found integer
| | help: try using a conversion method: `2.to_string()`
| expected due to this

error[E0308]: mismatched types
--> $DIR/conversion-methods.rs:12:47
|
LL | let _prove_piercing_earnest: Vec<usize> = &[1, 2, 3];
| ^^^^^^^^^^
| |
| expected struct `std::vec::Vec`, found `&[{integer}; 3]`
| help: try using a conversion method: `(&[1, 2, 3]).to_vec()`
| ---------- ^^^^^^^^^^
| | |
| | expected struct `std::vec::Vec`, found `&[{integer}; 3]`
| | help: try using a conversion method: `(&[1, 2, 3]).to_vec()`
| expected due to this
|
= note: expected struct `std::vec::Vec<usize>`
found reference `&[{integer}; 3]`
@@ -2,10 +2,11 @@ error[E0308]: mismatched types
--> $DIR/cross-borrow-trait.rs:10:26
|
LL | let _y: &dyn Trait = x;
| ^
| |
| expected `&dyn Trait`, found struct `std::boxed::Box`
| help: consider borrowing here: `&x`
| ---------- ^
| | |
| | expected `&dyn Trait`, found struct `std::boxed::Box`
| | help: consider borrowing here: `&x`
| expected due to this
|
= note: expected reference `&dyn Trait`
found struct `std::boxed::Box<dyn Trait>`
@@ -2,40 +2,47 @@ error[E0308]: mismatched types
--> $DIR/issue-53280-expected-float-found-integer-literal.rs:2:24
|
LL | let sixteen: f32 = 16;
| ^^
| |
| expected `f32`, found integer
| help: use a float literal: `16.0`
| --- ^^
| | |
| | expected `f32`, found integer
| | help: use a float literal: `16.0`
| expected due to this

error[E0308]: mismatched types
--> $DIR/issue-53280-expected-float-found-integer-literal.rs:5:38
|
LL | let a_million_and_seventy: f64 = 1_000_070;
| ^^^^^^^^^
| |
| expected `f64`, found integer
| help: use a float literal: `1_000_070.0`
| --- ^^^^^^^^^
| | |
| | expected `f64`, found integer
| | help: use a float literal: `1_000_070.0`
| expected due to this

error[E0308]: mismatched types
--> $DIR/issue-53280-expected-float-found-integer-literal.rs:8:30
|
LL | let negative_nine: f32 = -9;
| ^^
| |
| expected `f32`, found integer
| help: use a float literal: `-9.0`
| --- ^^
| | |
| | expected `f32`, found integer
| | help: use a float literal: `-9.0`
| expected due to this

error[E0308]: mismatched types
--> $DIR/issue-53280-expected-float-found-integer-literal.rs:15:30
|
LL | let sixteen_again: f64 = 0x10;
| ^^^^ expected `f64`, found integer
| --- ^^^^ expected `f64`, found integer
| |
| expected due to this

error[E0308]: mismatched types
--> $DIR/issue-53280-expected-float-found-integer-literal.rs:17:30
|
LL | let and_once_more: f32 = 0o20;
| ^^^^ expected `f32`, found integer
| --- ^^^^ expected `f32`, found integer
| |
| expected due to this

error: aborting due to 5 previous errors

0 comments on commit 34f03c0

Please sign in to comment.
You can’t perform that action at this time.