Commit Graph

2424 Commits

Author SHA1 Message Date
Guillaume Gomez
3b64f86beb
Rollup merge of #56330 - estebank:cleanup-span, r=zackmdavis
Clean up span in non-trailing `..` suggestion
2018-11-29 13:10:54 +01:00
Guillaume Gomez
796892e0ef
Rollup merge of #56220 - estebank:suggest-lifetime-move, r=nikomatsakis
Suggest appropriate place for lifetime when declared after type arguments
2018-11-29 13:10:39 +01:00
Esteban Küber
66a2c39290 Clean up span in non-trailing .. suggestion 2018-11-28 16:05:02 -08:00
Esteban Küber
6f028fe8e0 Specify suggestion applicability 2018-11-26 13:58:46 -08:00
Vadim Petrochenkov
dae4c7b1ff resolve: Implement edition hygiene for imports and absolute paths
Use per-span hygiene in a few other places in resolve
Prefer `rust_2015`/`rust_2018` helpers to comparing editions
2018-11-27 00:32:30 +03:00
Esteban Küber
45dfe43887 Emit one diagnostic for multiple misplaced lifetimes 2018-11-26 08:32:47 -08:00
Esteban Küber
234d043d18 Move lifetimes before the *first* type argument 2018-11-25 12:51:04 -08:00
Esteban Küber
79ee8f329d Suggest appropriate place for lifetime when declared after type arguments 2018-11-25 12:41:38 -08:00
Guillaume Gomez
75d226ed76
Rollup merge of #56002 - Axary:master, r=estebank
fix #55972: Erroneous self arguments on bare functions emit subpar compilation error

#55972

r? @estebank
2018-11-22 10:37:50 +01:00
Axary
88d60941da improve error note 2018-11-20 14:43:16 +01:00
Axary
2be930bd03 fix tidy (remove whitespace) 2018-11-16 19:35:13 +01:00
Axary
fe23ffbda0 improve error when self is used as not the first argument 2018-11-16 19:27:27 +01:00
Axary
646d68f585 add a note to the error message 2018-11-16 18:43:06 +01:00
Axary
218e35efa1 eat CloseDelim 2018-11-16 13:54:49 +01:00
Eric Huss
7f4bc2247a Clean up some non-mod-rs stuff. 2018-11-14 18:55:41 -08:00
Nicholas Nethercote
c6862992d9 Change Lit::short_name to Lit::literal_name.
This avoids a moderately hot allocation in `parse_lit_token`.
2018-11-12 15:16:03 +11:00
Mark Rousskov
686de87d2f
Rollup merge of #55777 - nnethercote:less-P-in-ast, r=petrochenkov
Use `Lit` rather than `P<Lit>` in `ast::ExprKind`.

Because it results in fewer allocations and small speedups on some
benchmarks.
2018-11-08 18:15:19 -07:00
Nicholas Nethercote
706c2ad651 Use Lit rather than P<Lit> in ast::ExprKind.
Because it results in fewer allocations and small speedups on some
benchmarks.
2018-11-08 19:00:55 +11:00
kennytm
9d9146ad95
Rollup merge of #55734 - teresy:shorthand-fields, r=davidtwco
refactor: use shorthand fields

refactor: use shorthand for single fields everywhere (excluding tests).
2018-11-07 21:27:00 +08:00
teresy
eca11b99a7 refactor: use shorthand fields 2018-11-06 15:05:44 -05:00
bors
af791bb8f4 Auto merge of #55451 - estebank:arg-doc, r=pnkfelix
Custom diagnostic when trying to doc comment argument

When writing

```
pub fn f(
    /// Comment
    id: u8,
) {}
```

Produce a targeted diagnostic

```
error: documentation comments cannot be applied to method arguments
  --> $DIR/fn-arg-doc-comment.rs:2:5
   |
LL |     /// Comment
   |     ^^^^^^^^^^^ doc comments are not allowed here
```

Fix #54801.
2018-11-05 16:36:18 +00:00
bors
794fc062be Auto merge of #55455 - estebank:expected-descr, r=michaelwoerister
Use token description in "expected/found" parse messages

Fix #54309.
2018-11-04 06:56:11 +00:00
Alexander Regueiro
4bdc3d833a Extended elaboration for trait aliases to include arbitrary bounds. 2018-11-03 04:09:34 +00:00
Alexander Regueiro
90041d638b Added support for trait aliases as object types. 2018-11-03 04:09:34 +00:00
Esteban Küber
54858d5a67 Fix regression 2018-10-29 09:39:58 -07:00
Esteban Küber
3e22e0c3bc Use token description in "expected/found" parse messages 2018-10-28 16:05:50 -07:00
Esteban Küber
adb96ec64b Provide specific label for patern parsing error 2018-10-28 14:38:00 -07:00
Esteban Küber
d491734b15 Point at match when a parse failure ocurrs inside of it 2018-10-28 11:41:23 -07:00
Esteban Küber
ea57134607 Produce targeted diagnostic when using doc comments on fn args
Before parsing argument names and types, try to consume an incorrectly
included doc comment or attribute in order to recover and continue
parsing the rest of the fn definition.
2018-10-28 11:38:50 -07:00
bors
4f5cfa611d Auto merge of #55192 - cramertj:nested-mod, r=petrochenkov
Fix ordering of nested modules in non-mod.rs mods

Flatten relative offset into directory path before adding inline
(mod x { ... }) module names to the current directory path.

Fix #55094
2018-10-28 13:13:55 +00:00
Nick Cameron
59cb1705d7 rebasing and reviewer changes
Primarily refactoring `(Ident, Option<NodeId>)` to `Segment`
2018-10-26 09:50:51 +13:00
Nick Cameron
fc67d8fac4 Give each PathSegment a NodeId 2018-10-26 09:48:44 +13:00
ljedrz
d28aed6dc4 Prefer unwrap_or_else to unwrap_or in case of function calls/allocations 2018-10-19 09:45:45 +02:00
Taylor Cramer
ca35ca8395 Fix ordering of nested modules in non-mod.rs mods
Flatten relative offset into directory path before adding inline
(mod x { ... }) module names to the current directory path.

Fix #55094
2018-10-18 17:11:51 -07:00
Donato Sciarra
406cbf1a39 Support underscore as constant name
Issue: 54912
2018-10-14 10:14:58 +02:00
kennytm
644dbf99ed
Rollup merge of #54967 - holmgr:master, r=estebank
Remove incorrect span for second label inner macro invocation

A fix for issue #54841
2018-10-12 22:04:16 +08:00
bors
a534216fa6 Auto merge of #54850 - mcr431:fix-54707-trait-function-from-macro, r=nikomatsakis
Fix #54707 - parse_trait_item_ now handles interpolated blocks as function body decls

Fix #54707 - parse_trait_item_ now handles interpolated blocks as function body decls

Previously parsing trait items only handled opening brace token and semicolon, I added a branch to the match statement that will also handle interpolated blocks.
2018-10-11 09:19:23 +00:00
Manish Goregaokar
e1e628ec87 Rollup merge of #54893 - dsciarra:issue-54379, r=pnkfelix
Fixes #47311.
r? @nrc
2018-10-10 15:59:21 -07:00
Manish Goregaokar
8ebc6d6dbb Rollup merge of #54862 - Havvy:cfg_attr_multi, r=petrochenkov
Fixes #47311.
r? @nrc
2018-10-10 15:58:40 -07:00
holmgr
05bb22d9e8 Remove incorrect span for second label inner macro invocation 2018-10-10 19:39:16 +02:00
Matthew Russo
344747330c parse_trait_item_ now handles interpolated blocks as function body decls 2018-10-08 22:50:34 -04:00
Donato Sciarra
b7248d5988 Fix internal compiler error on malformed match arm pattern.
Issue: 54379
2018-10-07 13:14:21 +02:00
Havvy (Ryan Scheel)
1a867dc346 cfg_attr_multi: Basic implementation
Does not implement the warning or a feature flag.
2018-10-05 17:29:17 -07:00
Pietro Albini
a95a6e287a
Rollup merge of #54833 - abonander:issue-54441, r=petrochenkov
make `Parser::parse_foreign_item()` return a foreign item or error

Fixes `Parser::parse_foreign_item()` to follow the convention of `parse_trait_item()` and `parse_impl_item()` in that it *must* parse an item or return an error, and then the caller is responsible for detecting the closing delimiter.

This prevents it from looping endlessly on an unexpected token in `ext/expand.rs` where it was also leaking memory by continually pushing to `Parser::expected_tokens` via `Parser::check_keyword()`.

closes #54441

r? @petrochenkov
cc @dtolnay
2018-10-05 22:33:17 +02:00
Andy Russell
f5db411410
add suggestion for inverted function parameters
Fixes #54065.
2018-10-05 10:33:19 -04:00
Austin Bonander
9da428dad8 make Parser::parse_foreign_item() return a foreign item or error
closes #54441
2018-10-05 02:47:57 -07:00
bors
c4501a0f1d Auto merge of #52319 - tinco:issue_12590, r=pnkfelix
Track whether module declarations are inline (fixes #12590)

To track whether module declarations are inline I added a field `inline: bool` to `ast::Mod`. The main use case is for pretty to know whether it should render the items associated with the module, but perhaps there are use cases for this information to not be forgotten in the AST.
2018-09-27 09:51:12 +00:00
David Wood
3becbbc129
Fixed off-by-one span.
Fixes the off-by-one span issue where closure argument spans were
pointing to the token after the argument.
2018-09-23 14:18:34 +02:00
Pietro Albini
7c34cf7ee3
Rollup merge of #54415 - petrochenkov:norollback, r=estebank
parser: Tweak function parameter parsing to avoid rollback on succesfull path

Since rollback is not perfect and may e.g. leave non-fatal errors after it, we need to make sure compilation fails if it happens.
So in particular case of `fn parse_arg_general` we need to parse the "good" `TYPE` first and only then rollback and recover erroneous `PAT: TYPE` if necessary.
Found when working on https://github.com/rust-lang/rfcs/pull/2544#issuecomment-423293222.

r? @ghost
2018-09-22 09:56:40 +02:00
Pietro Albini
1eee532eff
Rollup merge of #54409 - estebank:remove-in, r=pnkfelix
Detect `for _ in in bar {}` typo

Fix #36611, #52964, without modifying the parsing of emplacement `in` to avoid further problems like #50832.
2018-09-22 09:56:37 +02:00