about summary refs log tree commit diff
path: root/src/libsyntax/ext/base.rs
AgeCommit message (Collapse)AuthorLines
2015-11-22Look up macro names as well when suggesting replacements for function ↵Manish Goregaokar-3/+9
resolve errors fixes #5780
2015-11-20Rename #[deprecated] to #[rustc_deprecated]Vadim Petrochenkov-1/+1
2015-11-13Auto merge of #29761 - eefriedman:rename-nopanic, r=sanxiynbors-2/+2
Just `sed s/_nopanic//g`. Hopefully makes libsyntax a bit more readable.
2015-11-11libsyntax: Add more quasiquoting macrosKyle Mayes-0/+12
2015-11-10Rename _nopanic methods to remove the suffix.Eli Friedman-2/+2
Just `sed s/_nopanic//g`. Hopefully makes libsyntax a bit more readable.
2015-11-10Use lifetime elisionSeo Sanghyeon-2/+2
2015-11-03Auto merge of #29285 - eefriedman:libsyntax-panic, r=nrcbors-2/+2
A set of commits which pushes some panics out of core parser methods, and into users of those parser methods.
2015-10-31Remove PatWildMultiVadim Petrochenkov-1/+1
2015-10-27Don't use panicking helpers in Parser.Eli Friedman-2/+2
2015-10-16Auto merge of #29014 - petrochenkov:stability, r=brsonbors-1/+1
Stricter checking of stability attributes + enforcement of their invariants at compile time (+ removed dead file librustc_front/attr.rs) I intended to enforce use of `reason` for unstable items as well (it normally presents for new items), but it turned out too intrusive, many older unstable items don't have `reason`s. r? @aturon I'm studying how stability works and do some refactoring along the way, so it's probably not the last PR.
2015-10-13Refactor attr::StabilityVadim Petrochenkov-1/+1
Stricter checking + enforcement of invariants at compile time
2015-10-12Remove the push_unsafe! and pop_unsafe! macros.Nick Cameron-6/+0
This is a [breaking change].
2015-10-09Auto merge of #28857 - nrc:lowering, r=nikomatsakisbors-5/+2
r? @nikomatsakis
2015-10-09Some cleanup of no longer used AST thingsNick Cameron-5/+2
2015-10-08typos: fix a grabbag of typos all over the placeCristi Cobzarenco-1/+1
2015-09-24Cleanup interfaces of Name, SyntaxContext and IdentVadim Petrochenkov-3/+3
Make sure Name, SyntaxContext and Ident are passed by value Make sure Idents don't serve as keys (or parts of keys) in maps, Ident comparison is not well defined
2015-09-01Remove the Modifier and Decorator kinds of syntax extensions.Nick Cameron-68/+0
This is a [breaking-change] for syntax extension authors. The fix is to use MultiModifier or MultiDecorator, which have the same functionality but are more flexible. Users of syntax extensions are unaffected.
2015-08-27Enumify CompilerExpansion in ExpnInfoManish Goregaokar-4/+5
2015-08-17feature gate `cfg(target_feature)`.Huon Wilson-1/+5
This is theoretically a breaking change, but GitHub search turns up no uses of it, and most non-built-in cfg's are passed via cargo features, which look like `feature = "..."`, and hence can't overlap.
2015-08-06Auto merge of #27296 - jroesch:type-macros, r=huonwbors-0/+20
This pull request implements the functionality for [RFC 873](https://github.com/rust-lang/rfcs/blob/master/text/0873-type-macros.md). This is currently just an update of @freebroccolo's branch from January, the corresponding commits are linked in each commit message. @nikomatsakis and I had talked about updating the macro language to support a lifetime fragment specifier, and it is possible to do that work on this branch as well. If so we can (collectively) talk about it next week during the pre-RustCamp work week.
2015-08-04Update and add test caseJared Roesch-1/+6
Test case from here: https://github.com/freebroccolo/rust/commit/9e93fef3c0e61836a8b56f727eb7a2e94bb4ca09
2015-08-04Extend macro machinery to expand macros in typesJared Roesch-0/+15
Reapplied the changes from https://github.com/freebroccolo/rust/commit/7aafe24139abc2d1f302bbb166bcaa006f12cf4d to a clean branch of master
2015-08-03syntax: Implement #![no_core]Alex Crichton-4/+9
This commit is an implementation of [RFC 1184][rfc] which tweaks the behavior of the `#![no_std]` attribute and adds a new `#![no_core]` attribute. The `#![no_std]` attribute now injects `extern crate core` at the top of the crate as well as the libcore prelude into all modules (in the same manner as the standard library's prelude). The `#![no_core]` attribute disables both std and core injection. [rfc]: https://github.com/rust-lang/rfcs/pull/1184
2015-07-22Hack for "unsafety hygiene" -- `push_unsafe!` and `pop_unsafe!`.Felix S. Klock II-0/+6
Even after expansion, the generated expressions still track depth of such pushes (i.e. how often you have "pushed" without a corresponding "pop"), and we add a rule that in a context with a positive `push_unsafe!` depth, it is effectively an `unsafe` block context. (This way, we can inject code that uses `unsafe` features, but still contains within it a sub-expression that should inherit the outer safety checking setting, outside of the injected code.) This is a total hack; it not only needs a feature-gate, but probably should be feature-gated forever (if possible). ignore-pretty in test/run-pass/pushpop-unsafe-okay.rs
2015-06-16Remove superfluous variableSimonas Kazlauskas-2/+0
2015-06-16Fix file!(), line!() and column!() macrosSimonas Kazlauskas-16/+25
These used to return wrong results in case they were expanded inside compiler’s iternal syntax sugar (closures, if-let) expansions Fixes #26322
2015-05-22Let MultiItemDecorator take `&Annotatable` (fixes #25683)Manish Goregaokar-3/+3
2015-05-14syntax: replace sess.span_diagnostic.cm with sess.codemap().Eduard Burtescu-1/+1
2015-04-30WIP refactor expansion of decorators and move derive to MultiDecoratorNick Cameron-4/+16
2015-04-25Rebasing and making MulitDecorators workNick Cameron-15/+3
2015-04-25Merge branch 'syntax' of https://github.com/aochagavia/rust into mulit-decorNick Cameron-2/+56
Conflicts: src/librustc/plugin/registry.rs src/libsyntax/ext/base.rs src/libsyntax/ext/cfg_attr.rs src/libsyntax/ext/deriving/mod.rs src/libsyntax/ext/expand.rs src/libsyntax/print/pprust.rs src/test/auxiliary/macro_crate_test.rs
2015-04-21syntax: remove #![feature(box_syntax, box_patterns)]Erick Tryzelaar-4/+4
2015-04-17Rollup merge of #24430 - laumann:trace-macros-flag, r=pnkfelixManish Goregaokar-4/+2
This is the second attempt at turning the trace_macros macro into a compiler flag. See #22619
2015-04-14Negative case of `len()` -> `is_empty()`Tamir Duberstein-1/+1
`s/([^\(\s]+\.)len\(\) [(?:!=)>] 0/!$1is_empty()/g`
2015-04-14Add "trace-macros" as a compiler flagThomas Jespersen-4/+2
Fixes #22619
2015-04-11Remove the vestigial ExtCtxt::print_backtrace function.Ryan Prichard-10/+0
It was added in 2011-08-05 and reduced to a no-op ten days later.
2015-04-07Improves handling of statement macros.Christopher Chambers-14/+16
Statement macros are now treated somewhat like item macros, in that a statement macro can now expand into a series of statements, rather than just a single statement. This allows statement macros to be nested inside other kinds of macros and expand properly, where previously the expansion would only work when no nesting was present. See: src/test/run-pass/macro-stmt_macro_in_expr_macro.rs src/test/run-pass/macro-nested_stmt_macro.rs This changes the interface of the MacResult trait. make_stmt has become make_stmts and now returns a vector, rather than a single item. Plugin writers who were implementing MacResult will have breakage, as well as anyone using MacEager::stmt. See: src/libsyntax/ext/base.rs This also causes a minor difference in behavior to the diagnostics produced by certain malformed macros. See: src/test/compile-fail/macro-incomplete-parse.rs
2015-04-05Work towards a non-panicing parser (libsyntax)Phil Dawes-4/+4
- Functions in parser.rs return PResult<> rather than panicing - Other functions in libsyntax call panic! explicitly for now if they rely on panicing behaviour. - 'panictry!' macro added as scaffolding while converting panicing functions. (This does the same as 'unwrap()' but is easier to grep for and turn into try!()) - Leaves panicing wrappers for the following functions so that the quote_* macros behave the same: - parse_expr, parse_item, parse_pat, parse_arm, parse_ty, parse_stmt
2015-04-01Fallout in libsyntaxNiko Matsakis-1/+1
2015-03-25Add trivial cast lints.Nick Cameron-3/+3
This permits all coercions to be performed in casts, but adds lints to warn in those cases. Part of this patch moves cast checking to a later stage of type checking. We acquire obligations to check casts as part of type checking where we previously checked them. Once we have type checked a function or module, then we check any cast obligations which have been acquired. That means we have more type information available to check casts (this was crucial to making coercions work properly in place of some casts), but it means that casts cannot feed input into type inference. [breaking change] * Adds two new lints for trivial casts and trivial numeric casts, these are warn by default, but can cause errors if you build with warnings as errors. Previously, trivial numeric casts and casts to trait objects were allowed. * The unused casts lint has gone. * Interactions between casting and type inference have changed in subtle ways. Two ways this might manifest are: - You may need to 'direct' casts more with extra type information, for example, in some cases where `foo as _ as T` succeeded, you may now need to specify the type for `_` - Casts do not influence inference of integer types. E.g., the following used to type check: ``` let x = 42; let y = &x as *const u32; ``` Because the cast would inform inference that `x` must have type `u32`. This no longer applies and the compiler will fallback to `i32` for `x` and thus there will be a type error in the cast. The solution is to add more type information: ``` let x: u32 = 42; let y = &x as *const u32; ```
2015-03-11syntax: move MethMac to MacImplItem and combine {Provided,Required}Method ↵Eduard Burtescu-6/+6
into MethodTraitItem.
2015-03-11syntax: gather common fields of impl & trait items into their respective types.Eduard Burtescu-34/+16
2015-03-11syntax: move indirection around {Trait,Impl}Item, from within.Eduard Burtescu-30/+25
2015-03-06Make #[derive(Anything)] into sugar for #[derive_Anything]Keegan McAllister-4/+2
This is a hack, but I don't think we can do much better as long as `derive` is running at the syntax expansion phase. If the custom_derive feature gate is enabled, this works with user-defined traits and syntax extensions. Without the gate, you can't use e.g. #[derive_Clone] directly, so this does not change the stable language. This commit also cleans up the deriving code somewhat, and forbids some previously-meaningless attribute syntax. For this reason it's technically a [breaking-change]
2015-03-06Auto merge of #22899 - huonw:macro-stability, r=alexcrichtonbors-5/+8
Unstable items used in a macro expansion will now always trigger stability warnings, *unless* the unstable items are directly inside a macro marked with `#[allow_internal_unstable]`. IOW, the compiler warns unless the span of the unstable item is a subspan of the definition of a macro marked with that attribute. E.g. #[allow_internal_unstable] macro_rules! foo { ($e: expr) => {{ $e; unstable(); // no warning only_called_by_foo!(); }} } macro_rules! only_called_by_foo { () => { unstable() } // warning } foo!(unstable()) // warning The unstable inside `foo` is fine, due to the attribute. But the `unstable` inside `only_called_by_foo` is not, since that macro doesn't have the attribute, and the `unstable` passed into `foo` is also not fine since it isn't contained in the macro itself (that is, even though it is only used directly in the macro). In the process this makes the stability tracking much more precise, e.g. previously `println!("{}", unstable())` got no warning, but now it does. As such, this is a bug fix that may cause [breaking-change]s. The attribute is definitely feature gated, since it explicitly allows side-stepping the feature gating system. --- This updates `thread_local!` macro to use the attribute, since it uses unstable features internally (initialising a struct with unstable fields).
2015-03-06Add #[allow_internal_unstable] to track stability for macros better.Huon Wilson-5/+8
Unstable items used in a macro expansion will now always trigger stability warnings, *unless* the unstable items are directly inside a macro marked with `#[allow_internal_unstable]`. IOW, the compiler warns unless the span of the unstable item is a subspan of the definition of a macro marked with that attribute. E.g. #[allow_internal_unstable] macro_rules! foo { ($e: expr) => {{ $e; unstable(); // no warning only_called_by_foo!(); }} } macro_rules! only_called_by_foo { () => { unstable() } // warning } foo!(unstable()) // warning The unstable inside `foo` is fine, due to the attribute. But the `unstable` inside `only_called_by_foo` is not, since that macro doesn't have the attribute, and the `unstable` passed into `foo` is also not fine since it isn't contained in the macro itself (that is, even though it is only used directly in the macro). In the process this makes the stability tracking much more precise, e.g. previously `println!("{}", unstable())` got no warning, but now it does. As such, this is a bug fix that may cause [breaking-change]s. The attribute is definitely feature gated, since it explicitly allows side-stepping the feature gating system.
2015-03-05Rollup merge of #22764 - ivanradanov:fileline_help, r=huonwManish Goregaokar-0/+4
When warnings and errors occur, the associated help message should not print the same code snippet. https://github.com/rust-lang/rust/issues/21938
2015-03-05Auto merge of #22061 - pczarn:quote_matcher_and_attr, r=kmcallisterbors-1/+7
Fixes #19674 Fixes #17396 (already closed, yeah) cc @kmcallister , @cmr
2015-03-04Add quasiquote for matchers and attributesPiotr Czarnecki-1/+7
2015-03-03Switched to Box::new in many places.Felix S. Klock II-3/+3
Many of the modifications putting in `Box::new` calls also include a pointer to Issue 22405, which tracks going back to `box <expr>` if possible in the future. (Still tried to use `Box<_>` where it sufficed; thus some tests still have `box_syntax` enabled, as they use a mix of `box` and `Box::new`.) Precursor for overloaded-`box` and placement-`in`; see Issue 22181.