Expand is_uninhabited for references

This commit is contained in:
Andrew Cann 2016-09-15 01:11:11 +08:00
parent 75140512eb
commit f1bdd4fae2
2 changed files with 8 additions and 7 deletions

View File

@ -178,8 +178,9 @@ enum Void {}
issue = "0")]
#[doc(hidden)]
pub struct ArgumentV1<'a> {
value: &'a Void,
formatter: fn(&Void, &mut Formatter) -> Result,
_ph: PhantomData<&'a ()>,
value: *const Void,
formatter: fn(*const Void, &mut Formatter) -> Result,
}
#[unstable(feature = "fmt_internals", reason = "internal to format_args!",
@ -203,6 +204,7 @@ impl<'a> ArgumentV1<'a> {
f: fn(&T, &mut Formatter) -> Result) -> ArgumentV1<'b> {
unsafe {
ArgumentV1 {
_ph: PhantomData,
formatter: mem::transmute(f),
value: mem::transmute(x)
}
@ -218,7 +220,7 @@ impl<'a> ArgumentV1<'a> {
fn as_usize(&self) -> Option<usize> {
if self.formatter as usize == ArgumentV1::show_usize as usize {
Some(unsafe { *(self.value as *const _ as *const usize) })
Some(unsafe { *(self.value as *const usize) })
} else {
None
}

View File

@ -946,11 +946,10 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
},
TyNever => true,
TyTuple(ref tys) => tys.iter().any(|ty| ty.is_uninhabited(cx)),
TyArray(ty, len) => len > 0 && ty.is_uninhabited(cx),
TyTuple(ref tys) => tys.iter().any(|ty| ty.is_uninhabited_recurse(visited, cx)),
TyArray(ty, len) => len > 0 && ty.is_uninhabited_recurse(visited, cx),
TyRef(_, ref tm) => tm.ty.is_uninhabited_recurse(visited, cx),
// FIXME(canndrew): this line breaks core::fmt
//TyRef(_, ref tm) => tm.ty.is_uninhabited(cx),
_ => false,
}
}