Skip to content

A : instead of a :: in a path of a use item should be a recoverable parsing error #103269

Closed
@pnkfelix

Description

@pnkfelix
Member

I tried this code:

use std::process:Command;
use std::fs:File;

fn main() { }

I expected to see this happen: I expected to see two diagnostic messages, telling me about the distinct parse errors on lines 1 and 2.

Instead, this happened: The first error was treated as non-recoverable, yielding this output (playground):

error: expected one of `::`, `;`, or `as`, found `:`
 --> src/main.rs:1:17
  |
1 | [use std::process:Command;](https://play.rust-lang.org/#)
  |                 ^ expected one of `::`, `;`, or `as`

error: could not compile `playground` due to previous error

I'm assuming recovering in the face of this parse error would be a relatively simple task, given that there is already the : present that should be a strong hint that someone meant to type ::. So I'm tagging this with labels indicating that its a good opportunity for someone who wants to acquaint themselves with the code base.

Activity

added
C-bugCategory: This is a bug.
E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
on Oct 19, 2022
pnkfelix

pnkfelix commented on Oct 19, 2022

@pnkfelix
MemberAuthor

(This needs a mentor. I am thinking that if someone doesn't pick it up by Friday, then I will see about using it as the basis for one or more instructional videos.)

added
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
A-parserArea: The lexing & parsing of Rust source code to an AST
on Oct 19, 2022
compiler-errors

compiler-errors commented on Oct 19, 2022

@compiler-errors
Member

I can mentor whoever wants to work on this. See https://github.com/rust-lang/rust/blob/master/compiler/rustc_parse/src/parser/item.rs#L950 for the general area where changes need to be made, and ping me if someone needs help on Zulip.

me-diru

me-diru commented on Oct 19, 2022

@me-diru

May I work on this?

compiler-errors

compiler-errors commented on Oct 19, 2022

@compiler-errors
Member

You can claim an issue with rustbot, and I recommend checking out the rustc dev guide to find out what the contribution process looks like.

chetankokil

chetankokil commented on Oct 20, 2022

@chetankokil

@compiler-errors i would like to work on this with your help.

will-flores1

will-flores1 commented on Oct 20, 2022

@will-flores1

@rustbot claim

will-flores1

will-flores1 commented on Oct 21, 2022

@will-flores1

@rustbot release-assignment

fee1-dead

fee1-dead commented on Oct 22, 2022

@fee1-dead
Member

This is mostly about adding checks around eat(token::ModSep) such that it recovers when encountering token::Colon. src

However, we would also need the ability to recover to be configurable as arguments to parse_path, as we would want to recover from use std:process::Command as well.

PS: don't take this as is.. I am not that familiar with ast and recovery, but I think this is the main idea

8 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-parserArea: The lexing & parsing of Rust source code to an ASTC-bugCategory: This is a bug.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.T-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

    Participants

    @pnkfelix@compiler-errors@chetankokil@mucinoab@me-diru

    Issue actions

      A `:` instead of a `::` in a path of a `use` item should be a recoverable parsing error · Issue #103269 · rust-lang/rust