about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2024-01-03Rollup merge of #119523 - maurer:fix-sparc-llvm-18, r=nikicLeón Orell Valerian Liehr-2/+2
llvm: Allow `noundef` in codegen tests LLVM 18 will automatically infer `noundef` in some situations. Adjust codegen tests to accept this. See llvm/llvm-project#76553 for why `noundef` is being generated now. ``@rustbot`` label:+llvm-main
2024-01-03Rollup merge of #119505 - fmease:no-host-param-for-trait-fns, r=fee1-deadLeón Orell Valerian Liehr-22/+141
Don't synthesize host effect params for trait associated functions marked const Fixes #113378. r? fee1-dead or compiler
2024-01-03Rollup merge of #119494 - fmease:deny-hr-param-defaults, r=compiler-errorsLeón Orell Valerian Liehr-32/+88
Deny defaults for higher-ranked generic parameters Fixes #119489 (incl. https://github.com/rust-lang/rust/issues/119489#issuecomment-1873399208). Partially reverts #119042. cc ```@bvanjoi``` r? ```@compiler-errors``` or compiler
2024-01-03Rollup merge of #119477 - lukas-code:tooltip-z-index, r=notriddleLeón Orell Valerian Liehr-0/+12
rustdoc ui: adjust tooltip z-index to be above sidebar In https://github.com/rust-lang/rust/pull/115660 the sidebar's z-index was changed to 100. This PR changes the tooltip's z-index to 101 to be above the sidebar again. Fixes [after beta-backport] https://github.com/rust-lang/rust/issues/119472.
2024-01-03Rollup merge of #119476 - fmease:pp-always-const-trait-preds, r=compiler-errorsLeón Orell Valerian Liehr-3/+73
Pretty-print always-const trait predicates correctly Follow-up to #119099. r? fee1-dead
2024-01-03Rollup merge of #119474 - nbdd0121:naked, r=NilstriebLeón Orell Valerian Liehr-2/+2
Update tracking issue of naked_functions The original tracking issue #32408 was superseded by the new one #90957 (constrainted naked functions) and therefore is closed.
2024-01-02llvm: Allow `noundef` in codegen testsMatthew Maurer-2/+2
LLVM 18 will automatically infer `noundef` in some situations. Adjust codegen tests to accept this. See llvm/llvm-project#76553 for why `noundef` is being generated now.
2024-01-02E0379: Provide suggestionsLeón Orell Valerian Liehr-16/+107
2024-01-02E0379: Make diagnostic more preciseLeón Orell Valerian Liehr-17/+17
2024-01-02Don't synthesize host effect params for trait assoc fns marked constLeón Orell Valerian Liehr-0/+28
2024-01-01Deny defaults for higher-ranked generic parametersLeón Orell Valerian Liehr-32/+88
2024-01-01Pretty-print always-const trait predicates correctlyLeón Orell Valerian Liehr-3/+73
2023-12-31rustdoc ui: adjust tooltip z-index to be above sidebarLukas Markeffsky-0/+12
2023-12-31Update tracking issue of naked_functionsGary Guo-2/+2
The original tracking issue was superseded by a new one (constrainted naked functions) and therefore is closed.
2023-12-31Auto merge of #119066 - notriddle:notriddle/sidebar-source-redesign, ↵bors-96/+60
r=GuillaumeGomez rustdoc: clean up source sidebar hide button This is a redesign of the feature, with parts pulled from https://github.com/rust-lang/rust/pull/119049 but with a button that looks more like a button and matches the one used on other sidebar pages. Preview: * http://notriddle.com/rustdoc-html-demo-8/source-sidebar-resize/src/std/lib.rs.html * http://notriddle.com/rustdoc-html-demo-8/source-sidebar-resize/std/index.html | | Before | After | |--|--|--| | Closed | ![image](https://github.com/rust-lang/rust/assets/1593513/092bed75-79c3-412f-8e7b-557f30dfb1e3) | ![image](https://github.com/rust-lang/rust/assets/1593513/b68e1ee9-9aef-484d-a5b1-2fd29c9d72ea) | Open | ![image](https://github.com/rust-lang/rust/assets/1593513/95cf9545-25b1-48ec-820b-02e1aec99839) | ![image](https://github.com/rust-lang/rust/assets/1593513/923532f6-59e0-4d7c-9976-21699c30d42e) | Mobile Closed | ![image](https://github.com/rust-lang/rust/assets/1593513/9bc00cc5-937c-4120-94be-94c7cb6d5297) | ![image](https://github.com/rust-lang/rust/assets/1593513/76a744d8-aac2-46fe-abb9-3b34e2d3ccaa) | Mobile Open | ![image](https://github.com/rust-lang/rust/assets/1593513/d19a94fe-47b1-462d-a280-44fc215b9b72) | ![image](https://github.com/rust-lang/rust/assets/1593513/2b2e3dec-b610-4b12-8a72-35b86359ba45)
2023-12-30Auto merge of #119284 - Nadrieril:fix-bodiless-arm-parse, r=cjgillotbors-0/+37
Don't drop a hir node after lowering Fixes https://github.com/rust-lang/rust/issues/119271. It seems that all hir nodes that get allocated an id must be placed within the hir on pain of ICEs. In https://github.com/rust-lang/rust/pull/118527 I dropped guards on never patterns since they're not useful, which caused the ICE.
2023-12-30Update to bitflags 2 in the compilerNilstrieb-9/+9
This involves lots of breaking changes. There are two big changes that force changes. The first is that the bitflag types now don't automatically implement normal derive traits, so we need to derive them manually. Additionally, bitflags now have a hidden inner type by default, which breaks our custom derives. The bitflags docs recommend using the impl form in these cases, which I did.
2023-12-30Auto merge of #119437 - matthiaskrgr:rollup-esf96p6, r=matthiaskrgrbors-6/+29
Rollup of 5 pull requests Successful merges: - #119158 (Clean up alloc::sync::Weak Clone implementation) - #119386 (fix typo in `IpAddr::to_canonical`) - #119413 (solaris support on bootstrap lock) - #119424 (Primitive docs: fix confusing `Send` in `&T`'s list) - #119425 (Fix invalid check-cfg Cargo feature diagnostic help) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-30Rollup merge of #119425 - Urgau:check-cfg-fix-cargo-diag-bug, r=NilstriebMatthias Krüger-6/+29
Fix invalid check-cfg Cargo feature diagnostic help #118213 added specialized diagnostic for Cargo `feature` cfg. However when providing an empty `#[cfg(feature)]` condition the suggestion would suggest adding `feature` as a feature in `Cargo.toml` (wtf!). This PR removes the invalid logic, which even brings a nice improvement. ```diff --> $DIR/cargo-feature.rs:18:7 | LL | #[cfg(feature)] - | ^^^^^^^ + | ^^^^^^^- help: specify a config value: `= "bitcode"` | = note: expected values for `feature` are: `bitcode` - = help: consider defining `feature` as feature in `Cargo.toml` ``` The first commit add a test showing the bug and the second commit fixes the bug. `@rustbot` label +F-check-cfg
2023-12-30Auto merge of #119377 - tmiasko:after, r=cjgillotbors-1/+1
Don't validate / lint MIR before each pass To avoid redundant work and verbose output in case of failures.
2023-12-30Auto merge of #116012 - cjgillot:gvn-const, r=oli-obkbors-1063/+1072
Implement constant propagation on top of MIR SSA analysis This implements the idea I proposed in https://github.com/rust-lang/rust/pull/110719#issuecomment-1718324700 Based on https://github.com/rust-lang/rust/pull/109597 The value numbering "GVN" pass formulates each rvalue that appears in MIR with an abstract form (the `Value` enum), and assigns an integer `VnIndex` to each. This abstract form can be used to deduplicate values, reusing an earlier local that holds the same value instead of recomputing. This part is proposed in #109597. From this abstract representation, we can perform more involved simplifications, for example in https://github.com/rust-lang/rust/pull/111344. With the abstract representation `Value`, we can also attempt to evaluate each to a constant using the interpreter. This builds a `VnIndex -> OpTy` map. From this map, we can opportunistically replace an operand or a rvalue with a constant if their value has an associated `OpTy`. The most relevant commit is [Evaluated computed values to constants.](https://github.com/rust-lang/rust/commit/2767c4912ea249c2f613a9cedcd6c13ea1237e54)" r? `@oli-obk`
2023-12-30Fix invalid check-cfg Cargo feature diagnostic helpUrgau-2/+1
2023-12-30Add check-cfg test for Cargo feature without valueUrgau-6/+30
2023-12-29Rollup merge of #119410 - est31:fix_if_guard_unused, r=NilstriebMatthias Krüger-2/+2
Rename test to be more descriptive As suggested in https://github.com/rust-lang/rust/pull/119402#discussion_r1438171079 r? ``@Nilstrieb``
2023-12-29Rollup merge of #119406 - lqd:issue-114325, r=compiler-errorsMatthias Krüger-0/+55
Add non-regression test for ATPIT ICE #114325 ATPIT issue #114325 had been unknowingly fixed by https://github.com/rust-lang/rust/pull/107421, so this PR adds its [MCVE](https://github.com/rust-lang/rust/issues/114325#issuecomment-1721561552) as a non-regression test. Closes #114325.
2023-12-29Rollup merge of #119388 - Enselic:prevent-lint-triplication, r=cjgillotMatthias Krüger-629/+29
rustc_lint: Prevent triplication of various lints Prevent triplication of various lints. The triplication happens because we run the same lint three times (or less in some cases): * In `BuiltinCombinedPreExpansionLintPass` * In `BuiltinCombinedEarlyLintPass` * In `shallow_lint_levels_on()` Only run the lints one time by checking the `lint_added_lints` bool. Set your GitHub diff setting to ignore whitespaces changes when reviewing this PR, since I had to enclose a block inside an if. Closes #73301 (I found this while exploring the code related to [this](https://github.com/rust-lang/rust/pull/119251#discussion_r1435677330) comment.)
2023-12-29Auto merge of #118911 - Young-Flash:fix_issue_118819, r=fmeasebors-4/+120
fix: correct the args for `disambiguate the associated function` diagnostic This is somehow silimar to https://github.com/rust-lang/rust/pull/118502, we shouldn't take receiver as first arg all the cases. close https://github.com/rust-lang/rust/issues/118819
2023-12-29Rename testest31-2/+2
2023-12-29add non-regression test for issue 114325Rémy Rakic-0/+55
2023-12-29Also walk bindings created by if-let guardsest31-0/+23
2023-12-28Auto merge of #119174 - compiler-errors:movability, r=cjgillotbors-2/+0
Remove movability from `TyKind::Coroutine` There's no reason to store movability in the generator struct directly. It is computed from the HIR, and can be pulled into a query to access when necessary.
2023-12-28rustc_lint: Prevent triplication of 'unknown lint' lintMartin Nordholts-369/+19
2023-12-28rustc_lint: Prevent multiple 'incompatible with previous forbid' lintsMartin Nordholts-203/+7
2023-12-28rustc_lint: Prevent multiple 'lint ignored' lintsMartin Nordholts-57/+3
Prevent multiple 'ignored unless specified at crate level' lints. The multiplication happens because we run the same lint three times: * In BuiltinCombinedEarlyLintPass * In BuiltinCombinedPreExpansionLintPass * In shallow_lint_levels_on Only run the lint one time by checking the `lint_added_lints` bool.
2023-12-28Rollup merge of #119380 - ShE3py:match-never-pat, r=petrochenkovMatthias Krüger-25/+25
Don't suggest writing a bodyless arm if the pattern can never be a never pattern #118527 enabled arms to be bodyless for never patterns ; this PR removes the `,` and `}` suggestions for patterns that could never be never patterns.
2023-12-28Rollup merge of #119376 - msrd0:regression-test-106630, r=petrochenkovMatthias Krüger-0/+33
Add regression test for #106630 This PR adds a regression test for #106630. I was unsure where exactly to place the test or how to test it locally so please let me know if I should change something.
2023-12-28Rollup merge of #119331 - notriddle:notriddle/maxpatheditdistance, ↵Matthias Krüger-27/+122
r=GuillaumeGomez rustdoc-search: count path edits with separate edit limit Avoids strange-looking results like this one, where the path component seems to be ignored: ![image](https://github.com/rust-lang/rust/assets/1593513/f0ef077a-6e09-4d67-a29d-8cabc1495f66) Since the two are counted separately elsewhere, they should get their own limits, too. The biggest problem with combining them is that paths are loosely checked by not requiring every component to match, which means that if they are short and matched loosely, they can easily find "drunk typist" matches that make no sense, like this old result: std::collections::btree_map::itermut matching slice::itermut maxEditDistance = ("slice::itermut".length) / 3 = 14 / 3 = 4 editDistance("std", "slice") = 4 editDistance("itermut", "itermut") = 0 4 + 0 <= 4 PASS Of course, `slice::itermut` should not match stuff from btreemap. `slice` should not match `std`. The new result counts them separately: maxPathEditDistance = "slice".length / 3 = 5 / 3 = 1 maxEditDistance = "itermut".length / 3 = 7 / 3 = 2 editDistance("std", "slice") = 4 4 <= 1 FAIL Effectively, this makes path queries less "typo-resistant". It's not zero, but it means `vec` won't match the `v1` prelude. This commit also adds substring matching to paths. It's stricter than the substring matching in the main part, but loose enough that what I expect to match does. Queries without parent paths are unchanged.
2023-12-28Remove movability from TyKind::CoroutineMichael Goulet-2/+0
2023-12-28Don't validate / lint MIR before each passTomasz Miąsko-1/+1
To avoid redundant work and verbose output in case of failures.
2023-12-28Don't expect bodyless arms if the pattern can never be a never patternLieselotte-25/+25
2023-12-28Add regression test for #106630Dominic-0/+33
2023-12-27Auto merge of #119105 - dtolnay:paren, r=WaffleLapkinbors-0/+60
Fix parenthesization of subexprs containing statement boundary This PR fixes a multitude of false negatives and false positives in the AST pretty printer's parenthesis insertion related to statement boundaries &mdash; statements which terminate unexpectedly early if there aren't parentheses. Without this fix, the AST pretty printer (including both `stringify!` and `rustc -Zunpretty=expanded`) is prone to producing output which is not syntactically valid Rust. Invalid output is problematic because it means Rustfmt is unable to parse the output of `cargo expand`, for example, causing friction by forcing someone trying to debug a macro into reading poorly formatted code. I believe the set of bugs fixed in this PR account for the most prevalent reason that `cargo expand` produces invalid output in real-world usage. Fixes #98790. ## False negatives The following is a correct program &mdash; `cargo check` succeeds. ```rust macro_rules! m { ($e:expr) => { match () { _ => $e } }; } fn main() { m!({ 1 } - 1); } ``` But `rustc -Zunpretty=expanded main.rs` produces output that is invalid Rust syntax, because parenthesization is needed and not being done by the pretty printer. ```rust fn main() { match () { _ => { 1 } - 1, }; } ``` Piping this expanded code to rustfmt, it fails to parse. ```console error: unexpected `,` in pattern --> <stdin>:1:38 | 1 | fn main() { match () { _ => { 1 } - 1, }; } | ^ | help: try adding parentheses to match on a tuple... | 1 | fn main() { match () { _ => { 1 } (- 1,) }; } | + + help: ...or a vertical bar to match on multiple alternatives | 1 | fn main() { match () { _ => { 1 } - 1 | }; } | ~~~~~ ``` Fixed output after this PR: ```rust fn main() { match () { _ => ({ 1 }) - 1, }; } ``` ## False positives Less problematic, but worth fixing (just like #118726). ```rust fn main() { let _ = match () { _ => 1 } - 1; } ``` Output of `rustc -Zunpretty=expanded lib.rs` before this PR. There is no reason parentheses would need to be inserted there. ```rust fn main() { let _ = (match () { _ => 1, }) - 1; } ``` After this PR: ```rust fn main() { let _ = match () { _ => 1, } - 1; } ``` ## Alternatives considered In this PR I opted to parenthesize only the leading subexpression causing the statement boundary, rather than the entire statement. Example: ```rust macro_rules! m { ($e:expr) => { $e }; } fn main() { m!(loop { break [1]; }[0] - 1); } ``` This PR produces the following pretty-printed contents for fn main: ```rust (loop { break [1]; })[0] - 1; ``` A different equally correct output would be: ```rust (loop { break [1]; }[0] - 1); ``` I chose the one I did because it is the *only* approach used by handwritten code in the standard library and compiler. There are 4 places where parenthesization is being used to prevent a statement boundary, and in all 4, the developer has chosen to parenthesize the smallest subexpression rather than the whole statement: https://github.com/rust-lang/rust/blob/b37d43efd9c5a7a3d76ed21c454dd0f40945d77d/compiler/rustc_codegen_cranelift/example/alloc_system.rs#L102 https://github.com/rust-lang/rust/blob/b37d43efd9c5a7a3d76ed21c454dd0f40945d77d/compiler/rustc_parse/src/errors.rs#L1021-L1029 https://github.com/rust-lang/rust/blob/b37d43efd9c5a7a3d76ed21c454dd0f40945d77d/library/core/src/future/poll_fn.rs#L151 https://github.com/rust-lang/rust/blob/b37d43efd9c5a7a3d76ed21c454dd0f40945d77d/library/core/src/ops/range.rs#L824-L828
2023-12-27Auto merge of #119099 - fmease:always-const-trait-bounds, r=fee1-deadbors-111/+372
Introduce `const Trait` (always-const trait bounds) Feature `const_trait_impl` currently lacks a way to express “always const” trait bounds. This makes it impossible to define generic items like fns or structs which contain types that depend on const method calls (\*). While the final design and esp. the syntax of effects / keyword generics isn't set in stone, some version of “always const” trait bounds will very likely form a part of it. Further, their implementation is trivial thanks to the `effects` backbone. Not sure if this needs t-lang sign-off though. (\*): ```rs #![feature(const_trait_impl, effects, generic_const_exprs)] fn compute<T: const Trait>() -> Type<{ T::generate() }> { /*…*/ } struct Store<T: const Trait> where Type<{ T::generate() }>:, { field: Type<{ T::generate() }>, } ``` Lastly, “always const” trait bounds are a perfect fit for `generic_const_items`. ```rs #![feature(const_trait_impl, effects, generic_const_items)] const DEFAULT<T: const Default>: T = T::default(); ``` Previously, we (oli, fee1-dead and I) wanted to reinterpret `~const Trait` as `const Trait` in generic const items which would've been quite surprising and not very generalizable. Supersedes #117530. --- cc `@oli-obk` As discussed r? fee1-dead (or compiler)
2023-12-27Auto merge of #117303 - sjwang05:issue-117245, r=estebankbors-0/+200
Suggest `=>` --> `>=` in comparisons Fixes #117245
2023-12-27Introduce `const Trait` (always-const trait bounds)León Orell Valerian Liehr-111/+372
2023-12-27Auto merge of #119327 - notriddle:notriddle/plusencoding, r=GuillaumeGomezbors-0/+9
rustdoc: treat query string `+` as space Fixes #119219
2023-12-27Rollup merge of #119175 - veera-sivarajan:fix-cast-to-slice, r=WaffleLapkinMatthias Krüger-14/+33
fix: diagnostic for casting reference to slice fixes: #118790 Removes `if self.cast_ty.is_trait()` to produce the same diagnostic for cast to slice and trait.
2023-12-27fix broken CI and code reviewYoung-Flash-6/+53
2023-12-26Suggest `=>` --> `>=` in conditionssjwang05-0/+200
2023-12-26rustdoc-search: count path edits with separate edit limitMichael Howell-27/+122
Since the two are counted separately elsewhere, they should get their own limits, too. The biggest problem with combining them is that paths are loosely checked by not requiring every component to match, which means that if they are short and matched loosely, they can easily find "drunk typist" matches that make no sense, like this old result: std::collections::btree_map::itermut matching slice::itermut maxEditDistance = ("slice::itermut".length) / 3 = 14 / 3 = 4 editDistance("std", "slice") = 4 editDistance("itermut", "itermut") = 0 4 + 0 <= 4 PASS Of course, `slice::itermut` should not match stuff from btreemap. `slice` should not match `std`. The new result counts them separately: maxPathEditDistance = "slice".length / 3 = 5 / 3 = 1 maxEditDistance = "itermut".length / 3 = 7 / 3 = 2 editDistance("std", "slice") = 4 4 <= 1 FAIL Effectively, this makes path queries less "typo-resistant". It's not zero, but it means `vec` won't match the `v1` prelude. Queries without parent paths are unchanged.