Skip to content

__arg variables from async fn desugaring are accessible to the user #60438

Closed

Description

@nikomatsakis

The fixes for #54716 and #60236 introduced __arg variables that, presently, are accessible to the user (playground):

#![feature(async_await)]

async fn foo(_: usize) {
    println!("{}", __arg0);
}

fn main() { }

This code compiles, but it should error.

Activity

  1. added
    T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
    on May 1, 2019
  2. davidtwco commented on May 1, 2019

    @davidtwco
    Member

    A complete test case:

    // aux-build:arc_wake.rs
    // edition:2018
    
    #![allow(unused_variables)]
    #![feature(async_await, await_macro)]
    
    extern crate arc_wake;
    
    use arc_wake::ArcWake;
    use std::future::Future;
    use std::sync::Arc;
    use std::task::Context;
    
    struct EmptyWaker;
    
    impl ArcWake for EmptyWaker {
        fn wake(self: Arc<Self>) {}
    }
    
    async fn foobar_async(x: u32, (a, _, _c): (u32, u32, u32), _: u32, _y: u32) {
        assert_eq!(__arg1, (1, 2, 3)); // this doesn't compile error, but should
        assert_eq!(__arg2, 4);
    }
    
    fn main() {
        let empty = Arc::new(EmptyWaker);
        let waker = ArcWake::into_waker(empty);
        let mut cx = Context::from_waker(&waker);
    
        let mut fut = Box::pin(foobar_async(0, (1, 2, 3), 4, 0));
        let _ = fut.as_mut().poll(&mut cx);
    }
  3. self-assigned this
    on May 1, 2019
  4. added a commit that references this issue on May 1, 2019
    16939a5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-async-awaitArea: Async & AwaitT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions