提交 4038b5b3 编写于 作者: N Niko Matsakis

add def-ids from nominal types into TraitSelect

This way we distinguish, in particular, `Foo: Sized`
and `Bar: Sized`, which fixes #33850.
上级 63bb0847
......@@ -946,7 +946,28 @@ pub fn def_id(&self) -> DefId {
/// Creates the dep-node for selecting/evaluating this trait reference.
fn dep_node(&self) -> DepNode<DefId> {
DepNode::TraitSelect(self.def_id(), vec![])
// Ideally, the dep-node would just have all the input types
// in it. But they are limited to including def-ids. So as an
// approximation we include the def-ids for all nominal types
// found somewhere. This means that we will e.g. conflate the
// dep-nodes for `u32: SomeTrait` and `u64: SomeTrait`, but we
// would have distinct dep-nodes for `Vec<u32>: SomeTrait`,
// `Rc<u32>: SomeTrait`, and `(Vec<u32>, Rc<u32>): SomeTrait`.
// Note that it's always sound to conflate dep-nodes, it jus
// leads to more recompilation.
let def_ids: Vec<_> =
self.input_types()
.iter()
.flat_map(|t| t.walk())
.filter_map(|t| match t.sty {
ty::TyStruct(adt_def, _) |
ty::TyEnum(adt_def, _) =>
Some(adt_def.did),
_ =>
None
})
.collect();
DepNode::TraitSelect(self.def_id(), def_ids)
}
pub fn input_types(&self) -> &[Ty<'tcx>] {
......
......@@ -40,7 +40,7 @@ pub fn use_EmbedX(embed: EmbedX) -> u32 {
embed.x.x as u32
}
#[rustc_dirty(label="TypeckItemBody", cfg="rpass2")] // FIXME(#33850) should be clean
#[rustc_clean(label="TypeckItemBody", cfg="rpass2")]
pub fn use_Y() {
let x: Y = Y { y: 'c' };
}
......
......@@ -47,7 +47,7 @@ pub fn use_EmbedX(embed: EmbedX) -> u32 {
//[cfail2]~^ ERROR attempted access of field `x`
}
#[rustc_dirty(label="TypeckItemBody", cfg="cfail2")] // FIXME(#33850) should be clean
#[rustc_clean(label="TypeckItemBody", cfg="cfail2")]
pub fn use_Y() {
let x: Y = Y { y: 'c' };
}
......
......@@ -45,7 +45,7 @@ pub fn use_EmbedX(x: EmbedX) -> u32 {
x.x as u32
}
#[rustc_dirty(label="TypeckItemBody", cfg="rpass2")] // FIXME(#33850) should be clean
#[rustc_clean(label="TypeckItemBody", cfg="rpass2")]
pub fn use_Y() {
let x: Y = Y { y: 'c' };
}
......
......@@ -28,7 +28,7 @@ pub fn use_EmbedX(embed: EmbedX) -> u32 {
embed.x.x as u32
}
#[rustc_dirty(label="TypeckItemBody", cfg="rpass2")] // FIXME(#33850) should be clean
#[rustc_clean(label="TypeckItemBody", cfg="rpass2")]
pub fn use_Y() {
let x: Y = Y { y: 'c' };
}
......
......@@ -44,7 +44,7 @@ pub fn use_EmbedX(embed: EmbedX) -> u32 {
embed.x.x as u32
}
#[rustc_dirty(label="TypeckItemBody", cfg="rpass2")] // FIXME(#33850) should be clean
#[rustc_clean(label="TypeckItemBody", cfg="rpass2")]
pub fn use_Y() {
let x: Y = Y { y: 'c' };
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册