Fix compile panic on non existant type return #53300
This commit is contained in:
parent
588e6e969e
commit
ec47293998
2 changed files with 41 additions and 1 deletions
|
|
@ -1163,7 +1163,25 @@ fn type_of<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Ty<'tcx> {
|
|||
ItemKind::Existential(hir::ExistTy {
|
||||
impl_trait_fn: Some(owner),
|
||||
..
|
||||
}) => tcx.typeck_tables_of(owner).concrete_existential_types[&def_id],
|
||||
}) => {
|
||||
tcx.typeck_tables_of(owner)
|
||||
.concrete_existential_types
|
||||
.get(&def_id)
|
||||
.cloned()
|
||||
.unwrap_or_else(|| {
|
||||
// This can occur if some error in the
|
||||
// owner fn prevented us from populating
|
||||
// the `concrete_existential_types` table.
|
||||
tcx.sess.delay_span_bug(
|
||||
DUMMY_SP,
|
||||
&format!(
|
||||
"owner {:?} has no existential type for {:?} in its tables",
|
||||
owner, def_id,
|
||||
),
|
||||
);
|
||||
tcx.types.err
|
||||
})
|
||||
}
|
||||
ItemKind::Trait(..)
|
||||
| ItemKind::TraitAlias(..)
|
||||
| ItemKind::Mod(..)
|
||||
|
|
|
|||
22
src/test/compile-fail/issue-53300.rs
Normal file
22
src/test/compile-fail/issue-53300.rs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright 2012-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.
|
||||
|
||||
// issue 53300
|
||||
|
||||
pub trait A {
|
||||
fn add(&self, b: i32) -> i32;
|
||||
}
|
||||
|
||||
fn addition() -> Wrapper<impl A> {}
|
||||
//~^ ERROR cannot find type `Wrapper` in this scope [E0412]
|
||||
|
||||
fn main() {
|
||||
let res = addition();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue