Commit Graph

693 Commits

Author SHA1 Message Date
bors
38a959a543 Auto merge of #36843 - petrochenkov:dotstab, r=nikomatsakis
Stabilize `..` in tuple (struct) patterns

I'd like to nominate `..` in tuple and tuple struct patterns for stabilization.
This feature is a relatively small extension to existing stable functionality and doesn't have known blockers.
The feature first appeared in Rust 1.10 6 months ago.
An example of use: https://github.com/rust-lang/rust/pull/36203

Closes https://github.com/rust-lang/rust/issues/33627
r? @nikomatsakis
2016-11-08 02:06:45 -08:00
Nicholas Nethercote
00e48affde Replace FnvHasher use with FxHasher.
This speeds up compilation by 3--6% across most of rustc-benchmarks.
2016-11-08 15:14:59 +11:00
Vadim Petrochenkov
74bb594563 Stabilize .. in tuple (struct) patterns 2016-11-03 01:38:15 +03:00
Jeffrey Seyfried
076c5d445b Fix shadowing checking. 2016-11-02 07:42:37 +00:00
Jeffrey Seyfried
6c4b551403 Cleanup Resolver::disallowed_shadowing. 2016-10-31 06:56:06 +00:00
Guillaume Gomez
f12e66e642 Rollup merge of #37430 - robinst:missing-crate-message-add-semicolon, r=eddyb
Add semicolon to "Maybe a missing `extern crate foo`" message

I had it a couple of times that I was missing the "extern crate" line
after I introduced a new dependency. So I copied the text from the
message and inserted it into the beginning of my code, only to find the
compiler complaining that I was missing the semicolon. (I forgot to add
it after the text that I had pasted.)

There's a similar message which does include the semicolon, namely
"help: you can import it into scope: `use foo::Bar;`". I think the two
messages should be consistent, so this change adds it for "extern
crate".
2016-10-28 17:05:47 +02:00
Vadim Petrochenkov
a9f91b1b0e Preparations and cleanup
Diagnostics for struct path resolution errors in resolve and typeck are unified.
Self type is treated as a type alias in few places (not reachable yet).
Unsafe cell is seen in constants even through type aliases.
All checks for struct paths in typeck work on type level.
2016-10-27 22:14:41 +03:00
Robin Stocker
de5172ce5f Add semicolon to "Maybe a missing extern crate foo" message
I had it a couple of times that I was missing the "extern crate" line
after I introduced a new dependency. So I copied the text from the
message and inserted it into the beginning of my code, only to find the
compiler complaining that I was missing the semicolon. (I forgot to add
it after the text that I had pasted.)

There's a similar message which does include the semicolon, namely
"help: you can import it into scope: `use foo::Bar;`". I think the two
messages should be consistent, so this change adds it for "extern
crate".
2016-10-27 15:24:08 +11:00
Jeffrey Seyfried
04ca378b89 Support use $crate; with a future compatibility warning. 2016-10-25 20:26:00 +00:00
Jeffrey Seyfried
199ed20aa6 Fix $crate-related regressions. 2016-10-25 20:25:59 +00:00
Jeffrey Seyfried
dcdab2df67 Fix label scopes. 2016-10-22 23:37:54 +00:00
Jeffrey Seyfried
8b0c292a72 Improve $crate. 2016-10-19 10:03:06 +00:00
Jeffrey Seyfried
7b81106a85 Use Idents instead of Names in ImportDirective's paths. 2016-10-19 09:58:12 +00:00
Jeffrey Seyfried
6a6ef91ba7 nit: Import Ident in resolve. 2016-10-19 09:58:08 +00:00
Eduard-Mihai Burtescu
a6788d0ba8 Rollup merge of #37198 - jseyfried:future_proof_macros_11, r=nrc
macros 1.1: future proofing and cleanup

This PR
 - uses the macro namespace for custom derives (instead of a dedicated custom derive namespace),
 - relaxes the shadowing rules for `#[macro_use]`-imported custom derives to match the shadowing rules for ordinary `#[macro_use]`-imported macros, and
 - treats custom derive `extern crate`s like empty modules so that we can eventually allow, for example, `extern crate serde_derive; use serde_derive::Serialize;` backwards compatibly.

r? @alexcrichton
2016-10-19 08:00:00 +03:00
Jeffrey Seyfried
33e3da831c Use the macro namespace for custom derives. 2016-10-15 22:55:19 +00:00
Jonathan Turner
cd0c70f430 Rollup merge of #36307 - faebser:E0408_new_error_format, r=GuillaumeGomez
Changed error message E0408 to new format

Followed your text and was able to change the ouput to the new format.
I did not encounter any broken test therefore this is a really small commit.

Thanks for letting me hack on the compiler :)

r? @jonathandturner
2016-10-14 12:07:07 -07:00
Fabian Frei
595b754a4b Changed error message E0408 to new format
r? @jonathandturner
2016-10-13 00:16:52 +02:00
Alex Crichton
20991829e2 Rollup merge of #37084 - jseyfried:cleanup_expanded_macro_use_scopes, r=nrc
macros: clean up scopes of expanded `#[macro_use]` imports

This PR changes the scope of macro-expanded `#[macro_use]` imports to match that of unexpanded `#[macro_use]` imports. For example, this would be allowed:
```rust
example!();
macro_rules! m { () => { #[macro_use(example)] extern crate example_crate; } }
m!();
```

This PR also enforces the full shadowing restrictions from RFC 1560 on `#[macro_use]` imports (currently, we only enforce the weakened restrictions from #36767).

This is a [breaking-change], but I believe it is highly unlikely to cause breakage in practice.
r? @nrc
2016-10-12 14:07:56 -07:00
Jeffrey Seyfried
111caef9a3 Clean up the scopes of expanded #[macro_use] imports. 2016-10-11 05:14:08 +00:00
Jeffrey Seyfried
6808b0a2b7 Check for shadowing errors after all invocations have been expanded. 2016-10-11 03:28:54 +00:00
Jeffrey Seyfried
fbc96e18ad Persistent macro scopes. 2016-10-08 03:41:55 +00:00
Jeffrey Seyfried
a23bdd2769 Rename resolve::macros::{ExpansionData -> InvocationData}. 2016-10-07 21:54:37 +00:00
Jeffrey Seyfried
2cf964967c Immutable ExpansionData. 2016-10-07 21:54:05 +00:00
Vadim Petrochenkov
b3cb8f68cc Turn compatibility lint match_of_unit_variant_via_paren_dotdot into a hard error 2016-10-05 12:22:26 +03:00
Vadim Petrochenkov
bd291ce21a Turn some impossible definitions into ICEs 2016-10-04 22:25:25 +03:00
Vadim Petrochenkov
c95b280d72 Move pattern resolution checks from typeck to resolve
Make error messages more precise
2016-10-04 22:20:38 +03:00
Vadim Petrochenkov
e8ea38e42a Further cleanup in resolve
`try_define` is not used in build_reduced_graph anymore
Collection of field names for error reporting is optimized
Some comments added
2016-10-04 22:20:37 +03:00
Vadim Petrochenkov
da7b1c984c Separate Def::StructCtor/Def::VariantCtor from Def::Struct/Def::Variant 2016-10-04 22:20:37 +03:00
bors
f3745653e1 Auto merge of #36767 - jseyfried:enforce_rfc_1560_shadowing, r=nrc
Enforce the shadowing restrictions from RFC 1560 for today's macros

This PR enforces a weakened version of the shadowing restrictions from RFC 1560. More specifically,
 - If a macro expansion contains a `macro_rules!` macro definition that is used outside of the expansion, the defined macro may not shadow an existing macro.
 - If a macro expansion contains a `#[macro_use] extern crate` macro import that is used outside of the expansion, the imported macro may not shadow an existing macro.

This is a [breaking-change]. For example,
```rust
macro_rules! m { () => {} }
macro_rules! n { () => {
    macro_rules! m { () => {} } //< This shadows an existing macro.
    m!(); //< This is inside the expansion that generated `m`'s definition, so it is OK.
} }
n!();
m!(); //< This use of `m` is outside the expansion, so it causes the shadowing to be an error.
```

r? @nrc
2016-10-03 01:30:32 -07:00
Jeffrey Seyfried
ed1e00268b Enforce the weakened shadowing restriction. 2016-10-02 08:25:27 +00:00
Jeffrey Seyfried
797eb57aa8 Refactor field expansion_data of Resolver to use a Mark instead of a u32. 2016-10-02 04:25:31 +00:00
Jeffrey Seyfried
5c2d76d23e Add struct macros::NameBinding. 2016-10-02 04:25:27 +00:00
Jeffrey Seyfried
91e1f24f12 Fix module_to_string. 2016-10-01 07:41:53 +00:00
bors
a059cb2f33 Auto merge of #36601 - jseyfried:build_reduced_graph_in_expansion, r=nrc
Assign def ids and build the module graph during expansion

r? @nrc
2016-09-27 14:11:07 -07:00
Jeffrey Seyfried
634ecf038d Merge ModuleData and ModuleS. 2016-09-27 06:43:43 +00:00
Jeffrey Seyfried
b3a81ee844 Build the reduced graph during expansion. 2016-09-27 06:42:10 +00:00
Jeffrey Seyfried
ebaaafcd5d Peform def id assignment during expansion. 2016-09-27 06:42:09 +00:00
Jonathan Turner
2fa91b23c5 Update E0425, E0446, E0449 2016-09-26 16:05:46 -07:00
Jeffrey Seyfried
b4906a93a0 Load macros from #[macro_use] extern crates in resolve. 2016-09-24 20:22:25 +00:00
Jeffrey Seyfried
7b5c59ea65 Load extern crates in resolve. 2016-09-23 06:35:33 +00:00
Jeffrey Seyfried
1ee64e44a9 Use Resolver::visit_expansion only with monotonic expansions. 2016-09-22 21:14:03 +00:00
Jeffrey Seyfried
272cf4e61d Refactor no_implicit_prelude: Cell<bool> -> no_implicit_prelude: bool. 2016-09-22 07:45:11 +00:00
Jeffrey Seyfried
9a0e88a339 Refactor away ParentLink. 2016-09-22 07:13:54 +00:00
Eduard Burtescu
ef4352fba6 rustc_metadata: group information into less tags. 2016-09-20 20:08:04 +03:00
Eduard Burtescu
8734aaa33e rustc_metadata: move more RBML tags to auto-serialization. 2016-09-20 20:08:02 +03:00
Eduard Burtescu
903ec52ba9 rustc: replace uses of NodeId in Def, other than closures and labels. 2016-09-20 20:08:00 +03:00
Eduard Burtescu
fc363cb482 rustc_metadata: go only through rustc_serialize in astencode. 2016-09-20 20:07:54 +03:00
Eduard Burtescu
7b073343db rustc_metadata: remove astencode tests. 2016-09-20 19:21:33 +03:00
Manish Goregaokar
bab9238a1e Rollup merge of #36438 - jseyfried:node_ids_in_expansion, r=nrc
Assign node ids during macro expansion

After this PR,
 - The `ExtCtxt` can access `resolve`'s `Resolver` through the trait object `ext::base::Resolver`.
  - The `Resolver` trait object can load macros and replaces today's `MacroLoader` trait object.
  - The macro expander uses the `Resolver` trait object to resolve macro invocations.
 - The macro expander assigns node ids and builds the `Resolver`'s `macros_at_scope` map.
   - This is groundwork for merging import resolution and expansion.
 - Performance of expansion together with node id assignment improves by ~5%.

**EDIT:** Since Github is reordering the commits, here is `git log`:
 - b54e1e3997: Differentiate between monotonic and non-monotonic expansion and only assign node ids during monotonic expansion.
 - 78c0039878: Expand generated test harnesses and macro registries.
 - f3c2dca353: Remove scope placeholders from the crate root.
 - c86c8d41a2: Perform node id assignment and `macros_at_scope` construction during the `InvocationCollector` and `PlaceholderExpander` folds.
 - 72a636975f: Move macro resolution into `librustc_resolve`.
 - 20b43b2323: Rewrite the unit tests in `ext/expand.rs` as a `compile-fail` test.
 - a9821e1658: Refactor `ExtCtxt` to use a `Resolver` instead of a `MacroLoader`.
 - 60440b226d: Refactor `noop_fold_stmt_kind` out of `noop_fold_stmt`.
 - 50f94f6c95: Avoid needless reexpansions.

r? @nrc
2016-09-15 18:16:21 +05:30
Jeffrey Seyfried
c86c8d41a2 Perform node id assignment and macros_at_scope construction during
the `InvocationCollector` and `PlaceholderExpander` folds.
2016-09-13 09:40:28 +00:00
Jeffrey Seyfried
72a636975f Move macro resolution into librustc_resolve. 2016-09-13 09:40:26 +00:00
Jeffrey Seyfried
a9821e1658 Refactor ExtCtxt to use a Resolver instead of a MacroLoader. 2016-09-13 05:31:16 +00:00
Alex Burka
0a62676c73 fix "X is not a member of trait Y" span labels
The span labels for associated types and consts were hardcoded to `Foo`
rather than substituting the name of the trait.

This also normalizes the wording for associated methods', traits', and
consts' span labels.

Fixes #36428.
2016-09-13 03:13:13 +00:00
Jeffrey Seyfried
ff3a644951 Add struct AmbiguityError. 2016-09-06 03:52:36 +00:00
Jeffrey Seyfried
888a968139 Add field used: Cell<bool> to variant NameBindingKind::Import. 2016-09-06 03:43:46 +00:00
Jeffrey Seyfried
32674b3f1a Avoid false positive unused import warnings. 2016-09-06 03:43:20 +00:00
Vadim Petrochenkov
e05e74ac83 Replace _, _ with .. 2016-09-04 12:30:33 +03:00
Vadim Petrochenkov
6f7e51e49b Replace _, _, _ with .. 2016-09-04 12:27:01 +03:00
Vadim Petrochenkov
641d8e9e4c Some better support for unions through the compiler 2016-09-03 13:39:34 +03:00
Jeffrey Seyfried
90ce504c1c Address comments. 2016-09-02 00:35:16 +00:00
Jeffrey Seyfried
4f5616e3c4 Avoid cascading name resolution errors caused by an ambiguous module. 2016-09-01 22:30:29 +00:00
Jeffrey Seyfried
32a0cfeb48 Avoid reporting multiple ambiguity errors for a single use of a name. 2016-09-01 22:30:28 +00:00
Jeffrey Seyfried
681a14f29b item_like_imports: Allow unused ambiguous glob imports. 2016-09-01 22:30:27 +00:00
Jeffrey Seyfried
245a0c5530 item_like_imports: Make all visible items glob importable. 2016-09-01 22:30:26 +00:00
Jeffrey Seyfried
5ba22c0ed6 Add item_like_imports feature. 2016-09-01 22:29:50 +00:00
Jeffrey Seyfried
513e955a18 Add field dummy_binding to Resolver. 2016-09-01 22:29:30 +00:00
Jeffrey Seyfried
95528d1a98 Refactor away resolver.current_vis and add module.normal_ancestor_id. 2016-09-01 22:29:29 +00:00
Jeffrey Seyfried
1e4c8173e1 Improve diagnostics and remove dead code. 2016-09-01 22:29:28 +00:00
Jeffrey Seyfried
87ae68c1d6 Refactor binding.def() to return a Def instead of an Option<Def>. 2016-09-01 22:29:27 +00:00
Jeffrey Seyfried
5dc1196191 Refactor away binding.is_pseudo_public(). 2016-09-01 22:29:26 +00:00
Jonathan Turner
c75fd78de3 Rollup merge of #35773 - EugeneGonzalez:master, r=jonathandturner
Change E0259 to the new error format

Fixes #35514 as part of #35233.

Sorry about creating a new PR I was having a lot of troubles squashing the commit because I didn't properly branch the new feature.

r? @GuillaumeGomez
2016-08-31 13:53:33 -07:00
Eugene R Gonzalez
d4ca5613a0 Change E0259 to the new error format
Fixed E0259 unit test

Added name of conflict to E0259's note
2016-08-30 21:28:50 -04:00
bors
4473130f4e Auto merge of #36126 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 16 pull requests

- Successful merges: #35418, #35759, #35862, #35863, #35895, #35962, #35977, #35993, #35997, #36054, #36056, #36060, #36086, #36100, #36103, #36125
- Failed merges: #35771, #35810
2016-08-30 06:01:39 -07:00
bors
71ee82a8aa Auto merge of #36066 - jseyfried:rollup, r=Manishearth
Batch up libsyntax breaking changes

Batch of the following syntax-[breaking-change] changes:
 - #35591: Add a field `span: Span` to `ast::Generics`.
 - #35618: Remove variant `Mod` of `ast::PathListItemKind` and refactor the remaining variant `ast::PathListKind::Ident` to a struct `ast::PathListKind_`.
 - #35480: Change uses of `Constness` in the AST to `Spanned<Constness>`.
  - c.f. `MethodSig`, `ItemKind`
 - #35728: Refactor `cx.pat_enum()` into `cx.pat_tuple_struct()` and `cx.pat_path()`.
 - #35850: Generalize the elements of lists in attributes from `MetaItem` to a new type `NestedMetaItem` that can represent a `MetaItem` or a literal.
 - #35917: Remove traits `AttrMetaMethods`, `AttributeMethods`, and `AttrNestedMetaItemMethods`.
  - Besides removing imports of these traits, this won't cause fallout.
 - Add a variant `Union` to `ItemKind` to future proof for `union` (c.f. #36016).
 - Remove inherent methods `attrs` and `fold_attrs` of `Annotatable`.
  - Use methods `attrs` and `map_attrs` of `HasAttrs` instead.

r? @Manishearth
2016-08-30 00:36:19 -07:00
Mohit Agarwal
d6fc2baa11
Update E0260 to new error format
Updates #35515.
Part of #35233.

r? @jonathandturner
2016-08-29 16:20:08 +05:30
Jeffrey Seyfried
4fe94e0be6 Future proof the AST for union. 2016-08-29 05:20:40 +00:00
Jonas Schievink
144e576c87 Use FnvHashMap in more places
* A step towards #34902
* More stable error messages in some places related to crate loading
* Possible slight performance improvements since all `HashMap`s
  replaced had small keys where `FnvHashMap` should be faster
  (although I didn't measure)
2016-08-27 15:20:45 +02:00
Jonathan Turner
0c84ac124a Rollup merge of #35858 - shyaamsundhar:patch-1, r=GuillaumeGomez
E0435, E0437 & E0438 New Error Format

Part of #35801 , #35802 and #35803
r? @GuillaumeGomez

Hi! Please review the changes.
2016-08-22 15:34:21 -07:00
Jonathan Turner
cc51d1c21d Rollup merge of #35841 - kyrias:new-error-E0424, r=GuillaumeGomez
Update E0424 to the new error format

Fixes #35797.
Part of #35233.

r? @GuillaumeGomez
2016-08-22 15:34:20 -07:00
Jonathan Turner
ae83225afc Rollup merge of #35835 - crypto-universe:E0426, r=jonathandturner
New format for E0426

Issue #35799 as a part of issue #35233
r? jonathandturner
2016-08-22 15:34:20 -07:00
Knight
8fdc531446 Updated E0423 to new format 2016-08-22 13:57:37 +08:00
Knight
a4c6307a15 Updated E0432 to new format 2016-08-22 13:57:10 +08:00
bors
1576de0ce6 Auto merge of #35776 - jseyfried:more_groundwork, r=nrc
resolve: More groundwork for `item_like_imports` (RFC 1560)

r? @nrc
2016-08-21 11:03:48 -07:00
Shyam Sundar B
738b91e997 Update lib.rs
Update lib.rs
Update lib.rs
Update E0438.rs
Update E0437.rs
Update E0435.rs
2016-08-21 18:43:58 +05:30
Johannes Löthberg
ff44f088d7 Update E0424 to the new error format
Fixes #35797.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
2016-08-20 22:05:51 +02:00
crypto-universe
5d02b03059 New format for E0426
Issue #35799 as a part of issue #35233
?r jonathandturner
2016-08-19 22:31:31 +02:00
trixnz
3b64cf669c Update E0428 to new format 2016-08-19 19:19:34 +02:00
Jeffrey Seyfried
fbc322975f Refactor out finalize_import() from resolve_import(). 2016-08-18 03:31:10 +00:00
Jeffrey Seyfried
165b0b618c Check privacy in resolve_name_in_module. 2016-08-18 03:22:48 +00:00
Jeffrey Seyfried
7608bbdea8 Refactor resolve_module_path to take an Option<Span> instead of a Span. 2016-08-18 03:22:47 +00:00
Jeffrey Seyfried
05afe15d1f Refactor record_used: bool -> record_used: Option<Span>. 2016-08-18 03:22:47 +00:00
Jeffrey Seyfried
75c3fd89d4 Refactor away the field arenas of ModuleS. 2016-08-18 03:22:47 +00:00
Jeffrey Seyfried
bfc98f59a4 Refactor away module.resolve_name(). 2016-08-18 03:22:47 +00:00
Jeffrey Seyfried
89de52eff0 Add field current_vis to Resolver. 2016-08-18 03:22:43 +00:00
Jeffrey Seyfried
37154ca95d Refactor unresolved_imports -> indeterminate_imports. 2016-08-18 03:13:42 +00:00
Jeffrey Seyfried
c64cd86be8 Add field parent to ImportDirective. 2016-08-18 03:13:41 +00:00
Eduard-Mihai Burtescu
c3601d40ec Rollup merge of #35756 - crypto-universe:E0407, r=GuillaumeGomez
New output for E0407

Issue #35697 as a part of #35233.
r? @GuillaumeGomez
2016-08-18 06:12:23 +03:00
Eduard-Mihai Burtescu
71759ec52c Rollup merge of #35739 - circuitfox:E0403-update-error-format, r=jonathandturner
E0403 update error format

Fixes #35696

Part of #35233

r? @jonathandturner

Also did the bonus for this one.
2016-08-18 06:12:21 +03:00
crypto-universe
2179defa04 New output for E0407
Issue #35697 as a part of #35233.
r? @jonathandturner
2016-08-17 19:59:22 +02:00