Navigation Menu

Skip to content

Commit

Permalink
Expand is_uninhabited for references
Browse files Browse the repository at this point in the history
  • Loading branch information
canndrew committed Nov 22, 2016
1 parent 7514051 commit f1bdd4f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/libcore/fmt/mod.rs
Expand Up @@ -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!",
Expand All @@ -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)
}
Expand All @@ -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
}
Expand Down
7 changes: 3 additions & 4 deletions src/librustc/ty/sty.rs
Expand Up @@ -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,
}
}
Expand Down

0 comments on commit f1bdd4f

Please sign in to comment.