Jeffrey Seyfried
2a1d2edb82
Declarative macros 2.0 without hygiene.
2017-05-25 05:51:06 +00:00
est31
25b7f10c78
Address review comments
2017-05-15 07:38:39 +02:00
est31
d14d194f61
Support #[allow] etc logic on a per macro level
...
This commit extends the current unused macro linter
to support directives like #[allow(unused_macros)]
or #[deny(unused_macros)] directly next to the macro
definition, or in one of the modules the macro is
inside. Before, we only supported such directives
at a per crate level, due to the crate's NodeId
being passed to session.add_lint.
We also had to implement handling of the macro's
NodeId in the lint visitor.
2017-05-13 16:02:29 +02:00
est31
df188b8f97
Add lint for unused macros
2017-05-13 16:02:29 +02:00
Oliver Schneider
a54bbf2cb3
Weave the span of an import through the resolve code
2017-05-12 11:21:11 +02:00
Oliver Schneider
e2f781c7ea
Example usage of multiple suggestions
2017-05-10 13:20:27 +02:00
Oliver Schneider
dd87eabd83
Remove need for &format!(...) or &&"" dances in span_label
calls
2017-05-08 12:56:15 +02:00
Alex Burka
e0cd76674d
feature gate :vis matcher
2017-04-15 19:06:58 +00:00
Jeffrey Seyfried
6a9448b523
Fix bug parsing #[derive]
macro invocations.
2017-04-03 23:02:49 +00:00
Jeffrey Seyfried
737511ee11
Ensure that macro resolutions in trait positions get finalized.
2017-03-27 05:22:18 +00:00
Jeffrey Seyfried
d64d3814c4
Rename builtin
=> global
.
2017-03-24 21:06:01 +00:00
Jeffrey Seyfried
64e9af47f4
Allow declarative macros 2.0 and use
macro imports to shadow builtin macros.
2017-03-24 21:05:52 +00:00
Corey Farwell
880f03b28c
Rollup merge of #40509 - jseyfried:duplicate_check_macro_exports, r=nrc
...
Forbid conflicts between macros 1.0 exports and macros 2.0 exports
This PR forbids for conflicts between `#[macro_export]`/`#[macro_reexport]` macro exports and `pub use` macro exports. For example,
```rust
// crate A:
pub use macros::foo;
//^ This is allowed today, will be forbidden by this PR.
// crate B:
extern crate A; // This triggers a confusing error today.
use A::foo; // This could refer to refer to either macro export in crate A.
```
r? @nrc
2017-03-22 19:30:23 -04:00
Jeffrey Seyfried
bd862d29d3
Fix bug in legacy #[derive]
processing logic.
2017-03-21 16:53:34 -04:00
Jeffrey Seyfried
678e882ce2
Check for conflicts between macros 1.0 exports (#[macro_export]
, #[macro_reexport]
)
...
and macros 2.0 exports (`pub use` macro re-exports and `pub macro` (once implemented)
at the crate root.
2017-03-21 16:23:18 -04:00
bors
9c15de4fd5
Auto merge of #40346 - jseyfried:path_and_tokenstream_attr, r=nrc
...
`TokenStream`-based attributes, paths in attribute and derive macro invocations
This PR
- refactors `Attribute` to use `Path` and `TokenStream` instead of `MetaItem`.
- supports macro invocation paths for attribute procedural macros.
- e.g. `#[::foo::attr_macro] struct S;`, `#[cfg_attr(all(), foo::attr_macro)] struct S;`
- supports macro invocation paths for derive procedural macros.
- e.g. `#[derive(foo::Bar, super::Baz)] struct S;`
- supports arbitrary tokens as arguments to attribute procedural macros.
- e.g. `#[foo::attr_macro arbitrary + tokens] struct S;`
- supports using arbitrary tokens in "inert attributes" with derive procedural macros.
- e.g. `#[derive(Foo)] struct S(#[inert arbitrary + tokens] i32);`
where `#[proc_macro_derive(Foo, attributes(inert))]`
r? @nrc
2017-03-19 10:56:08 +00:00
Jeffrey Seyfried
839c2860cc
Liberalize attributes.
2017-03-14 04:39:21 +00:00
Jeffrey Seyfried
68c1cc68b4
Refactor Attribute
to use Path
and TokenStream
instead of MetaItem
.
2017-03-14 04:03:43 +00:00
Corey Farwell
8d1c5700f0
Rollup merge of #40369 - petrochenkov:segspan, r=eddyb
...
Give spans to individual path segments in AST
And use these spans in path resolution diagnostics.
The spans are spans of identifiers in segments, not whole segments. I'm not sure what spans are more useful in general, but identifier spans are a better fit for resolve errors.
HIR still doesn't have spans.
Fixes https://github.com/rust-lang/rust/pull/38927#discussion_r95336667 https://github.com/rust-lang/rust/pull/38890#issuecomment-271731008
r? @nrc @eddyb
2017-03-12 12:48:46 -04:00
Vadim Petrochenkov
ffdcf74866
resolve: Use path segment spans in smart_resolve_path
2017-03-10 08:21:45 -08:00
Vadim Petrochenkov
32575a0487
Give spans to individual path segments in AST
2017-03-10 08:21:45 -08:00
Jeffrey Seyfried
8c98996934
Avoid using Mark
and Invocation
for macro defs.
2017-03-10 08:08:32 -08:00
Jeffrey Seyfried
e839486318
Move resolve_invoc
from syntax
to resolve
.
2017-03-10 08:08:32 -08:00
Jeffrey Seyfried
212b6c2550
Refactor out ast::ItemKind::MacroDef
.
2017-03-10 08:08:32 -08:00
Jeffrey Seyfried
9fe7d3ffe4
Fix const expression macro invocations.
2017-03-05 23:58:19 +00:00
Jeffrey Seyfried
f6eaaf350e
Integrate TokenStream
.
2017-03-03 02:15:37 +00:00
Eduard-Mihai Burtescu
a6a5c32e0e
Rollup merge of #39953 - keeperofdakeys:macro-error, r=jseyfried
...
Provide suggestions for unknown macros imported with `use`
cc https://github.com/rust-lang/rust/issues/30197
r? @jseyfried
2017-02-25 14:13:23 +02:00
Josh Driver
da6dc5331f
Add macro suggestions for macros imported with use
...
This commit searchs modules for macro suggestions.
It also removes imported macro_rules from macro_names,
and adds more corner case checks for which macros
should be suggested in specific contexts.
2017-02-23 20:28:35 +10:30
Josh Driver
4ecdc68153
Move MacroKind into Def::Macro
2017-02-23 20:12:33 +10:30
Austin Bonander
dac25e2b27
Don't assume plugin-whitelisted attributes are proc macro attributes
...
closes #40001
2017-02-22 15:43:03 -08:00
Vadim Petrochenkov
bf95c29c98
Privatize fields of PathResolution
...
Ensure Def::Err has depth == 0
2017-02-19 00:34:08 +03:00
Josh Driver
2d91e7aab8
Refactor macro resolution errors + add derive macro suggestions
2017-02-16 22:03:15 +10:30
Jeffrey Seyfried
2cc61eebb7
Allow using inert attributes from proc_macro_derive
s with #![feature(proc_macro)]
.
2017-02-12 07:20:04 +00:00
Jeffrey Seyfried
4b413bc393
Move legacy custom derives collection into resolver.find_attr_invoc()
.
2017-02-12 03:22:52 +00:00
Josh Driver
fbdd038866
Move derive macro expansion into the MacroExpander
...
This removes the expand_derives function, and sprinkles
the functionality throughout the Invocation Collector,
Expander and Resolver.
2017-02-05 09:31:02 +10:30
Jeffrey Seyfried
356fa2c5db
Warn on unused #[macro_use]
imports.
2017-01-22 01:31:00 +00:00
Austin Bonander
375cbd20cf
Implement #[proc_macro_attribute]
...
* Add support for `#[proc_macro]`
* Reactivate `proc_macro` feature and gate `#[proc_macro_attribute]` under it
* Have `#![feature(proc_macro)]` imply `#![feature(use_extern_macros)]`,
error on legacy import of proc macros via `#[macro_use]`
2017-01-16 22:41:22 -08:00
Vadim Petrochenkov
2092682191
resolve: Do not use "resolve"/"resolution" in error messages
2017-01-12 10:08:27 +03:00
Josh Driver
e9b5839918
Style fixes
2016-12-31 17:55:59 +10:30
Josh Driver
22f788c644
Stop macro calls in structs for proc_macro_derive from panicing
2016-12-31 17:19:23 +10:30
Jeffrey Seyfried
41f1e189ee
Use DefId
s instead of NodeId
s for pub(restricted)
visibilities.
2016-12-24 00:23:03 +00:00
bors
467a7f049b
Auto merge of #38533 - jseyfried:legacy_custom_derive_deprecation, r=nrc
...
Allow legacy custom derive authors to disable warnings in downstream crates
This PR allows legacy custom derive authors to use a pre-deprecated method `registry.register_custom_derive()` instead of `registry.register_syntax_extension()` to avoid downstream deprecation warnings.
r? @nrc
2016-12-23 18:43:12 +00:00
Jeffrey Seyfried
c12fc66a9d
Allow legacy custom derive authors to disable warnings in downstream crates.
2016-12-23 05:49:34 +00:00
Jeffrey Seyfried
f10f50b426
Refactor how global paths are represented (for both ast and hir).
2016-12-22 06:14:35 +00:00
Alex Crichton
0cf7d5dcae
Merge branch 'rfc_1560_warning_cycle' of https://github.com/jseyfried/rust into rollup
...
Conflicts:
src/librustc_resolve/lib.rs
src/librustc_resolve/resolve_imports.rs
2016-12-20 13:00:16 -08:00
Jeffrey Seyfried
8d9ba291f5
Minor bugfix for macro invocation path resolution.
2016-12-19 20:57:02 +00:00
Jeffrey Seyfried
8e61ff25d8
Optimize ast::PathSegment
.
2016-12-19 20:57:00 +00:00
Jeffrey Seyfried
421c5d11c1
Remove scope placeholders, remove method add_macro
of ext::base::Resolver
.
2016-12-18 23:26:30 +00:00
Jeffrey Seyfried
e80d1a8faf
Remove MacroDef
's fields imported_from
and allow_internal_unstable
,
...
remove `export` argument of `resolver.add_macro()`.
2016-12-18 23:26:29 +00:00
Jeffrey Seyfried
59de7f8f04
Add ident.unhygienize()
and use Ident
more instead of Name
in resolve
.
2016-12-18 23:26:22 +00:00