about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
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-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-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-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-14Fallback effects even if types also fall backMichael Goulet-1/+8
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
2023-09-14Rollup merge of #115834 - compiler-errors:binder-vars, r=jackh726Matthias Krüger-0/+27
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-14Rollup merge of #115832 - Zalathar:fix-no-coverage, r=oli-obkMatthias Krüger-1/+1
Fix the error message for `#![feature(no_coverage)]` When #114656 was written, the feature flag to replace `no_coverage` was originally spelled `coverage`, but it was eventually changed to `coverage_attribute` instead. That update happened to miss this error message in `removed.rs`, and unfortunately I only noticed just *after* the original PR was approved and merged. cc ``@bossmc`` (original author) ``@oli-obk`` (original reviewer) ``@rustbot`` label +A-code-coverage
2023-09-14Paper over an accidental regressionOli Scherer-14/+15
2023-09-14Auto merge of #112038 - Nemo157:edition-2024-unsafe_op_in_unsafe_fn, r=RalfJungbors-0/+33
Change `unsafe_op_in_unsafe_fn` to be `warn`-by-default from edition 2024 This was previously FCPed: https://github.com/rust-lang/rust/issues/71668#issuecomment-1189396886 There were two blocking requirements: * Fix the `unused_unsafe` lint, done in https://github.com/rust-lang/rust/pull/100081 * Have `cargo fix` able to fix the lint, done in https://github.com/rust-lang/rust/pull/112017
2023-09-14Auto merge of #115764 - RalfJung:const-by-ref-alloc-id, r=oli-obkbors-0/+183
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-14add regression test for something we fixedRalf Jung-0/+31
2023-09-14fix clippy (and MIR printing) handling of ConstValue::Indirect slicesRalf Jung-5/+5
2023-09-14bless allRalf Jung-0/+152
2023-09-14Auto merge of #115825 - cjgillot:expr-field-lint, r=compiler-errorsbors-0/+15
Visit ExprField for lint levels. Fixes https://github.com/rust-lang/rust/issues/115823
2023-09-14Properly consider binder vars in HasTypeFlagsVisitorMichael Goulet-0/+27
2023-09-14Fix the error message for `#![feature(no_coverage)]`Zalathar-1/+1
2023-09-14Auto merge of #114656 - bossmc:rework-no-coverage-attr, r=oli-obkbors-141/+151
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-13Visit ExprField for lint levels.Camille GILLOT-0/+15
2023-09-13Rollup merge of #115815 - bvanjoi:fix-115809, r=oli-obkMatthias Krüger-0/+32
fix: return early when has tainted in mir pass Fixes https://github.com/rust-lang/rust/issues/115809 As in #115643, `run_pass` is skipped if the body has tainted errors. r? `@oli-obk`
2023-09-13Rollup merge of #115771 - RalfJung:no-more-const-err-lint, r=oli-obkMatthias Krüger-8/+12
cleanup leftovers of const_err lint Some code / comments seem to not have been updated when const_err was turned into a hard error, so we can do a bit of cleanup here. r? `@oli-obk`
2023-09-13fix: skip opt if body has tainted errorbohan-0/+32
2023-09-13Address review commentsMatthew Jasper-0/+347
- Add doc comment to new type - Restore "only supported directly in conditions of `if` and `while` expressions" note - Rename variant with clearer name
2023-09-13Auto merge of #115269 - bvanjoi:fix-113834, r=petrochenkovbors-69/+136
resolve: mark binding is determined after all macros had been expanded Fixes #113834 Fixes #115377 r? `@petrochenkov`
2023-09-13Auto merge of #115735 - bjorn3:better_list_crate_metadata, r=wesleywiserbors-7/+7
Extend rustc -Zls This makes it show a lot more things and thus a lot more useful.
2023-09-13resolve: determined binding after parent module macro expandbohan-69/+136
2023-09-13Auto merge of #115785 - fmease:fix-pat-regression, r=wesleywiserbors-0/+21
Only suggest turbofish in patterns if we may recover Fixes [after backport] #115780. CC #103534.
2023-09-12Auto merge of #115128 - davidtwco:re-enable-debuginfo-test, r=wesleywiserbors-1/+0
tests: re-enable pretty-std-collections on macOS Fixes #78665. I made some small modifications to this test so that it would pass for me locally (though I was only able to test using lldb without built-in Rust support, but that seems to be the mode in which it would fail). I ran it a few hundred times with stage one and stage two to see if I could re-produce the spurious failures that were being reported in #78665 and couldn't. From the discussion in #78665, it seemed like this was related to Xcode versions and could be reproduced locally fairly easily. It's been a couple years since this was disabled so a lot has changed. If this starts failing spuriously again then we can disable it and I can look into that. r? `@wesleywiser` (discussed in wg-debugging's triage meeting)
2023-09-12Only suggest turbofish in patterns if we may recoverLeón Orell Valerian Liehr-0/+21
2023-09-12Auto merge of #115215 - ouz-a:mir_issue, r=lcnrbors-0/+49
Remove assert that checks type equality https://github.com/rust-lang/rust/pull/112307 although this prevented `unsound` issues it also seems to introduce regressions https://github.com/rust-lang/rust/issues/114858 is example of this regression. I locally tested this https://github.com/rust-lang/rust/issues/114858#issuecomment-1686502262 issue and failing assert is [this](https://www.diffchecker.com/cjb7jSQm/). This is also related to https://github.com/rust-lang/rust/pull/115025
2023-09-12cleanup leftovers of const_err lintRalf Jung-8/+12
2023-09-12Auto merge of #115705 - cjgillot:const-prop-aggregate, r=oli-obkbors-63/+856
Read from non-scalar constants and statics in dataflow const-prop DataflowConstProp is designed to handle scalar values. When MIR features an assignment from a non-scalar constant, we need to manually decompose it into the custom state space. This PR tweaks interpreter callbacks to allow reusing `eval_mir_constant` without having a stack frame to get a span from. r? `@oli-obk` cc `@jachris`
2023-09-12Auto merge of #115678 - RalfJung:abi-compat-test, r=petrochenkovbors-14/+64
test ABI compatibility for some unsized types as well and test for what `DispatchFromDyn` needs. Also I ran this on a whole bunch of targets via Miri and added enough `cfg` to make it all work, as documentation for what does and doesn't currently work. (Most of those targets do not have their tests run on CI anyway.) Here's the shell rune I used for that: ``` for TARGET in x86_64-unknown-linux-gnu x86_64-pc-windows-gnu aarch64-unknown-linux-gnu s390x-unknown-linux-gnu mips64-unknown-linux-gnuabi64 sparc64-unknown-linux-gnu powerpc64-unknown-linux-gnu powerpc64le-unknown-linux-gnu riscv64gc-unknown-linux-gnu loongarch64-unknown-linux-gnu wasm32-unknown-unknown; do BOOTSTRAP_SKIP_TARGET_SANITY=1 ./x.py run miri --stage 0 --args tests/ui/abi/compatibility.rs --target $TARGET; done ```
2023-09-12add some DispatchFromDyn ABI compatibility testsRalf Jung-0/+5
2023-09-12add enough cfg to make the test pass on problematic targetsRalf Jung-14/+39
2023-09-12also test ABI-compatibility for some unsized typesRalf Jung-2/+19
2023-09-12make sure the types in the ABI compat test actually type-checkRalf Jung-2/+5
2023-09-12Rollup merge of #115765 - asquared31415:cast_diag, r=WaffleLapkinMatthias Krüger-12/+96
Add source type for invalid bool casts Also adds tests for casting various types to `bool` that were otherwise untested. r? `@WaffleLapkin`
2023-09-11Auto merge of #115767 - matthiaskrgr:rollup-byf3lvq, r=matthiaskrgrbors-10/+224
Rollup of 8 pull requests Successful merges: - #115548 (Extract parallel operations in `rustc_data_structures::sync` into a new `parallel` submodule) - #115591 (Add regression test for LLVM 17-rc3 miscompile) - #115631 (Don't ICE when computing ctype's `repr_nullable_ptr` for possibly-unsized ty) - #115708 (fix homogeneous_aggregate not ignoring some ZST) - #115730 (Some more small driver refactors) - #115749 (Allow loading the SMIR for constants and statics) - #115757 (Add a test for #108030) - #115761 (Update books) r? `@ghost` `@rustbot` modify labels: rollup
2023-09-11Remove assert that checks type equalityouz-a-0/+49
2023-09-11Rollup merge of #115757 - DianQK:lto-linkage-used-attr, r=wesleywiserMatthias Krüger-0/+69
Add a test for #108030 Closes #108030. This issue has been resolved in LLVM 17. I can verify that this test fails on 63a81b0c5ab336a7c8d6a9e8a812dd598a51ba18. r? compiler
2023-09-11Rollup merge of #115749 - oli-obk:smir_consts, r=compiler-errorsMatthias Krüger-0/+6
Allow loading the SMIR for constants and statics cc https://github.com/rust-lang/project-stable-mir/issues/34 before this PR we were ICEing when trying to access the SMIR of anything other than functions
2023-09-11Rollup merge of #115730 - bjorn3:some_driver_refactors, r=compiler-errorsMatthias Krüger-2/+1
Some more small driver refactors To improve clarity and simplify some code.
2023-09-11Rollup merge of #115708 - RalfJung:homogeneous, r=davidtwcoMatthias Krüger-8/+78
fix homogeneous_aggregate not ignoring some ZST This is an ABI-breaking change, because it fixes bugs in our ABI code. I'm not sure what that means for this PR, we don't really have a process for such changes, do we? I can only hope nobody relied on the old buggy behavior. Fixes https://github.com/rust-lang/rust/issues/115664
2023-09-11Rollup merge of #115631 - compiler-errors:ctypes-unsized, r=davidtwcoMatthias Krüger-0/+24
Don't ICE when computing ctype's `repr_nullable_ptr` for possibly-unsized ty We may not always be able to compute the layout of a type like `&T` when `T: ?Sized`, even if we're able to estimate its size skeleton. r? davidtwco Fixes #115628