about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2024-11-23Add simd_relaxed_fma intrinsicCaleb Zulawski-0/+4
2024-11-23Rollup merge of #133286 - jieyouxu:bug-ourselves, r=compiler-errors许杰友 Jieyou Xu (Joe)-0/+36
Re-delay a resolve `bug` related to `Self`-ctor in patterns For the code pattern reported in <https://github.com/rust-lang/rust/issues/133272>, ```rs impl Foo { fn fun() { let S { ref Self } = todo!(); } } ``` <https://github.com/rust-lang/rust/pull/121208> converted this to a `span_bug` from a `span_delayed_bug` because this specific self-ctor code pattern lacked test coverage. It turns out this can be hit but we just lacked test coverage, so change it back to a `span_delayed_bug` and add a targeted test case. Follow-up to #121208, cc ``@nnethercote`` (very good exercise to expose our test coverage gaps). Fixes #133272.
2024-11-23Rollup merge of #132949 - clubby789:macro-rules-attr-derive, r=fmease许杰友 Jieyou Xu (Joe)-2/+53
Add specific diagnostic for using macro_rules macro as attribute/derive Fixes #132928
2024-11-23Rollup merge of #127483 - BertalanD:no_sanitize-global-var, r=rcvalle许杰友 Jieyou Xu (Joe)-31/+55
Allow disabling ASan instrumentation for globals AddressSanitizer adds instrumentation to global variables unless the [`no_sanitize_address`](https://llvm.org/docs/LangRef.html#global-attributes) attribute is set on them. This commit extends the existing `#[no_sanitize(address)]` attribute to set this; previously it only had the desired effect on functions. (cc https://github.com/rust-lang/rust/issues/39699)
2024-11-23Auto merge of #132915 - veluca93:unsafe-fields, r=jswrennbors-18/+415
Implement the unsafe-fields RFC. RFC: rust-lang/rfcs#3458 Tracking: - https://github.com/rust-lang/rust/issues/132922 r? jswrenn
2024-11-23Auto merge of #133360 - compiler-errors:rollup-a2o38tq, r=compiler-errorsbors-217/+543
Rollup of 8 pull requests Successful merges: - #132090 (Stop being so bail-y in candidate assembly) - #132658 (Detect const in pattern with typo) - #132911 (Pretty print async fn sugar in opaques and trait bounds) - #133102 (aarch64 softfloat target: always pass floats in int registers) - #133159 (Don't allow `-Zunstable-options` to take a value ) - #133208 (generate-copyright: Now generates a library file too.) - #133215 (Fix missing submodule in `./x vendor`) - #133264 (implement OsString::truncate) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-22Rollup merge of #133159 - Zalathar:unstable-options-no-value, r=jieyouxuMichael Goulet-7/+7
Don't allow `-Zunstable-options` to take a value Passing an explicit boolean value (`-Zunstable-options=on`, `off` etc.) sometimes appears to work, but actually puts the compiler into an unintended state where unstable _options_ are still forbidden, but unstable values of _some_ stable options are allowed. This is a result of `-Zunstable-options` being checked in multiple different places, in slightly different ways. Fixing the checks in `config::nightly_options` to understand boolean values would be non-trivial, so for now it's easier to make things consistent by forbidding values in the `-Z` parser. --- There were a few uses of this in tests, which happened to work because they were tests of unstable values.
2024-11-22Rollup merge of #133102 - RalfJung:aarch64-softfloat, r=davidtwco,wesleywiserMichael Goulet-0/+48
aarch64 softfloat target: always pass floats in int registers This is a part of https://github.com/rust-lang/rust/issues/131058: on softfloat aarch64 targets, the float registers may be unavailable. And yet, LLVM will happily use them to pass float types if the corresponding target features are enabled. That's a problem as it means enabling/disabling `neon` instructions can change the ABI. Other targets have a `soft-float` target feature that forces the use of the soft-float ABI no matter whether float registers are enabled or not; aarch64 has nothing like that. So we follow the aarch64 [softfloat ABI](https://github.com/rust-lang/rust/issues/131058#issuecomment-2385027423) and treat floats like integers for `extern "C"` functions. For the "Rust" ABI, we do the same for scalars, and then just do something reasonable for ScalarPair that avoids the pointer indirection. Cc ```@workingjubilee```
2024-11-22Rollup merge of #132911 - compiler-errors:async-fn-sugar, r=fmeaseMichael Goulet-7/+38
Pretty print async fn sugar in opaques and trait bounds sudo r? fmease
2024-11-22Rollup merge of #132658 - estebank:const-in-pattern-typo, r=NadrierilMichael Goulet-0/+123
Detect const in pattern with typo When writing a constant name incorrectly in a pattern, the pattern will be identified as a new binding. We look for consts in the current crate, consts that where imported in the current crate and for local `let` bindings in case someone got them confused with `const`s. ``` error: unreachable pattern --> $DIR/const-with-typo-in-pattern-binding.rs:30:9 | LL | GOOOD => {} | ----- matches any value LL | LL | _ => {} | ^ no value can reach this | help: you might have meant to pattern match against the value of similarly named constant `GOOD` instead of introducing a new catch-all binding | LL | GOOD => {} | ~~~~ ``` Fix #132582.
2024-11-22Rollup merge of #132090 - compiler-errors:baily, r=lcnrMichael Goulet-203/+327
Stop being so bail-y in candidate assembly A conceptual follow-up to #132084. We gotta stop bailing so much when there are errors; it's both unnecessary, leads to weird knock-on errors, and it's messing up the vibes lol
2024-11-23Auto merge of #132329 - compiler-errors:fn-and-destruct, r=lcnrbors-74/+237
Implement `~const Destruct` effect goal in the new solver This also fixed a subtle bug/limitation of the `NeedsConstDrop` check. Specifically, the "`Qualif`" API basically treats const drops as totally structural, even though dropping something that has an explicit `Drop` implementation cannot be structurally decomposed. For example: ```rust #![feature(const_trait_impl)] #[const_trait] trait Foo { fn foo(); } struct Conditional<T: Foo>(T); impl Foo for () { fn foo() { println!("uh oh"); } } impl<T> const Drop for Conditional<T> where T: ~const Foo { fn drop(&mut self) { T::foo(); } } const FOO: () = { let _ = Conditional(()); //~^ This should error. }; fn main() {} ``` In this example, when checking if the `Conditional(())` rvalue is const-drop, since `Conditional` has a const destructor, we would previously recurse into the `()` value and determine it has nothing to drop, which means that it is considered to *not* need a const drop -- even though dropping `Conditional(())` would mean evaluating the destructor which relies on that `T: const Foo` bound to hold! This could be fixed alternatively by banning any const conditions on `const Drop` impls, but that really sucks -- that means that basically no *interesting* const drop impls could be written. We have the capability to totally and intuitively support the right behavior, which I've implemented here.
2024-11-22Auto merge of #133349 - ehuss:stabilize-2024, r=traviscross,compiler-errorsbors-330/+304
Stabilize the 2024 edition This stabilizes the 2024 edition for Rust 1.85, scheduled to be released on February 20, 2025. 🎉 cc tracking issue: https://github.com/rust-lang/rust/issues/117258 There is a fair amount of follow-up work after this that I am working on (various docs, cargo, rustfmt, etc.), and this is will unblock those other changes.
2024-11-22Stabilize the 2024 editionEric Huss-330/+304
2024-11-22Check drop is trivial before checking ty needs dropMichael Goulet-177/+46
2024-11-22Pretty print AsyncFn traits tooMichael Goulet-6/+37
2024-11-22Deduplicate checking drop terminatorMichael Goulet-14/+15
2024-11-22Gate const drop behind const_destruct feature, and fix ↵Michael Goulet-26/+243
const_precise_live_drops post-drop-elaboration check
2024-11-22Implement ~const Destruct in new solverMichael Goulet-23/+99
2024-11-22Diagnostic for using macro_rules macro as attr/deriveclubby789-28/+18
2024-11-22Simplify logic a bitMichael Goulet-1/+1
2024-11-22Auto merge of #133339 - jieyouxu:rollup-gav0nvr, r=jieyouxubors-10/+18
Rollup of 8 pull requests Successful merges: - #133238 (re-export `is_loongarch_feature_detected`) - #133288 (Support `each_ref` and `each_mut` in `[T; N]` in constant expressions.) - #133311 (Miri subtree update) - #133313 (Use arc4random of libc for RTEMS target) - #133319 (Simplify `fulfill_implication`) - #133323 (Bail in effects in old solver if self ty is ty var) - #133330 (library: update comment around close()) - #133337 (Fix typo in `std::thread::Scope::spawn` documentation.) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-22Rollup merge of #133323 - compiler-errors:bail-if-self-var, r=lcnr许杰友 Jieyou Xu (Joe)-0/+16
Bail in effects in old solver if self ty is ty var Otherwise when we try to check something like `?t: ~const Trait` we'll immediately stick it to the first param-env candidate, lol. r? lcnr
2024-11-22Auto merge of #130867 - michirakara:steps_between, r=dtolnaybors-3/+3
distinguish overflow and unimplemented in Step::steps_between
2024-11-22Bail in effects in old solver if self ty is ty varMichael Goulet-0/+16
2024-11-22Simplify fulfill_implicationMichael Goulet-10/+2
2024-11-21distinguish overflow and unimplemented in Step::steps_betweenmichirakara-3/+3
2024-11-21Implement the unsafe-fields RFC.Luca Versari-18/+415
Co-Authored-By: Jacob Pratt <jacob@jhpratt.dev>
2024-11-21Rollup merge of #133078 - matthiaskrgr:uiuiui, r=davidtwcoMatthias Krüger-11/+11
tests: ui/inline-consts: add issue number to a test, rename other tests rename other tests from a_b_c to a-b-c
2024-11-21Rollup merge of #132489 - compiler-errors:fn-sugg-tweaks, r=BoxyUwUMatthias Krüger-12/+43
Fix closure arg extraction in `extract_callable_info`, generalize it to async closures * Fix argument extraction in `extract_callable_info` * FIx `extract_callable_info` to work for async closures * Remove redundant `is_fn_ty` which is just a less general `extract_callable_info` * More precisely name what is being called (i.e. call it a "closure" not a "function") Review this without whitespace -- I ended up reformatting `extract_callable_info` because some pesky `//` comments were keeping the let-chains from being formatted.
2024-11-21Rollup merge of #131586 - taiki-e:s390x-vector-abi, r=compiler-errors,uweigandMatthias Krüger-0/+829
Support s390x z13 vector ABI cc #130869 This resolves the following fixmes: - https://github.com/rust-lang/rust/blob/58420a065b68ecb3eec03b942740c761cdadd5c4/compiler/rustc_target/src/abi/call/s390x.rs#L1-L2 - https://github.com/rust-lang/rust/blob/58420a065b68ecb3eec03b942740c761cdadd5c4/compiler/rustc_target/src/spec/targets/s390x_unknown_linux_gnu.rs#L9-L11 Refs: Section 1.2.3 "Parameter Passing" and section 1.2.5 "Return Values" in ELF Application Binary Interface s390x Supplement, Version 1.6.1 (lzsabi_s390x.pdf in https://github.com/IBM/s390x-abi/releases/tag/v1.6.1) This PR extends ~~https://github.com/rust-lang/rust/pull/127731~~ https://github.com/rust-lang/rust/pull/132173 (merged) 's ABI check to handle cases where `vector` target feature is disabled. If we do not do ABI check, we run into the ABI problems as described in https://github.com/rust-lang/rust/issues/116558 and https://github.com/rust-lang/rust/issues/130869#issuecomment-2408268044, and the problem of the compiler generating strange code (https://github.com/rust-lang/rust/pull/131586#discussion_r1799003554). cc `@uweigand` `@rustbot` label +O-SystemZ +A-ABI
2024-11-21Rollup merge of #131544 - nbdd0121:asm_goto_safe_block, r=petrochenkovMatthias Krüger-0/+37
Make asm label blocks safe context Tracking issue: https://github.com/rust-lang/rust/issues/119364 `asm!()` is forced to be wrapped inside unsafe. If there's no special treatment, the label blocks would also always be unsafe with no way of opting out. It was suggested that a simple fix is to make asm label blocks safe: https://github.com/rust-lang/rust/issues/119364#issuecomment-2316037703. `@rustbot` labels: +A-inline-assembly +F-asm
2024-11-21Rollup merge of #130236 - yaahc:unstable-feature-usage, r=estebankMatthias Krüger-0/+96
unstable feature usage metrics example output ``` test-lib on  master [?] is 📦 v0.1.0 via 🦀 v1.80.1 ❯ cat src/lib.rs ───────┬─────────────────────────────────────────────────────── │ File: src/lib.rs ───────┼─────────────────────────────────────────────────────── 1 │ #![feature(unix_set_mark)] 2 │ pub fn add(left: u64, right: u64) -> u64 { 3 │ left + right 4 │ } 5 │ 6 │ #[cfg(test)] 7 │ mod tests { 8 │ use super::*; 9 │ 10 │ #[test] 11 │ fn it_works() { 12 │ let result = add(2, 2); 13 │ assert_eq!(result, 4); 14 │ } 15 │ } ───────┴─────────────────────────────────────────────────────── test-lib on  master [?] is 📦 v0.1.0 via 🦀 v1.80.1 ❯ cargo +stage1 rustc -- -Zmetrics-dir=$PWD/metrics Compiling test-lib v0.1.0 (/home/yaahc/tmp/test-lib) Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.08s test-lib on  master [?] is 📦 v0.1.0 via 🦀 v1.80.1 ❯ cat metrics/unstable_feature_usage.json ───────┬───────────────────────────────────────────────────────────────────── │ File: metrics/unstable_feature_usage.json ───────┼───────────────────────────────────────────────────────────────────── 1 │ {"lib_features":[{"symbol":"unix_set_mark"}],"lang_features":[]} ``` related to https://github.com/rust-lang/rust/issues/129485
2024-11-21Re-delay a resolve `bug`Jieyou Xu-0/+36
For the code pattern reported in <https://github.com/rust-lang/rust/issues/133272>, ```rs impl Foo { fn fun() { let S { ref Self } = todo!(); } } ``` <https://github.com/rust-lang/rust/pull/121208> converted this to a `span_bug` from a `span_delayed_bug` because this specific self-ctor code pattern lacked test coverage. It turns out this can be hit but we just lacked test coverage, so change it back to a `span_delayed_bug` and add a target tested case.
2024-11-21Rollup merge of #133218 - compiler-errors:const-opaque, r=fee1-deadMatthias Krüger-5/+75
Implement `~const` item bounds in RPIT an RPIT in a `const fn` is allowed to be conditionally const itself :) r? fee1-dead or reroll
2024-11-21Rollup merge of #132207 - compiler-errors:tweak-res-mod-segment, r=petrochenkovMatthias Krüger-3/+53
Store resolution for self and crate root module segments Let's make sure to record the segment resolution for `self::`, `crate::` and `$crate::`. I'm actually somewhat surprised that the only diagnostic that uses this is the one that errors on invalid generics on a module segment... but seems strictly more correct regardless, and there may be other diagnostics using these segments resolutions that just haven't been tested for `self`. Also includes a drive-by on `report_prohibit_generics_error`.
2024-11-21Stop being so bail-y in candidate assemblyMichael Goulet-203/+327
2024-11-20Auto merge of #133261 - matthiaskrgr:rollup-ekui4we, r=matthiaskrgrbors-86/+341
Rollup of 6 pull requests Successful merges: - #129838 (uefi: process: Add args support) - #130800 (Mark `get_mut` and `set_position` in `std::io::Cursor` as const.) - #132708 (Point at `const` definition when used instead of a binding in a `let` statement) - #133226 (Make `PointerLike` opt-in instead of built-in) - #133244 (Account for `wasm32v1-none` when exporting TLS symbols) - #133257 (Add `UnordMap::clear` method) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-20Update tests/run-make/unstable-feature-usage-metrics/rmake.rsJane Losare-Lusby-3/+3
Co-authored-by: Esteban Kuber <estebank@users.noreply.github.com>
2024-11-20aarch64 softfloat target: always pass floats in int registersRalf Jung-0/+48
2024-11-20unstable feature usage metricsJane Losare-Lusby-0/+96
2024-11-20Rollup merge of #133226 - compiler-errors:opt-in-pointer-like, r=lcnrMatthias Krüger-38/+104
Make `PointerLike` opt-in instead of built-in The `PointerLike` trait currently is a built-in trait that computes the layout of the type. This is a bit problematic, because types implement this trait automatically. Since this can be broken due to semver-compatible changes to a type's layout, this is undesirable. Also, calling `layout_of` in the trait system also causes cycles. This PR makes the trait implemented via regular impls, and adds additional validation on top to make sure that those impls are valid. This could eventually be `derive()`d for custom smart pointers, and we can trust *that* as a semver promise rather than risking library authors accidentally breaking it. On the other hand, we may never expose `PointerLike`, but at least now the implementation doesn't invoke `layout_of` which could cause ICEs or cause cycles. Right now for a `PointerLike` impl to be valid, it must be an ADT that is `repr(transparent)` and the non-1zst field needs to implement `PointerLike`. There are also some primitive impls for `&T`/ `&mut T`/`*const T`/`*mut T`/`Box<T>`.
2024-11-20Rollup merge of #132708 - estebank:const-as-binding, r=NadrierilMatthias Krüger-48/+237
Point at `const` definition when used instead of a binding in a `let` statement Modify `PatKind::InlineConstant` to be `ExpandedConstant` standing in not only for inline `const` blocks but also for `const` items. This allows us to track named `const`s used in patterns when the pattern is a single binding. When we detect that there is a refutable pattern involving a `const` that could have been a binding instead, we point at the `const` item, and suggest renaming. We do this for both `let` bindings and `match` expressions missing a catch-all arm if there's at least one single binding pattern referenced. After: ``` error[E0005]: refutable pattern in local binding --> $DIR/bad-pattern.rs:19:13 | LL | const PAT: u32 = 0; | -------------- missing patterns are not covered because `PAT` is interpreted as a constant pattern, not a new variable ... LL | let PAT = v1; | ^^^ pattern `1_u32..=u32::MAX` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html = note: the matched value is of type `u32` help: introduce a variable instead | LL | let PAT_var = v1; | ~~~~~~~ ``` Before: ``` error[E0005]: refutable pattern in local binding --> $DIR/bad-pattern.rs:19:13 | LL | let PAT = v1; | ^^^ | | | pattern `1_u32..=u32::MAX` not covered | missing patterns are not covered because `PAT` is interpreted as a constant pattern, not a new variable | help: introduce a variable instead: `PAT_var` | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html = note: the matched value is of type `u32` ``` CC #132582.
2024-11-20Store resolution for self and crate root module segmentsMichael Goulet-3/+53
2024-11-20Auto merge of #131326 - dingxiangfei2009:issue-130836-attempt-2, r=nikomatsakisbors-112/+649
Reduce false positives of tail-expr-drop-order from consumed values (attempt #2) r? `@nikomatsakis` Tracked by #123739. Related to #129864 but not replacing, yet. Related to #130836. This is an implementation of the approach suggested in the [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/temporary.20drop.20order.20changes). A new MIR statement `BackwardsIncompatibleDrop` is added to the MIR syntax. The lint now works by inspecting possibly live move paths before at the `BackwardsIncompatibleDrop` location and the actual drop under the current edition, which should be one before Edition 2024 in practice.
2024-11-20Detect const in pattern with typoEsteban Küber-0/+123
When writing a constant name incorrectly in a pattern, the pattern will be identified as a new binding. We look for consts in the current crate, consts that where imported in the current crate and for local `let` bindings in case someone got them confused with `const`s. ``` error: unreachable pattern --> $DIR/const-with-typo-in-pattern-binding.rs:30:9 | LL | GOOOD => {} | ----- matches any value LL | LL | _ => {} | ^ no value can reach this | help: you might have meant to pattern match against the value of similarly named constant `GOOD` instead of introducing a new catch-all binding | LL | GOOD => {} | ~~~~ ``` Fix #132582.
2024-11-20Make PointerLike opt-in as a traitMichael Goulet-38/+104
2024-11-20reduce false positives of tail-expr-drop-order from consumed valuesDing Xiang Fei-112/+649
take 2 open up coroutines tweak the wordings the lint works up until 2021 We were missing one case, for ADTs, which was causing `Result` to yield incorrect results. only include field spans with significant types deduplicate and eliminate field spans switch to emit spans to impl Drops Co-authored-by: Niko Matsakis <nikomat@amazon.com> collect drops instead of taking liveness diff apply some suggestions and add explantory notes small fix on the cache let the query recurse through coroutine new suggestion format with extracted variable name fine-tune the drop span and messages bugfix on runtime borrows tweak message wording filter out ecosystem types earlier apply suggestions clippy check lint level at session level further restrict applicability of the lint translate bid into nop for stable mir detect cycle in type structure
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()`.