summary refs log tree commit diff
path: root/compiler/rustc_query_system
AgeCommit message (Collapse)AuthorLines
2024-10-01add unstable support for outputting file checksums for use in cargoJacob Kiesel-0/+2
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-13/+13
2024-09-02chore: Fix typos in 'compiler' (batch 2)Alexander Cyon-1/+1
2024-08-29Add `warn(unreachable_pub)` to `rustc_query_system`.Nicholas Nethercote-10/+11
2024-08-20fix: simple typo in compiler directoryc8ef-1/+1
2024-08-19Prevent double panic in query system, improve diagnosticsFelix Rath-2/+9
2024-08-07Use more slice patterns inside the compilerLeón Orell Valerian Liehr-6/+5
2024-08-02chore: use shorthand initializerYuri Astrakhan-1/+1
2024-07-29Reformat `use` declarations.Nicholas Nethercote-83/+89
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-18Be more accurate about calculating `display_col` from a `BytePos`Esteban Küber-6/+0
No longer track "zero-width" chars in `SourceMap`, read directly from the line when calculating the `display_col` of a `BytePos`. Move `char_width` to `rustc_span` and use it from the emitter. This change allows the following to properly align in terminals (depending on the font, the replaced control codepoints are rendered as 1 or 2 width, on my terminal they are rendered as 1, on VSCode text they are rendered as 2): ``` error: this file contains an unclosed delimiter --> $DIR/issue-68629.rs:5:17 | LL | ␜␟ts␀![{i | -- unclosed delimiter | | | unclosed delimiter LL | ␀␀ fn rݻoa>rݻm | ^ ```
2024-07-15Use dep: for crate dependenciesMichael Goulet-1/+1
2024-07-12enable fuzzing of `SearchGraph`lcnr-1/+1
fully move it into `rustc_type_ir` and make it independent of `Interner`.
2024-06-25Auto merge of #126326 - eggyal:ununsafe-StableOrd, r=michaelwoeristerbors-1/+4
Un-unsafe the `StableOrd` trait Whilst incorrect implementations of this trait can cause miscompilation, they cannot cause memory unsafety in rustc. [Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Policy.20of.20.60unsafe.60.20within.20the.20compiler). cc [MCP 533](https://github.com/rust-lang/compiler-team/issues/533), #105175, `@michaelwoerister` r? `@Nilstrieb`
2024-06-22Ensure careful consideration is given by implsAlan Egerton-0/+3
Added an associated `const THIS_IMPLEMENTATION_HAS_BEEN_TRIPLE_CHECKED` to the `StableOrd` trait to ensure that implementors carefully consider whether the trait's contract is upheld, as incorrect implementations can cause miscompilations.
2024-06-19Allow for try_force_from_dep_node to failMichael Baikov-7/+11
The way it is implemented currently try_force_from_dep_node returns true as long as there's a function to force the query. It wasn't this way from the beginning, earlier version was producing forcing result and it was changed in https://github.com/rust-lang/rust/pull/89978, I couldn't find any comments addressing this change. One way it can fail is by failing to recover the query in DepNodeParams::recover - when we are trying to query something that no longer exists in the current environment
2024-06-18Use a dedicated type instead of a reference for the diagnostic contextOli Scherer-2/+2
This paves the way for tracking more state (e.g. error tainting) in the diagnostic context handle
2024-06-12Un-unsafe the `StableOrd` traitAlan Egerton-1/+1
Whilst incorrect implementations of this trait can cause miscompilation, they cannot cause memory unsafety in rustc.
2024-06-12Use `tidy` to sort crate attributes for all compiler crates.Nicholas Nethercote-2/+4
We already do this for a number of crates, e.g. `rustc_middle`, `rustc_span`, `rustc_metadata`, `rustc_span`, `rustc_errors`. For the ones we don't, in many cases the attributes are a mess. - There is no consistency about order of attribute kinds (e.g. `allow`/`deny`/`feature`). - Within attribute kind groups (e.g. the `feature` attributes), sometimes the order is alphabetical, and sometimes there is no particular order. - Sometimes the attributes of a particular kind aren't even grouped all together, e.g. there might be a `feature`, then an `allow`, then another `feature`. This commit extends the existing sorting to all compiler crates, increasing consistency. If any new attribute line is added there is now only one place it can go -- no need for arbitrary decisions. Exceptions: - `rustc_log`, `rustc_next_trait_solver` and `rustc_type_ir_macros`, because they have no crate attributes. - `rustc_codegen_gcc`, because it's quasi-external to rustc (e.g. it's ignored in `rustfmt.toml`).
2024-06-06Make the panic info more usefulOli Scherer-2/+1
2024-05-21Add a footer in FileEncoder and check for it in MemDecoderBen Kimock-7/+3
2024-05-03Remove some unneeded `Cargo.toml` dependencies.Nicholas Nethercote-1/+0
I found these with a hacky shell script.
2024-04-30Remove `extern crate tracing` from numerous crates.Nicholas Nethercote-6/+5
2024-04-29Remove `extern crate rustc_data_structures` from `rustc_query_system`.Nicholas Nethercote-18/+19
2024-04-29Remove `extern crate rustc_macros` from numerous crates.Nicholas Nethercote-4/+4
2024-04-22Rollup merge of #124252 - michaelwoerister:better-forbidden-read-ice, r=oli-obkGuillaume Gomez-1/+44
Improve ICE message for forbidden dep-graph reads. The new message mentions the main context that the ICE might occur in and it mentions the query/dep-node that is being read. cc https://github.com/rust-lang/rust/pull/123781, where this would have been helpful.
2024-04-22Stabilize generic `NonZero`.Markus Reiter-1/+0
2024-04-22Add more context to the forbidden dep-graph read ICE error message.Michael Woerister-1/+5
2024-04-22Improve ICE message for forbidden dep-graph reads.Michael Woerister-1/+40
2024-04-11remove some things that do not need to beMatthias Krüger-6/+1
2024-04-06Remove sharding for VecCacheMark Rousskov-13/+6
This sharding is never used (per the comment in code). If we re-add sharding at some point in the future this is cheap to restore, but for now no need for the extra complexity.
2024-04-05Auto merge of #122070 - Zoxc:dep-edges-from-previous, r=cjgillotbors-43/+179
Encode dep graph edges directly from the previous graph when promoting This encodes dep graph edges directly from the previous graph when promoting nodes from a previous session, avoiding allocations / copies. ~~Based on https://github.com/rust-lang/rust/pull/122064 and https://github.com/rust-lang/rust/pull/116375.~~ <table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check:unchanged</td><td align="right">0.4177s</td><td align="right">0.4072s</td><td align="right">💚 -2.52%</td></tr><tr><td>🟣 <b>hyper</b>:check:unchanged</td><td align="right">0.1430s</td><td align="right">0.1420s</td><td align="right"> -0.69%</td></tr><tr><td>🟣 <b>regex</b>:check:unchanged</td><td align="right">0.3106s</td><td align="right">0.3038s</td><td align="right">💚 -2.19%</td></tr><tr><td>🟣 <b>syn</b>:check:unchanged</td><td align="right">0.5823s</td><td align="right">0.5688s</td><td align="right">💚 -2.33%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check:unchanged</td><td align="right">1.3992s</td><td align="right">1.3692s</td><td align="right">💚 -2.14%</td></tr><tr><td>Total</td><td align="right">2.8528s</td><td align="right">2.7910s</td><td align="right">💚 -2.17%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9803s</td><td align="right">💚 -1.97%</td></tr></table>
2024-04-03rustc_index: Add a `ZERO` constant to index typesVadim Petrochenkov-1/+1
It is commonly used.
2024-03-26Remove `CacheSelector` trait now that we can use GATsOli Scherer-43/+1
2024-03-23Add some comments and do some renamesJohn Kåre Alsaker-4/+22
2024-03-23Encode dep graph edges directly from the previous graph when promotingJohn Kåre Alsaker-42/+160
2024-03-12Rollup merge of #122245 - saethlin:check-dep-graph-size, r=petrochenkovJubilee-3/+7
Detect truncated DepGraph files I suspect that the following issues are caused by truncated incr comp files: * https://github.com/rust-lang/rust/issues/120582 * https://github.com/rust-lang/rust/issues/121499 * https://github.com/rust-lang/rust/issues/122210 We fail with an allocation failure or capacity overflow in this case because we assume that the ending bytes of an DepGraph file are the lengths of arrays. If the file has somehow been truncated then the ending bytes are probably some of our varint encoding, which tries to eliminate zero bytes, so interpreting a random 8 bytes as an array length has a very high chance of producing a byte capacity over `isize::MAX`. Now theoretically since https://github.com/rust-lang/rust/pull/119510 merged I have fixed the out-of-disk issues and yet in https://github.com/rust-lang/rust/issues/120894#issuecomment-1945126700 I still see some decoding failures that look like out-of-disk ICEs, for example https://crater-reports.s3.amazonaws.com/beta-1.77-1/beta-2024-02-10/gh/scottfones.aoc_2022/log.txt So this PR should ensure that we get an ICE that clearly identifies if the file in question is truncated.
2024-03-10Auto merge of #122064 - Zoxc:dep-graph-encode-tweaks, r=cjgillotbors-74/+33
Dep node encoding cleanups This does some cleanups around dep node encoding. Performance change with `-Zthreads=2`: <table><tr><td rowspan="2">Benchmark</td><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th><td colspan="1"><b>Before</b></th><td colspan="2"><b>After</b></th></tr><tr><td align="right">Time</td><td align="right">Time</td><td align="right">%</th><td align="right">Memory</td><td align="right">Memory</td><td align="right">%</th></tr><tr><td>🟣 <b>clap</b>:check:unchanged</td><td align="right">0.4337s</td><td align="right">0.4306s</td><td align="right"> -0.72%</td><td align="right">88.90 MiB</td><td align="right">89.04 MiB</td><td align="right"> 0.15%</td></tr><tr><td>🟣 <b>hyper</b>:check:unchanged</td><td align="right">0.1541s</td><td align="right">0.1528s</td><td align="right"> -0.86%</td><td align="right">51.99 MiB</td><td align="right">52.03 MiB</td><td align="right"> 0.07%</td></tr><tr><td>🟣 <b>regex</b>:check:unchanged</td><td align="right">0.3286s</td><td align="right">0.3248s</td><td align="right">💚 -1.15%</td><td align="right">71.89 MiB</td><td align="right">71.74 MiB</td><td align="right"> -0.21%</td></tr><tr><td>🟣 <b>syn</b>:check:unchanged</td><td align="right">0.6118s</td><td align="right">0.6057s</td><td align="right">💚 -1.01%</td><td align="right">106.59 MiB</td><td align="right">106.66 MiB</td><td align="right"> 0.06%</td></tr><tr><td>🟣 <b>syntex_syntax</b>:check:unchanged</td><td align="right">1.4570s</td><td align="right">1.4463s</td><td align="right"> -0.74%</td><td align="right">197.29 MiB</td><td align="right">197.33 MiB</td><td align="right"> 0.02%</td></tr><tr><td>Total</td><td align="right">2.9852s</td><td align="right">2.9601s</td><td align="right"> -0.84%</td><td align="right">516.66 MiB</td><td align="right">516.80 MiB</td><td align="right"> 0.03%</td></tr><tr><td>Summary</td><td align="right">1.0000s</td><td align="right">0.9911s</td><td align="right"> -0.89%</td><td align="right">1 byte</td><td align="right">1.00 bytes</td><td align="right"> 0.02%</td></tr></table> r? `@cjgillot`
2024-03-09Detect truncated incr comp filesBen Kimock-3/+7
2024-03-09Some tweaks to the parallel query cycle handlerJohn Kåre Alsaker-16/+8
2024-03-06Avoid the double lock around `EncoderState`John Kåre Alsaker-17/+18
2024-03-06Remove profiling from `intern_node`John Kåre Alsaker-32/+5
2024-03-06Add a profiler reference to `GraphEncoder`John Kåre Alsaker-32/+17
2024-03-02Don't panic when waiting on poisoned queriesJohn Kåre Alsaker-3/+2
2024-02-29Overhaul how stashed diagnostics work, again.Nicholas Nethercote-2/+1
Stashed errors used to be counted as errors, but could then be cancelled, leading to `ErrorGuaranteed` soundness holes. #120828 changed that, closing the soundness hole. But it introduced other difficulties because you sometimes have to account for pending stashed errors when making decisions about whether errors have occured/will occur and it's easy to overlook these. This commit aims for a middle ground. - Stashed errors (not warnings) are counted immediately as emitted errors, avoiding the possibility of forgetting to consider them. - The ability to cancel (or downgrade) stashed errors is eliminated, by disallowing the use of `steal_diagnostic` with errors, and introducing the more restrictive methods `try_steal_{modify,replace}_and_emit_err` that can be used instead. Other things: - `DiagnosticBuilder::stash` and `DiagCtxt::stash_diagnostic` now both return `Option<ErrorGuaranteed>`, which enables the removal of two `delayed_bug` calls and one `Ty::new_error_with_message` call. This is possible because we store error guarantees in `DiagCtxt::stashed_diagnostics`. - Storing the guarantees also saves us having to maintain a counter. - Calls to the `stashed_err_count` method are no longer necessary alongside calls to `has_errors`, which is a nice simplification, and eliminates two more `span_delayed_bug` calls and one FIXME comment. - Tests are added for three of the four fixed PRs mentioned below. - `issue-121108.rs`'s output improved slightly, omitting a non-useful error message. Fixes #121451. Fixes #121477. Fixes #121504. Fixes #121508.
2024-02-28Rename `DiagnosticBuilder` as `Diag`.Nicholas Nethercote-4/+4
Much better! Note that this involves renaming (and updating the value of) `DIAGNOSTIC_BUILDER` in clippy.
2024-02-28Rename `Diagnostic` as `DiagInner`.Nicholas Nethercote-3/+3
I started by changing it to `DiagData`, but that didn't feel right. `DiagInner` felt much better.
2024-02-22Rollup merge of #121401 - eltociear:patch-25, r=nnethercoteMatthias Krüger-1/+1
Fix typo in serialized.rs accomodate -> accommodate
2024-02-22Adjust the `has_errors*` methods.Nicholas Nethercote-1/+1
Currently `has_errors` excludes lint errors. This commit changes it to include lint errors. The motivation for this is that for most places it doesn't matter whether lint errors are included or not. But there are multiple places where they must be includes, and only one place where they must not be included. So it makes sense for `has_errors` to do the thing that fits the most situations, and the new `has_errors_excluding_lint_errors` method in the one exceptional place. The same change is made for `err_count`. Annoyingly, this requires the introduction of `err_count_excluding_lint_errs` for one place, to preserve existing error printing behaviour. But I still think the change is worthwhile overall.
2024-02-22Fix typo in serialized.rsIkko Eltociear Ashimine-1/+1
accomodate -> accommodate
2024-02-15Use generic `NonZero` internally.Markus Reiter-2/+3