Closed
Description
A couple of days ago it was all working fine, but in a fresh build (rustc 1.0.0-dev (593db005d 2015-03-25) (built 2015-03-25)
) trouble is happening:
#![allow(dead_code)]
// Note that it’s got to be *const T; T compiles fine!
fn gimme_a_raw_pointer<T>(_: *const T) { }
fn gimme_a_raw_pointer_to_unit(_: *const ()) { }
fn gimme_a_raw_pointer_to_a_u8(_: *const u8) { }
fn main() {
// This builds fine:
//let pointer: *const _ = &();
// But add an `as *const _` (the type ascription on `let pointer` is optional and meaningless):
let pointer = &() as *const _;
// Clearly `pointer` must be of type `*const ()`.
// The real failure case was a “simple” `println!("{:?}", pointer)`.
// I have extracted the essence of the failure here:
gimme_a_raw_pointer(pointer);
// Uncomment either of these two and it will suddenly figure out that that _ has got to be ().
//gimme_a_raw_pointer_to_unit(pointer);
//gimme_a_raw_pointer_to_a_u8(pointer);
}
<anon>:18:5: 18:24 error: unable to infer enough type information about `_`; type annotations required [E0282]
<anon>:18 gimme_a_raw_pointer(pointer);
^~~~~~~~~~~~~~~~~~~
error: aborting due to previous error