about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2024-12-04Do not emit empty suggestionEsteban Küber-0/+76
The `println!();` statement's span doesn't include the `;`, and the modified suggestions where trying to get the `;` by getting the differenece between the statement's and the expression's spans, which was an empty suggestion. Fix #133833, fix #133834.
2024-12-03Auto merge of #104342 - mweber15:add_file_location_to_more_types, r=wesleywiserbors-0/+112
Require `type_map::stub` callers to supply file information This change attaches file information (`DIFile` reference and line number) to struct debug info nodes. Before: ``` ; foo.ll ... !5 = !DIFile(filename: "<unknown>", directory: "") ... !16 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyType", scope: !2, file: !5, size: 32, align: 32, elements: !17, templateParams: !19, identifier: "4cb373851db92e732c4cb5651b886dd0") ... ``` After: ``` ; foo.ll ... !3 = !DIFile(filename: "foo.rs", directory: "/home/matt/src/rust98678", checksumkind: CSK_SHA1, checksum: "bcb9f08512c8f3b8181ef4726012bc6807bc9be4") ... !16 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyType", scope: !2, file: !3, line: 3, size: 32, align: 32, elements: !17, templateParams: !19, identifier: "9e5968c7af39c148acb253912b7f409f") ... ``` Fixes #98678 r? `@wesleywiser`
2024-12-03Auto merge of #133788 - matthiaskrgr:rollup-1p100a8, r=matthiaskrgrbors-55/+252
Rollup of 6 pull requests Successful merges: - #132723 (Unify `sysroot_target_{bin,lib}dir` handling) - #133041 (Print name of env var in `--print=deployment-target`) - #133325 (Reimplement `~const` trait specialization) - #133395 (Add simd_relaxed_fma intrinsic) - #133517 (Deeply normalize when computing implied outlives bounds) - #133785 (Add const evaluation error UI test.) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-03Rollup merge of #133785 - HypheX:add-ui-test, r=compiler-errorsMatthias Krüger-0/+21
Add const evaluation error UI test. This closes #78834
2024-12-03Rollup merge of #133517 - compiler-errors:deep-norm, r=lcnrMatthias Krüger-23/+56
Deeply normalize when computing implied outlives bounds r? lcnr Unfortunately resolving regions is still slightly scuffed (though in an unrelated way). Specifically, we should be normalizing our param-env outlives when constructing the `OutlivesEnv`; otherwise, these assumptions (https://github.com/rust-lang/rust/blob/dd2837ec5de4301a692e05a7c4475e980af57a57/compiler/rustc_infer/src/infer/outlives/env.rs#L78) are not constructed correctly. Let me know if you want us to track that somewhere.
2024-12-03Rollup merge of #133395 - calebzulawski:simd_relaxed_fma, r=workingjubileeMatthias Krüger-0/+4
Add simd_relaxed_fma intrinsic Adds compiler support for https://github.com/rust-lang/portable-simd/issues/387#issuecomment-2337169786 r? `@workingjubilee` cc `@RalfJung` is this kind of nondeterminism a problem for miri/opsem?
2024-12-03Rollup merge of #133325 - compiler-errors:const-spec, r=lcnr,fee1-deadMatthias Krüger-17/+146
Reimplement `~const` trait specialization Reimplement const specialization. We need this for `PartialEq` constification :) r? lcnr
2024-12-03Rollup merge of #133041 - madsmtm:print-deployment-target-env-var, r=davidtwcoMatthias Krüger-15/+25
Print name of env var in `--print=deployment-target` The deployment target environment variable is OS-specific, and if you're in a place where you're asking `rustc` for the deployment target, you're likely to also wanna know the name of the environment variable. I myself wanted this for some code I'm working on in bootstrap, for example. Behaviour before this PR: ```console $ rustc --print=deployment-target --target=aarch64-apple-darwin deployment_target=11.0 $ rustc --print=deployment-target --target=aarch64-apple-visionos deployment_target=1.0 ``` Behaviour after this PR: ```console $ rustc --print=deployment-target --target=aarch64-apple-darwin MACOSX_DEPLOYMENT_TARGET=11.0 $ rustc --print=deployment-target --target=aarch64-apple-visionos XROS_DEPLOYMENT_TARGET=1.0 ``` My _belief_ is that this option is extremely rarely used in general, and a GitHub search for "rustc print deployment-target" seems to confirm this, it revealed only the following actual pieces of code using this: - https://github.com/PyO3/maturin/blob/b292ef69349f2a56cb8ab1b59fda0be3d3b9f138/src/build_context.rs#L1199-L1220 - https://github.com/rust-lang/cc-rs/blob/daab9244b03e244c4f2511944870d719c443f61f/src/lib.rs#L3422-L3426 `maturin` does `.split('=').last()`, so it will continue to work after this change, but `cc v1.0.84` did `.strip_prefix("deployment_target=")` since [this PR](https://github.com/rust-lang/cc-rs/pull/848), so it would break. That's _probably_ fine though, it was broken in a lot of scenarios anyway, and [got](https://github.com/rust-lang/cc-rs/pull/901) [reverted](https://github.com/rust-lang/cc-rs/pull/943) in `v1.0.85`. So while this is _technically_ a breaking change, I really doubt that anyone is going to observe it, so it's probably fine. ``@BlackHoleFox`` wdyt? ``@rustbot`` label O-apple r? compiler
2024-12-03Auto merge of #133321 - compiler-errors:const-checker, r=wesleywiserbors-311/+105
Get rid of HIR const checker As far as I can tell, the HIR const checker was implemented in https://github.com/rust-lang/rust/pull/66170 because we were not able to issue useful const error messages in the MIR const checker. This seems to have changed in the last 5 years, probably due to work like #90532. I've tweaked the diagnostics slightly and think the error messages have gotten *better* in fact. Thus I think the HIR const checker has reached the end of its usefulness, and we can retire it. cc `@RalfJung`
2024-12-02Add ui test for const evaluation fail when type is too big.Xelph-0/+21
2024-12-02Fix tests when using MinGWMatt Weber-4/+4
2024-12-02Assert that obligations are empty before deeply normalizingMichael Goulet-23/+10
2024-12-02Deeply normalize when computing implied outlives boundsMichael Goulet-0/+46
2024-12-02Fix const specializationMichael Goulet-10/+116
2024-12-02Reimplement specialization for const traitsMichael Goulet-7/+30
2024-12-02Rollup merge of #133732 - nnethercote:fix-Z-dump-mir-dataflow, r=compiler-errorsGuillaume Gomez-0/+12
Fix `-Zdump-mir-dataflow` r? `@cjgillot`
2024-12-02Rollup merge of #133710 - Urgau:target_feature-merge-conflitcs, r=jieyouxuGuillaume Gomez-24/+344
Reducing `target_feature` check-cfg merge conflicts It was rightfully pointed in https://github.com/rust-lang/rust/pull/133099#discussion_r1862490542 that the expected values for the `target_feature` cfg are regularly updated and unfortunately the check-cfg tests for it are very merge-conflict prone. This PR aims at drastically reducing the likely-hood of those, by normalizing the "and X more" diagnostic, as well as making the full expected list multi-line instead of being on a single one. cc `@RalfJung` r? `@jieyouxu`
2024-12-02Rollup merge of #133704 - RalfJung:promoted-size-overflow-ice, r=compiler-errorsGuillaume Gomez-50/+193
fix ICE when promoted has layout size overflow Turns out there is no reason to distinguish `tainted_by_errors` and `can_be_spurious` here, we can just track whether we allow this even in "infallible" constants. Fixes https://github.com/rust-lang/rust/issues/125476
2024-12-02Rollup merge of #133701 - kornelski:c-str, r=workingjubileeGuillaume Gomez-3/+3
Use c"lit" for CStrings without unwrap I've reviewed uses of `CString::new("lit")`. Some could be changed to `c"lit"`. Some could be changed to `c"lit".to_owned()`, avoiding an `unwrap()`. Many `CString` documentation examples could be simplified. I deliberately haven't changed all the examples to use the exact same expression, so that they can demonstrate many ways of creating `CString`s. I've left UI tests mostly unchanged, because `c""` requires edition 2021, but most UI tests use 2015, and I didn't want to accidentally change what the tests are testing.
2024-12-02Rollup merge of #133610 - camelid:move-from_anon_const, r=BoxyUwUGuillaume Gomez-24/+79
Move `Const::{from_anon_const,try_from_lit}` to hir_ty_lowering Fixes #128176. This accomplishes one of the followup items from #131081. These operations are much more about lowering the HIR than about `Const`s themselves. They fit better in hir_ty_lowering with `lower_const_arg` (formerly `Const::from_const_arg`) and the rest. To accomplish this, `const_evaluatable_predicates_of` had to be changed to not use `from_anon_const` anymore. Instead of visiting the HIR and lowering anon consts on the fly, it now visits the `rustc_middle::ty` data structures instead and directly looks for `UnevaluatedConst`s. This approach was proposed in: https://github.com/rust-lang/rust/pull/131081#discussion_r1821189257 r? `@BoxyUwU`
2024-12-02Rollup merge of #133535 - RalfJung:forbidden_lint_groups-future-compat, ↵Guillaume Gomez-0/+878
r=davidtwco show forbidden_lint_groups in future-compat reports Part of https://github.com/rust-lang/rust/issues/81670. This has been a future-compat lint for a while, time to dial it up to show up in reports.
2024-12-02Move `Const::{from_anon_const,try_from_lit}` to hir_ty_loweringNoah Lev-24/+79
These operations are much more about lowering the HIR than about `Const`s themselves. They fit better in hir_ty_lowering with `lower_const_arg` (formerly `Const::from_const_arg`) and the rest. To accomplish this, `const_evaluatable_predicates_of` had to be changed to not use `from_anon_const` anymore. Instead of visiting the HIR and lowering anon consts on the fly, it now visits the `rustc_middle::ty` data structures instead and directly looks for `UnevaluatedConst`s. This approach was proposed in: https://github.com/rust-lang/rust/pull/131081#discussion_r1821189257
2024-12-02Use c"lit" for CStrings without unwrapKornel-3/+3
2024-12-02Reduce conflicts for check-cfg `target_feature` cfg valuesUrgau-12/+318
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-02Add test for `-Zdump-mir-dataflow`.Nicholas Nethercote-0/+12
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-01Add specific test for check-cfg "and X more" diagnosticUrgau-12/+26
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-01fix ICE when promoted has layout size overflowRalf Jung-50/+193
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