about summary refs log tree commit diff
path: root/src/librustc_builtin_macros/deriving/generic
AgeCommit message (Collapse)AuthorLines
2020-08-30mv compiler to compiler/mark-2037/+0
2020-08-22Use smaller def span for functionsAaron Hill-0/+1
Currently, the def span of a funtion encompasses the entire function signature and body. However, this is usually unnecessarily verbose - when we are pointing at an entire function in a diagnostic, we almost always want to point at the signature. The actual contents of the body tends to be irrelevant to the diagnostic we are emitting, and just takes up additional screen space. This commit changes the `def_span` of all function items (freestanding functions, `impl`-block methods, and `trait`-block methods) to be the span of the signature. For example, the function ```rust pub fn foo<T>(val: T) -> T { val } ``` now has a `def_span` corresponding to `pub fn foo<T>(val: T) -> T` (everything before the opening curly brace). Trait methods without a body have a `def_span` which includes the trailing semicolon. For example: ```rust trait Foo { fn bar(); }``` the function definition `Foo::bar` has a `def_span` of `fn bar();` This makes our diagnostic output much shorter, and emphasizes information that is relevant to whatever diagnostic we are reporting. We continue to use the full span (including the body) in a few of places: * MIR building uses the full span when building source scopes. * 'Outlives suggestions' use the full span to sort the diagnostics being emitted. * The `#[rustc_on_unimplemented(enclosing_scope="in this scope")]` attribute points the entire scope body. * The 'unconditional recursion' lint uses the full span to show additional context for the recursive call. All of these cases work only with local items, so we don't need to add anything extra to crate metadata.
2020-08-17rust_ast::ast => rustc_astUjjwal Sharma-3/+3
2020-08-08Eliminate the `SessionGlobals` from `librustc_ast`.Nicholas Nethercote-2/+2
By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This means they are accessed via the `Session`, rather than via TLS. A few `Attr` methods and `librustc_ast` functions are now methods of `Session`. All of this required passing a `Session` to lots of functions that didn't already have one. Some of these functions also had arguments removed, because those arguments could be accessed directly via the `Session` argument. `contains_feature_attr()` was dead, and is removed. Some functions were moved from `librustc_ast` elsewhere because they now need to access `Session`, which isn't available in that crate. - `entry_point_type()` --> `librustc_builtin_macros` - `global_allocator_spans()` --> `librustc_metadata` - `is_proc_macro_attr()` --> `Session`
2020-07-17Remove `ExtCtxt::ident_of`.Nicholas Nethercote-39/+41
It's equivalent to `Ident::from_str_and_span`. The commit also introduces some more static symbols so that `Ident::new` can be used in various places instead of `Ident::from_str_and_span`. The commit also changes `Path::path` from a `&str` to a `Symbol`, which then allows the lifetime annotation to be removed from `Ty`. Also, the use of `Symbol` in `Bounds` removes the need for its lifetime annotation.
2020-07-17Simplify `LifetimeBounds`.Nicholas Nethercote-18/+11
The `lifetimes` field is always empty. This commit removes it, and renames the type as `Bounds`.
2020-07-15Add and use more static symbols.Nicholas Nethercote-7/+7
Note that the output of `unpretty-debug.stdout` has changed. In that test the hash values are normalized from a symbol numbers to small numbers like "0#0" and "0#1". The increase in the number of static symbols must have caused the original numbers to contain more digits, resulting in different pretty-printing prior to normalization.
2020-06-08Don't lose empty `where` clause when pretty-printingAaron Hill-1/+5
Previously, we would parse `struct Foo where;` and `struct Foo;` identically, leading to an 'empty' `where` clause being omitted during pretty printing. This will cause us to lose spans when proc-macros involved, since we will have a collected `where` token that does not appear in the pretty-printed item. We now explicitly track the presence of a `where` token during parsing, so that we can distinguish between `struct Foo where;` and `struct Foo;` during pretty-printing
2020-05-19update `discriminant_value` usage in the compilerBastian Kauschke-70/+10
2020-05-08Remove ast::{Ident, Name} reexports.Camille GILLOT-12/+12
2020-05-02fix rustdoc warningsTshepang Lekhonkhobe-1/+1
2020-04-18Move `MapInPlace` to rustc_data_structuresYuki Okushi-1/+1
2020-03-23Rollup merge of #70269 - matthiaskrgr:clippy_closures, r=Dylan-DPCMazdak Farrokhzad-2/+2
remove redundant closures (clippy::redundant_closure)
2020-03-22remove redundant closures (clippy::redundant_closure)Matthias Krüger-2/+2
2020-03-21use let instead of match for matches with single bindings ↵Matthias Krüger-2/+3
(clippy::match_single_binding)
2020-03-20remove redundant returns (clippy::needless_return)Matthias Krüger-1/+0
2020-03-12ast: `Mac`/`Macro` -> `MacCall`Vadim Petrochenkov-1/+1
2020-03-06Don't redundantly repeat field names (clippy::redundant_field_names)Matthias Krüger-1/+1
2020-02-29Rename `syntax` to `rustc_ast` in source codeVadim Petrochenkov-9/+9
2020-02-28use to_vec() instead of .iter().cloned().collect() to convert slices to vecs.Matthias Krüger-2/+2
2020-02-24parse/ast: move `Defaultness` into variants.Mazdak Farrokhzad-3/+3
2020-02-18Rollup merge of #69194 - Centril:assoc-extern-fuse, r=petrochenkovMazdak Farrokhzad-3/+2
parse: fuse associated and extern items up to defaultness Language changes: - The grammar of extern `type` aliases is unified with associated ones, and becomes: ```rust TypeItem = "type" ident generics {":" bounds}? where_clause {"=" type}? ";" ; ``` Semantic restrictions (`ast_validation`) are added to forbid any parameters in `generics`, any bounds in `bounds`, and any predicates in `where_clause`, as well as the presence of a type expression (`= u8`). (Work still remains to fuse this with free `type` aliases, but this can be done later.) - The grammar of constants and static items (free, associated, and extern) now permits the absence of an expression, and becomes: ```rust GlobalItem = {"const" {ident | "_"} | "static" "mut"? ident} {"=" expr}? ";" ; ``` - A semantic restriction is added to enforce the presence of the expression (the body). - A semantic restriction is added to reject `const _` in associated contexts. Together, these changes allow us to fuse the grammar of associated items and extern items up to `default`ness which is the main goal of the PR. ----------------------- We are now very close to fully fusing the entirely of item parsing and their ASTs. To progress further, we must make a decision: should we parse e.g. `default use foo::bar;` and whatnot? Accepting that is likely easiest from a parsing perspective, as it does not require using look-ahead, but it is perhaps not too onerous to only accept it for `fn`s (and all their various qualifiers), `const`s, `static`s, and `type`s. r? @petrochenkov
2020-02-17Rename `FunctionRetTy` to `FnRetTy`Yuki Okushi-1/+1
2020-02-15ast: move Generics into AssocItemKindsMazdak Farrokhzad-3/+2
2020-02-13Constness -> enum Const { Yes(Span), No }Mazdak Farrokhzad-3/+3
Same idea for `Unsafety` & use new span for better diagnostics.
2020-02-10Add `#[repr(no_niche)]`.Felix S. Klock II-1/+2
This repr-hint makes a struct/enum hide any niche within from its surrounding type-construction context. It is meant (at least initially) as an implementation detail for resolving issue 68303. We will not stabilize the repr-hint unless someone finds motivation for doing so. (So, declaration of `no_niche` feature lives in section of file where other internal implementation details are grouped, and deliberately leaves out the tracking issue number.) incorporated review feedback, and fixed post-rebase.
2020-02-011. move node_id to syntaxMazdak Farrokhzad-1/+1
2. invert rustc_session & syntax deps 3. drop rustc_session dep in rustc_hir
2020-02-01Move builtin attribute logic to new rustc_attr crate.Mazdak Farrokhzad-1/+1
For now, this is all the crate contains, but more attribute logic & types will be moved there over time.
2020-01-30Use `P` for `NtTraitItem`, `NtImplItem`, and `NtForeignItem`.Nicholas Nethercote-7/+8
This commit reduces the size of `Nonterminal` from a whopping 240 bytes to 72 bytes (on x86-64), which gets it below the `memcpy` threshold. It also removes some impedance mismatches with `Annotatable`, which already uses `P` for these variants.
2020-01-19Add `constness` field to `ast::ItemKind::Impl`Dylan MacKenzie-0/+1
2020-01-17Use named fields for `ast::ItemKind::Impl`Dylan MacKenzie-8/+8
2020-01-16don't clone types that are copyMatthias Krüger-1/+1
found via clippy
2020-01-02Normalize `syntax::symbol` imports.Mazdak Farrokhzad-1/+1
2020-01-02Normalize `syntax::source_map` imports.Mazdak Farrokhzad-2/+2
2020-01-01Rename `syntax_pos` to `rustc_span` in source codeVadim Petrochenkov-3/+3
2019-12-30Rename `libsyntax_ext` and `libsyntax_expand` in codeVadim Petrochenkov-2/+2
2019-12-30Make things build againVadim Petrochenkov-4/+4
2019-12-30Rename directories for some crates from `syntax_x` to `rustc_x`Vadim Petrochenkov-0/+2095
`syntax_expand` -> `rustc_expand` `syntax_pos` -> `rustc_span` `syntax_ext` -> `rustc_builtin_macros`