Skip to content

Instantly share code, notes, and snippets.

@davidtwco
Last active July 28, 2022 09:50
Show Gist options
  • Save davidtwco/3f3de4690fd646910c13e14e36dc3a12 to your computer and use it in GitHub Desktop.
Save davidtwco/3f3de4690fd646910c13e14e36dc3a12 to your computer and use it in GitHub Desktop.
#![crate_type = "lib"]
#![feature(staged_api)]
#![stable(feature = "the_tortoise_and_the_unstable_function", since = "1.0.0")]
#[stable(feature = "the_tortoise_and_the_unstable_function", since = "1.0.0")]
pub struct Foo;
#[stable(feature = "the_tortoise_and_the_unstable_function", since = "1.0.0")]
pub struct Bar;
#[stable(feature = "the_tortoise_and_the_unstable_function", since = "1.0.0")]
impl std::ops::Deref for Foo {
type Target = Bar;
fn deref(&self) -> &Self::Target {
&Bar
}
}
impl Foo {
#[unstable(feature = "tortoise_on_foo", issue = "none")]
pub fn tortoise(&self) -> u32 {
4
}
}
impl Bar {
#[stable(feature = "the_tortoise_and_the_unstable_function", since = "1.0.0")]
pub fn tortoise(&self) -> u32 {
3
}
}
// aux-build:aux.rs
extern crate aux;
use aux::Foo;
fn main() {
let f = Foo;
assert_eq!(f.tortoise(), 4);
}
@davidtwco
Copy link
Author

warning: an associated function with this name may be added to the standard library in the future
 --> src/test/ui/typeck/probe-deref-before-unstable-with-flag.rs:8:18
  |
8 |     assert_eq!(f.tortoise(), 4);
  |                  ^^^^^^^^
  |
  = note: `#[warn(unstable_name_collisions)]` on by default
  = warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior!
  = note: for more information, see issue #48919 <https://github.com/rust-lang/rust/issues/48919>
  = help: call with fully qualified syntax `Bar::tortoise(...)` to keep using the current method
  = help: add `#![feature(tortoise_on_foo)]` to the crate attributes to enable `Foo::tortoise`

warning: 1 warning emitted

or, with -Zpick-stable-methods-before-any-unstable=no:

error[E0658]: use of unstable library feature 'tortoise_on_foo'
 --> src/test/ui/typeck/probe-deref-before-unstable-with-flag.rs:8:18
  |
8 |     assert_eq!(f.tortoise(), 4);
  |                  ^^^^^^^^
  |
  = help: add `#![feature(tortoise_on_foo)]` to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0658`.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment