Skip to content

std: Improve non-task-based usage #14644

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

Merged
merged 1 commit into from
Jun 5, 2014

Conversation

alexcrichton
Copy link
Member

A few notable improvements were implemented to cut down on the number of aborts
triggered by the standard library when a local task is not found.

  • Primarily, the unwinding functionality was restructured to support an unsafe
    top-level function, try. This function invokes a closure, capturing any
    failure which occurs inside of it. The purpose of this function is to be as
    lightweight of a "try block" as possible for rust, intended for use when the
    runtime is difficult to set up.

    This function is not meant to be used by normal rust code, nor should it be
    consider for use with normal rust code.

  • When invoking spawn(), a fail!() is triggered rather than an abort.

  • When invoking LocalIo::borrow(), which is transitively called by all I/O
    constructors, None is returned rather than aborting to indicate that there is
    no local I/O implementation.

A test case was also added showing the variety of things that you can do without
a runtime or task set up now. In general, this is just a refactoring to abort
less quickly in the standard library when a local task is not found.

A few notable improvements were implemented to cut down on the number of aborts
triggered by the standard library when a local task is not found.

* Primarily, the unwinding functionality was restructured to support an unsafe
  top-level function, `try`. This function invokes a closure, capturing any
  failure which occurs inside of it. The purpose of this function is to be as
  lightweight of a "try block" as possible for rust, intended for use when the
  runtime is difficult to set up.

  This function is *not* meant to be used by normal rust code, nor should it be
  consider for use with normal rust code.

* When invoking spawn(), a `fail!()` is triggered rather than an abort.

* When invoking LocalIo::borrow(), which is transitively called by all I/O
  constructors, None is returned rather than aborting to indicate that there is
  no local I/O implementation.

* Invoking get() on a TLD key will return None if no task is available

* Invoking replace() on a TLD key will fail if no task is available.

A test case was also added showing the variety of things that you can do without
a runtime or task set up now. In general, this is just a refactoring to abort
less quickly in the standard library when a local task is not found.
@brson
Copy link
Contributor

brson commented Jun 4, 2014

What's the story with task::failing now?

@brson brson closed this Jun 4, 2014
@brson brson reopened this Jun 4, 2014
@alexcrichton
Copy link
Member Author

Currently, task::failing will abort if you don't set a local task (it's using Local::borrow). Regardless it's not hooked up to the plumbing in unwinding, so it still has no concept of whether an unwind is in progress without consulting the local task.

bors added a commit that referenced this pull request Jun 5, 2014
…=brson

A few notable improvements were implemented to cut down on the number of aborts
triggered by the standard library when a local task is not found.

* Primarily, the unwinding functionality was restructured to support an unsafe
  top-level function, `try`. This function invokes a closure, capturing any
  failure which occurs inside of it. The purpose of this function is to be as
  lightweight of a "try block" as possible for rust, intended for use when the
  runtime is difficult to set up.

  This function is *not* meant to be used by normal rust code, nor should it be
  consider for use with normal rust code.

* When invoking spawn(), a `fail!()` is triggered rather than an abort.

* When invoking LocalIo::borrow(), which is transitively called by all I/O
  constructors, None is returned rather than aborting to indicate that there is
  no local I/O implementation.

A test case was also added showing the variety of things that you can do without
a runtime or task set up now. In general, this is just a refactoring to abort
less quickly in the standard library when a local task is not found.
@bors bors closed this Jun 5, 2014
@bors bors merged commit 0c7c93b into rust-lang:master Jun 5, 2014
@alexcrichton alexcrichton deleted the more-no-runtime-use-cases branch June 5, 2014 17:03
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 5, 2023
feat: don't wavy-underline the whole for loop
bors pushed a commit to rust-lang-ci/rust that referenced this pull request Apr 22, 2025
rust-lang#14644)

Closes rust-lang/rust-clippy#14578

changelog: [`unnecessary_lazy_evaluations`] fix wrong suggestions for
async closure
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.

3 participants