Open kmcallister opened 9 years ago
cc @nick29581
Once this is fixed, I will submit a patch I wrote that ICEs when add_lint
is called in the wrong place.
@nick29581: Any thoughts on this? I think we should fix this for 1.0 or remove the lint for now, because it never prints anything.
I think we should fix it :-) Do you know how hard it would be to do another lint pass after trans?
I think it's worth a shot. It would also eliminate a bunch of hacks for the existing variant size lint in trans.
If we leave these two lints hardcoded then we don't need a full pass, we just need to go through the session / AST and print out saved lints, which I think could be factored out easily enough.
Still broken. Updated test:
#![deny(fat_ptr_transmutes)]
use std::mem;
fn main() {
let x: [u8; 8] = [0; 8];
let y: [u8; 16] = unsafe {
mem::transmute(&x[..])
};
println!("{:?}", &x[..]);
}
Triage: no change.
As far as I can tell, this lint is never invoked today (even in trans); it's previous use was removed by @nikomatsakis in c5edd22646fcde05b39490558371c7ea9d525a0f. @nikomatsakis, could you comment on what the reasoning there was? I feel like it might've been an accidental removal...
Looking into the code seems to suggest that the problem is that with slices, the representation (as I understand it) is *(usize, usize)
so the type's size is the "same" in this case. That would explain why we don't detect this, I believe, though I may be wrong about my reasoning here.
@Mark-Simulacrum hmm I do think that was an accident, or perhaps a merge failure.
This lint appears to have been completely removed, and trying to use it emits a "removed lint" warning. Should this issue be closed?
compiles and runs with no warnings. The problem is that
trans::intrinsic::check_intrinsics
callsSession::add_lint
but the pass that emits these lints has already run. See this comment inrustc::lint
.Please add a test case when fixing this! :)