Skip to content

UFCS ignoring unstable library feature requirements? #36399

Closed
@iliekturtles

Description

@iliekturtles

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions