about summary refs log tree commit diff
path: root/src/librustc_passes
AgeCommit message (Collapse)AuthorLines
2019-11-18Add more context to `async fn` trait error. Suggest `async-trait`.Agustin Fernandez-1/+6
2019-11-16Use "field is never read" instead of "field is never used"cosine-1/+1
2019-11-15Rollup merge of #66197 - Centril:transparent-ast, r=varkorTyler Mandry-9/+1
Push `ast::{ItemKind, ImplItemKind}::OpaqueTy` hack down into lowering We currently have a hack in the form of `ast::{ItemKind, ImplItemKind}::OpaqueTy` which is constructed literally when you write `type Alias = impl Trait;` but not e.g. `type Alias = Vec<impl Trait>;`. Per https://github.com/rust-lang/rfcs/pull/2515, this needs to change to allow `impl Trait` in nested positions. This PR achieves this change for the syntactic aspect but not the semantic one, which will require changes in lowering and def collection. In the interim, `TyKind::opaque_top_hack` is introduced to avoid knock-on changes in lowering, collection, and resolve. These hacks can then be removed and fixed one by one until the desired semantics are supported. r? @varkor
2019-11-14TAIT: remove redundant check from ast_validationMazdak Farrokhzad-9/+1
2019-11-14move E0744 to new error codeGuillaume Gomez-0/+1
2019-11-14Remove unused error_codes.rs filesGuillaume Gomez-657/+0
2019-11-14Update to use new librustc_error_codes libraryGuillaume Gomez-2/+9
2019-11-13Use `ast::Mutability`Dylan MacKenzie-2/+3
2019-11-13Change control flow error to delay span bugDylan MacKenzie-4/+5
2019-11-13Fix broken doc-testDylan MacKenzie-1/+1
2019-11-13Small fixes to commentsDylan MacKenzie-4/+5
2019-11-13Add HIR pass to check for `if`s and `loop`s in a `const`Dylan MacKenzie-0/+159
These high-level constructs get mapped to control-flow primitives by the time the MIR const-checker runs, making it hard to get the span for the erroneous expression.
2019-11-13Add E0744 for control flow in constsDylan MacKenzie-0/+22
2019-11-11Auto merge of #66252 - cjgillot:trees, r=oli-obkbors-2/+2
Merge repeated definitions Step forward on #66149 I may need further context to understand the need for a separate crate. Also, please tell me if you think of other definitions to merge.
2019-11-11syntactically allow visibility on trait item & enum variantMazdak Farrokhzad-0/+6
2019-11-10Merge hir::GeneratorMovability into ast::Movability.Camille GILLOT-2/+2
2019-11-10move syntax::parse -> librustc_parseMazdak Farrokhzad-4/+5
also move MACRO_ARGUMENTS -> librustc_parse
2019-11-09move attr meta grammar to parse::validate_atr + ast_validationMazdak Farrokhzad-0/+5
2019-11-08Rollup merge of #66188 - Centril:fnsig, r=davidtwcoMazdak Farrokhzad-4/+4
`MethodSig` -> `FnSig` & Use it in `ItemKind::Fn` In both AST & HIR, rename `MethodSig` to `FnSig` and then proceed to use it in `ItemKind::Fn` so that the overall structure is more regular. r? @davidtwco
2019-11-08Rollup merge of #65785 - Centril:compat-to-error-2, r=oli-obkMazdak Farrokhzad-112/+19
Transition future compat lints to {ERROR, DENY} - Take 2 Follow up to https://github.com/rust-lang/rust/pull/63247 implementing https://github.com/rust-lang/rust/pull/63247#issuecomment-536295992. - `legacy_ctor_visibility` (ERROR) -- closes #39207 - `legacy_directory_ownership` (ERROR) -- closes #37872 - `safe_extern_static` (ERROR) -- closes #36247 - `parenthesized_params_in_types_and_modules` (ERROR) -- closes #42238 - `duplicate_macro_exports` (ERROR) - `nested_impl_trait` (ERROR) -- closes #59014 - `ill_formed_attribute_input` (DENY) -- transitions #57571 - `patterns_in_fns_without_body` (DENY) -- transitions #35203 r? @varkor cc @petrochenkov
2019-11-08ast::ItemKind::Fn: use ast::FnSigMazdak Farrokhzad-4/+4
2019-11-07Auto merge of #65750 - nnethercote:cheaper-doc-comments, r=petrochenkovbors-1/+1
Cheaper doc comments This PR implements the idea from #60935: represent doc comments more cheaply, rather than converting them into `#[doc="..."]` attribute form. Unlike #60936 (which is about coalescing doc comments to reduce their number), this approach does not have any backwards compatibility concerns, and it eliminates about 80-90% of the current cost of doc comments (as estimated using the numbers in #60930, which eliminated the cost of doc comments entirely by treating them as normal comments). r? @petrochenkov
2019-11-06Make doc comments cheaper with `AttrKind`.Nicholas Nethercote-1/+1
`AttrKind` is a new type with two variants, `Normal` and `DocComment`. It's a big performance win (over 10% in some cases) because `DocComment` lets doc comments (which are common) be represented very cheaply. `Attribute` gets some new helper methods to ease the transition: - `has_name()`: check if the attribute name matches a single `Symbol`; for `DocComment` variants it succeeds if the symbol is `sym::doc`. - `is_doc_comment()`: check if it has a `DocComment` kind. - `{get,unwrap}_normal_item()`: extract the item from a `Normal` variant; panic otherwise. Fixes #60935.
2019-11-06nested_impl_trait -> errorMazdak Farrokhzad-107/+19
2019-11-06legacy_directory_ownership -> errorMazdak Farrokhzad-5/+0
2019-11-06Auto merge of #65830 - Quantumplation:master, r=davidtwco,estebankbors-3/+14
Use ident.span instead of def_span in dead-code pass Hello! First time contributor! :) This should fix #58729. According to @estebank in the duplicate #63064, def_span scans forward on the line until it finds a {, and if it can't find one, falls back to the span for the whole item. This was apparently written before the identifier span was explicitly tracked on each node. This means that if an unused function signature spans multiple lines, the entire function (potentially hundreds of lines) gets flagged as dead code. This could, for example, cause IDEs to add error squiggly's to the whole function. By using the span from the ident instead, we narrow the scope of this in most cases. In a wider sense, it's probably safe to use ident.span instead of def_span in most locations throughout the whole code base, but since this is my first contribution, I kept it small. Some interesting points that came up while I was working on this: - I reorganized the tests a bit to bring some of the dead code ones all into the same location - A few tests were for things unrelated to dead code (like the path-lookahead for parens), so I added #![allow(dead_code)] and cleaned up the stderr file to reduce noise in the future - The same fix doesn't apply to const and static declarations. I tried adding these cases to the match expression, but that created a much wider change to tests and error messages, so I left it off until I could get some code review to validate the approach.
2019-11-05Use source_callee().is_some() to detect macrosPi Lanningham-4/+5
macro_backtrace() allocates a vector, whereas source_callee() doesn't but indicates the same thing. Suggested by @estebank
2019-11-05Detect if item.span is in a macro, and fall backPi Lanningham-3/+13
If item.span is part of a macro invocation, this has several downstream implications. To name two that were found while working on this: - The dead-code error gets annotated with a "in this macro invocation" - Some errors get canceled if they refer to remote crates Ideally, we should annotate item.ident.span with the same macro info, but this is a larger change (see: #66095), so for now we just fall back to the old behavior if this item was generated by a macro. I use span.macro_backtrace().len() to detect if it's part of a macro, because that (among other things) is what is used by the code which adds the "in this macro invocation" annotations mentioned above.
2019-11-04Auto merge of #65835 - Mark-Simulacrum:lockless-lintbuffer, r=nikomatsakisbors-9/+12
Remove LintBuffer from Session This moves the `LintBuffer` from `Session` into the `Resolver`, where it is used until lowering is done and then consumed by early lint passes. This also happily removes the failure mode of buffering lints too late where it would have previously lead to ICEs; it is statically no longer possible to do so. I suspect that with a bit more work a similar move could be done for the lint buffer inside `ParseSess`, but this PR doesn't touch it (in part to keep itself small). The last commit is the "interesting" commit -- the ones before it don't work (though they compile) as they sort of prepare the various crates for the lint buffer to be passed in rather than accessed through Session.
2019-11-03Migrate resolver over to internal lint bufferMark Rousskov-9/+12
2019-10-30Do not complain about missing `fn main()` in some casesEsteban Küber-1/+8
2019-10-28Rollup merge of #65792 - Centril:split-syntax-2, r=petrochenkovMazdak Farrokhzad-2/+1
rustc, rustc_passes: reduce deps on rustc_expand Part of #65324. r? @petrochenkov
2019-10-27rustc, rustc_passes: don't depend on syntax_expand.Mazdak Farrokhzad-2/+1
This is done by moving some data definitions to syntax::expand.
2019-10-26Use ident instead of def_span in dead-code passPi Lanningham-1/+1
According to @estebank, def_span scans forward on the line until it finds a {, and if it can't find one, fallse back to the span for the whole item. This was apparently written before the identifier span was explicitly tracked on each node. This means that if an unused function signature spans multiple lines, the entire function (potentially hundreds of lines) gets flagged as dead code. This could, for example, cause IDEs to add error squiggly's to the whole function. By using the span from the ident instead, we narrow the scope of this in most cases. In a wider sense, it's probably safe to use ident.span instead of def_span in most locations throughout the whole code base, but since this is my first contribution, I kept it small. Some interesting points that came up while I was working on this: - I reorganized the tests a bit to bring some of the dead code ones all into the same location - A few tests were for things unrelated to dead code (like the path-lookahead for parens), so I added #![allow(dead_code)] and cleaned up the stderr file to reduce noise in the future - The same fix doesn't apply to const and static declarations. I tried adding these cases to the match expression, but that created a much wider change to tests and error messages, so I left it off until I could get some code review to validate the approach.
2019-10-26Update with word change suggestionObsidianMinor-1/+1
Co-Authored-By: varkor <github@varkor.com>
2019-10-26Add detailed explaination for E0666Sydney Acksman-1/+24
2019-10-16move syntax::ext to new crate syntax_expandMazdak Farrokhzad-1/+2
2019-10-13ast: remove implicit pprust dependency via Display.Mazdak Farrokhzad-1/+2
Instead just use `pprust::path_to_string(..)` where needed. This has two benefits: a) The AST definition is now independent of printing it. (Therefore we get closer to extracting a data-crate.) b) Debugging should be easier as program flow is clearer.
2019-10-10Add long error explanation for E0568Guillaume Gomez-1/+29
2019-10-08Rollup merge of #65135 - GuillaumeGomez:add-error-code-check, r=Mark-SimulacrumMazdak Farrokhzad-4/+21
Add check for missing tests for error codes Fixes #64811. r? @Mark-Simulacrum
2019-10-08Add long error explanation for E0567Guillaume Gomez-1/+28
2019-10-07Add long error explanation for E0561Guillaume Gomez-1/+28
2019-10-07Fix/improve some error codes long explanationGuillaume Gomez-4/+21
2019-10-06sort error codes in librustc_passesGuillaume Gomez-162/+161
2019-10-04middle::intrinsicck -> rustc_passesMark Rousskov-0/+279
2019-10-04middle::entry -> rustc_passesMark Rousskov-0/+285
2019-10-04middle::dead -> rustc_passesMark Rousskov-0/+677
2019-10-04move middle::liveness to rustc_passesMark Rousskov-0/+1570
2019-09-30Remove HIR based const qualificationMatthew Jasper-660/+0
2019-09-26Rename `ForeignItem.node` to `ForeignItem.kind`varkor-1/+1