diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2019-08-19 12:24:06 -0700 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2019-08-19 12:24:06 -0700 |
| commit | 1808e4da68bd94393c03229550b166cafebf38e8 (patch) | |
| tree | 239331fb671dd0a1cc38f99ec1b3f589f0f6e201 /src | |
| parent | 94ee54c42504267cbbce6ec8ab8fc408161a0bc3 (diff) | |
| download | rust-1808e4da68bd94393c03229550b166cafebf38e8.tar.gz rust-1808e4da68bd94393c03229550b166cafebf38e8.zip | |
review comments
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/hir/lowering.rs | 23 | ||||
| -rw-r--r-- | src/librustc/traits/fulfill.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/associated-item/associated-item-type-issue-63594.rs | 22 | ||||
| -rw-r--r-- | src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs | 32 | ||||
| -rw-r--r-- | src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr (renamed from src/test/ui/associated-item/associated-item-type-issue-63594.stderr) | 2 |
5 files changed, 47 insertions, 36 deletions
diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 0ead9671937..d1f541afbe9 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -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, } } diff --git a/src/librustc/traits/fulfill.rs b/src/librustc/traits/fulfill.rs index f3c85277a8a..c1de4939c1d 100644 --- a/src/librustc/traits/fulfill.rs +++ b/src/librustc/traits/fulfill.rs @@ -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, ) { diff --git a/src/test/ui/associated-item/associated-item-type-issue-63594.rs b/src/test/ui/associated-item/associated-item-type-issue-63594.rs deleted file mode 100644 index 65b58b70e92..00000000000 --- a/src/test/ui/associated-item/associated-item-type-issue-63594.rs +++ /dev/null @@ -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) - } -} diff --git a/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs b/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs new file mode 100644 index 00000000000..a58cec53421 --- /dev/null +++ b/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.rs @@ -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) + } +} diff --git a/src/test/ui/associated-item/associated-item-type-issue-63594.stderr b/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr index 432a761b191..b6b49c2e903 100644 --- a/src/test/ui/associated-item/associated-item-type-issue-63594.stderr +++ b/src/test/ui/associated-type-bounds/assoc-type-eq-with-dyn-atb-fail.stderr @@ -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` |
