about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2024-12-02Rollup merge of #133744 - HypheX:typo-fix, r=fmeaseGuillaume Gomez-3/+3
Fix typo README.md Fix typo README.md 2: Electric Boogaloo Expands on #131144
2024-12-02Rollup merge of #133730 - dtolnay:parentest, r=compiler-errorsGuillaume Gomez-0/+242
Add pretty-printer parenthesis insertion test This test demonstrates numerous bugs in rustc_ast_pretty, including all five of: - Failing to insert parentheses where necessary to preserve the meaning of a syntax tree, producing invalid syntax. - Failing to insert parentheses, producing valid syntax with the wrong meaning. - Inserting too many parentheses. - Inserting parentheses in the wrong place, producing invalid syntax. - Losing syntactically significant parts of the syntax tree. These pretty-printer bugs have consequences for `-Zunpretty=expanded`. The `cargo expand` subcommand cannot work reliably unless rustc can consistently produce valid Rust output. Erroneous syntax cannot be passed through rustfmt, or queried with [syn-select](https://crates.io/crates/syn-select). The test in this PR is a port of a test from Syn that tests the automatic parenthesis insertion performed by Syn's `ToTokens` impls. In Syn we actually run this test over every expression in every Rust source file in the whole rust-lang/rust repo, including rustc and the standard library and tools and test suites. For the test here, I have only used a small selection of interesting expressions. This will serve as an easy spot to accumulate regression tests as the various bugs get fixed. Once rustc's pretty-printer is in better shape, it's possible that the test can be expanded to cover a larger set of expressions collected automatically like in Syn.
2024-12-02Rollup merge of #133721 - aDotInTheVoid:rdj-dyn-link, r=GuillaumeGomezGuillaume Gomez-0/+15
rustdoc-json: Add test for `impl Trait for dyn Trait` Found while investigating #133719 Helps with #81359 r? `@GuillaumeGomez`
2024-12-02Rollup merge of #133715 - aDotInTheVoid:rdj-static, r=GuillaumeGomezGuillaume Gomez-0/+51
rustdoc-json: Include safety of `static`s `static`s in an `extern` block can have an associated safety annotation ["because there is nothing guaranteeing that the bit pattern at the static’s memory is valid for the type it is declared with"](https://doc.rust-lang.org/reference/items/external-blocks.html#statics). Rustdoc already knows this and displays in for HTML. This PR also includes it in JSON. Inspired by https://github.com/obi1kenobi/cargo-semver-checks/issues/975 which needs this, but it's probably useful in other places. r? `@GuillaumeGomez.` Possibly easier to review commit-by-commit.
2024-12-02Fix typos on tests/ui/README.mdXelph-3/+3
2024-12-01Add pretty-printer parenthesis insertion testDavid Tolnay-0/+242
2024-12-01Rollup merge of #133446 - Zalathar:querify, r=cjgillotJacob Pratt-8/+8
coverage: Use a query to identify which counter/expression IDs are used Given that we already have a query to identify the highest-numbered counter ID in a MIR body, we can extend that query to also build bitsets of used counter/expression IDs. That lets us avoid some messy coverage bookkeeping during the main MIR traversal for codegen. This does mean that we fail to treat some IDs as used in certain MIR-inlining scenarios, but I think that's fine, because it means that the results will be consistent across all instantiations of a function. --- There's some more cleanup I want to do in the function coverage collector, since it isn't really collecting anything any more, but I'll leave that for future work.
2024-12-01rustdoc-json: Add test for `impl Trait for dyn Trait`Alona Enraght-Moony-0/+15
2024-12-01rustdoc-json: Include safety of `static`sAlona Enraght-Moony-0/+41
2024-12-01rustdoc-json: Add tests for `static`sAlona Enraght-Moony-0/+10
2024-12-01Auto merge of #133703 - matthiaskrgr:rollup-fwlw0mc, r=matthiaskrgrbors-181/+369
Rollup of 7 pull requests Successful merges: - #132974 (Properly pass linker arguments that contain commas) - #133403 (Make `adjust_fulfillment_errors` work with `HostEffectPredicate` and `const_conditions`) - #133482 (Only error raw lifetime followed by `\'` in edition 2021+) - #133595 (Do not emit `missing_doc_code_examples` rustdoc lint on module and a few other items) - #133669 (Move some functions out of const_swap feature gate) - #133674 (Fix chaining `carrying_add`s) - #133691 (Check let source before suggesting annotation) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-01Rollup merge of #133691 - compiler-errors:let-source, r=lqdMatthias Krüger-0/+60
Check let source before suggesting annotation Make sure we don't annotate nonsense type annotations on locals that come from desugarings. fixes #133688
2024-12-01Rollup merge of #133674 - scottmcm:chain-carrying-add, r=AmanieuMatthias Krüger-0/+33
Fix chaining `carrying_add`s Something about the MIR lowering for `||` ended up breaking this, but it's fixed by changing the code to use `|` instead. I also added an assembly test to ensure it *keeps* being [`adc`](https://www.felixcloutier.com/x86/adc). cc https://github.com/rust-lang/rust/issues/85532#issuecomment-2495119815, which noticed this.
2024-12-01Rollup merge of #133669 - RalfJung:const_swap_splitup, r=dtolnayMatthias Krüger-1/+1
Move some functions out of const_swap feature gate - `swap_unchecked` is still unstable as a regular fn, so that feature gate can also cover its constness. - `swap_nonoverlapping` isn't ready to be stabilized yet, so make it a different feature gate. Part of https://github.com/rust-lang/rust/issues/83163, https://github.com/rust-lang/rust/issues/88539, https://github.com/rust-lang/rust/issues/133668
2024-12-01Rollup merge of #133595 - GuillaumeGomez:missing_doc_code_examples, r=notriddleMatthias Krüger-62/+26
Do not emit `missing_doc_code_examples` rustdoc lint on module and a few other items It doesn't make sense to expect modules to have code examples. Same goes for: * Trait aliases * Foreign items * Associated types and constants Should make the use of this lint a bit nicer. r? ``@notriddle``
2024-12-01Rollup merge of #133482 - compiler-errors:raw-lt-tick, r=estebankMatthias Krüger-3/+7
Only error raw lifetime followed by `\'` in edition 2021+ Fixes #133479 cc #132341 I think this fixes a purely theoretical regression since it only affects edition 2015 (who is using that?) and only in the very rare case of a raw lifetime followed immediately by a lifetime like `'r#a'r`.
2024-12-01Rollup merge of #133403 - compiler-errors:adjust-host-effect-preds, ↵Matthias Krüger-115/+242
r=fee1-dead,lcnr Make `adjust_fulfillment_errors` work with `HostEffectPredicate` and `const_conditions` Greatly improves the spans for reporting unsatisfied `~const` bounds :) r? project-const-traits or maybe ``@lcnr`` (if you want to deal with a diagnostics PR lmao)
2024-12-01Auto merge of #132390 - RalfJung:diagnostics-root-dir, ↵bors-6/+6
r=albertlarsan68,weihanglo bootstrap: show diagnostics relative to rustc src dir Fixes https://github.com/rust-lang/rust/issues/128726 Depends on https://github.com/rust-lang/cargo/pull/14752 propagating to bootstrap cargo
2024-12-01Auto merge of #133694 - matthiaskrgr:rollup-s6xj4rf, r=matthiaskrgrbors-206/+58
Rollup of 8 pull requests Successful merges: - #128184 (std: refactor `pthread`-based synchronization) - #132047 (Robustify and genericize return-type-notation resolution in `resolve_bound_vars`) - #133515 (fix: hurd build, stat64.st_fsid was renamed to st_dev) - #133602 (fix: fix codeblocks in `PathBuf` example) - #133622 (update link to "C++ Exceptions under the hood" blog) - #133660 (Do not create trait object type if missing associated types) - #133686 (Add diagnostic item for `std::ops::ControlFlow`) - #133689 (Fixed typos by changing `happend` to `happened`) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-01Rollup merge of #133689 - HomelikeBrick42:master, r=jieyouxuMatthias Krüger-12/+12
Fixed typos by changing `happend` to `happened` I just noticed this typo before and decided to fix it :3
2024-12-01Rollup merge of #133660 - compiler-errors:trait-obj-missing-assoc, r=lcnrMatthias Krüger-194/+15
Do not create trait object type if missing associated types r? lcnr
2024-12-01Rollup merge of #132047 - compiler-errors:rbv-rtn-cleanup, r=cjgillotMatthias Krüger-0/+31
Robustify and genericize return-type-notation resolution in `resolve_bound_vars` #129629 implemented return-type-notation (RTN) in its path form, like `where T::method(..): Bound`. As part of lowering, we must record the late-bound vars for the where clause introduced by the method (namely, its early- and late-bound lifetime arguments, since `where T::method(..)` turns into a higher-ranked where clause over all of the lifetimes according to [RFC 3654](https://rust-lang.github.io/rfcs/3654-return-type-notation.html#converting-to-higher-ranked-trait-bounds)). However, this logic was only looking at the where clauses of the parent item that the `T::method(..)` bound was written on, and not any parent items. This PR generalizes that logic to look at the parent item (i.e. the outer impl or trait) instead and fixes a (debug only) assertion as an effect. This logic is also more general and likely easier to adapt to more interesting (though likely very far off) cases like non-lifetime binder `for<T: Trait> T::method(..): Send` bounds. Tracking: - https://github.com/rust-lang/rust/issues/109417
2024-12-01Only error raw lifetime followed by \' in edition 2021+Michael Goulet-3/+7
2024-12-01Adjust HostEffect error spans correctly to point at argsMichael Goulet-115/+242
2024-12-01Auto merge of #133499 - nikic:no-backend-verify, r=Mark-Simulacrumbors-10/+2
Respect verify-llvm-ir option in the backend We are currently unconditionally verifying the LLVM IR in the backend (twice), ignoring the value of the verify-llvm-ir option. This has substantial compile-time impact for debug builds.
2024-12-01Check let source before suggesting annotationMichael Goulet-0/+60
2024-12-01Auto merge of #133365 - compiler-errors:compare-impl-item, r=lcnrbors-170/+53
Make `compare_impl_item` into a query Turns `compare_impl_item` into a query (generalizing the existing query for `compare_impl_const`), and uses that in `Instance::resolve` to fail resolution when an implementation is incompatible with the trait it comes from. Fixes #119701 Fixes #121127 Fixes #121411 Fixes #129075 Fixes #129127 Fixes #129214 Fixes #131294
2024-12-01Fixed typos by changing `happend` to `happened`HomelikeBrick42-12/+12
2024-11-30Auto merge of #133684 - RalfJung:rollup-j2tmrg7, r=RalfJungbors-1/+45
Rollup of 6 pull requests Successful merges: - #131698 (use stores of the correct size to set discriminants) - #133571 (Mark visionOS as supporting `std`) - #133655 (Eliminate print_expr_maybe_paren function from pretty printers) - #133667 (Remove unused code) - #133670 (bump hashbrown version) - #133673 (replace hard coded error id with `ErrorKind::DirectoryNotEmpty`) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-30Rollup merge of #133667 - sunwxg:xiaoguang/remove-unused-code, r=clubby789Ralf Jung-1/+0
Remove unused code
2024-11-30Rollup merge of #131698 - the8472:remove-set-discriminant-hack, r=RalfJungRalf Jung-0/+45
use stores of the correct size to set discriminants Resolves an old HACK /FIXME. Note that I haven't worked much with codegen so I'm not sure if I'm using the functions correctly and I was surprised seeing out-of-range values being fed into `const_uint_big` but apparently they're wrapped implicitly? By making it explicit we can pass in-range values instead.
2024-11-30Auto merge of #133659 - jieyouxu:rollup-576gh4p, r=jieyouxubors-340/+641
Rollup of 6 pull requests Successful merges: - #131551 (Support input/output in vector registers of PowerPC inline assembly) - #132515 (Fix and undeprecate home_dir()) - #132721 (CI: split x86_64-mingw job) - #133106 (changes old intrinsic declaration to new declaration) - #133496 (thread::available_parallelism for wasm32-wasip1-threads) - #133548 (Add `BTreeSet` entry APIs to match `HashSet`) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-30Do not create trait object type if missing associated typesMichael Goulet-194/+15
2024-11-30Move refinement check out of compare_impl_itemMichael Goulet-0/+26
2024-11-30Make compare_impl_item into a queryMichael Goulet-170/+27
2024-11-30add tests for niches in pointersThe 8472-0/+45
2024-11-30bless tests for changed library pathRalf Jung-6/+6
2024-11-30Fix chaining `carrying_add`sScott McMurray-0/+33
Something about the MIR lowering for `||` ended up breaking this, but it's fixed by changing the code to use `|` instead. I also added an assembly test to ensure it *keeps* being `adc`.
2024-11-30add test for bytewise ptr::swap of a pointerRalf Jung-1/+1
2024-11-30Remove unused codeXiaoguang Wang-1/+0
2024-11-30Rollup merge of #133106 - BLANKatGITHUB:intrinsic, r=RalfJung许杰友 Jieyou Xu (Joe)-1/+1
changes old intrinsic declaration to new declaration This pr is for issue #132735 It changes old `extern "intrinsic"` code block with new declaration. There are other blocks that use old declaration but as the changes needed in single block is quite large I do them in parts
2024-11-30Rollup merge of #131551 - taiki-e:ppc-asm-vreg-inout, r=Amanieu许杰友 Jieyou Xu (Joe)-339/+640
Support input/output in vector registers of PowerPC inline assembly This extends currently clobber-only vector registers (`vreg`) support to allow passing `#[repr(simd)]` types as input/output. | Architecture | Register class | Target feature | Allowed types | | ------------ | -------------- | -------------- | -------------- | | PowerPC | `vreg` | `altivec` | `i8x16`, `i16x8`, `i32x4`, `f32x4` | | PowerPC | `vreg` | `vsx` | `f32`, `f64`, `i64x2`, `f64x2` | In addition to floats and `core::simd` types listed above, `core::arch` types and custom `#[repr(simd)]` types of the same size and type are also allowed. All allowed types and relevant target features are currently unstable. r? `@Amanieu` `@rustbot` label +O-PowerPC +A-inline-assembly
2024-11-30Rollup merge of #133625 - RalfJung:custom-mir-debug-info, r=compiler-errors许杰友 Jieyou Xu (Joe)-3/+38
custom MIR: add doc comment for debuginfo This is a revival of https://github.com/rust-lang/rust/pull/117015
2024-11-30Rollup merge of #133620 - ↵许杰友 Jieyou Xu (Joe)-11/+66
dev-ardi:simplify-hir_typeck_pass_to_variadic_function, r=compiler-errors Simplify hir_typeck_pass_to_variadic_function r? ``@compiler-errors`` This reworks a bit how the diagnostic is generated so that it does the same as #133538 The `help` is useless now so I removed it
2024-11-30Rollup merge of #133587 - taiki-e:loongarch-asm-freg, r=Amanieu许杰友 Jieyou Xu (Joe)-0/+145
Fix target_feature handling in freg of LoongArch inline assembly In LoongArch inline assembly, freg currently always accepts f32/f64 as input/output. https://github.com/rust-lang/rust/blob/9b4d7c6a40b328d212095c28670c629facf1557d/compiler/rustc_target/src/asm/loongarch.rs#L41 However, these types actually require f/d target features as in RISC-V. Otherwise, an (ugly) compile error will occur: https://godbolt.org/z/K61Gq1E9E f32/f64 without f: ``` error: couldn't allocate output register for constraint '{$f1}' --> <source>:12:11 | 12 | asm!("", in("$f1") x, lateout("$f1") y); | ^ ``` f64 with f but without d: ``` error: scalar-to-vector conversion failed, possible invalid constraint for vector type --> <source>:19:11 | 19 | asm!("", in("$f1") x, lateout("$f1") y); | ^ ``` cc ``@heiher`` r? ``@Amanieu`` ``@rustbot`` label +O-LoongArch +A-inline-assembly
2024-11-30Rollup merge of #133585 - estebank:issue-133563, r=jieyouxu许杰友 Jieyou Xu (Joe)-76/+231
Do not call `extern_crate` on current trait on crate mismatch errors When we encounter an error caused by traits/types of different versions of the same crate, filter out the current crate when collecting spans to add to the context so we don't call `extern_crate` on the `DefId` of the current crate, which is meaningless and ICEs. Produced output with this filter: ``` error[E0277]: the trait bound `foo::Struct: Trait` is not satisfied --> y.rs:13:19 | 13 | check_trait::<foo::Struct>(); | ^^^^^^^^^^^ the trait `Trait` is not implemented for `foo::Struct` | note: there are multiple different versions of crate `foo` in the dependency graph --> y.rs:7:1 | 4 | extern crate foo; | ----------------- one version of crate `foo` is used here, as a direct dependency of the current crate 5 | 6 | pub struct Struct; | ----------------- this type implements the required trait 7 | pub trait Trait {} | ^^^^^^^^^^^^^^^ this is the required trait | ::: x.rs:4:1 | 4 | pub struct Struct; | ----------------- this type doesn't implement the required trait 5 | pub trait Trait {} | --------------- this is the found trait = note: two types coming from two different versions of the same crate are different types even if they look the same = help: you can use `cargo tree` to explore your dependency tree note: required by a bound in `check_trait` --> y.rs:10:19 | 10 | fn check_trait<T: Trait>() {} | ^^^^^ required by this bound in `check_trait` ``` Fix #133563.
2024-11-30Rollup merge of #133488 - Enselic:recurse-2, r=BoxyUwU许杰友 Jieyou Xu (Joe)-0/+19
tests: Add regression test for self referential structs with cow as last field Making compilation pass for this code was retroactively stabilized via FCP in 1.79. The code does not compile in 1.78. See https://github.com/rust-lang/rust/issues/129541 for details. Closes #107481
2024-11-30Rollup merge of #116161 - Soveu:varargs2, r=cjgillot许杰友 Jieyou Xu (Joe)-78/+5
Stabilize `extended_varargs_abi_support` I think that is everything? If there is any documentation regarding `extern` and/or varargs to correct, let me know, some quick greps suggest that there might be none. Tracking issue: https://github.com/rust-lang/rust/issues/100189
2024-11-29simplify how the `hir_typeck_pass_to_variadic_function` diagnostic is createdOrion Gonzalez-11/+66
2024-11-29Move the `crate-loading` test to use `diff` outputEsteban Küber-76/+146