about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-09-18Auto merge of #115748 - RalfJung:post-mono, r=oli-obkbors-75/+150
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-18Prevent using `#[target_feature]` on lang item functionsEduardo Sánchez Muñoz-0/+56
2023-09-18rustdoc: hide repr(transparent) if it isn't part of the public ABILeón Orell Valerian Liehr-6/+75
2023-09-18make more prettyBoxy-105/+29
2023-09-18Prototype using const generic for simd_shuffle IDX arrayOli Scherer-19/+129
2023-09-18remove provisional cachelcnr-2/+78
2023-09-18Migrate 'cast to bool' diagnosticclubby789-10/+50
2023-09-18coverage: Regression test for inconsistent handling of closure spansZalathar-0/+289
2023-09-18coverage: Fix an unstable-sort inconsistency in coverage spansZalathar-16/+16
This code was calling `sort_unstable_by`, but failed to impose a total order on the initial spans. That resulted in unpredictable handling of closure spans, producing inconsistencies in the coverage maps and in user-visible coverage reports. This patch fixes the problem by always sorting closure spans before otherwise-identical non-closure spans, and also switches to a stable sort in case the ordering is still not total.
2023-09-18Auto merge of #115914 - ↵bors-5/+9
GuillaumeGomez:turn-custom_code_classes_in_docs-into-warning, r=Manishearth Turn custom code classes in docs into warning By habit, since it was a new feature gate, I added a check which emitted an error in case the new syntax was used. However, since rustdoc tags parser was accepting *everything*, using the "new" syntax should never ever emit errors. It now emits a warning. Follow-up of #110800. cc `@Manishearth` r? `@notriddle`
2023-09-17Auto merge of #115334 - RalfJung:transparent-aligned-zst, r=compiler-errorsbors-44/+61
repr(transparent): it's fine if the one non-1-ZST field is a ZST This code currently gets rejected: ```rust #[repr(transparent)] struct MyType([u16; 0]) ``` That clearly seems like a bug to me: `repr(transparent)` [got defined ](https://github.com/rust-lang/rust/issues/77841#issuecomment-716575747) as having any number of 1-ZST fields plus optionally one more field; `MyType` clearly satisfies that definition. This PR changes the `repr(transparent)` logic to actually match that definition.
2023-09-17Auto merge of #115909 - Dylan-DPC:rollup-uf96r2d, r=Dylan-DPCbors-20/+85
Rollup of 6 pull requests Successful merges: - #114965 (Remove Drop impl of mpsc Receiver and (Sync)Sender) - #115434 (make `Debug` impl for `ascii::Char` match that of `char`) - #115477 (Stabilize the `Saturating` type) - #115611 (add diagnostic for raw identifiers in format string) - #115654 (improve PassMode docs) - #115862 (Migrate `compiler/rustc_hir_typeck/src/callee.rs` to translatable diagnostics) r? `@ghost` `@rustbot` modify labels: rollup
2023-09-17Update tests for `custom_code_classes_in_docs` featureGuillaume Gomez-5/+9
2023-09-17Auto merge of #114750 - Enselic:metadata-dep-info, r=compiler-errorsbors-0/+22
Make `.rmeta` file in `dep-info` have correct name (`lib` prefix) Since `filename_for_metadata()` and `OutputFilenames::path(OutputType::Metadata)` had different logic for the name of the metadata file, the `.d` file contained a file name different from the actual name used. Share the logic to fix the out-of-sync name. Without this fix, the `.d` file contained dash-separated_something-extra.rmeta: dash-separated.rs instead of libdash_separated_something-extra.rmeta: dash-separated.rs which is the name of the file that is actually written by the compiler. Worth noting: It took me several iterations to get all tests to pass, so I am relatively confident that this PR does not break anything. Closes #68839
2023-09-17Rollup merge of #115862 - clubby789:migrate-callee-translatable, ↵Dylan DPC-12/+18
r=compiler-errors Migrate `compiler/rustc_hir_typeck/src/callee.rs` to translatable diagnostics
2023-09-17Rollup merge of #115654 - RalfJung:pass-mode-cast, r=compiler-errorsDylan DPC-2/+2
improve PassMode docs
2023-09-17Rollup merge of #115611 - lukas-code:format!("{r#ident}"), r=compiler-errorsDylan DPC-0/+61
add diagnostic for raw identifiers in format string Format strings don't support raw identifiers (e.g. `format!("{r#type}")`), but they do support keywords in the format string directly (e.g. `format!("{type}")`). This PR improves the error output when attempting to use a raw identifier in a format string and adds a machine-applicable suggestion to remove the `r#`. fixes https://github.com/rust-lang/rust/issues/115466
2023-09-17Rollup merge of #114965 - benschulz:mpsc-drop, r=dtolnayDylan DPC-6/+4
Remove Drop impl of mpsc Receiver and (Sync)Sender This change removes the empty `Drop` implementations for `mpsc::Receiver`, `mpsc::Sender` and `mpsc::SyncSender`. These implementations do not specify `#[may_dangle]`, so by removing them we make `mpsc` types play nice with drop check. This was previously attempted in [#105243](https://github.com/rust-lang/rust/pull/105243#issuecomment-1337188646) but then [abandoned due to a test failure](https://github.com/rust-lang/rust/pull/105243#issuecomment-1337227970). I've aligned the test with those for `Mutex` and `RwLock`.
2023-09-17Auto merge of #114452 - weiznich:feature/diagnostic_on_unimplemented, ↵bors-6/+207
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-17Auto merge of #113748 - clarfonthey:ip-step, r=dtolnaybors-1/+1
impl Step for IP addresses ACP: rust-lang/libs-team#235 Note: since this is insta-stable, it requires an FCP. Separating out from the bit operations PR since it feels logically disjoint, and so their FCPs can be separate.
2023-09-16Rollup merge of #115890 - GuillaumeGomez:migrate-gui-test-color-41, r=notriddleMatthias Krüger-1/+1
Migrate GUI colors test to original CSS color format Follow-up of https://github.com/rust-lang/rust/pull/111459. r? `@notriddle`
2023-09-16Rollup merge of #115884 - RalfJung:const-debug-print, r=oli-obkMatthias Krüger-6/+6
make ty::Const debug printing less verbose Similar in spirit to https://github.com/rust-lang/rust/pull/115873
2023-09-16Auto merge of #115894 - matthiaskrgr:rollup-pe5efh4, r=matthiaskrgrbors-2/+5
Rollup of 3 pull requests Successful merges: - #115860 (Enable varargs support for AAPCS calling convention) - #115867 (coverage: Simplify internal representation of debug types) - #115885 (don't globally ignore rustc-ice files) Failed merges: - #115873 (Make `TyKind::Adt`'s `Debug` impl be more pretty) - #115884 (make ty::Const debug printing less verbose) r? `@ghost` `@rustbot` modify labels: rollup
2023-09-16make ty::Const debug printing less verboseRalf Jung-6/+6
2023-09-16Rollup merge of #115860 - Soveu:varargs2, r=WaffleLapkinMatthias Krüger-2/+5
Enable varargs support for AAPCS calling convention Welp, I was looking for a reason why this shouldn't be stabilized after so long... and here it is.
2023-09-16Auto merge of #110800 - GuillaumeGomez:custom_code_classes_in_docs, r=t-rustdocbors-0/+298
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-16Migrate GUI colors test to original CSS color formatGuillaume Gomez-1/+1
2023-09-16Rollup merge of #115866 - RalfJung:interpret-debug, r=compiler-errorsMatthias Krüger-16/+15
make interpreter and TyAndLayout type Debug impl independent of Ty debug impl This fixes some (but not all) of the fallout from https://github.com/rust-lang/rust/pull/115661. Second commit is taken from https://github.com/rust-lang/rust/pull/107084 (and slightly adjusted); I preserved the original git author information.
2023-09-16Auto merge of #115315 - RalfJung:field-capture-packed-alignment, r=oli-obkbors-17/+12
closure field capturing: don't depend on alignment of packed fields This fixes the closure field capture part of https://github.com/rust-lang/rust/issues/115305: field capturing always stops at projections into packed structs, no matter the alignment of the field. This means changing a private field type from `u8` to `u64` can never change how closures capture fields, which is probably what we want. Here's an example where, before this PR, changing the type of a private field in a repr(Rust) struct can change the output of a program: ```rust #![allow(dead_code)] mod m { // before patch #[derive(Default)] pub struct S1(u8); // after patch #[derive(Default)] pub struct S2(u64); } struct NoisyDrop; impl Drop for NoisyDrop { fn drop(&mut self) { eprintln!("dropped!"); } } #[repr(packed)] struct MyType { field: m::S1, // output changes when this becomes S2 other_field: NoisyDrop, third_field: Vec<()>, } fn test(r: MyType) { let c = || { let _val = std::ptr::addr_of!(r.field); let _val = r.third_field; }; drop(c); eprintln!("before dropping"); } fn main() { test(MyType { field: Default::default(), other_field: NoisyDrop, third_field: Vec::new(), }); } ``` Of course this is a breaking change for the same reason that doing field capturing in the first place was a breaking change. Packed fields are relatively rare and depending on drop order is relatively rare, so I don't expect this to have much impact, but it's hard to be sure and even a crater run will only tell us so much. Also see the [nomination comment](https://github.com/rust-lang/rust/pull/115315#issuecomment-1702807825). Cc `@rust-lang/wg-rfc-2229` `@ehuss`
2023-09-16impl Step for IP addressesltdk-1/+1
2023-09-16Auto merge of #114494 - est31:extend_useless_ptr_null_checks, r=jackh726bors-21/+31
Make useless_ptr_null_checks smarter about some std functions This teaches the `useless_ptr_null_checks` lint that some std functions can't ever return null pointers, because they need to point to valid data, get references as input, etc. This is achieved by introducing an `#[rustc_never_returns_null_ptr]` attribute and adding it to these std functions (gated behind bootstrap `cfg_attr`). Later on, the attribute could maybe be used to tell LLVM that the returned pointer is never null. I don't expect much impact of that though, as the functions are pretty shallow and usually the input data is already never null. Follow-up of PR #113657 Fixes #114442
2023-09-16Auto merge of #115829 - notriddle:notriddle/rustdoc-theme-css-merge, ↵bors-2/+3
r=GuillaumeGomez rustdoc: merge theme css into rustdoc.css Based on https://github.com/rust-lang/rust/pull/115812#issuecomment-1717960119 Having them in separate files used to make more sense, before the migration to CSS variables made the theme files as small as they are nowadays. This is already how docs.rs and mdBook do it. WebPageTest comparison page: https://www.webpagetest.org/video/compare.php?tests=230913_AiDc3F_B9E,230913_AiDc7G_B9B Filmstrip comparison: ![image](https://github.com/rust-lang/rust/assets/1593513/7ccad27b-7497-47ee-94c0-1a701b69c0c2) Old waterfall: ![image](https://github.com/rust-lang/rust/assets/1593513/7a6e4375-226d-4205-8871-a4d775a70748) New waterfall: ![image](https://github.com/rust-lang/rust/assets/1593513/e29112e3-84f7-417d-a250-cd6c10fa50f5)
2023-09-15special case `TyAndLayout` debug implBoxy-16/+15
2023-09-15Implement new eBNF for codeblock attributesGuillaume Gomez-62/+146
2023-09-15Add support for double quotes in markdown codeblock attributesGuillaume Gomez-0/+50
2023-09-15Add tests for `custom_code_classes_in_docs` featureGuillaume Gomez-0/+164
2023-09-15rustdoc: merge theme css into rustdoc.cssMichael Howell-2/+3
Based on https://github.com/rust-lang/rust/pull/115812#issuecomment-1717960119 Having them in separate files used to make more sense, before the migration to CSS variables made the theme files as small as they are nowadays. This is already how docs.rs and mdBook do it.
2023-09-15Migrate 'explicit destructor call' diagnosticclubby789-12/+18
2023-09-15avoid blessing cargo deps's source code in ui testsPietro Albini-3/+0
2023-09-15clarify PassMode::Indirect as wellRalf Jung-2/+2
2023-09-15Canonicalize effect vars in new solverMichael Goulet-0/+22
2023-09-15Auto merge of #115859 - compiler-errors:effect-fallback, r=fee1-deadbors-1/+8
Fallback effects even if types also fallback `||` is short circuiting, so if we do ty/int var fallback, we *don't* do effect fallback 😸 r? `@fee1-dead` or `@oli-obk` Fixes #115791 Fixes #115842
2023-09-14Auto merge of #115857 - notriddle:notriddle/gui-test-themes, r=GuillaumeGomezbors-1/+149
rusdoc: add gui test for custom CSS themes Based on https://github.com/rust-lang/rust/pull/115829#issuecomment-1720056602
2023-09-14Enable varargs support for AAPCS calling conventionSoveu-2/+5
This is the default calling convention for ARM - it is used for extern "C", therefore it supports varargs.
2023-09-14Fallback effects even if types also fall backMichael Goulet-1/+8
2023-09-14don't point at const usage site for resolution-time errorsRalf Jung-76/+58
also share the code that emits the actual error
2023-09-14move required_consts check to general post-mono-check functionRalf Jung-17/+110
2023-09-14rusdoc: add gui test for custom CSS themesMichael Howell-1/+149
Based on https://github.com/rust-lang/rust/pull/115829#issuecomment-1720056602
2023-09-14Auto merge of #115677 - matthewjasper:let-expr-recovery, r=b-naberbors-1739/+1904
Improve invalid let expression handling - Move all of the checks for valid let expression positions to parsing. - Add a field to ExprKind::Let in AST/HIR to mark whether it's in a valid location. - Suppress some later errors and MIR construction for invalid let expressions. - Fix a (drop) scope issue that was also responsible for #104172. Fixes #104172 Fixes #104868
2023-09-14Rollup merge of #115844 - oli-obk:opaque_lifetime_ambiguity, r=jackh726Matthias Krüger-14/+15
Paper over an accidental regression r? types cc https://github.com/rust-lang/rust/issues/115781 (do not close issue until beta backport has been performed) The PR reasons are explained with comments in the source. In order to keep the diff simple, this PR effectively reverts https://github.com/rust-lang/rust/pull/113661, but only for RPITs. I will submit a follow up PR that fixes this correctly instead of just disabling the newly added check for RPITs. This PR should be significantly easier to review for beta backport