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
Jeffrey Seyfried
cfabce2230
Demote most backwards incompatible ambiguity errors from RFC 1560 to warnings.
2016-12-15 06:02:49 +00:00
Jeffrey Seyfried
ed9a09d40c
Support paths in macro invocations.
2016-11-30 22:54:40 +00:00
Jeffrey Seyfried
29791ada1d
Minor cleanup.
2016-11-30 21:19:46 +00:00
Jeffrey Seyfried
e9e178a581
Refactor away ResolveResult
.
2016-11-29 00:18:39 +00:00
Jeffrey Seyfried
cbe478766c
macros: improve performance of legacy name resolution.
2016-11-23 01:51:37 +00:00
bors
ebec55406b
Auto merge of #37824 - jseyfried:symbols, r=eddyb
...
Clean up `ast::Attribute`, `ast::CrateConfig`, and string interning
This PR
- removes `ast::Attribute_` (changing `Attribute` from `Spanned<Attribute_>` to a struct),
- moves a `MetaItem`'s name from the `MetaItemKind` variants to a field of `MetaItem`,
- avoids needlessly wrapping `ast::MetaItem` with `P`,
- moves string interning into `syntax::symbol` (`ast::Name` is a reexport of `symbol::Symbol` for now),
- replaces `InternedString` with `Symbol` in the AST, HIR, and various other places, and
- refactors `ast::CrateConfig` from a `Vec` to a `HashSet`.
r? @eddyb
2016-11-21 08:08:47 -06:00
Jeffrey Seyfried
bf41c85c24
Cleanup.
2016-11-21 09:21:48 +00:00
Jeffrey Seyfried
36c8f6b0d3
Cleanup InternedString
.
2016-11-21 09:00:56 +00:00
Jeffrey Seyfried
a2626410d7
Refactor MetaItemKind
to use Name
s instead of InternedString
s.
2016-11-20 11:46:06 +00:00
Jeffrey Seyfried
6cb33a089f
Cleanup formatting.
2016-11-17 08:16:32 +00:00
Jeffrey Seyfried
9c88650080
Add feature use_extern_macros
.
2016-11-17 08:08:06 +00:00
Jeffrey Seyfried
1bbf7a43d3
Add field expansion: Mark
to NameBinding
.
2016-11-17 08:07:46 +00:00