about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2024-12-14don't show the full linker args unless `--verbose` is passedjyn-8/+52
the linker arguments can be *very* long, especially for crates with many dependencies. some parts of them are not very useful. unless specifically requested: - omit object files specific to the current invocation - fold rlib files into a single braced argument (in shell expansion format) this shortens the output significantly without removing too much information.
2024-12-12Auto merge of #129181 - beetrees:asm-spans, r=pnkfelix,compiler-errorsbors-167/+1521
Pass end position of span through inline ASM cookie Before this PR, only the start position of the span was passed though the inline ASM cookie to diagnostics. LLVM 19 has full support for 64-bit inline ASM cookies; this PR uses that to pass the end position of the span in the upper 32 bits, meaning inline ASM diagnostics now point at the entire line the error occurred on, not just the first character of it.
2024-12-11Auto merge of #128004 - folkertdev:naked-fn-asm, r=Amanieubors-89/+319
codegen `#[naked]` functions using global asm tracking issue: https://github.com/rust-lang/rust/issues/90957 Fixes #124375 This implements the approach suggested in the tracking issue: use the existing global assembly infrastructure to emit the body of `#[naked]` functions. The main advantage is that we now have full control over what gets generated, and are no longer dependent on LLVM not sneakily messing with our output (inlining, adding extra instructions, etc). I discussed this approach with `@Amanieu` and while I think the general direction is correct, there is probably a bunch of stuff that needs to change or move around here. I'll leave some inline comments on things that I'm not sure about. Combined with https://github.com/rust-lang/rust/pull/127853, if both accepted, I think that resolves all steps from the tracking issue. r? `@Amanieu`
2024-12-11Auto merge of #134177 - matthiaskrgr:rollup-hgp8q60, r=matthiaskrgrbors-4/+2
Rollup of 6 pull requests Successful merges: - #132975 (De-duplicate and improve definition of core::ffi::c_char) - #133598 (Change `GetManyMutError` to match T-libs-api decision) - #134148 (add comments in check_expr_field) - #134163 (coverage: Rearrange the code for embedding per-function coverage metadata) - #134165 (wasm(32|64): update alignment string) - #134170 (Subtree update of `rust-analyzer`) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-11Rollup merge of #134163 - Zalathar:covfun, r=SparrowLii,jieyouxuMatthias Krüger-4/+2
coverage: Rearrange the code for embedding per-function coverage metadata This is a series of refactorings to the code that prepares and embeds per-function coverage metadata records (“covfun records”) in the `__llvm_covfun` linker section of the final binary. The `llvm-cov` tool reads this metadata from the binary when preparing a coverage report. Beyond general cleanup, a big motivation behind these changes is to pave the way for re-landing an updated version of #133418. --- There should be no change in compiler output, as demonstrated by the absence of (meaningful) changes to coverage tests. The first patch is just moving code around, so I suggest looking at the other patches to see the actual changes. --- try-job: x86_64-gnu try-job: x86_64-msvc try-job: aarch64-apple
2024-12-11coverage: Adjust a codegen test to ignore the order of covmap/covfun globalsZalathar-4/+2
2024-12-11Rollup merge of #134142 - compiler-errors:paren-sug, r=jieyouxuJacob Pratt-1/+28
Rudimentary heuristic to insert parentheses when needed for RPIT overcaptures lint We don't have basically any preexisting machinery to detect when parentheses are needed for *types*. AFAICT, all of the diagnostics we have for opaques just... fail when they suggest `+ 'a` when that's ambiguous. Fixes #132853
2024-12-11Rollup merge of #134136 - estebank:const-trait-default-field-test, r=jieyouxuJacob Pratt-13/+39
Exercise const trait interaction with default fields Add a test case for using the result of a fn call of an associated function of a `const` trait in a struct default field. ```rust struct X; trait Trait { fn value() -> Self; } impl const Trait for X { fn value() -> Self { X } } struct S<T: const Trait> { a: T = T::value(), } ```
2024-12-11Rollup merge of #134105 - compiler-errors:validate-self-preds, r=wesleywiserJacob Pratt-0/+22
Validate self in host predicates correctly `assert_only_contains_predicates_from` was added to make sure that we are computing predicates for the correct self type for a given `PredicateFilter`. That was not implemented correctly for `PredicateFilter::SelfOnly` when there are const predicates. Fixes #133526
2024-12-10Rudimentary heuristic to insert parentheses when needed for RPIT ↵Michael Goulet-1/+28
overcaptures lint
2024-12-10make naked function generics test stricterFolkert de Vries-4/+5
2024-12-10fix the `naked-asan` testFolkert de Vries-5/+2
we get these declarations ``` ; opt level 0 declare x86_intrcc void @page_fault_handler(ptr byval([8 x i8]) align 8, i64) unnamed_addr #1 ; opt level > 0 declare x86_intrcc void @page_fault_handler(ptr noalias nocapture noundef byval([8 x i8]) align 8 dereferenceable(8), i64 noundef) unnamed_addr #1 ``` The space after `i64` in the original regex made the regex not match for opt level 0. Removing the space fixes the issue. ``` declare x86_intrcc void @page_fault_handler(ptr {{.*}}, i64 {{.*}}){{.*}}#[[ATTRS:[0-9]+]] ```
2024-12-10codegen `#[naked]` functions using `global_asm!`Folkert-85/+317
2024-12-10Further document default field testEsteban Küber-7/+12
2024-12-10Rollup merge of #134103 - compiler-errors:never-pat-range, r=oli-obkLeón Orell Valerian Liehr-0/+27
Don't ICE when encountering never in range pattern Fixes #133947 r? oli-obk
2024-12-10Rollup merge of #134094 - estebank:const-trait-errors, r=compiler-errorsLeón Orell Valerian Liehr-186/+1065
Tweak wording of non-const traits used as const bounds Use verbose suggestions and add additional labels/notes. r? ``@compiler-errors``
2024-12-10Rollup merge of #134042 - sayantn:power8-crypto, r=jieyouxuLeón Orell Valerian Liehr-0/+1
Add the `power8-crypto` target feature Add the `power8-crypto` target feature. This will enable adding some new PPC intrinsics in stdarch (specifically AES, SHA and CLMUL intrinsics). The implied target feature is from [here](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/PowerPC/PPC.td) ```@rustbot``` label A-target-feature O-PowerPC
2024-12-10Rollup merge of #133583 - tbu-:pr_fix_typo2, r=compiler-errorsLeón Orell Valerian Liehr-2/+2
Fix type (exit → exist)
2024-12-10Excercise const trait interaction with default fieldsEsteban Küber-9/+30
Add a test case for using the result of a fn call of an associated function of a `const` trait in a struct default field. ```rust struct X; trait Trait { fn value() -> Self; } impl const Trait for X { fn value() -> Self { X } } struct S<T: const Trait> { a: T = T::value(), } ```
2024-12-10Fix type (exit → exist)Tobias Bucher-2/+2
2024-12-10Auto merge of #134125 - fmease:rollup-u38o3ob, r=fmeasebors-4/+118
Rollup of 11 pull requests Successful merges: - #133478 (jsondocck: Parse, don't validate commands.) - #133967 ([AIX] Pass -bnoipath when adding rust upstream dynamic crates) - #133970 ([AIX] Replace sa_sigaction with sa_union.__su_sigaction for AIX) - #133980 ([AIX] Remove option "-n" from AIX "ln" command) - #134008 (Make `Copy` unsafe to implement for ADTs with `unsafe` fields) - #134017 (Don't use `AsyncFnOnce::CallOnceFuture` bounds for signature deduction) - #134023 (handle cygwin environment in `install::sanitize_sh`) - #134041 (Use SourceMap to load debugger visualizer files) - #134065 (Move `write_graphviz_results`) - #134106 (Add compiler-maintainers who requested to be on review rotation) - #134123 (bootstrap: Forward cargo JSON output to stdout, not stderr) Failed merges: - #134120 (Remove Felix from ping groups and review rotation) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-10Rollup merge of #134017 - compiler-errors:call-once-deduction, r=jieyouxuLeón Orell Valerian Liehr-0/+14
Don't use `AsyncFnOnce::CallOnceFuture` bounds for signature deduction We shouldn't be using `AsyncFnOnce::CallOnceFuture` projection bounds to deduce anything about the return type of an async closure, **only** `AsyncFnOnce::Output`. This was accidental b/c all we were looking at was the def id of the trait, rather than the projection. This PR fixes that. This doesn't affect stable code, since `CallOnceFuture` bounds cannot be written on stable. Fixes #134015
2024-12-10Rollup merge of #134008 - jswrenn:unsafe-fields-copy, r=compiler-errorsLeón Orell Valerian Liehr-0/+69
Make `Copy` unsafe to implement for ADTs with `unsafe` fields As a rule, the application of `unsafe` to a declaration requires that use-sites of that declaration also entail `unsafe`. For example, a field declared `unsafe` may only be read in the lexical context of an `unsafe` block. For nearly all safe traits, the safety obligations of fields are explicitly discharged when they are mentioned in method definitions. For example, idiomatically implementing `Clone` (a safe trait) for a type with unsafe fields will require `unsafe` to clone those fields. Prior to this commit, `Copy` violated this rule. The trait is marked safe, and although it has no explicit methods, its implementation permits reads of `Self`. This commit resolves this by making `Copy` conditionally safe to implement. It remains safe to implement for ADTs without unsafe fields, but unsafe to implement for ADTs with unsafe fields. Tracking: #132922 r? ```@compiler-errors```
2024-12-10Rollup merge of #133980 - xingxue-ibm:ln-option-aix, r=jieyouxuLeón Orell Valerian Liehr-1/+11
[AIX] Remove option "-n" from AIX "ln" command The option `-n` for the AIX `ln` command has a different purpose than it does on Linux. On Linux, the `-n` option is used to treat the destination path as normal file if it is a symbolic link to a directory, which is the default behavior of the AIX `ln` command.
2024-12-10Rollup merge of #133970 - xingxue-ibm:sigaction, r=nnethercoteLeón Orell Valerian Liehr-3/+24
[AIX] Replace sa_sigaction with sa_union.__su_sigaction for AIX On AIX, the `sa_sigaction` member of `struct sigaction` is accessed as the union member `sa_union.__su_sigaction`.
2024-12-10Rollup merge of #134010 - RalfJung:promoted-type-error-ice, r=oli-obkLeón Orell Valerian Liehr-174/+23
fix ICE on type error in promoted Fixes https://github.com/rust-lang/rust/issues/133968 Ensure that when we turn a type error into a "this promoted failed to evaluate" error, we do record this as something that may happen even in "infallible" promoteds.
2024-12-10Rollup merge of #133946 - Zalathar:ready-first, r=oli-obkLeón Orell Valerian Liehr-1076/+783
coverage: Prefer to visit nodes whose predecessors have been visited In coverage instrumentation, we need to traverse the control-flow graph and decide what kind of counter (physical counter or counter-expression) should be used for each node that needs a counter. The existing traversal order is complex and hard to tweak. This new traversal order tries to be a bit more principled, by always preferring to visit nodes whose predecessors have already been visited, which is a good match for how the counter-creation code ends up dealing with a node's in-edges and out-edges. For several of the coverage tests, this ends up being a strict improvement in reducing the size of the coverage metadata, and also reducing the number of physical counters needed. (The new traversal should hopefully also allow some further code simplifications in the future.) --- This is made possible by the separate simplification pass introduced by #133849. Without that, almost any change to the traversal order ends up increasing the size of the expression table or the number of physical counters.
2024-12-10Rollup merge of #131558 - ↵León Orell Valerian Liehr-1/+69
sassman:feat/warnin-for-no-mangle-together-with-export-name, r=Urgau Lint on combining `#[no_mangle]` and `#[export_name]` This is my very first contribution to the compiler, even though I read the [chapter about lints](https://rustc-dev-guide.rust-lang.org/diagnostics.html) I'm not very certain that this ~~new lint is done right as a builtin lint~~ PR is right. I appreciate any guidance on how to improve the code. - Add test for issue #47446 - ~~Implement the new lint `mixed_export_name_and_no_mangle` as a builtin lint (not sure if that is the right way to go)~~ Extend `unused_attributes` lint - Add suggestion how to fix it <details> <summary>Old proposed new lint</summary> > The `mixed_export_name_and_no_mangle` lint detects usage of both `#[export_name]` and `#[no_mangle]` on the same item which results on `#[no_mangle]` being ignored. > > *warn-by-default* > > ### Example > > ```rust > #[no_mangle] // ignored > #[export_name = "foo"] // takes precedences > pub fn bar() {} > ``` > > ### Explanation > > The compiler will not respect the `#[no_mangle]` attribute when generating the symbol name for the function, as the `#[export_name]` attribute takes precedence. This can lead to confusion and is unnecessary. </details>
2024-12-10Auto merge of #134096 - fmease:rollup-0asgoo8, r=fmeasebors-102/+145
Rollup of 9 pull requests Successful merges: - #133996 (Move most tests for `-l` and `#[link(..)]` into `tests/ui/link-native-libs`) - #134012 (Grammar fixes) - #134032 (docs: better examples for `std::ops::ControlFlow`) - #134040 (bootstrap: print{ln}! -> eprint{ln}! (take 2)) - #134043 (Add test to check unicode identifier version) - #134053 (rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 10)) - #134055 (interpret: clean up deduplicating allocation functions) - #134073 (dataflow_const_prop: do not eval a ptr address in SwitchInt) - #134084 (Fix typo in RFC mention 3598 -> 3593) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-10Validate self in host predicates correctlyMichael Goulet-0/+22
2024-12-10Don't ICE when encountering never in patternMichael Goulet-0/+27
2024-12-10Tweak wording of non-const traits used as const boundsEsteban Küber-186/+1065
Use verbose suggestions and add additional labels/notes. Add more test cases for stable/nightly and feature enabled/disabled.
2024-12-10Auto merge of #129514 - estebank:default-field-values, r=compiler-errorsbors-184/+860
Introduce `default_field_values` feature Initial implementation of `#[feature(default_field_values]`, proposed in https://github.com/rust-lang/rfcs/pull/3681. We now parse const expressions after a `=` in a field definition, to specify a `struct` field default value. We now allow `Struct { field, .. }` where there's no base after `..`. `#[derive(Default)]` now uses the default value if present, continuing to use `Default::default()` if not. ```rust #[derive(Debug)] pub struct S; #[derive(Debug, Default)] pub struct Foo { pub bar: S = S, pub baz: i32 = 42 + 3, } fn main () { let x = Foo { .. }; let y = Foo::default(); let z = Foo { baz: 1, .. }; assert_eq!(45, x.baz); assert_eq!(45, y.baz); assert_eq!(1, z.baz); } ```
2024-12-09Rollup merge of #134073 - DianQK:fix-131227, r=oli-obkLeón Orell Valerian Liehr-16/+19
dataflow_const_prop: do not eval a ptr address in SwitchInt Fixes #131227.
2024-12-09Rollup merge of #134053 - notriddle:notriddle/issue-d, r=GuillaumeGomezLeón Orell Valerian Liehr-86/+95
rustdoc: rename `issue-\d+.rs` tests to have meaningful names (part 10) Follow up https://github.com/rust-lang/rust/pull/130287 et al As always, it's easier to review the commits one at a time. Don't use the Files Changed tab. It's confusing.
2024-12-09Rollup merge of #134043 - ehuss:unicode-version, r=jieyouxuLeón Orell Valerian Liehr-0/+31
Add test to check unicode identifier version This adds a test to verify which version of Unicode is used for identifiers. This is part of the language, documented at https://doc.rust-lang.org/nightly/reference/identifiers.html#r-ident.unicode. The version here often changes implicitly due to dependency updates pulling in new versions, and thus we often don't notice it has changed leaving the documentation out of date. The intent here is to have a canary to give us a notification when it changes so that we can update the documentation.
2024-12-09Rollup merge of #133996 - Zalathar:ui-link-native-libs, r=jieyouxuLeón Orell Valerian Liehr-0/+0
Move most tests for `-l` and `#[link(..)]` into `tests/ui/link-native-libs` Tests for the closely-related `-l` flag and `#[link(..)]` attribute are spread across a few different directories, and in some cases have ended up in a test directory intended for other linker-related functionality. This PR moves most of them into a single `tests/ui/link-native-libs` directory. --- Part of #133895. try-job: i686-mingw r? jieyouxu
2024-12-09Support x-crate default fieldsEsteban Küber-0/+11
2024-12-09Unconditionally error at definition if default field value has const errorsEsteban Küber-41/+10
Emit E0080 always on struct definition with default fields that have unconditional const errors and remove `default_field_always_invalid_const` lint.
2024-12-09Disallow `#[default] Variant {}` regardless of feature flagEsteban Küber-8/+22
2024-12-09review comments: rewordingsEsteban Küber-44/+44
2024-12-09Provide diagnostic for `Struct(a, .., z)` expressionEsteban Küber-8/+92
People might extrapolate from `Struct { .. }` that `Struct(..)` would work, but it doesn't.
2024-12-09Detect `struct S(ty = val);`Esteban Küber-2/+10
Emit a specific error for unsupported default field value syntax in tuple structs.
2024-12-09Introduce `default_field_values` featureEsteban Küber-168/+758
Initial implementation of `#[feature(default_field_values]`, proposed in https://github.com/rust-lang/rfcs/pull/3681. Support default fields in enum struct variant Allow default values in an enum struct variant definition: ```rust pub enum Bar { Foo { bar: S = S, baz: i32 = 42 + 3, } } ``` Allow using `..` without a base on an enum struct variant ```rust Bar::Foo { .. } ``` `#[derive(Default)]` doesn't account for these as it is still gating `#[default]` only being allowed on unit variants. Support `#[derive(Default)]` on enum struct variants with all defaulted fields ```rust pub enum Bar { #[default] Foo { bar: S = S, baz: i32 = 42 + 3, } } ``` Check for missing fields in typeck instead of mir_build. Expand test with `const` param case (needs `generic_const_exprs` enabled). Properly instantiate MIR const The following works: ```rust struct S<A> { a: Vec<A> = Vec::new(), } S::<i32> { .. } ``` Add lint for default fields that will always fail const-eval We *allow* this to happen for API writers that might want to rely on users' getting a compile error when using the default field, different to the error that they would get when the field isn't default. We could change this to *always* error instead of being a lint, if we wanted. This will *not* catch errors for partially evaluated consts, like when the expression relies on a const parameter. Suggestions when encountering `Foo { .. }` without `#[feature(default_field_values)]`: - Suggest adding a base expression if there are missing fields. - Suggest enabling the feature if all the missing fields have optional values. - Suggest removing `..` if there are no missing fields.
2024-12-09Add test to check unicode identifier versionEric Huss-0/+31
2024-12-09fix ICE on type error in promotedRalf Jung-174/+23
2024-12-09dataflow_const_prop: do not eval a ptr address in SwitchIntDianQK-16/+19
2024-12-09Add regression test for #134060许杰友 Jieyou Xu (Joe)-0/+27
Mostly just to check that the lint impl doesn't ICE from an easy case.
2024-12-09Revert #131669 due to ICEs许杰友 Jieyou Xu (Joe)-127/+114
Revert <https://github.com/rust-lang/rust/pull/131669> due to ICE reports: - <https://github.com/rust-lang/rust/issues/134059> (real-world) - <https://github.com/rust-lang/rust/issues/134060> (fuzzing) The changes can be re-landed with those cases addressed. This reverts commit 703bb982303ecab02fec593899639b4c3faecddd, reversing changes made to f415c07494b98e4559e4b13a9c5f867b0e6b2444.
2024-12-08rustdoc: rename `issue-\d+.rs` tests to have meaningful namesMichael Howell-80/+80