Closed
Description
I don't think this is intentional, at least it is not documented in the RFCs 1023 or 2451:
STR
Crate a (compile with should_not_have_an_effect
):
#![feature(fundamental)]
pub trait Abc {}
#[cfg_attr(should_not_have_an_effect, fundamental)]
pub trait Foo<T> {}
Crate b:
extern crate a;
pub struct Bar;
impl a::Abc for a::Foo<Bar> {}
Expected Result
The cfg_attr
does not have an effect - the code gives this error:
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> b.rs:4:1
|
4 | impl a::Abc for a::Foo<Bar> {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ impl doesn't use types inside crate
|
= note: the impl does not reference any types defined in this crate
= note: define and implement a trait or new type instead
error: aborting due to previous error
Actual result
With --cfg should_not_have_an_effect
, the code compiles
Stability consequences
This can't be observed in stable code right now - the only stable #[fundamental]
traits are Sized
(which doesn't have type parameters) and the Fn
traits (which can only be implemented for tuples, and these are never fundamental). However, if we did stabilize a "normal" #[fundamental]
trait with type parameters, this would be visible on stable.
Metadata
Metadata
Assignees
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
arielb1 commentedon Dec 4, 2018
This should either be fixed (
#[fundamental]
trait objects don't act as#[fundamental]
types) or documented in the RFCs.nikomatsakis commentedon Dec 13, 2018
Discussed in the @rust-lang/lang meeting. We decided that for now we should just make
#[fundamental]
trait objects not act as#[fundamental]
types.arielb1 commentedon Dec 14, 2018
No warning period needed because this is a nightly feature? I think I'll
E-mentor thisor not, this looks too simple.stop treating trait objects from #[fundamental] traits as fundamental
Rollup merge of rust-lang#56862 - arielb1:fundamentally-clean, r=niko…
Rollup merge of rust-lang#56862 - arielb1:fundamentally-clean, r=niko…
Rollup merge of rust-lang#56862 - arielb1:fundamentally-clean, r=niko…
Auto merge of #56862 - arielb1:fundamentally-clean, r=nikomatsakis
1 remaining item