summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2024-04-29Don't trigger `unused_qualifications` on global paths许杰友 Jieyou Xu (Joe)-25/+23
2024-04-22Stop using HirId for fn-like parentsMichael Goulet-0/+63
(cherry picked from commit 68d7c837fc377ac4145d931171fa2b1d1bd1670f)
2024-04-19disable two debuginfo tests under gdb 15Rémy Rakic-0/+4
it seems gdb 15 regresses some of our debuginfo tests. disable them temporarily so that CI doesn't randomly start failing soon. (cherry picked from commit 6e19f82160c216fcb5f8eaff915b7fe274a5568e)
2024-04-18rustdoc: check redundant explicit links with correct itemidMichael Howell-0/+14
Fixes a regression caused by 0a50dba50bedd24377bd1066da3b4b7066df4d28 (cherry picked from commit 0fea38a01f4015d310230b76984068b6fe8414d4)
2024-04-18Silence unused_imports lint for redundant importsMichael Goulet-238/+36
(cherry picked from commit 0db2a4010a5a7a57372e9135d327da8c7d92c8ab)
2024-04-11add non-regression test for issue 123275Rémy Rakic-0/+244
(cherry picked from commit 54f8db84329116889fce5d58292b5cc6b83642e6)
2024-04-11Check def id before calling match_projection_projectionsMichael Goulet-0/+38
(cherry picked from commit 43dae6934153693be62902fcefed0f97b4ca892f)
2024-04-11Only inspect user-written predicates for privacy concernsOli Scherer-11/+6
(cherry picked from commit 83bd12c70fd34dece71bcc632ee3df64036ca1d8)
2024-04-11Add regression testOli Scherer-0/+43
(cherry picked from commit 769ab55558488d1ff786fa13e8ba1fb071a9791b)
2024-04-11fix attribute validation on associated items in traitsgvozdvmozgu-0/+15
(cherry picked from commit 8b576d553678688ece127b6f6a25b611e8726c05)
2024-04-09Use new-style directives in ui testChris Denton-3/+3
2024-04-09Disallow or quote all specials in bat argsChris Denton-0/+93
2024-04-04Make sure to insert Sized bound first into clauses listMichael Goulet-1/+31
(cherry picked from commit f2fd2d8c7080f7a7d770b3e3d27e525250c182dc)
2024-04-04Don't inherit codegen attrs from parent staticMichael Goulet-0/+11
(cherry picked from commit 4ff8a9bd6b64e32703603cf8bc8cb5cb221d4889)
2024-04-04Fix f16 and f128 feature gates in editions other than 2015Trevor Gross-20/+20
Fixes https://github.com/rust-lang/rust/issues/123282 Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com> (cherry picked from commit 5afe072ead1154f9817ee610e3e60345507c7625)
2024-04-04Update f16 and f128 tests to run on both 2015 and 2018 editionsTrevor Gross-10/+146
Reproduce the bug from <https://github.com/rust-lang/rust/issues/123282> that indicates this feature gate hits edition-dependent resolution paths. Resolution changed in edition 2018, so test that as well. (cherry picked from commit 9a7b1762279eaa95d0289760d3b859fbbc9221f1)
2024-03-28Make `#[diagnostic::on_unimplemented]` format string parsing more robustGeorg Semmler-0/+238
This commit fixes several issues with the format string parsing of the `#[diagnostic::on_unimplemented]` attribute that were pointed out by @ehuss. In detail it fixes: * Appearing format specifiers (display, etc). For these we generate a warning that the specifier is unsupported. Otherwise we ignore them * Positional arguments. For these we generate a warning that positional arguments are unsupported in that location and replace them with the format string equivalent (so `{}` or `{n}` where n is the index of the positional argument) * Broken format strings with enclosed }. For these we generate a warning about the broken format string and set the emitted message literally to the provided unformatted string * Unknown format specifiers. For these we generate an additional warning about the unknown specifier. Otherwise we emit the literal string as message. This essentially makes those strings behave like `format!` with the minor difference that we do not generate hard errors but only warnings. After that we continue trying to do something unsuprising (mostly either ignoring the broken parts or falling back to just giving back the literal string as provided). Fix #122391 (cherry picked from commit 5568c569c03c8c22ce81185b9e49efcaa6866050)
2024-03-28add non-regression test for issue 122674Rémy Rakic-0/+22
(cherry picked from commit f3e9dfaed6c4d44fc0a5182221c31e5b0ff038fd)
2024-03-18Explicitly pass RUSTC_BOOTSTRAP to running wasmtimeMark Rousskov-0/+1
This ensures that tests are permitted to use nightly features, which is currently required for them to run at all. Also ignore a test that relies on running with RUSTC_BOOTSTRAP *not* set.
2024-03-16Auto merge of #122371 - oli-obk:visit_nested_body, r=tmiaskobors-0/+35
Stop walking the bodies of statics for reachability, and evaluate them instead cc `@saethlin` `@RalfJung` cc #119214 This reuses the `DefIdVisitor` from `rustc_privacy`, because they basically try to do the same thing. This PR's changes can probably be extended to constants, too, but let's tackle that separately, it's likely more involved.
2024-03-16Auto merge of #121926 - tgross35:f16-f128-step3-feature-gate, ↵bors-104/+239
r=compiler-errors,petrochenkov `f16` and `f128` step 3: compiler support & feature gate Continuation of https://github.com/rust-lang/rust/pull/121841, another portion of https://github.com/rust-lang/rust/pull/114607 This PR exposes the new types to the world and adds a feature gate. Marking this as a draft because I need some feedback on where I did the feature gate check. It also does not yet catch type via suffixed literals (so the feature gate test will fail, probably some others too because I haven't belssed). If there is a better place to check all types after resolution, I can do that. If not, I figure maybe I can add a second gate location in AST when it checks numeric suffixes. Unfortunately I still don't think there is much testing to be done for correctness (codegen tests or parsed value checks) until we have basic library support. I think that will be the next step. Tracking issue: https://github.com/rust-lang/rust/issues/116909 r? `@compiler-errors` cc `@Nilstrieb` `@rustbot` label +F-f16_and_f128
2024-03-15Auto merge of #122571 - matthiaskrgr:rollup-36wwovk, r=matthiaskrgrbors-220/+351
Rollup of 6 pull requests Successful merges: - #122254 (Detect calls to .clone() on T: !Clone types on borrowck errors) - #122495 (Visually mark 👻hidden👻 items with document-hidden-items) - #122543 (Add `#![rustc_never_type_mode = "..."]` crate-level attribute to allow experimenting) - #122560 (Safe Transmute: Use 'not yet supported', not 'unspecified' in errors) - #122562 (Mention labelled blocks in `break` docs) - #122563 (CI: cache PR CI Docker builds) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-15Rollup merge of #122560 - jswrenn:not-yet-supported, r=compiler-errorsMatthias Krüger-179/+179
Safe Transmute: Use 'not yet supported', not 'unspecified' in errors We can (and will) support analyzing the transmutability of types whose layouts aren't completely specified by its repr. This change ensures that the error messages remain sensible after this support lands. r? ``@compiler-errors``
2024-03-15Rollup merge of #122495 - Manishearth:rustdoc-👻👻👻, r=GuillaumeGomezMatthias Krüger-4/+8
Visually mark 👻hidden👻 items with document-hidden-items Fixes #122485 This adds a 👻 in the item list (much like the :lock: used for private items), and also shows `#[doc(hidden)]` in the code view, where `pub(crate)` etc gets shown for private items. This does not do anything for enum variants, if people have ideas. I think we can just show the attribute.
2024-03-15Rollup merge of #122254 - estebank:issue-48677, r=oli-obkMatthias Krüger-37/+164
Detect calls to .clone() on T: !Clone types on borrowck errors When encountering a lifetime error on a type that *holds* a type that doesn't implement `Clone`, explore the item's body for potential calls to `.clone()` that are only cloning the reference `&T` instead of `T` because `T: !Clone`. If we find this, suggest `T: Clone`. ``` error[E0502]: cannot borrow `*list` as mutable because it is also borrowed as immutable --> $DIR/clone-on-ref.rs:7:5 | LL | for v in list.iter() { | ---- immutable borrow occurs here LL | cloned_items.push(v.clone()) | ------- this call doesn't do anything, the result is still `&T` because `T` doesn't implement `Clone` LL | } LL | list.push(T::default()); | ^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | LL | drop(cloned_items); | ------------ immutable borrow later used here | help: consider further restricting this bound | LL | fn foo<T: Default + Clone>(list: &mut Vec<T>) { | +++++++ ``` ``` error[E0505]: cannot move out of `x` because it is borrowed --> $DIR/clone-on-ref.rs:23:10 | LL | fn qux(x: A) { | - binding `x` declared here LL | let a = &x; | -- borrow of `x` occurs here LL | let b = a.clone(); | ------- this call doesn't do anything, the result is still `&A` because `A` doesn't implement `Clone` LL | drop(x); | ^ move out of `x` occurs here LL | LL | println!("{b:?}"); | ----- borrow later used here | help: consider annotating `A` with `#[derive(Clone)]` | LL + #[derive(Clone)] LL | struct A; | ``` Fix #48677.
2024-03-15Auto merge of #122341 - compiler-errors:alias-wfness, r=lcnrbors-6/+60
Consolidate WF for aliases Make RPITs/TAITs/weak (type) aliases/projections all enforce: 1. their nominal predicates 2. their args are WF This possibly does extra work, but is also nice for consistency sake. r? lcnr
2024-03-15Safe Transmute: lowercase diagnosticsJack Wrenn-153/+153
2024-03-15Safe Transmute: Use 'not yet supported', not 'unspecified' in errorsJack Wrenn-26/+26
We can (and will) support analyzing the transmutability of types whose layouts aren't completely specified by its repr. This change ensures that the error messages remain sensible after this support lands.
2024-03-15Auto merge of #122555 - GuillaumeGomez:rollup-tr6wu54, r=GuillaumeGomezbors-0/+2
Rollup of 6 pull requests Successful merges: - #114651 (rustdoc: add `--test-builder-wrapper` arg to support wrappers such as RUSTC_WRAPPER when building doctests) - #122468 (Cleanup `MirBorrowckCtxt::prefixes`) - #122496 (Greatly reduce GCC build logs) - #122512 (Cursor.rs documentation fix) - #122513 (hir: Remove `opt_local_def_id_to_hir_id` and `opt_hir_node_by_def_id`) - #122530 (less symbol interner locks) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-15Rollup merge of #114651 - tmfink:rustdoc-rustc-wrapper, r=GuillaumeGomezGuillaume Gomez-0/+2
rustdoc: add `--test-builder-wrapper` arg to support wrappers such as RUSTC_WRAPPER when building doctests Currently, `rustdoc` builds test crates with `rustc` directly instead of using [`RUSTC_WRAPPER`](https://doc.rust-lang.org/cargo/reference/config.html#buildrustc-wrapper) (if any is set). This causes build issues in build systems that use `cargo` but tweak linking flags by setting the `RUSTC_WRAPPER` environment variable. This change is not meant to be final--it's only a minimal proof of concept. Please advise on the best way to proceed. Open questions: - [x] Does supporting the `rustc` wrappers make sense? - yes, `cargo-miri` for example needs a "hack" to workaround the issue - [X] What environment variable(s) should be read for the rustc wrapper? Should `rustdoc` [use the same names as `cargo`](https://doc.rust-lang.org/cargo/reference/config.html#buildrustc-wrapper)? - None, since `rustdoc` takes arguments - [X] What name should be used for a `rustdoc` CLI option? - `--test-builder-wrapper` - [X] Should a separate workspace wrapper (like `RUSTC_WORKSPACE_WRAPPER`) be supported? - `--test-builder-wrapper` can be passed multiple times to get multiple wrappers passed - [X] How/where should this be documented? It's not obvious to all users that `cargo doc` actually causes `rustdoc` to compile tests with rust - Added doc to `src/doc/rustdoc/src/command-line-arguments.md` per `@GuillaumeGomez`
2024-03-15Auto merge of #121297 - michaelwoerister:set-pdb-alt-path, r=wesleywiserbors-0/+44
link.exe: Don't embed full path to PDB file in binary. This PR makes `rustc` unconditionally pass `/PDBALTPATH:%_PDB%` to MSVC-style linkers, causing the linker to only embed the filename of the PDB in the binary instead of the full path. This will help implement the [trim-paths RFC](https://github.com/rust-lang/rust/issues/111540) for `*-msvc` targets. Passing `/PDBALTPATH:%_PDB%` to the linker is already done by many projects that need reproducible builds and [debugger's should still be able to find the PDB](https://learn.microsoft.com/cpp/build/reference/pdbpath) if it is in the same directory as the binary. r? `@ghost` Fixes https://github.com/rust-lang/rust/issues/87825
2024-03-15Rollup merge of #122523 - compiler-errors:ensure-associated-types, r=oli-obkMatthias Krüger-0/+22
Ensure RPITITs are created before def-id freezing From the test: ```rust // `ty::Error` in a trait ref will silence any missing item errors, but will also // prevent the `associated_items` query from being called before def ids are frozen. ``` Essentially, the code that checks that `impl`s have all their items (`check_impl_items_against_trait`) is also (implicitly) responsible for fetching the `associated_items` query before, but since we early return here: https://github.com/rust-lang/rust/blob/c2901f543577af99b9cb708f5c0d28525eb7f08f/compiler/rustc_hir_analysis/src/check/check.rs#L732-L737 ...that means that this never happens for trait refs that reference errors. Fixes #122518 r? oli-obk
2024-03-15Rollup merge of #122515 - jieyouxu:ice-self-ty-mismatch, r=compiler-errorsMatthias Krüger-0/+62
Pass the correct DefId when suggesting writing the aliased Self type out Fixes #122467.
2024-03-15Rollup merge of #122471 - RalfJung:const-eval-span, r=oli-obkMatthias Krüger-2/+181
preserve span when evaluating mir::ConstOperand This lets us show to the user where they were using the faulty const (which can be quite relevant when generics are involved). I wonder if we should change "erroneous constant encountered" to something like "the above error was encountered while evaluating this constant" or so, to make this more similar to what the collector emits when showing a "backtrace" of where things get monomorphized? It seems a bit strange to rely on the order of emitted diagnostics for that but it seems the collector already [does that](https://github.com/rust-lang/rust/blob/da8a8c9223722e17cc0173ce9490076b4a6d263d/compiler/rustc_monomorphize/src/collector.rs#L472-L475).
2024-03-15Rollup merge of #122174 - notriddle:master, r=TaKO8KiMatthias Krüger-0/+38
diagnostics: suggest `Clone` bounds when noop `clone()` Fixes #121524
2024-03-15rustdoc: fix test's saved stdoutTravis Finkenauer-0/+2
Also reword "test-builder-wrapper" argument help.
2024-03-15Auto merge of #122517 - petrochenkov:bodihash, r=oli-obkbors-0/+11
Fill in HIR hash for associated opaque types Fixes https://github.com/rust-lang/rust/issues/122508
2024-03-14Ensure RPITITs are created before def-id freezingMichael Goulet-0/+22
2024-03-15Auto merge of #122511 - matthiaskrgr:rollup-swzilin, r=matthiaskrgrbors-23/+1175
Rollup of 10 pull requests Successful merges: - #117118 ([AIX] Remove AixLinker's debuginfo() implementation) - #121650 (change std::process to drop supplementary groups based on CAP_SETGID) - #121764 (Make incremental sessions identity no longer depend on the crate names provided by source code) - #122212 (Copy byval argument to alloca if alignment is insufficient) - #122322 (coverage: Initial support for branch coverage instrumentation) - #122373 (Fix the conflict problem between the diagnostics fixes of lint `unnecessary_qualification` and `unused_imports`) - #122479 (Implement `Duration::as_millis_{f64,f32}`) - #122487 (Rename `StmtKind::Local` variant into `StmtKind::Let`) - #122498 (Update version of cc crate) - #122503 (Make `SubdiagMessageOp` well-formed) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-14preserve span when evaluating mir::ConstOperandRalf Jung-2/+181
2024-03-14Fill in HIR hash for associated opaque typesVadim Petrochenkov-0/+11
2024-03-14Pass the correct DefId when suggesting writing the aliased Self type out许杰友 Jieyou Xu (Joe)-0/+62
2024-03-14Rollup merge of #122487 - GuillaumeGomez:rename-stmtkind-local, r=oli-obkMatthias Krüger-3/+3
Rename `StmtKind::Local` variant into `StmtKind::Let` It comes from this [discussion](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Improve.20naming.20of.20.60ExprKind.3A.3ALet.60.3F). Starting point was: > I often end up looking at [ExprKind::Let](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir/enum.ExprKind.html#variant.Let) instead of Local because of the name. I think renaming it (both the `ExprKind` variant and the Let struct) to `LetPattern` or LetPat could improve the situation as I'm not sure I'm not the only one encountering this issue. And then it evolved into: > It's already `Expr::Let` instead of `StmtKind::Local`. Counterproposal: rename `StmtKind::Local` to `StmtKind::Let`. The goal here is to clear this confusion. r? `@oli-obk`
2024-03-14Rollup merge of #122373 - surechen:fix_121331, r=petrochenkovMatthias Krüger-20/+183
Fix the conflict problem between the diagnostics fixes of lint `unnecessary_qualification` and `unused_imports` fixes #121331 For an `item` that triggers lint unnecessary_qualification, if the `use item` which imports this item is also trigger unused import, fixing the two lints at the same time may lead to the problem that the `item` cannot be found. This PR will avoid reporting lint unnecessary_qualification when conflict occurs. r? ``@petrochenkov``
2024-03-14Rollup merge of #122322 - Zalathar:branch, r=oli-obkMatthias Krüger-0/+863
coverage: Initial support for branch coverage instrumentation (This is a review-ready version of the changes that were drafted in #118305.) This PR adds support for branch coverage instrumentation, gated behind the unstable flag value `-Zcoverage-options=branch`. (Coverage instrumentation must also be enabled with `-Cinstrument-coverage`.) During THIR-to-MIR lowering (MIR building), if branch coverage is enabled, we collect additional information about branch conditions and their corresponding then/else blocks. We inject special marker statements into those blocks, so that the `InstrumentCoverage` MIR pass can reliably identify them even after the initially-built MIR has been simplified and renumbered. The rest of the changes are mostly just plumbing needed to gather up the information that was collected during MIR building, and include it in the coverage metadata that we embed in the final binary. Note that `llvm-cov show` doesn't print branch coverage information in its source views by default; that needs to be explicitly enabled with `--show-branches=count` or similar. --- The current implementation doesn't have any support for instrumenting `if let` or let-chains. I think it's still useful without that, and adding it would be non-trivial, so I'm happy to leave that for future work.
2024-03-14Rollup merge of #122212 - erikdesjardins:byval-align2, r=wesleywiserMatthias Krüger-0/+126
Copy byval argument to alloca if alignment is insufficient Fixes #122211 "Ignore whitespace" recommended.
2024-03-14Auto merge of #119849 - lcnr:eagerly-instantiate-binders, r=compiler-errorsbors-373/+463
more eagerly instantiate binders The old solver sometimes incorrectly used `sub`, change it to explicitly instantiate binders and use `eq` instead. While doing so I also moved the instantiation before the normalize calls. This caused some observable changes, will explain these inline. This PR therefore requires a crater run and an FCP. r? types
2024-03-14Add UI tests related to feature-gated primitivesTrevor Gross-0/+72
Add a test that `f16` and `f128` are usable with the feature gate enabled, as well as a test that user types with the same name as primitives are not improperly gated.
2024-03-14Remove unneeded `f16` and `f128` parser testsTrevor Gross-104/+0
Superceded by feature gate tests.
2024-03-14Add feature gates for `f16` and `f128`Trevor Gross-0/+167
Includes related tests and documentation pages. Michael Goulet: Don't issue feature error in resolver for f16/f128 unless finalize Co-authored-by: Michael Goulet <michael@errs.io>