From: bors Date: Sun, 29 Apr 2018 03:01:09 +0000 (+0000) Subject: Auto merge of #50271 - sinkuu:fix_ice, r=eddyb X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=f76f6fbdea497c3cb536e33387f405cc74b99b76;hp=f4c1f0ce93137049bd6c25d3289bf12bfc00426d;p=rust.git Auto merge of #50271 - sinkuu:fix_ice, r=eddyb Fix ICE #48984 * ~~fbf6423 The tail type was not normalized.~~ * https://github.com/rust-lang/rust/commit/d0839d5680d2a51785eeb0811cf3e2beba90eacb The method had a wrong assumption that something whose parent is a trait is an associated item. Fixes #48984. --- diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 388bf1fb99a..57f92707ccf 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -977,7 +977,13 @@ pub fn get_implementations_for_trait(&self, } pub fn get_trait_of_item(&self, id: DefIndex) -> Option { - self.def_key(id).parent.and_then(|parent_index| { + let def_key = self.def_key(id); + match def_key.disambiguated_data.data { + DefPathData::TypeNs(..) | DefPathData::ValueNs(..) => (), + // Not an associated item + _ => return None, + } + def_key.parent.and_then(|parent_index| { match self.entry(parent_index).kind { EntryKind::Trait(_) => Some(self.local_def_id(parent_index)), _ => None, diff --git a/src/test/run-pass/auxiliary/issue-48984-aux.rs b/src/test/run-pass/auxiliary/issue-48984-aux.rs new file mode 100644 index 00000000000..6290279701e --- /dev/null +++ b/src/test/run-pass/auxiliary/issue-48984-aux.rs @@ -0,0 +1,16 @@ +// Copyright 2018 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "lib"] +#![crate_name = "issue48984aux"] + +pub trait Foo { type Item; } + +pub trait Bar: Foo { } diff --git a/src/test/run-pass/issue-48984.rs b/src/test/run-pass/issue-48984.rs new file mode 100644 index 00000000000..227ad4e58f1 --- /dev/null +++ b/src/test/run-pass/issue-48984.rs @@ -0,0 +1,17 @@ +// Copyright 2018 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 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// aux-build:issue-48984-aux.rs +extern crate issue48984aux; +use issue48984aux::Bar; + +fn do_thing() { } + +fn main() { }