From 5e38020b84d300b68befa65f73f0335bcd2fdca0 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 4 Apr 2017 13:48:34 -0700 Subject: Generalize fallibility template instantiation fallibility Return `None` whenever we can't find a template definition, not only when the template is a builtin. --- src/ir/template.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ir/template.rs b/src/ir/template.rs index 4022b366..18a3f805 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,12 @@ impl TemplateInstantiation { }); template_ref.and_then(|cur| cur.referenced()) - }) - .expect("Should have found the template definition one way or another"); + }); + + let definition = match definition { + None => return None, + Some(def) => def, + }; let template_definition = Item::from_ty_or_ref(definition.cur_type(), definition, None, ctx); -- cgit v1.2.3 From 7b6245082128645c33f96fea49509c687c0785c7 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Tue, 4 Apr 2017 14:31:43 -0700 Subject: Warn when we can't find a template definition But only if the type is not a builtin type. If it is a builtin type, then it's expected that we won't have a definition. --- src/ir/template.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ir/template.rs b/src/ir/template.rs index 18a3f805..3484a9c6 100644 --- a/src/ir/template.rs +++ b/src/ir/template.rs @@ -121,8 +121,14 @@ impl TemplateInstantiation { }); let definition = match definition { - None => return None, Some(def) => def, + None => { + if !ty.declaration().is_builtin() { + warn!("Could not find template definition for template \ + instantiation"); + } + return None + } }; let template_definition = -- cgit v1.2.3