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>
45
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;
79
810mod src {
911 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 > ;
1214 }
1315
1416 pub mod hidden_core {
15- use super :: aliases:: B ;
17+ use super :: aliases:: ExposedType ;
1618
17- pub struct A < T > { t : T }
19+ pub struct InternalStruct < T > {
20+ _x : T ,
21+ }
1822
19- pub fn make ( ) -> B { A { t : 1.0 } }
23+ pub fn new ( ) -> ExposedType {
24+ InternalStruct { _x : 1.0 }
25+ }
2026
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+ }
2331 }
2432 }
2533}
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>
35
6+ //@ check-pass
47//@ aux-build:issue-14421.rs
58
6-
79extern crate issue_14421 as bug_lib;
810
9- use bug_lib:: B ;
10- use bug_lib:: make ;
11+ use bug_lib:: ExposedType ;
12+ use bug_lib:: new ;
1113
1214pub fn main ( ) {
13- let mut an_A : B = make ( ) ;
14- an_A . foo ( ) ;
15+ let mut x : ExposedType = new ( ) ;
16+ x . foo ( ) ;
1517}
You can’t perform that action at this time.
0 commit comments