Skip to content

Commit 1808e4d

Browse files
committed
review comments
1 parent 94ee54c commit 1808e4d

File tree

5 files changed

+47
-36
lines changed

5 files changed

+47
-36
lines changed

src/librustc/hir/lowering.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,13 +1033,14 @@ impl<'a> LoweringContext<'a> {
10331033
/// ```
10341034
///
10351035
/// returns a `hir::TypeBinding` representing `Item`.
1036-
fn lower_assoc_ty_constraint(&mut self,
1037-
c: &AssocTyConstraint,
1038-
itctx: ImplTraitContext<'_>)
1039-
-> hir::TypeBinding {
1040-
debug!("lower_assoc_ty_constraint(constraint={:?}, itctx={:?})", c, itctx);
1036+
fn lower_assoc_ty_constraint(
1037+
&mut self,
1038+
constraint: &AssocTyConstraint,
1039+
itctx: ImplTraitContext<'_>,
1040+
) -> hir::TypeBinding {
1041+
debug!("lower_assoc_ty_constraint(constraint={:?}, itctx={:?})", constraint, itctx);
10411042

1042-
let kind = match c.kind {
1043+
let kind = match constraint.kind {
10431044
AssocTyConstraintKind::Equality { ref ty } => hir::TypeBindingKind::Equality {
10441045
ty: self.lower_ty(ty, itctx)
10451046
},
@@ -1094,15 +1095,15 @@ impl<'a> LoweringContext<'a> {
10941095
impl_trait_node_id,
10951096
DefPathData::ImplTrait,
10961097
ExpnId::root(),
1097-
c.span,
1098+
constraint.span,
10981099
);
10991100

11001101
self.with_dyn_type_scope(false, |this| {
11011102
let ty = this.lower_ty(
11021103
&Ty {
11031104
id: this.sess.next_node_id(),
11041105
node: TyKind::ImplTrait(impl_trait_node_id, bounds.clone()),
1105-
span: c.span,
1106+
span: constraint.span,
11061107
},
11071108
itctx,
11081109
);
@@ -1124,10 +1125,10 @@ impl<'a> LoweringContext<'a> {
11241125
};
11251126

11261127
hir::TypeBinding {
1127-
hir_id: self.lower_node_id(c.id),
1128-
ident: c.ident,
1128+
hir_id: self.lower_node_id(constraint.id),
1129+
ident: constraint.ident,
11291130
kind,
1130-
span: c.span,
1131+
span: constraint.span,
11311132
}
11321133
}
11331134

src/librustc/traits/fulfill.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,8 @@ impl<'a, 'b, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'b, 'tcx> {
427427
ty::Predicate::WellFormed(ty) => {
428428
match ty::wf::obligations(
429429
self.selcx.infcx(),
430-
obligation.param_env,
431-
obligation.cause.body_id,
430+
obligation.param_env,
431+
obligation.cause.body_id,
432432
ty,
433433
obligation.cause.span,
434434
) {

src/test/ui/associated-item/associated-item-type-issue-63594.rs

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// This test documents that `type Out = Box<dyn Bar<Assoc: Copy>>;`
2+
// is allowed and will correctly reject an opaque `type Out` which
3+
// does not satisfy the bound `<TheType as Bar>::Assoc: Copy`.
4+
//
5+
// FIXME(rust-lang/lang): I think this behavior is logical if we want to allow
6+
// `dyn Trait<Assoc: Bound>` but we should decide if we want that. // Centril
7+
//
8+
// Additionally, as reported in https://github.com/rust-lang/rust/issues/63594,
9+
// we check that the spans for the error message are sane here.
10+
11+
#![feature(associated_type_bounds)]
12+
13+
fn main() {}
14+
15+
trait Bar { type Assoc; }
16+
17+
trait Thing {
18+
type Out;
19+
fn func() -> Self::Out;
20+
}
21+
22+
struct AssocNoCopy;
23+
impl Bar for AssocNoCopy { type Assoc = String; }
24+
25+
impl Thing for AssocNoCopy {
26+
type Out = Box<dyn Bar<Assoc: Copy>>;
27+
//~^ ERROR the trait bound `std::string::String: std::marker::Copy` is not satisfied
28+
29+
fn func() -> Self::Out {
30+
Box::new(AssocNoCopy)
31+
}
32+
}

src/test/ui/associated-item/associated-item-type-issue-63594.stderr renamed to src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: the trait bound `std::string::String: std::marker::Copy` is not satisfied
2-
--> $DIR/associated-item-type-issue-63594.rs:16:28
2+
--> $DIR/assoc-type-eq-with-dyn-atb-fail.rs:26:28
33
|
44
LL | type Out = Box<dyn Bar<Assoc: Copy>>;
55
| ^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::string::String`

0 commit comments

Comments
 (0)