diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2017-04-04 16:33:04 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-04-04 16:33:04 -0500 |
commit | abd454cfc67c6815bc9084fdf5b1405bfd5ac660 (patch) | |
tree | 39b367f354515605967d78038cc097eb867cbad9 | |
parent | e51789aab7005bbc27c27bc8700f9244cff10ce0 (diff) | |
parent | 7b6245082128645c33f96fea49509c687c0785c7 (diff) |
Auto merge of #614 - fitzgen:not-just-builtin-templates, r=emilio
Generalize template instantiation fallibility
Return `None` whenever we can't find a template definition, not only when the
template is a builtin.
Hitting this in other tests with libclang 4
r? @emilio or @upsuper
-rw-r--r-- | src/ir/template.rs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/ir/template.rs b/src/ir/template.rs index 4022b366..3484a9c6 100644 --- a/src/ir/template.rs +++ b/src/ir/template.rs @@ -100,10 +100,6 @@ impl TemplateInstantiation { .collect() }); - if ty.declaration().is_builtin() { - return None; - } - let definition = ty.declaration() .specialized() .or_else(|| { @@ -122,8 +118,18 @@ impl TemplateInstantiation { }); template_ref.and_then(|cur| cur.referenced()) - }) - .expect("Should have found the template definition one way or another"); + }); + + let definition = match definition { + Some(def) => def, + None => { + if !ty.declaration().is_builtin() { + warn!("Could not find template definition for template \ + instantiation"); + } + return None + } + }; let template_definition = Item::from_ty_or_ref(definition.cur_type(), definition, None, ctx); |