about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
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.
2023-12-26Suggest `=` to `==` in more cases, even in the face of reference mismatchEsteban Küber-1/+17
Given `foo: &String` and `bar: str`, suggest `==` when given `if foo = bar {}`: ``` error[E0308]: mismatched types --> $DIR/assignment-expected-bool.rs:37:8 | LL | if foo = bar {} | ^^^^^^^^^ expected `bool`, found `()` | help: you might have meant to compare for equality | LL | if foo == bar {} | + ```
2023-12-26Auto merge of #118431 - sjwang05:issue-44695, r=estebankbors-54/+377
Emit better suggestions for `&T == T` and `T == &T` Fixes #40660 Fixes #44695
2023-12-26rustdoc: treat query string `+` as spaceMichael Howell-0/+9
Fixes #119219
2023-12-26Auto merge of #119324 - compiler-errors:rollup-c6eqcg9, r=compiler-errorsbors-5/+72
Rollup of 5 pull requests Successful merges: - #119235 (Add missing feature gate for sanitizer CFI cfgs) - #119240 (Make some non-diagnostic-affecting `QPath::LangItem` into regular `QPath`s) - #119297 (Pass DeadItem and lint as consistent group in dead-code.) - #119307 (Clean up some lifetimes in `rustc_pattern_analysis`) - #119323 (add test for coercing never to infinite type) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-26Rollup merge of #119323 - lukas-code:test-never-to-infinite, r=compiler-errorsMichael Goulet-1/+31
add test for coercing never to infinite type Closes https://github.com/rust-lang/rust/issues/113197. This was fixed in https://github.com/rust-lang/rust/pull/118308, probably https://github.com/rust-lang/rust/pull/118308/commits/1978168c136ba65b8da3f5a45834631c13d7c56f.
2023-12-26Rollup merge of #119297 - cjgillot:issue-119267, r=petrochenkovMichael Goulet-0/+4
Pass DeadItem and lint as consistent group in dead-code. Fixes https://github.com/rust-lang/rust/issues/119267
2023-12-26Rollup merge of #119240 - compiler-errors:lang-item-more, r=petrochenkovMichael Goulet-4/+3
Make some non-diagnostic-affecting `QPath::LangItem` into regular `QPath`s The rest of 'em affect diagnostics, so leave them alone... for now. cc #115178
2023-12-26Rollup merge of #119235 - Urgau:missing-feature-gate-sanitizer-cfi-cfgs, ↵Michael Goulet-0/+34
r=Nilstrieb Add missing feature gate for sanitizer CFI cfgs Found during the review of https://github.com/rust-lang/rust/pull/118494 in https://github.com/rust-lang/rust/pull/118494#discussion_r1416079288. cc `@rcvalle`
2023-12-26Auto merge of #119042 - bvanjoi:fix-118697-2, r=compiler-errorsbors-0/+37
fallback `default` to `None` during ast-lowering for lifetime binder Fixes #118697 This is another attempt. It has a fallback, setting `default` to `None` and emit an error for non-lifetime binders during ast lowering. r? `@compiler-errors`
2023-12-26add test for coercing never to infinite typeLukas Markeffsky-0/+30
2023-12-26rename testsLukas Markeffsky-1/+1
2023-12-26Auto merge of #119133 - scottmcm:assert-unchecked, r=thomccbors-0/+19
Add `hint::assert_unchecked` Libs-API expressed interest, modulo bikeshedding, in https://github.com/rust-lang/libs-team/issues/315#issuecomment-1863159430 I think that means this is good for nightly, since we can always rename it before stabilization. Tracking issue: https://github.com/rust-lang/rust/issues/119131
2023-12-26Auto merge of #119129 - jyn514:verbose, r=compiler-errors,estebankbors-55/+96
rework `-Zverbose` implements the changes described in https://github.com/rust-lang/compiler-team/issues/706 the first commit is only a name change from `-Zverbose` to `-Zverbose-internals` and does not change behavior. the second commit changes diagnostics. possible follow up work: - `ty::pretty` could print more info with `--verbose` than it does currently. `-Z verbose-internals` shows too much info in a way that's not helpful to users. michael had ideas about this i didn't fully understand: https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/uplift.20some.20-Zverbose.20calls.20and.20rename.20to.E2.80.A6.20compiler-team.23706/near/408984200 - `--verbose` should imply `-Z write-long-types-to-disk=no`. the code in `ty_string_with_limit` should take `--verbose` into account (apparently this affects `Ty::sort_string`, i'm not familiar with this code). writing a file to disk should suggest passing `--verbose`. r? `@compiler-errors` cc `@estebank`
2023-12-26Don't drop a hir node after loweringNadrieril-0/+37