about summary refs log tree commit diff
path: root/compiler/rustc_error_messages
AgeCommit message (Collapse)AuthorLines
2022-08-22Migrate deprecated_where_clause_location, forbidden_assoc_constraint, ↵finalchild-0/+18
keyword_lifetime, invalid_label, invalid_visibility
2022-08-22Migrate forbidden_letfinalchild-0/+6
2022-08-21Migrate diagnostics in parser/expr to SessionDiagnosticXiretza-0/+109
2022-08-20Rollup merge of #100723 - 5225225:the-easy-ones, r=compiler-errorsMatthias Krüger-0/+2
Add the diagnostic translation lints to crates that don't emit them Some of these have a note saying that they should build on a stable compiler, does that mean they shouldn't get these lints? Or can we cfg them out on those?
2022-08-20Rollup merge of #100709 - JhonnyBillM:port-expected-used-symbol-diagnostic, ↵Matthias Krüger-0/+2
r=compiler-errors Migrate typeck's `used` expected symbol diagnostic to `SessionDiagnostic` r? ``@davidtwco``
2022-08-20Rollup merge of #100667 - Xiretza:diag-structs-parser-ivd, r=davidtwcoMatthias Krüger-0/+9
Migrate "invalid variable declaration" errors to SessionDiagnostic After seeing the great blog post on Inside Rust, I decided to try my hand at this. Just one diagnostic for now to get used to the workflow and to check if this is the way to do it or if there are any problems.
2022-08-19Rollup merge of #99576 - compiler-errors:foreign-fundamental-drop-is-bad, ↵Dylan DPC-2/+2
r=TaKO8Ki Do not allow `Drop` impl on foreign fundamental types `Drop` should not be implemented on `Pin<T>` even if `T` is local. This does not trigger regular orphan rules is because `Pin` is `#[fundamental]`... but we don't allow specialized `Drop` impls anyways, so these rules are not sufficient to prevent this impl on stable. Let's just choose even stricter rules, since we shouldn't be implementing `Drop` on a foreign ADT ever. Fixes #99575
2022-08-18Add diagnostic translation lints to crates that don't emit them5225225-0/+2
2022-08-18ADD - ExpectedUsedSymbol diagnostic to port used() diagnosticJhonny Bill Mena-0/+2
2022-08-18fluent: fix slug name for borrowck::generic_does_not_live_long_enoughXiretza-1/+1
2022-08-18tidy: check fluent files for styleXiretza-5/+5
2022-08-18Rollup merge of #100674 - PragmaTwice:mig-typeck-unused-crate-diag, r=davidtwcoMatthias Krüger-0/+8
Migrate lint reports in typeck::check_unused to LintDiagnostic In this PR, I migrate two lint reports in `typeck::check_unused` by `LintDiagnostic`, all of which is about extern crates. ```@rustbot``` label +A-translation r? rust-lang/diagnostics
2022-08-18Rollup merge of #100651 - nidnogg:diagnostics_migration_expand_transcribe, ↵Matthias Krüger-0/+17
r=davidtwco Migrations for rustc_expand transcribe.rs This PR includes some migrations to the new diagnostics API for the `rustc_expand` module. r? ```@davidtwco```
2022-08-17Migrate "invalid variable declaration" errors to SessionDiagnosticXiretza-0/+9
2022-08-17Moved structs to rustc_expand::errors, added several more migrations, fixed ↵nidnogg-2/+10
slug name
2022-08-17Migrate lint reports in typeck::check_unused to LintDiagnosticPragmaTwice-0/+8
2022-08-16Migrated more diagnostics under transcribe.rsnidnogg-0/+6
2022-08-16Added first migration for repeated expressions without syntax varsnidnogg-0/+3
2022-08-17Migrate emoji identifier diagnostics to `SessionDiagnostic`finalchild-0/+7
2022-08-16Do not allow Drop impl on foreign fundamental typesMichael Goulet-2/+2
2022-08-15Rollup merge of #100377 - est31:fluent_grepability, r=davidtwcoMatthias Krüger-358/+358
Replace - with _ in fluent slugs to improve developer workflows This is a proposal to smoothen the compiler contribution experience in the face of the move to fluent. ## Context The fluent project has introduced a layer of abstraction to compiler errors. Previously, people would write down error messages directly in the same file the code was located to emit them. Now, there is a slug that connects the code in the compiler to the error message in the ftl file. You can look at 7ef610c003f8072ec4ca4ecf195922a9a44e48dd to see an example of the changes: Old: ```Rust let msg = format!( "bounds on `{}` are most likely incorrect, consider instead \ using `{}` to detect whether a type can be trivially dropped", predicate, cx.tcx.def_path_str(needs_drop) ); lint.build(&msg).emit(); ``` New (Rust side): ```Rust lint.build(fluent::lint::drop_trait_constraints) .set_arg("predicate", predicate) .set_arg("needs_drop", cx.tcx.def_path_str(needs_drop)) .emit(); ``` New (Fluent side): ```fluent lint-drop-trait-constraints = bounds on `{$predicate}` are most likely incorrect, consider instead using `{$needs_drop}` to detect whether a type can be trivially dropped ``` You will note that in the ftl file, the slug is slightly different from the slug in the Rust file: The ftl slug uses `-` (e.g. `lint-drop-trait-constraints`) while the rust slug uses `::` and `_` (e.g. `lint::drop_trait_constraints`). This choice was probably done due to: * Rust not accepting `-` in identifiers (as it is an operator) * fluent not supporting the `:` character in slug names (parse error upon attempts) * all official fluent documentation using `-` instead of `_` ## The problem The two different types of slugs, one with `-`, and one with `_`, cause difficulties for contributors. Imagine you don't have perfect knowledge of where stuff is in the compiler (i would say this is most people), and you encounter an error for which you think there is something you could improve that is not just a rewording. So you want to find out where in the compiler's code that error is being emitted. The best way is via grepping. 1. you grep for the message in the compiler's source code. You discover the ftl file and find out the slug for that error. 2. That slug however contains `-` instead of `_`, so you have to manually translate the `-`'s into `_`s, and furthermore either remove the leading module name, or replace the first `-` with a `::`. 3. you do a second grep to get to the emitting location in the compiler's code. This translation difficulty in step 2 appears also in the other direction when you want to figure out what some code in the compiler is doing and use error messages to help your understanding. Comments and variable names are way less exposed to users so [are more likely going to lie](https://github.com/rust-lang/rust/commit/cc3c5d2700481bae497d6cde825c1d48e79c776a) than error messages. I think that at least the `-`→`_` translation which makes up most of step 2 can be removed at low cost. ## The solution If you look closely, the practice of fluent to use `-` is only a stylistic choice and it is not enforced by fluent implementations, neither the playground nor the one the rust compiler uses, that slugs may not contain `_`. Thus, we can in fact migrate the ftl side to `_`. So now we'll have slugs like `lint_drop_trait_constraints` on the ftl side. You only have to do one replacement now to get to the Rust slug: remove the first `_` and place a `::` in its stead. I would argue that this change is in fact useful as it allows you to control whether you want to look at the rust side of things or the ftl side of things via changing the query string only: with an increased number of translations checked into the repository, grepping for raw slugs will return the slug in many ftl files, so an explicit step to look for the source code is always useful. In the other direction (rust to fluent), you don't need a translation at all any more, as you can just take the final piece of the slug (e.g. `drop_trait_constraints`) and grep for that. The PR also adds enforcement to forbid usage of `_` in slug names. Internal slug names (those leading with a `-`) are exempt from that enforcement. As another workflow that benefits from this change, people who add new errors don't have to do that `-` conversion either. | Before/After | Fluent slug | Rust slug (no change) | |--|--|--| | Before | `lint-drop-trait-constraints` | `lint::drop_trait_constraints`| | After | `lint_drop_trait_constraints` | `lint::drop_trait_constraints`| Note that I've suggested this previously in the translation thread on zulip. I think it's important to think about non-translator contribution impact of fluent. I have certainly plans for more improvements, but this is a good first step. ``@rustbot`` label A-diagnostics
2022-08-12Adjust cfgsMark Rousskov-1/+0
2022-08-12Replace - with _ in ftl slugs for better grepabilityest31-358/+358
Having to replace - with _ (and vice versa) makes the slugs less greppable and thus constitutes a contributor roadblock. Result of running this repeatedly up until reaching a fixpoint: find compiler/rustc_error_messages/locales/en-US/ -type f -exec sed -i 's/\(.+\)-\(.*\)=/\1_\2=/' {} \; Plus some fixes to update usages of slugs leading with -.
2022-08-04link_ordinal is available for foreign staticyukang-2/+2
2022-08-03check link ordinal make sure target is foreign functionyukang-0/+3
2022-07-27lint: add bad opt access internal lintDavid Wood-0/+6
Some command-line options accessible through `sess.opts` are best accessed through wrapper functions on `Session`, `TyCtxt` or otherwise, rather than through field access on the option struct in the `Session`. Adds a new lint which triggers on those options that should be accessed through a wrapper function so that this is prohibited. Options are annotated with a new attribute `rustc_lint_opt_deny_field_access` which can specify the error message (i.e. "use this other function instead") to be emitted. A simpler alternative would be to simply rename the options in the option type so that it is clear they should not be used, however this doesn't prevent uses, just discourages them. Another alternative would be to make the option fields private, and adding accessor functions on the option types, however the wrapper functions sometimes rely on additional state from `Session` or `TyCtxt` which wouldn't be available in an function on the option type, so the accessor would simply make the field available and its use would be discouraged too. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-25passes: port more of `check_attr` moduleDavid Wood-0/+107
Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-20clippy::perf fixesMatthias Krüger-1/+1
2022-07-19Auto merge of #98180 - notriddle:notriddle/rustdoc-fn, ↵bors-2/+2
r=petrochenkov,GuillaumeGomez Improve the function pointer docs This is #97842 but for function pointers instead of tuples. The concept is basically the same. * Reduce duplicate impls; show `fn (T₁, T₂, …, Tₙ)` and include a sentence saying that there exists up to twelve of them. * Show `Copy` and `Clone`. * Show auto traits like `Send` and `Sync`, and blanket impls like `Any`. https://notriddle.com/notriddle-rustdoc-test/std/primitive.fn.html
2022-07-18Update invalid atomic ordering lintTomasz Miąsko-5/+0
The restriction that success ordering must be at least as strong as its failure ordering in compare-exchange operations was lifted in #98383.
2022-07-17rustdoc: extend `#[doc(tuple_variadic)]` to fn pointersMichael Howell-2/+2
The attribute is also renamed `fake_variadic`.
2022-07-16Stabilize `let_chains`Caio-1/+1
2022-07-15passes: migrate half of `check_attr`David Wood-0/+152
Migrate half of the `rustc_passes::check_attr` diagnostics to using diagnostic derives and being translatable.
2022-07-15errors: lint on `LintDiagnosticBuilder::build`David Wood-0/+9
Apply the `#[rustc_lint_diagnostics]` attribute to `LintDiagnosticBuilder::build` so that diagnostic migration lints will trigger for it. Signed-off-by: David Wood <david.wood@huawei.com>
2022-07-10use subdiagnostic for messageMichael Goulet-1/+7
2022-07-08simplify plurals in fluent messages using hir::ConstContextMichael Goulet-22/+6
2022-07-08Migrate MutDeref, TransientMutBorrow diagnosticsMichael Goulet-0/+19
2022-07-08Migrate PanicNonStr, RawPtrComparison, RawPtrToInt diagnosticsMichael Goulet-0/+11
2022-07-08Migrate StaticAccess diagnosticMichael Goulet-1/+11
2022-07-08Migrate NonConstOp diagnosticMichael Goulet-0/+3
2022-07-08Migrate unstable-in-stable diagnosticMichael Goulet-0/+5
2022-07-08Use dashes instead of underscores in fluent namesMichael Goulet-2/+2
2022-06-30lint: port asm labels diagnosticsDavid Wood-0/+2
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port deref nullptr diagnosticsDavid Wood-0/+3
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port clashing extern diagnosticsDavid Wood-0/+7
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port incomplete features diagnosticsDavid Wood-0/+4
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port explicit outlives diagnosticsDavid Wood-0/+6
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port keyword idents diagnosticsDavid Wood-0/+3
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port test items diagnosticsDavid Wood-0/+2
Signed-off-by: David Wood <david.wood@huawei.com>
2022-06-30lint: port `...` range pattern diagnosticsDavid Wood-0/+3
Signed-off-by: David Wood <david.wood@huawei.com>