File tree Expand file tree Collapse file tree 4 files changed +87
-0
lines changed Expand file tree Collapse file tree 4 files changed +87
-0
lines changed Original file line number Diff line number Diff line change
1
+ pub trait A {
2
+ fn foo ( ) { }
3
+ }
Original file line number Diff line number Diff line change
1
+ //@ aux-crate:priv:private_dep=private-dep.rs
2
+ //@ compile-flags: -Zunstable-options
3
+
4
+ extern crate private_dep;
5
+ use private_dep:: A ;
6
+
7
+ pub struct B ;
8
+
9
+ impl A for B {
10
+ fn foo ( ) { }
11
+ }
Original file line number Diff line number Diff line change
1
+ // Don't suggest importing a function from a private dependency.
2
+ // Issues: #138191, #142676
3
+
4
+ // Avoid suggesting traits from std-private deps
5
+ //@ forbid-output: compiler_builtins
6
+ //@ forbid-output: object
7
+
8
+ // Check a custom trait to withstand changes in above crates
9
+ //@ aux-crate:public_dep=public-dep.rs
10
+ //@ compile-flags: -Zunstable-options
11
+ //@ forbid-output: private_dep
12
+
13
+ struct VecReader ( Vec < u8 > ) ;
14
+
15
+ impl std:: io:: Read for VecReader {
16
+ fn read ( & mut self , buf : & mut [ u8 ] ) -> std:: io:: Result < usize > {
17
+ self . 0 . read ( buf)
18
+ //~^ ERROR no method named `read` found for struct `Vec<u8>`
19
+ }
20
+ }
21
+
22
+ extern crate public_dep;
23
+ use public_dep:: B ;
24
+
25
+ fn main ( ) {
26
+ let _ = u8:: cast_from_lossy ( 9 ) ;
27
+ //~^ ERROR no function or associated item named `cast_from_lossy` found for type `u8`
28
+ let _ = B :: foo ( ) ;
29
+ //~^ ERROR no function or associated item named `foo` found for struct `B`
30
+ }
Original file line number Diff line number Diff line change
1
+ error[E0599]: no method named `read` found for struct `Vec<u8>` in the current scope
2
+ --> $DIR/dont-suggest-private-dependencies.rs:17:16
3
+ |
4
+ LL | self.0.read(buf)
5
+ | ^^^^
6
+ |
7
+ = help: items from traits can only be used if the trait is in scope
8
+ help: trait `ReadRef` which provides `read` is implemented but not in scope; perhaps you want to import it
9
+ |
10
+ LL + use object::read::read_ref::ReadRef;
11
+ |
12
+ help: there is a method `read_at` with a similar name
13
+ |
14
+ LL | self.0.read_at(buf)
15
+ | +++
16
+
17
+ error[E0599]: no function or associated item named `cast_from_lossy` found for type `u8` in the current scope
18
+ --> $DIR/dont-suggest-private-dependencies.rs:26:17
19
+ |
20
+ LL | let _ = u8::cast_from_lossy(9);
21
+ | ^^^^^^^^^^^^^^^ function or associated item not found in `u8`
22
+ |
23
+ = help: items from traits can only be used if the trait is in scope
24
+ help: trait `CastFrom` which provides `cast_from_lossy` is implemented but not in scope; perhaps you want to import it
25
+ |
26
+ LL + use compiler_builtins::math::libm_math::support::int_traits::CastFrom;
27
+ |
28
+
29
+ error[E0599]: no function or associated item named `foo` found for struct `B` in the current scope
30
+ --> $DIR/dont-suggest-private-dependencies.rs:28:16
31
+ |
32
+ LL | let _ = B::foo();
33
+ | ^^^ function or associated item not found in `B`
34
+ |
35
+ = help: items from traits can only be used if the trait is in scope
36
+ help: trait `A` which provides `foo` is implemented but not in scope; perhaps you want to import it
37
+ |
38
+ LL + use private_dep::A;
39
+ |
40
+
41
+ error: aborting due to 3 previous errors
42
+
43
+ For more information about this error, try `rustc --explain E0599`.
You can’t perform that action at this time.
0 commit comments