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

Unsafe blocks inside generators #45729

Closed
valff opened this issue Nov 2, 2017 · 4 comments
Closed

Unsafe blocks inside generators #45729

valff opened this issue Nov 2, 2017 · 4 comments
Labels
A-coroutines Area: Coroutines

Comments

@valff
Copy link
Contributor

valff commented Nov 2, 2017

Calling an unsafe function inside a generator doesn't require unsafe block.

playground

#![feature(generators)]

fn main() {
  let _ = || loop {
    ::std::ptr::read_volatile(0 as *const u32);
    // Try to uncomment and the error will disappear:
    // yield;
  };
}

I expected to see an error in both cases: commented and uncommented yield. Instead the error disappear when using a generator.

Meta

rustc --version --verbose:

rustc 1.23.0-nightly (90ef3372e 2017-10-29)
binary: rustc
commit-hash: 90ef3372e8ad74517eafa61e9494688c258b15ce
commit-date: 2017-10-29
host: x86_64-unknown-linux-gnu
release: 1.23.0-nightly
LLVM version: 4.0
@alexcrichton alexcrichton added the A-coroutines Area: Coroutines label Nov 3, 2017
@alexcrichton
Copy link
Member

cc @Zoxc

@Zoxc
Copy link
Contributor

Zoxc commented Nov 3, 2017

cc @arielb1 I'm guessing this is the result of the new MIR unsafety checking?

@durka
Copy link
Contributor

durka commented Nov 4, 2017

@Zoxc are generators desugared in the HIR, if so have you used a PushUnsafeBlock without PopUnsafeBlock?

@Zoxc
Copy link
Contributor

Zoxc commented Nov 5, 2017

@durka They are "desugared" after any unsafety checking.

@bors bors closed this as completed in a6b1a81 Nov 10, 2017
Dylan-DPC-zz referenced this issue in Dylan-DPC-zz/rust Mar 21, 2021
…chenkov

Move some tests to more reasonable directories - 5

cc rust-lang#73494

Threshold is 0.95. Next time I promise I will take a look into the special/misclassified directories.

- [issues/issue-23208.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-23208.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/23208)</sup>: associated-types 0.951
- [weird-exprs.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/weird-exprs.rs) <sup>unknown</sup>: destructuring-assignment 0.958
- [issues/issue-1701.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-1701.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/1701)</sup>: structs-enums 0.974
- [issues/issue-48508-aux.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-48508-aux.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/48508)</sup>: numbers-arithmetic 0.991
- [fn_must_use.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/fn_must_use.rs) <sup>unknown</sup>: lint 1.000
- [mir_check_nonconst.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/mir_check_nonconst.rs) <sup>unknown</sup>: consts 1.002
- [issues/issue-52060.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-52060.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/52060)</sup>: consts 1.017
- [issues/issue-45729-unsafe-in-generator.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-45729-unsafe-in-generator.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/45729)</sup>: generator 1.024
- [issues/issue-10392.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-10392.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/10392)</sup>: pattern 1.039
- [no-implicit-prelude.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/no-implicit-prelude.rs) <sup>unknown</sup>: resolve 1.071
- [issues/issue-68000-unicode-ident-after-missing-comma.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-68000-unicode-ident-after-missing-comma.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/68000)</sup>: parser 1.079
- [shadow.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/shadow.rs) <sup>unknown</sup>: binding 1.099
- [issues/issue-65611.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-65611.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/65611)</sup>: consts 1.139
- [concat-rpass.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/concat-rpass.rs) <sup>unknown</sup>: macros 1.194
- [issues/issue-31597.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-31597.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/31597)</sup>: associated-types 1.195
- [issues/issue-78372.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/issues/issue-78372.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/78372)</sup>: resolve 1.426
- [impl-trait-in-bindings-issue-73003.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/impl-trait-in-bindings-issue-73003.rs) <sup>[issue](https://github.com/rust-lang/rust/issues/73003)</sup>: impl-trait 1.471
- [impl-trait-in-bindings.rs](https://github.com/rust-lang/rust/blob/master/src/test/ui/impl-trait-in-bindings.rs) <sup>unknown</sup>: impl-trait 2.500

r? `@petrochenkov`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-coroutines Area: Coroutines
Projects
None yet
Development

No branches or pull requests

4 participants