Skip to content

Commit 1cbcd9e

Browse files
committed
added renamed docs formatted stderr | tests/ui/methods/method-missing-call.rs
1 parent 7a690f2 commit 1cbcd9e

File tree

4 files changed

+69
-55
lines changed

4 files changed

+69
-55
lines changed

tests/ui/methods/method-missing-call.rs

Lines changed: 0 additions & 30 deletions
This file was deleted.

tests/ui/methods/method-missing-call.stderr

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//! Test taking a method value without parentheses
2+
3+
struct Point {
4+
x: isize,
5+
y: isize,
6+
}
7+
8+
impl Point {
9+
fn new() -> Point {
10+
Point { x: 0, y: 0 }
11+
}
12+
13+
fn get_x(&self) -> isize {
14+
self.x
15+
}
16+
}
17+
18+
fn main() {
19+
// Test with primitive type method
20+
let _f = 10i32.abs; //~ ERROR attempted to take value of method
21+
22+
// Test with custom type method
23+
let point: Point = Point::new();
24+
let px: isize = point.get_x; //~ ERROR attempted to take value of method `get_x` on type `Point`
25+
26+
// Test with method chains - ensure the span is useful
27+
let ys = &[1, 2, 3, 4, 5, 6, 7];
28+
let a = ys
29+
.iter()
30+
.map(|x| x)
31+
.filter(|&&x| x == 1)
32+
.filter_map; //~ ERROR attempted to take value of method `filter_map` on type
33+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
error[E0615]: attempted to take value of method `abs` on type `i32`
2+
--> $DIR/method-value-without-call.rs:20:20
3+
|
4+
LL | let _f = 10i32.abs;
5+
| ^^^ method, not a field
6+
|
7+
help: use parentheses to call the method
8+
|
9+
LL | let _f = 10i32.abs();
10+
| ++
11+
12+
error[E0615]: attempted to take value of method `get_x` on type `Point`
13+
--> $DIR/method-value-without-call.rs:24:27
14+
|
15+
LL | let px: isize = point.get_x;
16+
| ^^^^^ method, not a field
17+
|
18+
help: use parentheses to call the method
19+
|
20+
LL | let px: isize = point.get_x();
21+
| ++
22+
23+
error[E0615]: attempted to take value of method `filter_map` on type `Filter<Map<std::slice::Iter<'_, {integer}>, {closure@$DIR/method-value-without-call.rs:30:14: 30:17}>, {closure@$DIR/method-value-without-call.rs:31:17: 31:22}>`
24+
--> $DIR/method-value-without-call.rs:32:10
25+
|
26+
LL | .filter_map;
27+
| ^^^^^^^^^^ method, not a field
28+
|
29+
help: use parentheses to call the method
30+
|
31+
LL | .filter_map(_);
32+
| +++
33+
34+
error: aborting due to 3 previous errors
35+
36+
For more information about this error, try `rustc --explain E0615`.

0 commit comments

Comments
 (0)