Skip to content

Commit

Permalink
Don't ICE just because an impl is missing an associated type. Trust i…
Browse files Browse the repository at this point in the history
…n the other compiler passes.

Fixes #17359.
  • Loading branch information
nikomatsakis committed Jan 5, 2015
1 parent c886894 commit 540a777
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/librustc/middle/traits/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,12 @@ fn confirm_candidate<'cx,'tcx>(
match impl_ty {
Some(ty) => (ty, impl_vtable.nested.to_vec()),
None => {
selcx.tcx().sess.span_bug(
obligation.cause.span,
format!("impl `{}` did not contain projection for `{}`",
impl_vtable.repr(selcx.tcx()),
obligation.repr(selcx.tcx())).as_slice());
// This means that the impl is missing a
// definition for the associated type. This error
// ought to be reported by the type checker method
// `check_impl_items_against_trait`, so here we
// just return ty_err.
(selcx.tcx().types.err, vec!())
}
}
}
Expand Down
23 changes: 23 additions & 0 deletions src/test/compile-fail/associated-types-issue-17359.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

// Test that we do not ICE when an impl is missing an associated type (and that we report
// a useful error, of course).

#![feature(associated_types)]

trait Trait {
type Type;
}

impl Trait for int {} //~ ERROR missing: `Type`

fn main() {}

0 comments on commit 540a777

Please sign in to comment.