Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d79e0e1

Browse files
committedJan 15, 2025·
make is_importable stop to rejecting assoc const and fn
1 parent b759390 commit d79e0e1

33 files changed

+490
-264
lines changed
 

‎compiler/rustc_resolve/src/imports.rs

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -829,33 +829,27 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
829829
Err(Undetermined) => indeterminate_count += 1,
830830
// Don't update the resolution, because it was never added.
831831
Err(Determined) if target.name == kw::Underscore => {}
832-
Ok(binding)
833-
if binding.is_importable()
834-
|| binding.is_assoc_const_or_fn()
835-
&& this.tcx.features().import_trait_associated_functions() =>
836-
{
832+
Ok(binding) if binding.is_importable() => {
833+
if binding.is_assoc_const_or_fn()
834+
&& !this.tcx.features().import_trait_associated_functions()
835+
{
836+
feature_err(
837+
this.tcx.sess,
838+
sym::import_trait_associated_functions,
839+
import.span,
840+
"`use` associated items of traits is unstable",
841+
)
842+
.emit();
843+
}
837844
let imported_binding = this.import(binding, import);
838845
target_bindings[ns].set(Some(imported_binding));
839846
this.define(parent, target, ns, imported_binding);
840847
}
841848
source_binding @ (Ok(..) | Err(Determined)) => {
842-
if let Ok(binding) = source_binding {
843-
if binding.is_assoc_const_or_fn() {
844-
feature_err(
845-
this.tcx.sess,
846-
sym::import_trait_associated_functions,
847-
import.span,
848-
"`use` associated items of traits is unstable",
849-
)
849+
if source_binding.is_ok() {
850+
this.dcx()
851+
.create_err(IsNotDirectlyImportable { span: import.span, target })
850852
.emit();
851-
} else {
852-
this.dcx()
853-
.create_err(IsNotDirectlyImportable {
854-
span: import.span,
855-
target,
856-
})
857-
.emit();
858-
}
859853
}
860854
let key = BindingKey::new(target, ns);
861855
this.update_resolution(parent, key, false, |_, resolution| {

‎compiler/rustc_resolve/src/lib.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -920,10 +920,7 @@ impl<'ra> NameBindingData<'ra> {
920920
}
921921

922922
fn is_importable(&self) -> bool {
923-
!matches!(
924-
self.res(),
925-
Res::Def(DefKind::AssocConst | DefKind::AssocFn | DefKind::AssocTy, _)
926-
)
923+
!matches!(self.res(), Res::Def(DefKind::AssocTy, _))
927924
}
928925

929926
fn is_assoc_const_or_fn(&self) -> bool {

‎tests/ui/associated-type-bounds/return-type-notation/not-a-method.stderr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ error[E0576]: cannot find function `method` in this scope
1515
|
1616
LL | method(..): Send,
1717
| ^^^^^^ not found in this scope
18+
|
19+
help: consider importing this associated function
20+
|
21+
LL + use Tr::method;
22+
|
1823

1924
error[E0412]: cannot find type `method` in this scope
2025
--> $DIR/not-a-method.rs:36:5

‎tests/ui/delegation/bad-resolve.stderr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ error[E0425]: cannot find function `foo` in this scope
6262
|
6363
LL | reuse foo { &self.0 }
6464
| ^^^ not found in this scope
65+
|
66+
help: consider importing this associated function
67+
|
68+
LL + use Trait::foo;
69+
|
6570

6671
error[E0425]: cannot find function `foo2` in trait `Trait`
6772
--> $DIR/bad-resolve.rs:37:18

‎tests/ui/delegation/explicit-paths.stderr

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,42 +21,58 @@ error[E0425]: cannot find function `foo4` in `S`
2121
|
2222
LL | reuse S::foo4;
2323
| ^^^^ not found in `S`
24+
|
25+
note: associated function `trait_assoc_fn_to_other::Trait2::foo4` exists but is inaccessible
26+
--> $DIR/explicit-paths.rs:65:9
27+
|
28+
LL | reuse F::foo4 { &F }
29+
| ^^^^^^^^^^^^^ not accessible
2430

2531
error[E0425]: cannot find function `foo4` in `F`
2632
--> $DIR/explicit-paths.rs:38:18
2733
|
2834
LL | reuse F::foo4 { &self.0 }
2935
| ^^^^ not found in `F`
3036
|
31-
note: function `fn_to_other::foo4` exists but is inaccessible
37+
note: these items exist but are inaccessible
3238
--> $DIR/explicit-paths.rs:27:5
3339
|
3440
LL | reuse S::foo4;
35-
| ^^^^^^^^^^^^^^ not accessible
41+
| ^^^^^^^^^^^^^^ `fn_to_other::foo4`: not accessible
42+
...
43+
LL | reuse F::foo4 { &F }
44+
| ^^^^^^^^^^^^^ `trait_assoc_fn_to_other::Trait2::foo4`: not accessible
3645

3746
error[E0425]: cannot find function `foo4` in `F`
3847
--> $DIR/explicit-paths.rs:51:18
3948
|
4049
LL | reuse F::foo4 { &self.0 }
4150
| ^^^^ not found in `F`
4251
|
43-
note: function `fn_to_other::foo4` exists but is inaccessible
52+
note: these items exist but are inaccessible
4453
--> $DIR/explicit-paths.rs:27:5
4554
|
4655
LL | reuse S::foo4;
47-
| ^^^^^^^^^^^^^^ not accessible
56+
| ^^^^^^^^^^^^^^ `fn_to_other::foo4`: not accessible
57+
...
58+
LL | reuse F::foo4 { &F }
59+
| ^^^^^^^^^^^^^ `trait_assoc_fn_to_other::Trait2::foo4`: not accessible
4860

4961
error[E0425]: cannot find function `foo4` in `F`
5062
--> $DIR/explicit-paths.rs:65:18
5163
|
5264
LL | reuse F::foo4 { &F }
5365
| ^^^^ not found in `F`
5466
|
55-
note: function `fn_to_other::foo4` exists but is inaccessible
56-
--> $DIR/explicit-paths.rs:27:5
67+
help: consider importing this associated function
68+
|
69+
LL + use trait_assoc_fn_to_other::Trait2::foo4;
70+
|
71+
help: if you import `foo4`, refer to it directly
72+
|
73+
LL - reuse F::foo4 { &F }
74+
LL + reuse foo4 { &F }
5775
|
58-
LL | reuse S::foo4;
59-
| ^^^^^^^^^^^^^^ not accessible
6076

6177
error[E0119]: conflicting implementations of trait `Trait` for type `S`
6278
--> $DIR/explicit-paths.rs:74:5

‎tests/ui/delegation/ice-issue-124342.stderr

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ error[E0425]: cannot find function `foo` in module `to_reuse`
33
|
44
LL | reuse to_reuse::foo { foo }
55
| ^^^ not found in `to_reuse`
6+
|
7+
help: consider importing this associated function
8+
|
9+
LL + use Trait::foo;
10+
|
11+
help: if you import `foo`, refer to it directly
12+
|
13+
LL - reuse to_reuse::foo { foo }
14+
LL + reuse foo { foo }
15+
|
616

717
error[E0425]: cannot find value `foo` in this scope
818
--> $DIR/ice-issue-124342.rs:7:27
@@ -14,6 +24,10 @@ help: you might have meant to refer to the associated function
1424
|
1525
LL | reuse to_reuse::foo { Self::foo }
1626
| ++++++
27+
help: consider importing this associated function
28+
|
29+
LL + use Trait::foo;
30+
|
1731

1832
error: aborting due to 2 previous errors
1933

‎tests/ui/imports/import-trait-method.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ trait Foo {
44

55
use Foo::foo; //~ ERROR `use` associated items of traits is unstable [E0658]
66

7-
fn main() { foo(); }
7+
fn main() { foo(); } //~ ERROR type annotations needed

‎tests/ui/imports/import-trait-method.stderr

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ LL | use Foo::foo;
88
= help: add `#![feature(import_trait_associated_functions)]` to the crate attributes to enable
99
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
1010

11-
error: aborting due to 1 previous error
11+
error[E0283]: type annotations needed
12+
--> $DIR/import-trait-method.rs:7:13
13+
|
14+
LL | fn main() { foo(); }
15+
| ^^^^^ cannot infer type
16+
|
17+
= note: cannot satisfy `_: Foo`
18+
19+
error: aborting due to 2 previous errors
1220

13-
For more information about this error, try `rustc --explain E0658`.
21+
Some errors have detailed explanations: E0283, E0658.
22+
For more information about an error, try `rustc --explain E0283`.

‎tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -313,39 +313,26 @@ LL | unknown_metavar!(a);
313313
|
314314
= note: this error originates in the macro `unknown_metavar` (in Nightly builds, run with -Z macro-backtrace for more info)
315315

316-
error[E0425]: cannot find value `i` in this scope
317-
--> $DIR/syntax-errors.rs:23:36
316+
error[E0425]: cannot find function `count` in this scope
317+
--> $DIR/syntax-errors.rs:23:30
318318
|
319319
LL | ( $( $i:ident ),* ) => { count(i) };
320-
| ^ not found in this scope
320+
| ^^^^^ not found in this scope
321321
...
322322
LL | no_curly__no_rhs_dollar__round!(a, b, c);
323323
| ---------------------------------------- in this macro invocation
324324
|
325325
= note: this error originates in the macro `no_curly__no_rhs_dollar__round` (in Nightly builds, run with -Z macro-backtrace for more info)
326-
327-
error[E0425]: cannot find value `i` in this scope
328-
--> $DIR/syntax-errors.rs:30:29
329-
|
330-
LL | ( $i:ident ) => { count(i) };
331-
| ^ not found in this scope
332-
...
333-
LL | no_curly__no_rhs_dollar__no_round!(a);
334-
| ------------------------------------- in this macro invocation
326+
help: consider importing this associated function
335327
|
336-
= note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info)
337-
338-
error[E0425]: cannot find value `a` in this scope
339-
--> $DIR/syntax-errors.rs:152:37
328+
LL + use std::iter::Iterator::count;
340329
|
341-
LL | no_curly__rhs_dollar__no_round!(a);
342-
| ^ not found in this scope
343330

344-
error[E0425]: cannot find function `count` in this scope
345-
--> $DIR/syntax-errors.rs:23:30
331+
error[E0425]: cannot find value `i` in this scope
332+
--> $DIR/syntax-errors.rs:23:36
346333
|
347334
LL | ( $( $i:ident ),* ) => { count(i) };
348-
| ^^^^^ not found in this scope
335+
| ^ not found in this scope
349336
...
350337
LL | no_curly__no_rhs_dollar__round!(a, b, c);
351338
| ---------------------------------------- in this macro invocation
@@ -358,6 +345,21 @@ error[E0425]: cannot find function `count` in this scope
358345
LL | ( $i:ident ) => { count(i) };
359346
| ^^^^^ not found in this scope
360347
...
348+
LL | no_curly__no_rhs_dollar__no_round!(a);
349+
| ------------------------------------- in this macro invocation
350+
|
351+
= note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info)
352+
help: consider importing this associated function
353+
|
354+
LL + use std::iter::Iterator::count;
355+
|
356+
357+
error[E0425]: cannot find value `i` in this scope
358+
--> $DIR/syntax-errors.rs:30:29
359+
|
360+
LL | ( $i:ident ) => { count(i) };
361+
| ^ not found in this scope
362+
...
361363
LL | no_curly__no_rhs_dollar__no_round!(a);
362364
| ------------------------------------- in this macro invocation
363365
|
@@ -373,6 +375,16 @@ LL | no_curly__rhs_dollar__no_round!(a);
373375
| ---------------------------------- in this macro invocation
374376
|
375377
= note: this error originates in the macro `no_curly__rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info)
378+
help: consider importing this associated function
379+
|
380+
LL + use std::iter::Iterator::count;
381+
|
382+
383+
error[E0425]: cannot find value `a` in this scope
384+
--> $DIR/syntax-errors.rs:152:37
385+
|
386+
LL | no_curly__rhs_dollar__no_round!(a);
387+
| ^ not found in this scope
376388

377389
error: aborting due to 39 previous errors
378390

‎tests/ui/methods/suggest-method-on-call-for-ambig-receiver.stderr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ error[E0425]: cannot find function `consume` in this scope
33
|
44
LL | consume(right);
55
| ^^^^^^^ not found in this scope
6+
|
7+
help: consider importing this associated function
8+
|
9+
LL + use std::io::BufRead::consume;
10+
|
611

712
error: aborting due to 1 previous error
813

‎tests/ui/methods/suggest-method-on-call-with-macro-rcvr.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ error[E0425]: cannot find function `len` in this scope
44
LL | let hello = len(vec![]);
55
| ^^^ not found in this scope
66
|
7-
help: use the `.` operator to call the method `len` on `&Vec<_>`
7+
help: consider importing this associated function
88
|
9-
LL - let hello = len(vec![]);
10-
LL + let hello = vec![].len();
9+
LL + use std::iter::ExactSizeIterator::len;
1110
|
1211

1312
error: aborting due to 1 previous error

‎tests/ui/resolve/associated-fn-called-as-fn.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,32 @@
11
struct S;
2+
//~^ HELP consider importing one of these associated functions
3+
//~| HELP consider importing one of these associated functions
4+
25
impl Foo for S {
3-
fn parse(s:&str) {
6+
fn parse(s: &str) {
47
for c in s.chars() {
58
match c {
69
'0'..='9' => collect_primary(&c), //~ ERROR cannot find function `collect_primary`
710
//~^ HELP you might have meant to call the associated function
811
'+' | '-' => println!("We got a sign: {}", c),
9-
_ => println!("Not a number!")
12+
_ => println!("Not a number!"),
1013
}
1114
}
1215
}
1316
}
1417
trait Foo {
15-
fn collect_primary(ch:&char) { }
16-
fn parse(s:&str);
18+
fn collect_primary(ch: &char) {}
19+
fn parse(s: &str);
1720
}
1821
trait Bar {
19-
fn collect_primary(ch:&char) { }
20-
fn parse(s:&str) {
22+
fn collect_primary(ch: &char) {}
23+
fn parse(s: &str) {
2124
for c in s.chars() {
2225
match c {
2326
'0'..='9' => collect_primary(&c), //~ ERROR cannot find function `collect_primary`
2427
//~^ HELP you might have meant to call the associated function
2528
'+' | '-' => println!("We got a sign: {}", c),
26-
_ => println!("Not a number!")
29+
_ => println!("Not a number!"),
2730
}
2831
}
2932
}

‎tests/ui/resolve/associated-fn-called-as-fn.stderr

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0425]: cannot find function `collect_primary` in this scope
2-
--> $DIR/associated-fn-called-as-fn.rs:6:30
2+
--> $DIR/associated-fn-called-as-fn.rs:9:30
33
|
44
LL | '0'..='9' => collect_primary(&c),
55
| ^^^^^^^^^^^^^^^
@@ -8,9 +8,15 @@ help: you might have meant to call the associated function
88
|
99
LL | '0'..='9' => Self::collect_primary(&c),
1010
| ++++++
11+
help: consider importing one of these associated functions
12+
|
13+
LL + use Bar::collect_primary;
14+
|
15+
LL + use Foo::collect_primary;
16+
|
1117

1218
error[E0425]: cannot find function `collect_primary` in this scope
13-
--> $DIR/associated-fn-called-as-fn.rs:23:30
19+
--> $DIR/associated-fn-called-as-fn.rs:26:30
1420
|
1521
LL | '0'..='9' => collect_primary(&c),
1622
| ^^^^^^^^^^^^^^^
@@ -19,6 +25,12 @@ help: you might have meant to call the associated function
1925
|
2026
LL | '0'..='9' => Self::collect_primary(&c),
2127
| ++++++
28+
help: consider importing one of these associated functions
29+
|
30+
LL + use Bar::collect_primary;
31+
|
32+
LL + use Foo::collect_primary;
33+
|
2234

2335
error: aborting due to 2 previous errors
2436

‎tests/ui/resolve/bad-env-capture.stderr

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@ LL | fn bar() { log(debug, x); }
66
|
77
= help: use the `|| { ... }` closure form instead
88

9-
error[E0425]: cannot find value `debug` in this scope
10-
--> $DIR/bad-env-capture.rs:4:20
11-
|
12-
LL | fn bar() { log(debug, x); }
13-
| ^^^^^ not found in this scope
14-
159
error[E0425]: cannot find function `log` in this scope
1610
--> $DIR/bad-env-capture.rs:4:16
1711
|
1812
LL | fn bar() { log(debug, x); }
1913
| ^^^ not found in this scope
14+
|
15+
help: consider importing this associated function
16+
|
17+
LL + use std::simd::StdFloat::log;
18+
|
19+
20+
error[E0425]: cannot find value `debug` in this scope
21+
--> $DIR/bad-env-capture.rs:4:20
22+
|
23+
LL | fn bar() { log(debug, x); }
24+
| ^^^^^ not found in this scope
2025

2126
error: aborting due to 3 previous errors
2227

‎tests/ui/resolve/bad-env-capture2.stderr

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@ LL | fn bar() { log(debug, x); }
66
|
77
= help: use the `|| { ... }` closure form instead
88

9-
error[E0425]: cannot find value `debug` in this scope
10-
--> $DIR/bad-env-capture2.rs:3:20
11-
|
12-
LL | fn bar() { log(debug, x); }
13-
| ^^^^^ not found in this scope
14-
159
error[E0425]: cannot find function `log` in this scope
1610
--> $DIR/bad-env-capture2.rs:3:16
1711
|
1812
LL | fn bar() { log(debug, x); }
1913
| ^^^ not found in this scope
14+
|
15+
help: consider importing this associated function
16+
|
17+
LL + use std::simd::StdFloat::log;
18+
|
19+
20+
error[E0425]: cannot find value `debug` in this scope
21+
--> $DIR/bad-env-capture2.rs:3:20
22+
|
23+
LL | fn bar() { log(debug, x); }
24+
| ^^^^^ not found in this scope
2025

2126
error: aborting due to 3 previous errors
2227

‎tests/ui/resolve/bad-env-capture3.stderr

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@ LL | fn bar() { log(debug, x); }
66
|
77
= help: use the `|| { ... }` closure form instead
88

9-
error[E0425]: cannot find value `debug` in this scope
10-
--> $DIR/bad-env-capture3.rs:4:24
11-
|
12-
LL | fn bar() { log(debug, x); }
13-
| ^^^^^ not found in this scope
14-
159
error[E0425]: cannot find function `log` in this scope
1610
--> $DIR/bad-env-capture3.rs:4:20
1711
|
1812
LL | fn bar() { log(debug, x); }
1913
| ^^^ not found in this scope
14+
|
15+
help: consider importing this associated function
16+
|
17+
LL + use std::simd::StdFloat::log;
18+
|
19+
20+
error[E0425]: cannot find value `debug` in this scope
21+
--> $DIR/bad-env-capture3.rs:4:24
22+
|
23+
LL | fn bar() { log(debug, x); }
24+
| ^^^^^ not found in this scope
2025

2126
error: aborting due to 3 previous errors
2227

‎tests/ui/resolve/bad-expr-path.stderr

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
error[E0425]: cannot find function `log` in this scope
2+
--> $DIR/bad-expr-path.rs:4:5
3+
|
4+
LL | log(debug, m1::arguments);
5+
| ^^^ not found in this scope
6+
|
7+
help: consider importing this associated function
8+
|
9+
LL + use std::simd::StdFloat::log;
10+
|
11+
112
error[E0425]: cannot find value `debug` in this scope
213
--> $DIR/bad-expr-path.rs:4:9
314
|
@@ -19,12 +30,6 @@ LL | fn main(arguments: Vec<String>) {
1930
= note: expected signature `fn()`
2031
found signature `fn(Vec<String>)`
2132

22-
error[E0425]: cannot find function `log` in this scope
23-
--> $DIR/bad-expr-path.rs:4:5
24-
|
25-
LL | log(debug, m1::arguments);
26-
| ^^^ not found in this scope
27-
2833
error: aborting due to 4 previous errors
2934

3035
Some errors have detailed explanations: E0425, E0580.

‎tests/ui/resolve/bad-expr-path2.stderr

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
error[E0425]: cannot find function `log` in this scope
2+
--> $DIR/bad-expr-path2.rs:6:5
3+
|
4+
LL | log(debug, m1::arguments);
5+
| ^^^ not found in this scope
6+
|
7+
help: consider importing this associated function
8+
|
9+
LL + use std::simd::StdFloat::log;
10+
|
11+
112
error[E0425]: cannot find value `debug` in this scope
213
--> $DIR/bad-expr-path2.rs:6:9
314
|
@@ -19,12 +30,6 @@ LL | fn main(arguments: Vec<String>) {
1930
= note: expected signature `fn()`
2031
found signature `fn(Vec<String>)`
2132

22-
error[E0425]: cannot find function `log` in this scope
23-
--> $DIR/bad-expr-path2.rs:6:5
24-
|
25-
LL | log(debug, m1::arguments);
26-
| ^^^ not found in this scope
27-
2833
error: aborting due to 4 previous errors
2934

3035
Some errors have detailed explanations: E0423, E0425, E0580.

‎tests/ui/resolve/filter-intrinsics.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ error[E0425]: cannot find function `transmute` in this scope
44
LL | let _ = transmute::<usize>();
55
| ^^^^^^^^^ not found in this scope
66
|
7-
help: consider importing this function
7+
help: consider importing one of these items
8+
|
9+
LL + use std::mem::TransmuteFrom::transmute;
810
|
911
LL + use std::mem::transmute;
1012
|

‎tests/ui/resolve/issue-14254.stderr

Lines changed: 122 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,39 @@
1+
error[E0425]: cannot find function `baz` in this scope
2+
--> $DIR/issue-14254.rs:19:9
3+
|
4+
LL | baz();
5+
| ^^^
6+
|
7+
help: you might have meant to call the method
8+
|
9+
LL | self.baz();
10+
| +++++
11+
help: consider importing this associated function
12+
|
13+
LL + use Foo::baz;
14+
|
15+
116
error[E0425]: cannot find value `a` in this scope
217
--> $DIR/issue-14254.rs:21:9
318
|
419
LL | a;
520
| ^ not found in this scope
621

22+
error[E0425]: cannot find function `baz` in this scope
23+
--> $DIR/issue-14254.rs:28:9
24+
|
25+
LL | baz();
26+
| ^^^
27+
|
28+
help: you might have meant to call the method
29+
|
30+
LL | self.baz();
31+
| +++++
32+
help: consider importing this associated function
33+
|
34+
LL + use Foo::baz;
35+
|
36+
737
error[E0425]: cannot find value `x` in this scope
838
--> $DIR/issue-14254.rs:30:9
939
|
@@ -42,13 +72,32 @@ help: you might have meant to refer to the associated function
4272
|
4373
LL | Self::bah;
4474
| ++++++
75+
help: consider importing this associated function
76+
|
77+
LL + use Foo::bah;
78+
|
4579

4680
error[E0425]: cannot find value `b` in this scope
4781
--> $DIR/issue-14254.rs:38:9
4882
|
4983
LL | b;
5084
| ^ not found in this scope
5185

86+
error[E0425]: cannot find function `baz` in this scope
87+
--> $DIR/issue-14254.rs:45:9
88+
|
89+
LL | baz();
90+
| ^^^
91+
|
92+
help: you might have meant to call the method
93+
|
94+
LL | self.baz();
95+
| +++++
96+
help: consider importing this associated function
97+
|
98+
LL + use Foo::baz;
99+
|
100+
52101
error[E0425]: cannot find value `x` in this scope
53102
--> $DIR/issue-14254.rs:47:9
54103
|
@@ -87,37 +136,34 @@ help: you might have meant to refer to the associated function
87136
|
88137
LL | Self::bah;
89138
| ++++++
139+
help: consider importing this associated function
140+
|
141+
LL + use Foo::bah;
142+
|
90143

91144
error[E0425]: cannot find value `b` in this scope
92145
--> $DIR/issue-14254.rs:55:9
93146
|
94147
LL | b;
95148
| ^ not found in this scope
96149

97-
error[E0425]: cannot find value `bah` in this scope
98-
--> $DIR/issue-14254.rs:64:9
150+
error[E0425]: cannot find function `baz` in this scope
151+
--> $DIR/issue-14254.rs:62:9
99152
|
100-
LL | bah;
153+
LL | baz();
101154
| ^^^
102155
|
103-
help: you might have meant to refer to the associated function
104-
|
105-
LL | Self::bah;
106-
| ++++++
107-
108-
error[E0425]: cannot find value `bah` in this scope
109-
--> $DIR/issue-14254.rs:73:9
156+
help: you might have meant to call the method
110157
|
111-
LL | bah;
112-
| ^^^
158+
LL | self.baz();
159+
| +++++
160+
help: consider importing this associated function
113161
|
114-
help: you might have meant to refer to the associated function
162+
LL + use Foo::baz;
115163
|
116-
LL | Self::bah;
117-
| ++++++
118164

119165
error[E0425]: cannot find value `bah` in this scope
120-
--> $DIR/issue-14254.rs:82:9
166+
--> $DIR/issue-14254.rs:64:9
121167
|
122168
LL | bah;
123169
| ^^^
@@ -126,20 +172,28 @@ help: you might have meant to refer to the associated function
126172
|
127173
LL | Self::bah;
128174
| ++++++
175+
help: consider importing this associated function
176+
|
177+
LL + use Foo::bah;
178+
|
129179

130-
error[E0425]: cannot find value `bah` in this scope
131-
--> $DIR/issue-14254.rs:91:9
180+
error[E0425]: cannot find function `baz` in this scope
181+
--> $DIR/issue-14254.rs:71:9
132182
|
133-
LL | bah;
183+
LL | baz();
134184
| ^^^
135185
|
136-
help: you might have meant to refer to the associated function
186+
help: you might have meant to call the method
187+
|
188+
LL | self.baz();
189+
| +++++
190+
help: consider importing this associated function
191+
|
192+
LL + use Foo::baz;
137193
|
138-
LL | Self::bah;
139-
| ++++++
140194

141195
error[E0425]: cannot find value `bah` in this scope
142-
--> $DIR/issue-14254.rs:100:9
196+
--> $DIR/issue-14254.rs:73:9
143197
|
144198
LL | bah;
145199
| ^^^
@@ -148,20 +202,13 @@ help: you might have meant to refer to the associated function
148202
|
149203
LL | Self::bah;
150204
| ++++++
151-
152-
error[E0425]: cannot find function `baz` in this scope
153-
--> $DIR/issue-14254.rs:19:9
205+
help: consider importing this associated function
154206
|
155-
LL | baz();
156-
| ^^^
207+
LL + use Foo::bah;
157208
|
158-
help: you might have meant to call the method
159-
|
160-
LL | self.baz();
161-
| +++++
162209

163210
error[E0425]: cannot find function `baz` in this scope
164-
--> $DIR/issue-14254.rs:28:9
211+
--> $DIR/issue-14254.rs:80:9
165212
|
166213
LL | baz();
167214
| ^^^
@@ -170,31 +217,28 @@ help: you might have meant to call the method
170217
|
171218
LL | self.baz();
172219
| +++++
173-
174-
error[E0425]: cannot find function `baz` in this scope
175-
--> $DIR/issue-14254.rs:45:9
220+
help: consider importing this associated function
176221
|
177-
LL | baz();
178-
| ^^^
179-
|
180-
help: you might have meant to call the method
222+
LL + use Foo::baz;
181223
|
182-
LL | self.baz();
183-
| +++++
184224

185-
error[E0425]: cannot find function `baz` in this scope
186-
--> $DIR/issue-14254.rs:62:9
225+
error[E0425]: cannot find value `bah` in this scope
226+
--> $DIR/issue-14254.rs:82:9
187227
|
188-
LL | baz();
228+
LL | bah;
189229
| ^^^
190230
|
191-
help: you might have meant to call the method
231+
help: you might have meant to refer to the associated function
232+
|
233+
LL | Self::bah;
234+
| ++++++
235+
help: consider importing this associated function
236+
|
237+
LL + use Foo::bah;
192238
|
193-
LL | self.baz();
194-
| +++++
195239

196240
error[E0425]: cannot find function `baz` in this scope
197-
--> $DIR/issue-14254.rs:71:9
241+
--> $DIR/issue-14254.rs:89:9
198242
|
199243
LL | baz();
200244
| ^^^
@@ -203,20 +247,28 @@ help: you might have meant to call the method
203247
|
204248
LL | self.baz();
205249
| +++++
250+
help: consider importing this associated function
251+
|
252+
LL + use Foo::baz;
253+
|
206254

207-
error[E0425]: cannot find function `baz` in this scope
208-
--> $DIR/issue-14254.rs:80:9
255+
error[E0425]: cannot find value `bah` in this scope
256+
--> $DIR/issue-14254.rs:91:9
209257
|
210-
LL | baz();
258+
LL | bah;
211259
| ^^^
212260
|
213-
help: you might have meant to call the method
261+
help: you might have meant to refer to the associated function
262+
|
263+
LL | Self::bah;
264+
| ++++++
265+
help: consider importing this associated function
266+
|
267+
LL + use Foo::bah;
214268
|
215-
LL | self.baz();
216-
| +++++
217269

218270
error[E0425]: cannot find function `baz` in this scope
219-
--> $DIR/issue-14254.rs:89:9
271+
--> $DIR/issue-14254.rs:98:9
220272
|
221273
LL | baz();
222274
| ^^^
@@ -225,17 +277,25 @@ help: you might have meant to call the method
225277
|
226278
LL | self.baz();
227279
| +++++
280+
help: consider importing this associated function
281+
|
282+
LL + use Foo::baz;
283+
|
228284

229-
error[E0425]: cannot find function `baz` in this scope
230-
--> $DIR/issue-14254.rs:98:9
285+
error[E0425]: cannot find value `bah` in this scope
286+
--> $DIR/issue-14254.rs:100:9
231287
|
232-
LL | baz();
288+
LL | bah;
233289
| ^^^
234290
|
235-
help: you might have meant to call the method
291+
help: you might have meant to refer to the associated function
292+
|
293+
LL | Self::bah;
294+
| ++++++
295+
help: consider importing this associated function
296+
|
297+
LL + use Foo::bah;
236298
|
237-
LL | self.baz();
238-
| +++++
239299

240300
error: aborting due to 24 previous errors
241301

‎tests/ui/resolve/issue-2356.stderr

Lines changed: 67 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,44 @@
1+
error[E0425]: cannot find function `shave` in this scope
2+
--> $DIR/issue-2356.rs:17:5
3+
|
4+
LL | shave();
5+
| ^^^^^ not found in this scope
6+
|
7+
help: consider importing this associated function
8+
|
9+
LL + use Groom::shave;
10+
|
11+
12+
error[E0425]: cannot find function `clone` in this scope
13+
--> $DIR/issue-2356.rs:24:5
14+
|
15+
LL | clone();
16+
| ^^^^^
17+
|
18+
help: you might have meant to call the method
19+
|
20+
LL | self.clone();
21+
| +++++
22+
help: consider importing this associated function
23+
|
24+
LL + use std::clone::Clone::clone;
25+
|
26+
27+
error[E0425]: cannot find function `default` in this scope
28+
--> $DIR/issue-2356.rs:31:5
29+
|
30+
LL | default();
31+
| ^^^^^^^
32+
|
33+
help: you might have meant to call the associated function
34+
|
35+
LL | Self::default();
36+
| ++++++
37+
help: consider importing this associated function
38+
|
39+
LL + use std::default::Default::default;
40+
|
41+
142
error[E0425]: cannot find value `whiskers` in this scope
243
--> $DIR/issue-2356.rs:39:5
344
|
@@ -7,6 +48,21 @@ LL | whiskers: isize,
748
LL | whiskers -= other;
849
| ^^^^^^^^
950

51+
error[E0425]: cannot find function `shave` in this scope
52+
--> $DIR/issue-2356.rs:41:5
53+
|
54+
LL | shave(4);
55+
| ^^^^^
56+
|
57+
help: you might have meant to call the associated function
58+
|
59+
LL | Self::shave(4);
60+
| ++++++
61+
help: consider importing this associated function
62+
|
63+
LL + use Groom::shave;
64+
|
65+
1066
error[E0424]: expected value, found module `self`
1167
--> $DIR/issue-2356.rs:65:8
1268
|
@@ -20,6 +76,17 @@ help: add a `self` receiver parameter to make the associated `fn` a method
2076
LL | fn meow(&self) {
2177
| +++++
2278

79+
error[E0425]: cannot find function `shave` in this scope
80+
--> $DIR/issue-2356.rs:74:5
81+
|
82+
LL | shave();
83+
| ^^^^^ not found in this scope
84+
|
85+
help: consider importing this associated function
86+
|
87+
LL + use Groom::shave;
88+
|
89+
2390
error[E0425]: cannot find value `whiskers` in this scope
2491
--> $DIR/issue-2356.rs:79:5
2592
|
@@ -48,45 +115,6 @@ LL | fn main() {
48115
LL | self += 1;
49116
| ^^^^ `self` value is a keyword only available in methods with a `self` parameter
50117

51-
error[E0425]: cannot find function `shave` in this scope
52-
--> $DIR/issue-2356.rs:17:5
53-
|
54-
LL | shave();
55-
| ^^^^^ not found in this scope
56-
57-
error[E0425]: cannot find function `clone` in this scope
58-
--> $DIR/issue-2356.rs:24:5
59-
|
60-
LL | clone();
61-
| ^^^^^
62-
|
63-
help: you might have meant to call the method
64-
|
65-
LL | self.clone();
66-
| +++++
67-
68-
error[E0425]: cannot find function `default` in this scope
69-
--> $DIR/issue-2356.rs:31:5
70-
|
71-
LL | default();
72-
| ^^^^^^^
73-
|
74-
help: you might have meant to call the associated function
75-
|
76-
LL | Self::default();
77-
| ++++++
78-
79-
error[E0425]: cannot find function `shave` in this scope
80-
--> $DIR/issue-2356.rs:41:5
81-
|
82-
LL | shave(4);
83-
| ^^^^^
84-
|
85-
help: you might have meant to call the associated function
86-
|
87-
LL | Self::shave(4);
88-
| ++++++
89-
90118
error[E0425]: cannot find function `purr` in this scope
91119
--> $DIR/issue-2356.rs:43:5
92120
|
@@ -133,12 +161,6 @@ help: consider using the associated function on `Self`
133161
LL | Self::grow_older();
134162
| ++++++
135163

136-
error[E0425]: cannot find function `shave` in this scope
137-
--> $DIR/issue-2356.rs:74:5
138-
|
139-
LL | shave();
140-
| ^^^^^ not found in this scope
141-
142164
error[E0425]: cannot find function `purr_louder` in this scope
143165
--> $DIR/issue-2356.rs:86:5
144166
|

‎tests/ui/resolve/no-implicit-prelude-nested.stderr

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ error[E0425]: cannot find function `drop` in this scope
5454
LL | drop(2)
5555
| ^^^^ not found in this scope
5656
|
57-
help: consider importing this function
57+
help: consider importing one of these items
5858
|
5959
LL + use std::mem::drop;
6060
|
61+
LL + use std::ops::Drop::drop;
62+
|
6163

6264
error[E0405]: cannot find trait `Add` in this scope
6365
--> $DIR/no-implicit-prelude-nested.rs:23:10
@@ -115,10 +117,12 @@ error[E0425]: cannot find function `drop` in this scope
115117
LL | drop(2)
116118
| ^^^^ not found in this scope
117119
|
118-
help: consider importing this function
120+
help: consider importing one of these items
119121
|
120122
LL + use std::mem::drop;
121123
|
124+
LL + use std::ops::Drop::drop;
125+
|
122126

123127
error[E0405]: cannot find trait `Add` in this scope
124128
--> $DIR/no-implicit-prelude-nested.rs:38:14
@@ -176,10 +180,12 @@ error[E0425]: cannot find function `drop` in this scope
176180
LL | drop(2)
177181
| ^^^^ not found in this scope
178182
|
179-
help: consider importing this function
183+
help: consider importing one of these items
180184
|
181185
LL + use std::mem::drop;
182186
|
187+
LL + use std::ops::Drop::drop;
188+
|
183189

184190
error: aborting due to 18 previous errors
185191

‎tests/ui/resolve/no-implicit-prelude.stderr

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ error[E0425]: cannot find function `drop` in this scope
5454
LL | drop(2)
5555
| ^^^^ not found in this scope
5656
|
57-
help: consider importing this function
57+
help: consider importing one of these items
5858
|
5959
LL + use std::mem::drop;
6060
|
61+
LL + use std::ops::Drop::drop;
62+
|
6163

6264
error: aborting due to 6 previous errors
6365

‎tests/ui/resolve/resolve-assoc-suggestions.stderr

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ help: you might have meant to refer to the method
6666
|
6767
LL | self.method;
6868
| +++++
69+
help: consider importing this associated function
70+
|
71+
LL + use Tr::method;
72+
|
6973

7074
error: aborting due to 9 previous errors
7175

‎tests/ui/resolve/resolve-speculative-adjustment.stderr

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ error[E0425]: cannot find value `field` in this scope
44
LL | field;
55
| ^^^^^ not found in this scope
66

7+
error[E0425]: cannot find function `method` in this scope
8+
--> $DIR/resolve-speculative-adjustment.rs:19:13
9+
|
10+
LL | method();
11+
| ^^^^^^ not found in this scope
12+
|
13+
help: consider importing this associated function
14+
|
15+
LL + use Tr::method;
16+
|
17+
718
error[E0425]: cannot find value `field` in this scope
819
--> $DIR/resolve-speculative-adjustment.rs:23:9
920
|
@@ -25,12 +36,10 @@ help: you might have meant to call the method
2536
|
2637
LL | self.method();
2738
| +++++
28-
29-
error[E0425]: cannot find function `method` in this scope
30-
--> $DIR/resolve-speculative-adjustment.rs:19:13
39+
help: consider importing this associated function
40+
|
41+
LL + use Tr::method;
3142
|
32-
LL | method();
33-
| ^^^^^^ not found in this scope
3443

3544
error: aborting due to 4 previous errors
3645

‎tests/ui/resolve/typo-suggestion-for-variable-with-name-similar-to-struct-field.stderr

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,28 @@ help: a local variable with a similar name exists
3131
LL | println!("{cofig}");
3232
| ~~~~~
3333

34+
error[E0425]: cannot find function `baz` in this scope
35+
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:31:9
36+
|
37+
LL | baz();
38+
| ^^^
39+
...
40+
LL | fn ba() {}
41+
| ------- similarly named function `ba` defined here
42+
|
43+
help: you might have meant to call the method
44+
|
45+
LL | self.baz();
46+
| +++++
47+
help: a function with a similar name exists
48+
|
49+
LL | ba();
50+
| ~~
51+
help: consider importing this associated function
52+
|
53+
LL + use B::baz;
54+
|
55+
3456
error[E0425]: cannot find value `bah` in this scope
3557
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:33:9
3658
|
@@ -48,6 +70,10 @@ help: a function with a similar name exists
4870
|
4971
LL | ba;
5072
| ~~
73+
help: consider importing this associated function
74+
|
75+
LL + use B::bah;
76+
|
5177

5278
error[E0425]: cannot find value `BAR` in this scope
5379
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:35:9
@@ -66,6 +92,10 @@ help: a constant with a similar name exists
6692
|
6793
LL | BARR;
6894
| ~~~~
95+
help: consider importing this associated constant
96+
|
97+
LL + use B::BAR;
98+
|
6999

70100
error[E0412]: cannot find type `Baz` in this scope
71101
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:37:18
@@ -85,24 +115,6 @@ help: a type alias with a similar name exists
85115
LL | let foo: Bar = "".to_string();
86116
| ~~~
87117

88-
error[E0425]: cannot find function `baz` in this scope
89-
--> $DIR/typo-suggestion-for-variable-with-name-similar-to-struct-field.rs:31:9
90-
|
91-
LL | baz();
92-
| ^^^
93-
...
94-
LL | fn ba() {}
95-
| ------- similarly named function `ba` defined here
96-
|
97-
help: you might have meant to call the method
98-
|
99-
LL | self.baz();
100-
| +++++
101-
help: a function with a similar name exists
102-
|
103-
LL | ba();
104-
| ~~
105-
106118
error: aborting due to 7 previous errors
107119

108120
Some errors have detailed explanations: E0412, E0425.

‎tests/ui/suggestions/fn-to-method.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
struct Foo;
2+
//~^ HELP consider importing one of these associated functions
3+
//~| HELP consider importing this associated function
24

35
impl Foo {
46
fn bar(self) {}
@@ -7,11 +9,9 @@ impl Foo {
79
fn main() {
810
let x = cmp(&1, &2);
911
//~^ ERROR cannot find function `cmp` in this scope
10-
//~| HELP use the `.` operator to call the method `Ord::cmp` on `&{integer}`
1112

1213
let y = len([1, 2, 3]);
1314
//~^ ERROR cannot find function `len` in this scope
14-
//~| HELP use the `.` operator to call the method `len` on `&[{integer}]`
1515

1616
let z = bar(Foo);
1717
//~^ ERROR cannot find function `bar` in this scope

‎tests/ui/suggestions/fn-to-method.stderr

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
error[E0425]: cannot find function `cmp` in this scope
2-
--> $DIR/fn-to-method.rs:8:13
2+
--> $DIR/fn-to-method.rs:10:13
33
|
44
LL | let x = cmp(&1, &2);
55
| ^^^ not found in this scope
66
|
7-
help: use the `.` operator to call the method `Ord::cmp` on `&{integer}`
7+
help: consider importing one of these associated functions
8+
|
9+
LL + use std::cmp::Ord::cmp;
10+
|
11+
LL + use std::iter::Iterator::cmp;
812
|
9-
LL | let x = (&1).cmp(&2);
10-
| ~ ~~~~~~~~~
1113

1214
error[E0425]: cannot find function `len` in this scope
13-
--> $DIR/fn-to-method.rs:12:13
15+
--> $DIR/fn-to-method.rs:13:13
1416
|
1517
LL | let y = len([1, 2, 3]);
1618
| ^^^ not found in this scope
1719
|
18-
help: use the `.` operator to call the method `len` on `&[{integer}]`
20+
help: consider importing this associated function
1921
|
20-
LL - let y = len([1, 2, 3]);
21-
LL + let y = [1, 2, 3].len();
22+
LL + use std::iter::ExactSizeIterator::len;
2223
|
2324

2425
error[E0425]: cannot find function `bar` in this scope

‎tests/ui/suggestions/method-access-to-range-literal-typo.fixed

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
//@ run-rustfix
22

33
#![allow(unused)]
4+
#![feature(import_trait_associated_functions)]
5+
6+
use Trait::foo;
47

58
fn as_ref() -> Option<Vec<u8>> {
69
None
710
}
811
struct Type {
9-
option: Option<Vec<u8>>
12+
option: Option<Vec<u8>>,
1013
}
1114
trait Trait {
1215
fn foo(&self) -> &Vec<u8>;

‎tests/ui/suggestions/method-access-to-range-literal-typo.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
//@ run-rustfix
22

33
#![allow(unused)]
4+
#![feature(import_trait_associated_functions)]
45

56
fn as_ref() -> Option<Vec<u8>> {
67
None
78
}
89
struct Type {
9-
option: Option<Vec<u8>>
10+
option: Option<Vec<u8>>,
1011
}
1112
trait Trait {
1213
fn foo(&self) -> &Vec<u8>;

‎tests/ui/suggestions/method-access-to-range-literal-typo.stderr

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
error[E0425]: cannot find function `foo` in this scope
2-
--> $DIR/method-access-to-range-literal-typo.rs:26:22
2+
--> $DIR/method-access-to-range-literal-typo.rs:27:22
33
|
44
LL | self.option..foo().get(0)
55
| ^^^ not found in this scope
66
|
7-
help: you might have meant to write `.` instead of `..`
7+
help: consider importing this associated function
88
|
9-
LL - self.option..foo().get(0)
10-
LL + self.option.foo().get(0)
9+
LL + use Trait::foo;
1110
|
1211

1312
error[E0308]: mismatched types
14-
--> $DIR/method-access-to-range-literal-typo.rs:22:9
13+
--> $DIR/method-access-to-range-literal-typo.rs:23:9
1514
|
1615
LL | fn method(&self) -> Option<&Vec<u8>> {
1716
| ---------------- expected `Option<&Vec<u8>>` because of return type
@@ -27,7 +26,7 @@ LL + self.option.as_ref().map(|x| x)
2726
|
2827

2928
error[E0308]: mismatched types
30-
--> $DIR/method-access-to-range-literal-typo.rs:26:9
29+
--> $DIR/method-access-to-range-literal-typo.rs:27:9
3130
|
3231
LL | fn method2(&self) -> Option<&u8> {
3332
| ----------- expected `Option<&u8>` because of return type

‎tests/ui/tool-attributes/tool-attributes-misplaced-1.stderr

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,16 @@ error[E0423]: expected value, found tool attribute `rustfmt::skip`
4747
|
4848
LL | rustfmt::skip;
4949
| ^^^^^^^^^^^^^ not a value
50+
|
51+
help: consider importing this associated function instead
52+
|
53+
LL + use std::iter::Iterator::skip;
54+
|
55+
help: if you import `skip`, refer to it directly
56+
|
57+
LL - rustfmt::skip;
58+
LL + skip;
59+
|
5060

5161
error: aborting due to 8 previous errors
5262

‎tests/ui/unboxed-closures/unboxed-closures-type-mismatch-closure-from-another-scope.stderr

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,17 @@ error[E0425]: cannot find value `y` in this scope
1010
LL | closure(&mut p, &y);
1111
| ^ help: a local variable with a similar name exists: `p`
1212

13+
error[E0423]: expected function, found macro `deref`
14+
--> $DIR/unboxed-closures-type-mismatch-closure-from-another-scope.rs:13:5
15+
|
16+
LL | deref(p);
17+
| ^^^^^ not a function
18+
|
19+
help: consider importing this associated function instead
20+
|
21+
LL + use std::ops::Deref::deref;
22+
|
23+
1324
error[E0308]: mismatched types
1425
--> $DIR/unboxed-closures-type-mismatch-closure-from-another-scope.rs:9:17
1526
|
@@ -26,18 +37,6 @@ note: closure parameter defined here
2637
LL | let mut closure = expect_sig(|p, y| *p = y);
2738
| ^
2839

29-
error[E0423]: expected function, found macro `deref`
30-
--> $DIR/unboxed-closures-type-mismatch-closure-from-another-scope.rs:13:5
31-
|
32-
LL | deref(p);
33-
| ^^^^^ not a function
34-
|
35-
help: use the `.` operator to call the method `Deref::deref` on `&&()`
36-
|
37-
LL - deref(p);
38-
LL + p.deref();
39-
|
40-
4140
error: aborting due to 4 previous errors
4241

4342
Some errors have detailed explanations: E0308, E0423, E0425.

0 commit comments

Comments
 (0)
Please sign in to comment.