Skip to content

portable-simd is entirely untested in rust-lang/rust #160607

Closed

Description

@RalfJung

It looks like portable-simd doctests (and possibly the other tests as well) are entirely untested in this repo. Since #146882, some of the doctests are now failing to compile:

  0.000008   ---- crates/core_simd/src/simd/num/int.rs - core_simd::simd::num::int::SimdInt::abs_diff (line 81) stdout ----
  0.000007   error: use of deprecated constant `std::i32::MIN`: replaced by the `MIN` associated constant on this type
  0.000007     --> crates/core_simd/src/simd/num/int.rs:89:27
  0.000007      |
  0.000006   89 | let a = Simd::from_array([MIN, MAX, 100, -100]);
  0.000007      |                           ^^^
  0.000006      |
  0.000007   note: the lint level is defined here
  0.000007     --> crates/core_simd/src/simd/num/int.rs:79:9
  0.000007      |
  0.000007   79 | #![deny(warnings)]
  0.000006      |         ^^^^^^^^
  0.000007      = note: `#[deny(deprecated)]` implied by `#[deny(warnings)]`
  0.000007   
  0.000007   error: use of deprecated constant `std::i32::MAX`: replaced by the `MAX` associated constant on this type
  0.000008     --> crates/core_simd/src/simd/num/int.rs:89:32
  0.000005      |
  0.000005   89 | let a = Simd::from_array([MIN, MAX, 100, -100]);
  0.000004      |                                ^^^
  0.000005   
  0.000004   error: use of deprecated constant `std::i32::MAX`: replaced by the `MAX` associated constant on this type
  0.000005     --> crates/core_simd/src/simd/num/int.rs:90:27
  0.000004      |
  0.000005   90 | let b = Simd::from_array([MAX, MIN, -80, -120]);
  0.000004      |                           ^^^
  0.000005   
  0.000004   error: use of deprecated constant `std::i32::MIN`: replaced by the `MIN` associated constant on this type
  0.000005     --> crates/core_simd/src/simd/num/int.rs:90:32
  0.000004      |
  0.000005   90 | let b = Simd::from_array([MAX, MIN, -80, -120]);
  0.000004      |                                ^^^
  0.000005   
  0.000005   error: use of deprecated constant `std::i32::MIN`: replaced by the `MIN` associated constant on this type
  0.000004     --> crates/core_simd/src/simd/num/int.rs:88:17
  0.000005      |
  0.000008   88 | use core::i32::{MIN, MAX};
  0.000007      |                 ^^^
  0.000007   
  0.000007   error: use of deprecated constant `std::i32::MAX`: replaced by the `MAX` associated constant on this type
  0.000007     --> crates/core_simd/src/simd/num/int.rs:88:22
  0.000007      |
  0.000007   88 | use core::i32::{MIN, MAX};
  0.000007      |                      ^^^
  0.000010   
  0.000008   error: aborting due to 6 previous errors
  0.000012   
  0.000007   Couldn't compile the test.

We should have at least some basic "does it build" smoke tests running in this repo.

Cc @rust-lang/project-portable-simd

Activity

  1. added
    needs-triage
    on Aug 6, 2026
  2. RalfJung commented on Aug 6, 2026

    @RalfJung
    MemberAuthor

    I am very surprised that apparently this is not run together with ./x test library/core --doc. These files are included as a regular module in libcore, aren't they?

  3. added
    PG-portable-simd
    E-needs-test
    on Aug 6, 2026
  4. RalfJung commented on Aug 6, 2026

    @RalfJung
    MemberAuthor

    @Kobzol any idea why these doctests apparently have not been run?

  5. RalfJung commented on Aug 6, 2026

    @RalfJung
    MemberAuthor

    Hm, there's also something else that is odd... the output says int.rs:79 is where we configure deny(warnings) but there is no such thing there?

    /// Lanewise absolute difference.
    /// Every element becomes the absolute difference of `self` and `second`.
    ///
    /// # Examples
    /// ```
    /// # #![feature(portable_simd)]
    /// # #[cfg(feature = "as_crate")] use core_simd::simd;
    /// # #[cfg(not(feature = "as_crate"))] use core::simd;
    /// # use simd::prelude::*;
    /// use core::i32::{MIN, MAX};
    /// let a = Simd::from_array([MIN, MAX, 100, -100]);
    /// let b = Simd::from_array([MAX, MIN, -80, -120]);
    /// assert_eq!(a.abs_diff(b), Simd::from_array([u32::MAX, u32::MAX, 180, 20]));
    /// ```
    fn abs_diff(self, second: Self) -> Self::Unsigned;

    Is rustdoc sometimes auto-inserting a deny(warnings)?

  6. RalfJung commented on Aug 6, 2026

    @RalfJung
    MemberAuthor

    Ah, I think I found it... libcore has this

    #![doc(
        html_playground_url = "https://play.rust-lang.org/",
        issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
        test(no_crate_inject, attr(deny(warnings))),
        test(attr(allow(dead_code, deprecated, unused_variables, unused_mut, duplicate_features)))
    )]

    but portable-simd's core crate only has

    #![doc(test(attr(deny(warnings))))]

    Therefore the tests work fine when run as part of libcore, but don't work when run separately.

  7. removed
    needs-triage
    on Aug 6, 2026
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

    E-needs-testPG-portable-simd

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions