How does `as` break inference?

We believe constructs of the form:

fn bar<T>(x: *const T, y: something) -> T { ...}

let x = foo as *const _;
bar(x, something)

can break inference, while constructs of the form:

fn bar<T>(x: *const T, y: something) -> T { ...}

let x: *const _ = foo;
bar(x, something)

would have proper inference, but we're struggling to come up with an example where the latter compiles but the former fails to compile. Anyone got any ideas?

found it Rust Playground

Did you mean to post a different link? The code in the link you posted doesn't use any as expressions, except in the offset calculation in the cell_project!() macro.

(pronouns fixed)

note the commented-out let field = field as *mut _;. can't exactly have the 2 examples in the 1 playground...

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.