Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

missing allow internal unstable for generic_assert #120612

Closed
matthiaskrgr opened this issue Feb 3, 2024 · 1 comment · Fixed by #126096
Closed

missing allow internal unstable for generic_assert #120612

matthiaskrgr opened this issue Feb 3, 2024 · 1 comment · Fixed by #126096
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

matthiaskrgr commented Feb 3, 2024

I tried this code:

Note that generic_assert is not marked as internal
https://github.com/rust-lang/rust/blob/master/compiler/rustc_feature/src/unstable.rs#L201

    /// Outputs useful `assert!` messages
    (unstable, generic_assert, "1.63.0", None),
    /// Allows using the `rust-intrinsic`'s "ABI".
#![feature(generic_assert)]

pub fn main() {
    assert!(true);
}

I expected to see this happen:
code compiles

Instead, this happened:

error[E0658]: use of unstable library feature 'core_intrinsics': intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library
 --> assert.rs:4:5
  |
4 |     assert!(true);
  |     ^
  |
  = help: add `#![feature(core_intrinsics)]` to the crate attributes to enable
  = note: this compiler was built on 2024-02-01; consider upgrading it if it is out of date
  = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to 1 previous error

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

Maybe the lint should ignore code from expansions?

Meta

rustc --version --verbose:

rustc 1.77.0-nightly (bf3c6c5be 2024-02-01)
binary: rustc
commit-hash: bf3c6c5bed498f41ad815641319a1ad9bcecb8e8
commit-date: 2024-02-01
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6
@matthiaskrgr matthiaskrgr added the C-bug Category: This is a bug. label Feb 3, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 3, 2024
@matthiaskrgr matthiaskrgr changed the title false positive use of unstable library feature false positive use of unstable library feature ? Feb 3, 2024
@saethlin saethlin added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Feb 3, 2024
@PatchMixolydic
Copy link
Contributor

PatchMixolydic commented Feb 3, 2024

On 1.77.0-nightly (2024-02-01 bf3c6c5bed498f41ad81), the expansion of assert! with #![feature(generic_assert)] contains a call to core::intrinsics::unlikely:

pub fn main() {
    {
        #[allow(unused_imports)]
        use ::core::asserting::{TryCaptureGeneric, TryCapturePrintable};
        if ::core::intrinsics::unlikely(!true) {
                {
                    ::core::panicking::panic_fmt(format_args!("Assertion failed: true"));
                }
            }
    };
}

assert! is tagged with #[allow_internal_unstable(generic_assert_internals)], but not #[allow_internal_unstable(core_intrinsics)].

#[allow_internal_unstable(panic_internals, edition_panic, generic_assert_internals)]
macro_rules! assert {

@Noratrieb Noratrieb added T-libs Relevant to the library team, which will review and decide on the PR/issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Feb 4, 2024
@Noratrieb Noratrieb changed the title false positive use of unstable library feature ? missing allow internal unstable for generic_assert Feb 4, 2024
facebook-github-bot pushed a commit to facebook/sapling that referenced this issue Feb 22, 2024
Summary:
In D53729268, we started using generic_asserts for better visibility in unit test failures. This makes us use the feature `generic_assert` but also forces us to use `core_intrinsics` which is not strictly needed. The only reason we are forced to use this is [this bug](rust-lang/rust#120612).

Clippy doesn't like that we are using compiler internal stuff and gives a strong warning. Since we can't do anything about it, I have added a comment to provide context on why this cannot be fixed currently.

Reviewed By: YousefSalama, singhsrb

Differential Revision: D54061913

fbshipit-source-id: f5b952bfe13dc0e5af17b5b28c3d18adf43ba000
@bors bors closed this as completed in efd8959 Jun 7, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jun 7, 2024
Rollup merge of rust-lang#126096 - c410-f3r:tests-tests-tests, r=jhpratt

[RFC-2011] Allow `core_intrinsics` when activated

Fix rust-lang#120612
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants