about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-07-24Auto merge of #113956 - fmease:rustdoc-fix-x-crate-rpitits, ↵bors-0/+70
r=GuillaumeGomez,compiler-errors rustdoc: handle cross-crate RPITITs correctly Filter out the internal associated types synthesized during the desugaring of RPITITs, they really shouldn't show up in the docs. This also fixes #113929 since we're no longer invoking `is_impossible_associated_item` (renamed from `is_impossible_method`) which cannot handle them (leading to an ICE). I don't think it makes sense to try to make `is_impossible_associated_item` handle this exotic kind of associated type (CC original author `@compiler-errors).` @ T-rustdoc reviewers, currently I'm throwing out ITIT assoc tys before cleaning assoc tys at each usage-site. I'm thinking about making `clean_middle_assoc_item` return an `Option<_>` instead and doing the check inside of it to prevent any call sites from forgetting the check for ITITs. Since I wasn't sure if you would like that approach, I didn't go through with it. Let me know what you think. <details><summary>Explanation on why <code>is_impossible_associated_item(itit_assoc_ty)</code> leads to an ICE</summary> Given the following code: ```rs pub trait Trait { fn def<T>() -> impl Default {} } impl Trait for () {} ``` The generated associated type looks something like (simplified): ```rs type {opaque#0}<T>: Default = impl Default; // the name is actually `kw::Empty` but this is the `def_path_str` repr ``` The query `is_impossible_associated_item` goes through all predicates of the associated item – in this case `<T as Sized>` – to check if they contain any generic parameters from the (generic) associated type itself. For predicates that don't contain any *own* generics, it does further processing, part of which is instantiating the predicate with the generic arguments of the impl block (which is only correct if they truly don't contain any own generics since they wouldn't get instantiated this way leading to an ICE). It checks if `parent_def_id(T) == assoc_ty_def_id` to get to know if `T` is owned by the assoc ty. Unfortunately this doesn't work for ITIT assoc tys. In this case, the parent of `T` is `Trait::def` (!) which is the associated function (I'm pretty sure this is very intentional) which is of course not equal to the assoc ty `Trait::{opaque#0}`. </details> `@rustbot` label A-cross-crate-reexports
2023-07-24Add regression test for #113982Guillaume Gomez-0/+22
2023-07-24builtin_macros: expect raw strings tooDavid Wood-0/+17
`expr_to_string` allows raw strings through so this code should be expected to handle those. Signed-off-by: David Wood <david@davidtw.co>
2023-07-24interpret: support projecting into Place::Local without force_allocationRalf Jung-1/+1
2023-07-24new unstable option: -Zwrite-long-types-to-diskMahdi Dibaiee-30/+36
This option guards the logic of writing long type names in files and instead using short forms in error messages in rustc_middle/ty/error behind a flag. The main motivation for this change is to disable this behaviour when running ui tests. This logic can be triggered by running tests in a directory that has a long enough path, e.g. /my/very-long-path/where/rust-codebase/exists/ This means ui tests can fail depending on how long the path to their file is. Some ui tests actually rely on this behaviour for their assertions, so for those we enable the flag manually.
2023-07-23Use erased self type when autoderefing for trait error suggestionMichael Goulet-0/+49
2023-07-23Auto merge of #113976 - GuillaumeGomez:migrate-gui-test-color-23, r=notriddlebors-2/+2
Migrate GUI colors test to original CSS color format Follow-up of https://github.com/rust-lang/rust/pull/111459. r? `@notriddle`
2023-07-23Migrate GUI colors test to original CSS color formatGuillaume Gomez-2/+2
2023-07-23add proc macro testDeadbeef-0/+30
2023-07-23reimplement C string literalsDeadbeef-88/+12
2023-07-23Auto merge of #111836 - calebzulawski:target-feature-closure, r=workingjubileebors-0/+51
Fix #[inline(always)] on closures with target feature 1.1 Fixes #108655. I think this is the most obvious solution that isn't overly complicated. The comment includes more justification, but I think this is likely better than demoting the `#[inline(always)]` to `#[inline]`, since existing code is unaffected.
2023-07-22Auto merge of #112953 - compiler-errors:interpolated-block-exprs, r=WaffleLapkinbors-0/+35
Support interpolated block for `try` and `async` I'm putting this up for T-lang discussion, to decide whether or not they feel like this should be supported. This was raised in #112952, which surprised me. There doesn't seem to be a *technical* reason why we don't support this. ### Precedent: This is supported: ```rust macro_rules! always { ($block:block) => { if true $block } } fn main() { always!({}); } ``` ### Counterpoint: However, for context, this is *not* supported: ```rust macro_rules! unsafe_block { ($block:block) => { unsafe $block } } fn main() { unsafe_block!({}); } ``` If this support for `async` and `try` with interpolated blocks is *not* desirable, then I can convert them to instead the same diagnostic as `unsafe $block` and make this situation a lot less ambiguous. ---- I'll try to write up more before T-lang triage on Tuesday. I couldn't find anything other than #69760 for why something like `unsafe $block` is not supported, and even that PR doesn't have much information. Fixes #112952
2023-07-22Rollup merge of #113959 - GuillaumeGomez:migrate-gui-test-color-22, r=notriddleMatthias Krüger-24/+25
Migrate GUI colors test to original CSS color format Follow-up of https://github.com/rust-lang/rust/pull/111459. r? `@notriddle`
2023-07-22Rollup merge of #113957 - Urgau:regression-test-issue-113941, r=dtolnayMatthias Krüger-0/+13
Add regression test for issue #113941 - naive layout isn't refined This PR adds a regression test for issue #113941 - `the naive layout isn't refined by the actual layout` based on the minimized repro https://github.com/rust-lang/rust/issues/113941#issuecomment-1646446769.
2023-07-22Rollup merge of #112508 - compiler-errors:trait-sig-lifetime-sugg-ice, ↵Matthias Krüger-27/+81
r=cjgillot Tweak spans for self arg, fix borrow suggestion for signature mismatch 1. Adjust a suggestion message that was annoying me 2. Fix #112503 by recording the right spans for the `self` part of the `&self` 0th argument 3. Remove the suggestion for adjusting a trait signature on type mismatch, bc that's gonna probably break all the other impls of the trait even if it fixes its one usage :sweat_smile:
2023-07-22Add #[inline] to core debug assertion helpersBen Kimock-8/+2
2023-07-22Don't call a type uncallable if its signature has errors in itMichael Goulet-0/+17
2023-07-22Support interpolated block for try and asyncMichael Goulet-0/+35
2023-07-22Migrate GUI colors test to original CSS color formatGuillaume Gomez-24/+25
2023-07-22Add regression test for issue #113941 - naive layout isn't refinedUrgau-0/+13
2023-07-22add tests for broken links in unused doc stringsLukas Markeffsky-0/+43
2023-07-22fix doc links on `extern crate` itemsLukas Markeffsky-4/+5
2023-07-22rustdoc: handle cross-crate RPITITs correctlyLeón Orell Valerian Liehr-0/+70
2023-07-22fix doc links on `use` itemsLukas Markeffsky-0/+16
2023-07-21Revert "Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obk"David Tolnay-41/+32
This reverts commit 557359f92512ca88b62a602ebda291f17a953002, reversing changes made to 1e6c09a803fd543a98bfbe1624d697a55300a786.
2023-07-21Support `.comment` section like GCC/Clang (`!llvm.ident`)Miguel Ojeda-0/+49
Both GCC and Clang write by default a `.comment` section with compiler information: ```txt $ gcc -c -xc /dev/null && readelf -p '.comment' null.o String dump of section '.comment': [ 1] GCC: (GNU) 11.2.0 $ clang -c -xc /dev/null && readelf -p '.comment' null.o String dump of section '.comment': [ 1] clang version 14.0.1 (https://github.com/llvm/llvm-project.git c62053979489ccb002efe411c3af059addcb5d7d) ``` They also implement the `-Qn` flag to avoid doing so: ```txt $ gcc -Qn -c -xc /dev/null && readelf -p '.comment' null.o readelf: Warning: Section '.comment' was not dumped because it does not exist! $ clang -Qn -c -xc /dev/null && readelf -p '.comment' null.o readelf: Warning: Section '.comment' was not dumped because it does not exist! ``` So far, `rustc` only does it for WebAssembly targets and only when debug info is enabled: ```txt $ echo 'fn main(){}' | rustc --target=wasm32-unknown-unknown --emit=llvm-ir -Cdebuginfo=2 - && grep llvm.ident rust_out.ll !llvm.ident = !{!27} ``` In the RFC part of this PR it was decided to always add the information, which gets us closer to other popular compilers. An opt-out flag like GCC and Clang may be added later on if deemed necessary. Implementation-wise, this covers both `ModuleLlvm::new()` and `ModuleLlvm::new_metadata()` cases by moving the addition to `context::create_module` and adds a few test cases. ThinLTO also sees the `llvm.ident` named metadata duplicated (in temporary outputs), so this deduplicates it like it is done for `wasm.custom_sections`. The tests also check this duplication does not take place. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-07-21Auto merge of #113922 - matthiaskrgr:rollup-90cj2vv, r=matthiaskrgrbors-4/+4
Rollup of 4 pull requests Successful merges: - #113887 (new solver: add a separate cache for coherence) - #113910 (Add FnPtr ty to SMIR) - #113913 (error/E0691: include alignment in error message) - #113914 (rustc_target: drop duplicate code) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-21Rollup merge of #113913 - dvdhrm:pr/transpalign, r=jackh726Matthias Krüger-4/+4
error/E0691: include alignment in error message Include the computed alignment of the violating field when rejecting transparent types with non-trivially aligned ZSTs. ZST member fields in transparent types must have an alignment of 1 (to ensure it does not raise the layout requirements of the transparent field). The current error message looks like this: ```text LL | struct Foobar(u32, [u32; 0]); | ^^^^^^^^ has alignment larger than 1 ``` This patch changes the report to include the alignment of the violating field: ```text LL | struct Foobar(u32, [u32; 0]); | ^^^^^^^^ has alignment of 4, which is larger than 1 ``` In case of unknown alignments, it will yield: ```text LL | struct Foobar(u32, [u32; 0]); | ^^^^^^^^ may have alignment larger than 1 ``` This allows developers to get a better grasp why a specific field is rejected. Knowing the alignment of the violating field makes it easier to judge where that alignment-requirement originates, and thus hopefully provide better hints on how to mitigate the problem. This idea was proposed in 2022 in #98071 as part of a bigger change. This commit simply extracts this error-message change, to decouple it from the other diagnostic improvements. (Originally proposed by `@compiler-errors` in #98071)
2023-07-21Auto merge of #113166 - moulins:ref-niches-initial, r=oli-obkbors-32/+41
Prototype: Add unstable `-Z reference-niches` option MCP: rust-lang/compiler-team#641 Relevant RFC: rust-lang/rfcs#3204 This prototype adds a new `-Z reference-niches` option, controlling the range of valid bit-patterns for reference types (`&T` and `&mut T`), thereby enabling new enum niching opportunities. Like `-Z randomize-layout`, this setting is crate-local; as such, references to built-in types (primitives, tuples, ...) are not affected. The possible settings are (here, `MAX` denotes the all-1 bit-pattern): | `-Z reference-niches=` | Valid range | |:---:|:---:| | `null` (the default) | `1..=MAX` | | `size` | `1..=(MAX- size)` | | `align` | `align..=MAX.align_down_to(align)` | | `size,align` | `align..=(MAX-size).align_down_to(align)` | ------ This is very WIP, and I'm not sure the approach I've taken here is the best one, but stage 1 tests pass locally; I believe this is in a good enough state to unleash this upon unsuspecting 3rd-party code, and see what breaks.
2023-07-21lint/ctypes: only try normalizeDavid Wood-0/+12
Now that this lint runs on any external-ABI fn-ptr, normalization won't always succeed, so use `try_normalize_erasing_regions` instead. Signed-off-by: David Wood <david@davidtw.co>
2023-07-21Double check that hidden types match the expected hidden typeOli Scherer-2/+73
2023-07-21Track (partial) niche information in `NaiveLayout`Moulins-2/+14
Still more complexity, but this allows computing exact `NaiveLayout`s for null-optimized enums, and thus allows calls like `transmute::<Option<&T>, &U>()` to work in generic contexts.
2023-07-21error/E0691: include alignment in error messageDavid Rheinsberg-4/+4
Include the computed alignment of the violating field when rejecting transparent types with non-trivially aligned ZSTs. ZST member fields in transparent types must have an alignment of 1 (to ensure it does not raise the layout requirements of the transparent field). The current error message looks like this: LL | struct Foobar(u32, [u32; 0]); | ^^^^^^^^ has alignment larger than 1 This patch changes the report to include the alignment of the violating field: LL | struct Foobar(u32, [u32; 0]); | ^^^^^^^^ has alignment of 4, which is larger than 1 In case of unknown alignments, it will yield: LL | struct Foobar<T>(u32, [T; 0]); | ^^^^^^ may have alignment larger than 1 This allows developers to get a better grasp why a specific field is rejected. Knowing the alignment of the violating field makes it easier to judge where that alignment-requirement originates, and thus hopefully provide better hints on how to mitigate the problem. This idea was proposed in 2022 in #98071 as part of a bigger change. This commit simply extracts this error-message change, to decouple it from the other diagnostic improvements.
2023-07-21Rollup merge of #113780 - dtolnay:printkindpath, r=b-naberMatthias Krüger-2/+27
Support `--print KIND=PATH` command line syntax As is already done for `--emit KIND=PATH` and `-L KIND=PATH`. In the discussion of #110785, it was pointed out that `--print KIND=PATH` is nicer than trying to apply the single global `-o` path to `--print`'s output, because in general there can be multiple print requests within a single rustc invocation, and anyway `-o` would already be used for a different meaning in the case of `link-args` and `native-static-libs`. I am interested in using `--print cfg=PATH` in Buck2. Currently Buck2 works around the lack of support for `--print KIND=PATH` by [indirecting through a Python wrapper script](https://github.com/facebook/buck2/blob/d43cf3a51a31f00be2c2248e78271b0fef0452b4/prelude/rust/tools/get_rustc_cfg.py) to redirect rustc's stdout into the location dictated by the build system. From skimming Cargo's usages of `--print`, it definitely seems like it would benefit from `--print KIND=PATH` too. Currently it is working around the lack of this by inserting `--crate-name=___ --print=crate-name` so that it can look for a line containing `___` as a delimiter between the 2 other `--print` informations it actually cares about. This is commented as a "HACK" and "abuse". https://github.com/rust-lang/cargo/blob/31eda6f7c360d9911f853b3014e057db61238f3e/src/cargo/core/compiler/build_context/target_info.rs#L242 (FYI `@weihanglo` as you dealt with this recently in https://github.com/rust-lang/cargo/pull/11633.) Mentioning reviewers active in #110785: `@fee1-dead` `@jyn514` `@bjorn3`
2023-07-21Track ABI info. in `NaiveLayout`, and use it for `PointerLike` checksMoulins-1/+0
THis significantly complicates `NaiveLayout` logic, but is necessary to ensure that bounds like `NonNull<T>: PointerLike` hold in generic contexts. Also implement exact layout computation for structs.
2023-07-21Track exactness in `NaiveLayout` and use it for `SizeSkeleton` checksMoulins-5/+2
2023-07-21properly handle arrays and wide pointers in `naive_layout_of`Moulins-1/+1
2023-07-21add `naive_layout_of` queryMoulins-25/+26
2023-07-21Auto merge of #113344 - scottmcm:alt-slice-zst-handing, r=the8472bors-14/+54
Get `!nonnull` metadata on slice iterators, without `assume`s This updates the non-ZST paths to read the end pointer through a pointer-to-`NonNull`, so that they all get `!nonnull` metadata. That means that the last `assume(!ptr.is_null())` can be deleted, without impacting codegen -- the codegen tests confirm the LLVM-IR ends up exactly the same as before.
2023-07-20Auto merge of #113858 - cjgillot:const-prop-pairs, r=oli-obkbors-146/+137
Always const-prop scalars and scalar pairs This removes some complexity from the pass. The limitation to propagate ScalarPairs only for tuple comes from https://github.com/rust-lang/rust/pull/67015, when ScalarPair constant were modeled using `Rvalue::Aggregate`. Nowadays, we use `ConstValue::ByRef`, which does not care about the underlying type. The justification for not propagating in all cases was perf. This seems not to be a clear cut any more: https://github.com/rust-lang/rust/pull/113858#issuecomment-1642396746
2023-07-20Propagate ScalarPair for any type.Camille GILLOT-8/+14
2023-07-20Also propagate ScalarPair operands.Camille GILLOT-6/+12
2023-07-20Always propagate into operands.Camille GILLOT-134/+113
2023-07-20Auto merge of #113856 - WaffleLapkin:vtablin', r=oli-obkbors-3/+103
Refactor vtable encoding and optimize it for the case of multiple marker traits This PR does two things - Refactor `prepare_vtable_segments` (this was motivated by the other change, `prepare_vtable_segments` was quite hard to understand and while trying to edit it I've refactored it) - Mostly remove `loop`s labeled `break`s/`continue`s whenever there is a simpler solution - Also use `?` - Make vtable format a bit more efficient wrt to marker traits - See the tests for an example Fixes https://github.com/rust-lang/rust/issues/113840 cc `@crlf0710` ---- Review wise it's probably best to review each commit individually, as then it's more clear why the refactoring is correct. I can split the last two commits (which change behavior) into a separate PR if it makes reviewing easier
2023-07-20Auto merge of #113546 - cjgillot:unused-query, r=compiler-errorsbors-2/+2
Querify unused trait check. This code transitively loads information for all bodies, and from resolutions. As it does not return a value, it should be beneficial to have it as a query.
2023-07-20Get `!nonnull` metadata consistently in slice iterators, without needing ↵Scott McMurray-14/+54
`assume`s
2023-07-20Add ui test of LLVM print-from-C++ changesDavid Tolnay-0/+8
2023-07-20Move OutFileName writing into rustc_sessionDavid Tolnay-1/+1
2023-07-20Add test of --print KIND=PATHDavid Tolnay-1/+18
2023-07-20Auto merge of #113890 - matthiaskrgr:rollup-k1w2vii, r=matthiaskrgrbors-13/+112
Rollup of 7 pull requests Successful merges: - #110765 (rustdoc: fix position of `default` in method rendering) - #113529 (Permit pre-evaluated constants in simd_shuffle) - #113800 (Avoid another gha group nesting) - #113827 (Add Foreign, Never, FnDef, Closure and Generator tys to SMIR) - #113835 (new solver: don't consider blanket impls multiple times) - #113883 (Remove outdated Firefox-specific CSS for search's crate selector appearance) - #113884 (Don't translate compiler-internal bug messages) r? `@ghost` `@rustbot` modify labels: rollup