summary refs log tree commit diff
path: root/compiler/rustc_resolve/src/diagnostics.rs
AgeCommit message (Collapse)AuthorLines
2022-06-19Mention what item is using an invalid `Self` typeMichael Goulet-0/+2
2022-06-14Separate `source_span` and `expn_that_defined` from `Definitions`.Camille GILLOT-10/+11
2022-06-13remove unnecessary `to_string` and `String::new` for `tool_only_span_suggestion`Takayuki Maeda-7/+2
2022-06-13remove unnecessary `to_string` and `String::new`Takayuki Maeda-12/+7
2022-06-01Rollup merge of #97264 - ↵Matthias Krüger-3/+12
TaKO8Ki:suggest-extern-crate-when-failing-to-resolve-use-crate, r=estebank Suggest `extern crate foo` when failing to resolve `use foo` closes #97095 r? ``@estebank``
2022-05-25suggest `extern crate foo` when failing to resolve `use foo`Takayuki Maeda-3/+12
fix ci error
2022-05-20Remove `crate` visibility usage in compilerJacob Pratt-20/+20
2022-05-12Auto merge of #96150 - est31:unused_macro_rules, r=petrochenkovbors-0/+14
Implement a lint to warn about unused macro rules This implements a new lint to warn about unused macro rules (arms/matchers), similar to the `unused_macros` lint added by #41907 that warns about entire macros. ```rust macro_rules! unused_empty { (hello) => { println!("Hello, world!") }; () => { println!("empty") }; //~ ERROR: 1st rule of macro `unused_empty` is never used } fn main() { unused_empty!(hello); } ``` Builds upon #96149 and #96156. Fixes #73576
2022-05-07Auto merge of #96094 - Elliot-Roberts:fix_doctests, r=compiler-errorsbors-13/+13
Begin fixing all the broken doctests in `compiler/` Begins to fix #95994. All of them pass now but 24 of them I've marked with `ignore HELP (<explanation>)` (asking for help) as I'm unsure how to get them to work / if we should leave them as they are. There are also a few that I marked `ignore` that could maybe be made to work but seem less important. Each `ignore` has a rough "reason" for ignoring after it parentheses, with - `(pseudo-rust)` meaning "mostly rust-like but contains foreign syntax" - `(illustrative)` a somewhat catchall for either a fragment of rust that doesn't stand on its own (like a lone type), or abbreviated rust with ellipses and undeclared types that would get too cluttered if made compile-worthy. - `(not-rust)` stuff that isn't rust but benefits from the syntax highlighting, like MIR. - `(internal)` uses `rustc_*` code which would be difficult to make work with the testing setup. Those reason notes are a bit inconsistently applied and messy though. If that's important I can go through them again and try a more principled approach. When I run `rg '```ignore \(' .` on the repo, there look to be lots of different conventions other people have used for this sort of thing. I could try unifying them all if that would be helpful. I'm not sure if there was a better existing way to do this but I wrote my own script to help me run all the doctests and wade through the output. If that would be useful to anyone else, I put it here: https://github.com/Elliot-Roberts/rust_doctest_fixing_tool
2022-05-05Implement the unused_macro_rules lintest31-0/+14
2022-05-03Tweak wordingEsteban Kuber-5/+4
2022-05-03When suggesting to import an item, also suggest changing the path if appropriateEsteban Küber-4/+17
When we don't find an item we search all of them for an appropriate import and suggest `use`ing it. This is sometimes done for expressions that have paths with more than one segment. We now also suggest changing that path to work with the `use`. Fix #95413
2022-05-02fix most compiler/ doctestsElliot Roberts-13/+13
2022-05-02rustc: Panic by default in `DefIdTree::parent`Vadim Petrochenkov-2/+2
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root. So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root. Same applies to `local_parent`/`opt_local_parent`.
2022-05-01resolve: Rename `unusable_binding` to `ignore_binding`Vadim Petrochenkov-5/+5
2022-05-01resolve: Merge `last_import_segment` into `Finalize`Vadim Petrochenkov-3/+0
2022-05-01resolve: Turn `enum Finalize` into an optional structVadim Petrochenkov-11/+8
2022-04-30Use newtype `enum`s instead of `bool`Esteban Kuber-21/+43
2022-04-30When encountering a binding that could be a const or unit variant, suggest ↵Esteban Kuber-19/+71
the right path
2022-04-21Remove redundant `format!`sNixon Enraght-Moony-1/+1
2022-04-17Stop using CRATE_DEF_INDEX.Camille GILLOT-2/+2
`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.
2022-04-14Reimplement lowering of sym operands for asm! so that it also works with ↵Amanieu d'Antras-0/+6
global_asm!
2022-04-12Rollup merge of #95405 - cjgillot:probe, r=petrochenkovDylan DPC-18/+660
Move name resolution logic to a dedicated file The code resolution logic from an Ident is scattered between several files. The first commits creates `rustc_resolve::probe` module to hold the different mutually recursive functions together. Just a move, no code change. The following commits attempt to make the logic a bit more readable. The two fields `last_import_segment` and `unusable_binding` are replaced by function parameters. In order to manage the fallout, `maybe_` variants of the function are added, dedicated to speculative resolution. r? `@petrochenkov`
2022-04-12Move diagnostic methods to the dedicated module.Camille GILLOT-12/+468
2022-04-12Simplify error reporting.Camille GILLOT-84/+76
2022-04-12Move path resolution error to rustc_resolve::diagnostics.Camille GILLOT-3/+195
2022-04-12Pass last_import_segment and unusable_binding as parameters.Camille GILLOT-5/+7
2022-04-11fix a bad error message for `relative paths are not supported in ↵Takayuki Maeda-1/+1
visibilities` error
2022-04-05errors: implement fallback diagnostic translationDavid Wood-1/+1
This commit updates the signatures of all diagnostic functions to accept types that can be converted into a `DiagnosticMessage`. This enables existing diagnostic calls to continue to work as before and Fluent identifiers to be provided. The `SessionDiagnostic` derive just generates normal diagnostic calls, so these APIs had to be modified to accept Fluent identifiers. In addition, loading of the "fallback" Fluent bundle, which contains the built-in English messages, has been implemented. Each diagnostic now has "arguments" which correspond to variables in the Fluent messages (necessary to render a Fluent message) but no API for adding arguments has been added yet. Therefore, diagnostics (that do not require interpolation) can be converted to use Fluent identifiers and will be output as before.
2022-04-05span: move `MultiSpan`David Wood-2/+2
`MultiSpan` contains labels, which are more complicated with the introduction of diagnostic translation and will use types from `rustc_errors` - however, `rustc_errors` depends on `rustc_span` so `rustc_span` cannot use types like `DiagnosticMessage` without dependency cycles. Introduce a new `rustc_error_messages` crate that can contain `DiagnosticMessage` and `MultiSpan`. Signed-off-by: David Wood <david.wood@huawei.com>
2022-03-30Spellchecking compiler commentsYuri Astrakhan-1/+1
This PR cleans up the rest of the spelling mistakes in the compiler comments. This PR does not change any literal or code spelling issues.
2022-03-25resolve: Rename `CrateLint` to `Finalize`Vadim Petrochenkov-8/+6
And `crate_lint`/`record_used` to `finalize`
2022-03-25resolve: Stop passing unused spans and node ids to path resolution functionsVadim Petrochenkov-14/+9
2022-03-25resolve: Do not build expensive suggestions if they are not actually usedVadim Petrochenkov-4/+4
Also remove a redundant parameter from `fn resolve_path(_with_ribs)`, `crate_lint: CrateLint` is a more detailed version of `record_used: bool` with `CrateLint::No` meaning `false` and anything else meaning `true`.
2022-03-02rename ErrorReported -> ErrorGuaranteedmark-3/+5
2022-02-23rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".Eduard-Mihai Burtescu-3/+6
2022-02-23Replace `&mut DiagnosticBuilder`, in signatures, with `&mut Diagnostic`.Eduard-Mihai Burtescu-4/+4
2022-02-18Rollup merge of #93634 - matthiaskrgr:clippy_complexity_jan_2022, r=oli-obkMatthias Krüger-4/+3
compiler: clippy::complexity fixes useless_format map_flatten useless_conversion needless_bool filter_next clone_on_copy needless_option_as_deref
2022-02-12change to a struct variantEllen-1/+1
2022-02-03compiler: clippy::complexity fixesMatthias Krüger-4/+3
useless_format map_flatten useless_conversion needless_bool filter_next clone_on_copy needless_option_as_deref
2022-01-31Make `span_extend_to_prev_str()` more robustFabian Wolff-19/+19
2022-01-16rustc_metadata: Switch all decoder methods from vectors to iteratorsVadim Petrochenkov-6/+4
Also remove unnecessary `is_proc_macro_crate` checks from decoder
2022-01-08Simplify error reporting.Camille GILLOT-0/+19
2022-01-06rustc_metadata: Make attribute decoding slightly faster and stricterVadim Petrochenkov-4/+6
Rename `CStore::item_attrs` -> `CStore::item_attrs_untracked` top follow conventions
2021-12-15Remove unnecessary sigils around `Ident::as_str()` calls.Nicholas Nethercote-1/+1
2021-12-15Remove `SymbolStr`.Nicholas Nethercote-4/+3
By changing `as_str()` to take `&self` instead of `self`, we can just return `&str`. We're still lying about lifetimes, but it's a smaller lie than before, where `SymbolStr` contained a (fake) `&'static str`!
2021-11-27Improve error message for `E0659` if the source is not availableFabian Wolff-1/+1
2021-11-16Fix case where ICE #90878 was still triggered by a leading newlineNilstrieb-9/+7
I cannot provide a test for that thanks to tidy.
2021-11-15Fix `non-constant value` ICE (#90878)Nilstrieb-1/+15
This also fixes the same suggestion, which was kind of broken, because it just searched for the last occurence of `const` to replace with a `let`. This works great in some cases, but when there is no const and a leading space to the file, it doesn't work and panic with overflow because it thought that it had found a const. I also changed the suggestion to only trigger if the `const` and the non-constant value are on the same line, because if they aren't, the suggestion is very likely to be wrong. Also don't trigger the suggestion if the found `const` is on line 0, because that triggers the ICE.
2021-11-12rustc_feature: Convert `BuiltinAttribute` from tuple to a structVadim Petrochenkov-1/+1