about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2024-12-19Auto merge of #134516 - matthiaskrgr:rollup-aqwxii0, r=matthiaskrgrbors-187/+276
Rollup of 5 pull requests Successful merges: - #134463 (compiletest: don't register predefined `MSVC`/`NONMSVC` FileCheck prefixes) - #134487 (Add reference annotations for the `coverage` attribute) - #134497 (coverage: Store coverage source regions as `Span` until codegen (take 2)) - #134502 (Update std libc version to 0.2.169) - #134506 (Remove a duplicated check that doesn't do anything anymore.) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-19Auto merge of #134486 - compiler-errors:drop-for-lint, r=nikomatsakisbors-0/+354
Make sure we handle `backwards_incompatible_lint` drops appropriately in drop elaboration In #131326, a new kind of scheduled drop (`drop_kind: DropKind::Value` + `backwards_incompatible_lint: true`) was added so that we could insert a new kind of no-op MIR statement (`backward incompatible drop`) for linting purposes. These drops were intended to have *no side-effects*, but drop elaboration code forgot to handle these drops specially and they were handled otherwise as normal drops in most of the code. This ends up being **unsound** since we insert more than one drop call for some values, which means that `Drop::drop` could be called more than once. This PR fixes this by splitting out the `DropKind::ForLint` and adjusting the code. I'm not totally certain if all of the places I've adjusted are either reachable or correct, but I'm pretty certain that it's *more* correct than it was previously. cc `@dingxiangfei2009` r? nikomatsakis Fixes #134482
2024-12-19Rollup merge of #134506 - oli-obk:push-mrrulszyuslt, r=jieyouxuMatthias Krüger-5/+18
Remove a duplicated check that doesn't do anything anymore. fixes #134005 This code didn't actually `lub` the type of the previous expressions, but just the current type over and over again. Changing it to using the actual expression type does not change anything either, so may as well remove the entire loop.
2024-12-19Rollup merge of #134497 - Zalathar:spans, r=jieyouxuMatthias Krüger-22/+59
coverage: Store coverage source regions as `Span` until codegen (take 2) This is an attempt to re-land #133418: > Historically, coverage spans were converted into line/column coordinates during the MIR instrumentation pass. > This PR moves that conversion step into codegen, so that coverage spans spend most of their time stored as Span instead. > In addition to being conceptually nicer, this also reduces the size of coverage mappings in MIR, because Span is smaller than 4x u32. That PR was reverted by #133608, because in some circumstances not covered by our test suite we were emitting coverage metadata that was causing `llvm-cov` to exit with an error (#133606). --- The implementation here is *mostly* the same, but adapted for subsequent changes in the relevant code (e.g. #134163). I believe that the changes in #134163 should be sufficient to prevent the problem that required the original PR to be reverted. But I haven't been able to reproduce the original breakage in a regression test, and the `llvm-cov` error message is extremely unhelpful, so I can't completely rule out the possibility of this breaking again. r? jieyouxu (reviewer of the original PR)
2024-12-19Rollup merge of #134487 - ehuss:reference-coverage, r=compiler-errorsMatthias Krüger-103/+123
Add reference annotations for the `coverage` attribute This adds reference annotations for the `coverage` attribute.
2024-12-19Rollup merge of #134463 - jieyouxu:filecheck-prefix, r=ZalatharMatthias Krüger-57/+76
compiletest: don't register predefined `MSVC`/`NONMSVC` FileCheck prefixes This was fragile as it was based on host target passed to compiletest, but the user could cross-compile and run test for a different target (e.g. cross from linux to msvc, but msvc won't be set on the target). Furthermore, it was also very surprising as normally revision names (other than `CHECK`) was accepted as FileCheck prefixes. This partially reverts the `MSVC`/`NONMSVC` predefined FileCheck prefix registration introduced historically for some codegen tests. This makes some codegen tests more verbose since they now need to explicitly introduce `MSVC`/`NONMSVC` revisions, but I think that's less surprising, e.g.: ```rs //@ revisions: MSVC NONMSVC //`@[MSVC]` only-msvc //`@[NONMSVC]` ignore-msvc ``` Note that revisions are not *only* FileCheck prefixes in FileCheck-based test suites, as they also can be used to conditionally apply certain compiletest directives. r? `@Zalathar` (or reroll a `r/? compiletest` reviewer) try-job: x86_64-msvc try-job: i686-msvc try-job: x86_64-mingw-1 try-job: i686-mingw
2024-12-19Explicitly register `MSVC`/`NONMSVC` revisions for some codegen tests许杰友 Jieyou Xu (Joe)-50/+76
2024-12-19compiletest: don't register `MSVC`/`NONMSVC` FileCheck prefixes许杰友 Jieyou Xu (Joe)-7/+0
This was fragile as it was based on host target passed to compiletest, but the user could cross-compile and run test for a different target (e.g. cross from linux to msvc, but msvc won't be set on the target). Furthermore, it was also very surprising as normally revision names (other than `CHECK`) was accepted as FileCheck prefixes.
2024-12-19Auto merge of #134499 - jieyouxu:rollup-zmaveur, r=jieyouxubors-22/+55
Rollup of 7 pull requests Successful merges: - #133702 (Variants::Single: do not use invalid VariantIdx for uninhabited enums) - #134427 (ci: remove duplicate task definition) - #134432 (Fix intra doc links not generated inside footnote definitions) - #134437 (reduce compiler `Assemble` complexity) - #134474 (Forbid overwriting types in typeck) - #134477 (move lint_unused_mut into sub-fn) - #134491 (Some destructor/drop related tweaks) r? `@ghost` `@rustbot` modify labels: rollup
2024-12-19coverage: Add a synthetic test for when all spans are discardedZalathar-0/+37
2024-12-19Remove a duplicated check that doesn't do anything anymore.Oli Scherer-5/+18
2024-12-19Rollup merge of #134474 - oli-obk:push-yomnkntvzlxw, r=compiler-errors许杰友 Jieyou Xu (Joe)-11/+15
Forbid overwriting types in typeck While trying to figure out some type setting logic in https://github.com/rust-lang/rust/pull/134248 I realized that we sometimes set a type twice. While hopefully that would have been the same type, we didn't ensure that at all and just silently accepted it. So now we reject setting it twice, unless errors are happening, then we don't care. Best reviewed commit by commit. No behaviour change is intended.
2024-12-19Rollup merge of #134432 - GuillaumeGomez:intra-doc-in-footnotes, r=notriddle许杰友 Jieyou Xu (Joe)-0/+24
Fix intra doc links not generated inside footnote definitions Fixes #132208. The problem was that we were running the `Footnote` "pass" before the `LinkReplacer` one. Sadly, the change is bigger than it should because we can't specialize the `Iterator` trait implementation, forcing me to add a new type to handle the other `Iterator` kind (the one which still has the `Range`). r? ``@notriddle``
2024-12-19Rollup merge of #133702 - RalfJung:single-variant, r=oli-obk许杰友 Jieyou Xu (Joe)-11/+16
Variants::Single: do not use invalid VariantIdx for uninhabited enums ~~Stacked on top of https://github.com/rust-lang/rust/pull/133681, only the last commit is new.~~ Currently, `Variants::Single` for an empty enum contains a `VariantIdx` of 0; looking that up in the enum variant list will ICE. That's quite confusing. So let's fix that by adding a new `Variants::Empty` case for types that have 0 variants. try-job: i686-msvc
2024-12-19Auto merge of #133961 - lcnr:borrowck-cleanup, r=jackh726bors-6/+36
cleanup region handling: add `LateParamRegionKind` The second commit is to enable a split between `BoundRegionKind` and `LateParamRegionKind`, by avoiding `BoundRegionKind` where it isn't necessary. The third comment then adds `LateParamRegionKind` to avoid having the same late-param region for separate bound regions. This fixes #124021. r? `@compiler-errors`
2024-12-19coverage: Store coverage source regions as `Span` until codegenZalathar-22/+22
2024-12-18Rollup merge of #134481 - estebank:unstable-lint-span, r=compiler-errorsJacob Pratt-32/+32
Point at lint name instead of whole attr for gated lints ``` warning: unknown lint: `test_unstable_lint` --> $DIR/warn-unknown-unstable-lint-inline.rs:4:10 | LL | #![allow(test_unstable_lint, another_unstable_lint)] | ^^^^^^^^^^^^^^^^^^ | = note: the `test_unstable_lint` lint is unstable = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date note: the lint level is defined here --> $DIR/warn-unknown-unstable-lint-inline.rs:3:9 | LL | #![warn(unknown_lints)] | ^^^^^^^^^^^^^ warning: unknown lint: `test_unstable_lint` --> $DIR/warn-unknown-unstable-lint-inline.rs:4:29 | LL | #![allow(test_unstable_lint, another_unstable_lint)] | ^^^^^^^^^^^^^^^^^^^^^ | = note: the `another_unstable_lint` lint is unstable = help: add `#![feature(another_unstable_lint)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date ``` This is particularly relevant when there are multiple lints in the same `warn` attribute. Pointing at the smaller span makes it clearer which one the warning is complaining about.
2024-12-18Rollup merge of #134418 - jieyouxu:ui-cleanup-3, r=compiler-errorsJacob Pratt-20/+45
Advent of `tests/ui` (misc cleanups and improvements) [3/N] Part of #133895. Misc improvements to some ui tests immediately under `tests/ui/`. Best reviewed commit-by-commit. Each commit's commit message contains further elaboration and rationale for changes. r? compiler
2024-12-18Rollup merge of #133643 - lcnr:merge-candidates, r=compiler-errorsJacob Pratt-50/+48
-Znext-solver: modify candidate preference rules This implements the design proposed in the FCP in #132325 and matches the old solver behavior. I hope the inline comments are all sufficiently clear, I personally think this is a fairly clear improvement over the existing approach using `fn discard_impls_shadowed_by_env`. This fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/96. This also fixes #133639 which encounters an ICE in negative coherence when evaluating the where-clause. Given the features required to trigger this ICE :shrug: r? ``@compiler-errors``
2024-12-18Rollup merge of #132056 - weiznich:diagnostic_do_not_recommend_final_tests, ↵Jacob Pratt-141/+263
r=compiler-errors Stabilize `#[diagnostic::do_not_recommend]` This PR seeks to stabilize the `#[diagnostic::do_not_recommend]`attribute. This attribute was first proposed as `#[do_not_recommend`] attribute in RFC 2397 (https://github.com/rust-lang/rfcs/pull/2397). It gives the crate authors the ability to not suggest to the compiler to not show certain traits in its error messages. With the presence of the `#[diagnostic]` tool attribute namespace it was decided to move the attribute there, as that lowers the amount of guarantees the compiler needs to give about the exact way this influences error messages. It turns the attribute into a hint which can be ignored. In addition to the original proposed functionality this attribute now also hides the marked trait in help messages ("This trait is implemented by: "). The attribute does not accept any argument and can only be placed on trait implementations. If it is placed somewhere else a lint warning is emitted and the attribute is otherwise ignored. If an argument is detected a lint warning is emitted and the argument is ignored. This follows the rules outlined by the diagnostic namespace. This attribute allows crates like diesel to improve their error messages drastically. The most common example here is the following error message: ``` error[E0277]: the trait bound `&str: Expression` is not satisfied --> /home/weiznich/Documents/rust/rust/tests/ui/diagnostic_namespace/do_not_recommend.rs:53:15 | LL | SelectInt.check("bar"); | ^^^^^ the trait `Expression` is not implemented for `&str`, which is required by `&str: AsExpression<Integer>` | = help: the following other types implement trait `Expression`: Bound<T> SelectInt note: required for `&str` to implement `AsExpression<Integer>` --> /home/weiznich/Documents/rust/rust/tests/ui/diagnostic_namespace/do_not_recommend.rs:26:13 | LL | impl<T, ST> AsExpression<ST> for T | ^^^^^^^^^^^^^^^^ ^ LL | where LL | T: Expression<SqlType = ST>, | ------------------------ unsatisfied trait bound introduced here ``` By applying the new attribute to the wild card trait implementation of `AsExpression` for `T: Expression` the error message becomes: ``` error[E0277]: the trait bound `&str: AsExpression<Integer>` is not satisfied --> $DIR/as_expression.rs:55:15 | LL | SelectInt.check("bar"); | ^^^^^ the trait `AsExpression<Integer>` is not implemented for `&str` | = help: the trait `AsExpression<Text>` is implemented for `&str` = help: for that trait implementation, expected `Text`, found `Integer` ``` which makes it much easier for users to understand that they are facing a type mismatch. Other explored example usages include: * This standard library error message: https://github.com/rust-lang/rust/pull/128008 * That bevy derived example: https://github.com/rust-lang/rust/blob/e1f306899514ea80abc1d1c9f6a57762afb304a3/tests/ui/diagnostic_namespace/do_not_recommend/supress_suggestions_in_help.rs (No more tuple pyramids) Fixes #51992 r? ``@compiler-errors`` This PR also adds a few more tests, makes sure that all the tests are run for the old and new trait solver and adds a check that the attribute does not contain arguments.
2024-12-18Add reference annotations for the `coverage` attributeEric Huss-103/+123
2024-12-18Separate DropKind::ForLintMichael Goulet-100/+52
2024-12-18Add a failing testMichael Goulet-0/+402
2024-12-18Point at lint name instead of whole attr for gated lintsEsteban Küber-32/+32
``` warning: unknown lint: `test_unstable_lint` --> $DIR/warn-unknown-unstable-lint-inline.rs:4:10 | LL | #![allow(test_unstable_lint, another_unstable_lint)] | ^^^^^^^^^^^^^^^^^^ | = note: the `test_unstable_lint` lint is unstable = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date note: the lint level is defined here --> $DIR/warn-unknown-unstable-lint-inline.rs:3:9 | LL | #![warn(unknown_lints)] | ^^^^^^^^^^^^^ warning: unknown lint: `test_unstable_lint` --> $DIR/warn-unknown-unstable-lint-inline.rs:4:29 | LL | #![allow(test_unstable_lint, another_unstable_lint)] | ^^^^^^^^^^^^^^^^^^^^^ | = note: the `test_unstable_lint` lint is unstable = help: add `#![feature(test_unstable_lint)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date note: the lint level is defined here --> $DIR/warn-unknown-unstable-lint-inline.rs:3:9 | LL | #![warn(unknown_lints)] | ^^^^^^^^^^^^^ ``` This is particularly relevant when there are multiple lints in the same `warn` attribute. Pointing at the smaller span makes it clearer which one the warning is complaining about.
2024-12-18Auto merge of #134443 - joshtriplett:use-field-init-shorthand, ↵bors-4/+4
r=lqd,tgross35,nnethercote Use field init shorthand where possible Field init shorthand allows writing initializers like `tcx: tcx` as `tcx`. The compiler already uses it extensively. Fix the last few places where it isn't yet used. EDIT: this PR also updates `rustfmt.toml` to set `use_field_init_shorthand = true`.
2024-12-18Forbid overwriting types in typeckOli Scherer-11/+15
2024-12-18resolve FIXMElcnr-5/+0
2024-12-18add testslcnr-33/+45
2024-12-18update new solver candidate assemblylcnr-12/+3
2024-12-18fix crasheslcnr-6/+36
2024-12-18Rollup merge of #134436 - taiki-e:assembly-asm-minicore, r=jieyouxu许杰友 Jieyou Xu (Joe)-489/+110
tests/assembly/asm: Remove uses of rustc_attrs and lang_items features by using minicore Similar to https://github.com/rust-lang/rust/pull/134385 (for tests/ui/asm), but for tests/assembly/asm. r? jieyouxu
2024-12-18Rollup merge of #134394 - dianne:clarify-pat-2024-migration, r=compiler-errors许杰友 Jieyou Xu (Joe)-150/+211
Clarify the match ergonomics 2024 migration lint's output This makes a few changes: - Rather than using the whole pattern as a span for the lint, this collects spans for each problematic default binding mode reset and labels them with why they're problems. - The lint's suggestions are now verbose-styled, so that it's clear what's being suggested vs. what's problematic. - The wording is now less technical, and the hard error version of this diagnostic now links to the same reference material as the lint (currently an unwritten page of the edition guide). I'm not totally confident in the wording or formatting, so I'd appreciate feedback on that in particular. I tried to draw a connection with word choice between the labels and the suggestion, but it might be imprecise, unclear, or cluttered. If so, it might be worth making the labels more terse and adding notes that explain them, but that's harder to read in a way too. cc ```@Nadrieril``` ```@Jules-Bertholet``` Closes #133854. For reference, the error from that issue becomes: ``` error: pattern uses features incompatible with edition 2024 --> $DIR/remove-me.rs:6:25 | LL | map.iter().filter(|(&(_x, _y), &_c)| false); | ^ ^ cannot implicitly match against multiple layers of reference | | | cannot implicitly match against multiple layers of reference | help: make the implied reference pattern explicit | LL | map.iter().filter(|&(&(_x, _y), &_c)| false); | + ```
2024-12-18Rollup merge of #133926 - compiler-errors:const-conditions, r=lcnr许杰友 Jieyou Xu (Joe)-13/+221
Fix const conditions for RPITITs Fixes #133918 r? lcnr
2024-12-18mir-opt: Do not handle the cleanup BB in the EarlyOtherwiseBranchDianQK-86/+49
2024-12-18mir-opt: a sub-BB of a cleanup BB must also be a cleanup BBDianQK-0/+320
2024-12-18Reapply "Auto merge of #129047 - DianQK:early_otherwise_branch_scalar, ↵DianQK-0/+247
r=cjgillot" This reverts commit 16a02664e66afbfcd738b600d4a409e809040695.
2024-12-18make no-variant types a dedicated Variants variantRalf Jung-381/+127
2024-12-18Variants::Single: do not use invalid VariantIdx for uninhabited enumsRalf Jung-138/+397
2024-12-18Also warn against `#[diagnostic::do_not_recommend]` on plain implsGeorg Semmler-2/+18
2024-12-18Stabilize `#[diagnostic::do_not_recommend]`Georg Semmler-227/+49
This commit seeks to stabilize the `#[diagnostic::do_not_recommend]` attribute. This attribute was first proposed as `#[do_not_recommend`] attribute in RFC 2397 (https://github.com/rust-lang/rfcs/pull/2397). It gives the crate authors the ability to not suggest to the compiler to not show certain traits in it's error messages. With the presence of the `#[diagnostic]` tool attribute namespace it was decided to move the attribute there, as that lowers the amount of guarantees the compiler needs to give about the exact way this influences error messages. It turns the attribute into a hint which can be ignored. In addition to the original proposed functionality this attribute now also hides the marked trait in help messages ("This trait is implemented by: "). The attribute does not accept any argument and can only be placed on trait implementations. If it is placed somewhere else a lint warning is emitted and the attribute is otherwise ignored. If an argument is detected a lint warning is emitted and the argument is ignored. This follows the rules outlined by the diagnostic namespace. This attribute allows crates like diesel to improve their error messages drastically. The most common example here is the following error message: ``` error[E0277]: the trait bound `&str: Expression` is not satisfied --> /home/weiznich/Documents/rust/rust/tests/ui/diagnostic_namespace/do_not_recommend.rs:53:15 | LL | SelectInt.check("bar"); | ^^^^^ the trait `Expression` is not implemented for `&str`, which is required by `&str: AsExpression<Integer>` | = help: the following other types implement trait `Expression`: Bound<T> SelectInt note: required for `&str` to implement `AsExpression<Integer>` --> /home/weiznich/Documents/rust/rust/tests/ui/diagnostic_namespace/do_not_recommend.rs:26:13 | LL | impl<T, ST> AsExpression<ST> for T | ^^^^^^^^^^^^^^^^ ^ LL | where LL | T: Expression<SqlType = ST>, | ------------------------ unsatisfied trait bound introduced here ``` By applying the new attribute to the wild card trait implementation of `AsExpression` for `T: Expression` the error message becomes: ``` error[E0277]: the trait bound `&str: AsExpression<Integer>` is not satisfied --> $DIR/as_expression.rs:55:15 | LL | SelectInt.check("bar"); | ^^^^^ the trait `AsExpression<Integer>` is not implemented for `&str` | = help: the trait `AsExpression<Text>` is implemented for `&str` = help: for that trait implementation, expected `Text`, found `Integer` ``` which makes it much easier for users to understand that they are facing a type mismatch. Other explored example usages included * This standard library error message: https://github.com/rust-lang/rust/pull/128008 * That bevy derived example: https://github.com/rust-lang/rust/blob/e1f306899514ea80abc1d1c9f6a57762afb304a3/tests/ui/diagnostic_namespace/do_not_recommend/supress_suggestions_in_help.rs (No more tuple pyramids) Fixes #51992
2024-12-18Check `#[diagnostic::do_not_recommend]` for argumentsGeorg Semmler-0/+68
This commit adds a check that verifies that no arguments are passed to `#[diagnostic::do_not_recommend]`. If we detect arguments we emit a warning.
2024-12-18Improve testing coverage for `#[diagnostic::do_not_recommend]`Georg Semmler-14/+230
This PR aims to improve the testing coverage for `#[diagnostic::do_not_recommend]`. It ensures that all tests are run for the old and new solver to verify that the behaviour is the same for both variants. It also adds two new tests: * A test with 4 traits having wild card impl for each other, with alternating `#[diagnostic::do_not_recommend]` attributse * A test with a lifetime dependend wild card impl, which is something that's not supported yet
2024-12-18Fix const conditions for RPITITsMichael Goulet-13/+221
2024-12-17Add the edition guide link from the match 2024 migration lint to the error ↵dianne-0/+8
as well
2024-12-17Use field init shorthand where possibleJosh Triplett-4/+4
Field init shorthand allows writing initializers like `tcx: tcx` as `tcx`. The compiler already uses it extensively. Fix the last few places where it isn't yet used.
2024-12-17Improve the pattern migration 2024 migration lint's messagedianne-62/+62
2024-12-17Clarify the match ergonomics 2024 migration lint's outputdianne-150/+203
2024-12-17Rollup merge of #134423 - jieyouxu:bootstrap-test-valid, r=onur-ozkanMatthias Krüger-0/+4
bootstrap: use specific-purpose ui test path for `test_valid` self-test I wanted to move some ui tests around in #134418, which broke `test_valid` since it was referencing two non-specific-purpose ui tests. This PR instead adds two dummy tests under `tests/ui/bootstrap/self-test/`, for that purpose specifically. r? bootstrap
2024-12-17Rollup merge of #134408 - rmehri01:rpit-inherits-lifetime, r=compiler-errorsMatthias Krüger-0/+24
Regression test for RPIT inheriting lifetime from projection Regression test to close https://github.com/rust-lang/rust/issues/51525
2024-12-17Rollup merge of #134323 - Zalathar:dismantle-map-data, r=jieyouxuMatthias Krüger-4/+4
coverage: Dismantle `map_data.rs` by moving its responsibilities elsewhere This is a series of incremental changes that combine to let us get rid of `coverageinfo/map_data.rs`, by moving all of its responsibilities into more appropriate places. Some of the notable consequences are: - We once again build the per-CGU file table on the fly while preparing individual covfun records, instead of building the whole table up-front. The up-front approach was introduced by #117042 to work around various other problems in generating the covmap/covfun records, but subsequent cleanups have made that approach no longer necessary. - Expression conversion and mapping-region conversion are now performed directly in `mapgen::covfun`, which should make future changes easier. - We no longer insert unused function instances into the same map that is also used to track used function instances. This helps to decouple the handling of used vs unused functions. --- There should be no meaningful change to compiler output. The file table is no longer sorted, because reordering it would invalidate the file indices stored in individual covfun records, but the table order should still be deterministic (albeit arbitrary). There are some subsequent cleanups that I intend to investigate, but this is enough change for one PR.