summary refs log tree commit diff
path: root/compiler/rustc_lint/src/context.rs
AgeCommit message (Collapse)AuthorLines
2022-03-16rustc_error: make ErrorReported impossible to constructmark-6/+10
There are a few places were we have to construct it, though, and a few places that are more invasive to change. To do this, we create a constructor with a long obvious name.
2022-03-11Improve `AdtDef` interning.Nicholas Nethercote-1/+1
This commit makes `AdtDef` use `Interned`. Much the commit is tedious changes to introduce getter functions. The interesting changes are in `compiler/rustc_middle/src/ty/adt.rs`.
2022-03-05Review changesJack Huey-4/+6
2022-03-05Change to lintJack Huey-0/+8
2022-03-05Improve unexpected_cfgs lint when their is no value expectedLoïc BRANSTETT-20/+26
2022-03-02Added `Expect` lint level and attribute (RFC-2383)xFrednet-0/+4
* Also added the `LintExpectationId` which will be used in future commits
2022-02-26Document that pre-expansion lint passes are deprecatedxFrednet-1/+6
2022-02-25Switch bootstrap cfgsMark Rousskov-1/+1
2022-02-25Auto merge of #93368 - eddyb:diagbld-guarantee, r=estebankbors-9/+13
rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission". That is, `DiagnosticBuilder` is now generic over the return type of `.emit()`, so we'll now have: * `DiagnosticBuilder<ErrorReported>` for error (incl. fatal/bug) diagnostics * can only be created via a `const L: Level`-generic constructor, that limits allowed variants via a `where` clause, so not even `rustc_errors` can accidentally bypass this limitation * asserts `diagnostic.is_error()` on emission, just in case the construction restriction was bypassed (e.g. by replacing the whole `Diagnostic` inside `DiagnosticBuilder`) * `.emit()` returns `ErrorReported`, as a "proof" token that `.emit()` was called (though note that this isn't a real guarantee until after completing the work on #69426) * `DiagnosticBuilder<()>` for everything else (warnings, notes, etc.) * can also be obtained from other `DiagnosticBuilder`s by calling `.forget_guarantee()` This PR is a companion to other ongoing work, namely: * #69426 and it's ongoing implementation: #93222 the API changes in this PR are needed to get statically-checked "only errors produce `ErrorReported` from `.emit()`", but doesn't itself provide any really strong guarantees without those other `ErrorReported` changes * #93244 would make the choices of API changes (esp. naming) in this PR fit better overall In order to be able to let `.emit()` return anything trustable, several changes had to be made: * `Diagnostic`'s `level` field is now private to `rustc_errors`, to disallow arbitrary "downgrade"s from "some kind of error" to "warning" (or anything else that doesn't cause compilation to fail) * it's still possible to replace the whole `Diagnostic` inside the `DiagnosticBuilder`, sadly, that's harder to fix, but it's unlikely enough that we can paper over it with asserts on `.emit()` * `.cancel()` now consumes `DiagnosticBuilder`, preventing `.emit()` calls on a cancelled diagnostic * it's also now done internally, through `DiagnosticBuilder`-private state, instead of having a `Level::Cancelled` variant that can be read (or worse, written) by the user * this removes a hazard of calling `.cancel()` on an error then continuing to attach details to it, and even expect to be able to `.emit()` it * warnings were switched to *only* `can_emit_warnings` on emission (instead of pre-cancelling early) * `struct_dummy` was removed (as it relied on a pre-`Cancelled` `Diagnostic`) * since `.emit()` doesn't consume the `DiagnosticBuilder` <sub>(I tried and gave up, it's much more work than this PR)</sub>, we have to make `.emit()` idempotent wrt the guarantees it returns * thankfully, `err.emit(); err.emit();` can return `ErrorReported` both times, as the second `.emit()` call has no side-effects *only* because the first one did do the appropriate emission * `&mut Diagnostic` is now used in a lot of function signatures, which used to take `&mut DiagnosticBuilder` (in the interest of not having to make those functions generic) * the APIs were already mostly identical, allowing for low-effort porting to this new setup * only some of the suggestion methods needed some rework, to have the extra `DiagnosticBuilder` functionality on the `Diagnostic` methods themselves (that change is also present in #93259) * `.emit()`/`.cancel()` aren't available, but IMO calling them from an "error decorator/annotator" function isn't a good practice, and can lead to strange behavior (from the caller's perspective) * `.downgrade_to_delayed_bug()` was added, letting you convert any `.is_error()` diagnostic into a `delay_span_bug` one (which works because in both cases the guarantees available are the same) This PR should ideally be reviewed commit-by-commit, since there is a lot of fallout in each. r? `@estebank` cc `@Manishearth` `@nikomatsakis` `@mark-i-m`
2022-02-24Rollup merge of #94175 - Urgau:check-cfg-improvements, r=petrochenkovDylan DPC-1/+34
Improve `--check-cfg` implementation This pull-request is a mix of improvements regarding the `--check-cfg` implementation: - Simpler internal representation (usage of `Option` instead of separate bool) - Add --check-cfg to the unstable book (based on the RFC) - Improved diagnostics: * List possible values when the value is unexpected * Suggest if possible a name or value that is similar - Add more tests (well known names, mix of combinations, ...) r? ```@petrochenkov```
2022-02-23Continue improvements on the --check-cfg implementationLoïc BRANSTETT-12/+13
- Test the combinations of --check-cfg with partial values() and --cfg - Test that we detect unexpected value when none are expected
2022-02-23rustc_errors: let `DiagnosticBuilder::emit` return a "guarantee of emission".Eduard-Mihai Burtescu-9/+13
2022-02-22Improve diagnostic of the unexpected_cfgs lintLoïc BRANSTETT-1/+33
2022-02-20Auto merge of #94062 - Mark-Simulacrum:drop-print-cfg, r=oli-obkbors-6/+6
Move ty::print methods to Drop-based scope guards Primary goal is reducing codegen of the TLS access for each closure, which shaves ~3 seconds of bootstrap time over rustc as a whole.
2022-02-19Adopt let else in more placesest31-3/+2
2022-02-16Move ty::print methods to Drop-based scope guardsMark Rousskov-6/+6
2022-02-15Overhaul `Const`.Nicholas Nethercote-1/+1
Specifically, rename the `Const` struct as `ConstS` and re-introduce `Const` as this: ``` pub struct Const<'tcx>(&'tcx Interned<ConstS>); ``` This now matches `Ty` and `Predicate` more closely, including using pointer-based `eq` and `hash`. Notable changes: - `mk_const` now takes a `ConstS`. - `Const` was copy, despite being 48 bytes. Now `ConstS` is not, so need a we need separate arena for it, because we can't use the `Dropless` one any more. - Many `&'tcx Const<'tcx>`/`&Const<'tcx>` to `Const<'tcx>` changes - Many `ct.ty` to `ct.ty()` and `ct.val` to `ct.val()` changes. - Lots of tedious sigil fiddling.
2022-02-01add a rustc::query_stability lintlcnr-2/+5
2022-01-31Rollup merge of #90277 - pierwill:fix-70258-inference-terms, r=jackh726Matthias Krüger-1/+1
Improve terminology around "after typeck" Closes #70258.
2022-01-28Rollup merge of #92611 - Amanieu:asm-reference, r=m-ou-seMatthias Krüger-0/+1
Add links to the reference and rust by example for asm! docs and lints These were previously removed in #91728 due to broken links. cc ``@ehuss`` since this updates the rust-by-example submodule
2022-01-23rustc_lint: Reuse the set of registered tools from resolverVadim Petrochenkov-12/+20
2022-01-23rustc_lint: Remove some redundant fields from `EarlyContext`Vadim Petrochenkov-20/+5
Use consistent function parameter order for early context construction and early linting Rename some functions to make it clear that they do not necessarily work on the whole crate
2022-01-19Add links to the reference and rust by example for asm! docs and lintsAmanieu d'Antras-0/+1
2021-12-21Rollup merge of #91770 - TaKO8Ki:suggest-adding-cfg-test, r=joshtriplettMatthias Krüger-1/+9
Suggest adding a `#[cfg(test)]` to to a test module closes #88138
2021-12-19Auto merge of #91957 - nnethercote:rm-SymbolStr, r=oli-obkbors-3/+3
Remove `SymbolStr` This was originally proposed in https://github.com/rust-lang/rust/pull/74554#discussion_r466203544. As well as removing the icky `SymbolStr` type, it allows the removal of a lot of `&` and `*` occurrences. Best reviewed one commit at a time. r? `@oli-obk`
2021-12-18Rollup merge of #92032 - petrochenkov:extblockpath, r=oli-obkMatthias Krüger-2/+2
hir: Do not introduce dummy type names for `extern` blocks in def paths Use a separate nameless `DefPathData` variant instead. Extracted from https://github.com/rust-lang/rust/pull/91795.
2021-12-18hir: Do not introduce dummy type names for `extern` blocks in def pathsVadim Petrochenkov-2/+2
Use a separate nameless `DefPathData` variant instead
2021-12-18Rollup merge of #89090 - cjgillot:bare-dyn, r=jackh726Matthias Krüger-10/+0
Lint bare traits in AstConv. Removing the lint from lowering allows to: - make lowering querification easier; - have the lint implementation in only one place. r? `@estebank`
2021-12-16suggest adding a `#[cfg(test)]` to test modulesTakayuki Maeda-1/+9
remove a empty line import `module_to_string` use `contains("test")` show a suggestion in case module starts_with/ends_with "test" replace `parent` with `containing`
2021-12-15Remove unnecessary sigils around `Symbol::as_str()` calls.Nicholas Nethercote-3/+3
2021-12-12Address review feedbackAmanieu d'Antras-1/+0
2021-12-12Stabilize asm! and global_asm!Amanieu d'Antras-1/+1
They are also removed from the prelude as per the decision in https://github.com/rust-lang/rust/issues/87228. stdarch and compiler-builtins are updated to work with the new, stable asm! and global_asm! macros.
2021-12-11Remove useless variant.Camille GILLOT-20/+1
2021-12-04Lint bare traits in AstConv.Camille GILLOT-10/+0
2021-11-06Improve terminology around "after typeck"pierwill-1/+1
2021-11-04Optimize literal, doc comment lint as well, extract function.Hans Kratz-2/+2
2021-10-31Lint against RTL unicode codepoints in literals and commentsEsteban Küber-1/+38
Address CVE-2021-42574.
2021-10-28Revert "Add rustc lint, warning when iterating over hashmaps"Mark Rousskov-5/+2
2021-10-15allow `potential_query_instability` everywherelcnr-2/+5
2021-09-28rustc_session: Remove lint store from `Session`Vadim Petrochenkov-15/+0
2021-09-26Pass real crate-level attributes to `pre_expansion_lint`Samuel Moelius-1/+2
2021-09-02ty::layout: split `LayoutOf` into required and (blanket) provided halves.Eduard-Mihai Burtescu-2/+2
2021-09-02ty::layout: implement `layout_of` automatically as a default method.Eduard-Mihai Burtescu-2/+3
2021-09-02rustc_target: move `LayoutOf` to `ty::layout`.Eduard-Mihai Burtescu-5/+4
2021-08-27rustc_target: require `TyAbiInterface` in `LayoutOf`.Eduard-Mihai Burtescu-1/+22
2021-08-27rustc_target: add lifetime parameter to `LayoutOf`.Eduard-Mihai Burtescu-1/+1
2021-08-18Error when warnings lint group is used with force-warnRyan Levick-1/+10
2021-08-04Fix lint capitalization and ignoring, test with include_strasquared31415-1/+1
2021-08-04Lint against named asm labelsasquared31415-0/+4
2021-08-03Use a multipart suggestion for the parenthesesFabian Wolff-3/+6