Stream: t-compiler/rust-analyzer

Topic: ? operator

Hoang Luu (May 01 2019 at 18:08, on Zulip):

Right now I have this case:

    let match_arm = ctx.node_at_offset::<MatchArm>()?;

apparently, RA can recognize node_at_offset as:

    pub(crate) fn node_at_offset<N: AstNode>(&self) -> Option<&'a N>

but it can not recognize match_arm, after removal of ?, RA correctly shows match_arm as Option<&MatchArm>, is this a known issue?

matklad (May 01 2019 at 18:08, on Zulip):

Yeah, this is not yet implemented

Hoang Luu (May 01 2019 at 18:14, on Zulip):

I'm interested in this, which part should I look into to implement it? Or the scope of this one is too big right now?

matklad (May 01 2019 at 18:15, on Zulip):

I think this is blocked by chalk integration, cc @Florian Diebold

matklad (May 01 2019 at 18:16, on Zulip):

The specific bit of code that handle is is

Hoang Luu (May 01 2019 at 18:23, on Zulip):

I see, then it's too big for now. I think solving that adhoc-ly by just unwrap Result/Option could be simple and usable for most of the cases, but if solving it generally is near then it's worth to wait.

Florian Diebold (May 01 2019 at 18:31, on Zulip):

Yeah, exactly :)

Hoang Luu (May 14 2019 at 15:54, on Zulip):

Now that we have chalk integrated, how should we implement TryExpr properly?
My local small hack right now:

            Expr::Try { expr } => {
                if let Ty::Apply(ty) = self.infer_expr(*expr, &Expectation::none()) {
                    if ty.parameters.0.len() != 1 {
                    } else {
                } else {

this reduce Expressions of unknown type of rust-analyzer projects from 15% to 14%

Florian Diebold (May 14 2019 at 16:02, on Zulip):

I'm currently looking into Deref handling, once we have that we should have the tools to project an associated type, which should make the path to implementing this pretty clear

Florian Diebold (May 14 2019 at 16:02, on Zulip):

At which point I'll probably write up mentoring instructions for it ;)

Hoang Luu (May 14 2019 at 16:07, on Zulip):


Last update: Jul 24 2021 at 20:30UTC