summaryrefslogtreecommitdiffstats
path: root/tests/ui/methods/method-on-ambiguous-numeric-type.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
commita4b7ed7a42c716ab9f05e351f003d589124fd55d (patch)
treeb620cd3f223850b28716e474e80c58059dca5dd4 /tests/ui/methods/method-on-ambiguous-numeric-type.rs
parentAdding upstream version 1.67.1+dfsg1. (diff)
downloadrustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz
rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/methods/method-on-ambiguous-numeric-type.rs')
-rw-r--r--tests/ui/methods/method-on-ambiguous-numeric-type.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/ui/methods/method-on-ambiguous-numeric-type.rs b/tests/ui/methods/method-on-ambiguous-numeric-type.rs
new file mode 100644
index 000000000..82f47438d
--- /dev/null
+++ b/tests/ui/methods/method-on-ambiguous-numeric-type.rs
@@ -0,0 +1,32 @@
+// aux-build:macro-in-other-crate.rs
+
+#[macro_use] extern crate macro_in_other_crate;
+
+macro_rules! local_mac {
+ ($ident:ident) => { let $ident = 42; }
+}
+
+fn main() {
+ let x = 2.0.neg();
+ //~^ ERROR can't call method `neg` on ambiguous numeric type `{float}`
+
+ let y = 2.0;
+ let x = y.neg();
+ //~^ ERROR can't call method `neg` on ambiguous numeric type `{float}`
+ println!("{:?}", x);
+
+ for i in 0..100 {
+ println!("{}", i.pow(2));
+ //~^ ERROR can't call method `pow` on ambiguous numeric type `{integer}`
+ }
+
+ local_mac!(local_bar);
+ local_bar.pow(2);
+ //~^ ERROR can't call method `pow` on ambiguous numeric type `{integer}`
+}
+
+fn qux() {
+ mac!(bar);
+ bar.pow(2);
+ //~^ ERROR can't call method `pow` on ambiguous numeric type `{integer}`
+}