about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-07-24Add regression test for generics reexport of private importGuillaume Gomez-0/+13
2023-07-24Add test for `--document-hidden-items`Guillaume Gomez-0/+16
2023-07-24Add test for private itemsGuillaume Gomez-0/+32
2023-07-24Correctly handle `super` and `::`Guillaume Gomez-0/+23
2023-07-24Extend issue-81141-private-reexport-in-public-api test to cover more casesGuillaume Gomez-0/+80
2023-07-24Add regression test for #81141Guillaume Gomez-0/+34
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-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-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-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-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
2023-07-20Rollup merge of #113835 - lcnr:assemble-candidates-considering-self-ty, ↵Matthias Krüger-0/+58
r=compiler-errors new solver: don't consider blanket impls multiple times only consider candidates which rely on the self type in `assemble_candidates_after_normalizing_self_ty`. r? ``@compiler-errors``
2023-07-20Rollup merge of #113529 - oli-obk:simd_shuffle_evaluated, r=wesleywiserMatthias Krüger-1/+23
Permit pre-evaluated constants in simd_shuffle fixes https://github.com/rust-lang/rust/issues/113500
2023-07-20Rollup merge of #110765 - wackbyte:fix-defaultness-position, ↵Matthias Krüger-12/+31
r=fmease,GuillaumeGomez rustdoc: fix position of `default` in method rendering With the following code: ```rs #![feature(specialization)] pub trait A { unsafe fn a(); } impl A for () { default unsafe fn a() {} } ``` rustdoc would render the `impl` of `a` as ```rs unsafe default fn a() ``` which is inconsistent with the actual position of `default`. This PR fixes this issue.
2023-07-20Auto merge of #113758 - cjgillot:move-dse, r=JakobDegen,oli-obkbors-28/+90
Turn copy into moves during DSE. Dead store elimination computes whether removing a direct store to an unborrowed place is allowed. Where removing a store is allowed, writing `uninit` is too. This means that we can use this pass to transform `copy` operands into `move` operands. This is only interesting in call terminators, so we only handle those. Special care is taken for the `use_both(_1, _1)` case: - moving the second argument is ok, as `_1` is not live after the call; - moving the first argument is not, as the second argument reads `_1`. Fixes #75993 Fixes https://github.com/rust-lang/rust/issues/108068 r? `@RalfJung` cc `@JakobDegen`
2023-07-20reviewlcnr-23/+33
2023-07-20assembly: only consider blanket impls oncelcnr-0/+48
2023-07-20Auto merge of #113695 - bjorn3:fix_rlib_cdylib_metadata_handling, ↵bors-40/+68
r=pnkfelix,petrochenkov Verify that all crate sources are in sync This ensures that rustc will not attempt to link against a cdylib as if it is a rust dylib when an rlib for the same crate is available. Previously rustc didn't actually check if any further formats of a crate which has been loaded are of the same version and if they are actually valid. This caused a cdylib to be interpreted as rust dylib as soon as the corresponding rlib was loaded. As cdylibs don't export any rust symbols, linking would fail if rustc decides to link against the cdylib rather than the rlib. Two crates depended on the previous behavior by separately compiling a test crate as both rlib and dylib. These have been changed to capture their original spirit to the best of my ability while still working when rustc verifies that all crates are in sync. It is unlikely that build systems depend on the current behavior and in any case we are taking a lot of measures to ensure that any change to either the source or the compilation options (including crate type) results in rustc rejecting it as incompatible. We merely didn't do this check here for now obsolete perf reasons. Fixes https://github.com/rust-lang/rust/issues/10786 Fixes https://github.com/rust-lang/rust/issues/82151 Fixes https://github.com/rust-lang/rust/issues/82972 Closes https://github.com/bevy-cheatbook/bevy-cheatbook/issues/114
2023-07-20Monomorphize constants before inspecting themOli Scherer-1/+4
2023-07-20Rollup merge of #113871 - clubby789:derive-sugg-span, r=compiler-errorsMatthias Krüger-1/+1
Use the correct span for displaying the line following a derive sugge… `span` here is the main span of the diagnostic. In the linked issue's case, this belongs to `main.rs`. However, the line numbers (and line we are trying to display) are in `name.rs`, so using `span_to_lines` gives us the wrong `FileLines`. Use `parts[0].span` (the span of the suggestion) here like the rest of the code does to get the right file. Not sure if this needs a dedicated test because this fixes an existing error in the UI suite Fixes #113844
2023-07-20Rollup merge of #113857 - GuillaumeGomez:document-hidden-items-test, r=notriddleMatthias Krüger-0/+71
Add tests for `--document-hidden-items` option Since `--document-hidden-items` was greatly fixed/improved in https://github.com/rust-lang/rust/pull/113574, thought it might be worth adding some more tests for it to prevent new regressions. As for the first commit, it allows to go from: ``` Traceback (most recent call last): File "/home/imperio/rust/rust/src/etc/htmldocck.py", line 706, in <module> check(sys.argv[1], get_commands(rust_test_path)) File "/home/imperio/rust/rust/src/etc/htmldocck.py", line 689, in check for c in commands: File "/home/imperio/rust/rust/src/etc/htmldocck.py", line 274, in get_commands args = shlex.split(args) File "/usr/lib/python3.10/shlex.py", line 315, in split return list(lex) File "/usr/lib/python3.10/shlex.py", line 300, in __next__ token = self.get_token() File "/usr/lib/python3.10/shlex.py", line 109, in get_token raw = self.read_token() File "/usr/lib/python3.10/shlex.py", line 191, in read_token raise ValueError("No closing quotation") ValueError: No closing quotation ``` to: ``` Traceback (most recent call last): File "/home/imperio/rust/rust/src/etc/htmldocck.py", line 708, in <module> check(sys.argv[1], get_commands(rust_test_path)) File "/home/imperio/rust/rust/src/etc/htmldocck.py", line 691, in check for c in commands: File "/home/imperio/rust/rust/src/etc/htmldocck.py", line 278, in get_commands raise Exception("line {}: {}".format(lineno + 1, exc)) from None Exception: line 57: No closing quotation ``` Having the line where the error occurred is quite useful. r? `@notriddle`