Don't ICE just because an impl is missing an associated type. Trust in the other compiler passes.
Fixes #17359.
This commit is contained in:
parent
c8868942e8
commit
540a7777b8
@ -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!())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
23
src/test/compile-fail/associated-types-issue-17359.rs
Normal file
23
src/test/compile-fail/associated-types-issue-17359.rs
Normal file
@ -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() {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user