about summary refs log tree commit diff
path: root/compiler/rustc_middle
AgeCommit message (Collapse)AuthorLines
2023-09-17nop_lift macros: ensure that we are using the right internerRalf Jung-0/+24
2023-09-17Auto merge of #114452 - weiznich:feature/diagnostic_on_unimplemented, ↵bors-0/+16
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-16Rollup merge of #115884 - RalfJung:const-debug-print, r=oli-obkMatthias Krüger-6/+20
make ty::Const debug printing less verbose Similar in spirit to https://github.com/rust-lang/rust/pull/115873
2023-09-16miri: reduce code duplication in SSE/SSE2 bin_op_* functionsEduardo Sánchez Muñoz-4/+8
2023-09-16make ty::Const debug printing less verboseRalf Jung-6/+20
2023-09-16Auto merge of #110800 - GuillaumeGomez:custom_code_classes_in_docs, r=t-rustdocbors-2/+2
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-16thir::pattern: update some comments and error type namesRalf Jung-6/+10
2023-09-16Auto merge of #115740 - tmiasko:cache-reachable-set, r=cjgillotbors-0/+1
Cache reachable_set on disk
2023-09-15Fix incorrect codeblock attributes in docsGuillaume Gomez-2/+2
2023-09-14don't point at const usage site for resolution-time errorsRalf Jung-17/+50
also share the code that emits the actual error
2023-09-14move required_consts check to general post-mono-check functionRalf Jung-15/+65
2023-09-14Auto merge of #115848 - matthiaskrgr:rollup-lsul9dz, r=matthiaskrgrbors-15/+45
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-14Rollup merge of #115834 - compiler-errors:binder-vars, r=jackh726Matthias Krüger-15/+45
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: 31ae3b2bdb9376b749fc1d64b531e86806e03c73. 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-14Auto merge of #115804 - RalfJung:valtree-to-const-val, r=oli-obkbors-22/+17
consistently pass ty::Const through valtrees Some drive-by things extracted from https://github.com/rust-lang/rust/pull/115748.
2023-09-14Auto merge of #115817 - fee1-dead-contrib:fix-codegen, r=oli-obkbors-11/+21
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-14differentiate root and nested goalslcnr-10/+19
2023-09-14Auto merge of #115764 - RalfJung:const-by-ref-alloc-id, r=oli-obkbors-71/+109
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-14fix clippy (and MIR printing) handling of ConstValue::Indirect slicesRalf Jung-26/+62
2023-09-14don't force all slice-typed ConstValue to be ConstValue::SliceRalf Jung-18/+7
2023-09-14inspect: explicitly store added goalslcnr-0/+2
2023-09-14order `added_goals_evaluation` and `nested_probes`lcnr-7/+12
2023-09-14`GoalCandidate` to `Probe`lcnr-11/+14
2023-09-14treat host effect params as erased generics in codegenDeadbeef-11/+21
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-14found another place where we can eval() a const, and go through valtreesRalf Jung-6/+5
2023-09-14always evaluate ConstantKind::Ty through valtreesRalf Jung-16/+12
2023-09-14make it more clear which functions create fresh AllocIdRalf Jung-11/+12
2023-09-14cleanup op_to_const a bit; rename ConstValue::ByRef → IndirectRalf Jung-9/+15
2023-09-14use AllocId instead of Allocation in ConstValue::ByRefRalf Jung-11/+17
2023-09-14Auto merge of #115751 - lcnr:inspect-cleanup, r=compiler-errorsbors-80/+149
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-14Properly consider binder vars in HasTypeFlagsVisitorMichael Goulet-15/+45
2023-09-14Auto merge of #114656 - bossmc:rework-no-coverage-attr, r=oli-obkbors-1/+1
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-13rustc_middle: add `Scalar::from_i8` and `Scalar::from_i16` and use them in MiriEduardo Sánchez Muñoz-0/+10
2023-09-13Rollup merge of #115736 - Zoxc:time-cleanup, r=wesleywiserMatthias Krüger-0/+37
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-13Auto merge of #115803 - RalfJung:const-eval, r=oli-obkbors-249/+191
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-13Generate MIR pass names for profiling on the fly and pass the body DefId as ↵John Kåre Alsaker-0/+37
argument
2023-09-13restore the old logic adjusting ty::UnevaluatedConst before evaluationRalf Jung-29/+41
2023-09-13Auto merge of #115810 - nnethercote:folding-comments, r=WaffleLapkinbors-8/+8
Folding comments r? `@WaffleLapkin`
2023-09-13Comments to clarify the working of `HasTypeFlagsVisitor`.Nicholas Nethercote-8/+8
2023-09-13make the set of methods between our two Const types more consistentRalf Jung-150/+116
2023-09-13make the eval() functions on our const types return the resulting valueRalf Jung-161/+125
2023-09-12`#[diagnostic::on_unimplemented]` without filtersGeorg Semmler-0/+16
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-12Auto merge of #115699 - RalfJung:interpret-abi-compat, r=oli-obkbors-8/+15
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-11Rollup merge of #115743 - compiler-errors:no-impls, r=davidtwcoMatthias Krüger-0/+4
Point out if a local trait has no implementations Slightly helps with #115741
2023-09-11Rollup merge of #115727 - fee1-dead-contrib:effect-fallback, r=oli-obkMatthias Krüger-24/+117
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-11dedup `GoalEvaluationStep` and `GoalCandidate`lcnr-14/+19
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-11add `is_host_effect` to `GenericParamDefKind::Const` and address reviewDeadbeef-4/+3
2023-09-11inspect: strongly typed CandidateKindlcnr-18/+89
2023-09-11Auto merge of #115656 - cjgillot:default-relative-spans, r=davidtwcobors-1/+1
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-11revision -> iteration for added_goals_evaluationlcnr-3/+3
2023-09-11split GoalEvaluation and CanonicalGoalEvaluationlcnr-50/+43
the unnormalized goal is in the callers inference context, while anything inside of the `CanonicalGoalEvaluation` is inside of a new one.