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

Test cases: #[trace] async fn a(mut b) #112

Closed
taqtiqa-mark opened this issue Mar 15, 2022 · 3 comments
Closed

Test cases: #[trace] async fn a(mut b) #112

taqtiqa-mark opened this issue Mar 15, 2022 · 3 comments

Comments

@taqtiqa-mark
Copy link
Contributor

taqtiqa-mark commented Mar 15, 2022

#[minitrace::trace("a", enter_on_poll = true)]
async fn a(mut b: String) {
    c(&mut b)
}

fn c(d: &mut String) {
    d;
}

gives this error, which is resolved per this comment:

173 | async fn a(mut b: String) {
    |                - help: consider changing this to be mutable: `mut b`
174 |     c(&mut b)
    |       ^^^^^^ cannot borrow as mutable

error[E0596]: cannot borrow `client` as mutable, as it is not declared as mutable

Remove the trace macro and the error goes away.

For anyone caught out, until a fix lands, the workaround should have no performance impact (should be optimized by the compiler):

async fn a( b: String) {
   let mut b = b;
    c(&mut b)
}

Note the synchronous version appears to survive intact:

#[minitrace::trace("a")]
fn a(mut b: String) {
    c(&mut b)
}

fn c(d: &mut String) {
    d;
}

Test cases related to issue #81.

@andylokandy
Copy link
Collaborator

andylokandy commented Mar 15, 2022

I believe the issue comes from this statement, although I haven't had a machine to test it now:

ident.mutability = None;

And frankly speaking, I don't know why this statement is here 🤣 because it's all copy-and-pasted from crate async-trait. I guess it's an async-trait specific constraint and we can simply remove it.

@taqtiqa-mark
Copy link
Contributor Author

taqtiqa-mark commented Mar 15, 2022

Testing now. That change does resolve the issue. I'll leave this open as test cases to be implemented.

@taqtiqa-mark taqtiqa-mark changed the title #[trace] breaks: async fn a(mut b) Test cases: #[trace] async fn a(mut b) Mar 15, 2022
taqtiqa-mark added a commit to taqtiqa-mark/utrace-rust that referenced this issue Mar 20, 2022
Close issue tikv#112.
Per the comment of @andylokandy this appears to be a residual
carried over from the async-trait crate code.

Signed-off-by: Mark Van de Vyver <mark@taqtiqa.com>
@taqtiqa-mark
Copy link
Contributor Author

Closed by PR #119

taqtiqa-mark added a commit to taqtiqa-mark/utrace-rust that referenced this issue Apr 28, 2022
Signed-off-by: Mark Van de Vyver <mark@taqtiqa.com>
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

No branches or pull requests

2 participants