about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/util
AgeCommit message (Collapse)AuthorLines
2025-03-30Remove attribute `#[rustc_error]`Vadim Petrochenkov-1/+1
2025-02-11Simplify intra-crate qualifiers.Nicholas Nethercote-4/+4
The following is a weird pattern for a file within `rustc_middle`: ``` use rustc_middle::aaa; use crate::bbb; ``` More sensible and standard would be this: ``` use crate::{aaa, bbb}; ``` I.e. we generally prefer using `crate::` to using a crate's own name. (Exceptions are things like in macros where `crate::` doesn't work because the macro is used in multiple crates.) This commit fixes a bunch of these weird qualifiers.
2025-01-31Overhaul `to_readable_str`.Nicholas Nethercote-37/+0
It's a function that prints numbers with underscores inserted for readability (e.g. "1_234_567"), used by `-Zmeta-stats` and `-Zinput-stats`. It's the only thing in `rustc_middle::util::common`, which is a bizarre location for it. This commit: - moves it to `rustc_data_structures`, a more logical crate for it; - puts it in a module `thousands`, like the similar crates.io crate; - renames it `format_with_underscores`, which is a clearer name; - rewrites it to be more concise; - slightly improves the testing.
2025-01-31Move `find_self_call`.Nicholas Nethercote-50/+0
It's a function that does stuff with MIR and yet it weirdly has its own module in `rustc_middle::util`. This commit moves it into `rustc_middle::mir`, a more sensible home.
2025-01-31Give a better explanation for having `bug_fmt` and `span_bug_fmt`.Nicholas Nethercote-3/+3
2025-01-13Assert that Instance::try_resolve is only used on body-like thingsMichael Goulet-151/+0
2025-01-06Improve find_self_call with reborrowed receiverMichael Goulet-19/+22
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-11-22Get rid of HIR const checkerMichael Goulet-0/+7
2024-11-18use `TypingEnv` when no `infcx` is availablelcnr-4/+4
the behavior of the type system not only depends on the current assumptions, but also the currentnphase of the compiler. This is mostly necessary as we need to decide whether and how to reveal opaque types. We track this via the `TypingMode`.
2024-11-04ty::KContainer -> ty::AssocItemContainer::KMichael Goulet-2/+2
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-5/+5
2024-09-03Move `MirPass` to `rustc_mir_transform`.Nicholas Nethercote-16/+0
Because that's now the only crate that uses it. Moving stuff out of `rustc_middle` is always welcome. I chose to use `impl crate::MirPass`/`impl crate::MirLint` (with explicit `crate::`) everywhere because that's the only mention of `MirPass`/`MirLint` used in all of these files. (Prior to this change, `MirPass` was mostly imported via `use rustc_middle::mir::*` items.)
2024-07-29Reformat `use` declarations.Nicholas Nethercote-8/+10
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-19Avoid ref when using format! in compilerYuri Astrakhan-1/+1
Clean up a few minor refs in `format!` macro, as it has a performance cost. Apparently the compiler is unable to inline `format!("{}", &variable)`, and does a run-time double-reference instead (format macro already does one level referencing). Inlining format args prevents accidental `&` misuse.
2024-07-02Instance::resolve -> Instance::try_resolve, and other nitsMichael Goulet-1/+1
2024-06-14Use is_lang_item more aggressivelyMichael Goulet-4/+4
2024-05-23Remove `#[macro_use] extern crate tracing` from `rustc_middle`.Nicholas Nethercote-0/+2
2024-04-13remove some ancient debug output, looks unused?klensy-15/+0
2024-04-12remove dead codeklensy-30/+0
2024-03-19Make span_bug panic site useful againOli Scherer-8/+11
2024-02-12Tweak delayed bug mentions.Nicholas Nethercote-6/+6
Now that we have both `delayed_bug` and `span_delayed_bug`, it makes sense to use the generic term "delayed bug" more.
2024-02-07MirPass: make name more constklensy-0/+16
2024-01-15compiler: Lower fn call arg spans down to MIRMartin Nordholts-1/+8
To enable improved accuracy of diagnostics in upcoming commits.
2023-12-24Remove `Session` methods that duplicate `DiagCtxt` methods.Nicholas Nethercote-3/+3
Also add some `dcx` methods to types that wrap `TyCtxt`, for easier access.
2023-12-18Rename `Session::span_diagnostic` as `Session::dcx`.Nicholas Nethercote-2/+2
2023-12-02Rename `HandlerInner::delay_span_bug` as `HandlerInner::span_delayed_bug`.Nicholas Nethercote-6/+6
Because the corresponding `Level` is `DelayedBug` and `span_delayed_bug` follows the pattern used everywhere else: `span_err`, `span_warning`, etc.
2023-09-22Merge `ExternProviders` into the general `Providers` structOli Scherer-0/+1
2023-09-22Have a single struct for queries and hookOli Scherer-0/+23
2023-09-21rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::ConstRalf Jung-2/+2
2023-07-30inline format!() args up to and including rustc_middleMatthias Krüger-2/+2
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-18/+18
2023-05-15Move expansion of query macros in rustc_middle to rustc_middle::queryJohn Kåre Alsaker-2/+2
2023-05-03Restrict `From<S>` for `{D,Subd}iagnosticMessage`.Nicholas Nethercote-2/+2
Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into<String>`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile.
2023-04-27Don't call await a methodMichael Goulet-0/+5
2023-04-16Move some utils out of `rustc_const_eval`Nilstrieb-0/+180
This allows us to get rid of the `rustc_const_eval->rustc_borrowck` dependency edge which was delaying the compilation of borrowck. The added utils in `rustc_middle` are small and should not affect compile times there.
2022-12-30Add some docs to `bug`, `span_bug` and `delay_span_bug`Nilstrieb-2/+1
2022-04-05span: move `MultiSpan`David Wood-1/+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>
2021-11-09Use AddAssign implest31-1/+1
2021-02-03Make panic/assert calls in rustc compatible with Rust 2021.Mara Bos-2/+2
2020-12-29Add `#[track_caller]` to `bug!` and `register_renamed`Joshua Nelson-0/+1
Before: ``` thread 'rustc' panicked at 'compiler/rustc_lint/src/context.rs:267:18: invalid lint renaming of broken_intra_doc_links to rustdoc::broken_intra_doc_links', compiler/rustc_middle/src/util/bug.rs:34:26 ``` After: ``` thread 'rustc' panicked at 'src/librustdoc/core.rs:455:24: invalid lint renaming of broken_intra_doc_links to rustdoc::broken_intra_doc_links', compiler/rustc_middle/src/util/bug.rs:35:26 ``` The reason I added it to `register_renamed` too is that any panic in that function will be the caller's fault.
2020-09-26Remove unused #[allow(...)] statements from compiler/est31-2/+0
2020-08-30mv compiler to compiler/mark-0/+135