提交 98eb29cb 编写于 作者: M Matthew McAllister

Fix trait alias inherent impl resolution

Fixes #60021 and #72415.
上级 963bf528
......@@ -795,6 +795,7 @@ fn assemble_inherent_candidates_from_object(&mut self, self_ty: Ty<'tcx>) {
fn assemble_inherent_candidates_from_param(&mut self, param_ty: ty::ParamTy) {
// FIXME: do we want to commit to this behavior for param bounds?
debug!("assemble_inherent_candidates_from_param(param_ty={:?})", param_ty);
let bounds = self.param_env.caller_bounds.iter().filter_map(|predicate| match *predicate {
ty::Predicate::Trait(ref trait_predicate, _) => {
......@@ -949,7 +950,7 @@ fn assemble_extension_candidates_for_trait(
import_ids: import_ids.clone(),
kind: TraitCandidate(new_trait_ref),
},
true,
false,
);
});
} else {
......
// check-pass
#![feature(trait_alias)]
trait SomeTrait {
fn map(&self) {}
}
impl<T> SomeTrait for Option<T> {}
trait SomeAlias = SomeTrait;
fn main() {
let x = Some(123);
// This should resolve to the trait impl for Option
Option::map(x, |z| z);
// This should resolve to the trait impl for SomeTrait
SomeTrait::map(&x);
}
// check-pass
#![feature(trait_alias)]
trait Bounded { const MAX: Self; }
impl Bounded for u32 {
// This should correctly resolve to the associated const in the inherent impl of u32.
const MAX: Self = u32::MAX;
}
trait Num = Bounded + Copy;
fn main() {}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册