Skip to content

Don't suggest feature-gated paths on stable #101956

Open
@QuineDot

Description

@QuineDot

This might well be a duplicate, but I couldn't find an existing bug. I ran into this with c_int.

Given the following program:

fn main() {
    let _: c_int;
}

The output (with no dependencies) is

 --> src/main.rs:2:12
  |
2 |     let _: c_int;
  |            ^^^^^ not found in this scope
  |
help: consider importing one of these items
  |
1 | use core::ffi::c_int;
  |
1 | use std::os::raw::c_int;

Ideally the output should look like:

 --> src/main.rs:2:12
  |
2 |     let _: c_int;
  |            ^^^^^ not found in this scope
  |
help: consider importing one of these items
  |
1 | use std::os::raw::c_int;

as core::ffi::c_int is unstable:

use core::ffi::c_int;
fn main() {
    let _: c_int;
}

Output:

error[E0658]: use of unstable library feature 'core_ffi_c'
 --> src/main.rs:1:5
  |
1 | use core::ffi::c_int;
  |     ^^^^^^^^^^^^^^^^
  |
  = note: see issue #94501 <https://github.com/rust-lang/rust/issues/94501> for more information

error[E0658]: use of unstable library feature 'core_ffi_c'
 --> src/main.rs:3:12
  |
3 |     let _: c_int;
  |            ^^^^^
  |
  = note: see issue #94501 <https://github.com/rust-lang/rust/issues/94501> for more information

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

Stable compiler version 1.63.0. This particular example works on Beta and Nightly, but presumably there are or will be other things in the standard library with a stable path and an unstable path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-stabilityArea: `#[stable]`, `#[unstable]` etc.C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions