mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-28 23:53:55 +00:00
Improve impossible-case handling in ty::get_element_type
This commit is contained in:
parent
91d45b91e6
commit
36c4cb37ad
@ -959,16 +959,17 @@ fn type_is_tup_like(&ctxt cx, &t ty) -> bool {
|
||||
}
|
||||
|
||||
fn get_element_type(&ctxt cx, &t ty, uint i) -> t {
|
||||
assert (type_is_tup_like(cx, ty));
|
||||
alt (struct(cx, ty)) {
|
||||
case (ty_tup(?mts)) { ret mts.(i).ty; }
|
||||
case (ty_rec(?flds)) { ret flds.(i).mt.ty; }
|
||||
case (_) {
|
||||
cx.sess.bug("get_element_type called on type "
|
||||
+ ty_to_str(cx, ty) + " - expected a \
|
||||
tuple or record");
|
||||
}
|
||||
}
|
||||
// NB: This is not exhaustive -- struct(cx, ty) could be a box or a
|
||||
// tag.
|
||||
|
||||
cx.sess.bug("get_element_type called on a value other than a " +
|
||||
"tuple or record");
|
||||
}
|
||||
|
||||
fn type_is_box(&ctxt cx, &t ty) -> bool {
|
||||
|
Loading…
Reference in New Issue
Block a user