Commit Graph

2490 Commits

Author SHA1 Message Date
David Wood
7fcf31b181 Add suggestion for underscore binding fix.
This commit emits a suggestion for adding an underscore binding to
arguments in trait methods that previously did not have a argument name
specified.
2018-12-07 12:02:41 +01:00
David Wood
e4dc15a969 Add context for RFC 1685 change in 2018 edition.
This commit adds a note providing context for the change to argument
names being required in the 2018 edition for trait methods.
2018-12-07 11:56:56 +01:00
bors
4bb5d35659 Auto merge of #56392 - petrochenkov:regensym, r=oli-obk
Delay gensym creation for "underscore items" (`use foo as _`/`const _`) until name resolution

So they cannot be cloned by macros. See https://github.com/rust-lang/rust/pull/56303 for the discussion.

Mostly fix cross-crate use of underscore items by inverting the "gensyms are lost in metadata" bug as described in https://github.com/rust-lang/rust/pull/56303#issuecomment-442464695.
Fix unused import warnings for single-segment imports (first commit) and `use crate_name as _` imports (as specified in https://github.com/rust-lang/rust/pull/56303#issuecomment-442274118).
Prohibit accidentally implemented `static _: TYPE = EXPR;` (cc https://github.com/rust-lang/rust/pull/55983).
Add more tests for `use foo as _` imports.
2018-12-06 15:08:11 +00:00
Vadim Petrochenkov
d08f7dcdca Address review comments 2018-12-04 01:13:03 +03:00
Vadim Petrochenkov
08f8faedd0 syntax: Rename some keywords
`CrateRoot` -> `PathRoot`, `::` doesn't necessarily mean crate root now
`SelfValue` -> `SelfLower`, `SelfType` -> `SelfUpper`, both `self` and `Self` can be used in type and value namespaces now
2018-12-04 00:30:27 +03:00
kennytm
a498a6d198 Rollup merge of #56433 - yui-knk:update_comment_of_parse_visibility, r=petrochenkov
Add description about `crate` for parse_visibility's comment

This rule was introduced by https://github.com/rust-lang/rust/pull/45401.
2018-12-03 18:07:18 +08:00
kennytm
ca98bce303 Rollup merge of #56419 - mark-i-m:remove-try, r=Centril
Remove some uses of try!
2018-12-03 18:07:15 +08:00
Vadim Petrochenkov
2d4b633be3 Delay gensym creation for "underscore items" until name resolution
Prohibit `static _`
Fis unused import warnings for `use foo as _`
Add more tests for `use foo as _`
2018-12-02 15:42:30 +03:00
yui-knk
172ec724af Fix "line longer than 100 chars" 2018-12-02 18:33:12 +09:00
yui-knk
70371fde17 Add description about crate for parse_visibility's comment
This rule was introduced by https://github.com/rust-lang/rust/pull/45401.
2018-12-02 17:01:44 +09:00
Mark Mansi
e7e96921c2 remove some uses of try! 2018-12-01 15:48:55 -06:00
Vadim Petrochenkov
549bd45e9e resolve: Support aliasing local crate root in extern prelude 2018-12-01 14:38:47 +03:00
Esteban Küber
2645871111 Use appropriate terminology based on heuristic 2018-11-30 15:09:39 -08:00
Esteban Küber
0952856e6c Suggest an appropriate token when encountering pub Ident<'a> 2018-11-30 11:48:08 -08:00
kennytm
bdb901c865 Rollup merge of #56336 - nnethercote:clean-up-pp, r=nikomatsakis
Clean up and streamline the pretty-printer

Some minor improvements.
2018-12-01 02:03:43 +08:00
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
Nicholas Nethercote
787959c20d Use Cow in Token::String.
`Printer::word` takes a `&str` and converts it into a `String`, which
causes an allocation. But that allocation is rarely necessary, because
`&str` is almost always a `&'static str` or a `String` that won't be
used again.

This commit changes `Token::String` so it holds a `Cow<'static, str>`
instead of a `String`, which avoids a lot of allocations.
2018-11-29 17:12:18 +11: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