Skip to content

Commit f76f6fb

Browse files
committed
Auto merge of #50271 - sinkuu:fix_ice, r=eddyb
Fix ICE #48984 * ~~fbf6423 The tail type was not normalized.~~ * d0839d5 The method had a wrong assumption that something whose parent is a trait is an associated item. Fixes #48984.
2 parents f4c1f0c + 9fc2595 commit f76f6fb

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

src/librustc_metadata/decoder.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,13 @@ impl<'a, 'tcx> CrateMetadata {
977977
}
978978

979979
pub fn get_trait_of_item(&self, id: DefIndex) -> Option<DefId> {
980-
self.def_key(id).parent.and_then(|parent_index| {
980+
let def_key = self.def_key(id);
981+
match def_key.disambiguated_data.data {
982+
DefPathData::TypeNs(..) | DefPathData::ValueNs(..) => (),
983+
// Not an associated item
984+
_ => return None,
985+
}
986+
def_key.parent.and_then(|parent_index| {
981987
match self.entry(parent_index).kind {
982988
EntryKind::Trait(_) => Some(self.local_def_id(parent_index)),
983989
_ => None,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#![crate_type = "lib"]
12+
#![crate_name = "issue48984aux"]
13+
14+
pub trait Foo { type Item; }
15+
16+
pub trait Bar: Foo<Item=[u8;1]> { }

src/test/run-pass/issue-48984.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// aux-build:issue-48984-aux.rs
12+
extern crate issue48984aux;
13+
use issue48984aux::Bar;
14+
15+
fn do_thing<T: Bar>() { }
16+
17+
fn main() { }

0 commit comments

Comments
 (0)