about summary refs log tree commit diff
path: root/compiler/rustc_builtin_macros
AgeCommit message (Collapse)AuthorLines
2021-03-26Use iter::zip in compiler/Josh Stone-5/+4
2021-03-26Rollup merge of #83486 - Aaron1011:fix/global-alloc-error, r=petrochenkovDylan DPC-16/+16
Don't ICE when using `#[global_alloc]` on a non-item statement Fixes #83469 We need to return an `Annotatable::Stmt` if we were passed an `Annotatable::Stmt`
2021-03-25Don't ICE when using `#[global_alloc]` on a non-item statementAaron Hill-16/+16
Fixes #83469 We need to return an `Annotatable::Stmt` if we were passed an `Annotatable::Stmt`
2021-03-25Refactor #82270 as lint instead of an errorAmanieu d'Antras-65/+30
2021-03-19stabilize or_patternsmark-1/+1
2021-03-18Rollup merge of #82270 - asquared31415:asm-syntax-directive-errors, r=nagisaDylan DPC-1/+72
Emit error when trying to use assembler syntax directives in `asm!` The `.intel_syntax` and `.att_syntax` assembler directives should not be used, in favor of not specifying a syntax for intel, and in favor of the explicit `att_syntax` option using the inline assembly options. Closes #79869
2021-03-16ast/hir: Rename field-related structuresVadim Petrochenkov-13/+13
StructField -> FieldDef ("field definition") Field -> ExprField ("expression field", not "field expression") FieldPat -> PatField ("pattern field", not "field pattern") Also rename visiting and other methods working on them.
2021-03-14Bump recursion_limit in a few placesAaron Hill-0/+1
This is needed to get rustdoc to succeed on `dist-x86_64-linux-alt`
2021-03-10Rollup merge of #82217 - m-ou-se:edition-prelude, r=nikomatsakisDylan DPC-11/+19
Edition-specific preludes This changes `{std,core}::prelude` to export edition-specific preludes under `rust_2015`, `rust_2018` and `rust_2021`. (As suggested in https://github.com/rust-lang/rust/issues/51418#issuecomment-395630382.) For now they all just re-export `v1::*`, but this allows us to add things to the 2021edition prelude soon. This also changes the compiler to make the automatically injected prelude import dependent on the selected edition. cc `@rust-lang/libs` `@djc`
2021-03-08Move default inline asm dialect to Sessionasquared31415-6/+2
2021-03-08Rollup merge of #82682 - petrochenkov:cfgeval, r=Aaron1011Dylan DPC-21/+162
Implement built-in attribute macro `#[cfg_eval]` + some refactoring This PR implements a built-in attribute macro `#[cfg_eval]` as it was suggested in https://github.com/rust-lang/rust/pull/79078 to avoid `#[derive()]` without arguments being abused as a way to configure input for other attributes. The macro is used for eagerly expanding all `#[cfg]` and `#[cfg_attr]` attributes in its input ("fully configuring" the input). The effect is identical to effect of `#[derive(Foo, Bar)]` which also fully configures its input before passing it to macros `Foo` and `Bar`, but unlike `#[derive]` `#[cfg_eval]` can be applied to any syntax nodes supporting macro attributes, not only certain items. `cfg_eval` was the first name suggested in https://github.com/rust-lang/rust/pull/79078, but other alternatives are also possible, e.g. `cfg_expand`. ```rust #[cfg_eval] #[my_attr] // Receives `struct S {}` as input, the field is configured away by `#[cfg_eval]` struct S { #[cfg(FALSE)] field: u8, } ``` Tracking issue: https://github.com/rust-lang/rust/issues/82679
2021-03-07rustc_builtin_macros: Share some more logic between `derive` and `cfg_eval`Vadim Petrochenkov-26/+14
2021-03-07cfg_eval: Configure everything through mutable visitor methodsVadim Petrochenkov-70/+27
This is simpler and mirrors what invocation collector does
2021-03-07Move full configuration logic from `rustc_expand` to `rustc_builtin_macros`Vadim Petrochenkov-7/+178
This logic is applicable to two specific macros and not to the expansion infrastructure in general.
2021-03-06Implement built-in attribute macro `#[cfg_eval]`Vadim Petrochenkov-0/+31
2021-03-06rustc_ast: Replace `AstLike::finalize_tokens` with a getter `tokens_mut`Vadim Petrochenkov-9/+3
2021-03-05expand: Some more consistent naming in module loadingVadim Petrochenkov-2/+2
2021-03-05expand: Move module file path stack from global session to expansion dataVadim Petrochenkov-4/+3
Also don't push the paths on the stack directly in `fn parse_external_mod`, return them instead.
2021-02-25Pick the injected prelude based on the edition.Mara Bos-11/+19
2021-02-20Remove some P-sDániel Buga-4/+3
2021-02-20Take into account target default syntaxasquared31415-48/+72
2021-02-18Emit error when trying to use assembler syntax directives in `asm!`asquared31415-1/+52
2021-02-18ast: Keep expansion status for out-of-line module itemsVadim Petrochenkov-7/+6
Also remove `ast::Mod` which is mostly redundant now
2021-02-18ast: Stop using `Mod` in `Crate`Vadim Petrochenkov-6/+10
Crate root is sufficiently different from `mod` items, at least at syntactic level. Also remove customization point for "`mod` item or crate root" from AST visitors.
2021-02-16avoid full-slicing slicesMatthias Krüger-3/+3
If we already have a slice, there is no need to get another full-range slice from that, just use the original. clippy::redundant_slicing
2021-02-14bumped smallvec depsklensy-1/+1
2021-02-10Borrow builder only once in debug deriveTomasz Miąsko-9/+12
2021-02-09fix derive(RustcEncodable, RustcDecodable)Skgland-18/+12
2021-02-09use ufcs in derive(RustDecodable)Skgland-19/+31
2021-02-09use ufcs in derive(RustEncodable)Skgland-20/+40
2021-02-09use ufcs in derive(Ord) and derive(PartialOrd)Skgland-4/+7
2021-02-09Fix derived PartialOrd operatorsTomasz Miąsko-190/+7
The derived implementation of `partial_cmp` compares matching fields one by one, stopping the computation when the result of a comparison is not equal to `Some(Equal)`. On the other hand the derived implementation for `lt`, `le`, `gt` and `ge` continues the computation when the result of a field comparison is `None`, consequently those operators are not transitive and inconsistent with `partial_cmp`. Fix the inconsistency by using the default implementation that fall-backs to the `partial_cmp`. This also avoids creating very deeply nested closures that were quite costly to compile.
2021-02-07expand/resolve: Turn `#[derive]` into a regular macro attributeVadim Petrochenkov-0/+135
2021-02-03Auto merge of #81294 - pnkfelix:issue-81211-use-ufcs-in-derive-debug, r=oli-obkbors-17/+21
Use ufcs in derive(Debug) Cc #81211. (Arguably this *is* the fix for it.)
2021-02-02Rollup merge of #81647 - m-ou-se:assert-2021-fix, r=petrochenkovJack Huey-2/+2
Fix bug with assert!() calling the wrong edition of panic!(). The span of `panic!` produced by the `assert` macro did not carry the right edition. This changes `assert` to call the right version. Also adds tests for the 2021 edition of panic and assert, that would've caught this.
2021-02-02Auto merge of #81405 - bugadani:ast, r=cjgillotbors-13/+17
Box the biggest ast::ItemKind variants This PR is a different approach on https://github.com/rust-lang/rust/pull/81400, aiming to save memory in humongous ASTs. The three affected item kind enums are: - `ast::ItemKind` (208 -> 112 bytes) - `ast::AssocItemKind` (176 -> 72 bytes) - `ast::ForeignItemKind` (176 -> 72 bytes)
2021-02-02Bump rustfmt versionMark Rousskov-1/+1
Also switches on formatting of the mir build module
2021-02-01Fix bug with assert!() calling the wrong edition of panic!().Mara Bos-2/+2
The span of `panic!` produced by the `assert` macro did not carry the right edition. This changes `assert` to call the right version.
2021-02-01placate tidy.Felix S. Klock II-10/+4
2021-02-01Use UFCS instead of method calls in `derive(Debug)`. See issue 81211 for ↵Felix S. Klock II-15/+25
discussion.
2021-02-01Auto merge of #80851 - m-ou-se:panic-2021, r=petrochenkovbors-0/+51
Implement Rust 2021 panic This implements the Rust 2021 versions of `panic!()`. See https://github.com/rust-lang/rust/issues/80162 and https://github.com/rust-lang/rfcs/pull/3007. It does so by replacing `{std, core}::panic!()` by a bulitin macro that expands to either `$crate::panic::panic_2015!(..)` or `$crate::panic::panic_2021!(..)` depending on the edition of the caller. This does not yet make std's panic an alias for core's panic on Rust 2021 as the RFC proposes. That will be a separate change: https://github.com/rust-lang/rust/pull/80879/commits/c5273bdfb266c35e8eab9413aa8d58d27fdbe114 That change is blocked on figuring out what to do with https://github.com/rust-lang/rust/issues/80846 first.
2021-02-01Box the biggest ast::ItemKind variantsDániel Buga-13/+17
2021-01-25Implement new panic!() behaviour for Rust 2021.Mara Bos-0/+51
2021-01-24Rollup merge of #80855 - m-ou-se:assert-2021, r=petrochenkovJonas Schievink-5/+21
Expand assert!(expr, args..) to include $crate for hygiene on 2021. This makes `assert!(expr, args..)` properly hygienic in Rust 2021. This is part of rust-lang/rfcs#3007, see #80162. Before edition 2021, this was a breaking change, as `std::panic` and `core::panic` are different. In edition 2021 they will be identical, making it possible to apply proper hygiene here.
2021-01-24Only call span.rust_2021() when necessary.Mara Bos-7/+5
2021-01-20Force token collection to run when parsing nonterminalsAaron Hill-2/+3
Fixes #81007 Previously, we would fail to collect tokens in the proper place when only builtin attributes were present. As a result, we would end up with attribute tokens in the collected `TokenStream`, leading to duplication when we attempted to prepend the attributes from the AST node. We now explicitly track when token collection must be performed due to nomterminal parsing.
2021-01-10resolve: Simplify built-in macro tableVadim Petrochenkov-10/+4
2021-01-09Expand assert!(expr, args..) to include $crate for hygiene on 2021.Mara Bos-1/+19
Before 2021, this was a breaking change, as std::panic and core::panic are different. In edition 2021 they will be identical, making it possible again to apply proper hygiene here.
2021-01-09Don't set builtin_name for builtin macro implementations.Mara Bos-1/+1
This used to be necessary for `is_builtin` in the past, but is no longer required. Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2021-01-09Allow #[rustc_builtin_macro = "name"].Mara Bos-1/+1
This makes it possible to have both std::panic and core::panic as a builtin macro, by using different builtin macro names for each. Also removes SyntaxExtension::is_derive_copy, as the macro name (e.g. sym::Copy) is now tracked and provides that information directly.