about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2023-09-11Disentangle `Debug` and `Display` for `Ty`.Nicholas Nethercote-15/+51
The `Debug` impl for `Ty` just calls the `Display` impl for `Ty`. This is surprising and annoying. In particular, it means `Debug` doesn't show as much information as `Debug` for `TyKind` does. And `Debug` is used in some user-facing error messages, which seems bad. This commit changes the `Debug` impl for `Ty` to call the `Debug` impl for `TyKind`. It also does a number of follow-up changes to preserve existing output, many of which involve inserting `with_no_trimmed_paths!` calls. It also adds `Display` impls for `UserType` and `Canonical`. Some tests have changes to expected output: - Those that use the `rustc_abi(debug)` attribute. - Those that use the `EMIT_MIR` annotation. In each case the output is slightly uglier than before. This isn't ideal, but it's pretty weird (particularly for the attribute) that the output is using `Debug` in the first place. They're fairly obscure attributes (I hadn't heard of them) so I'm not worried by this. For `async-is-unwindsafe.stderr`, there is one line that now lacks a full path. This is a consistency improvement, because all the other mentions of `Context` in this test lack a path.
2023-09-10Point out if a local trait has no implementationsMichael Goulet-0/+4
2023-09-10Implement fallback for effect paramDeadbeef-21/+115
2023-09-10Cache reachable_set on diskTomasz Miąsko-0/+1
2023-09-09Use `FreezeLock` for `CStore`John Kåre Alsaker-5/+3
2023-09-09fix ptr_metadata_ty for DynStar typeRalf Jung-1/+3
2023-09-09give extra context to ABI mismatch errorsRalf Jung-7/+12
2023-09-09Auto merge of #115657 - Zoxc:source-span-avoid-query, r=cjgillotbors-1/+1
Avoid a `source_span` query when encoding Spans into query results This avoids a `source_span` query when encoding `Span`s into query results. It's not sound to execute queries here as the query caches can be locked and the dep graph is no longer writable. r? `@cjgillot`
2023-09-08Auto merge of #115418 - Zoxc:freeze-source, r=oli-obkbors-1/+1
Use `Freeze` for `SourceFile` This uses the `Freeze` type in `SourceFile` to let accessing `external_src` and `lines` be lock-free. Behavior of `add_external_src` is changed to set `ExternalSourceKind::AbsentErr` on a hash mismatch which matches the documentation. `ExternalSourceKind::Unneeded` was removed as it's unused. Based on https://github.com/rust-lang/rust/pull/115401.
2023-09-08Auto merge of #115612 - cjgillot:const-prop-int, r=oli-obkbors-1/+13
Improvements to dataflow const-prop Partially cherry-picked from https://github.com/rust-lang/rust/pull/110719 r? `@oli-obk` cc `@jachris`
2023-09-08Rework no_coverage to coverage(off)Andy Caldwell-1/+1
2023-09-08Rollup merge of #115629 - compiler-errors:sugg-deref-unsize, r=oli-obkMatthias Krüger-11/+8
Don't suggest dereferencing to unsized type Rudimentary check that the self type is Sized. I don't really like any of this diagnostics code -- it's really messy and also really prone to false positives and negatives, but oh well. Fixes #115569
2023-09-08Rollup merge of #115624 - compiler-errors:rtn-path, r=WaffleLapkinMatthias Krüger-0/+11
Print the path of a return-position impl trait in trait when `return_type_notation` is enabled When we're printing a return-position impl trait in trait, we usually just print it like an opaque. This is *usually* fine, but can be confusing when using `return_type_notation`. Print the path of the method from where the RPITIT originates when this feature gate is enabled.
2023-09-08Avoid a `source_span` query when encoding Spans into query resultsJohn Kåre Alsaker-1/+1
2023-09-07Enable incremental-relative-spans by default.Camille GILLOT-1/+1
2023-09-07Use `Freeze` for `SourceFile.lines`John Kåre Alsaker-1/+1
2023-09-07Auto merge of #115582 - compiler-errors:refine-yeet, r=oli-obkbors-1/+1
Implement refinement lint for RPITIT Implements a lint that warns against accidentally refining an RPITIT in an implementation. This is not a hard error, and can be suppressed with `#[allow(refining_impl_trait)]`, since this behavior may be desirable -- the lint just serves as an acknowledgement from the impl author that they understand that the types they write in the implementation are an API guarantee. This compares bounds syntactically, not semantically -- semantic implication is more difficult and essentially relies on adding the ability to keep the RPITIT hidden in the trait system so that things can be proven about the type that shows up in the impl without its own bounds leaking through, either via a new reveal mode or something else. This was experimentally implemented in #111931. Somewhat opinionated choices: 1. Putting the lint behind `refining_impl_trait` rather than a blanket `refine` lint. This could be changed, but I like keeping the lint specialized to RPITITs so the explanation can be tailored to it. 2. This PR does not include the `#[refine]` attribute or the feature gate, since it's kind of orthogonal and can be added in a separate PR. r? `@oli-obk`
2023-09-07Ensure that dyn trait bounds stay sortedMichael Goulet-11/+8
2023-09-07Auto merge of #110050 - saethlin:better-u32-encoding, r=nnethercotebors-1/+17
Use a specialized varint + bitpacking scheme for DepGraph encoding The previous scheme here uses leb128 to encode the edge tables that represent the incr comp dependency graph. The problem with that scheme is that leb128 has overhead for larger values, and generally relies on the distribution of encoded values being heavily skewed towards smaller values. That is definitely not the case for a dep node index, since they are handed out sequentially and the whole range is covered, the distribution is actually biased in the opposite direction: Most dep nodes are large. This PR implements a different varint encoding scheme. Instead of applying varint encoding to individual dep node indices (which is extremely branchy) we now apply it per node. While being built, each node now stores its edges in a `SmallVec` with a bit of extra logic to track the max value of each edge. Then we varint encode the whole batch. This is a gamble: We save on space by only claiming 2 bits per node instead of ~3 bits per edge which is a nice savings but needs to balance out with the space overhead that a single large index in a node with a lot of edges will encode unnecessary bytes in each of that node's edge indices. Then, to keep the runtime overhead of this encoding scheme down we deserialize our indices by loading 4 bytes for each then masking off the bytes that are't ours. This is much less code and branches than leb128, but relies on having some readable bytes past the end of each edge list. We explicitly add such padding to the in-memory data during decoding. And we also do this decoding lazily, turning a dense on-disk encoding into a peak memory reduction. Then we apply a bit-packing scheme; since in https://github.com/rust-lang/rust/pull/115391 we now have unused bits on `DepKind`, we use those unused bits (currently there are 7!) to store the 2 bits that we need for the byte width of the edges in each node, then use the remaining bits to store the length of the edge list, if it fits. r? `@nnethercote`
2023-09-07Print the path of an RPITIT in RTNMichael Goulet-0/+11
2023-09-07Implement refinement lint for RPITITMichael Goulet-1/+1
2023-09-06Auto merge of #115615 - matthiaskrgr:rollup-49fosdf, r=matthiaskrgrbors-1/+1
Rollup of 9 pull requests Successful merges: - #114511 (Remove the unhelpful let binding diag comes from FormatArguments) - #115473 (Add explanatory note to 'expected item' error) - #115574 (Replace `rustc_data_structures` dependency with `rustc_index` in `rustc_parse_format`) - #115578 (Clarify cryptic comments) - #115587 (fix #115348) - #115596 (A small change) - #115598 (Fix log formatting in bootstrap) - #115605 (Better Debug for `Ty` in smir) - #115614 (Fix minor grammar typo) r? `@ghost` `@rustbot` modify labels: rollup
2023-09-06Rollup merge of #115578 - ouz-a:rustc_clarify, r=oli-obkMatthias Krüger-1/+1
Clarify cryptic comments Clarifies some unclear comments that lurked in the compiler. r? ``@oli-obk``
2023-09-06Auto merge of #115252 - cjgillot:mir-composite, r=davidtwcobors-112/+106
Represent MIR composite debuginfo as projections instead of aggregates Composite debuginfo for MIR is currently represented as ``` debug name => Type { projection1 => place1, projection2 => place2 }; ``` ie. a single `VarDebugInfo` object with that name, and its value a `VarDebugInfoContents::Composite`. This PR proposes to reverse the representation to be ``` debug name.projection1 => place1; debug name.projection2 => place2; ``` ie. multiple `VarDebugInfo` objects with each their projection. This simplifies the handling of composite debuginfo by the compiler by avoiding weird nesting. Based on https://github.com/rust-lang/rust/pull/115139
2023-09-06Support array length.Camille GILLOT-0/+7
2023-09-06Support a few more rvalues.Camille GILLOT-0/+5
2023-09-06Auto merge of #115401 - Zoxc:freeze, r=oli-obkbors-11/+11
Add `FreezeLock` type and use it to store `Definitions` This adds a `FreezeLock` type which allows mutation using a lock until the value is frozen where it can be accessed lock-free. It's used to store `Definitions` in `Untracked` instead of a `RwLock`. Unlike the current scheme of leaking read guards this doesn't deadlock if definitions is written to after no mutation are expected.
2023-09-06make comments less crypticouz-a-1/+1
2023-09-05Do not assert in try_to_int.Camille GILLOT-1/+1
2023-09-05Auto merge of #115507 - cjgillot:relative-source-file, r=oli-obkbors-2/+3
Use relative positions inside a SourceFile. This allows to remove the normalization of start positions for hashing, and simplify allocation of global address space. cc `@Zoxc`
2023-09-05Refactor how MIR represents composite debuginfo.Camille GILLOT-57/+37
2023-09-05Refactor projection debug.Camille GILLOT-55/+69
2023-09-05Rollup merge of #115536 - RalfJung:interpreter-privacy, r=oli-obkMatthias Krüger-1/+1
interpret: make MemPlace, Place, Operand types private to the interpreter Outside the interpreter, only the typed versions should be used.
2023-09-04Use a specialized varint + bitpacking scheme for DepGraph encodingBen Kimock-1/+17
2023-09-04interpret: make MemPlace, Place, Operand types private to the interpreterRalf Jung-1/+1
2023-09-04Add help to allow lint for the implied by suggestionUrgau-0/+3
2023-09-04Auto merge of #115391 - saethlin:depkind-discrim, r=nnethercotebors-1/+47
Encode DepKind as u16 The derived Encodable/Decodable impls serialize/deserialize as a varint, which results in a lot of code size around the encoding/decoding of these types which isn't justified: The full range of values here is rather small but doesn't quite fit in to a `u8`. Growing _all_ serialized `DepKind` to 2 bytes costs us on average 1% size in the incr comp dep graph, which I plan to recoup in https://github.com/rust-lang/rust/pull/110050 by taking advantage of the unused bits in all the serialized `DepKind`. r? `@nnethercote`
2023-09-03Encode DepKind as u16Ben Kimock-1/+47
2023-09-03Use relative positions inside a SourceFile.Camille GILLOT-2/+3
2023-09-02Add `Freeze` type and use it to store `Definitions`John Kåre Alsaker-11/+11
2023-09-02Auto merge of #115422 - Zoxc:cache-once-lock, r=cjgillotbors-6/+6
Use `OnceLock` for `SingleCache` This uses `OnceLock` for `SingleCache` instead of `Lock<Option<T>>` so lookups are lock-free. r? `@cjgillot`
2023-09-01Auto merge of #113126 - Bryanskiy:delete_old, r=petrochenkovbors-3/+0
Replace old private-in-public diagnostic with type privacy lints Next part of RFC https://github.com/rust-lang/rust/issues/48054. r? `@petrochenkov`
2023-09-01Use `OnceLock` for `SingleCache`John Kåre Alsaker-6/+6
2023-08-30Don't record spans for predicates in coherenceMichael Goulet-1/+1
2023-08-30Pretty-print impl trait to name it.Camille GILLOT-4/+0
2023-08-30move marking-locals-live out of push_stack_frame, so it happens with ↵Ralf Jung-0/+2
argument passing this entirely avoids even creating unsized locals in Immediate::Uninitialized state
2023-08-30Rollup merge of #115313 - gurry:issue-114918-cycle-detected, r=compiler-errorsMatthias Krüger-1/+12
Make `get_return_block()` return `Some` only for HIR nodes in body Fixes #114918 The issue occurred while compiling the following input: ```rust fn uwu() -> [(); { () }] { loop {} } ``` It was caused by the code below trying to suggest a missing return type which resulted in a const eval cycle: https://github.com/rust-lang/rust/blob/1bd043098e05839afb557bd7a2858cb09a4054ca/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs#L68-L75 The root cause was `get_return_block()` returning an `Fn` node for a node in the return type (i.e. the second `()` in the return type `[(); { () }]` of the input) although it is supposed to do so only for nodes that lie in the body of the function and return `None` otherwise (at least as per my understanding). The PR fixes the issue by fixing this behaviour of `get_return_block()`.
2023-08-30Make get_return_block() return Some only for HIR nodes in bodyGurinder Singh-1/+12
Fixes # 114918
2023-08-29Rollup merge of #111580 - atsuzaki:layout-ice, r=oli-obkMatthias Krüger-1/+9
Don't ICE on layout computation failure Fixes #111176 regression. r? `@oli-obk`
2023-08-29Auto merge of #114894 - Zoxc:sharded-cfg-cleanup2, r=cjgillotbors-19/+20
Remove conditional use of `Sharded` from query state `Sharded` is already a zero cost abstraction, so it shouldn't affect the performance of the single thread compiler if LLVM does its job. r? `@cjgillot`