about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2025-02-05Rollup merge of #136509 - ehuss:nested-macro-rules-edition, r=jieyouxuLeón Orell Valerian Liehr-0/+112
Add tests for nested macro_rules edition behavior This adds tests to check the behavior of how nested macro_rules definitions work across edition boundaries. This covers a change in behavior due to https://github.com/rust-lang/rust/pull/133274. See https://github.com/rust-lang/rust/issues/135669
2025-02-05Rollup merge of #128045 - pnkfelix:rustc-contracts, r=oli-obkLeón Orell Valerian Liehr-12/+1162
#[contracts::requires(...)] + #[contracts::ensures(...)] cc https://github.com/rust-lang/rust/issues/128044 Updated contract support: attribute syntax for preconditions and postconditions, implemented via a series of desugarings that culminates in: 1. a compile-time flag (`-Z contract-checks`) that, similar to `-Z ub-checks`, attempts to ensure that the decision of enabling/disabling contract checks is delayed until the end user program is compiled, 2. invocations of lang-items that handle invoking the precondition, building a checker for the post-condition, and invoking that post-condition checker at the return sites for the function, and 3. intrinsics for the actual evaluation of pre- and post-condition predicates that third-party verification tools can intercept and reinterpret for their own purposes (e.g. creating shims of behavior that abstract away the function body and replace it solely with the pre- and post-conditions). Known issues: * My original intent, as described in the MCP (https://github.com/rust-lang/compiler-team/issues/759) was to have a rustc-prefixed attribute namespace (like rustc_contracts::requires). But I could not get things working when I tried to do rewriting via a rustc-prefixed builtin attribute-macro. So for now it is called `contracts::requires`. * Our attribute macro machinery does not provide direct support for attribute arguments that are parsed like rust expressions. I spent some time trying to add that (e.g. something that would parse the attribute arguments as an AST while treating the remainder of the items as a token-tree), but its too big a lift for me to undertake. So instead I hacked in something approximating that goal, by semi-trivially desugaring the token-tree attribute contents into internal AST constucts. This may be too fragile for the long-term. * (In particular, it *definitely* breaks when you try to add a contract to a function like this: `fn foo1(x: i32) -> S<{ 23 }> { ... }`, because its token-tree based search for where to inject the internal AST constructs cannot immediately see that the `{ 23 }` is within a generics list. I think we can live for this for the short-term, i.e. land the work, and continue working on it while in parallel adding a new attribute variant that takes a token-tree attribute alongside an AST annotation, which would completely resolve the issue here.) * the *intent* of `-Z contract-checks` is that it behaves like `-Z ub-checks`, in that we do not prematurely commit to including or excluding the contract evaluation in upstream crates (most notably, `core` and `std`). But the current test suite does not actually *check* that this is the case. Ideally the test suite would be extended with a multi-crate test that explores the matrix of enabling/disabling contracts on both the upstream lib and final ("leaf") bin crates.
2025-02-04Auto merge of #136549 - matthiaskrgr:rollup-sqbpgtd, r=matthiaskrgrbors-525/+867
Rollup of 7 pull requests Successful merges: - #136242 (Remove `LateContext::match_def_path()`) - #136274 (Check Sizedness of return type in WF) - #136284 (Allow using named consts in pattern types) - #136477 (Fix a couple NLL TLS spans ) - #136497 (Report generic mismatches when calling bodyless trait functions) - #136520 (Remove unnecessary layout assertions for object-safe receivers) - #136526 (mir_build: Rename `thir::cx::Cx` to `ThirBuildCx` and remove `UserAnnotatedTyHelpers`) Failed merges: - #136304 (Reject negative literals for unsigned or char types in pattern ranges and literals) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-04Rollup merge of #136520 - compiler-errors:redundant-layout-assert, r=lcnrMatthias Krüger-68/+40
Remove unnecessary layout assertions for object-safe receivers The soundness of `DispatchFromDyn` relies on the fact that, like all other built-in marker-like layout traits (e.g. `Sized`, `CoerceUnsized`), the guarantees that they enforce in *generic* code via traits will result in assumptions that we can rely on in codegen. Specifically, `DispatchFromDyn` ensures that we end up with a receiver that is a valid pointer type, and its implementation validity recursively ensures that the ABI of that pointer type upholds the `Scalar` or `ScalarPair` representation for sized and unsized pointees, respectively. The check that this layout guarantee holds for arbitrary, possibly generic receiver types that also may exist in possibly impossible-to-instantiate where clauses is overkill IMO, and leads to several ICEs due to the fact that computing layouts before monomorphization is going to be fallible at best. This PR removes the check altogether, since it just exists as a sanity check from very long ago, 6f2a161b1bbe6234188d6cfb3cabddef1e6ef20f. Fixes #125810 Fixes #90110 This PR is an alternative to #136195. cc `@adetaylor.` I didn't realize in that PR that the layout checks that were being modified were simply *sanity checks*, rather than being actually necessary for soundness.
2025-02-04Rollup merge of #136497 - Jarcho:fn_ctxt, r=compiler-errorsMatthias Krüger-12/+102
Report generic mismatches when calling bodyless trait functions Don't know if there's an open issue for this. Just happened to notice this when working in that area. The awkward extra spans added to the diagnostics of some tests (e.g. `trait-with-missing-associated-type-restriction`) is consistent with what happens for normal functions. Should probably be removed since that span doesn't seem to note anything useful. First and third commit are both cleanups removing some unnecessary work. Second commit has the actual fix. fixes #135124
2025-02-04Rollup merge of #136477 - lqd:nll-tls-spans, r=matthewjasperMatthias Krüger-2/+2
Fix a couple NLL TLS spans Some NLL TLS tests show incorrect spans for the end of function. It seems that the `TerminatorKind::Return` source info span can sometimes point at the single character after the end of the function. Completely changing the span where the terminator is built also changes a bunch of diagnostics: small functions have more code shown unrelated to the errors at hand, wrapping symbols appear and weird-looking arrows point to the end of function, etc. So it seems this is somehow unexpectedly relied upon in making diagnostics look better and their heuristics. So I just changed it where it matters for these few tests: the diagnostics specialized to conflict errors with thread locals. r? `@matthewjasper`
2025-02-04Rollup merge of #136284 - oli-obk:push-zsxuwnzmonnl, r=lcnrMatthias Krüger-93/+259
Allow using named consts in pattern types This required a refactoring first: I had to stop using `hir::Pat`in `hir::TyKind::Pat` and instead create a separate `TyPat` that has `ConstArg` for range ends instead of `PatExpr`. Within the type system we should be using `ConstArg` for all constants, as otherwise we'd be maintaining two separate const systems that could diverge. The big advantage of this PR is that we now inherit all the rules from const generics and don't have a separate system. While this makes things harder for users (const generic rules wrt what is allowed in those consts), it also means we don't accidentally allow some things like referring to assoc consts or doing math on generic consts.
2025-02-04Rollup merge of #136274 - compiler-errors:sized-wf, r=lcnrMatthias Krüger-350/+464
Check Sizedness of return type in WF Still need to clean this up a bit. This should fix https://github.com/rust-lang/trait-system-refactor-initiative/issues/150. r? lcnr
2025-02-04Auto merge of #135760 - scottmcm:disjoint-bitor, r=WaffleLapkinbors-0/+43
Add `unchecked_disjoint_bitor` per ACP373 Following the names from libs-api in https://github.com/rust-lang/libs-team/issues/373#issuecomment-2085686057 Includes a fallback implementation so this doesn't have to update cg_clif or cg_gcc, and overrides it in cg_llvm to use `or disjoint`, which [is available in LLVM 18](https://releases.llvm.org/18.1.0/docs/LangRef.html#or-instruction) so hopefully we don't need any version checks.
2025-02-04Allow using named consts in pattern typesOli Scherer-43/+171
2025-02-04Auto merge of #136534 - jhpratt:rollup-dnz57dq, r=jhprattbors-9/+11
Rollup of 6 pull requests Successful merges: - #136398 (add UnsafeCell direct access APIs) - #136465 (Some `rustc_middle` cleanups) - #136479 (std::fs: further simplify dirent64 handling) - #136504 (Fix last compare-mode false negatives in tests) - #136511 (Add `cast_signed` and `cast_unsigned` methods for `NonZero` types) - #136518 (Add note about `FnPtr` trait being exposed as public bound) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-04bless test expectationsRémy Rakic-2/+2
2025-02-04Rollup merge of #136504 - lqd:more-compare-modes, r=jieyouxuJacob Pratt-9/+11
Fix last compare-mode false negatives in tests This PR is a continuation of #136310 and fixes the last remaining cases of false negatives when running tests under a compare-mode. With these normalizations, all the compare-mode failures in `next-solver` (and `polonius`) should now be real, actual differences in diagnostics.
2025-02-04Rollup merge of #136167 - pitaj:new_range, r=NadrierilJacob Pratt-46/+155
Implement unstable `new_range` feature Switches `a..b`, `a..`, and `a..=b` to resolve to the new range types. For rust-lang/rfcs#3550 Tracking issue #123741 also adds the re-export that was missed in the original implementation of `new_range_api`
2025-02-04Rollup merge of #134777 - saethlin:enable-more-tests-on-windows, r=NoratriebJacob Pratt-63/+41
Enable more tests on Windows As part of the discussion of https://github.com/rust-lang/compiler-team/issues/822 on Zulip, it was mentioned that problems with the i686-pc-windows-gnu target may have resulted in tests being disabled on Windows. So in this PR, I've ripped out all our `//@ ignore-windows` directives, then re-added all the ones that are definitely required based on the outcome of try-builds, and in some cases I've improved the justification or tightened the directives to `//@ ignore-msvc` or ignoring specific targets.
2025-02-04Auto merge of #136525 - matthiaskrgr:rollup-m8kqlek, r=matthiaskrgrbors-350/+541
Rollup of 6 pull requests Successful merges: - #134807 (fix(rustdoc): always use a channel when linking to doc.rust-lang.org) - #134814 (Add `kl` and `widekl` target features, and the feature gate) - #135836 (bootstrap: only build `crt{begin,end}.o` when compiling to MUSL) - #136022 (Port ui/simd tests to use the intrinsic macro) - #136309 (set rustc dylib on manually constructed rustc command) - #136462 (mir_build: Simplify `lower_pattern_range_endpoint`) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-04Rollup merge of #136022 - vayunbiyani:port_tests, r=RalfJungMatthias Krüger-348/+518
Port ui/simd tests to use the intrinsic macro
2025-02-04Rollup merge of #134814 - sayantn:keylocker, r=oli-obkMatthias Krüger-0/+21
Add `kl` and `widekl` target features, and the feature gate This is an effort towards #134813. This PR adds the target-features and the feature gate to `rustc` <!-- ```@rustbot``` label O-x86_64 O-x86_32 A-target-feature r? compiler -->
2025-02-04Rollup merge of #134807 - poliorcetics:ab/push-skpynvsmwkll, r=camelidMatthias Krüger-2/+2
fix(rustdoc): always use a channel when linking to doc.rust-lang.org Closes #131971 I manually checked the resulting links One issue is that this will create `nightly/...` links in places that formerly linked to stable, is that ok ? (the `slice` and `array` links in the search help notably)
2025-02-04Auto merge of #136507 - matthiaskrgr:rollup-uzwv9mo, r=matthiaskrgrbors-94/+244
Rollup of 8 pull requests Successful merges: - #136289 (OnceCell & OnceLock docs: Using (un)initialized consistently) - #136299 (Ignore NLL boring locals in polonius diagnostics) - #136411 (Omit argument names from function pointers that do not have argument names) - #136430 (Use the type-level constant value `ty::Value` where needed) - #136476 (Remove generic `//@ ignore-{wasm,wasm32,emscripten}` in tests) - #136484 (Notes on types/traits used for in-memory query caching) - #136493 (platform-support: document CPU baseline for x86-32 targets) - #136498 (Update books) r? `@ghost` `@rustbot` modify labels: rollup
2025-02-03Fix ICE when function argument mismatches.Jason Newcomb-9/+66
2025-02-04Remove unnecessary layout assertions for object-safe receiversMichael Goulet-68/+40
2025-02-04Add missing lang items in no_core tests in rustdocMichael Goulet-8/+31
2025-02-03Rename rustc_contract to contractCelina G. Val-127/+484
This has now been approved as a language feature and no longer needs a `rustc_` prefix. Also change the `contracts` feature to be marked as incomplete and `contracts_internals` as internal.
2025-02-03Update test output to include check_contracts cfgCelina G. Val-12/+13
This is now a valid expected value.
2025-02-03Improve contracts intrisics and remove wrapper functionCelina G. Val-40/+30
1. Document the new intrinsics. 2. Make the intrinsics actually check the contract if enabled, and remove `contract::check_requires` function. 3. Use panic with no unwind in case contract is using to check for safety, we probably don't want to unwind. Following the same reasoning as UB checks.
2025-02-03Refactor contract builtin macro + error handlingCelina G. Val-0/+207
Instead of parsing the different components of a function signature, eagerly look for either the `where` keyword or the function body. - Also address feedback to use `From` instead of `TryFrom` in cranelift contract and ubcheck codegen.
2025-02-03Separate contract feature gates for the internal machineryFelix S. Klock II-6/+157
The extended syntax for function signature that includes contract clauses should never be user exposed versus the interface we want to ship externally eventually.
2025-02-03demonstrate how to capture state at precondition time and feed into ↵Felix S. Klock II-0/+74
postcondition predicate.
2025-02-03Desugars contract into the internal AST extensionsFelix S. Klock II-0/+164
Check ensures on early return due to Try / Yeet Expand these two expressions to include a call to contract checking
2025-02-03Add tests for nested macro_rules edition behaviorEric Huss-0/+112
This adds tests to check the behavior of how nested macro_rules definitions work across edition boundaries. This covers a change in behavior due to https://github.com/rust-lang/rust/pull/133274. See https://github.com/rust-lang/rust/issues/135669
2025-02-03Express contracts as part of function header and lower it to the contract ↵Celina G. Val-0/+118
lang items includes post-developed commit: do not suggest internal-only keywords as corrections to parse failures. includes post-developed commit: removed tabs that creeped in into rustfmt tool source code. includes post-developed commit, placating rustfmt self dogfooding. includes post-developed commit: add backquotes to prevent markdown checking from trying to treat an attr as a markdown hyperlink/ includes post-developed commit: fix lowering to keep contracts from being erroneously inherited by nested bodies (like closures). Rebase Conflicts: - compiler/rustc_parse/src/parser/diagnostics.rs - compiler/rustc_parse/src/parser/item.rs - compiler/rustc_span/src/hygiene.rs Remove contracts keywords from diagnostic messages
2025-02-03contracts: added lang items that act as hooks for rustc-injected code to invoke.Felix S. Klock II-0/+47
see test for an example of the kind of injected code that is anticipated here.
2025-02-03Contracts core intrinsics.Felix S. Klock II-0/+41
These are hooks to: 1. control whether contract checks are run 2. allow 3rd party tools to intercept and reintepret the results of running contracts.
2025-02-03Rollup merge of #136476 - jieyouxu:panic-panic-panic, r=lcnrMatthias Krüger-19/+7
Remove generic `//@ ignore-{wasm,wasm32,emscripten}` in tests Follow-up to #135926. In favor of capability-based guards `//@ needs-{unwind,subprocess}`. Resolves #135923. r? ``@ghost`` try-job: test-various
2025-02-03Rollup merge of #136411 - dtolnay:fnptr, r=notriddleMatthias Krüger-6/+14
Omit argument names from function pointers that do not have argument names This matches the style used for the vast majority of function pointer types in real-world code, in my experience. Prefixing `_: ` to every argument does not improve clarity. **Before:** <img src="https://github.com/user-attachments/assets/f07efa8b-d57e-4897-aa97-40db7d207862"> **After:** <img src="https://github.com/user-attachments/assets/8405e08b-d6d2-4904-bcc3-a3eb866cecf0">
2025-02-03Rollup merge of #136299 - lqd:polonius-next-episode-9, r=jackh726Matthias Krüger-69/+223
Ignore NLL boring locals in polonius diagnostics Another easy one ``@jackh726`` (the diff is inflated by blessed test expectations don't worry :) NLLs don't compute liveness for boring locals, and therefore cannot find them in causes explaining borrows. In polonius, we don't have this liveness optimization (we may be able to do something partially similar in the future, e.g. for function parameters and the like), so we do encounter these in diagnostics even though we don't want to. This PR: - restructures the polonius context into per-phase data, in spirit as you requested in an earlier review - stores the locals NLLs would consider boring into the errors/diagnostics data - ignores these if a boring local is found when trying to explain borrows This PR fixes around 80 cases of diagnostics differences between `-Zpolonius=next` and NLLs. I've also added explicit revisions to a few polonius tests (both for the in-tree implementation as well as the datalog implementation -- even if we'll eventually remove them). I didn't do this for all the "dead" expectations that were removed from #136112 for that same reason, it's fine. I'll soon/eventually add explicit revisions where they're needed: there's only a handful of tests left to fix. r? ``@jackh726``
2025-02-03Auto merge of #136146 - RalfJung:x86-abi, r=workingjubileebors-34/+56
Explicitly choose x86 softfloat/hardfloat ABI Part of https://github.com/rust-lang/rust/pull/135408: Instead of choosing this based on the target features listed in the target spec, make that choice explicit. All built-in targets are being updated here; custom (JSON-defined) x86 (32bit and 64bit) softfloat targets need to explicitly set `rustc-abi` to `x86-softfloat`.
2025-02-03fix `json-*.rs` and `E0462` tests for compare-modesRémy Rakic-1/+3
2025-02-03fix normalization in `E0271` test for compare-modesRémy Rakic-3/+3
2025-02-03fix `crateresolve*.rs` tests and duplicates for compare modesRémy Rakic-5/+5
- duplicates of crateresolve1 are used in a couple error-codes tests - also fix the note in crateresolve1 to link to these other duplicates, now that E0523 has been merged into E0464
2025-02-03Make error message less awkwardMichael Goulet-25/+25
2025-02-03Check Sizedness of return type in WFMichael Goulet-323/+414
2025-02-03Check for generic parameter mismatches on trait functions.Jason Newcomb-3/+36
2025-02-03add rustc_abi to control ABI decisions LLVM does not have flags for, and use ↵Ralf Jung-34/+56
it for x86 softfloat
2025-02-03Enable more tests on WindowsBen Kimock-63/+41
2025-02-03tests: remove redundant `//@ ignore-{wasm,wasm32,emscripten}`许杰友 Jieyou Xu (Joe)-19/+7
2025-02-03Rollup merge of #136438 - RalfJung:offset_from_ub_errors, r=oli-obk许杰友 Jieyou Xu (Joe)-14/+14
miri: improve error when offset_from preconditions are violated Fixes https://github.com/rust-lang/miri/issues/4143
2025-02-03Rollup merge of #136432 - fmease:lta-fix-def-site-checks, r=compiler-errors许杰友 Jieyou Xu (Joe)-0/+65
LTA: Actually check where-clauses for well-formedness at the def site All of the added tests used to wrongfully pass. r? oli-obk or types/compiler or reassign
2025-02-03Rollup merge of #136404 - fmease:rm-compiletest-relic-of-the-past, ↵许杰友 Jieyou Xu (Joe)-30/+30
r=Noratrieb,jieyouxu Remove a footgun-y feature / relic of the past from the compiletest DSL The compiletest DSL still features a historical remnant from the time when its directives were merely prefixed with `//` instead of `//`@`` when unknown directive names weren't rejected since they could just as well be part of prose: As an "optimization", it stops looking for directives once it stumbles upon a line which starts with either `fn` or `mod`. This is super footgun-y as it obviously leads to any seeming compiletest directives below `fn` and `mod` items getting completely ignored. See #136403 for a practical example. As well the assembly test updated in this PR. ~~Blocked on #136403.~~ (merged)