about summary refs log tree commit diff
path: root/compiler/rustc_passes/src
AgeCommit message (Collapse)AuthorLines
2024-01-06rustc_span: Optimize syntax context comparisonsVadim Petrochenkov-1/+1
Including comparisons with root context
2024-01-05Auto merge of #119634 - matthiaskrgr:rollup-v2xt7et, r=matthiaskrgrbors-15/+6
Rollup of 8 pull requests Successful merges: - #119151 (Hide foreign `#[doc(hidden)]` paths in import suggestions) - #119350 (Imply outlives-bounds on lazy type aliases) - #119354 (Make `negative_bounds` internal & fix some of its issues) - #119506 (Use `resolutions(()).effective_visiblities` to avoid cycle errors in `report_object_error`) - #119554 (Fix scoping for let chains in match guards) - #119563 (Check yield terminator's resume type in borrowck) - #119589 (cstore: Remove unnecessary locking from `CrateMetadata`) - #119622 (never patterns: Document behavior of never patterns with macros-by-example) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-05Rollup merge of #119554 - matthewjasper:remove-guard-distinction, ↵Matthias Krüger-15/+6
r=compiler-errors Fix scoping for let chains in match guards If let guards were previously represented as a different type of guard in HIR and THIR. This meant that let chains in match guards were not handled correctly because they were treated exactly like normal guards. - Remove `hir::Guard` and `thir::Guard`. - Make the scoping different between normal guards and if let guards also check for let chains. closes #118593
2024-01-05Auto merge of #119192 - michaelwoerister:mcp533-push, r=cjgillotbors-10/+9
Replace a number of FxHashMaps/Sets with stable-iteration-order alternatives This PR replaces almost all of the remaining `FxHashMap`s in query results with either `FxIndexMap` or `UnordMap`. The only case that is missing is the `EffectiveVisibilities` struct which turned out to not be straightforward to transform. Once that is done too, we can remove the `HashStable` implementation from `HashMap`. The first commit adds the `StableCompare` trait which is a companion trait to `StableOrd`. Some types like `Symbol` can be compared in a cross-session stable way, but their `Ord` implementation is not stable. In such cases, a `StableCompare` implementation can be provided to offer a lightweight way for stable sorting. The more heavyweight option is to sort via `ToStableHashKey`, but then sorting needs to have access to a stable hashing context and `ToStableHashKey` can also be expensive as in the case of `Symbol` where it has to allocate a `String`. The rest of the commits are rather mechanical and don't overlap, so they are best reviewed individually. Part of [MCP 533](https://github.com/rust-lang/compiler-team/issues/533).
2024-01-05Rollup merge of #119538 - nnethercote:cleanup-errors-5, r=compiler-errorsMichael Goulet-22/+22
Cleanup error handlers: round 5 More rustc_errors cleanups. A sequel to https://github.com/rust-lang/rust/pull/119171. r? ````@compiler-errors````
2024-01-05Remove `hir::Guard`Matthew Jasper-15/+6
Use Expr instead. Use `ExprKind::Let` to represent if let guards.
2024-01-05Auto merge of #118297 - shepmaster:warn-dead-tuple-fields, r=WaffleLapkinbors-23/+35
Merge `unused_tuple_struct_fields` into `dead_code` This implicitly upgrades the lint from `allow` to `warn` and places it into the `unused` lint group. [Discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Moving.20.60unused_tuple_struct_fields.60.20from.20allow.20to.20warn)
2024-01-04Address review comments and add back some #[inline] attrs from removed commits.Michael Woerister-2/+0
2024-01-04Replace a number of FxHashMaps/Sets with stable-iteration-order alternatives.Michael Woerister-8/+9
2024-01-03Rename some `Diagnostic` setters.Nicholas Nethercote-22/+22
`Diagnostic` has 40 methods that return `&mut Self` and could be considered setters. Four of them have a `set_` prefix. This doesn't seem necessary for a type that implements the builder pattern. This commit removes the `set_` prefixes on those four methods.
2024-01-02Merge `unused_tuple_struct_fields` into `dead_code`Jake Goulding-23/+35
This implicitly upgrades the lint from `allow` to `warn` and places it into the `unused` lint group.
2023-12-30is_coroutine -> is_coroutine_or_closureMichael Goulet-1/+1
2023-12-29Rollup merge of #119402 - est31:fix_if_guard_unused, r=compiler-errorsMatthias Krüger-0/+3
Also walk bindings created by if-let guards This change makes the `unused_variables` lint pick up unused bindings created by if-let guards. Fixes #119383
2023-12-29Also walk bindings created by if-let guardsest31-0/+3
2023-12-28Use `Pat::walk_always` instead of manual walkNilstrieb-29/+6
2023-12-27move walk_expr outside of every match branchzetanumbers-8/+2
2023-12-26Rollup merge of #119297 - cjgillot:issue-119267, r=petrochenkovMichael Goulet-62/+46
Pass DeadItem and lint as consistent group in dead-code. Fixes https://github.com/rust-lang/rust/issues/119267
2023-12-26Auto merge of #119258 - compiler-errors:closure-kind, r=eholkbors-10/+9
Make closures carry their own ClosureKind Right now, we use the "`movability`" field of `hir::Closure` to distinguish a closure and a coroutine. This is paired together with the `CoroutineKind`, which is located not in the `hir::Closure`, but the `hir::Body`. This is strange and redundant. This PR introduces `ClosureKind` with two variants -- `Closure` and `Coroutine`, which is put into `hir::Closure`. The `CoroutineKind` is thus removed from `hir::Body`, and `Option<Movability>` no longer needs to be a stand-in for "is this a closure or a coroutine". r? eholk
2023-12-25Only regular coroutines have movabilityMichael Goulet-7/+4
2023-12-25Make closures carry their own ClosureKind, rather than deducing what it is ↵Michael Goulet-10/+12
from movability
2023-12-25Pass DeadItem and lint as consistent group in dead-code.Camille GILLOT-62/+46
2023-12-24Remove more `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-1/+1
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-153/+168
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-22Auto merge of #119097 - nnethercote:fix-EmissionGuarantee, r=compiler-errorsbors-46/+28
Fix `EmissionGuarantee` There are some problems with the `DiagCtxt` API related to `EmissionGuarantee`. This PR fixes them. r? `@compiler-errors`
2023-12-19Add `level` arg to `into_diagnostic`.Nicholas Nethercote-46/+28
And make all hand-written `IntoDiagnostic` impls generic, by using `DiagnosticBuilder::new(dcx, level, ...)` instead of e.g. `dcx.struct_err(...)`. This means the `create_*` functions are the source of the error level. This change will let us remove `struct_diagnostic`. Note: `#[rustc_lint_diagnostics]` is added to `DiagnosticBuilder::new`, it's necessary to pass diagnostics tests now that it's used in `into_diagnostic` functions.
2023-12-18Replace some instances of FxHashMap/FxHashSet with stable alternatives ↵Michael Woerister-3/+0
(mostly in rustc_hir and rustc_ast_lowering) Part of https://github.com/rust-lang/compiler-team/issues/533
2023-12-18Rename many `DiagCtxt` arguments.Nicholas Nethercote-10/+10
2023-12-18Rename `Handler` as `DiagCtxt`.Nicholas Nethercote-5/+5
2023-12-15Fix enforcement of generics for associated itemsMichael Goulet-19/+27
2023-12-15banish hir::GenericBound::LangItemTraitMichael Goulet-1/+1
2023-12-15Collect lang items from ASTMichael Goulet-155/+245
2023-12-13Auto merge of #118870 - Enselic:rustc_passes-query-stability, r=compiler-errorsbors-1/+10
rustc_passes: Enforce `rustc::potential_query_instability` lint Stop allowing `rustc::potential_query_instability` in all of `rustc_passes` and instead allow it on a case-by-case basis if it is safe. In this case, all instances of the lint are safe to allow. Part of https://github.com/rust-lang/rust/issues/84447 which is E-help-wanted.
2023-12-12Move some methods from `tcx.hir()` to `tcx`zetanumbers-22/+21
Renamings: - find -> opt_hir_node - get -> hir_node - find_by_def_id -> opt_hir_node_by_def_id - get_by_def_id -> hir_node_by_def_id Fix rebase changes using removed methods Use `tcx.hir_node_by_def_id()` whenever possible in compiler Fix clippy errors Fix compiler Apply suggestions from code review Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com> Add FIXME for `tcx.hir()` returned type about its removal Simplify with with `tcx.hir_node_by_def_id`
2023-12-12rustc_passes: Enforce `rustc::potential_query_instability` lintMartin Nordholts-1/+10
Stop allowing `rustc::potential_query_instability` in all of `rustc_passes` and instead allow it on a case-by-case basis if it is safe. In this case, all instances of the lint are safe to allow.
2023-12-05Remove `#[rustc_host]`, use internal desugaringDeadbeef-2/+7
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-2/+2
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
2023-11-29Rollup merge of #118157 - Nadrieril:never_pat-feature-gate, r=compiler-errorsMatthias Krüger-1/+16
Add `never_patterns` feature gate This PR adds the feature gate and most basic parsing for the experimental `never_patterns` feature. See the tracking issue (https://github.com/rust-lang/rust/issues/118155) for details on the experiment. `@scottmcm` has agreed to be my lang-team liaison for this experiment.
2023-11-29Add `never_patterns` feature gateNadrieril-1/+16
2023-11-28Yeet E0744Michael Goulet-14/+4
2023-11-26rustc: `hir().local_def_id_to_hir_id()` -> `tcx.local_def_id_to_hir_id()` ↵Vadim Petrochenkov-14/+12
cleanup
2023-11-26Use `rustc_fluent_macro::fluent_messages!` directly.Nicholas Nethercote-2/+1
Currently we always do this: ``` use rustc_fluent_macro::fluent_messages; ... fluent_messages! { "./example.ftl" } ``` But there is no need, we can just do this everywhere: ``` rustc_fluent_macro::fluent_messages! { "./example.ftl" } ``` which is shorter.
2023-11-26Avoid need for `{D,Subd}iagnosticMessage` imports.Nicholas Nethercote-1/+0
The `fluent_messages!` macro produces uses of `crate::{D,Subd}iagnosticMessage`, which means that every crate using the macro must have this import: ``` use rustc_errors::{DiagnosticMessage, SubdiagnosticMessage}; ``` This commit changes the macro to instead use `rustc_errors::{D,Subd}iagnosticMessage`, which avoids the need for the imports.
2023-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-104/+104
`x clippy compiler -Aclippy::all -Wclippy::needless_borrow --fix`. Then I had to remove a few unnecessary parens and muts that were exposed now.
2023-11-20Store feature stability un-splitMichael Goulet-31/+23
2023-11-20Unify defined_lib_features and lib_features queriesMichael Goulet-44/+48
2023-11-15Re-format code with new rustfmtMark Rousskov-1/+4
2023-11-15Bump cfg(bootstrap)sMark Rousskov-3/+3
2023-11-14Fix some typoscui fliter-1/+1
Signed-off-by: cui fliter <imcusg@gmail.com>
2024-01-25Remove unused featuresclubby789-2/+0
2024-01-23Rename `TyCtxt::emit_spanned_lint` as `TyCtxt::emit_node_span_lint`.Nicholas Nethercote-58/+58