about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2023-02-03Auto merge of #107642 - Dylan-DPC:rollup-edcqhm5, r=Dylan-DPCbors-202/+684
Rollup of 6 pull requests Successful merges: - #107082 (Autotrait bounds on dyn-safe trait methods) - #107427 (Add candidates for DiscriminantKind builtin) - #107539 (Emit warnings on unused parens in index expressions) - #107544 (Improve `TokenCursor`.) - #107585 (Don't cause a cycle when formatting query description that references a FnDef) - #107633 (Fix suggestion for coercing Option<&String> to Option<&str>) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-03Rollup merge of #107633 - clubby789:option-string-coerce-fix, r=NilstriebDylan DPC-13/+88
Fix suggestion for coercing Option<&String> to Option<&str> Fixes #107604 This also makes the diagnostic `MachineApplicable`, and runs `rustfix` to check we're not producing incorrect code. ``@rustbot`` label +A-diagnostics
2023-02-03Rollup merge of #107585 - compiler-errors:fndef-sig-cycle, r=oli-obkDylan DPC-20/+51
Don't cause a cycle when formatting query description that references a FnDef When a function returns `-> _`, we use typeck to compute what the resulting type of the body _should_ be. If we call another query inside of typeck and hit a cycle error, we attempt to report the cycle error which requires us to compute all of the query descriptions for the stack. However, if one of the queries in that cycle has a query description that references this function as a FnDef type, we'll cause a *second* cycle error from within the cycle error reporting code, since rendering a FnDef requires us to compute its signature. This causes an unwrap to ICE, since during the *second* cycle reporting code, we try to look for a job that isn't in the active jobs list. We can avoid this by using `with_no_queries!` when computing these query descriptions. Fixes #107089 The only drawback is that the rendering of opaque types in cycles regresses a bit :| I'm open to alternate suggestions about how we may handle this...
2023-02-03Rollup merge of #107544 - nnethercote:improve-TokenCursor, r=petrochenkovDylan DPC-91/+98
Improve `TokenCursor`. Some small improvements, for things that were bugging me. Best reviewed one commit at a time. r? ``@petrochenkov``
2023-02-03Rollup merge of #107539 - PossiblyAShrub:unused-parens-in-index, r=lcnrDylan DPC-0/+45
Emit warnings on unused parens in index expressions Fixes: #96606. I am not sure what the best term for "index expression" is. Is there a better term we could use?
2023-02-03Rollup merge of #107427 - detrumi:builtin-impl-candidates, r=compiler-errorsDylan DPC-0/+25
Add candidates for DiscriminantKind builtin Part of #107379
2023-02-03Rollup merge of #107082 - dtolnay:autotraits, r=lcnrDylan DPC-78/+377
Autotrait bounds on dyn-safe trait methods This PR is a successor to #106604 implementing the approach encouraged by https://github.com/rust-lang/rust/pull/106604#issuecomment-1387353737. **I propose making it legal to use autotraits as trait bounds on the `Self` type of trait methods in a trait object.** https://github.com/rust-lang/rust/issues/51443#issuecomment-1374847313 justifies why this use case is particularly important in the context of the async-trait crate. ```rust #![feature(auto_traits)] #![deny(where_clauses_object_safety)] auto trait AutoTrait {} trait MyTrait { fn f(&self) where Self: AutoTrait; } fn main() { let _: &dyn MyTrait; } ``` Previously this would fail with: ```console error: the trait `MyTrait` cannot be made into an object --> src/main.rs:7:8 | 7 | fn f(&self) where Self: AutoTrait; | ^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #51443 <https://github.com/rust-lang/rust/issues/51443> note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> --> src/main.rs:7:8 | 6 | trait MyTrait { | ------- this trait cannot be made into an object... 7 | fn f(&self) where Self: AutoTrait; | ^ ...because method `f` references the `Self` type in its `where` clause = help: consider moving `f` to another trait ``` In order for this to be sound without hitting #50781, **I further propose that we disallow handwritten autotrait impls that apply to trait objects.** Both of the following were previously allowed (_on nightly_) and no longer allowed in my proposal: ```rust auto trait AutoTrait {} trait MyTrait {} impl AutoTrait for dyn MyTrait {} // NOT ALLOWED impl<T: ?Sized> AutoTrait for T {} // NOT ALLOWED ``` (`impl<T> AutoTrait for T {}` remains allowed.) After this change, traits with a default impl are implemented for a trait object **if and only if** the autotrait is one of the trait object's trait bounds (or a supertrait of a bound). In other words `dyn Trait + AutoTrait` always implements AutoTrait while `dyn Trait` never implements AutoTrait. Fixes https://github.com/dtolnay/async-trait/issues/228. r? `@lcnr`
2023-02-03Autotrait bounds on dyn-safe trait methodsDavid Tolnay-10/+110
2023-02-03Disallow impl autotrait for trait objectDavid Tolnay-68/+267
2023-02-03Auto merge of #107599 - clubby789:debug-less-ref, r=nnethercotebors-12/+27
Don't generate unecessary `&&self.field` in deriving Debug Since unsized fields may only be the last one in a struct, we only need to generate a double reference (`&&self.field`) for the final one. cc `@nnethercote`
2023-02-03Fix suggestion for coercing Option<&String> to Option<&str>clubby789-13/+88
2023-02-03Auto merge of #107569 - petrochenkov:optattr, r=nnethercotebors-76/+90
ast: Optimize list and value extraction primitives for attributes It's not necessary to convert the whole attribute into a meta item to extract something specific.
2023-02-03Use new helper inside probeWilco Kusee-6/+2
2023-02-03Auto merge of #107625 - matthiaskrgr:rollup-xr9oldy, r=matthiaskrgrbors-122/+521
Rollup of 6 pull requests Successful merges: - #106575 (Suggest `move` in nested closure when appropriate) - #106805 (Suggest `{var:?}` when finding `{?:var}` in inline format strings) - #107500 (Add tests to assert current behavior of large future sizes) - #107598 (Fix benchmarks in library/core with black_box) - #107602 (Parse and recover from type ascription in patterns) - #107608 (Use triple rather than arch for fuchsia test-runner) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-03Rollup merge of #107608 - P1n3appl3:master, r=tmandryMatthias Krüger-29/+24
Use triple rather than arch for fuchsia test-runner This allows the user of the test-runner script to specify a full triple rather than just an architecture which helps with the transition from the two component to three component target triples for fuchsia.
2023-02-03Rollup merge of #107602 - estebank:anon-enum-access, r=compiler-errorsMatthias Krüger-39/+164
Parse and recover from type ascription in patterns Reintroduce part of #106960, which was reverted in #107478. r? `@compiler-errors`
2023-02-03Rollup merge of #107598 - chenyukang:yukang/fix-core-bench, r=thomccMatthias Krüger-32/+44
Fix benchmarks in library/core with black_box Fixes #107590
2023-02-03Rollup merge of #107500 - bryangarza:future-sizes-baseline-test, ↵Matthias Krüger-0/+94
r=compiler-errors Add tests to assert current behavior of large future sizes Based on a couple of sources: - https://swatinem.de/blog/future-size/ - https://github.com/rust-lang/rust/issues/62958
2023-02-03Rollup merge of #106805 - madsravn:master, r=compiler-errorsMatthias Krüger-1/+97
Suggest `{var:?}` when finding `{?:var}` in inline format strings Link to issue: https://github.com/rust-lang/rust/issues/106572 This is my first PR to this project, so hopefully I can get some good pointers with me from the first PR. Currently my idea was to test out whether or not this is the correct solution to this issue and then hopefully expand upon the idea to not only work for Debug formatting but for all of them. If this is a valid solution, I will create a new issue to give a better error message to a broader range of wrong-order formatting.
2023-02-03Rollup merge of #106575 - estebank:issue-64008, r=pnkfelixMatthias Krüger-21/+98
Suggest `move` in nested closure when appropriate Fix #64008.
2023-02-03Auto merge of #107543 - ehuss:protocol-sparse, r=jyn514bors-0/+6
Enable Cargo's sparse protocol in CI This enables the sparse protocol in CI in order to exercise and dogfood it. This is intended test the production server in a real-world situation. Closes #107342
2023-02-03Auto merge of #107241 - clubby789:bootstrap-lto-off, r=simulacrumbors-2/+19
Add `rust.lto=off` to bootstrap and set as compiler/library default Closes #107202 The issue mentions `embed-bitcode=on`, but here https://github.com/rust-lang/rust/blob/c8e6a9e8b6251bbc8276cb78cabe1998deecbed7/src/bootstrap/compile.rs#L379-L381 it appears that this is always set for std stage 1+, so I'm unsure if changes are needed here. `@rustbot` label +A-bootstrap
2023-02-03Rename `Cursor`/`CursorRef` as `TokenTreeCursor`/`RefTokenTreeCursor`.Nicholas Nethercote-29/+34
This makes it clear they return token trees, and makes for a nice comparison against `TokenCursor` which returns tokens.
2023-02-03Remove `TokenCursorFrame`.Nicholas Nethercote-42/+34
The motivation here is to eliminate the `Option<(Delimiter, DelimSpan)>`, which is `None` for the outermost token stream and `Some` for all other token streams. We are already treating the innermost frame specially -- this is the `frame` vs `stack` distinction in `TokenCursor`. We can push that further so that `frame` only contains the cursor, and `stack` elements contain the delimiters for their children. When we are in the outermost token stream `stack` is empty, so there are no stored delimiters, which is what we want because the outermost token stream *has* no delimiters. This change also shrinks `TokenCursor`, which shrinks `Parser` and `LazyAttrTokenStreamImpl`, which is nice.
2023-02-03Make clear that `TokenTree::Token` shouldn't contain a delimiter.Nicholas Nethercote-2/+9
2023-02-03Improve doc comment desugaring.Nicholas Nethercote-27/+30
Sometimes the parser needs to desugar a doc comment into `#[doc = r"foo"]`. Currently it does this in a hacky way: by pushing a "fake" new frame (one without a delimiter) onto the `TokenCursor` stack. This commit changes things so that the token stream itself is modified in place. The nice thing about this is that it means `TokenCursorFrame::delim_sp` is now only `None` for the outermost frame.
2023-02-02Tweak misleading commentMichael Goulet-1/+1
2023-02-02Don't generate unecessary `&&self.field` in deriving Debugclubby789-12/+27
2023-02-02Use triple rather than arch for fuchsia test runnerJoseph Ryan-29/+24
2023-02-02Auto merge of #107000 - GuillaumeGomez:fix-items-in-doc-hidden-block, ↵bors-111/+357
r=notriddle,petrochenkov Fix handling of items inside a `doc(hidden)` block Fixes #106373. cc `@aDotInTheVoid` r? `@notriddle`
2023-02-02Emit warnings on unused parens/braces in index expressionsAidan Olsen-0/+45
2023-02-02Auto merge of #107601 - matthiaskrgr:rollup-07zaafe, r=matthiaskrgrbors-170/+322
Rollup of 7 pull requests Successful merges: - #106919 (Recover `_` as `..` in field pattern) - #107493 (Improve diagnostic for missing space in range pattern) - #107515 (Improve pretty-printing of `HirIdValidator` errors) - #107524 (Remove both StorageLive and StorageDead in CopyProp.) - #107532 (Erase regions before doing uninhabited check in borrowck) - #107559 (Rename `rust_2015` → `is_rust_2015`) - #107577 (Reinstate the `hir-stats.rs` tests on stage 1.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-02Parse and recover from type ascription in patternsEsteban Küber-39/+164
2023-02-03fix #107590, Fix benchmarks in library/core with black_boxyukang-32/+44
2023-02-02Suggest `move` in nested closure when appropriateEsteban Küber-21/+98
Fix #64008.
2023-02-02Rollup merge of #107577 - nnethercote:reinstate-hir-stats, r=jyn514Matthias Krüger-1/+5
Reinstate the `hir-stats.rs` tests on stage 1. r? ```@the8472```
2023-02-02Rollup merge of #107559 - WaffleLapkin:is_it_2015¿, r=davidtwcoMatthias Krüger-18/+21
Rename `rust_2015` → `is_rust_2015` r? ```@compiler-errors``` https://github.com/rust-lang/rust/pull/107508#discussion_r1092300088
2023-02-02Rollup merge of #107532 - compiler-errors:erase-regions-in-uninhabited, ↵Matthias Krüger-1/+22
r=jackh726 Erase regions before doing uninhabited check in borrowck ~Also, fingerprint query keys/values when debug assertions are enabled. This should make it easier to check for issues like this without `-Cincremental`, and make UI tests a bit cleaner.~ edit: moving that to a separate PR Fixes #107505
2023-02-02Rollup merge of #107524 - cjgillot:both-storage, r=RalfJungMatthias Krüger-48/+176
Remove both StorageLive and StorageDead in CopyProp. Fixes https://github.com/rust-lang/rust/issues/107511 https://github.com/rust-lang/rust/pull/106908 removed StorageDead without the accompanying StorageLive. In loops, execution would see repeated StorageLive, without any StorageDead, which is UB. So when removing storage statements, we have to remove both StorageLive and StorageDead. ~I also added a MIR validation pass for StorageLive. It may be a bit overzealous.~
2023-02-02Rollup merge of #107515 - Swatinem:hirvalidator, r=compiler-errorsMatthias Krüger-49/+32
Improve pretty-printing of `HirIdValidator` errors This now uses `node_to_string` for both missing and seen Ids, which includes the snippet of code for which the Id was allocated. Also removes the duplicated printing of `HirId`, as `node_to_string` also includes that.
2023-02-02Rollup merge of #107493 - clubby789:range-fat-arrow-followup, r=estebankMatthias Krüger-21/+24
Improve diagnostic for missing space in range pattern Improves the diagnostic in #107425 by turning it into a note explaining the parsing issue. r? `@compiler-errors`
2023-02-02Rollup merge of #106919 - compiler-errors:underscore-typo-in-field-pat, ↵Matthias Krüger-32/+42
r=jackh726 Recover `_` as `..` in field pattern
2023-02-02Improve diagnostic for missing space in range patternclubby789-21/+24
2023-02-02Auto merge of #107478 - compiler-errors:anon-enum-tys-are-ambiguous, r=estebankbors-265/+72
Revert "Teach parser to understand fake anonymous enum syntax" and related commits anonymous enum types are currently ambiguous in positions like: * `|` operator: `a as fn() -> B | C` * closure args: `|_: as fn() -> A | B` I first tried to thread around `RecoverAnonEnum` into all these positions, but the resulting complexity in the compiler is IMO not worth it, or at least worth a bit more thinking time. In the mean time, let's revert this syntax for now, so we can go back to the drawing board. Fixes #107461 cc: `@estebank` `@cjgillot` #106960 --- ### Squashed revert commits: Revert "review comment: Remove AST AnonTy" This reverts commit 020cca8d36cb678e3ddc2ead41364be314d19e93. Revert "Ensure macros are not affected" This reverts commit 12d18e403139eeeeb339e8611b2bed4910864edb. Revert "Emit fewer errors on patterns with possible type ascription" This reverts commit c847a01a3b1f620c4fdb98c75805033e768975d1. Revert "Teach parser to understand fake anonymous enum syntax" This reverts commit 2d824206655bfb26cb5eed43490ee396542b153e.
2023-02-02PR fixing wrong order of format parameters in strings. Issue #106572Mads Ravn-1/+97
Adding Adding Fixing small issues for PR Adding tests Removing unused binding Changing the wording on note Fixing PR comment
2023-02-02Auto merge of #107584 - matthiaskrgr:rollup-vav4ljz, r=matthiaskrgrbors-254/+155
Rollup of 5 pull requests Successful merges: - #107201 (Remove confusing 'while checking' note from opaque future type mismatches) - #107312 (Add Style Guide rules for let-else statements) - #107488 (Fix syntax in `-Zunpretty-expanded` output for derived `PartialEq`.) - #107531 (Inline CSS background images directly into the CSS) - #107576 (Add proc-macro boilerplate to crt-static test) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-02-02Use `rust_2018` instead of `!is_rust_2015`Maybe Waffle-1/+1
2023-02-02Rename `rust_2015` => `is_rust_2015`Maybe Waffle-18/+21
2023-02-02Recover _ as .. in field patternMichael Goulet-32/+42
2023-02-02Add a testMichael Goulet-0/+26