about summary refs log tree commit diff
path: root/src/test/ui/proc-macro
AgeCommit message (Collapse)AuthorLines
2019-11-17Rollup merge of #66271 - petrochenkov:abism, r=CentrilYuki Okushi-18/+52
syntax: Keep string literals in ABIs and `asm!` more precisely As a result we don't lose spans when `extern` functions or blocks are passed to proc macros, and also escape all string literals consistently. Continuation of https://github.com/rust-lang/rust/pull/60679, which did a similar thing with all literals besides those in ABIs and `asm!`. TODO: Add tests. Fixes https://github.com/rust-lang/rust/issues/60493 Fixes https://github.com/rust-lang/rust/issues/64561 r? @Centril
2019-11-17Add some more testsVadim Petrochenkov-1/+33
2019-11-16ast: Keep `extern` qualifiers in functions more preciselyVadim Petrochenkov-17/+19
2019-11-16Add some more testsVadim Petrochenkov-13/+78
2019-11-16expand: Stop marking derive helper attributes as knownVadim Petrochenkov-7/+41
Pass them through name resolution instead
2019-11-16resolve: Introduce a new scope for derive helpersVadim Petrochenkov-6/+24
2019-11-12Rollup merge of #66278 - LukasKalbertodt:fix-proc-macro-error, r=CentrilYuki Okushi-6/+6
Fix error message about exported symbols from proc-macro crates Someone forgot to update the error message after `#[proc_macro]` and `#[proc_macro_attribute]` were stabilized.
2019-11-11Fix error message about exported symbols from proc-macro cratesLukas Kalbertodt-6/+6
Someone forgot to update the error message after `#[proc_macro]` and `#[proc_macro_attribute]` were stabilized.
2019-11-10Auto merge of #66070 - petrochenkov:regattr, r=matthewjasperbors-7/+24
Support registering inert attributes and attribute tools using crate-level attributes And remove `#[feature(custom_attribute)]`. (`rustc_plugin::Registry::register_attribute` is not removed yet, I'll do it in a follow up PR.) ```rust #![register_attr(my_attr)] #![register_tool(my_tool)] #[my_attr] // OK #[my_tool::anything] // OK fn main() {} ``` --- Some tools (`rustfmt` and `clippy`) used in tool attributes are hardcoded in the compiler. We need some way to introduce them without hardcoding as well. This PR introduces a way to do it with a crate level attribute. The previous attempt to introduce them through command line (https://github.com/rust-lang/rust/pull/57921) met some resistance. This probably needs to go through an RFC before stabilization. However, I'd prefer to land *this* PR without an RFC to able to remove `#[feature(custom_attribute)]` and `Registry::register_attribute` while also providing a replacement. --- `register_attr` is a direct replacement for `#![feature(custom_attribute)]` (https://github.com/rust-lang/rust/issues/29642), except it doesn't rely on implicit fallback from unresolved attributes to custom attributes (which was always hacky and is the primary reason for the removal of `custom_attribute`) and requires registering the attribute explicitly. It's not clear whether it should go through stabilization or not. It's quite possible that all the uses should migrate to `#![register_tool]` (https://github.com/rust-lang/rust/issues/66079) instead. --- Details: - The naming is `register_attr`/`register_tool` rather than some `register_attributes` (plural, no abbreviation) for consistency with already existing attributes like `cfg_attr`, or `feature`, etc. --- Previous attempt: https://github.com/rust-lang/rust/pull/57921 cc https://github.com/rust-lang/rust/issues/44690 Tracking issues: #66079 (`register_tool`), #66080 (`register_attr`) Closes https://github.com/rust-lang/rust/issues/29642
2019-11-09Remove `#[feature(custom_attribute)]`Vadim Petrochenkov-7/+24
2019-11-09move attr meta grammar to parse::validate_atr + ast_validationMazdak Farrokhzad-12/+12
2019-11-07Rollup merge of #66087 - tmiasko:ui-mode, r=CentrilMazdak Farrokhzad-1/+1
Update some build-pass ui tests to use check-pass where applicable Helps with issue https://github.com/rust-lang/rust/issues/62277.
2019-11-05rewrote error messages for #[rustc_error]Quentin Boyer-2/+2
2019-11-04Use check-pass in ui tests where appropriateTomasz Miąsko-1/+1
2019-11-04expand: Feature gate out-of-line modules in proc macro inputVadim Petrochenkov-0/+132
2019-10-29Rollup merge of #65832 - tlively:emscripten-exception-handling, r=alexcrichtonTyler Mandry-1/+1
Re-enable Emscripten's exception handling support Passes LLVM codegen and Emscripten link-time flags for exception handling if and only if the panic strategy is `unwind`. Sets the default panic strategy for Emscripten targets to `unwind`. Re-enables tests that depend on unwinding support for Emscripten, including `should_panic` tests. r? @alexcrichton
2019-10-29Change E0741 into E0742Guillaume Gomez-2/+2
2019-10-29Update ui testsGuillaume Gomez-2/+3
2019-10-27Point at local similarly named element and tweak references to variantsEsteban Küber-27/+35
Point at the span for the definition of ADTs internal to the current crate. Look at the leading char of the ident to determine whether we're expecting a likely fn or any of a fn, a tuple struct or a tuple variant. Turn fn `add_typo_suggestion` into a `Resolver` method.
2019-10-26Rollup merge of #65773 - estebank:sugg-whitespace, r=CentrilMazdak Farrokhzad-0/+1
Increase spacing for suggestions in diagnostics Make the spacing between the code snippet and verbose structured suggestions consistent with note and help messages. r? @Centril
2019-10-25Re-enable Emscripten's exception handling supportThomas Lively-1/+1
Passes LLVM codegen and Emscripten link-time flags for exception handling if and only if the panic strategy is `unwind`. Sets the default panic strategy for Emscripten targets to `unwind`. Re-enables tests that depend on unwinding support for Emscripten, including `should_panic` tests.
2019-10-24Increase spacing for suggestions in diagnosticsEsteban Küber-0/+1
Make the spacing between the code snippet and verbose structured suggestions consistent with note and help messages.
2019-10-24Deprecated proc_macro doesn't trigger warning on build librarywangxiangqing-0/+2
Change-Id: Ib3a396e7334d209fe6c6ef425bbfc7b2ae471378
2019-10-22Deprecated proc_macro doesn't trigger warning on build librarywangxiangqing-5/+4
Change-Id: Ib3a396e7334d209fe6c6ef425bbfc7b2ae471378
2019-10-22Deprecated proc_macro doesn't trigger warning on build librarywangxiangqing-0/+15
Change-Id: Ib3a396e7334d209fe6c6ef425bbfc7b2ae471378
2019-10-16Upgrade Emscripten targets to use upstream LLVM backendThomas Lively-1/+1
- Compatible with Emscripten 1.38.46-upstream or later upstream. - Refactors the Emscripten target spec to share code with other wasm targets. - Replaces the old incorrect wasm32 C call ABI with the correct one, preserving the old one as wasm32_bindgen_compat for wasm-bindgen compatibility. - Updates the varargs ABI used by Emscripten and deletes the old one. - Removes the obsolete wasm32-experimental-emscripten target. - Uses EMCC_CFLAGS on CI to avoid the timeout problems with #63649.
2019-10-15Test basic hygiene for `macro_rules` produced by transparent macrosVadim Petrochenkov-0/+74
2019-10-15Stabilize proc macros generating `macro_rules` itemsVadim Petrochenkov-105/+0
2019-10-10Auto merge of #65140 - petrochenkov:disapp, r=nikomatsakisbors-0/+37
resolve: Remove an incorrect assert Fixes https://github.com/rust-lang/rust/issues/64803.
2019-10-05Revert "Auto merge of #63649 - tlively:emscripten-upstream-upgrade, ↵Tyler Mandry-1/+1
r=alexcrichton" This reverts commit 7870050796e5904a0fc85ecbe6fa6dde1cfe0c91, reversing changes made to 2e7244807a7878f6eca3eb7d97ae9b413aa49014.
2019-10-05resolve: Remove an incorrect assertVadim Petrochenkov-0/+37
2019-10-04Upgrade Emscripten targets to use upstream LLVM backendThomas Lively-1/+1
- Refactors the Emscripten target spec to share code with other wasm targets. - Replaces the incorrect wasm32 C call ABI with the old asmjs version, which is correct for both wasm32 and JS. - Updates the varargs ABI used by Emscripten and deletes the old one. - Removes the obsolete wasm32-experimental-emscripten target. - Temporarily makes Emscripten targets use panic=abort by default because supporting unwinding will require an LLVM patch.
2019-10-03Rollup merge of #65018 - Aaron1011:fix/backtrace-stderr, r=nikomatsakisTyler Mandry-3/+6
Set RUST_BACKTRACE=0 in tests that include a backtrace in stderr This removes the implicit dependency on the environment variables set when running `./x.py test`
2019-10-03proc_macro: Add `Span::mixed_site` exposing `macro_rules` hygieneVadim Petrochenkov-35/+152
2019-10-02Set RUST_BACKTRACE=0 in tests that include a backtrace in stderrAaron Hill-3/+6
This removes the implicit dependency on the environment variables set when running `./x.py test`
2019-09-30Stabilize proc macros in type positionsVadim Petrochenkov-21/+18
2019-09-30Stabilize macros in `extern` blocksVadim Petrochenkov-51/+36
Add some tests for macros in extern blocks, remove duplicate tests
2019-09-15resolve: Remove `!` from "cannot find" diagnostics for macrosVadim Petrochenkov-8/+8
2019-09-15resolve: Tweak "cannot find" wording for attributesVadim Petrochenkov-10/+10
2019-09-15Auto merge of #60584 - jonas-schievink:ice-panic-hook, r=oli-obkbors-3/+18
Use `panic::set_hook` to print the ICE message This allows custom frontends and backends to override the hook with their own, for example to point people to a different issue tracker. ICE messages are printed in a slightly different order now. Nightly prints: ``` thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:347:21 note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace. error: aborting due to 2 previous errors Some errors have detailed explanations: E0277, E0658. For more information about an error, try `rustc --explain E0277`. error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports note: rustc 1.36.0-nightly (08bfe1612 2019-05-02) running on x86_64-unknown-linux-gnu ``` After this PR, rustc prints: ``` thread 'rustc' panicked at 'called `Option::unwrap()` on a `None` value', src/libcore/option.rs:347:21 note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace. error: internal compiler error: unexpected panic note: the compiler unexpectedly panicked. this is a bug. note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports note: rustc 1.36.0-dev running on x86_64-unknown-linux-gnu error: aborting due to 2 previous errors Some errors have detailed explanations: E0277, E0658. For more information about an error, try `rustc --explain E0277`. ```
2019-09-14Try to fix the test output normalizationJonas Schievink-15/+15
2019-09-09Rollup merge of #63468 - c410-f3r:attrs, r=petrochenkovMazdak Farrokhzad-11/+4
Resolve attributes in several places Resolve attributes for Arm, Field, FieldPat, GenericParam, Param, StructField and Variant. This PR is based on @petrochenkov work located at https://github.com/petrochenkov/rust/commit/83fdb8d598c1a871d40b21faed64ee698b74f814.
2019-09-09Resolve attributes in several placesCaio-11/+4
Arm, Field, FieldPat, GenericParam, Param, StructField and Variant
2019-09-08Improve wording.Charles Lew-2/+2
2019-09-07Rollup merge of #63919 - matthewjasper:remove-gensymmed, r=petrochenkovMazdak Farrokhzad-86/+86
Use hygiene for AST passes AST passes are now able to have resolve consider their expansions as if they were opaque macros defined either in some module in the current crate, or a fake empty module with `#[no_implicit_prelude]`. * Add an ExpnKind for AST passes. * Remove gensyms in AST passes. * Remove gensyms in`#[test]`, `#[bench]` and `#[test_case]`. * Allow opaque macros to define tests. * Move tests for unit tests to their own directory. * Remove `Ident::{gensym, is_gensymed}` - `Ident::gensym_if_underscore` still exists. cc #60869, #61019 r? @petrochenkov
2019-09-05Add `with_{def_site,call_site,legacy}_ctxt,` methods to `Span`Vadim Petrochenkov-86/+86
Use these to create call-site spans for AST passes when needed.
2019-08-30Update proc-macro testsJonas Schievink-3/+18
Due to #59998, the panic hook fires incorrectly for errors that should not be treated as ICEs. Previously, this would only print the default panic message, but moving the ICE printing into the panic handler will now print the entire ICE ordeal we all hate to see. Unfortunately this will make #59998 a lot more visible.
2019-08-29Rollup merge of #63867 - petrochenkov:dhelpers, r=matthewjasperMazdak Farrokhzad-46/+59
resolve: Block expansion of a derive container until all its derives are resolved So, it turns out there's one more reason to block expansion of a `#[derive]` container until all the derives inside it are resolved, beside `Copy` (https://github.com/rust-lang/rust/pull/63248). The set of derive helper attributes registered by derives in the container also has to be known before the derives themselves are expanded, otherwise it may be too late (see https://github.com/rust-lang/rust/pull/63468#issuecomment-524550872 and the `#[stable_hasher]`-related test failures in https://github.com/rust-lang/rust/pull/63468). So, we stop our attempts to unblock the container earlier, as soon as the `Copy` status is known, and just block until all its derives are resolved. After all the derives are resolved we immediately go and process their helper attributes in the item, without delaying it until expansion of the individual derives. Unblocks https://github.com/rust-lang/rust/pull/63468 r? @matthewjasper (as a reviewer of https://github.com/rust-lang/rust/pull/63248) cc @c410-f3r
2019-08-27proc_macro: Update `Span::def_site` to use the proc macro definition locationVadim Petrochenkov-32/+120
Which is no longer dummy and is available from metadata now.
2019-08-27Respect attributes on proc macro definitionsVadim Petrochenkov-0/+43