Closed
Description
While reviewing the list of active feature gates and double-checking the behavior of visible_private_types
, I found that the check is not working for e.g. the program below:
mod a {
#[derive(Debug)]
struct S { x: i32 }
pub fn foo() -> S { S { x: 3 } }
impl S { }
}
mod b {
use a;
#[cfg(expected)]
pub fn call_foo() {
let s: a::S = a::foo();
println!("{:?}", s);
}
#[cfg(not(expected))]
pub fn call_foo() {
let s = a::foo();
println!("{:?}", s);
}
}
fn main() {
b::call_foo();
}
In the playpen, the above compiles and runs. I expected to see an error due to the type of a::foo
returning the private type a::S
.