-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide suggestion when trying to use method on numeric literal
- Loading branch information
Showing
8 changed files
with
161 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,12 @@ | ||
error[E0599]: no method named `f` found for type `{integer}` in the current scope | ||
error[E0689]: can't call method `f` on ambiguous numeric type `{integer}` | ||
--> $DIR/issue_41652.rs:19:11 | ||
| | ||
19 | 3.f() | ||
| ^ | ||
help: you must specify a concrete type for this numeric value, like `u32` | ||
| | ||
= note: found the following associated functions; to be used as methods, functions must have a `self` parameter | ||
= help: try with `{integer}::f` | ||
note: candidate #1 is defined in the trait `issue_41652_b::Tr` | ||
--> $DIR/auxiliary/issue_41652_b.rs:14:5 | ||
| | ||
14 | / fn f() | ||
15 | | where Self: Sized; | ||
| |__________________________^ | ||
= help: to disambiguate the method call, write `issue_41652_b::Tr::f(3)` instead | ||
19 | (3 as u32).f() | ||
| ^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/test/ui/suggestions/method-on-ambiguous-numeric-type.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
fn main() { | ||
let x = 2.0.powi(2); | ||
//~^ ERROR can't call method `powi` on ambiguous numeric type `{float}` | ||
println!("{:?}", x); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/test/ui/suggestions/method-on-ambiguous-numeric-type.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0689]: can't call method `powi` on ambiguous numeric type `{float}` | ||
--> $DIR/method-on-ambiguous-numeric-type.rs:12:17 | ||
| | ||
12 | let x = 2.0.powi(2); | ||
| ^^^^ | ||
help: you must specify a concrete type for this numeric value, like `f32` | ||
| | ||
12 | let x = (2.0 as f32).powi(2); | ||
| ^^^^^^^^^^^^ | ||
|
||
error: aborting due to previous error | ||
|