diff options
| author | Flavio Percoco <flaper87@gmail.com> | 2014-04-11 23:48:02 +0200 |
|---|---|---|
| committer | Flavio Percoco <flaper87@gmail.com> | 2014-05-01 00:49:20 +0200 |
| commit | a51be8ecd81dd8f10cec1363cd14c3fdd7b19a1a (patch) | |
| tree | e010370128e843d5c55a409650237b302222e095 | |
| parent | a3f9f37014c77cda1ae53bf0984190e877aa413a (diff) | |
Allow manual implementations of built-in traits
[RFC #3] cc #13231
| -rw-r--r-- | src/librustc/middle/typeck/collect.rs | 9 | ||||
| -rw-r--r-- | src/test/compile-fail/cant-implement-builtin-kinds.rs | 19 |
2 files changed, 1 insertions, 27 deletions
diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 9c49512d4dc..c87776ba893 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -631,14 +631,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::Item) { parent_visibility); for trait_ref in opt_trait_ref.iter() { - let trait_ref = instantiate_trait_ref(ccx, trait_ref, selfty); - - // Prevent the builtin kind traits from being manually implemented. - if tcx.lang_items.to_builtin_kind(trait_ref.def_id).is_some() { - tcx.sess.span_err(it.span, - "cannot provide an explicit implementation \ - for a builtin kind"); - } + instantiate_trait_ref(ccx, trait_ref, selfty); } }, ast::ItemTrait(ref generics, _, _, ref trait_methods) => { diff --git a/src/test/compile-fail/cant-implement-builtin-kinds.rs b/src/test/compile-fail/cant-implement-builtin-kinds.rs deleted file mode 100644 index 6bedac6d12d..00000000000 --- a/src/test/compile-fail/cant-implement-builtin-kinds.rs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2013 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. - -// See issue #8517 for why this should be illegal. - -struct X<T>(T); - -impl <T> Send for X<T> { } //~ ERROR cannot provide an explicit implementation for a builtin kind -impl <T> Sized for X<T> { } //~ ERROR cannot provide an explicit implementation for a builtin kind -impl <T> Share for X<T> { } //~ ERROR cannot provide an explicit implementation for a builtin kind - -fn main() { } |
