Skip to content

Diagnostics could be better for unclosed delimiters #63690

Closed
@sgrif

Description

@sgrif

Depending on where the unclosed delimiter is in the file, you can get dozens or even hundreds of meaningless errors after the unclosed delimiter. Since terminals display the last output from a program, this means that the actual error gets completely buried. This afternoon I had to scroll through more than 200 lines of output to find where the actual error was. This can be reproduced by taking any reasonably large file, deleting the closing } of a function towards the top, and trying to build it.

Example Output
error: this file contains an un-closed delimiter
   --> src/controllers/helpers/pagination.rs:175:3
    |
16  | impl Page {
    |           - un-closed delimiter
17  |     fn new(params: &IndexMap<String, String>) -> CargoResult<Self> {
    |                                                                    - this delimiter might not be properly closed...
...
31  | }
    | - ...as it matches this but it has different indentation
...
175 | }
    |   ^

error: this file contains an un-closed delimiter
   --> src/controllers/helpers/pagination.rs:175:3
    |
16  | impl Page {
    |           - un-closed delimiter
17  |     fn new(params: &IndexMap<String, String>) -> CargoResult<Self> {
    |                                                                    - this delimiter might not be properly closed...
...
31  | }
    | - ...as it matches this but it has different indentation
...
175 | }
    |   ^

error: expected one of `async`, `const`, `default`, `existential`, `extern`, `fn`, `type`, or `unsafe`, found `struct`
  --> src/controllers/helpers/pagination.rs:34:12
   |
34 | pub(crate) struct PaginationOptions {
   |            ^^^^^^ expected one of 8 possible tokens here

error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `impl`
  --> src/controllers/helpers/pagination.rs:39:1
error: expected one of `async`, `const`, `default`, `existential`, `extern`, `fn`, `type`, or `unsafe`, found `struct`
  --> src/controllers/helpers/pagination.rs:34:12
   |
34 | pub(crate) struct PaginationOptions {
   |            ^^^^^^ expected one of 8 possible tokens here

error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `impl`
  --> src/controllers/helpers/pagination.rs:39:1
   |
37 | }
   |  - expected one of 11 possible tokens here
38 |
39 | impl PaginationOptions {
   | ^^^^ unexpected token

   |
37 | }
   |  - expected one of 11 possible tokens here
38 |
39 | impl PaginationOptions {
   | ^^^^ unexpected token

error: expected one of `async`, `const`, `default`, `existential`, `extern`, `fn`, `type`, or `unsafe`, found `trait`
  --> src/controllers/helpers/pagination.rs:69:12
   |
69 | pub(crate) trait Paginate: Sized {
   |            ^^^^^ expected one of 8 possible tokens here

error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `impl`
  --> src/controllers/helpers/pagination.rs:78:1
   |
76 | }
   |  - expected one of 11 possible tokens here
77 |
78 | impl<T> Paginate for T {}
   | ^^^^ unexpected token

error: expected one of `async`, `const`, `default`, `existential`, `extern`, `fn`, `type`, or `unsafe`, found `trait`
  --> src/controllers/helpers/pagination.rs:69:12
   |
69 | pub(crate) trait Paginate: Sized {
   |            ^^^^^ expected one of 8 possible tokens here

error: expected one of `(`, `async`, `const`, `default`, `existential`, `extern`, `fn`, `type`, or `unsafe`, found `struct`
  --> src/controllers/helpers/pagination.rs:80:5
   |
80 | pub struct Paginated<T> {
   |     ^^^^^^ expected one of 9 possible tokens here

error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `impl`
  --> src/controllers/helpers/pagination.rs:78:1
   |
76 | }
   |  - expected one of 11 possible tokens here
77 |
78 | impl<T> Paginate for T {}
   | ^^^^ unexpected token
error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `impl`
  --> src/controllers/helpers/pagination.rs:85:1
   |
83 | }
   |  - expected one of 11 possible tokens here

84 |
85 | impl<T> Paginated<T> {
   | ^^^^ unexpected token

error: expected one of `(`, `async`, `const`, `default`, `existential`, `extern`, `fn`, `type`, or `unsafe`, found `struct`
  --> src/controllers/helpers/pagination.rs:80:5
   |
80 | pub struct Paginated<T> {
   |     ^^^^^^ expected one of 9 possible tokens here

error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `impl`
   --> src/controllers/helpers/pagination.rs:120:1
    |
118 | }
    |  - expected one of 11 possible tokens here
119 |
120 | impl<T> IntoIterator for Paginated<T> {
    | ^^^^ unexpected token

error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `impl`
  --> src/controllers/helpers/pagination.rs:85:1
   |
83 | }
   |  - expected one of 11 possible tokens here
84 |
85 | impl<T> Paginated<T> {
   | ^^^^ unexpected token
error: expected one of `async`, `const`, `default`, `existential`, `extern`, `fn`, `type`, or `unsafe`, found `struct`
   --> src/controllers/helpers/pagination.rs:130:12
    |
130 | pub(crate) struct PaginatedQuery<T> {

    |            ^^^^^^ expected one of 8 possible tokens here

error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `impl`
   --> src/controllers/helpers/pagination.rs:135:1
    |
133 | }
    |  - expected one of 11 possible tokens here
134 |
135 | impl<T> PaginatedQuery<T> {
    | ^^^^ unexpected token

error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `impl`
   --> src/controllers/helpers/pagination.rs:120:1
    |
118 | }
    |  - expected one of 11 possible tokens here
119 |
120 | impl<T> IntoIterator for Paginated<T> {
    | ^^^^ unexpected token

error: expected one of `async`, `const`, `default`, `existential`, `extern`, `fn`, `type`, or `unsafe`, found `struct`
   --> src/controllers/helpers/pagination.rs:130:12
    |
130 | pub(crate) struct PaginatedQuery<T> {
    |            ^^^^^^ expected one of 8 possible tokens here

error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `impl`
   --> src/controllers/helpers/pagination.rs:149:1
    |
147 | }
    |  - expected one of 11 possible tokens here
148 |
149 | impl<T> QueryId for PaginatedQuery<T> {
    | ^^^^ unexpected token

error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `impl`
   --> src/controllers/helpers/pagination.rs:135:1
    |
133 | }
    |  - expected one of 11 possible tokens here
134 |
135 | impl<T> PaginatedQuery<T> {
    | ^^^^ unexpected token

error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `impl`
   --> src/controllers/helpers/pagination.rs:154:1
    |
152 | }
    |  - expected one of 11 possible tokens here
153 |
154 | impl<T: Query> Query for PaginatedQuery<T> {
    | ^^^^ unexpected token

error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `impl`
   --> src/controllers/helpers/pagination.rs:149:1
    |
147 | }
    |  - expected one of 11 possible tokens here
148 |
149 | impl<T> QueryId for PaginatedQuery<T> {
    | ^^^^ unexpected token

error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `impl`
   --> src/controllers/helpers/pagination.rs:158:1
    |
156 | }
    |  - expected one of 11 possible tokens here
157 |
158 | impl<T, DB> RunQueryDsl<DB> for PaginatedQuery<T> {}
    | ^^^^ unexpected token

error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `impl`
   --> src/controllers/helpers/pagination.rs:154:1
    |
152 | }
    |  - expected one of 11 possible tokens here
153 |
154 | impl<T: Query> Query for PaginatedQuery<T> {
    | ^^^^ unexpected token

error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `impl`
   --> src/controllers/helpers/pagination.rs:158:1
    |
156 | }
    |  - expected one of 11 possible tokens here
157 |
158 | impl<T, DB> RunQueryDsl<DB> for PaginatedQuery<T> {}
    | ^^^^ unexpected token

error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `impl`
   --> src/controllers/helpers/pagination.rs:160:1
    |
158 | impl<T, DB> RunQueryDsl<DB> for PaginatedQuery<T> {}
    |                                                     - expected one of 11 possible tokens here
159 |
160 | impl<T> QueryFragment<Pg> for PaginatedQuery<T>
    | ^^^^ unexpected token

error: expected one of `async`, `const`, `crate`, `default`, `existential`, `extern`, `fn`, `pub`, `type`, `unsafe`, or `}`, found `impl`
   --> src/controllers/helpers/pagination.rs:160:1
    |
158 | impl<T, DB> RunQueryDsl<DB> for PaginatedQuery<T> {}
    |                                                     - expected one of 11 possible tokens here
159 |
160 | impl<T> QueryFragment<Pg> for PaginatedQuery<T>
    | ^^^^ unexpected token

Metadata

Metadata

Assignees

Labels

A-diagnosticsArea: Messages for errors, warnings, and lintsA-parserArea: The lexing & parsing of Rust source code to an ASTC-enhancementCategory: An issue proposing an enhancement or a PR with one.D-papercutDiagnostics: An error or lint that needs small tweaks.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-diagnosticsWorking group: Diagnostics

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions