about summary refs log tree commit diff
path: root/src/librustc_save_analysis/sig.rs
AgeCommit message (Collapse)AuthorLines
2020-08-30mv compiler to compiler/mark-930/+0
2020-08-22Use smaller def span for functionsAaron Hill-1/+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-17Auto merge of #75120 - JulianKnodt:rm_reps, r=oli-obkbors-1/+1
rust_ast::ast => rustc_ast Rework of #71199 which is a rework #70621 Still working on this but just made the PR to track progress r? @Dylan-DPC
2020-08-17rust_ast::ast => rustc_astUjjwal Sharma-1/+1
2020-08-16save_analysis: support `QPath::LangItem`David Wood-1/+3
This commit implements support for `QPath::LangItem` and `GenericBound::LangItemTrait` in save analysis. Signed-off-by: David Wood <david@davidtw.co>
2020-08-16hir: introduce `QPath::LangItem`David Wood-0/+1
This commit introduces `QPath::LangItem` to the HIR and uses it in AST lowering instead of constructing a `hir::Path` from a slice of symbols. This might be better for performance, but is also much cleaner as the previous approach is fragile. In addition, it resolves a bug (#61019) where an extern crate imported as "std" would result in the paths created during AST lowering being resolved incorrectly (or not at all). Co-authored-by: Matthew Jasper <mjjasper1@gmail.com> Signed-off-by: David Wood <david@davidtw.co>
2020-07-03Use 'tcx for references to AccessLevels wherever possible.Eduard-Mihai Burtescu-55/+19
2020-06-11Rename `TyKind::Def` to `OpaqueDef`Matthew Jasper-1/+1
2020-06-09save_analysis: better handle functions signaturemarmeladema-4/+5
2020-06-09save_analysis: better handle pathsmarmeladema-1/+16
2020-06-04save_analysis: work on HIR tree instead of ASTmarmeladema-228/+243
2020-05-08Remove ast::{Ident, Name} reexports.Camille GILLOT-7/+8
2020-04-19Dogfood more or_patterns in the compilerJosh Stone-3/+1
2020-03-15Rollup merge of #69589 - petrochenkov:maccall, r=CentrilMazdak Farrokhzad-3/+3
ast: `Mac`/`Macro` -> `MacCall` It's now obvious that these refer to macro calls rather than to macro definitions. It's also a single name instead of two different names in different places. `rustc_expand` usually calls macro calls in a wide sense (including attributes and derives) "macro invocations", but structures and variants renamed in this PR are only relevant to fn-like macros, so it's simpler and clearer to just call them calls. cc https://github.com/rust-lang/rust/pull/63586#discussion_r314232513 r? @eddyb
2020-03-12ast: `Mac`/`Macro` -> `MacCall`Vadim Petrochenkov-3/+3
2020-03-12Rollup merge of #69722 - estebank:negative-impl-span-ast, r=CentrilMazdak Farrokhzad-1/+1
Tweak output for invalid negative impl AST errors Use more accurate spans for negative `impl` errors. r? @Centril
2020-03-06Don't redundantly repeat field names (clippy::redundant_field_names)Matthias Krüger-1/+1
2020-03-04Tweak output for invalid negative impl AST errorsEsteban Küber-1/+1
2020-03-01ast: Unmerge structures for associated items and foreign itemsVadim Petrochenkov-1/+0
2020-03-01Auto merge of #69592 - petrochenkov:nosyntax, r=Centrilbors-1/+1
Rename `libsyntax` to `librustc_ast` This was the last rustc crate that wasn't following the `rustc_*` naming convention. Follow-up to https://github.com/rust-lang/rust/pull/67763.
2020-02-29Rename `syntax` to `rustc_ast` in source codeVadim Petrochenkov-1/+1
2020-02-29don't use question mark operator on Err(), return the Result directly instead.Matthias Krüger-1/+1
2020-02-24parse/ast: move `Defaultness` into variants.Mazdak Farrokhzad-4/+4
2020-02-24add `Span` to `ast::Defaultness::Default`.Mazdak Farrokhzad-1/+1
2020-02-22parse: allow `type Foo: Ord` syntactically.Mazdak Farrokhzad-2/+5
2020-02-18Rollup merge of #69194 - Centril:assoc-extern-fuse, r=petrochenkovMazdak Farrokhzad-8/+15
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-4/+4
2020-02-15parse extern constsMazdak Farrokhzad-0/+1
2020-02-15ast/parser: fuse `static` & `const` grammars in all contexts.Mazdak Farrokhzad-1/+1
2020-02-15ast: make `= <expr>;` optional in free statics/consts.Mazdak Farrokhzad-6/+12
2020-02-15ast: normalize `ForeignItemKind::Ty` & `AssocItemKind::TyAlias`.Mazdak Farrokhzad-1/+1
2020-02-13IsAsync -> enum Async { Yes { span: Span, .. }, No }Mazdak Farrokhzad-2/+2
use new span for better diagnostics.
2020-02-13Constness -> enum Const { Yes(Span), No }Mazdak Farrokhzad-8/+8
Same idea for `Unsafety` & use new span for better diagnostics.
2020-02-05parser: merge `fn` grammars wrt. bodies & headersMazdak Farrokhzad-1/+2
also refactor `FnKind` and `visit_assoc_item` visitors
2020-02-01syntax::print -> new crate rustc_ast_prettyMazdak Farrokhzad-1/+1
2020-01-19Add `constness` field to `ast::ItemKind::Impl`Dylan MacKenzie-0/+4
2020-01-17Use named fields for `ast::ItemKind::Impl`Dylan MacKenzie-7/+7
2020-01-05Remove rustc_hir reexports in rustc::hir.Mazdak Farrokhzad-1/+1
2019-12-22Format the worldMark Rousskov-117/+68
2019-12-201. ast::Mutability::{Mutable -> Mut, Immutable -> Not}.Mazdak Farrokhzad-5/+5
2. mir::Mutability -> ast::Mutability.
2019-11-16ast: Keep `extern` qualifiers in functions more preciselyVadim Petrochenkov-8/+9
2019-11-14TAIT: adjust save-analysisMazdak Farrokhzad-10/+0
2019-11-08ast::ItemKind::Fn: use ast::FnSigMazdak Farrokhzad-1/+1
2019-11-08ast::MethodSig -> ast::FnSigMazdak Farrokhzad-2/+2
2019-11-07parser: don't hardcode ABIs into grammarMazdak Farrokhzad-16/+10
2019-09-26Rename `ForeignItem.node` to `ForeignItem.kind`varkor-1/+1
2019-09-26Rename `Item.node` to `Item.kind`varkor-1/+1
2019-09-26Rename `Ty.node` to `Ty.kind`varkor-1/+1
2019-08-14Merge Variant and Variant_Caio-2/+2
2019-08-04Rename `ItemKind::Ty` to `ItemKind::TyAlias`varkor-1/+1