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

Problems with inline hints with proc_macro #8547

Closed
barvirm opened this issue Apr 16, 2021 · 1 comment
Closed

Problems with inline hints with proc_macro #8547

barvirm opened this issue Apr 16, 2021 · 1 comment

Comments

@barvirm
Copy link

barvirm commented Apr 16, 2021

Rust-analyzer knows the correct type, but inline hint shows different types.
Is this problem with configuration, or I inline hint cannot resolve types creates in proc_macro?

/*
#[throws(i32)]
fn foo(x: bool) -> i32 {
    if x {
        0
    } else {
        throw!(1);
    }
}

// expanded code
fn bar(x: bool) -> Result<i32, i32> {
    if x {
        Ok(0)
    } else {
        Err(1)
    }
}
*/
// --------------------------------------------------
#[derive(Debug)]
struct Xerror;

#[throws(Xerror)]
fn foo(i: i32) -> i32 {
    if i < 0 {
        Err(Xerror)?;
    }
    i
}

fn main() {
    let _x = foo(32);  // this shows inline hint as i32, but correct type is Result<i32, Xerror>
}
@Veykril
Copy link
Member

Veykril commented Apr 16, 2021

We don't expand attribute macros yet. Duplicate of #6029.

@Veykril Veykril closed this as completed Apr 16, 2021
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