about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-03-15Auto merge of #109035 - scottmcm:ptr-read-should-know-undef, ↵bors-31/+267
r=WaffleLapkin,JakobDegen Ensure `ptr::read` gets all the same LLVM `load` metadata that dereferencing does I was looking into `array::IntoIter` optimization, and noticed that it wasn't annotating the loads with `noundef` for simple things like `array::IntoIter<i32, N>`. Trying to narrow it down, it seems that was because `MaybeUninit::assume_init_read` isn't marking the load as initialized (<https://rust.godbolt.org/z/Mxd8TPTnv>), which is unfortunate since that's basically its reason to exist. The root cause is that `ptr::read` is currently implemented via the *untyped* `copy_nonoverlapping`, and thus the `load` doesn't get any type-aware metadata: no `noundef`, no `!range`. This PR solves that by lowering `ptr::read(p)` to `copy *p` in MIR, for which the backends already do the right thing. Fortuitiously, this also improves the IR we give to LLVM for things like `mem::replace`, and fixes a couple of long-standing bugs where `ptr::read` on `Copy` types was worse than `*`ing them. Zulip conversation: <https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Move.20array.3A.3AIntoIter.20to.20ManuallyDrop/near/341189936> cc `@erikdesjardins` `@JakobDegen` `@workingjubilee` `@the8472` Fixes #106369 Fixes #73258
2023-03-15Split the mem-replace codegen testScott McMurray-22/+36
Apparently in CI it's getting generated in the opposite order, one function per file will make the test pass either way.
2023-03-14Improved implementation and comments after code review feedbackScott McMurray-52/+96
2023-03-15Auto merge of #107376 - aliemjay:remove-givens, r=lcnrbors-0/+58
remove obsolete `givens` from regionck Fixes #106567 r? `@lcnr` (feel free to reassign)
2023-03-14Auto merge of #109130 - matthiaskrgr:rollup-dm3jza6, r=matthiaskrgrbors-63/+471
Rollup of 9 pull requests Successful merges: - #108722 (Support for Fuchsia RISC-V target) - #108880 (Remove tests/ui/impl-trait/in-trait/new-lowering-strategy in favor of using revisions on existing tests) - #108909 (Fix object safety checks for new RPITITs) - #108915 (Remove some direct calls to local_def_id_to_hir_id on diagnostics) - #108923 (Make fns from other crates with RPITIT work for -Zlower-impl-trait-in-trait-to-assoc-ty) - #109101 (Fall back to old metadata computation when type references errors) - #109105 (Don't ICE for late-bound consts across `AnonConstBoundary`) - #109110 (Don't codegen impossible to satisfy impls) - #109116 (Emit diagnostic when calling methods on the unit type in method chains) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-14Rollup merge of #109116 - ↵Matthias Krüger-5/+38
MaciejWas:add-modifies-receiver-diagn-when-method-not-found, r=petrochenkov Emit diagnostic when calling methods on the unit type in method chains Fixes #104204. What this PR does: If a method is not found somewhere in a call chain, we check if we called earlier a method with signature `(&mut T, ...) -> ()`. If this is the case then we emit a diagnostic message. For example given input: ``` vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); ``` the current output is: ``` error[E0599]: no method named `sort` found for unit type `()` in the current scope --> hello.rs:3:72 | 3 | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); | ^^^^ method not found in `()` ``` after this PR it will be: ``` error[E0599]: no method named `sort` found for unit type `()` in the current scope --> ./hello.rs:3:72 | 3 | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); | ^^^^ method not found in `()` | note: method `sort_by_key` modifies its receiver in-place, it is not meant to be used in method chains. --> ./hello.rs:3:53 | 3 | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); | ^^^^^^^^^^^ this call modifies its receiver in-place ```
2023-03-14Rollup merge of #109110 - compiler-errors:impossible-impl-mono, r=jackh726Matthias Krüger-0/+13
Don't codegen impossible to satisfy impls Fixes #109098
2023-03-14Rollup merge of #109105 - compiler-errors:late-ct-in-anon-ct, r=oli-obkMatthias Krüger-0/+30
Don't ICE for late-bound consts across `AnonConstBoundary` Fixes #108194
2023-03-14Rollup merge of #109101 - compiler-errors:layout-err, r=michaelwoeristerMatthias Krüger-0/+22
Fall back to old metadata computation when type references errors Projection is a bit too aggressive normalizing `<dyn Trait<[type error]> as Pointee>::Metadata` to `[type error]`, rather than to `DynMetadata<..>`. Side-step that by just falling back to the old structural metadata computation. Fixes #109078
2023-03-14Rollup merge of #108923 - spastorino:new-rpitit-9, r=compiler-errorsMatthias Krüger-0/+2
Make fns from other crates with RPITIT work for -Zlower-impl-trait-in-trait-to-assoc-ty Only the last two commits are meaningful. r? `@compiler-errors`
2023-03-14Rollup merge of #108909 - spastorino:new-rpitit-7, r=compiler-errorsMatthias Krüger-12/+130
Fix object safety checks for new RPITITs This one goes on top of #108869 r? `@compiler-errors`
2023-03-14Rollup merge of #108880 - spastorino:new-rpitit-6, r=compiler-errorsMatthias Krüger-46/+236
Remove tests/ui/impl-trait/in-trait/new-lowering-strategy in favor of using revisions on existing tests r? `@compiler-errors` This one again sits on top of existing approved PRs and it still needs to add revisions to tests in `tests/ui/impl-trait/in-trait` as it only does so for async in traits.
2023-03-14Don't codegen impossible to satisfy implsMichael Goulet-0/+13
2023-03-14Emit "modifies receiver" diagnostic when no method is foundMaciej Wasilewski-5/+38
If no method is found when checking method call, we check if we called a method with signature (&mut T, ...) -> (). If this is the case then we emit a diagnostic message
2023-03-14Auto merge of #106505 - Nilstrieb:format-args-string-literal-episode-2, ↵bors-19/+144
r=petrochenkov Properly allow macro expanded `format_args` invocations to uses captures Originally, this was kinda half-allowed. There were some primitive checks in place that looked at the span to see whether the input was likely a literal. These "source literal" checks are needed because the spans created during `format_args` parsing only make sense when it is indeed a literal that was written in the source code directly. This is orthogonal to the restriction that the first argument must be a "direct literal", not being exanpanded from macros. This restriction was imposed by [RFC 2795] on the basis of being too confusing. But this was only concerned with the argument of the invocation being a literal, not whether it was a source literal (maybe in spirit it meant it being a source literal, this is not clear to me). Since the original check only really cared about source literals (which is good enough to deny the `format_args!(concat!())` example), macros expanding to `format_args` invocations were able to use implicit captures if they spanned the string in a way that lead back to a source string. The "source literal" checks were not strict enough and caused ICEs in certain cases (see #106191). So I tightened it up in #106195 to really only work if it's a direct source literal. This caused the `indoc` crate to break. `indoc` transformed the source literal by removing whitespace, which made it not a "source literal" anymore (which is required to fix the ICE). But since `indoc` spanned the literal in ways that made the old check think that it's a literal, it was able to use implicit captures (which is useful and nice for the users of `indoc`). This commit properly seperates the previously introduced concepts of "source literal" and "direct literal" and therefore allows `indoc` invocations, which don't create "source literals" to use implicit captures again. Fixes #106191 [RFC 2795]: https://rust-lang.github.io/rfcs/2795-format-args-implicit-identifiers.html#macro-hygiene
2023-03-14Make fns from other crates with RPITIT workSantiago Pastorino-0/+2
2023-03-14Properly allow macro expanded `format_args` invocations to uses capturesNilstrieb-19/+144
Originally, this was kinda half-allowed. There were some primitive checks in place that looked at the span to see whether the input was likely a literal. These "source literal" checks are needed because the spans created during `format_args` parsing only make sense when it is indeed a literal that was written in the source code directly. This is orthogonal to the restriction that the first argument must be a "direct literal", not being exanpanded from macros. This restriction was imposed by [RFC 2795] on the basis of being too confusing. But this was only concerned with the argument of the invocation being a literal, not whether it was a source literal (maybe in spirit it meant it being a source literal, this is not clear to me). Since the original check only really cared about source literals (which is good enough to deny the `format_args!(concat!())` example), macros expanding to `format_args` invocations were able to use implicit captures if they spanned the string in a way that lead back to a source string. The "source literal" checks were not strict enough and caused ICEs in certain cases (see # 106191 (the space is intended to avoid spammy backreferences)). So I tightened it up in # 106195 to really only work if it's a direct source literal. This caused the `indoc` crate to break. `indoc` transformed the source literal by removing whitespace, which made it not a "source literal" anymore (which is required to fix the ICE). But since `indoc` spanned the literal in ways that made the old check think that it's a literal, it was able to use implicit captures (which is useful and nice for the users of `indoc`). This commit properly seperates the previously introduced concepts of "source literal" and "direct literal" and therefore allows `indoc` invocations, which don't create "source literals" to use implicit captures again. [RFC 2795]: https://rust-lang.github.io/rfcs/2795-format-args-implicit-identifiers.html#macro-hygiene
2023-03-14Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errorsbors-273/+109
Remove `identity_future` indirection This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm. Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]`annotation. Fixes https://github.com/rust-lang/rust/issues/104826.
2023-03-14Auto merge of #108992 - petrochenkov:qcstore2, r=cjgillotbors-4/+4
resolve: Querify most cstore access methods (subset) A subset of https://github.com/rust-lang/rust/pull/108346 that is not on a hot path in any way.
2023-03-13Don't ICE for late-bound consts across AnonConstBoundaryMichael Goulet-0/+30
2023-03-13Layout of `&dyn Trait<[type error]>` is still wideMichael Goulet-0/+22
2023-03-13Rollup merge of #109088 - Nilstrieb:target-feature-on-statics-when, ↵Matthias Krüger-16/+114
r=compiler-errors Gracefully handle `#[target_feature]` on statics The was careful around not calling `fn_sig` on not-functions but well, it wasn't careful enough. This commit makes it a little more careful and also adds tests for a bunch more item kinds. I was sadly not able to fully bless the test locally because I'm on an aarch64 machine but I hope some manual editing made it work 😅 Fix #109079
2023-03-13Rollup merge of #109081 - krasimirgg:llvm-17-simd-wide-sum, r=nikicMatthias Krüger-1/+1
simd-wide-sum test: adapt for LLVM 17 codegen change After https://github.com/llvm/llvm-project/commit/0d4a709bb876824a0afa5f86e138e8ffdcaf7661 LLVM becomes more clever and turns ```@wider_reduce_loop``` into an alias: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/17806#0186da6b-582c-46bf-a227-1565fa0859ac/743-766 This adapts the test to prevent this.
2023-03-13Rollup merge of #108830 - compiler-errors:new-solver-fast-reject-faster, r=lcnrMatthias Krüger-0/+67
Treat projections with infer as placeholder during fast reject in new solver r? ``@lcnr`` Kind of a shame that we need to change all of the call sites for `for_each_relevant_impl`, etc. to pass an extra parameter. I guess I could have the "default" fn which calls a configurable fn?
2023-03-13Gracefully handle `#[target_feature]` on staticsNilstrieb-16/+114
The was careful around not calling `fn_sig` on not-functions but well, it wasn't careful enough. This commit makes it a little more careful and also adds tests for a bunch more item kinds.
2023-03-13Add a test that used to take forever to compileMichael Goulet-0/+43
2023-03-13Treat projections with infer as placeholder during fast reject in new solverMichael Goulet-0/+24
2023-03-13simd-wide-sum test: adapt for LLVM 17 codegen changeKrasimir Georgiev-1/+1
After https://github.com/llvm/llvm-project/commit/0d4a709bb876824a0afa5f86e138e8ffdcaf7661 LLVM becomes more clever and turns `@wider_reduce_loop` into an alias: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/17806#0186da6b-582c-46bf-a227-1565fa0859ac/743-766 This adapts the test to prevent this.
2023-03-13Auto merge of #108623 - scottmcm:try-different-as-slice-impl, r=the8472bors-5/+13
Move `Option::as_slice` to an always-sound implementation This approach depends on CSE to not have any branches or selects when the guessed offset is correct -- which it always will be right now -- but to also be *sound* (just less efficient) if the layout algorithms change such that the guess is incorrect. The codegen test confirms that CSE handles this as expected, leaving the optimal codegen. cc JakobDegen #108545
2023-03-13resolve: Remove `struct_field_names_untracked`Vadim Petrochenkov-4/+4
2023-03-13Auto merge of #108471 - clubby789:unbox-the-syntax, r=Nilstrieb,est31bors-786/+806
Remove `box_syntax` r? `@Nilstrieb` This removes the feature `box_syntax`, which allows the use of `box <expr>` to create a Box, and finalises removing use of the feature from the compiler. `box_patterns` (allowing the use of `box <pat>` in a pattern) is unaffected. It also removes `ast::ExprKind::Box` - the only way to create a 'box' expression now is with the rustc-internal `#[rustc_box]` attribute. As a temporary measure to help users move away, `box <expr>` now parses the inner expression, and emits a `MachineApplicable` lint to replace it with `Box::new` Closes #49733
2023-03-12Auto merge of #108872 - cjgillot:simp-const-prop, r=oli-obkbors-15/+17
Strengthen state tracking in const-prop Some/many of the changes are replicated between both the const-prop lint and the const-prop optimization. Behaviour changes: - const-prop opt does not give a span to propagated values. This was useless as that span's primary purpose is to diagnose evaluation failure in codegen. - we remove the `OnlyPropagateInto` mode. It was only used for function arguments, which are better modeled by a write before entry. - the tracking of assignments and discriminants make clearer that we do nothing in `NoPropagation` mode or on indirect places.
2023-03-12Add a codegen test to confirm this fixes 73258Scott McMurray-0/+38
2023-03-12Add a codegen test to confirm this fixes 106369Scott McMurray-0/+15
2023-03-12Rollup merge of #109029 - compiler-errors:parse-gating, r=jackh726Matthias Krüger-12/+49
Gate usages of `dyn*` and const closures in macros We silently accepted `dyn*` and const closures in macros as long as they didn't expand to anything containing these experimental features, unlike other gated features such as `for<'a>` binders on closures, etc. Let's not do that, to make sure nobody begins relying on this.
2023-03-12Rollup merge of #109009 - notriddle:notriddle/edit-distance, r=GuillaumeGomezMatthias Krüger-0/+12
rustdoc: use restricted Damerau-Levenshtein distance for search Based on https://github.com/rust-lang/rust/pull/108200, for the same rationale. > This replaces the existing Levenshtein algorithm with the Damerau-Levenshtein algorithm. This means that "ab" to "ba" is one change (a transposition) instead of two (a deletion and insertion). More specifically, this is a restricted implementation, in that "ca" to "abc" cannot be performed as "ca" → "ac" → "abc", as there is an insertion in the middle of a transposition. I believe that errors like that are sufficiently rare that it's not worth taking into account. Before this change, searching [`prinltn!`] listed `print!` first, followed by `println!`. With this change, `println!` matches more closely. [`prinltn!`]: https://doc.rust-lang.org/nightly/std/?search=prinltn!
2023-03-12Forbid the use of `#[target_feature]` on `start`Léo Lanteri Thauvin-0/+20
2023-03-12Forbid the use of `#[target_feature]` on `main`Léo Lanteri Thauvin-1/+18
2023-03-12Fix object safety checks for new RPITITsSantiago Pastorino-6/+59
2023-03-12Filter out RPITITs in object_safety_violations_for_traitSantiago Pastorino-3/+32
2023-03-12Filter out RPITITs in astconv when checking for missing associated typesSantiago Pastorino-3/+39
2023-03-12Run existing impl trait in traits tests using ↵Santiago Pastorino-8/+91
-Zlower-impl-trait-in-trait-to-assoc-ty
2023-03-12Run existing async in traits tests using -Zlower-impl-trait-in-trait-to-assoc-tySantiago Pastorino-10/+145
2023-03-12Remove tests/ui/impl-trait/in-trait/new-lowering-strategy in favor of using ↵Santiago Pastorino-28/+0
revisions on existing tests
2023-03-12Add recovery for use of removed `box` syntaxclubby789-10/+77
2023-03-12Remove `box_syntax` from AST and use in toolsclubby789-44/+18
2023-03-12Remove uses of `box_syntax` in rustc and toolsclubby789-742/+721
2023-03-12Rollup merge of #109034 - compiler-errors:lazy-norm-tests, r=jackh726Matthias Krüger-0/+172
Commit some tests for the new solver + lazy norm Also consolidate `typeck/lazy-norm` into `traits/new-solver`, since it's not really useful to maintain a distinction, like when a test really is due to "lazy norm" or "the new solver" (usually both!)
2023-03-12Rollup merge of #108841 - jackh726:issue-90528, r=compiler-errorsMatthias Krüger-0/+400
Add suggestion to diagnostic when user has array but trait wants slice. (rebased) Rebase of #91314, except for change to multipart suggestion Resolves #90528 r? ``@compiler-errors`` since you requested the multipart suggestion
2023-03-11Move `Option::as_slice` to an always-sound implementationScott McMurray-5/+13
This approach depends on CSE to not have any branches or selects when the guessed offset is correct -- which it always will be right now -- but to also be *sound* (just less efficient) if the layout algorithms change such that the guess is incorrect.