Skip to content

Introduce TyErr independent from TyInfer - #40887

Merged
bors merged 2 commits into
rust-lang:masterfrom
estebank:ty-placeholder
Apr 8, 2017
Merged

Introduce TyErr independent from TyInfer#40887
bors merged 2 commits into
rust-lang:masterfrom
estebank:ty-placeholder

Conversation

@estebank

@estebankestebank commented Mar 29, 2017

Copy link
Copy Markdown
Contributor

Add a TyErr type to represent unknown types in places where
parse errors have happened, while still able to build the AST.

Initially only used to represent incorrectly written fn arguments and
avoid "expected X parameters, found Y" errors when called with the
appropriate amount of parameters. We cannot use TyInfer for this as
_ is not allowed as a valid argument type.

Example output:

error: expected one of `:` or `@`, found `,`
--> file.rs:12:9
|
12 | fn bar(x, y: usize){}
| ^
error[E0061]: this function takes 2 parameters but 3 parameters were supplied
--> file.rs:19:9
|
12 | fn bar(x, y){}
| --------------- defined here
...
19 | bar(1,2,3);
| ^^^^^^^ expected 2 parameters

Fix#34264.

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

@estebank
estebankforce-pushed the ty-placeholder branch 2 times, most recently from ed0e5dd to 0835f7cCompareMarch 29, 2017 02:11
@petrochenkov

Copy link
Copy Markdown
Contributor

TyError would be a more appropriate name (by analogy with TypeVariants::TyError or Def::Err doing the similar job).

Comment threadsrc/libsyntax/parse/parser.rs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: error reporting is a "cold" code for a reader trying to understand the main logic (syntax of fn arguments in this case), it often makes sense to factor it into a separate function (already done) and move it somewhere else, so it's invisible unless intentionally looked for.

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@estebank

Copy link
Copy Markdown
ContributorAuthor

@petrochenkov done.

@estebankestebank changed the title Introduce TyPlaceholder independent from TyInferIntroduce TyErr independent from TyInferApr 2, 2017
Add a `TyErr` type to represent unknown types in places where
parse errors have happened, while still able to build the AST.
Initially only used to represent incorrectly written fn arguments and
avoid "expected X parameters, found Y" errors when called with the
appropriate amount of parameters. We cannot use `TyInfer` for this as
`_` is not allowed as a valid argument type.
Example output:
```rust
error: expected one of `:` or `@`, found `,`
--> file.rs:12:9
|
12 | fn bar(x, y: usize) {}
| ^
error[E0061]: this function takes 2 parameters but 3 parameters were supplied
--> file.rs:19:9
|
12 | fn bar(x, y) {}
| --------------- defined here
...
19 | bar(1, 2, 3);
| ^^^^^^^ expected 2 parameters
```
@arielb1

Copy link
Copy Markdown
Contributor

r? @petrochenkov

@petrochenkov

Copy link
Copy Markdown
Contributor

@bors r+

@bors

bors commented Apr 6, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit b83352e has been approved by petrochenkov

@bors

bors commented Apr 7, 2017

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #41121) made this pull request unmergeable. Please resolve the merge conflicts.

@frewsxcvfrewsxcv mentioned this pull request Apr 7, 2017
@estebank
estebankforce-pushed the ty-placeholder branch 2 times, most recently from 60b37ee to d01bc33CompareApril 7, 2017 21:55
@estebank

Copy link
Copy Markdown
ContributorAuthor

@bors r=petrochenkov
fixed merge conflicts

@bors

bors commented Apr 8, 2017

Copy link
Copy Markdown
Collaborator

📌 Commit 8c31412 has been approved by petrochenkov

@bors

bors commented Apr 8, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 8c31412 with merge 566afe4...

@bors

bors commented Apr 8, 2017

Copy link
Copy Markdown
Collaborator

💔 Test failed - status-appveyor

@TimNN

TimNN commented Apr 8, 2017

Copy link
Copy Markdown
Contributor

@bors retry

#41147

@bors

bors commented Apr 8, 2017

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 8c31412 with merge fe39e94...

bors added a commit that referenced this pull request Apr 8, 2017
Introduce `TyErr` independent from `TyInfer`
Add a `TyErr` type to represent unknown types in places where
parse errors have happened, while still able to build the AST.
Initially only used to represent incorrectly written fn arguments and
avoid "expected X parameters, found Y" errors when called with the
appropriate amount of parameters. We cannot use `TyInfer` for this as
`_` is not allowed as a valid argument type.
Example output:
```rust
error: expected one of `:` or `@`, found `,`
--> file.rs:12:9
|
12 | fn bar(x, y: usize) {}
| ^
error[E0061]: this function takes 2 parameters but 3 parameters were supplied
--> file.rs:19:9
|
12 | fn bar(x, y) {}
| --------------- defined here
...
19 | bar(1, 2, 3);
| ^^^^^^^ expected 2 parameters
```
Fix#34264.
@bors

bors commented Apr 8, 2017

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-appveyor, status-travis
Approved by: petrochenkov
Pushing fe39e94 to master...

@bors
bors merged commit 8c31412 into rust-lang:masterApr 8, 2017
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@estebank@rust-highfive@petrochenkov@arielb1@bors@TimNN@pnkfelix