Skip to content

Unsafe blocks inside generators #45729

Closed
Closed
@valff

Description

@valff

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions