about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2024-11-20Rollup merge of #133216 - compiler-errors:const-fn, r=lcnrJacob Pratt-90/+58
Implement `~const Fn` trait goal in the new solver Split out from https://github.com/rust-lang/rust/pull/132329 since this should be easier to review on its own. r? lcnr
2024-11-20Rollup merge of #132732 - gavincrawford:as_ptr_attribute, r=UrgauJacob Pratt-17/+44
Use attributes for `dangling_pointers_from_temporaries` lint Checking for dangling pointers by function name isn't ideal, and leaves out certain pointer-returning methods that don't follow the `as_ptr` naming convention. Using an attribute for this lint cleans things up and allows more thorough coverage of other methods, such as `UnsafeCell::get()`.
2024-11-20Auto merge of #133194 - khuey:master, r=jieyouxubors-0/+8246
Drop debug info instead of panicking if we exceed LLVM's capability to represent it Recapping a bit of history here: In #128861 I made debug info correctly represent parameters to inline functions by removing a fake lexical block that had been inserted to suppress LLVM assertions and by deduplicating those parameters. LLVM, however, expects to see a single parameter _with distinct locations_, particularly distinct inlinedAt values on the DILocations. This generally worked because no matter how deep the chain of inlines it takes two different call sites in the original function to result in the same function being present multiple times, and a function call requires a non-zero number of characters, but macros threw a wrench in that in #131944. At the time I thought the issue there was limited to proc-macros, where an arbitrary amount of code can be generated at a single point in the source text. In #132613 I added discriminators to DILocations that would otherwise be the same to repair #131944[^1]. This works, but LLVM's capacity for discriminators is not infinite (LLVM actually only allocates 12 bits for this internally). At the time I thought it would be very rare for anyone to hit the limit, but #132900 proved me wrong. In the relatively-minimized test case it also became clear to me that the issue affects regular macros too, because the call to the inlined function will (without collapse_debuginfo on the macro) be attributed to the (repeated, if the macro is used more than once) textual callsite in the macro definition. This PR fixes the panic by dropping debug info when we exceed LLVM's maximum discriminator value. There's also a preceding commit for a related but distinct issue: macros that use collapse_debuginfo should in fact have their inlinedAts collapsed to the macro callsite and thus not need discriminators at all (and not panic/warn accordingly when the discriminator limit is exhausted). Fixes #132900 r? `@jieyouxu` [^1]: Editor's note: `fix` is a magic keyword in PR description that apparently will close the linked issue (it's closed already in this case, but still).
2024-11-19Implement ~const Fn trait goals in the new solverMichael Goulet-90/+58
2024-11-19Auto merge of #133205 - matthiaskrgr:rollup-xhhhp5u, r=matthiaskrgrbors-6/+116
Rollup of 4 pull requests Successful merges: - #131081 (Use `ConstArgKind::Path` for all single-segment paths, not just params under `min_generic_const_args`) - #132577 (Report the `unexpected_cfgs` lint in external macros) - #133023 (Merge `-Zhir-stats` into `-Zinput-stats`) - #133200 (ignore an occasionally-failing test in Miri) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-19Auto merge of #133164 - RalfJung:promoted-oom, r=jieyouxubors-4/+27
interpret: do not ICE when a promoted fails with OOM Fixes https://github.com/rust-lang/rust/issues/130687 try-job: aarch64-apple try-job: dist-x86_64-linux
2024-11-19When the required discriminator value exceeds LLVM's limits, drop the debug ↵Kyle Huey-0/+4122
info for the function instead of panicking. The maximum discriminator value LLVM can currently encode is 2^12. If macro use results in more than 2^12 calls to the same function attributed to the same callsite, and those calls are MIR-inlined, we will require more than the maximum discriminator value to completely represent the debug information. Once we reach that point drop the debug info instead.
2024-11-19Honor collapse_debuginfo when dealing with MIR-inlined functions inside macros.Kyle Huey-0/+4124
The test relies on the fact that inlining more than 2^12 calls at the same callsite will trigger a panic (and after the following commit, a warning) due to LLVM limitations but with collapse_debuginfo the callsites should not be the same.
2024-11-19Rollup merge of #133023 - samestep:hir-stats-total-count, r=nnethercoteMatthias Krüger-6/+6
Merge `-Zhir-stats` into `-Zinput-stats` Currently `-Z hir-stats` prints the size and count of various kinds of nodes, and the total size of all the nodes it counted, but not the total count of nodes. So, before this PR: ``` $ git clone https://github.com/BurntSushi/ripgrep $ cd ripgrep $ cargo +nightly rustc -- -Z hir-stats ast-stats-1 PRE EXPANSION AST STATS ast-stats-1 Name Accumulated Size Count Item Size ast-stats-1 ---------------------------------------------------------------- ast-stats-1 ... ast-stats-1 ---------------------------------------------------------------- ast-stats-1 Total 93_576 ast-stats-1 ast-stats-2 POST EXPANSION AST STATS ast-stats-2 Name Accumulated Size Count Item Size ast-stats-2 ---------------------------------------------------------------- ast-stats-2 ... ast-stats-2 ---------------------------------------------------------------- ast-stats-2 Total 2_430_648 ast-stats-2 hir-stats HIR STATS hir-stats Name Accumulated Size Count Item Size hir-stats ---------------------------------------------------------------- hir-stats ... hir-stats ---------------------------------------------------------------- hir-stats Total 3_678_512 hir-stats ``` For consistency, this PR adds a total for the count as well: ``` $ cargo +stage1 rustc -- -Z hir-stats ast-stats-1 PRE EXPANSION AST STATS ast-stats-1 Name Accumulated Size Count Item Size ast-stats-1 ---------------------------------------------------------------- ast-stats-1 ... ast-stats-1 ---------------------------------------------------------------- ast-stats-1 Total 93_576 1_877 ast-stats-1 ast-stats-2 POST EXPANSION AST STATS ast-stats-2 Name Accumulated Size Count Item Size ast-stats-2 ---------------------------------------------------------------- ast-stats-2 ... ast-stats-2 ---------------------------------------------------------------- ast-stats-2 Total 2_430_648 48_625 ast-stats-2 hir-stats HIR STATS hir-stats Name Accumulated Size Count Item Size hir-stats ---------------------------------------------------------------- hir-stats ... hir-stats ---------------------------------------------------------------- hir-stats Total 3_678_512 73_418 hir-stats ``` I wasn't sure if I was supposed to update `tests/ui/stats/hir-stats.stderr` to reflect this. I ran it locally, thinking it would fail, but it didn't: ``` $ ./x test tests/ui/stats ... running 2 tests i. test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured; 17949 filtered out ``` Also: is there a reason `-Z hir-stats` and `-Z input-stats` both exist? The former seems like it should completely supercede the latter. But strangely, the two give very different numbers for node counts: ``` $ cargo +nightly rustc -- -Z input-stats ... Lines of code: 483 Pre-expansion node count: 2386 Post-expansion node count: 63844 ``` That's a 30% difference in this case. Is it intentional that these numbers are so different? I see comments for both saying that they are merely approximations and should not be expected to be correct: https://github.com/rust-lang/rust/blob/bd0826a4521a845f36cce1b00e1dd2918ba09e90/compiler/rustc_ast_passes/src/node_count.rs#L1 https://github.com/rust-lang/rust/blob/bd0826a4521a845f36cce1b00e1dd2918ba09e90/compiler/rustc_passes/src/hir_stats.rs#L1-L3
2024-11-19Rollup merge of #132577 - Urgau:check-cfg-report-extern-macro, r=petrochenkovMatthias Krüger-0/+37
Report the `unexpected_cfgs` lint in external macros This PR marks the `unexpected_cfgs` lint as being reportable in external macros, as it's probably not the intention of the macro author to leave ineffective cfgs in the users code. Fixes #132572 try-job: aarch64-gnu-debug
2024-11-19Introduce `min_generic_const_args` and directly represent pathsNoah Lev-0/+73
Co-authored-by: Boxy UwU <rust@boxyuwu.dev> Co-authored-by: León Orell Valerian Liehr <me@fmease.dev>
2024-11-19Rollup merge of #133187 - ehuss:reference-diagnostic, r=jieyouxuLeón Orell Valerian Liehr-147/+170
Add reference annotations for diagnostic attributes This adds reference annotations for `diagnostic::on_unimplmented` and the `diagnostic` namespace in general. There's also a rename for a test that looks like it was put in the wrong location.
2024-11-19Rollup merge of #133180 - GuillaumeGomez:jump-to-def-links-generics, r=notriddleLeón Orell Valerian Liehr-0/+14
[rustdoc] Fix items with generics not having their jump to def link generated Because the span originally included the generics, during the highlighting, it was not retrieved and therefore its jump to def link was not generated. r? ``@notriddle``
2024-11-18interpret: do not ICE when a promoted fails with OOMRalf Jung-4/+27
2024-11-18Add reference annotations for diagnostic attributesEric Huss-147/+170
This adds reference annotations for `diagnostic::on_unimplmented` and the `diagnostic` namespace in general.
2024-11-18Report `unexpected_cfgs` lint in external macrosUrgau-0/+37
2024-11-18Add regression test for jump to def links on items with genericsGuillaume Gomez-0/+14
2024-11-18Rollup merge of #133171 - binchengqu:master, r=jieyouxuGuillaume Gomez-1/+1
Add the missing quotation mark in comment
2024-11-18Rollup merge of #133157 - RalfJung:skip_stability_check_due_to_privacy, ↵Guillaume Gomez-6/+6
r=compiler-errors stability: remove skip_stability_check_due_to_privacy This was added in https://github.com/rust-lang/rust/pull/38689 to deal with https://github.com/rust-lang/rust/issues/38412. However, even after removing the check, the relevant tests still pass. Let's see if CI finds any other tests that rely on this. If not, it seems like logic elsewhere in the compiler changed so this is not required any more.
2024-11-18Add the missing quotation mark in commentbinchengqu-1/+1
Signed-off-by: binchengqu <bincheng@before.tech>
2024-11-18Rollup merge of #133142 - RalfJung:naming-is-hard, r=compiler-errorsJacob Pratt-1/+1
rename rustc_const_stable_intrinsic -> rustc_intrinsic_const_stable_indirect In https://github.com/rust-lang/rust/pull/120370 this name caused confusion as the author thought the intrinsic was stable. So let's try a different name... If we can land this before the beta cutoff we can avoid needing `cfg(bootstrap)` for this. ;) Cc `@compiler-errors` `@saethlin`
2024-11-18Rollup merge of #132934 - Zalathar:native-libs, r=jieyouxuJacob Pratt-4/+35
Overhaul the `-l` option parser (for linking to native libs) The current parser for `-l` options has accumulated over time, making it hard to follow. This PR tries to clean it up in several ways. Key changes: - This code now gets its own submodule, to slightly reduce clutter in `rustc_session::config`. - Cleaner division between iterating over multiple `-l` options, and processing each individual one. - Separate “split” step that breaks up the value string into `[KIND[:MODIFIERS]=]NAME[:NEW_NAME]`, but leaves parsing/validating those parts to later steps. - This step also gets its own (disposable) unit test, to make sure it works as expected. - A context struct reduces the burden of parameter passing, and makes it easier to write error messages that adapt to nightly/stable compilers. - Fewer calls to `nightly_options` helper functions, because at this point we can get the same information from `UnstableOptions` and `UnstableFeatures` (which are downstream of earlier calls to those helper functions). There should be no overall change in compiler behaviour.
2024-11-18stability: remove skip_stability_check_due_to_privacyRalf Jung-6/+6
2024-11-18rename rustc_const_stable_intrinsic -> rustc_intrinsic_const_stable_indirectRalf Jung-1/+1
2024-11-18Overhaul the `-l` option parser (for linking to native libs)Zalathar-1/+1
2024-11-18Add some UI tests for `-l` modifier parsingZalathar-0/+19
2024-11-17Rollup merge of #133147 - ChrisDenton:fixup, r=compiler-errorsJacob Pratt-4/+4
Fixup some test directives - A random comment had somehow been turned into an `//`@`` directive. - More dubiously I also removed leading spaces from directives in 3 UI tests for consistency. These are the only rustc tests that use that formatting. r? `@jieyouxu`
2024-11-17Rollup merge of #133143 - kornelski:let-mut-global, r=compiler-errorsJacob Pratt-1/+22
Diagnostics for let mut in item context The diagnostics for `let` at the top level did not account for `let mut`, which [made the error unclear](https://users.rust-lang.org/t/create-a-vector-of-constants-outside-main/121251/1). I've made the diagnostic always display a link to valid items. I've added dedicated help for `let mut` case that suggests using a `Mutex` (to steer novice users away from the `static mut` trap). Unfortunately, neither the Rust book, nor libstd docs have dedicated section listing all other types for interior-mutable `static`s.
2024-11-17Rollup merge of #133133 - notriddle:notriddle/trailing-test, r=GuillaumeGomezJacob Pratt-0/+10
rustdoc-search: add standalone trailing `::` test Follow up for #132569 r? `@GuillaumeGomez`
2024-11-17Rollup merge of #133130 - dianne:fix-133118, r=compiler-errorsJacob Pratt-4/+50
`suggest_borrow_generic_arg`: instantiate clauses properly This simplifies and fixes the way `suggest_borrow_generic_arg` instantiates callees' predicates when testing them to see if a moved argument can instead be borrowed. Previously, it would ICE if the moved argument's type included a region variable, since it was getting passed to a call of `EarlyBinder::instantiate`. This makes the instantiation much more straightforward, which also fixes the ICE. Fixes #133118 This also modifies `tests/ui/moves/moved-value-on-as-ref-arg.rs` to have more useful bounds on the tests for suggestions to borrow `Borrow` and `BorrowMut` arguments. With its old tautological `T: BorrowMut<T>` bound, this fix would make it suggest a shared borrow for that argument.
2024-11-17Rollup merge of #132993 - jieyouxu:i_am_very_stable, r=chenyukangJacob Pratt-0/+57
Make rustc consider itself a stable compiler when `RUSTC_BOOTSTRAP=-1` Addresses https://github.com/rust-lang/rust/issues/123404 to allow test writers to specify `//@ rustc-env:RUSTC_BOOTSTRAP=-1` to have a given rustc consider itself a stable rustc. This is only intended for testing usages. I did not use `RUSTC_BOOTSTRAP=0` because that can be confusing, i.e. one might think that means "not bootstrapping", but "forcing a given rustc to consider itself a stable compiler" is a different use case. I also added a specific test to check `RUSTC_BOOTSTRAP`'s various values and how that interacts with rustc's stability story w.r.t. features and cli flags. Noticed when trying to write a test for enabling ICE file dumping on stable. Dunno if this needs a compiler FCP or MCP, but I can file an MCP or ask someone to start an FCP if needed. Note that `RUSTC_BOOTSTRAP` is a perma-unstable env var and has no stability guarantees (heh) whatsoever. This does not affect bootstrapping because bootstrap never sets `RUSTC_BOOTSTRAP=-1`. If someone does set that when bootstrapping, it is considered PEBKAC. Accompanying dev-guide PR: https://github.com/rust-lang/rustc-dev-guide/pull/2136 cc `@estebank` and `@rust-lang/wg-diagnostics` for FYI
2024-11-17Rollup merge of #132944 - linyihai:needing-parenthases-issue-132924, ↵Jacob Pratt-0/+77
r=chenyukang add parentheses when unboxing suggestion needed This PR tried to `add parentheses when unboxing suggestion needed` Fixes #132924
2024-11-17Rollup merge of #132795 - compiler-errors:refine-rpitit, r=lcnrJacob Pratt-0/+88
Check `use<..>` in RPITIT for refinement `#![feature(precise_capturing_in_traits)]` allows users to write `+ use<>` bounds on RPITITs to control what lifetimes are captured by the RPITIT. Since RPITITs currently also warn for refinement in implementations, this PR extends that refinement check for cases where we *undercapture* in an implementation, since that may be indirectly "promising" a more relaxed outlives bound than the impl author intended. For an opaque to be refining, we need to capture *fewer* parameters than those mentioned in the captured params of the trait. For example: ``` trait TypeParam<T> { fn test() -> impl Sized; } // Indirectly capturing a lifetime param through a type param substitution. impl<'a> TypeParam<&'a ()> for i32 { fn test() -> impl Sized + use<> {} //~^ WARN impl trait in impl method captures fewer lifetimes than in trait } ``` Since the opaque in the method (implicitly) captures `use<Self, T>`, and `Self = i32, T = &'a ()` in the impl, we must mention `'a` in our `use<..>` on the impl. Tracking: * https://github.com/rust-lang/rust/issues/130044
2024-11-18Modify some feature-gate tests to also check command-line handlingZalathar-4/+16
2024-11-17`suggest_borrow_generic_arg`: instantiate clauses properlydianne-4/+50
Fixes issue 133118. This also modifies `tests/ui/moves/moved-value-on-as-ref-arg.rs` to have more useful bounds on the tests for suggestions to borrow `Borrow` and `BorrowMut` arguments. With its old tautological `T: BorrowMut<T>` bound, this fix would make it suggest a shared borrow for that argument.
2024-11-18Check use<..> in RPITIT for refinementMichael Goulet-0/+88
2024-11-17Auto merge of #120370 - x17jiri:likely_unlikely_fix, r=saethlinbors-46/+122
Likely unlikely fix RFC 1131 ( https://github.com/rust-lang/rust/issues/26179 ) added likely/unlikely intrinsics, but they have been broken for a while: https://github.com/rust-lang/rust/issues/96276 , https://github.com/rust-lang/rust/issues/96275 , https://github.com/rust-lang/rust/issues/88767 . This PR tries to fix them. Changes: - added a new `cold_path()` intrinsic - `likely()` and `unlikely()` changed to regular functions implemented using `cold_path()`
2024-11-17Diagnostics for let mut in item contextKornel-1/+22
2024-11-17fixup some test directivesChris Denton-4/+4
2024-11-17Auto merge of #132646 - jieyouxu:liberate-aarch64-gnu-debug, r=Kobzolbors-9/+8
Liberate `aarch64-gnu-debug` from the shackles of `--test-args=clang` ### Changes - Drop `--test-args=clang` from `aarch64-gnu-debug` so run-make tests that are `//@ needs-force-clang-based-tests` no longer only run if their test name contains `clang` (which is a very cool footgun). - Reorganize run-make-suport library slightly to accommodate a raw gcc invocation. - Fix `tests/run-make/mte-ffi/rmake.rs` to use `gcc` instead of *a* c compiler. try-job: aarch64-gnu try-job: aarch64-gnu-debug
2024-11-17Likely unlikely fixJiri Bobek-46/+122
2024-11-17Rollup merge of #133116 - RalfJung:const-null-ptr, r=dtolnay许杰友 Jieyou Xu (Joe)-3/+1
stabilize const_ptr_is_null FCP passed in https://github.com/rust-lang/rust/issues/74939. The second commit cleans up const stability around UB checks a bit, now that everything they need (except for `const_eval_select`) is stable. Fixes https://github.com/rust-lang/rust/issues/74939
2024-11-17Rollup merge of #133093 - est31:let_chains_tests, r=traviscross许杰友 Jieyou Xu (Joe)-6/+68
Let chains tests Filing this as this marks off two of the open issues in #132833: * extending the tests for `move-guard-if-let-chain.rs` and `conflicting_bindings.rs` to have chains with multiple let's (one implementation could for example search for the first `let` and then terminate). * An instance where a temporary lives shorter than with nested ifs, breaking compilation: #103476. This was fixed in the end by the if let rescoping work. Closes #103476
2024-11-17Rollup merge of #133060 - tyrone-wu:removelet-span-suggestion, r=jieyouxu许杰友 Jieyou Xu (Joe)-13/+28
Trim whitespace in RemoveLet primary span Separate `RemoveLet` span into primary span for `let` and removal suggestion span for `let `, so that primary span does not include whitespace. Fixes: #133031
2024-11-17Rollup merge of #133051 - estebank:cond-misparse, r=jieyouxu许杰友 Jieyou Xu (Joe)-28/+323
Increase accuracy of `if` condition misparse suggestion Fix #132656. Look at the expression that was parsed when trying to recover from a bad `if` condition to determine what was likely intended by the user beyond "maybe this was meant to be an `else` body". ``` error: expected `{`, found `map` --> $DIR/missing-dot-on-if-condition-expression-fixable.rs:4:30 | LL | for _ in [1, 2, 3].iter()map(|x| x) {} | ^^^ expected `{` | help: you might have meant to write a method call | LL | for _ in [1, 2, 3].iter().map(|x| x) {} | + ``` If a macro statement has been parsed after `else`, suggest a missing `if`: ``` error: expected `{`, found `falsy` --> $DIR/else-no-if.rs:47:12 | LL | } else falsy! {} { | ---- ^^^^^ | | | expected an `if` or a block after this `else` | help: add an `if` if this is the condition of a chained `else if` statement | LL | } else if falsy! {} { | ++ ```
2024-11-17rustdoc-search: add standalone trailing `::` testMichael Howell-0/+10
Follow up for #132569
2024-11-17Add a ui test for `RUSTC_BOOTSTRAP` vs rustc's stabilityJieyou Xu-0/+57
2024-11-17Auto merge of #133120 - matthiaskrgr:rollup-4actosy, r=matthiaskrgrbors-34/+28
Rollup of 7 pull requests Successful merges: - #131717 (Stabilize `const_atomic_from_ptr`) - #132134 (Remove `ResultsVisitable`) - #132449 (mark is_val_statically_known intrinsic as stably const-callable) - #132569 (rustdoc search: allow queries to end in an empty path segment) - #132787 (Unify FnKind between AST visitors and make WalkItemKind more straight forward) - #132832 (Deny capturing late-bound ty/const params in nested opaques) - #133097 (Opt out TaKO8Ki from review rotation for now) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-16stabilize const_ptr_is_nullRalf Jung-3/+1
2024-11-17Mark `numeric-types.rs` as 64-bit only for nowJieyou Xu-2/+5
This is to unblock the tree, a proper fix will need to be investigated. I think the debuginfo test suite supports revisions, however debugger directives do not respect such revisions, which is problematic. It's that 32-bit and 64-bit msvc of course have different integer widths for `isize` and `usize`, meaning their underlying integer is different and thus printed differently.