From 6c8251dcb5b6f4e5e73a0a69538e490bae3dea30 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 27 Aug 2018 18:39:32 -0400 Subject: [PATCH 1/2] resolve where clauses in types in impls --- src/librustc_resolve/lib.rs | 4 +-- src/librustc_typeck/astconv.rs | 5 +--- .../issue-47206.rs | 27 +++++++++++++++++++ 3 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 src/test/ui/rfc1598-generic-associated-types/issue-47206.rs diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 264f5c0113581..0d2fbacffdbb2 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -2525,7 +2525,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { visit::walk_impl_item(this, impl_item); } - ImplItemKind::Type(ref ty) => { + ImplItemKind::Type(..) => { // If this is a trait impl, ensure the type // exists in trait this.check_trait_item(impl_item.ident, @@ -2533,7 +2533,7 @@ impl<'a, 'crateloader: 'a> Resolver<'a, 'crateloader> { impl_item.span, |n, s| TypeNotMemberOfTrait(n, s)); - this.visit_ty(ty); + visit::walk_impl_item(this, impl_item); } ImplItemKind::Existential(ref bounds) => { // If this is a trait impl, ensure the type diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index 3c9452835fde9..302f20434e59b 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -30,7 +30,7 @@ use std::slice; use require_c_abi_if_variadic; use util::common::ErrorReported; use util::nodemap::{FxHashSet, FxHashMap}; -use errors::{FatalError, DiagnosticId}; +use errors::DiagnosticId; use lint; use std::iter; @@ -693,9 +693,6 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o { match path.def { Def::Trait(trait_def_id) => trait_def_id, Def::TraitAlias(alias_def_id) => alias_def_id, - Def::Err => { - FatalError.raise(); - } _ => unreachable!(), } } diff --git a/src/test/ui/rfc1598-generic-associated-types/issue-47206.rs b/src/test/ui/rfc1598-generic-associated-types/issue-47206.rs new file mode 100644 index 0000000000000..e13e0f522dddf --- /dev/null +++ b/src/test/ui/rfc1598-generic-associated-types/issue-47206.rs @@ -0,0 +1,27 @@ +// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// Regression test for #47206: ensure that impls which have where +// clauses don't silently fail. +// +// compile-pass + +#![feature(generic_associated_types)] +//~^ WARNING the feature `generic_associated_types` is incomplete + +trait Foo { + type Out; +} + +impl Foo for Box { + type Out where T: Clone = T; +} + +fn main() {} From 23372afc5ccc51ae56f637ebeabb6aa50328c2b7 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Mon, 27 Aug 2018 18:55:37 -0400 Subject: [PATCH 2/2] update the copyright year to 2018 --- src/test/ui/rfc1598-generic-associated-types/issue-47206.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/ui/rfc1598-generic-associated-types/issue-47206.rs b/src/test/ui/rfc1598-generic-associated-types/issue-47206.rs index e13e0f522dddf..34cfe54af52d1 100644 --- a/src/test/ui/rfc1598-generic-associated-types/issue-47206.rs +++ b/src/test/ui/rfc1598-generic-associated-types/issue-47206.rs @@ -1,4 +1,4 @@ -// Copyright 2012 The Rust Project Developers. See the COPYRIGHT +// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. //