Skip to content

Fix no std with alloc - #226

Merged
Lokathor merged 2 commits into
Lokathor:mainfrom
andrew-signal:fix-no-std-with-alloc
Sep 4, 2026
Merged

Fix no std with alloc#226
Lokathor merged 2 commits into
Lokathor:mainfrom
andrew-signal:fix-no-std-with-alloc

Conversation

@andrew-signal

@andrew-signal andrew-signal commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Resolves #225.

It looks like the functionality added in #224 accidentally calls the bare vec! macro.

This was not caught in tests, because no test configuration ran with alloc but without std.

This just changes it to match invocations elsewhere, plus adds test coverage.

@QueenOfSquiggles QueenOfSquiggles left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@QueenOfSquiggles

Copy link
Copy Markdown

I patched this branch into my current project and it solves the build issue entirely.

https://codeberg.org/QueenOfSquiggles/jktd

@JohanVonElectrum JohanVonElectrum left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@developer0hye developer0hye left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Validated commit f3fd1f5 locally on stable aarch64-apple-darwin. cargo check --no-default-features --features=alloc,grab_spare_slice,latest_stable_rust and cargo fmt --all -- --check both pass. The qualified alloc::vec! call directly fixes the 1.13.0 no_std + alloc regression, and the added workflow command covers the previously missing feature combination. This regression is currently blocking cold unlocked builds in downstream projects, including office2pdf.

@JohanVonElectrum

Copy link
Copy Markdown

Successfully used this to fix the cold installation of sqlx-cli.
Cloned sqlx, added a patch in Cargo.toml with this branch, and it worked.

@Lokathor
Lokathor merged commit 85f21c6 into Lokathor:main Sep 4, 2026
5 checks passed
@Lokathor

Lokathor commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Sorry about all this trouble everyone, 1.13.1 is released.

leynos added a commit to leynos/lille that referenced this pull request Sep 4, 2026
* Hold tinyvec at 1.12 until 1.13 builds again

`tinyvec` 1.13.0, published on 2026-09-03, imports `alloc::vec` as a module
and then invokes the `vec!` macro. On the nightly this repository pins the
macro no longer resolves:

```text
error: cannot find macro `vec` in this scope
   --> tinyvec-1.13.0/src/tinyvec.rs:710:21
note: `vec` is imported here, but it is a module, not a macro
```

The crate arrives transitively through Bevy's text and font stack, and this
workspace commits no `Cargo.lock`, so every build resolves the newest
compatible release and reaches the broken one. `make lint` and any
`--all-features` build fail on untouched `main`; the failure reproduces on a
clean detached checkout with an isolated target directory, so it is not a
local artefact.

Add a tilde requirement, which `AGENTS.md` permits for a documented lock to
patch-level updates. It is a resolution constraint only: no code in this
workspace names the crate, and the comment says so, so a later reader does not
mistake it for a dependency that can simply be dropped.

Upstream has not yanked 1.13.0. Lokathor/tinyvec#225 reports the same failure
and Lokathor/tinyvec#226 proposes the fix. Removal is tracked by
#340.

Claude-Session: https://claude.ai/code/session_01QrjNTnTwM7FmWXe5KFPMPY

* Catch a bad tinyvec resolution before the build does

The constraint had no test, so the only thing standing between a future
contributor and the broken release was a comment. Widen the requirement by
accident and the symptom is a macro error inside a crate nothing in this
workspace mentions.

`tests/dependency_resolution.rs` reads what Cargo actually resolved and fails
if `tinyvec` 1.13 or later is selected, naming the version and pointing at the
requirement. It also fails if the crate leaves the graph entirely, which is
the signal that the constraint and the test should both go.

Record the constraint in the developers guide as well: what it is for, why a
transitive dependency needs a direct requirement, why a tilde rather than a
caret, and the condition for removing it. A bare version requirement with no
explanation reads as a real dependency, and the next contributor cannot tell
whether dropping it is safe.

Claude-Session: https://claude.ai/code/session_01QrjNTnTwM7FmWXe5KFPMPY

* Say what the resolution test can and cannot catch

The guide called `tinyvec` "not a dependency", which is wrong: it is a
direct Cargo dependency whose only purpose is to bound resolution. Say
that instead, so a reader looking at `Cargo.toml` is not told the
opposite of what is there.

Both the guide and the test also implied the test runs before the build.
It does not. Cargo compiles the dependency graph before an integration
test runs, so a selected 1.13.0 fails the build first with the macro
error. What the test catches directly is the case that would otherwise
pass silently: a widened requirement whose resolved version still
compiles but sits outside the range this workspace has verified. Both
places now say that, and the guide points at `cargo tree --invert
tinyvec` for the case where the build fails first.

`ResolvedVersion` replaces the bare minor number. The old helper kept
only the second component, so a resolved 2.0.0 read as minor 0 and
passed a check meant to reject anything at or beyond 1.13, and the
failure message printed `1.[13]` rather than the version Cargo chose.
The type keeps the original text for the message and the major and minor
pair for the comparison.

Also reflow the guide paragraph to 80 columns and wrap the compiler
error in double backticks so Rustdoc renders it as one code span.

Claude-Session: https://claude.ai/code/session_01QrjNTnTwM7FmWXe5KFPMPY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vec macro import error with 1.13.0

5 participants