Skip to content

UFCS ignoring unstable library feature requirements? #36399

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
iliekturtles opened this issue Sep 11, 2016 · 3 comments
Closed

UFCS ignoring unstable library feature requirements? #36399

iliekturtles opened this issue Sep 11, 2016 · 3 comments

Comments

@iliekturtles
Copy link
Contributor

iliekturtles commented Sep 11, 2016

In the context of #![no_std] libraries the core::num::Float trait is marked as unstable but has stable methods, including powi. To use the stable methods glob imports or UFCS both work:

Glob import members of the num module:

#![no_std]
#![crate_type="lib"]

use core::num::*;
//use core::num::Float; // error: use of unstable library feature 'core_float': stable
                        // interface is via `impl f{32,64}` in later crates (see issue #32110)

fn foo() -> f32 {
    3.0f32.powi(2)
}

Use UFCS:

#![no_std]
#![crate_type="lib"]

fn bar() -> f32 {
    <f32 as core::num::Float>::powi(3.0f32, 2)
}

Shouldn't the UFCS variant give the unstable library feature error? Is there another way to use the member call syntax without the glob import?

@hanna-kruppe
Copy link
Contributor

The latter (UFCS) is particularly nasty because it allows stable code to depend on there being a trait at that path with that method.

@alexcrichton
Copy link
Member

Thanks for the report! I think this may e a duplicate of #30209, though, so closing in favor of that.

@hanna-kruppe
Copy link
Contributor

Ugh how did I miss that before telling @iliekturtles to file this issue? =/

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants