File tree Expand file tree Collapse file tree 2 files changed +29
-19
lines changed Expand file tree Collapse file tree 2 files changed +29
-19
lines changed Original file line number Diff line number Diff line change 1
- #![ crate_type="lib" ]
2
- #![ deny( warnings) ]
3
- #![ allow( dead_code) ]
1
+ //! Auxilary file for testing `dead_code` lint. This crate is compiled as a library and exposes
2
+ //! aliased types. When used externally, there should not be warnings of `dead_code`
3
+ //!
4
+ //! Issue: <https://github.com/rust-lang/rust/issues/14421>
4
5
5
- pub use src:: aliases:: B ;
6
- pub use src:: hidden_core:: make;
6
+ // Expose internal types to be used in external test
7
+ pub use src:: aliases:: ExposedType ;
8
+ pub use src:: hidden_core:: new;
7
9
8
10
mod src {
9
11
pub mod aliases {
10
- use super :: hidden_core:: A ;
11
- pub type B = A < f32 > ;
12
+ use super :: hidden_core:: InternalStruct ;
13
+ pub type ExposedType = InternalStruct < f32 > ;
12
14
}
13
15
14
16
pub mod hidden_core {
15
- use super :: aliases:: B ;
17
+ use super :: aliases:: ExposedType ;
16
18
17
- pub struct A < T > { t : T }
19
+ pub struct InternalStruct < T > {
20
+ _x : T ,
21
+ }
18
22
19
- pub fn make ( ) -> B { A { t : 1.0 } }
23
+ pub fn new ( ) -> ExposedType {
24
+ InternalStruct { _x : 1.0 }
25
+ }
20
26
21
- impl < T > A < T > {
22
- pub fn foo ( & mut self ) { println ! ( "called foo" ) ; }
27
+ impl < T > InternalStruct < T > {
28
+ pub fn foo ( & mut self ) {
29
+ println ! ( "called foo" ) ;
30
+ }
23
31
}
24
32
}
25
33
}
Original file line number Diff line number Diff line change 1
- //@ run-pass
2
- #![ allow( non_snake_case) ]
1
+ //! Regression test to ensure that `dead_code` warning does not get triggered when using re-exported
2
+ //! types that are exposed from a different crate
3
+ //!
4
+ //! Issue: <https://github.com/rust-lang/rust/issues/14421>
3
5
6
+ //@ check-pass
4
7
//@ aux-build:issue-14421.rs
5
8
6
-
7
9
extern crate issue_14421 as bug_lib;
8
10
9
- use bug_lib:: B ;
10
- use bug_lib:: make ;
11
+ use bug_lib:: ExposedType ;
12
+ use bug_lib:: new ;
11
13
12
14
pub fn main ( ) {
13
- let mut an_A : B = make ( ) ;
14
- an_A . foo ( ) ;
15
+ let mut x : ExposedType = new ( ) ;
16
+ x . foo ( ) ;
15
17
}
You can’t perform that action at this time.
0 commit comments