Rollup merge of #118775 - Young-Flash:fix, r=compiler-errors · rust-lang/rust@034d73d (original) (raw)

1

1

`` error[E0599]: no method named hello found for struct A in the current scope

``

2

``

`-

--> $DIR/suggest-assoc-fn-call-without-receiver.rs:12:8

`

``

2

`+

--> $DIR/suggest-assoc-fn-call-without-receiver.rs:20:8

`

3

3

` |

`

4

4

`LL | struct A {}

`

5

5

`` | -------- method hello not found for this struct

``

`@@ -18,7 +18,7 @@ LL | fn hello(_a: i32) {}

`

18

18

` | ^^^^^^^^^^^^^^^^^

`

19

19

``

20

20

`` error[E0599]: no method named test found for struct A in the current scope

``

21

``

`-

--> $DIR/suggest-assoc-fn-call-without-receiver.rs:14:8

`

``

21

`+

--> $DIR/suggest-assoc-fn-call-without-receiver.rs:22:8

`

22

22

` |

`

23

23

`LL | struct A {}

`

24

24

`` | -------- method test not found for this struct

``

`` @@ -36,6 +36,44 @@ note: the candidate is defined in an impl for the type A

``

36

36

`LL | fn test(_a: Self, _b: i32) {}

`

37

37

` | ^^^^^^^^^^^^^^^^^^^^^^^^^^

`

38

38

``

39

``

`-

error: aborting due to 2 previous errors

`

``

39

`` +

error[E0599]: no method named hello found for struct B<&str> in the current scope

``

``

40

`+

--> $DIR/suggest-assoc-fn-call-without-receiver.rs:26:8

`

``

41

`+

|

`

``

42

`+

LL | struct B {

`

``

43

`` +

| ----------- method hello not found for this struct

``

``

44

`+

...

`

``

45

`+

LL | _b.hello(1);

`

``

46

`+

| ---^^^^^---

`

``

47

`+

| | |

`

``

48

`+

| | this is an associated function, not a method

`

``

49

`` +

| help: use associated function syntax instead: B::<&str>::hello(1)

``

``

50

`+

|

`

``

51

`` +

= note: found the following associated functions; to be used as methods, functions must have a self parameter

``

``

52

`` +

note: the candidate is defined in an impl for the type B<T>

``

``

53

`+

--> $DIR/suggest-assoc-fn-call-without-receiver.rs:14:5

`

``

54

`+

|

`

``

55

`+

LL | fn hello(_a: i32) {}

`

``

56

`+

| ^^^^^^^^^^^^^^^^^

`

``

57

+

``

58

`` +

error[E0599]: no method named test found for struct B<&str> in the current scope

``

``

59

`+

--> $DIR/suggest-assoc-fn-call-without-receiver.rs:28:8

`

``

60

`+

|

`

``

61

`+

LL | struct B {

`

``

62

`` +

| ----------- method test not found for this struct

``

``

63

`+

...

`

``

64

`+

LL | _b.test(1);

`

``

65

`+

| ---^^^^---

`

``

66

`+

| | |

`

``

67

`+

| | this is an associated function, not a method

`

``

68

`` +

| help: use associated function syntax instead: B::<&str>::test(_b, 1)

``

``

69

`+

|

`

``

70

`` +

= note: found the following associated functions; to be used as methods, functions must have a self parameter

``

``

71

`` +

note: the candidate is defined in an impl for the type B<T>

``

``

72

`+

--> $DIR/suggest-assoc-fn-call-without-receiver.rs:15:5

`

``

73

`+

|

`

``

74

`+

LL | fn test(_a: Self, _b: i32) {}

`

``

75

`+

| ^^^^^^^^^^^^^^^^^^^^^^^^^^

`

``

76

+

``

77

`+

error: aborting due to 4 previous errors

`

40

78

``

41

79

`` For more information about this error, try rustc --explain E0599.

``