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

Reintroduce alloc_error_handler as deprecated #110733

Closed

Conversation

Manishearth
Copy link
Member

See #109507 (comment): The removal of #[alloc_error_handler] introduces a hard edge for people doing embedded development: code must contain the handler before that PR, and code must not contain that handler after that PR.

While it is an unstable feature and we can remove it immediately, it would be nicer to our embedded users for us to provide a slightly more graceful migration path for a couple releases.

This is not as graceful as it could be, as even with this change code that wants to have a different alloc error handler from its panic handler is still forced to pick a rust version, but at least the code compiles, and for the majority of cases where panics and allocs are going to be handled the same way it doesn't matter.

Not sure of this implementation; I could make it a future incompat lint instead of just using #[deprecated] given that it's a behavior change, not just a deprecation.

@rustbot
Copy link
Collaborator

rustbot commented Apr 23, 2023

r? @davidtwco

(rustbot has picked a reviewer for you, use r? to override)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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 Apr 23, 2023
@rustbot
Copy link
Collaborator

rustbot commented Apr 23, 2023

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@Amanieu
Copy link
Member

Amanieu commented Apr 23, 2023

default_alloc_error_handler has been stabilized for a while (#102318) which removes the requirement for no_std users to implement their own #[alloc_error_handler]. handle_alloc_error was already defaulting to calling the panic handler if #[alloc_error_handler] is absent.

@rust-log-analyzer
Copy link
Collaborator

The job mingw-check-tidy failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v3' (SHA:8e5e7e5ab8b370d6c329ec480221332ada57f0ab)
Download action repository 'rust-lang/simpleinfra@master' (SHA:4d706a8d448f000965ed9e883febfb36661202fe)
Complete job name: PR - mingw-check-tidy
git config --global core.autocrlf false
shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
env:
  CI_JOB_NAME: mingw-check-tidy
---
Building wheels for collected packages: reuse
  Building wheel for reuse (pyproject.toml): started
  Building wheel for reuse (pyproject.toml): finished with status 'done'
  Created wheel for reuse: filename=reuse-1.1.0-cp310-cp310-manylinux_2_35_x86_64.whl size=180119 sha256=9fa76c45f3193f307e02ea67d1a48cfe7ef2b854a074b766938a88e046bc7887
  Stored in directory: /tmp/pip-ephem-wheel-cache-hfwl8nwj/wheels/c2/3c/b9/1120c2ab4bd82694f7e6f0537dc5b9a085c13e2c69a8d0c76d
Installing collected packages: boolean-py, binaryornot, setuptools, reuse, python-debian, markupsafe, license-expression, jinja2, chardet
  Attempting uninstall: setuptools
    Found existing installation: setuptools 59.6.0
    Not uninstalling setuptools at /usr/lib/python3/dist-packages, outside environment /usr
---
Successfully built bddf55afeb2c
Successfully tagged rust-ci:latest
Built container sha256:bddf55afeb2c7179fdeb1ad46acdded0f47e8ad2488277528b32205887d40097
Uploading finished image to https://ci-caches.rust-lang.org/docker/eee721fc1ad06e35509f22d2087fb4acdb0a4d378bec3a191179769e2503f17c7f8f4292d7013976df3a24502e822c590708d80a62f327ca4849564995e4deb7
upload failed: - to s3://rust-lang-ci-sccache2/docker/eee721fc1ad06e35509f22d2087fb4acdb0a4d378bec3a191179769e2503f17c7f8f4292d7013976df3a24502e822c590708d80a62f327ca4849564995e4deb7 Unable to locate credentials
[CI_JOB_NAME=mingw-check-tidy]
[CI_JOB_NAME=mingw-check-tidy]
---
   Compiling cargo_metadata v0.15.3
   Compiling tidy v0.1.0 (/checkout/src/tools/tidy)
    Finished release [optimized] target(s) in 13.28s
fmt check
Diff in /checkout/library/core/src/prelude/v1.rs at line 77:
 // (no public module for them to be re-exported from).
 #[stable(feature = "builtin_macro_prelude", since = "1.38.0")]
 #[allow(deprecated)]
-pub use crate::macros::builtin::{alloc_error_handler, bench, derive, global_allocator, test, test_case};
+pub use crate::macros::builtin::{
+    alloc_error_handler, bench, derive, global_allocator, test, test_case,
 
 #[unstable(feature = "derive_const", issue = "none")]
 pub use crate::macros::builtin::derive_const;
Build completed unsuccessfully in 0:00:23
Build completed unsuccessfully in 0:00:23
Running `"/checkout/obj/build/x86_64-unknown-linux-gnu/rustfmt/bin/rustfmt" "--config-path" "/checkout" "--edition" "2021" "--unstable-features" "--skip-children" "--check" "/checkout/library/core/src/mem/manually_drop.rs" "/checkout/library/core/benches/fmt.rs" "/checkout/library/core/src/mem/mod.rs" "/checkout/library/core/src/mem/transmutability.rs" "/checkout/library/core/src/default.rs" "/checkout/library/core/benches/ascii/is_ascii.rs" "/checkout/library/core/src/prelude/v1.rs" "/checkout/library/core/src/mem/maybe_uninit.rs"` failed.
If you're running `tidy`, try again with `--bless`. Or, if you just want to format code, run `./x.py fmt` instead.

@Manishearth
Copy link
Member Author

Aha, I see. Thanks! I noticed it didn't work with our pinned nightly (we test embedded stuff with a pinned nightly as well as rolling nightlies) but I misread the date and didn't realize our pinned nightly was a year old. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants