about summary refs log tree commit diff
path: root/compiler/rustc_passes/src/entry.rs
AgeCommit message (Collapse)AuthorLines
2025-03-28use `slice::contains` where applicableYotam Ofek-1/+1
2025-03-12Move methods from `Map` to `TyCtxt`, part 4.Nicholas Nethercote-3/+3
Continuing the work from #137350. Removes the unused methods: `expect_variant`, `expect_field`, `expect_foreign_item`. Every method gains a `hir_` prefix.
2025-02-24Change span field accesses to method callsJana Dönszelmann-1/+1
2025-02-17Move some `Map` methods onto `TyCtxt`.Nicholas Nethercote-1/+1
The end goal is to eliminate `Map` altogether. I added a `hir_` prefix to all of them, that seemed simplest. The exceptions are `module_items` which became `hir_module_free_items` because there was already a `hir_module_items`, and `items` which became `hir_free_items` for consistency with `hir_module_free_items`.
2025-01-21remove support for the #[start] attributeRalf Jung-23/+4
2024-12-18Re-export more `rustc_span::symbol` things from `rustc_span`.Nicholas Nethercote-2/+1
`rustc_span::symbol` defines some things that are re-exported from `rustc_span`, such as `Symbol` and `sym`. But it doesn't re-export some closely related things such as `Ident` and `kw`. So you can do `use rustc_span::{Symbol, sym}` but you have to do `use rustc_span::symbol::{Ident, kw}`, which is inconsistent for no good reason. This commit re-exports `Ident`, `kw`, and `MacroRulesNormalizedIdent`, and changes many `rustc_span::symbol::` qualifiers in `compiler/` to `rustc_span::`. This is a 200+ net line of code reduction, mostly because many files with two `use rustc_span` items can be reduced to one.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-3/+3
2024-08-10rustc_passes: remove a redundant `#[allow(rustc::untranslatable_diagnostic)]`Pavel Grigorenko-1/+0
2024-07-29Reformat `use` declarations.Nicholas Nethercote-2/+2
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-05-04Various improvements to entrypoint codeNilstrieb-19/+23
This moves some code around and adds some documentation comments to make it easier to understand what's going on with the entrypoint logic, which is a bit complicated. The only change in behavior is consolidating the error messages for unix_sigpipe to make the code slightly simpler.
2024-05-02Change `SIGPIPE` ui from `#[unix_sigpipe = "..."]` to `-Zon-broken-pipe=...`Martin Nordholts-33/+10
In the stabilization attempt of `#[unix_sigpipe = "sig_dfl"]`, a concern was raised related to using a language attribute for the feature: Long term, we want `fn lang_start()` to be definable by any crate, not just libstd. Having a special language attribute in that case becomes awkward. So as a first step towards towards the next stabilization attempt, this PR changes the `#[unix_sigpipe = "..."]` attribute to a compiler flag `-Zon-broken-pipe=...` to remove that concern, since now the language is not "contaminated" by this feature. Another point was also raised, namely that the ui should not leak **how** it does things, but rather what the **end effect** is. The new flag uses the proposed naming. This is of course something that can be iterated on further before stabilization.
2024-03-28Make local_crate_source_file return a RealFileNameUrgau-4/+9
so it can be remapped (or not) by callers
2024-03-18Rollup merge of #122060 - clubby789:stabilize-imported-main, r=lcnrMatthias Krüger-11/+0
Stabilize `imported_main` FCP: https://github.com/rust-lang/rust/issues/28937#issuecomment-1977822831 Docs: https://github.com/rust-lang/reference/pull/1461
2024-03-14hir: Remove `opt_local_def_id_to_hir_id` and `opt_hir_node_by_def_id`Vadim Petrochenkov-1/+1
Also replace a few `hir_node()` calls with `hir_node_by_def_id()`
2024-03-10diagnostics: Do not suggest using `#[unix_sigpipe]` without a valueMartin Nordholts-4/+4
Remove `Word` from the `unix_sigpipe` attribute template so that plain `#[unix_sigpipe]` is not included in suggestions of valid forms of the attribute. Also re-arrange diagnostics code slightly to avoid duplicate diagnostics.
2024-03-06Stabilize `imported_main`clubby789-11/+0
2024-03-06Rewrite the `untranslatable_diagnostic` lint.Nicholas Nethercote-0/+1
Currently it only checks calls to functions marked with `#[rustc_lint_diagnostics]`. This commit changes it to check calls to any function with an `impl Into<{D,Subd}iagMessage>` parameter. This greatly improves its coverage and doesn't rely on people remembering to add `#[rustc_lint_diagnostics]`. The commit also adds `#[allow(rustc::untranslatable_diagnostic)`] attributes to places that need it that are caught by the improved lint. These places that might be easy to convert to translatable diagnostics. Finally, it also: - Expands and corrects some comments. - Does some minor formatting improvements. - Adds missing `DecorateLint` cases to `tests/ui-fulldeps/internal-lints/diagnostics.rs`.
2024-01-29Stop using `String` for error codes.Nicholas Nethercote-3/+3
Error codes are integers, but `String` is used everywhere to represent them. Gross! This commit introduces `ErrCode`, an integral newtype for error codes, replacing `String`. It also introduces a constant for every error code, e.g. `E0123`, and removes the `error_code!` macro. The constants are imported wherever used with `use rustc_errors::codes::*`. With the old code, we have three different ways to specify an error code at a use point: ``` error_code!(E0123) // macro call struct_span_code_err!(dcx, span, E0123, "msg"); // bare ident arg to macro call \#[diag(name, code = "E0123")] // string struct Diag; ``` With the new code, they all use the `E0123` constant. ``` E0123 // constant struct_span_code_err!(dcx, span, E0123, "msg"); // constant \#[diag(name, code = E0123)] // constant struct Diag; ``` The commit also changes the structure of the error code definitions: - `rustc_error_codes` now just defines a higher-order macro listing the used error codes and nothing else. - Because that's now the only thing in the `rustc_error_codes` crate, I moved it into the `lib.rs` file and removed the `error_codes.rs` file. - `rustc_errors` uses that macro to define everything, e.g. the error code constants and the `DIAGNOSTIC_TABLES`. This is in its new `codes.rs` file.
2024-01-14Rework how diagnostic lints are stored.Nicholas Nethercote-2/+2
`Diagnostic::code` has the type `DiagnosticId`, which has `Error` and `Lint` variants. Plus `Diagnostic::is_lint` is a bool, which should be redundant w.r.t. `Diagnostic::code`. Seems simple. Except it's possible for a lint to have an error code, in which case its `code` field is recorded as `Error`, and `is_lint` is required to indicate that it's a lint. This is what happens with `derive(LintDiagnostic)` lints. Which means those lints don't have a lint name or a `has_future_breakage` field because those are stored in the `DiagnosticId::Lint`. It's all a bit messy and confused and seems unintentional. This commit: - removes `DiagnosticId`; - changes `Diagnostic::code` to `Option<String>`, which means both errors and lints can straightforwardly have an error code; - changes `Diagnostic::is_lint` to `Option<IsLint>`, where `IsLint` is a new type containing a lint name and a `has_future_breakage` bool, so all lints can have those, error code or not.
2024-01-13Add check for ui_testing via promoting parameters from `ParseSess` to `Session`George-lewis-1/+1
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-9/+9
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-12Move some methods from `tcx.hir()` to `tcx`zetanumbers-1/+1
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-11-21Fix `clippy::needless_borrow` in the compilerNilstrieb-1/+1
`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-10-13Format all the let chains in compilerMichael Goulet-2/+6
2023-10-01Factor out the two `entry_point_type` functions.Nicholas Nethercote-26/+7
They are very similar, and each one has a comment about the importance of being kept in sync with the other. This commit removes the duplication.
2023-08-13Remove reached_eof from ParseSessbjorn3-6/+0
It was only ever set in a function which isn't called anywhere.
2023-08-09rustc: Move `crate_types` from `Session` to `GlobalCtxt`Vadim Petrochenkov-1/+1
Removes a piece of mutable state. Follow up to #114578.
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-1/+1
2023-04-04Replace a lock with an atomicOli Scherer-1/+1
2023-04-01slighty simplify a few boolean expressions (clippy::nonminimal_bool)Matthias Krüger-1/+1
2023-03-22rustc: Remove unused `Session` argument from some attribute functionsVadim Petrochenkov-4/+5
2023-03-02rustc_middle: Remove trait `DefIdTree`Vadim Petrochenkov-1/+1
This trait was a way to generalize over both `TyCtxt` and `Resolver`, but now `Resolver` has access to `TyCtxt`, so this trait is no longer necessary.
2023-01-16Move compiler input and ouput paths into sessionOli Scherer-1/+1
2022-10-29Rename some `OwnerId` fields.Nicholas Nethercote-10/+10
spastorino noticed some silly expressions like `item_id.def_id.def_id`. This commit renames several `def_id: OwnerId` fields as `owner_id`, so those expressions become `item_id.owner_id.def_id`. `item_id.owner_id.local_def_id` would be even clearer, but the use of `def_id` for values of type `LocalDefId` is *very* widespread, so I left that alone.
2022-10-07migrate entry.rs to translateable diagnosticsNathan Stocks-90/+55
2022-09-24separate definitions and `HIR` ownersTakayuki Maeda-4/+4
fix a ui test use `into` fix clippy ui test fix a run-make-fulldeps test implement `IntoQueryParam<DefId>` for `OwnerId` use `OwnerId` for more queries change the type of `ParentOwnerIterator::Item` to `(OwnerId, OwnerNode)`
2022-08-28Support `#[unix_sigpipe = "inherit|sig_dfl|sig_ign"]` on `fn main()`Martin Nordholts-14/+42
This makes it possible to instruct libstd to never touch the signal handler for `SIGPIPE`, which makes programs pipeable by default (e.g. with `./your-program | head -n 1`) without `ErrorKind::BrokenPipe` errors.
2022-07-18avoid `Symbol` to `&str` conversionsTakayuki Maeda-1/+1
2022-06-25rustc_passes: De-duplicate more code with `fn throw_attr_err()`Martin Nordholts-12/+14
So we can re-use the code for other attributes later.
2022-06-22Fixup missing renames from `#[main]` to `#[rustc_main]`Martin Nordholts-5/+5
In fc357039f9 `#[main]` was removed and replaced with `#[rustc_main]`. In some place the rename was forgotten, which makes the current code confusing, because at first glance it seems that `#[main]` is still around. Perform the renames also in these places.
2022-05-14use opt_item_name to pattern match items with namesMiguel Guarniz-2/+2
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13avoid converting to DefId from LocalDefId when using queryMiguel Guarniz-1/+1
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13replace hir().def_kind for def_kind query in rustc_passesMiguel Guarniz-1/+1
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13optimize find_item to fetch Item only when neededMiguel Guarniz-26/+39
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13remove ItemLikeVisitor impl for EntryContextMiguel Guarniz-23/+8
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-02rustc: Panic by default in `DefIdTree::parent`Vadim Petrochenkov-1/+1
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-04-17Stop using CRATE_DEF_INDEX.Camille GILLOT-31/+22
`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.
2022-03-22use `format-args-capture` and remove unnecessary nested if blocks in some ↵Takayuki Maeda-29/+23
parts of rustc_passes break before the `&&` Update compiler/rustc_passes/src/check_const.rs Co-authored-by: bjorn3 <bjorn3@users.noreply.github.com>
2022-03-05Do not point at whole file missing `fn main`Esteban Kuber-3/+3
Only point at the end of the crate. We could try making it point at the beginning of the crate, but that is confused with `DUMMY_SP`, causing the output to be *worse*. This change will make it so that VSCode will *not* underline the whole file when `main` is missing, so other errors will be visible.
2022-01-15Reduce use of local_def_id_to_hir_id.Camille GILLOT-3/+2