about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-10-24Auto merge of #116435 - compiler-errors:re-erased, r=lcnrbors-0/+51
Handle `ReErased` in responses in new solver There are legitimate cases in the compiler where we return `ReErased` for lifetimes that are uncaptured in the hidden type of an opaque. For example, in the test committed below, we ignore ignore the bivariant lifetimes of an opaque when it's inferred as the hidden type of another opaque. This may result in a `type_of(Opaque)` call returning a type that references `ReErased`. Let's handle this gracefully in the new solver. Also added a `rustc_hidden_type_of_opaques` attr to print hidden types. This seems useful for opaques. r? lcnr
2023-10-24Auto merge of #116300 - cjgillot:split-move, r=petrochenkovbors-69/+57
Separate move path tracking between borrowck and drop elaboration. The primary goal of this PR is to skip creating a `MovePathIndex` for path that do not need dropping in drop elaboration. The 2 first commits are cleanups. The next 2 commits displace `move` errors from move-path builder to borrowck. Move-path builder keeps the same logic, but does not carry error information any more. The remaining commits allow to filter `MovePathIndex` creation according to types. This is used in drop elaboration, to avoid computing dataflow for paths that do not need dropping.
2023-10-23Auto merge of #117103 - matthiaskrgr:rollup-96zuuom, r=matthiaskrgrbors-0/+33
Rollup of 6 pull requests Successful merges: - #107159 (rand use getrandom for freebsd (available since 12.x)) - #116859 (Make `ty::print::Printer` take `&mut self` instead of `self`) - #117046 (return unfixed len if pat has reported error) - #117070 (rustdoc: wrap Type with Box instead of Generics) - #117074 (Remove smir from triage and add me to stablemir) - #117086 (Update .mailmap to promote my livename) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-23Rollup merge of #117046 - bvanjoi:fix-116186, r=oli-obkMatthias Krüger-0/+33
return unfixed len if pat has reported error - Fixes #116186 - Fixes #113021 This issue arises due to the creation of a fixed-length pattern, as a result of the mir body corruption. The corruption taints `tcx.eval_to_allocation_raw`, causing it to return `AlreadyReported`. Consequently, this prevents `len.try_eval_target_usize` from evaluating correctly and returns `None`. Lastly, it results in the return of `[usize; min_len]`. To rectify this issue, my approach is that to return unfixed when encountering `ErrorHandled::Reported`. Additionally, in instances of `ErrorHandled::TooGeneric`, the previous logic has been reinstated.
2023-10-23Auto merge of #116033 - bvanjoi:fix-116032, r=petrochenkovbors-24/+120
report `unused_import` for empty reexports even it is pub Fixes #116032 An easy fix. r? `@petrochenkov` (Discovered this issue while reviewing #115993.)
2023-10-23Let's see what those opaque types actually areMichael Goulet-1/+37
2023-10-23Handle ReErased in responses in new solverMichael Goulet-0/+15
2023-10-23Auto merge of #107009 - cjgillot:jump-threading, r=pnkfelixbors-24/+1798
Implement jump threading MIR opt This pass is an attempt to generalize `ConstGoto` and `SeparateConstSwitch` passes into a more complete jump threading pass. This pass is rather heavy, as it performs a truncated backwards DFS on MIR starting from each `SwitchInt` terminator. This backwards DFS remains very limited, as it only walks through `Goto` terminators. It is build to support constants and discriminants, and a propagating through a very limited set of operations. The pass successfully manages to disentangle the `Some(x?)` use case and the DFA use case. It still needs a few tests before being ready.
2023-10-23Auto merge of #117087 - matthiaskrgr:rollup-08kkjkz, r=matthiaskrgrbors-1/+175
Rollup of 5 pull requests Successful merges: - #116960 (Location-insensitive polonius: consider a loan escaping if an SCC has member constraints applied only) - #116978 (Rewrite gdb pretty-printer registration) - #117040 (coverage: Add UI tests for values accepted by `-Cinstrument-coverage`) - #117064 (Eliminate rustc_attrs::builtin::handle_errors in favor of emitting errors directly) - #117073 (Fix suggestion for renamed coroutines feature) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-23Rollup merge of #117040 - Zalathar:instrument-coverage-ui, r=cjgillotMatthias Krüger-1/+70
coverage: Add UI tests for values accepted by `-Cinstrument-coverage` I wanted to clean up the code in `parse_instrument_coverage`, but it occurred to me that we currently don't have any UI tests for the various stable and unstable values supported by this flag. --- Normally it might be overkill to individually test all the different variants of `on`/`off`, but in this case the parsing of those values is mixed in with some other custom code, so I think it's worthwhile being thorough.
2023-10-23Rollup merge of #116960 - lqd:applied-member-constraints-scope, r=matthewjasperMatthias Krüger-0/+105
Location-insensitive polonius: consider a loan escaping if an SCC has member constraints applied only The location-insensitive analysis considered loans to escape if there were member constraints, which makes *some* sense for scopes and matches the scopes that NLL computes on all the tests. However, polonius and NLLs differ on the fuzzed case #116657, where an SCC has member constraints but no applied ones (and is kinda surprising). The existing UI tests with member constraints impacting scopes all have some constraint applied. This PR changes the location-insensitive analysis to consider a loan to escape if there are applied member constraints, and for extra paranoia/insurance via fuzzing and crater: actually checks the constraint's min choice is indeed a universal region as we expect. (This could be turned into a `debug_assert` and early return as a slight optimization after these periods of verification) The 4 UI tests where member constraints are meaningful for computing scopes still pass obviously, and this also fixes #116657. r? `@matthewjasper`
2023-10-23return unfixed len if pat has reported errorbohan-0/+33
2023-10-23Auto merge of #116837 - oli-obk:smir_run_macro, r=spastorinobors-11/+20
Avoid having `rustc_smir` depend on `rustc_interface` or `rustc_driver` This is done by moving all the logic into a macro that performs the entire "run" operation in one go. This makes https://github.com/rust-lang/rust/pull/116806 obsolete as a follow up we should make the macro usable without manually having to write ```rust #[macro_use] extern crate rustc_smir; extern crate stable_mir; extern crate rustc_driver; extern crate rustc_interface; use rustc_smir::rustc_internal; ``` in every crate that uses the macro. r? `@spastorino`
2023-10-23Try to work around 32 bit mingw issuesOli Scherer-0/+3
2023-10-23Auto merge of #116849 - oli-obk:error_shenanigans, r=cjgillotbors-168/+142
Avoid a `track_errors` by bubbling up most errors from `check_well_formed` I believe `track_errors` is mostly papering over issues that a sufficiently convoluted query graph can hit. I made this change, while the actual change I want to do is to stop bailing out early on errors, and instead use this new `ErrorGuaranteed` to invoke `check_well_formed` for individual items before doing all the `typeck` logic on them. This works towards resolving https://github.com/rust-lang/rust/issues/97477 and various other ICEs, as well as allowing us to use parallel rustc more (which is currently rather limited/bottlenecked due to the very sequential nature in which we do `rustc_hir_analysis::check_crate`) cc `@SparrowLii` `@Zoxc` for the new `try_par_for_each_in` function
2023-10-23Avoid having `rustc_smir` depend on `rustc_interface` or `rustc_driver`Oli Scherer-11/+17
2023-10-23coverage: Add UI tests for values accepted by `-Cinstrument-coverage`Zalathar-1/+70
2023-10-23Rollup merge of #117042 - Zalathar:file-table, r=cjgillotMatthias Krüger-3/+3
coverage: Emit the filenames section before encoding per-function mappings When embedding coverage information in LLVM IR (and ultimately in the resulting binary), there are two main things that each CGU needs to emit: - A single `__llvm_covmap` record containing a coverage header, which mostly consists of a list of filenames used by the CGU's coverage mappings. - Several `__llvm_covfun` records, one for each instrumented function, each of which contains the hash of the list of filenames in the header. There is a kind of loose cyclic dependency between the two: we need the hash of the file table before we can emit the covfun records, but we need to traverse all of the instrumented functions in order to build the file table. The existing code works by processing the individual functions first. It lazily adds filenames to the file table, and stores the mostly-complete function records in a temporary list. After this it hashes the file table, emits the header (containing the file table), and then uses the hash to emit all of the function records. This PR reverses that order: first we traverse all of the functions (without trying to prepare their function records) to build a *complete* file table, and then emit it immediately. At this point we have the file table hash, so we can then proceed to build and emit all of the function records, without needing to store them in an intermediate list. --- Along the way, this PR makes some necessary changes that are also worthwhile in their own right: - We split `FunctionCoverage` into distinct collector/finished phases, which neatly avoids some borrow-checker hassles when extracting a function's final expression/mapping data. - We avoid having to re-sort a function's mappings when preparing the list of filenames that it uses.
2023-10-23Auto merge of #115324 - francorbacho:master, r=davidtwcobors-0/+146
Suggest removing redundant arguments in format!() Closes #105225. This is also a follow-up to #105635, which seems to have become stale. r? `@estebank`
2023-10-22use visibility to check unused imports and delete some stmtsbohan-24/+120
2023-10-22coverage: Emit the filenames section before encoding per-function mappingsZalathar-3/+3
Most coverage metadata is encoded into two sections in the final executable. The `__llvm_covmap` section mostly just contains a list of filenames, while the `__llvm_covfun` section contains encoded coverage maps for each instrumented function. The catch is that each per-function record also needs to contain a hash of the filenames list that it refers to. Historically this was handled by assembling most of the per-function data into a temporary list, then assembling the filenames buffer, then using the filenames hash to emit the per-function data, and then finally emitting the filenames table itself. However, now that we build the filenames table up-front (via a separate traversal of the per-function data), we can hash and emit that part first, and then emit each of the per-function records immediately after building. This removes the awkwardness of having to temporarily store nearly-complete per-function records.
2023-10-22Auto merge of #116256 - apekros:issue-114912, r=cjgillotbors-0/+33
Add test for rust-lang#114912 Closes #114912
2023-10-22Rollup merge of #117034 - Nadrieril:fix-117033, r=cjgillotMatthias Krüger-0/+7
Don't crash on empty match in the `nonexhaustive_omitted_patterns` lint Oops Fixes https://github.com/rust-lang/rust/issues/117033
2023-10-22Auto merge of #116932 - Kobzol:fix-stage1-tests, r=Mark-Simulacrumbors-2/+4
Fix x86_64-gnu-llvm-15 CI tests The CI script was broken - if there was a test failure in the first command chain (inside the `if`), CI would not report the failure. It happened because there were two command chains separated by `&&` in the script, and since `set -e` doesn't exit for chained commands, if the first chain has failed, the script would happily continue forward, ignoring any test failures. This could be fixed e.g. by adding some `|| exit 1` to the first chain, but I suppose that the `&&` chaining is unnecessary here anyway. Reported [on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/242791-t-infra/topic/test.20failure.20didn't.20stop.20CI). Fixes: https://github.com/rust-lang/rust/issues/116867
2023-10-21Fix #117033Nadrieril-0/+7
2023-10-21Rollup merge of #116992 - estebank:issue-69492, r=oli-obkMatthias Krüger-0/+11
Mention the syntax for `use` on `mod foo;` if `foo` doesn't exist Newcomers might get confused that `mod` is the only way of defining scopes, and that it can be used as if it were `use`. Fix #69492.
2023-10-21Mention the syntax for `use` on `mod foo;` if `foo` doesn't existEsteban Küber-0/+11
Newcomers might get confused that `mod` is the only way of defining scopes, and that it can be used as if it were `use`. Fix #69492.
2023-10-21Auto merge of #117020 - matthiaskrgr:rollup-cg62m4h, r=matthiaskrgrbors-5/+34
Rollup of 3 pull requests Successful merges: - #106601 (Suggest `;` after bare `match` expression E0308) - #116975 (Move `invalid-llvm-passes` test to `invalid-compile-flags` folder) - #117019 (fix spans for removing `.await` on `for` expressions) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-21Rollup merge of #117019 - lukas-code:for-await, r=compiler-errorsMatthias Krüger-1/+19
fix spans for removing `.await` on `for` expressions We need to use a span with the outer syntax context of a desugared `for` expression to join it with the `.await` span. fixes https://github.com/rust-lang/rust/issues/117014
2023-10-21Rollup merge of #116975 - ojeda:move-invalid-test, r=NilstriebMatthias Krüger-0/+0
Move `invalid-llvm-passes` test to `invalid-compile-flags` folder Nowadays there is an `invalid-compile-flags` folder, thus move this one there.
2023-10-21Rollup merge of #106601 - estebank:match-semi, r=cjgillotMatthias Krüger-4/+15
Suggest `;` after bare `match` expression E0308 Fix #72634.
2023-10-21fix spans for removing `.await` on `for` expressionsLukas Markeffsky-1/+19
2023-10-21Auto merge of #116734 - Nadrieril:lint-per-column, r=cjgillotbors-110/+232
Lint `non_exhaustive_omitted_patterns` by columns This is a rework of the `non_exhaustive_omitted_patterns` lint to make it more consistent. The intent of the lint is to help consumers of `non_exhaustive` enums ensure they stay up-to-date with all upstream variants. This rewrite fixes two cases we didn't handle well before: First, because of details of exhaustiveness checking, the following wouldn't lint `Enum::C` as missing: ```rust match Some(x) { Some(Enum::A) => {} Some(Enum::B) => {} _ => {} } ``` Second, because of the fundamental workings of exhaustiveness checking, the following would treat the `true` and `false` cases separately and thus lint about missing variants: ```rust match (true, x) { (true, Enum::A) => {} (true, Enum::B) => {} (false, Enum::C) => {} _ => {} } ``` Moreover, it would correctly not lint in the case where the pair is flipped, because of asymmetry in how exhaustiveness checking proceeds. A drawback is that it no longer makes sense to set the lint level per-arm. This will silently break the lint for current users of it (but it's behind a feature gate so that's ok). The new approach is now independent of the exhaustiveness algorithm; it's a separate pass that looks at patterns column by column. This is another of the motivations for this: I'm glad to move it out of the algorithm, it was akward there. This PR is almost identical to https://github.com/rust-lang/rust/pull/111651. cc `@eholk` who reviewed it at the time. Compared to then, I'm more confident this is the right approach.
2023-10-21Do not create move paths that do not need dropping.Camille GILLOT-58/+46
2023-10-21Do not report errors from move path builder.Camille GILLOT-11/+11
2023-10-21Rollup merge of #116995 - estebank:issue-69944, r=compiler-errorsMatthias Krüger-1/+6
Point at assoc fn definition on type param divergence When the number of type parameters in the associated function of an impl and its trait differ, we now *always* point at the trait one, even if it comes from a foreign crate. When it is local, we point at the specific params, when it is foreign, we point at the whole associated item. Fix #69944.
2023-10-21Rollup merge of #116990 - estebank:issue-68445, r=cjgillotMatthias Krüger-0/+4
Mention `into_iter` on borrow errors suggestions when appropriate If we encounter a borrow error on `vec![1, 2, 3].iter()`, suggest `into_iter`. Fix #68445.
2023-10-21Rollup merge of #116974 - Zalathar:signature-spans, r=oli-obk,cjgillotMatthias Krüger-10/+192
coverage: Fix inconsistent handling of function signature spans While doing some more cleanup of `spans`, I noticed a strange inconsistency in how function signatures are handled. Normally the function signature span is treated as though it were executable as part of the start of the function, but in some cases the signature span disappears entirely from coverage, for no obvious reason. This is caused by the fact that spans created by `CoverageSpan::for_fn_sig` don't add the span to their `merged_spans` field (unlike normal statement/terminator spans). In cases where the span-processing code looks at those merged spans, it thinks the signature span is no longer visible and deletes it. Adding the signature span to `merged_spans` resolves the inconsistency. (Prior to #116409 this wouldn't have been possible, because there was no case in the old `CoverageStatement` enum representing a signature. Now that `merged_spans` is just a list of spans, that's no longer an obstacle.)
2023-10-21Rollup merge of #116964 - celinval:smir-mono-body, r=oli-obkMatthias Krüger-1/+25
Add stable Instance::body() and RustcInternal trait The `Instance::body()` returns a monomorphized body. For that, we had to implement visitor that monomorphize types and constants. We are also introducing the RustcInternal trait that will allow us to convert back from Stable to Internal. Note that this trait is not yet visible for our users as it depends on Tables. We should probably add a new trait that can be exposed. The tests here are very simple, and I'm planning on creating more exhaustive tests in the project-mir repo. But I was hoping to get some feedback here first. r? ```@oli-obk```
2023-10-21Rollup merge of #116961 - estebank:issue-60164, r=oli-obkMatthias Krüger-0/+24
Typo suggestion to change bindings with leading underscore When encountering a binding that isn't found but has a typo suggestion for a binding with a leading underscore, suggest changing the binding definition instead of the use place. Fix #60164.
2023-10-21Rollup merge of #116911 - estebank:issue-85378, r=oli-obkMatthias Krüger-0/+44
Suggest relaxing implicit `type Assoc: Sized;` bound Fix #85378.
2023-10-21FileCheck annotations.Camille GILLOT-34/+217
2023-10-21Correct loop_headers logic.Camille GILLOT-14/+2
2023-10-21Rebase fallout.Camille GILLOT-25/+1
2023-10-21Handle more terminators.Camille GILLOT-6/+24
2023-10-21Do not thread through loop headers.Camille GILLOT-32/+6
2023-10-21Implement JumpThreading pass.Camille GILLOT-0/+1635
2023-10-21coverage: Handle fn signature spans more consistently near `?`Zalathar-20/+22
2023-10-21coverage: Add a test showing the inconsistent handling of function signaturesZalathar-0/+180
2023-10-20Point at assoc fn definition on type param divergenceEsteban Küber-1/+6
When the number of type parameters in the associated function of an impl and its trait differ, we now *always* point at the trait one, even if it comes from a foreign crate. When it is local, we point at the specific params, when it is foreign, we point at the whole associated item. Fix #69944.