about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2022-07-25Add GUI test to prevent sidebar background regressionGuillaume Gomez-0/+22
2022-07-25Remove reachable coverage without countersTomasz Miąsko-17/+31
Remove reachable coverage without counters to maintain invariant that either there is no coverage at all or there is a live coverage counter left that provides the function source hash. The motivating example would be a following closure: ```rust let f = |x: bool| { debug_assert!(x); }; ``` Which, with span changes from #93967, with disabled debug assertions, after the final CFG simplifications but before removal of dead blocks, gives rise to MIR: ```rust fn main::{closure#0}(_1: &[closure@a.rs:2:13: 2:22], _2: bool) -> () { debug x => _2; let mut _0: (); bb0: { Coverage::Expression(4294967295) = 1 - 2; return; } ... } ```
2022-07-25Rollup merge of #99581 - nnethercote:improve-derive-packed-errors, r=estebankYuki Okushi-46/+60
Improve error messages involving `derive` and `packed`. There are two errors involving `derive` and `packed`. ``` `#[derive]` can't be derived on a `#[repr(packed)]` struct with type or const parameters `#[derive]` can't be derived on a `#[repr(packed)]` struct that does not derive Copy ``` The second one overstates things. It is possible to use derive on a repr(packed) struct that doesn't derive Copy in two cases. - If all the fields within the struct meet the required alignment: 1 for `repr(packed)`, or `N` for `repr(packed(N))`. - If `Default` is the only trait derived. This commit improves things in a few ways. - Changes the errors to say `this trait can't be derived on this ...`. This is more accurate, because it's just *this* trait and *this* packed struct that are a problem, not *all* derived traits on *all* packed structs. - Adds more details to the "ERROR" lines in the test case, enough to distinguish between the two error messages. - Adds more cases to the test case that don't cause errors, e.g. `Default` derives. - Uses a wider variety of builtin traits in the test case, for better coverage. r? `@estebank`
2022-07-25Rollup merge of #99494 - tmiasko:no-pie, r=Mark-SimulacrumYuki Okushi-1/+1
Use non-relocatable code in nofile-limit.rs test To avoid using static-pie which is not essential to the test but which was reported to cause problems on Void Linux where glibc is build without support for static-pie.
2022-07-25suggest removing the tuple struct field for the unwrapped valueTakayuki Maeda-0/+75
add a test case for macro
2022-07-25Generate correct suggestion with named arguments used positionallyPreston From-24/+864
Address issue #99265 by checking each positionally used argument to see if the argument is named and adding a lint to use the name instead. This way, when named arguments are used positionally in a different order than their argument order, the suggested lint is correct. For example: ``` println!("{b} {}", a=1, b=2); ``` This will now generate the suggestion: ``` println!("{b} {a}", a=1, b=2); ``` Additionally, this check now also correctly replaces or inserts only where the positional argument is (or would be if implicit). Also, width and precision are replaced with their argument names when they exists. Since the issues were so closely related, this fix for issue #99265 also fixes issue #99266. Fixes #99265 Fixes #99266
2022-07-25feat: impl export-executable-symbolscsmoe-0/+20
2022-07-25Deeply deny fn and raw ptrs in const genericsMichael Goulet-17/+71
2022-07-25Improve error messages involving `derive` and `packed`.Nicholas Nethercote-46/+60
There are two errors involving `derive` and `packed`. ``` `#[derive]` can't be derived on a `#[repr(packed)]` struct with type or const parameters `#[derive]` can't be derived on a `#[repr(packed)]` struct that does not derive Copy ``` The second one overstates things. It is possible to use derive on a repr(packed) struct that doesn't derive Copy in two cases. - If all the fields within the struct meet the required alignment: 1 for `repr(packed)`, or `N` for `repr(packed(N))`. - If `Default` is the only trait derived. This commit improves things in a few ways. - Changes the errors to say `$TRAIT can't be derived on this ...`. This is more accurate, because it's just $TRAIT and *this* packed struct that are a problem, not *all* derived traits on *all* packed structs. - Adds more details to the "ERROR" lines in the test case, enough to distinguish between the two error messages. - Adds more cases to the test case that don't cause errors, e.g. `Default` derives. - Uses a wider variety of builtin traits in the test case, for better coverage.
2022-07-25Auto merge of #97581 - ↵bors-12/+124
AngelicosPhosphoros:improve_calloc_check_in_vec_macro_for_tuples, r=Mark-Simulacrum Support vec zero-alloc optimization for tuples and byte arrays * Implement IsZero trait for tuples up to 8 IsZero elements; * Implement IsZero for u8/i8, leading to implementation of it for arrays of them too; * Add more codegen tests for this optimization. * Lower size of array for IsZero trait because it fails to inline checks
2022-07-24interpret, ptr_offset_from: refactor and test too-far-apart checkRalf Jung-22/+103
2022-07-24Do not prefer module parents which are `doc(hidden)` in visibility mapMichael Goulet-3/+3
2022-07-24Add failing testAlik Aslanyan-0/+69
2022-07-24Support vec zero-alloc optimization for tuples and byte arraysAngelicosPhosphoros-12/+124
* Implement IsZero trait for tuples up to 8 IsZero elements; * Implement IsZero for u8/i8, leading to implementation of it for arrays of them too; * Add more codegen tests for this optimization. * Lower size of array for IsZero trait because it fails to inline checks
2022-07-24Combine redundant obligation cause codesMichael Goulet-9/+9
2022-07-24Handle additional lifetime bounds on GATs like on methodsMichael Goulet-9/+7
2022-07-24Slightly improve mismatched GAT where clause errorMichael Goulet-25/+28
2022-07-24Move write! and writeln! temporaries test to check-failDavid Tolnay-16/+93
2022-07-24Regression in issue 99684 fixedDavid Tolnay-31/+1
2022-07-24Add regression test minimized from async-std writeDavid Tolnay-0/+67
2022-07-24Auto merge of #99409 - tmiasko:atomic-tests, r=m-ou-sebors-1/+109
Test codegen of atomic compare-exchange with additional memory orderings * Add a test for atomic operations introduced in #97423 & #98383. * Add a test for fallback code generation strategy used on LLVM 12 introduced in #98385. Use a separate test case instead of a revision system since test will be gone once LLVM 12 is no longer supported.
2022-07-24suggest dereferencing index when trying to use a reference of usize as indexTakayuki Maeda-32/+63
2022-07-24add backticksMaybe Waffle-1/+1
2022-07-24Add rustdoc test for `#[rustc_must_implement_one_of]`Maybe Waffle-0/+10
2022-07-24Auto merge of #93429 - fee1-dead-contrib:allow-super-trait-tilde-const, ↵bors-0/+100
r=oli-obk Allow `trait A: ~const B` What's included: a minimal working change set for `~const` supertraits to work. r? `@oli-obk`
2022-07-24Auto merge of #95548 - rcvalle:rust-cfi-2, r=nagisabors-39/+608
Add fine-grained LLVM CFI support to the Rust compiler This PR improves the LLVM Control Flow Integrity (CFI) support in the Rust compiler by providing forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types. Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue https://github.com/rust-lang/rust/issues/89653). LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto). Thank you again, `@eddyb,` `@nagisa,` `@pcc,` and `@tmiasko` for all the help!
2022-07-23Auto merge of #99652 - GuillaumeGomez:rollup-38v0x7y, r=GuillaumeGomezbors-35/+84
Rollup of 6 pull requests Successful merges: - #99298 (Make `ui-fulldeps/gated-plugins` and `ui-fulldeps/multiple-plugins` tests stage 2 only) - #99396 (Add some additional double-adjustment regression tests) - #99449 (Do not resolve associated const when there is no provided value) - #99595 (Mark atomics as unsupported on thumbv6m) - #99627 (Lock stdout once when listing tests) - #99638 (Remove Clean trait implementation for hir::Ty and middle::Ty) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-07-23Rollup merge of #99449 - compiler-errors:assoc-const-missing-item, r=lcnrGuillaume Gomez-31/+32
Do not resolve associated const when there is no provided value Fixes #98629, since now we just delay a bug when we're not able to evaluate a const item due to the value not actually being provided by anything. This means compilation proceeds forward to where the "missing item in impl" error is emitted. ---- The root issue here is that when we're looking for the defining `LeafDef` in `resolve_associated_item`, we end up getting the trait's AssocItem instead of the impl's AssocItem (which does not exist). This resolution "succeeds" even if the trait's item has no default value, and then since this item has no value to evaluate, it turns into a const eval error. This root issue becomes problematic (as in #98629) when this const eval error happens in wfcheck (for example, due to normalizing the param-env of something that references this const). Since this happens sooner than the check that an impl actually provides all of the items that a trait requires (which happens during later typecheck), we end up aborting compilation early with only this un-informative message. I'm not exactly sure _why_ this bug arises due to #96591 -- perhaps valtrees are evaluated more eagerly than in the old system? r? ``@oli-obk`` or ``@lcnr`` since y'all are familiar with const eval and reviewed #96591, though feel free to reassign. This is a regression from stable to beta, so I would be open to considering this for beta backport. It seems correct to me, especially given the improvements in the other UI tests this PR touches, but may have some side-effects that I'm unaware of...?
2022-07-23Rollup merge of #99396 - compiler-errors:missing-tests, r=Mark-SimulacrumGuillaume Gomez-0/+46
Add some additional double-adjustment regression tests I accidentally missed these when I rebased #98785 cc #98894 and #98897
2022-07-23Rollup merge of #99298 - ChrisDenton:ignore-plugins-stage1, r=Mark-SimulacrumGuillaume Gomez-4/+6
Make `ui-fulldeps/gated-plugins` and `ui-fulldeps/multiple-plugins` tests stage 2 only These test can fail on stage 1. Fixes #99295
2022-07-23Auto merge of #98208 - ivanloz:master, r=nagisabors-1/+18
Add support for LLVM ShadowCallStack. LLVMs ShadowCallStack provides backward edge control flow integrity protection by using a separate shadow stack to store and retrieve a function's return address. LLVM currently only supports this for AArch64 targets. The x18 register is used to hold the pointer to the shadow stack, and therefore this only works on ABIs which reserve x18. Further details are available in the [LLVM ShadowCallStack](https://clang.llvm.org/docs/ShadowCallStack.html) docs. # Usage `-Zsanitizer=shadow-call-stack` # Comments/Caveats * Currently only enabled for the aarch64-linux-android target * Requires the platform to define a runtime to initialize the shadow stack, see the [LLVM docs](https://clang.llvm.org/docs/ShadowCallStack.html) for more detail.
2022-07-23Do not suggest adding `;` when `,` is also a choiceMichael Goulet-12/+21
2022-07-23Add fine-grained LLVM CFI support to the Rust compilerRamon de C Valle-39/+608
This commit improves the LLVM Control Flow Integrity (CFI) support in the Rust compiler by providing forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types. Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue #89653). LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto).
2022-07-23Add testsDeadbeef-0/+100
2022-07-23Rollup merge of #99580 - fmease:fix-issue-99565, r=estebankMatthias Krüger-2/+23
Don't suggest unnameable generic arguments Fixes #99565. `@rustbot` label T-compiler A-diagnostics r? `@rust-lang/wg-diagnostics`
2022-07-22Do not resolve associated const when there is no provided valueMichael Goulet-31/+32
2022-07-22do not mark interior mutable shared refs as dereferenceableRalf Jung-1/+19
2022-07-22Enable raw-dylib for binariesDaniel Paoliello-14/+21
2022-07-22Auto merge of #99521 - fee1-dead-contrib:const_fix_hax, r=oli-obkbors-16/+1
Fix hack that remaps env constness. WARNING: might have perf implications. Are there any more problems with having a constness in the `ParamEnv` now? :) r? `@oli-obk`
2022-07-22include a demo that more programs can be compiledDing Xiang Fei-0/+17
2022-07-22Auto merge of #99491 - workingjubilee:sync-psimd, r=workingjubileebors-8/+9
Sync in portable-simd subtree r? `@ghost`
2022-07-22Rollup merge of #99539 - compiler-errors:bidirectional-block-suggestions, ↵Dylan DPC-40/+107
r=fee1-dead Improve suggestions for returning binding Fixes #99525 Also reworks the cause codes for match and if a bit, I think cleaning them up in a positive way. We no longer need to call `could_remove_semicolon` in successful code, which might save a few cycles?
2022-07-22Rollup merge of #99393 - ↵Dylan DPC-179/+188
Logarithmus:feature/99255-omit-const-generic-suffixes, r=petrochenkov feat: omit suffixes in const generics (e.g. `1_i32`) Closes #99255
2022-07-22Rollup merge of #98868 - tmiasko:unreachable-coverage, r=wesleywiserDylan DPC-0/+41
Fix unreachable coverage generation for inlined functions To generate a function coverage we need at least one coverage counter, so a coverage from unreachable blocks is retained only when some live counters remain. The previous implementation incorrectly retained unreachable coverage, because it didn't account for the fact that those live counters can belong to another function due to inlining. Fixes #98833.
2022-07-22Don't suggest unnameable generic argumentsLeón Orell Valerian Liehr-2/+23
2022-07-22Add simd_cast_ptr, simd_expose_addr, and simd_from_exposed_addr intrinsicsCaleb Zulawski-0/+33
2022-07-22Delay a span bug if we see ty/const generic params during writebackMichael Goulet-0/+28
2022-07-22Auto merge of #99420 - RalfJung:vtable, r=oli-obkbors-211/+266
make vtable pointers entirely opaque This implements the scheme discussed in https://github.com/rust-lang/unsafe-code-guidelines/issues/338: vtable pointers should be considered entirely opaque and not even readable by Rust code, similar to function pointers. - We have a new kind of `GlobalAlloc` that symbolically refers to a vtable. - Miri uses that kind of allocation when generating a vtable. - The codegen backends, upon encountering such an allocation, call `vtable_allocation` to obtain an actually dataful allocation for this vtable. - We need new intrinsics to obtain the size and align from a vtable (for some `ptr::metadata` APIs), since direct accesses are UB now. I had to touch quite a bit of code that I am not very familiar with, so some of this might not make much sense... r? `@oli-obk`
2022-07-21Rollup merge of #99552 - lcnr:orphan_check-rework, r=oli-obkMatthias Krüger-1/+1
Rewrite `orphan_check_trait_ref` to use a `TypeVisitor` The current impl is far more confusing than it has any right to be :sparkles: r? rust-lang/types
2022-07-21Rollup merge of #99549 - JohnTitor:issue-52304, r=compiler-errorsMatthias Krüger-0/+11
Add regression test for #52304 Closes #52304 r? ```@compiler-errors``` Signed-off-by: Yuki Okushi <jtitor@2k36.org>