about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2025-05-10Warn when #[export_name] is used with generic functionsMu001999-0/+460
2025-05-08Auto merge of #140106 - dianne:deref-pat-usefulness, r=Nadrierilbors-15/+369
allow deref patterns to participate in exhaustiveness analysis Per [this proposal](https://hackmd.io/4qDDMcvyQ-GDB089IPcHGg#Exhaustiveness), this PR allows deref patterns to participate in exhaustiveness analysis. Currently all deref patterns enforce `DerefPure` bounds on their scrutinees, so this assumes all patterns it's analyzing are well-behaved. This also doesn't support [mixed exhaustiveness](https://hackmd.io/4qDDMcvyQ-GDB089IPcHGg#Mixed-exhaustiveness), and instead emits an error if deref patterns are used together with normal constructors. I think mixed exhaustiveness would be nice to have (especially if we eventually want to support arbitrary `Deref` impls[^1]), but it'd require more work to get reasonable diagnostics[^2]. Tracking issue for deref patterns: #87121 r? `@Nadrieril` [^1]: Regardless of whether we support limited exhaustiveness checking for untrusted `Deref` or always require other arms to be exhaustive, I think it'd be useful to allow mixed matching for user-defined smart pointers. And it'd be strange if it worked there but not for `Cow`. [^2]: I think listing out witnesses of non-exhaustiveness can be confusing when they're not necessarily disjoint, and when you only need to cover some of them, so we'd probably want special formatting and/or explanatory subdiagnostics. And if it's implemented similarly to unions, we'd probably also want some way of merging witnesses; the way witnesses for unions can appear duplicated is pretty unfortunate. I'm not sure yet how the diagnostics should look, especially for deeply nested patterns.
2025-05-07Auto merge of #140751 - GuillaumeGomez:rollup-eahw4ta, r=GuillaumeGomezbors-53/+264
Rollup of 8 pull requests Successful merges: - #140234 (Separate dataflow analysis and results) - #140614 (Correct warning message in restricted visibility) - #140671 (Parser: Recover error from named params while parse_path) - #140700 (Don't crash on error codes passed to `--explain` which exceed our internal limit of 9999 ) - #140706 ([rustdoc] Ensure that temporary doctest folder is correctly removed even if doctests failed) - #140734 (Fix regression from #140393 for espidf / horizon / nuttx / vita) - #140741 (add armv5te-unknown-linux-gnueabi target maintainer) - #140745 (run-make-support: set rustc dylib path for cargo wrapper) r? `@ghost` `@rustbot` modify labels: rollup
2025-05-07Auto merge of #140590 - lcnr:closure-in-dead-code, r=compiler-errorsbors-0/+78
borrowck nested items in dead code fixes https://github.com/rust-lang/rust/issues/140583 r? `@compiler-errors`
2025-05-07Rollup merge of #140706 - GuillaumeGomez:fix-missing-temp-dir-cleanup, ↵Guillaume Gomez-0/+42
r=notriddle [rustdoc] Ensure that temporary doctest folder is correctly removed even if doctests failed Fixes #139899. The bug was due to the fact that if any doctest fails for any reason, we call `exit` (or it's called inside `libtest` if not edition 2024), meaning that `TempDir`'s destructor isn't called, and therefore the temporary folder isn't cleaned up. Took me a while to figure out how to reproduce but finally I was able to reproduce the bug with: `````rust #![doc(test(attr(deny(warnings))))] //! ``` //! let a = 12; //! ``` ````` And then I ensured that panicking doctests were cleaned up as well: `````rust //! ``` //! panic!(); //! ``` ````` And finally I checked if it was fixed for merged doctests too (`--edition 2024`). To make this work, I needed to add a new public function in `libtest` too which would call a function once all tests have been run. So only issue is: I have absolutely no idea how we can add a regression test for this fix. If anyone has an idea... r? `@notriddle`
2025-05-07Rollup merge of #140700 - Kivooeo:new-fix-six, r=davidtwco,fmeaseGuillaume Gomez-0/+74
Don't crash on error codes passed to `--explain` which exceed our internal limit of 9999 removed panic in case where we do `--explain > 9999` and added check for it now error looks like this instead of ICE ``` $ rustc.exe --explain E10000 error: E10000 is not a valid error code ``` fixes #140647 r? `@fmease`
2025-05-07Rollup merge of #140671 - xizheyin:issue-140169, r=petrochenkovGuillaume Gomez-52/+95
Parser: Recover error from named params while parse_path Fixes #140169 I added test to the first commit and the second added the code and changes to test. r? `@petrochenkov`
2025-05-07Rollup merge of #140614 - yuk1ty:fix-invalid-module-name-visibility, r=davidtwcoGuillaume Gomez-1/+53
Correct warning message in restricted visibility Fixes #131220
2025-05-07Use `parse_param_general` when parsing `(T, U)->R` in `parse_path_segment`xizheyin-69/+86
Signed-off-by: xizheyin <xizheyin@smail.nju.edu.cn> Co-authored-by: Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
2025-05-07Add regression test for #139899Guillaume Gomez-0/+42
2025-05-06error early when mixing deref patterns with normal constructorsdianne-0/+91
Without adding proper support for mixed exhaustiveness, mixing deref patterns with normal constructors would either violate `ConstructorSet::split`'s invariant 4 or 7. We'd either be ignoring rows with normal constructors or we'd have problems in unspecialization from non-disjoint constructors. Checking mixed exhaustivenss similarly to how unions are currently checked should work, but the diagnostics for unions are confusing. Since mixing deref patterns with normal constructors is pretty niche (currently it only makes sense for `Cow`), emitting an error lets us avoid committing to supporting mixed exhaustiveness without a good answer for the diagnostics.
2025-05-06add exhaustiveness/usefulness tests for deref patternsdianne-0/+269
2025-05-06let deref patterns participate in usefulness/exhaustivenessdianne-15/+9
This does not yet handle the case of mixed deref patterns with normal constructors; it'll ICE in `Constructor::is_covered_by`. That'll be fixed in a later commit.
2025-05-07Rollup merge of #140713 - compiler-errors:check_ref_cast, r=lcnrJacob Pratt-0/+22
Structurally resolve in `check_ref_cast` in new solver Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/203 r? lcnr
2025-05-07Rollup merge of #140709 - notriddle:rm-unportable-markdown, r=GuillaumeGomezJacob Pratt-85/+0
rustdoc: remove unportable markdown lint and old parser Follow up https://github.com/rust-lang/rust/pull/127127
2025-05-07Rollup merge of #140607 - lcnr:opaque-type-storage, r=compiler-errorsJacob Pratt-0/+25
support duplicate entries in the opaque_type_storage Necessary for the new solver as we may unify keys when eagerly resolving for canonical queries. See the relevant comment when instantiating query responses: ```rust // We eagerly resolve inference variables when computing the query response. // This can cause previously distinct opaque type keys to now be structurally equal. // // To handle this, we store any duplicate entries in a separate list to check them // at the end of typeck/borrowck. We could alternatively eagerly equate the hidden // types here. However, doing so is difficult as it may result in nested goals and // any errors may make it harder to track the control flow for diagnostics. if let Some(prev) = prev { self.delegate.add_duplicate_opaque_type(key, prev, self.origin_span); } ``` This will be far more relevant with #140497. r? `@compiler-errors`
2025-05-07Rollup merge of #139534 - madhav-madhusoodanan:apx-target-feature-addition, ↵Jacob Pratt-0/+20
r=workingjubilee Added support for `apxf` target feature
2025-05-07Rollup merge of #134273 - RalfJung:de-stabilize-bench, r=ibraheemdev,traviscrossJacob Pratt-70/+12
de-stabilize bench attribute This has been soft-unstable since forever (https://github.com/rust-lang/rust/pull/64066), and shown in future-compat reports since Rust 1.77 (https://github.com/rust-lang/rust/pull/116274). The feature covering `bench` itself is tracked in https://github.com/rust-lang/rust/issues/50297, which has been closed despite still having active feature gates referencing it. Cc `@rust-lang/libs-api`
2025-05-06Structurally resolve in check_ref_castMichael Goulet-0/+22
2025-05-06added error handle for error code > 9999Kivooeo-0/+74
2025-05-06Added apxf target feature testMadhav Madhusoodanan-0/+20
2025-05-06rustdoc: remove unportable markdown lint and old parserMichael Howell-85/+0
Follow up https://github.com/rust-lang/rust/pull/127127
2025-05-06Rollup merge of #139966 - Zalathar:span-merge, r=oli-obkGuillaume Gomez-1765/+2836
coverage: Only merge adjacent coverage spans For a long time, coverage instrumentation has automatically “merged” spans with the same control-flow into a smaller number of larger spans, even when the spans being merged are not overlapping or adjacent. This causes any source text between the original spans to be included in the merged span, which is then associated with an execution count when shown in coverage reports. That approach causes a number of problems: - The intervening source text can contain all sorts of things that shouldn't really be marked as executable code (e.g. nested items, parts of macro invocations, long comments). In some cases we have complicated workarounds (e.g. bucketing to avoid merging spans across nested items), but in other cases there isn't much we can do. - Merging can have aesthetically weird effects, such as including unbalanced parentheses, because the merging process doesn't really understand what it's doing at a source code level. - It generally leads to an accumulation of piled-on heuristics and special cases that give decent-looking results, but are fiendishly difficult to modify or replace. Therefore, this PR aims to abolish the merging of non-adjacent coverage spans. The big tradeoff here is that the resulting coverage metadata (embedded in the instrumented binary) tends to become larger, because the overall number of distinct spans has increased. That's unfortunate, but I see it as the inevitable cost of cleaning up the messes and inaccuracies that were caused by the old approach. And the resulting spans do tend to be more accurate to the program's actual control-flow. --- The `.coverage` snapshot changes give an indication of how this PR will affect user-visible coverage reports. In many cases the changes to reporting are minor or even nonexistent, despite substantial changes to the metadata (as indicated by `.cov-map` snapshots). --- try-job: aarch64-gnu
2025-05-06support duplicates in the opaque_types_storagelcnr-0/+25
2025-05-06Auto merge of #140702 - GuillaumeGomez:rollup-rpyxs20, r=GuillaumeGomezbors-57/+438
Rollup of 4 pull requests Successful merges: - #140135 (Unify sidebar buttons to use the same image) - #140632 (add a test for issue rust-lang/rust#81317) - #140658 (`deref_patterns`: let string and byte string literal patterns peel references and smart pointers before matching) - #140681 (Don't ignore compiler stderr in `lib-defaults.rs`) r? `@ghost` `@rustbot` modify labels: rollup
2025-05-06Rollup merge of #140681 - jieyouxu:test_helpers, r=petrochenkovGuillaume Gomez-15/+17
Don't ignore compiler stderr in `lib-defaults.rs` Closes #54222. - Don't ignore compiler stderr. - Document test intent. - Move under `tests/ui/link-native-libs/` instead. This was previously discussed on https://web.archive.org/web/20181028094402/https://botbot.me/mozilla/rust-tools/2017-02-21/?page=1. try-job: armhf-gnu try-job: test-various try-job: x86_64-msvc-1 try-job: i686-msvc-1 try-job: x86_64-mingw-1 try-job: aarch64-apple try-job: x86_64-apple-1
2025-05-06Rollup merge of #140658 - dianne:lit-deref-pats-p2, r=oli-obkGuillaume Gomez-42/+297
`deref_patterns`: let string and byte string literal patterns peel references and smart pointers before matching This follows up on #140028. Together, they allow using string and byte string literal patterns to match on smart pointers when `deref_patterns` is enabled. In particular, string literals can now match on `String`, subsuming the functionality of the `string_deref_patterns` feature. More generally, this works by letting literals peel references (and smart pointers) before matching, similar to most other patterns, providing an answer to #44849. Though it's only partially implemented at this point: this doesn't yet let named const patterns peel before matching. The peeling logic is general enough to support named consts, but the typing rules for named const patterns would need adjustments to feel consistent (e.g. arrays would need rules to be usable as slices, and `const STR: &'static str` wouldn't be able to match on a `String` unless a rule was added to let it be used where a `str` is expected, similar to what #140028 did for literals). This also allows string and byte string patterns to match on mutable references, following up on https://github.com/rust-lang/rust/pull/140028#discussion_r2053927512. Rather than forward the mutability of the scrutinee to literal patterns, I've opted to peel `&mut`s from the scrutinee. From a design point of view, this makes the behavior consistent with what would be expected from deref coercions using the methodology in the next paragraph. From a diagnostics point of view, this avoids labeling string and byte string patterns as "mutable references", which I think could be confusing. See [`byte-string-type-errors.rs`](https://github.com/rust-lang/rust/compare/master...dianne:rust:lit-deref-pats-p2?expand=1#diff-4a0dd9b164b67c706751f3c0b5762ddab08bcef05a91972beb0190c6c1cd3706) for how the diagnostics look. At a high level, the peeling logic implemented here tries to mimic how deref coercions work for expressions: we peel references (and smart pointers) from the scrutinee until the pattern can match against it, and no more. This is primarily tested by [`const-pats-do-not-mislead-inference.rs`](https://github.com/rust-lang/rust/compare/master...dianne:rust:lit-deref-pats-p2?expand=1#diff-19afc05b8aae9a30fe4a3a8c0bc2ab2c56b58755a45cdf5c12be0d5e83c4739d). To illustrate the connection, I wasn't sure if this made sense to include in the test file, but I've translated those tests to make sure they give the same inference results as deref coercions: [(playground)](https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=1869744cb9cdfed71a686990aadf9fe1). In each case, a reference to the scrutinee is coerced to have the type of the pattern (under a reference). Tracking issue for deref patterns: #87121 r? `@oli-obk` cc `@Nadrieril`
2025-05-06Rollup merge of #140632 - Skgland:test-for-issue-81317, r=oli-obkGuillaume Gomez-0/+88
add a test for issue rust-lang/rust#81317 closes rust-lang/rust#81317
2025-05-06Rollup merge of #140135 - GuillaumeGomez:sidebars-image, r=rustdocGuillaume Gomez-0/+36
Unify sidebar buttons to use the same image Part of https://github.com/rust-lang/rust/issues/139832. The source sidebar looks like this with the new image: ![image](https://github.com/user-attachments/assets/df4fee52-fb71-4794-91b7-3afc6d2aab70) You can test it [here](https://rustdoc.crud.net/imperio/sidebar-images/src/foo/foo.rs.html). r? `@notriddle`
2025-05-06coverage: Only merge adjacent coverage spansZalathar-1765/+2836
This also removes some manipulation of the function signature span that only made sense in the context of merging non-adjacent spans.
2025-05-06Auto merge of #140561 - compiler-errors:gather-fewer-locals, r=lcnrbors-253/+236
Do not gather local all together at the beginning of typeck r? lcnr
2025-05-06tests: don't ignore compiler stderr in `lib-defaults.rs`Jieyou Xu-15/+17
And also: - Document test intent. - Move under `link-native-libs/` instead.
2025-05-06Rollup merge of #140678 - compiler-errors:dont-ice-on-infer-in-upvar, r=lcnrStuart Cook-11/+35
Be a bit more relaxed about not yet constrained infer vars in closure upvar analysis See the writeup in `tests/ui/closures/opaque-upvar.rs`. TL;DR is that this has to do with the fact that the recursive revealing uses, which have not yet been constrained from the defining use by the time that closure upvar inference is performed, remain as infer vars during upvar analysis. We don't really care, though, since anywhere we structurally match on a type in upvar analysis, we already call `structurally_resolve_type` right before `.kind()`, which would emit a true ambiguity error. Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/197 r? lcnr
2025-05-06Rollup merge of #140673 - GuillaumeGomez:clean-rustdoc-tests, r=notriddleStuart Cook-0/+48
Clean rustdoc tests folder We were starting to have way too many tests in the `tests/rustdoc/` folder so I moved some of them in sub-folders. We now have less than 300 tests at the "top level" so I guess it's good enough for now. So this PR just moves tests in sub-folders and that's pretty much it. :smiley: r? ``@notriddle``
2025-05-06Rollup merge of #140251 - Zalathar:coverage-dump-path, r=clubby789Stuart Cook-306/+306
coverage-dump: Resolve global file IDs to filenames The coverage-dump tool, used by coverage tests, currently includes “global file ID” numbers in its dump output. This PR adds support for parsing coverage filename information from LLVM assembly `.ll` files, and resolving those file IDs to the corresponding filename, for inclusion in dump output. This makes dump output more informative, especially for test cases involving multiple files, and will be important for testing expansion region support in the future. --- The bootstrap changes don't necessarily have to land at the same time (e.g. they could be deferred to after the stage0 redesign if requested), but I would prefer to land them now if possible.
2025-05-06Rollup merge of #140035 - fee1-dead-contrib:push-oszwkkvmpkks, ↵Stuart Cook-0/+587
r=jieyouxu,wesleywiser Implement RFC 3503: frontmatters Tracking issue: #136889 Supercedes #137193. This implements [RFC 3503](https://github.com/rust-lang/rfcs/blob/master/text/3503-frontmatter.md). This might break rust-analyzer. Will look into how to fix that. Suggestions welcome for how to improve diagnostics.
2025-05-06Rollup merge of #139764 - dtolnay:extractif, r=AmanieuStuart Cook-1/+1
Consistent trait bounds for ExtractIf Debug impls Closes #137654. Refer to that issue for a table of the **4** different impl signatures we previously had in the standard library for Debug impls of various ExtractIf iterator types. The one we are standardizing on is the one so far only used by `alloc::collections::linked_list::ExtractIf`, which is _no_ `F: Debug` bound, _no_ `F: FnMut` bound, only `T: Debug` bound. This PR applies the following signature changes: ```diff /* alloc::collections::btree_map */ pub struct ExtractIf<'a, K, V, F, A = Global> where - F: 'a + FnMut(&K, &mut V) -> bool, Allocator + Clone, impl Debug for ExtractIf<'a, K, V, F, + A, > where K: Debug, V: Debug, - F: FnMut(&K, &mut V) -> bool, + A: Allocator + Clone, ``` ```diff /* alloc::collections::btree_set */ pub struct ExtractIf<'a, T, F, A = Global> where - T: 'a, - F: 'a + FnMut(&T) -> bool, Allocator + Clone, impl Debug for ExtractIf<'a, T, F, A> where T: Debug, - F: FnMut(&T) -> bool, A: Allocator + Clone, ``` ```diff /* alloc::collections::linked_list */ impl Debug for ExtractIf<'a, T, F, + A, > where T: Debug, + A: Allocator, ``` ```diff /* alloc::vec */ impl Debug for ExtractIf<'a, T, F, A> where T: Debug, - F: Debug, A: Allocator, - A: Debug, ``` ```diff /* std::collections::hash_map */ pub struct ExtractIf<'a, K, V, F> where - F: FnMut(&K, &mut V) -> bool, impl Debug for ExtractIf<'a, K, V, F> where + K: Debug, + V: Debug, - F: FnMut(&K, &mut V) -> bool, ``` ```diff /* std::collections::hash_set */ pub struct ExtractIf<'a, T, F> where - F: FnMut(&T) -> bool, impl Debug for ExtractIf<'a, T, F> where + T: Debug, - F: FnMut(&T) -> bool, ``` I have made the following changes to bring these types into better alignment with one another. - Delete `F: Debug` bounds. These are especially problematic because Rust closures do not come with a Debug impl, rendering the impl useless. - Delete `A: Debug` bounds. Allocator parameters are unstable for now, but in the future this would become an API commitment that we do not debug-print a representation of the allocator when printing an iterator. - Delete `F: FnMut` bounds. Requires `hashbrown` PR: https://github.com/rust-lang/hashbrown/pull/616. **API commitment:** we commit to not doing RefCell voodoo inside ExtractIf to have some way for its Debug impl (which takes &amp;self) to call a FnMut closure, if this is even possible. - Add `T: Debug` bounds (or `K`/`V`), even on Debug impls that do not currently make use of them, but might in the future. **Breaking change.** Must backport into Rust 1.87 (current beta) or do a de-stabilization PR in beta to delay those types by one release. - Render using `debug_struct` + `finish_non_exhaustive`, instead of `debug_tuple`. - Do not render the _entire_ underlying collection. - Show a "peek" field indicating the current position of the iterator.
2025-05-06Rollup merge of #139550 - Urgau:rmeta-remap-path-scope, r=nnethercoteStuart Cook-2/+70
Fix `-Zremap-path-scope` rmeta handling This PR fixes the conditional remapping (`-Zremap-path-scope`) of rmeta file paths ~~by using the `debuginfo` scope~~ by conditionally embedding the local path in addition to the remapped path. Fixes https://github.com/rust-lang/rust/issues/139217
2025-05-05Consistent trait bounds for ExtractIf Debug implsDavid Tolnay-1/+1
2025-05-06coverage-dump: Dump filenames instead of global file IDs (and bless)Zalathar-306/+306
2025-05-05Rollup merge of #140672 - compiler-errors:deeply-normalize, r=lcnrGuillaume Gomez-56/+98
Deeply normalize in the new solver in WF We need to deeply normalize types we check for well-formedness, since we only collect implied bounds from normalized signature types. Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/194 r? lcnr
2025-05-05Rollup merge of #140661 - Darksonn:fixedx18-tm, r=wesleywiserGuillaume Gomez-0/+37
Make `-Zfixed-x18` into a target modifier As part of #136966, the `-Zfixed-x18` flag should be turned into a target modifier. This is a blocker to stabilization of the flag. The flag was originally added in #124655 and the MCP for its addition is [MCP#748](https://github.com/rust-lang/compiler-team/issues/748). On some aarch64 targets, the x18 register is used as a temporary caller-saved register by default. When the `-Zfixed-x18` flag is passed, this is turned off so that the compiler doesn't use the x18 register. This allows end-users to use the x18 register for other purposes. For example, by accessing it with inline asm you can use the register as a very efficient thread-local variable. Another common use-case is to store the stack pointer needed by the shadow-call-stack sanitizer. There are also some aarch64 targets where not using x18 is the default – in those cases the flag is a no-op. Note that this flag does not *on its own* cause an ABI mismatch. What actually causes an ABI mismatch is when you have different compilation units that *disagree* on what it should be used for. But having a CU that uses it and another CU that doesn't normally isn't enough to trigger an ABI problem. However, we still consider the flag to be a target modifier in all cases, since it is assumed that you are passing the flag because you intend to assign some other meaning to the register. Rejecting all flag mismatches even if not all are unsound is consistent with [RFC#3716](https://rust-lang.github.io/rfcs/3716-target-modifiers.html). See the headings "not all mismatches are unsound" and "cases that are not caught" for additional discussion of this. On aarch64 targets where `-Zfixed-x18` is not a no-op, it is an error to pass `-Zsanitizer=shadow-call-stack` without also passing `-Zfixed-x18`.
2025-05-05Rollup merge of #140374 - compiler-errors:global_asm-bug, r=lcnrGuillaume Gomez-0/+62
Resolve instance for SymFn in global/naked asm `Instance::expect_resolve` ensures that we're actually going from trait item -> impl item. Fixes #140373
2025-05-05Rollup merge of #140115 - dianqk:gvn-matchbr, r=oli-obkGuillaume Gomez-74/+89
mir-opt: execute MatchBranchSimplification after GVN This can provide more opportunities for MatchBranchSimplification. Currently, rustc does not optimize the following code into a single statement at mir-opt, and this PR fixes the first case. ```rust pub fn match1(c: bool, v1: i32, v2: i32) -> i32 { if c { v1 - v2 } else { v1 - v2 } } pub fn match2(c: bool, v1: i32) -> i32 { if c { v1 - 1 } else { v1 - 1 } } ``` https://rust.godbolt.org/z/Y8xPMjrfM r? mir-opt
2025-05-05fix tidy and bless testSkgland-6/+8
2025-05-05Be a bit more relaxed about not yet constrained infer vars in closure upvar ↵Michael Goulet-11/+35
analysis
2025-05-05expand commentSkgland-0/+29
2025-05-05Take into-account `-Zremap-path-scope` when embedding filenamesUrgau-2/+70
2025-05-05Deeply normalize in the new solver in WFMichael Goulet-56/+98
2025-05-05Created `tests/rustdoc/async` subfolder to limit number of files at the top ↵Guillaume Gomez-0/+0
level