Skip to content

Commit

Permalink
resolve where clauses in types in impls
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Aug 27, 2018
1 parent 8785e34 commit 6c8251d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2525,15 +2525,15 @@ 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,
TypeNS,
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
Expand Down
5 changes: 1 addition & 4 deletions src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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!(),
}
}
Expand Down
27 changes: 27 additions & 0 deletions src/test/ui/rfc1598-generic-associated-types/issue-47206.rs
Original file line number Diff line number Diff line change
@@ -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 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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<T> Foo for Box<T> {
type Out where T: Clone = T;
}

fn main() {}

0 comments on commit 6c8251d

Please sign in to comment.