Open
Description
Right now we have a trick in the standard library where sometimes a trait is unstable but the methods are stable. This is primarily used for SliceConcatExt
to make join
stable on slices but you can't import the trait or rely on the fact that it's defined through a trait.
There are a few ways to bypass this, however:
// foo.rs
#![feature(staged_api)]
#![stable(feature = "foo", since = "1.2.0")]
#[unstable(feature = "bar", issue = "0")]
pub trait Foo {
#[stable(feature = "foo", since = "1.2.0")]
fn foo(&self) {}
}
#[stable(feature = "foo", since = "1.2.0")]
impl Foo for i32 {}
// bar.rs
#![allow(warnings)]
extern crate foo;
// this is expected to compile and work A-OK
fn test1() {
use foo::*;
1i32.foo();
}
// this is expected to fail to compile (e.g. needs the feature)
fn test2() {
use foo::Foo; //~ ERROR
}
// This should *also* fail to compile, but it does not
fn test3() {
foo::Foo::foo(&1) // no error
}
// Like above, this should also fail to compile, but it does not
fn test4() {
<i32 as foo::Foo>::foo(&1) // no error
}
fn main() {}
$ multirust run nightly rustc foo.rs --crate-type lib
$ multirust run nightly rustc bar.rs
bar.rs:11:9: 11:17 error: use of unstable library feature 'bar' (see issue #0)
bar.rs:11 use foo::Foo;
^~~~~~~~
bar.rs:11:9: 11:17 help: add #![feature(bar)] to the crate attributes to enable
error: aborting due to previous error
I thought that we crawled paths pretty meticulously, but apparently not :(
cc @petrochenkov
cc @rust-lang/libs