mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 10:45:18 +00:00
review comments
This commit is contained in:
parent
94ee54c425
commit
1808e4da68
@ -1033,13 +1033,14 @@ impl<'a> LoweringContext<'a> {
|
||||
/// ```
|
||||
///
|
||||
/// returns a `hir::TypeBinding` representing `Item`.
|
||||
fn lower_assoc_ty_constraint(&mut self,
|
||||
c: &AssocTyConstraint,
|
||||
itctx: ImplTraitContext<'_>)
|
||||
-> hir::TypeBinding {
|
||||
debug!("lower_assoc_ty_constraint(constraint={:?}, itctx={:?})", c, itctx);
|
||||
fn lower_assoc_ty_constraint(
|
||||
&mut self,
|
||||
constraint: &AssocTyConstraint,
|
||||
itctx: ImplTraitContext<'_>,
|
||||
) -> hir::TypeBinding {
|
||||
debug!("lower_assoc_ty_constraint(constraint={:?}, itctx={:?})", constraint, itctx);
|
||||
|
||||
let kind = match c.kind {
|
||||
let kind = match constraint.kind {
|
||||
AssocTyConstraintKind::Equality { ref ty } => hir::TypeBindingKind::Equality {
|
||||
ty: self.lower_ty(ty, itctx)
|
||||
},
|
||||
@ -1094,7 +1095,7 @@ impl<'a> LoweringContext<'a> {
|
||||
impl_trait_node_id,
|
||||
DefPathData::ImplTrait,
|
||||
ExpnId::root(),
|
||||
c.span,
|
||||
constraint.span,
|
||||
);
|
||||
|
||||
self.with_dyn_type_scope(false, |this| {
|
||||
@ -1102,7 +1103,7 @@ impl<'a> LoweringContext<'a> {
|
||||
&Ty {
|
||||
id: this.sess.next_node_id(),
|
||||
node: TyKind::ImplTrait(impl_trait_node_id, bounds.clone()),
|
||||
span: c.span,
|
||||
span: constraint.span,
|
||||
},
|
||||
itctx,
|
||||
);
|
||||
@ -1124,10 +1125,10 @@ impl<'a> LoweringContext<'a> {
|
||||
};
|
||||
|
||||
hir::TypeBinding {
|
||||
hir_id: self.lower_node_id(c.id),
|
||||
ident: c.ident,
|
||||
hir_id: self.lower_node_id(constraint.id),
|
||||
ident: constraint.ident,
|
||||
kind,
|
||||
span: c.span,
|
||||
span: constraint.span,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -427,8 +427,8 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
|
||||
ty::Predicate::WellFormed(ty) => {
|
||||
match ty::wf::obligations(
|
||||
self.selcx.infcx(),
|
||||
obligation.param_env,
|
||||
obligation.cause.body_id,
|
||||
obligation.param_env,
|
||||
obligation.cause.body_id,
|
||||
ty,
|
||||
obligation.cause.span,
|
||||
) {
|
||||
|
@ -1,22 +0,0 @@
|
||||
#![feature(associated_type_bounds)]
|
||||
|
||||
fn main() {}
|
||||
|
||||
trait Bar { type Assoc; }
|
||||
|
||||
trait Thing {
|
||||
type Out;
|
||||
fn func() -> Self::Out;
|
||||
}
|
||||
|
||||
struct AssocNoCopy;
|
||||
impl Bar for AssocNoCopy { type Assoc = String; }
|
||||
|
||||
impl Thing for AssocNoCopy {
|
||||
type Out = Box<dyn Bar<Assoc: Copy>>;
|
||||
//~^ ERROR the trait bound `std::string::String: std::marker::Copy` is not satisfied
|
||||
|
||||
fn func() -> Self::Out {
|
||||
Box::new(AssocNoCopy)
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
// This test documents that `type Out = Box<dyn Bar<Assoc: Copy>>;`
|
||||
// is allowed and will correctly reject an opaque `type Out` which
|
||||
// does not satisfy the bound `<TheType as Bar>::Assoc: Copy`.
|
||||
//
|
||||
// FIXME(rust-lang/lang): I think this behavior is logical if we want to allow
|
||||
// `dyn Trait<Assoc: Bound>` but we should decide if we want that. // Centril
|
||||
//
|
||||
// Additionally, as reported in https://github.com/rust-lang/rust/issues/63594,
|
||||
// we check that the spans for the error message are sane here.
|
||||
|
||||
#![feature(associated_type_bounds)]
|
||||
|
||||
fn main() {}
|
||||
|
||||
trait Bar { type Assoc; }
|
||||
|
||||
trait Thing {
|
||||
type Out;
|
||||
fn func() -> Self::Out;
|
||||
}
|
||||
|
||||
struct AssocNoCopy;
|
||||
impl Bar for AssocNoCopy { type Assoc = String; }
|
||||
|
||||
impl Thing for AssocNoCopy {
|
||||
type Out = Box<dyn Bar<Assoc: Copy>>;
|
||||
//~^ ERROR the trait bound `std::string::String: std::marker::Copy` is not satisfied
|
||||
|
||||
fn func() -> Self::Out {
|
||||
Box::new(AssocNoCopy)
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied
|
||||
--> $DIR/associated-item-type-issue-63594.rs:16:28
|
||||
--> $DIR/assoc-type-eq-with-dyn-atb-fail.rs:26:28
|
||||
|
|
||||
LL | type Out = Box<dyn Bar<Assoc: Copy>>;
|
||||
| ^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String`
|
Loading…
Reference in New Issue
Block a user