Check bounds when looking up type parameters
A mismatched type with more type parameters than the expected one causes `typeck` looking up out of the bound of type parameter vector, which leads to ICE. Closes #13466
This commit is contained in:
parent
ecc774f788
commit
fc043c054f
3 changed files with 36 additions and 12 deletions
|
|
@ -393,8 +393,9 @@ pub fn ty_to_str(cx: &ctxt, typ: t) -> ~str {
|
|||
ty_param(param_ty {idx: id, def_id: did}) => {
|
||||
let ident = match cx.ty_param_defs.borrow().find(&did.node) {
|
||||
Some(def) => token::get_ident(def.ident).get().to_str(),
|
||||
// This should not happen...
|
||||
None => format!("BUG[{:?}]", id)
|
||||
// This can only happen when a type mismatch error happens and
|
||||
// the actual type has more type parameters than the expected one.
|
||||
None => format!("<generic \\#{}>", id)
|
||||
};
|
||||
if !cx.sess.verbose() {
|
||||
ident
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue