Commit Graph

5676 Commits

Author SHA1 Message Date
Ralf Jung
57444cf9f3 use pretty_print_const_value from MIR constant 'extra' printing 2023-09-19 11:06:32 +02:00
Ralf Jung
10a822be38 move some MIR const pretty-printing into pretty.rs 2023-09-19 11:06:32 +02:00
Ralf Jung
49f5b17cdb more MIR const types to separate file 2023-09-19 11:06:27 +02:00
Michael Goulet
a30ad3a5a6 Don't resolve generic instances if they may be shadowed by dyn 2023-09-19 05:42:23 +00:00
Matthias Krüger
48c605129b
Rollup merge of #115873 - BoxyUwU:tykind_adt_debug, r=oli-obk
Make `TyKind::Adt`'s `Debug` impl be more pretty

Currently `{:?}` on `Ty` for a `TyKind::Adt` would print as `Adt(Foo, [])`. This PR changes it to be `Foo` when there are no generics or `Foo<T>`/`Foo<T, U>` when there _are_ generics. Example from debug log:
`├─0ms DEBUG rustc_hir_analysis::astconv return=Bar<T/#0, U/#1>`

I should have done this in my initial PR for a prettier TyKind: Debug impl but I thought I would need to be accessing generics_of to figure out where in the "path" the generics would have to go??? but no, adts literally only have a single place the generics can go (on the end). Feel a bit silly about this :)

r? `@oli-obk`
2023-09-19 01:29:41 +02:00
bors
cebb9cfd4f Auto merge of #115748 - RalfJung:post-mono, r=oli-obk
move required_consts check to general post-mono-check function

This factors some code that is common between the interpreter and the codegen backends into shared helper functions. Also as a side-effect the interpreter now uses the same `eval` functions as everyone else to get the evaluated MIR constants.

Also this is in preparation for another post-mono check that will be needed for (the current hackfix for) https://github.com/rust-lang/rust/issues/115709: ensuring that all locals are dynamically sized.

I didn't expect this to change diagnostics, but it's just cycle errors that change.

r? `@oli-obk`
2023-09-18 19:41:21 +00:00
Boxy
b2bf4b66f8 make more pretty 2023-09-18 17:29:13 +01:00
Matthias Krüger
0d29cdd187
Rollup merge of #115907 - RalfJung:interner-check, r=compiler-errors
nop_lift macros: ensure that we are using the right interner

Right now someone could put down the wrong list name when using these macros, and everything would still build. Nothing does a type-check to ensure that the `$set` contains element of type `Self::Lifted`. Let's fix that.

For lists this is fairly easy; for the other interners we need to unwrap some newtypes which makes this more complicated.
2023-09-18 13:02:19 +02:00
Matthias Krüger
944c4134d2
Rollup merge of #115838 - lcnr:added-goals, r=compiler-errors
inspect: closer to proof trees for coherence

a continuation of #115751. Now explicitly store the added goals

r? ```@compiler-errors```
2023-09-18 13:02:18 +02:00
Nicholas Nethercote
abe2a68acd Remove more unused Lift impls. 2023-09-18 09:37:10 +10:00
Nicholas Nethercote
af7d3e501b Remove unused Lift derives.
I found these by commenting out all `Lift` derives and then adding back
the ones that were necessary to successfully compile.
2023-09-18 09:37:10 +10:00
Nicholas Nethercote
6b1980f9cf Rename CloneLiftImpls as TrivialLiftImpls.
To match `TrivialTypeTraversalImpls` and
`TrivialTypeTraversalAndLiftImpls`, and because the `Clone` doesn't mean
anything.
2023-09-18 09:37:09 +10:00
Nicholas Nethercote
46fe65d0e5 Remove unused Display impls. 2023-09-18 09:37:09 +10:00
Nicholas Nethercote
1281d43942 Remove RegionHighlightMode::tcx.
It's easier to pass it in to the one method that needs it
(`highlighting_region_vid`) than to store it in the type. This means
`RegionHighlightMode` can impl `Default`.
2023-09-18 09:37:09 +10:00
Ralf Jung
3b817b2810 nop_lift macros: ensure that we are using the right interner 2023-09-17 20:52:15 +02:00
bors
327e6cf55c Auto merge of #114452 - weiznich:feature/diagnostic_on_unimplemented, r=compiler-errors
`#[diagnostic::on_unimplemented]` without filters

This commit adds support for a `#[diagnostic::on_unimplemented]` attribute with the following options:

* `message` to customize the primary error message
* `note` to add a customized note message to an error message
* `label` to customize the label part of the error message

The relevant behavior is specified in [RFC-3366](https://rust-lang.github.io/rfcs/3366-diagnostic-attribute-namespace.html)
2023-09-17 10:00:15 +00:00
Matthias Krüger
abae2b66e8
Rollup merge of #115884 - RalfJung:const-debug-print, r=oli-obk
make ty::Const debug printing less verbose

Similar in spirit to https://github.com/rust-lang/rust/pull/115873
2023-09-16 23:20:42 +02:00
Eduardo Sánchez Muñoz
21418429fd miri: reduce code duplication in SSE/SSE2 bin_op_* functions 2023-09-16 18:51:43 +02:00
Ralf Jung
5a3410ad1a make ty::Const debug printing less verbose 2023-09-16 16:31:09 +02:00
bors
41bafc4ff3 Auto merge of #110800 - GuillaumeGomez:custom_code_classes_in_docs, r=t-rustdoc
Accept additional user-defined syntax classes in fenced code blocks

Part of #79483.

This is a re-opening of https://github.com/rust-lang/rust/pull/79454 after a big update/cleanup. I also converted the syntax to pandoc as suggested by `@notriddle:` the idea is to be as compatible as possible with the existing instead of having our own syntax.

## Motivation

From the original issue: https://github.com/rust-lang/rust/issues/78917

> The technique used by `inline-c-rs` can be ported to other languages. It's just super fun to see C code inside Rust documentation that is also tested by `cargo doc`. I'm sure this technique can be used by other languages in the future.

Having custom CSS classes for syntax highlighting will allow tools like `highlight.js` to be used in order to provide highlighting for languages other than Rust while not increasing technical burden on rustdoc.

## What is the feature about?

In short, this PR changes two things, both related to codeblocks in doc comments in Rust documentation:

 * Allow to disable generation of `language-*` CSS classes with the `custom` attribute.
 * Add your own CSS classes to a code block so that you can use other tools to highlight them.

#### The `custom` attribute

Let's start with the new `custom` attribute: it will disable the generation of the `language-*` CSS class on the generated HTML code block. For example:

```rust
/// ```custom,c
/// int main(void) {
///     return 0;
/// }
/// ```
```

The generated HTML code block will not have `class="language-c"` because the `custom` attribute has been set. The `custom` attribute becomes especially useful with the other thing added by this feature: adding your own CSS classes.

#### Adding your own CSS classes

The second part of this feature is to allow users to add CSS classes themselves so that they can then add a JS library which will do it (like `highlight.js` or `prism.js`), allowing to support highlighting for other languages than Rust without increasing burden on rustdoc. To disable the automatic `language-*` CSS class generation, you need to use the `custom` attribute as well.

This allow users to write the following:

```rust
/// Some code block with `{class=language-c}` as the language string.
///
/// ```custom,{class=language-c}
/// int main(void) {
///     return 0;
/// }
/// ```
fn main() {}
```

This will notably produce the following HTML:

```html
<pre class="language-c">
int main(void) {
    return 0;
}</pre>
```

Instead of:

```html
<pre class="rust rust-example-rendered">
<span class="ident">int</span> <span class="ident">main</span>(<span class="ident">void</span>) {
    <span class="kw">return</span> <span class="number">0</span>;
}
</pre>
```

To be noted, we could have written `{.language-c}` to achieve the same result. `.` and `class=` have the same effect.

One last syntax point: content between parens (`(like this)`) is now considered as comment and is not taken into account at all.

In addition to this, I added an `unknown` field into `LangString` (the parsed code block "attribute") because of cases like this:

```rust
/// ```custom,class:language-c
/// main;
/// ```
pub fn foo() {}
```

Without this `unknown` field, it would generate in the DOM: `<pre class="language-class:language-c language-c">`, which is quite bad. So instead, it now stores all unknown tags into the `unknown` field and use the first one as "language". So in this case, since there is no unknown tag, it'll simply generate `<pre class="language-c">`. I added tests to cover this.

Finally, I added a parser for the codeblock attributes to make it much easier to maintain. It'll be pretty easy to extend.

As to why this syntax for adding attributes was picked: it's [Pandoc's syntax](https://pandoc.org/MANUAL.html#extension-fenced_code_attributes). Even if it seems clunkier in some cases, it's extensible, and most third-party Markdown renderers are smart enough to ignore Pandoc's brace-delimited attributes (from [this comment](https://github.com/rust-lang/rust/pull/110800#issuecomment-1522044456)).

## Raised concerns

#### It's not obvious when the `language-*` attribute generation will be added or not.

It is added by default. If you want to disable it, you will need to use the `custom` attribute.

#### Why not using HTML in markdown directly then?

Code examples in most languages are likely to contain `<`, `>`, `&` and `"` characters. These characters [require escaping](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre) when written inside the `<pre>` element. Using the \`\`\` code blocks allows rustdoc to take care of escaping, which means doc authors can paste code samples directly without manually converting them to HTML.

cc `@poliorcetics`
r? `@notriddle`
2023-09-16 13:10:11 +00:00
Ralf Jung
d34e15e740 thir::pattern: update some comments and error type names 2023-09-16 12:25:33 +02:00
bors
fd70f7eea2 Auto merge of #115740 - tmiasko:cache-reachable-set, r=cjgillot
Cache reachable_set on disk
2023-09-16 09:07:38 +00:00
Guillaume Gomez
6e21e4823d Fix incorrect codeblock attributes in docs 2023-09-15 21:32:29 +02:00
Ralf Jung
9ac8b363e3 don't point at const usage site for resolution-time errors
also share the code that emits the actual error
2023-09-14 22:34:05 +02:00
Ralf Jung
89ac57db4d move required_consts check to general post-mono-check function 2023-09-14 22:30:42 +02:00
bors
ccf817b9bb Auto merge of #115848 - matthiaskrgr:rollup-lsul9dz, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #115772 (Improve Span in smir)
 - #115832 (Fix the error message for `#![feature(no_coverage)]`)
 - #115834 (Properly consider binder vars in `HasTypeFlagsVisitor`)
 - #115844 (Paper over an accidental regression)

r? `@ghost`
`@rustbot` modify labels: rollup
2023-09-14 17:22:20 +00:00
Matthias Krüger
57370828b9
Rollup merge of #115834 - compiler-errors:binder-vars, r=jackh726
Properly consider binder vars in `HasTypeFlagsVisitor`

Given a PolyTraitRef like `for<'a> Ty: Trait` (where neither `Ty` nor `Trait` mention `'a`), we do *not* return true for `.has_type_flags(TypeFlags::HAS_LATE_BOUND)`, even though binders are supposed to act as if they have late-bound vars even if they don't mention them in their bound value: 31ae3b2bdb. This is because we use `HasTypeFlagsVisitor`, which only computes the type flags for `Ty`, `Const` and `Region` and `Predicates`, and we consequently skip any binders (and setting flags for their vars) that are not contained in one of these types.

This ends up causing a problem, because when we call `TyCtxt::erase_regions` (which both erases regions *and* anonymizes bound vars), we will skip such a PolyTraitRef, not anonymizing it, and therefore not making it structurally equal to other binders. This breaks vtable computations.

This PR computes the flags for all binders we enter in `HasTypeFlagsVisitor` if we're looking for `TypeFlags::HAS_LATE_BOUND` (or `TypeFlags::HAS_{RE,TY,CT}_LATE_BOUND`).

Fixes #115807
2023-09-14 19:12:32 +02:00
bors
e437e57954 Auto merge of #115804 - RalfJung:valtree-to-const-val, r=oli-obk
consistently pass ty::Const through valtrees

Some drive-by things extracted from https://github.com/rust-lang/rust/pull/115748.
2023-09-14 15:34:31 +00:00
bors
5e71913156 Auto merge of #115817 - fee1-dead-contrib:fix-codegen, r=oli-obk
treat host effect params as erased in codegen

This fixes the changes brought to codegen tests when effect params are added to libcore, by not attempting to monomorphize functions that get the host param by being `const fn`.

r? `@oli-obk`
2023-09-14 13:42:30 +00:00
lcnr
0cb800ec34 differentiate root and nested goals 2023-09-14 15:10:45 +02:00
bors
d97e04fbfc Auto merge of #115764 - RalfJung:const-by-ref-alloc-id, r=oli-obk
some ConstValue refactoring

In particular, use AllocId instead of Allocation in ConstValue::ByRef. This helps avoid redundant AllocIds when a  `ByRef` constant gets put back into the interpreter.

r? `@oli-obk`

Fixes https://github.com/rust-lang/rust/issues/105536
2023-09-14 10:04:45 +00:00
Ralf Jung
b18c0a8c4e fix clippy (and MIR printing) handling of ConstValue::Indirect slices 2023-09-14 11:56:55 +02:00
Ralf Jung
7aa44eee99 don't force all slice-typed ConstValue to be ConstValue::Slice 2023-09-14 11:56:55 +02:00
lcnr
1b141b6d73 inspect: explicitly store added goals 2023-09-14 10:41:36 +02:00
lcnr
a3f9530b30 order added_goals_evaluation and nested_probes 2023-09-14 10:20:23 +02:00
lcnr
be9d7e0b94 GoalCandidate to Probe 2023-09-14 09:58:29 +02:00
Deadbeef
a0a801cd38 treat host effect params as erased generics in codegen
This fixes the changes brought to codegen tests when effect params are
added to libcore, by not attempting to monomorphize functions that get
the host param by being `const fn`.
2023-09-14 07:34:35 +00:00
Ralf Jung
19fb2c7ccd found another place where we can eval() a const, and go through valtrees 2023-09-14 07:56:01 +02:00
Ralf Jung
292d5bba86 always evaluate ConstantKind::Ty through valtrees 2023-09-14 07:44:49 +02:00
Ralf Jung
430c386821 make it more clear which functions create fresh AllocId 2023-09-14 07:27:31 +02:00
Ralf Jung
0f8908da27 cleanup op_to_const a bit; rename ConstValue::ByRef → Indirect 2023-09-14 07:27:30 +02:00
Ralf Jung
551f481ffb use AllocId instead of Allocation in ConstValue::ByRef 2023-09-14 07:26:24 +02:00
bors
2394959310 Auto merge of #115751 - lcnr:inspect-cleanup, r=compiler-errors
some inspect improvements

split from #114810 because I still want to experiment a bunch with that PR and these changes are self-contained.

r? `@compiler-errors`
2023-09-14 04:42:07 +00:00
Michael Goulet
7ae301ec47 Properly consider binder vars in HasTypeFlagsVisitor 2023-09-14 03:49:59 +00:00
bors
c728bf3963 Auto merge of #114656 - bossmc:rework-no-coverage-attr, r=oli-obk
Rework `no_coverage` to `coverage(off)`

As discussed at the tail of https://github.com/rust-lang/rust/issues/84605 this replaces the `no_coverage` attribute with a `coverage` attribute that takes sub-parameters (currently `off` and `on`) to control the coverage instrumentation.

Allows future-proofing for things like `coverage(off, reason="Tested live", issue="#12345")` or similar.
2023-09-14 01:05:18 +00:00
Eduardo Sánchez Muñoz
68687e2535 rustc_middle: add Scalar::from_i8 and Scalar::from_i16 and use them in Miri 2023-09-13 19:41:21 +02:00
Matthias Krüger
5dc37c1966
Rollup merge of #115736 - Zoxc:time-cleanup, r=wesleywiser
Remove `verbose_generic_activity_with_arg`

This removes `verbose_generic_activity_with_arg` and changes users to `generic_activity_with_arg`. This keeps the output of `-Z time` readable while these repeated events are still available with the self profiling mechanism.
2023-09-13 18:37:41 +02:00
bors
76e59c71e8 Auto merge of #115803 - RalfJung:const-eval, r=oli-obk
make the eval() functions on our const types return the resulting value

This is a part of https://github.com/rust-lang/rust/pull/115748 that's hopefully perf-neutral, and that does not depend on https://github.com/rust-lang/rust/pull/115764.
2023-09-13 14:41:55 +00:00
John Kåre Alsaker
9624c30965 Generate MIR pass names for profiling on the fly and pass the body DefId as argument 2023-09-13 13:41:19 +02:00
Ralf Jung
8ef6b7a417 restore the old logic adjusting ty::UnevaluatedConst before evaluation 2023-09-13 11:47:21 +02:00
bors
38a16ef731 Auto merge of #115810 - nnethercote:folding-comments, r=WaffleLapkin
Folding comments

r? `@WaffleLapkin`
2023-09-13 07:38:50 +00:00
Nicholas Nethercote
4d8e50b2d3 Comments to clarify the working of HasTypeFlagsVisitor. 2023-09-13 16:50:35 +10:00
Ralf Jung
11a4a24d8e make the set of methods between our two Const types more consistent 2023-09-13 07:29:34 +02:00
Ralf Jung
6e4779ab17 make the eval() functions on our const types return the resulting value 2023-09-13 07:29:34 +02:00
Georg Semmler
5b8a7a0917
#[diagnostic::on_unimplemented] without filters
This commit adds support for a `#[diagnostic::on_unimplemented]`
attribute with the following options:

* `message` to customize the primary error message
* `note` to add a customized note message to an error message
* `label` to customize the label part of the error message

Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
Co-authored-by: Michael Goulet <michael@errs.io>
2023-09-12 20:03:18 +02:00
bors
366dab13f7 Auto merge of #115699 - RalfJung:interpret-abi-compat, r=oli-obk
interpret: change ABI-compat test to be type-based

This makes the test consistent across targets. Otherwise the chances are very high that ABI mismatches get accepted on x86_64 but still fail on many other targets with more complicated ABIs.

This implements (most of) the rules described in https://github.com/rust-lang/rust/pull/115476.
2023-09-12 03:34:55 +00:00
Matthias Krüger
f279afb455
Rollup merge of #115743 - compiler-errors:no-impls, r=davidtwco
Point out if a local trait has no implementations

Slightly helps with #115741
2023-09-11 17:03:32 +02:00
Matthias Krüger
e7a347baf8
Rollup merge of #115727 - fee1-dead-contrib:effect-fallback, r=oli-obk
Implement fallback for effect param

r? `@oli-obk` or `@lcnr`

tracking issue for this ongoing work: https://github.com/rust-lang/rust/issues/110395
2023-09-11 17:03:31 +02:00
lcnr
eac55eec9e dedup GoalEvaluationStep and GoalCandidate
also handle 2 panics when dumping proof trees for the whole test suite

- need to actually tell the proof tree builder about overflow
- need to handle a recursion_limit of 0 :<
2023-09-11 15:50:09 +02:00
Deadbeef
9654d5ceaf add is_host_effect to GenericParamDefKind::Const and address review 2023-09-11 13:18:36 +00:00
lcnr
8225a2e9ec inspect: strongly typed CandidateKind 2023-09-11 13:11:32 +02:00
bors
55e5c9d705 Auto merge of #115656 - cjgillot:default-relative-spans, r=davidtwco
Enable incremental-relative-spans by default.

This was enabled on nightly in https://github.com/rust-lang/rust/pull/84762.

It has been a while, without obvious bugs. It's time to enable it by default for incremental runs.
2023-09-11 10:46:55 +00:00
lcnr
006d599435 revision -> iteration for added_goals_evaluation 2023-09-11 11:51:32 +02:00
lcnr
fc452e2ed3 split GoalEvaluation and CanonicalGoalEvaluation
the unnormalized goal is in the callers inference context, while
anything inside of the `CanonicalGoalEvaluation` is inside of
a new one.
2023-09-11 11:51:32 +02:00
Nicholas Nethercote
64ea8eb1a9 Disentangle Debug and Display for Ty.
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-11 12:51:07 +10:00
Michael Goulet
30e6cea0ae Point out if a local trait has no implementations 2023-09-10 21:20:36 +00:00
Deadbeef
84a490712a Implement fallback for effect param 2023-09-10 07:48:47 +00:00
Tomasz Miąsko
5d3244ce9b Cache reachable_set on disk 2023-09-10 00:00:00 +00:00
John Kåre Alsaker
1d8fdc0332 Use FreezeLock for CStore 2023-09-09 16:02:11 +02:00
Ralf Jung
4999000da1 fix ptr_metadata_ty for DynStar type 2023-09-09 15:36:44 +02:00
Ralf Jung
f993ddc079 give extra context to ABI mismatch errors 2023-09-09 15:36:44 +02:00
bors
38bbc2ce03 Auto merge of #115657 - Zoxc:source-span-avoid-query, r=cjgillot
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-09 09:08:54 +00:00
bors
26f4b72724 Auto merge of #115418 - Zoxc:freeze-source, r=oli-obk
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-08 17:20:23 +00:00
bors
3cd97ed3c3 Auto merge of #115612 - cjgillot:const-prop-int, r=oli-obk
Improvements to dataflow const-prop

Partially cherry-picked from https://github.com/rust-lang/rust/pull/110719

r? `@oli-obk`
cc `@jachris`
2023-09-08 15:32:54 +00:00
Andy Caldwell
8e03371fc3
Rework no_coverage to coverage(off) 2023-09-08 12:46:06 +01:00
Matthias Krüger
38adedc598
Rollup merge of #115629 - compiler-errors:sugg-deref-unsize, r=oli-obk
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-08 08:23:03 +02:00
Matthias Krüger
bef5187e8b
Rollup merge of #115624 - compiler-errors:rtn-path, r=WaffleLapkin
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-08 08:23:03 +02:00
John Kåre Alsaker
2a5121b131 Avoid a source_span query when encoding Spans into query results 2023-09-08 02:08:52 +02:00
Camille GILLOT
717dc1ce21 Enable incremental-relative-spans by default. 2023-09-07 20:21:13 +00:00
John Kåre Alsaker
f49382c050 Use Freeze for SourceFile.lines 2023-09-07 13:05:05 +02:00
bors
7f0fa485a6 Auto merge of #115582 - compiler-errors:refine-yeet, r=oli-obk
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-07 07:26:26 +00:00
Michael Goulet
3bf3dadbc0 Ensure that dyn trait bounds stay sorted 2023-09-07 06:57:08 +00:00
bors
f00c139998 Auto merge of #110050 - saethlin:better-u32-encoding, r=nnethercote
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-07 02:09:41 +00:00
Michael Goulet
748476d94d Print the path of an RPITIT in RTN 2023-09-07 02:08:51 +00:00
Michael Goulet
e10262ca0a Implement refinement lint for RPITIT 2023-09-07 00:49:09 +00:00
bors
4e2116296c Auto merge of #115615 - matthiaskrgr:rollup-49fosdf, r=matthiaskrgr
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-06 18:16:06 +00:00
Matthias Krüger
93543bc8bc
Rollup merge of #115578 - ouz-a:rustc_clarify, r=oli-obk
Clarify cryptic comments

Clarifies some unclear comments that lurked in the compiler.

r? ``@oli-obk``
2023-09-06 19:31:49 +02:00
bors
a5b2ac6906 Auto merge of #115252 - cjgillot:mir-composite, r=davidtwco
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-06 16:10:11 +00:00
Camille GILLOT
fc63543792 Support array length. 2023-09-06 16:05:04 +00:00
Camille GILLOT
74a967bcec Support a few more rvalues. 2023-09-06 15:52:06 +00:00
bors
a0c28cd9dc Auto merge of #115401 - Zoxc:freeze, r=oli-obk
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-06 11:48:43 +00:00
ouz-a
7928c5f830 make comments less cryptic 2023-09-06 12:09:29 +03:00
Camille GILLOT
d35be6c097 Do not assert in try_to_int. 2023-09-05 21:25:41 +00:00
bors
a991861ec9 Auto merge of #115507 - cjgillot:relative-source-file, r=oli-obk
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-05 21:03:56 +00:00
Camille GILLOT
26c48e6f95 Refactor how MIR represents composite debuginfo. 2023-09-05 17:20:07 +00:00
Camille GILLOT
429a9258f1 Refactor projection debug. 2023-09-05 17:02:10 +00:00
Matthias Krüger
09974dfc69
Rollup merge of #115536 - RalfJung:interpreter-privacy, r=oli-obk
interpret: make MemPlace, Place, Operand types private to the interpreter

Outside the interpreter, only the typed versions should be used.
2023-09-05 15:16:50 +02:00
Ben Kimock
94fe18f84b Use a specialized varint + bitpacking scheme for DepGraph encoding 2023-09-04 12:16:50 -04:00
Ralf Jung
fa5f13775a interpret: make MemPlace, Place, Operand types private to the interpreter 2023-09-04 17:53:38 +02:00
Urgau
efbe445ba7 Add help to allow lint for the implied by suggestion 2023-09-04 14:21:38 +02:00