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.