Commit Graph

7489 Commits

Author SHA1 Message Date
varkor
6015edf9af Remove name from GenericParamKind::Lifetime 2018-06-20 12:23:08 +01:00
varkor
80dbe58efc Use ParamBounds in WhereRegionPredicate 2018-06-20 12:23:07 +01:00
varkor
aed530a457 Lift bounds into GenericParam 2018-06-20 12:22:46 +01:00
varkor
a5328bc17b Simply joint lifetime/type iteration 2018-06-20 12:21:52 +01:00
varkor
8bccfe7a52 Refactor counting methods 2018-06-20 12:21:52 +01:00
varkor
3bcb006fd9 Rename structures in ast 2018-06-20 12:21:52 +01:00
varkor
c65454850f Remove AngleBracketedArgs impl 2018-06-20 12:21:08 +01:00
varkor
e1d888c722 Remove methods from ast::GenericParam and ast::Generics 2018-06-20 12:21:08 +01:00
varkor
2c6ff2469a Refactor ast::GenericParam as a struct 2018-06-20 12:21:08 +01:00
varkor
82dba3d419 Refactor hir::GenericParam as a struct 2018-06-20 12:21:07 +01:00
varkor
d643946550 Rename ast::GenericParam and ast::GenericArg
It's so confusing to have everything having the same name, at least while refactoring.
2018-06-20 12:19:04 +01:00
varkor
f9d0968906 Make method and variable names more consistent 2018-06-20 12:19:04 +01:00
varkor
76c0d68745 Rename "parameter" to "arg" 2018-06-20 12:19:04 +01:00
varkor
3e89753283 Rename PathParameter(s) to GenericArg(s) 2018-06-20 12:19:04 +01:00
varkor
1ed60a9173 Rename *Parameter to *Param 2018-06-20 12:19:04 +01:00
varkor
494859e8dd Consolidate PathParameters and AngleBracketedParameterData 2018-06-20 12:19:03 +01:00
Esteban Küber
28cea50a46 Update error code numbers 2018-06-19 17:33:14 -07:00
Esteban Küber
317258c1ce Fix tidy and remove unused method 2018-06-19 15:19:20 -07:00
Esteban Küber
a93f176b74 Point to previous line for single expected token 2018-06-19 15:19:16 -07:00
Esteban Küber
776544f011 Add message to rustc_on_unimplemented attributes in core 2018-06-19 15:19:13 -07:00
Esteban Küber
b3a1d56ebe Add code to incorrect pub restriction error 2018-06-19 11:37:33 -07:00
Esteban Küber
09e42bcb10 Add code to invalid ABI error 2018-06-19 11:37:33 -07:00
Seiichi Uchida
cafe9d0ed4 Do not consume semicolon twice while parsing local statement 2018-06-19 14:04:16 +09:00
bors
ed39523406 Auto merge of #51278 - EPashkin:fix_mod_with_multilevel_paths_on_windows, r=nikomatsakis
Fix processing mod with multi-level path on Windows

Fix error in [rustfmt](https://github.com/rust-lang-nursery/rustfmt/issues/1754) because libsyntax can not handle `mod` with multilevel path on Windows.

Alternative is do almost same in https://github.com/rust-lang/rust/blob/master/src/libstd/sys/windows/fs.rs#L717 to allow work on paths with different separators, Ex. "\\\\?\\c:\\windows/temp"
2018-06-19 02:17:52 +00:00
bors
9181741ede Auto merge of #51549 - PSeitz:patch-1, r=kennytm
Follow up to #51508, make parse_block public instead parse_block_expr

This is an follow up to #51508

I mistakenly made parse_block_expr public instead of parse_block.
This fixes this.
2018-06-17 14:05:43 +00:00
bors
594b05dd97 Auto merge of #51425 - QuietMisdreavus:thats-def-a-namespace-there, r=petrochenkov
refactor: create multiple HIR items for imports

When lowering `use` statements into HIR, they get a `Def` of the thing they're pointing at. This is great for things that need to know what was just pulled into scope. However, this is a bit misleading, because a `use` statement can pull things from multiple namespaces if their names collide. This is a problem for rustdoc, because if there are a module and a function with the same name (for example) then it will only document the module import, because that's that the lowered `use` statement points to.

The current version of this PR does the following:

* Whenever the resolver comes across a `use` statement, it loads the definitions into a new `import_map` instead of the existing `def_map`. This keeps the resolutions per-namespace so that all the target definitions are available.
* When lowering `use` statements, it looks up the resolutions in the `import_map` and creates multiple `Item`s if there is more than one resolution.
* To ensure the `NodeId`s are properly tracked in the lowered module, they need to be created in the AST, and pulled out as needed if multiple resolutions are available.

Fixes https://github.com/rust-lang/rust/issues/34843
2018-06-17 09:48:10 +00:00
bors
61ba018093 Auto merge of #51562 - SimonSapin:transparent, r=cramertj
Stabilize #[repr(transparent)]

Tracking issue FCP: https://github.com/rust-lang/rust/issues/43036#issuecomment-394094318
Reference PR: https://github.com/rust-lang-nursery/reference/pull/353
2018-06-16 10:59:40 +00:00
PSeitz
b1c0857f62 Follow up on https://github.com/rust-lang/rust/pull/51508, make parse_block public instead parse_block_expr
This is an follow up to #51508

I mistakenly made parse_block_expr public instead of parse_block.
This fixes this.
2018-06-16 08:00:14 +02:00
bors
967c1f3be1 Auto merge of #50296 - cmdd:master, r=nikomatsakis
Add error message for using >= 65535 hashes for raw string literal escapes

Fixes #50111.
2018-06-15 19:05:25 +00:00
QuietMisdreavus
122b5b47c2 create multiple HIR items for a use statement 2018-06-14 17:47:28 -05:00
Niko Matsakis
d6f13c0e20 update wording, do not change parser 2018-06-12 14:49:17 -04:00
bors
b68432d560 Auto merge of #51521 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 3 pull requests

Successful merges:

 - #51261 (Updated RELEASES.md for 1.27.0)
 - #51502 (Make parse_seq_to_end and parse_path public)
 - #51510 (Long diagnostic for E0538)

Failed merges:
2018-06-12 17:37:12 +00:00
Mark Rousskov
398e570891
Rollup merge of #51510 - Havvy:diagnostic-list, r=GuillaumeGomez
Long diagnostic for E0538

r? @GuillaumeGomez
2018-06-12 11:22:54 -06:00
Mark Rousskov
1e06b1757c
Rollup merge of #51502 - jebrosen:pub_parse_methods, r=Mark-Simulacrum
Make parse_seq_to_end and parse_path public

(see SergioBenitez/Rocket#660, rust-lang/rust#51265)

Rocket currently uses `parse_seq_to_end` and `parse_path` in its codegen macros. Assuming I tested correctly, this is the minimal set of methods that are currently necessary to build Rocket again. I would be happy to add documentation of this and Rocket's other usages, if desired.
2018-06-12 11:22:53 -06:00
bors
ef8cb40c9c Auto merge of #51519 - ExpHP:issue-51331-b, r=petrochenkov
Fix for $crate var normalization in proc macro for externally defined macros

Fixes #51331, a bug that has existed in at least *some* form for a year and a half.

The PR includes the addition of a `fold_qpath` method to `syntax::fold::Folder`.  Overriding this method is useful for folds that modify paths in a way that invalidates indices (insertion or removal of a component), as it provides the opportunity to update `qself.position` in `<A as B>::C` paths.  I added it because the bugfix is messy without it.

(unfortunately, grepping around the codebase, I did not see anything else that could use it.)
2018-06-12 15:23:28 +00:00
Michael Lamparski
a20c177827 add fold::Folder::fold_qpath 2018-06-12 08:06:22 -04:00
bors
a1aae290d5 Auto merge of #51508 - PSeitz:master, r=Mark-Simulacrum
Make span_fatal and parse_block public

span_fatal and parse_block  were made private in #51265. These methods are used in stainless.

Related #51498 #51504
2018-06-12 11:06:09 +00:00
Simon Sapin
e2aef92c19 Stabilize #[repr(transparent)]
Tracking issue FCP: https://github.com/rust-lang/rust/issues/43036#issuecomment-394094318
Reference PR: https://github.com/rust-lang-nursery/reference/pull/353
2018-06-12 06:49:07 +02:00
bors
1abb4ef636 Auto merge of #51498 - topecongiro:pub-parse_ident, r=petrochenkov
Make parse_ident public

`parse_ident` was made private in #51265. In rustfmt the method is used to create a custom parser for macro call.
2018-06-12 02:48:10 +00:00
Havvy
e9e0ca0382 Slightly better summary for E0538 2018-06-11 17:21:15 -07:00
Havvy
45748256ef Long diagnostic for E0538 2018-06-11 15:49:54 -07:00
Simon Sapin
999690ce5d Stabilize the #[global_allocator] attribute
Fixes https://github.com/rust-lang/rust/issues/27389
2018-06-11 13:48:56 -07:00
PSeitz
6fd9ede0cd
Make span_fatal and parse_block public
span_fatal and parse_block  were made private in #51265. These methods are used in stainless.

Related #51498 #51504
2018-06-11 21:19:12 +02:00
jeb
7e56261fcb Make parse_seq_to_end and parse_path public 2018-06-11 10:40:58 -06:00
bors
0b7c9e756e Auto merge of #51490 - Havvy:diagnostic-list, r=GuillaumeGomez
Long diagnostic for E0541

r? @GuillaumeGomez
2018-06-11 15:28:44 +00:00
Seiichi Uchida
ed74b0b016 Make parse_ident public 2018-06-11 23:04:11 +09:00
Havvy
cf3fcab973 More E0541 long diagnostic wording tweaks 2018-06-11 03:51:04 -07:00
bors
13f8d073fe Auto merge of #51480 - dtolnay:lifetime, r=kennytm
Enable fall through past $:lifetime matcher

```rust
macro_rules! is_lifetime {
    ($lifetime:lifetime) => { true };
    ($other:tt) => { false };
}

fn main() {
    println!("{}", is_lifetime!('lifetime));
    println!("{}", is_lifetime!(@));
}
```

Before this fix, the `is_lifetime!` invocation would fail to compile with:

```
error: expected a lifetime, found `@`
 --> src/main.rs:8:33
  |
8 |     println!("{}", is_lifetime!(@));
  |                                 ^
```

Fixes #50903.
Fixes #51477.

r? @kennytm
2018-06-11 10:43:20 +00:00
Havvy
0c91bd200e Make tidy happy 2018-06-11 03:04:08 -07:00
Havvy
2d7b046d71 Fix typos in previous commit 2018-06-11 02:44:55 -07:00
Havvy
f7df1f38dd Long diagnostic for E0541 2018-06-11 01:52:12 -07:00
David Tolnay
987020846c
Enable fall through past $:lifetime matcher 2018-06-10 14:39:16 -07:00
bors
a805a2a5eb Auto merge of #50205 - topecongiro:include-parens-to-type-parameter, r=petrochenkov
Include parens to type parameter

The motivation of this PR is to fix a bug in rustfmt (cc https://github.com/rust-lang-nursery/rustfmt/issues/2630).
2018-06-10 20:09:22 +00:00
Seiichi Uchida
699be41809 Simplify an error handling in the parser 2018-06-10 10:37:38 +09:00
Seiichi Uchida
78a19d9b88 Include parens to type parameter 2018-06-10 10:37:38 +09:00
Mark Simulacrum
60058e5dbe Crate-ify and delete unused code in syntax::parse 2018-06-09 16:57:19 -06:00
bors
61d88318aa Auto merge of #51068 - Crazycolorz5:pluseqsplitting, r=petrochenkov
parser: Split `+=` into `+` and `=` where `+` is explicitly requested (such as generics)

Added functions in tokens to check whether a token leads with `+`. Used them when parsing to allow for token splitting of `+=` into `+` and `=`.
Fixes https://github.com/rust-lang/rust/issues/47856
2018-06-09 17:46:36 +00:00
Mark Rousskov
d68098a43e
Rollup merge of #51298 - Dylan-DPC:stabilise/termination-test, r=nikomatsakis
Stabilize unit tests with non-`()` return type

References #48854
2018-06-08 17:20:59 -06:00
Mark Rousskov
71865fb947
Rollup merge of #51099 - Crazycolorz5:expectedcloseparen, r=estebank
Fix Issue 38777

When looking through for a closing bracket in the loop condition, adds them to expecteds.
https://github.com/rust-lang/rust/issues/38777
2018-06-08 17:20:57 -06:00
David Cao
313d6c53df provide error message when using more than 65535 hash symbols for raw strings 2018-06-08 15:32:28 -07:00
Niko Matsakis
92d4ae2be2 rename irrefutable_let_pattern to irrefutable_let_patterns 2018-06-08 11:37:35 -04:00
kennytm
e46ef1bb86
Rollup merge of #51417 - pietroalbini:revert-49719, r=nikomatsakis
Revert #49719

This also needs to be backported into beta.

Fixes #51416.
r? @nikomatsakis
2018-06-08 07:05:47 +08:00
kennytm
26a9d589c8
Rollup merge of #51283 - kennytm:fix-51279-preempt-the-warning-song-and-dance, r=nikomatsakis
Deny #[cfg] and #[cfg_attr] on generic parameters.

Fix #51279.

Attributes on generic parameters are not expanded, meaning `#[cfg]`, `#[cfg_attr]` and attribute proc macros are entirely ignored on them.

This PR makes using the first two attributes an error, because if they are correctly expanded will affect the AST and change code behavior.

I'm beta-nominating this, because generic parameter attributes are stabilizing in 1.27, and if we did not reserve their usage, we may never be able to repurpose the meaning of these attributes in the Rust 2015 edition.
2018-06-08 07:05:39 +08:00
Pietro Albini
1df7817122
Revert "Auto merge of #49719 - mark-i-m:no_sep, r=petrochenkov"
This reverts commit d6ba1b9b02, reversing
changes made to 8de5353f75.
2018-06-07 17:07:05 +02:00
Sebastian Malton
e7c7f5f071 Allowing attributes to be on if let statements 2018-06-06 22:03:42 -04:00
Niko Matsakis
b417701ac1 add an explanatory comment 2018-06-07 00:26:31 +03:00
bors
35aeecb8aa Auto merge of #51201 - estebank:dotdot, r=petrochenkov
Accept `..` in incorrect position to avoid further errors

We currently give a specific message when encountering a `..` anywhere
other than the end of a pattern. Modify the parser to accept it (while
still emitting the error) so that we don't also trigger "missing fields
in pattern" errors afterwards.

Add suggestions to either remove trailing `,` or moving the `..` to the
end.

Follow up to #49268.
2018-06-06 14:04:06 +00:00
dylan_DPC
1048ae29a1 append unused variables with _ 2018-06-06 12:22:38 +05:30
dylan_DPC
e8fd74a11d remove redundant match branch 2018-06-05 23:44:42 +05:30
dylan_DPC
4cbf400366 flag changed to none 2018-06-05 23:28:32 +05:30
Esteban Küber
d66d35bb91 Account for comma in suggestion 2018-06-05 08:48:55 -07:00
Esteban Küber
cbc70a0d68 Improve diagnostics for incorrect .. usage
When using `..` somewhere other than the end, parse the rest of the
pattern correctly while still emitting an error.

Add suggestions to either remove trailing `,` or moving the `..` to the
end.
2018-06-05 08:48:55 -07:00
Esteban Küber
8f4a5429c2 Accept .. in incorrect position to avoid further errors
We currently give a specific message when encountering a `..` anywhere
other than the end of a pattern. Modify the parser to accept it (while
still emitting the error) so that we don't also trigger "missing fields
in pattern" errors afterwards.
2018-06-05 08:48:54 -07:00
Sebastian Malton
4fe40635ef Implementation of RFC 2086 - Allow Irrefutable Let patterns 2018-06-05 10:19:21 -04:00
bors
4122885e0f Auto merge of #51140 - GuillaumeGomez:doc-keyword, r=QuietMisdreavus
rustdoc: introduce the #[doc(keyword="")] attribute for documenting keywords

Part of #34601.

r? @QuietMisdreavus
2018-06-05 10:00:08 +00:00
Crazycolorz5
759a0e07b5 Fixed indentation error. 2018-06-04 22:25:01 -04:00
Crazycolorz5
812ace6e86 Fixed incorrect check_plus to token.is_like_plus. 2018-06-04 22:25:01 -04:00
Crazycolorz5
a5dc83d970 Tidy fixes. 2018-06-04 22:25:01 -04:00
Crazycolorz5
7a9ffa7307 Added is_like_plus to token, and used that in place of equality comparison to Plus token. 2018-06-04 22:25:00 -04:00
Crazycolorz5
682033c4e4 Implemented eat_plus and used it in parsing parse_ty_param_bounds_common. 2018-06-04 22:25:00 -04:00
bors
f9157f5b86 Auto merge of #51242 - ytausky:mut-ref, r=estebank
Suggest not mutably borrowing a mutable reference

This PR would (hopefully) solve #45392. I deviated a bit from @estebank's instructions since the error span only included the borrowed expression (e.g. the `b` in `&mut b`). I also didn't check the mutability of the local binding, since this whole case is concerned with an immutable local.

I can see two outstanding questions:
1. `note_immutability_blame` is called in two places, but I only have one test case. I think it covers the call in `report_bckerror`, but I'm not sure how to trigger the call from `report_aliasability_violation`.
2. There is one failing test, where the local binding is `self: &mut Self`. I'm not entirely sure what the correct output should be, but I think the new message should also apply. Unfortunately, since this parameter is parsed differently, its `let_span` covers both the pattern and the type, leading to a wrong suggestion text. I'm not sure how to correctly identify this case.
2018-06-05 01:47:13 +00:00
Guillaume Gomez
ded5c5a9ee Put doc keyword behind feature flag 2018-06-04 09:52:31 +02:00
Dylan DPC
72f2f1935d
Merge branch 'master' into stabilise/termination-test 2018-06-04 10:58:56 +05:30
Jorge Aparicio
e44ad61a2d implement #[panic_implementation] 2018-06-03 13:46:19 +02:00
dylan_DPC
bc7416213c fixed feature gate to right place 2018-06-02 17:58:06 +05:30
dylan_DPC
b78457f0fb Stabilize unit tests with non-() return type 2018-06-02 17:27:37 +05:30
Yaron Tausky
3303e6847b Suggest not mutably borrowing a mutable reference
This commit is concerned with the case where the user tries to mutably
borrow a mutable reference, thereby triggering an error. Instead of the
existing suggestion to make the binding mutable, the compiler will now
suggest to avoid borrowing altogether.
2018-06-01 23:17:10 +02:00
kennytm
c9cb806689
Deny #[cfg] and #[cfg_attr] on generic parameters. 2018-06-02 05:11:33 +08:00
Evgenii Pashkin
bd6c81aebb Fix processing mod with multi-level path on Windows 2018-06-01 21:09:42 +03:00
Crazycolorz5
c1df62a760 Add closing bracket expectation to sequences, modified appropriate test cases. 2018-06-01 10:05:46 -04:00
Guillaume Gomez
7552c2ea64
Rollup merge of #51240 - nnethercote:parse-2, r=nikomatsakis
Two minor parsing tweaks
2018-05-31 22:17:16 +02:00
Nicholas Nethercote
5adba8e9d9 Avoid an unnecessary match when lexing "<-". 2018-05-31 16:05:39 +10:00
Nicholas Nethercote
3af6291eff Tweak identifer lexing.
By calling `bump()` after getting the first char, to avoid a redundant
`ident_continue()` test on it.
2018-05-31 16:04:33 +10:00
bors
e38554cd80 Auto merge of #51145 - petrochenkov:npbot, r=alexcrichton
resolve: Make sure indeterminate and inconsistent macro resolutions always generate errors

Addresses the issue described in https://github.com/rust-lang/rust/pull/50911#issuecomment-392560525

I haven't come up with a minimized reproduction yet, but confirmed that `npbot` now generates the correct error with `![feature(use_extern_macros)]`.
2018-05-31 03:18:00 +00:00
Vadim Petrochenkov
345e7c3597 resolve: Make sure indeterminate and inconsistent macro resolutions always generate errors 2018-05-30 22:21:50 +03:00
Eduard-Mihai Burtescu
5c76b64546 rustc: don't visit lifetime parameters through visit_lifetime. 2018-05-30 20:29:38 +03:00
Eduard-Mihai Burtescu
a1433f2f88 syntax: remove overloading of fold_lifetime{,_def}{,s}. 2018-05-30 20:29:38 +03:00
bors
16cd84ee22 Auto merge of #50724 - zackmdavis:applicability_rush, r=Manishearth
add suggestion applicabilities to librustc and libsyntax

A down payment on #50723. Interested in feedback on whether my `MaybeIncorrect` vs. `MachineApplicable` judgement calls are well-calibrated (and that we have a consensus on what this means).

r? @Manishearth
cc @killercup @estebank
2018-05-28 10:11:26 +00:00
bors
a52b01bc67 Auto merge of #51101 - 11Takanori:fix-typo, r=frewsxcv
Fix typo in macro_parser.rs

innacurate -> inaccurate
2018-05-27 11:43:26 +00:00
kennytm
509f414b4f
Ensure every unstable feature has a tracking issue. 2018-05-27 14:22:35 +08:00