Skip to content

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

Closed

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.

Activity

  1. added
    A-diagnosticsArea: Messages for errors, warnings, and lints
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on Sep 17, 2022
  2. added
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    A-stabilityArea: `#[stable]`, `#[unstable]` etc.
    on Sep 20, 2022
  3. QuineDot commented on May 4, 2023

    @QuineDot
    Author

    This is indeed still happening with other unstable paths.

    fn main() -> Result<(), Box<dyn Error>> { Ok(()) }
    error E0405: cannot find trait `Error` in this scope
     --> src/main.rs:1:33
      |
    1 | fn main() -> Result<(), Box<dyn Error>> { Ok(()) }
      |                                 ^^^^^ not found in this scope
      |
    help: consider importing one of these items
      |
    1 | use core::error::Error;
    +use core::error::Error;
     fn main() -> Result<(), Box<dyn Error>> { Ok(()) }
    error E0658: use of unstable library feature 'error_in_core'
     --> src/main.rs:1:5
      |
    1 | use core::error::Error;
      |     ^^^^^^^^^^^^^^^^^^
      |
      = note: see issue #103765 <https://github.com/rust-lang/rust/issues/103765> for more information
  4. added
    A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`
    D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.
    on Mar 22, 2026
  5. jakubadamw commented on Apr 8, 2026

    @jakubadamw
    Contributor

    I believe this is a duplicate of #149402 that was fixed in #149440. It can be closed. @estebank, would you mind? 🙂

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-stabilityArea: `#[stable]`, `#[unstable]` etc.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`C-enhancementCategory: An issue proposing an enhancement or a PR with one.D-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.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