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

Fix occasional alloc not found error in format_runtime_string! #5632

Merged
merged 6 commits into from
Sep 7, 2024

Conversation

clangenb
Copy link
Contributor

@clangenb clangenb commented Sep 7, 2024

The macro hygiene for the format_runtime_string! macro was broken since #5010, which resulted in the following build error under certain circumstances:

  error[E0433]: failed to resolve: use of undeclared crate or module `alloc`
      --> /home/clang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/frame-benchmarking-36.0.0/src/v1.rs:1738:2
       |
  1738 | /     sp_runtime::format_runtime_string!(
  1739 | |         "\n* Pallet: {}\n\
  1740 | |         * Benchmark: {}\n\
  1741 | |         * Components: {:?}\n\
  ...    |
  1750 | |         error_message,
  1751 | |     )
       | |_____^ use of undeclared crate or module `alloc`
       |
       = note: this error originates in the macro `sp_runtime::format_runtime_string` (in Nightly builds, run with -Z macro-backtrace for more info)

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

This bug has been known already, but hasn't been fixed so far, see #5213 and https://substrate.stackexchange.com/questions/11786/use-of-undeclared-crate-or-module-alloc-when-upgrade-to-v1-13-0.

I have made a mini rust crate that can reproduce the bug, and it also shows that this PR will fix the issue: https://github.com/clangenb/sp-runtime-string-test.

@clangenb clangenb changed the title [sp-runtime] fix macro hygiene for format_runtime_string! Fix alloc not found error in format_runtime_string! Sep 7, 2024
@clangenb clangenb changed the title Fix alloc not found error in format_runtime_string! Fix occasional alloc not found error in format_runtime_string! Sep 7, 2024
@bkchr bkchr added the T1-FRAME This PR/Issue is related to core FRAME, the framework. label Sep 7, 2024
@bkchr bkchr enabled auto-merge September 7, 2024 07:28
@ggwpez ggwpez added the A4-needs-backport Pull request must be backported to all maintained releases. label Sep 7, 2024
auto-merge was automatically disabled September 7, 2024 09:19

Head branch was pushed to by a user without write access

Copy link

github-actions bot commented Sep 7, 2024

Review required! Latest push from author must always be reviewed

@ggwpez ggwpez added this pull request to the merge queue Sep 7, 2024
Merged via the queue into paritytech:master with commit 96fecc3 Sep 7, 2024
204 of 207 checks passed
github-actions bot pushed a commit that referenced this pull request Sep 7, 2024
…5632)

The macro hygiene for the `format_runtime_string!` macro was broken
since #5010, which
resulted in the following build error under certain circumstances:

```console
  error[E0433]: failed to resolve: use of undeclared crate or module `alloc`
      --> /home/clang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/frame-benchmarking-36.0.0/src/v1.rs:1738:2
       |
  1738 | /     sp_runtime::format_runtime_string!(
  1739 | |         "\n* Pallet: {}\n\
  1740 | |         * Benchmark: {}\n\
  1741 | |         * Components: {:?}\n\
  ...    |
  1750 | |         error_message,
  1751 | |     )
       | |_____^ use of undeclared crate or module `alloc`
       |
       = note: this error originates in the macro `sp_runtime::format_runtime_string` (in Nightly builds, run with -Z macro-backtrace for more info)

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

This bug has been known already, but hasn't been fixed so far, see
#5213 and
https://substrate.stackexchange.com/questions/11786/use-of-undeclared-crate-or-module-alloc-when-upgrade-to-v1-13-0.

I have made a mini rust crate that can reproduce the bug, and it also
shows that this PR will fix the issue:
https://github.com/clangenb/sp-runtime-string-test.

(cherry picked from commit 96fecc3)
Copy link

github-actions bot commented Sep 7, 2024

Successfully created backport PR for stable2407:

Copy link

github-actions bot commented Sep 7, 2024

Successfully created backport PR for stable2409:

github-actions bot pushed a commit that referenced this pull request Sep 7, 2024
…5632)

The macro hygiene for the `format_runtime_string!` macro was broken
since #5010, which
resulted in the following build error under certain circumstances:

```console
  error[E0433]: failed to resolve: use of undeclared crate or module `alloc`
      --> /home/clang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/frame-benchmarking-36.0.0/src/v1.rs:1738:2
       |
  1738 | /     sp_runtime::format_runtime_string!(
  1739 | |         "\n* Pallet: {}\n\
  1740 | |         * Benchmark: {}\n\
  1741 | |         * Components: {:?}\n\
  ...    |
  1750 | |         error_message,
  1751 | |     )
       | |_____^ use of undeclared crate or module `alloc`
       |
       = note: this error originates in the macro `sp_runtime::format_runtime_string` (in Nightly builds, run with -Z macro-backtrace for more info)

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

This bug has been known already, but hasn't been fixed so far, see
#5213 and
https://substrate.stackexchange.com/questions/11786/use-of-undeclared-crate-or-module-alloc-when-upgrade-to-v1-13-0.

I have made a mini rust crate that can reproduce the bug, and it also
shows that this PR will fix the issue:
https://github.com/clangenb/sp-runtime-string-test.

(cherry picked from commit 96fecc3)
ggwpez added a commit that referenced this pull request Sep 9, 2024
Backport #5632 into `stable2407` (cc @clangenb).

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: clangenb <37865735+clangenb@users.noreply.github.com>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
ggwpez added a commit that referenced this pull request Sep 9, 2024
Backport #5632 into `stable2409` (cc @clangenb).

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

---------

Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
Co-authored-by: clangenb <37865735+clangenb@users.noreply.github.com>
Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io>
@ggwpez ggwpez removed the A4-needs-backport Pull request must be backported to all maintained releases. label Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T1-FRAME This PR/Issue is related to core FRAME, the framework.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants