about summary refs log tree commit diff
path: root/src
AgeCommit message (Collapse)AuthorLines
2022-01-21Auto merge of #93138 - matthiaskrgr:rollup-m8akifd, r=matthiaskrgrbors-139/+670
Rollup of 17 pull requests Successful merges: - #91032 (Introduce drop range tracking to generator interior analysis) - #92856 (Exclude "test" from doc_auto_cfg) - #92860 (Fix errors on blanket impls by ignoring the children of generated impls) - #93038 (Fix star handling in block doc comments) - #93061 (Only suggest adding `!` to expressions that can be macro invocation) - #93067 (rustdoc mobile: fix scroll offset when jumping to internal id) - #93086 (Add tests to ensure that `let_chains` works with `if_let_guard`) - #93087 (Fix src/test/run-make/raw-dylib-alt-calling-convention) - #93091 (⬆ chalk to 0.76.0) - #93094 (src/test/rustdoc-json: Check for `struct_field`s in `variant_tuple_struct.rs`) - #93098 (Show a more informative panic message when `DefPathHash` does not exist) - #93099 (rustdoc: auto create output directory when "--output-format json") - #93102 (Pretty printer algorithm revamp step 3) - #93104 (Support --bless for pp-exact pretty printer tests) - #93114 (update comment for `ensure_monomorphic_enough`) - #93128 (Add script to prevent point releases with same number as existing ones) - #93136 (Backport the 1.58.1 release notes to master) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-01-20Rollup merge of #93128 - pietroalbini:pa-verify-stable-version-number, ↵Matthias Krüger-0/+34
r=Mark-Simulacrum Add script to prevent point releases with same number as existing ones This will hopefully prevent what happened today with #93110 and #93121, where we built point release artifacts without changing version numbers, thus requiring another PR to change the version number. r? `@Mark-Simulacrum`
2022-01-20Rollup merge of #93104 - dtolnay:ppbless, r=Mark-SimulacrumMatthias Krüger-1/+13
Support --bless for pp-exact pretty printer tests I ran into this while working on the stack of PRs containing #93102. `x.py test src/test/pretty --bless` previously would `fatal` instead of blessing the input files. Tested by making a silly pretty-printer tweak and running the above command: 98823c3929ebfe796786345c5ee713f63317d9c6
2022-01-20Rollup merge of #93099 - tomkris:rustdoc-fix, r=jshaMatthias Krüger-4/+8
rustdoc: auto create output directory when "--output-format json" This PR allows rustdoc to automatically create output directory in case it does not exist (when run with `--output-format json`). This fixes rustdoc crash: ```` $ rustdoc --output-format json -Z unstable-options src/main.rs error: couldn't generate documentation: No such file or directory (os error 2) | = note: failed to create or modify "doc/main.json" error: aborting due to previous error ```` With this fix behavior of `rustdoc --output-format json` becomes consistent with `rustdoc --output-format html` (which already auto-creates output directory if it's missing)
2022-01-20Rollup merge of #93094 - Enselic:check-for-enum-tuple-struct-fields, ↵Matthias Krüger-2/+4
r=CraftSpider src/test/rustdoc-json: Check for `struct_field`s in `variant_tuple_struct.rs` The presence of `struct_field`s is being checked for already in `variant_struct.rs`. We should also check for them in `variant_tuple_struct.rs`. This PR is one small step towards resolving #92945.
2022-01-20Rollup merge of #93087 - ricobbe:alt-calling-convention-test-fix, ↵Matthias Krüger-5/+11
r=Mark-Simulacrum Fix src/test/run-make/raw-dylib-alt-calling-convention Fix the test headers so that the test now runs on all intended platforms; it is currently ignored on all platforms because the headers are incorrect. Also comment out a couple of function calls that fail because of an unrelated problem, described in issue #91167.
2022-01-20Rollup merge of #93086 - c410-f3r:let-guard, r=Mark-SimulacrumMatthias Krüger-2/+26
Add tests to ensure that `let_chains` works with `if_let_guard` The current machinery already makes such combination possible but lacks tests. cc `@matthewjasper`
2022-01-20Rollup merge of #93067 - jsha:fix-scroll-padding-top, r=GuillaumeGomezMatthias Krüger-1/+14
rustdoc mobile: fix scroll offset when jumping to internal id Followup to #92692. The semantics of `scroll-margin-top` are a little surprising - the attribute needs to be applied to the element that gets scrolled into the viewport, not the scrolling element. This fixes an issue where clicking on a method (or other item) from the sidebar takes you to a scroll position where the topbar covers up the method name. I'm interested in ideas for how to test this with browser-ui-test, but I think it doesn't yet have what I need. What I need is an assert that `<element>.getBoundingClientRect().y` is > 45. Demo: https://rustdoc.crud.net/jsha/fix-scroll-padding-top/std/string/struct.String.html#method.extend_from_within r? `@GuillaumeGomez`
2022-01-20Rollup merge of #93061 - estebank:macr-suggestion, r=cjgillotMatthias Krüger-23/+68
Only suggest adding `!` to expressions that can be macro invocation
2022-01-20Rollup merge of #93038 - GuillaumeGomez:block-doc-comments, r=notriddleMatthias Krüger-2/+15
Fix star handling in block doc comments Fixes #92872. Some extra explanation about this PR and why https://github.com/rust-lang/rust/pull/92357 created this regression: when we merge doc comment kinds for example in: ```rust /// he /** * hello */ #[doc = "boom"] ``` We don't want to remove the empty lines between them. However, to correctly compute the "horizontal trim", we still need it, so instead, I put back a part of the "vertical trim" directly in the "horizontal trim" computation so it doesn't impact the output buffer but allows us to correctly handle the stars. r? ``@camelid``
2022-01-20Rollup merge of #92860 - CraftSpider:rustdoc-json-impl-ice, r=jshaMatthias Krüger-1/+28
Fix errors on blanket impls by ignoring the children of generated impls Related to #83718 We can safely skip the children, as they don't contain any new info, and may be subtly different for reasons hard to track down, in ways that are consistently worse than the actual generic impl.
2022-01-20Rollup merge of #92856 - GuillaumeGomez:exclude-test-doc_auto_cfg, r=Nemo157Matthias Krüger-20/+51
Exclude "test" from doc_auto_cfg Fixes #91740. cc `@Nemo157` (you were the one suggesting this iirc) r? `@camelid`
2022-01-20Rollup merge of #91032 - eholk:generator-drop-tracking, r=nikomatsakisMatthias Krüger-80/+413
Introduce drop range tracking to generator interior analysis This PR addresses cases such as this one from #57478: ```rust struct Foo; impl !Send for Foo {} let _: impl Send = || { let guard = Foo; drop(guard); yield; }; ``` Previously, the `generator_interior` pass would unnecessarily include the type `Foo` in the generator because it was not aware of the behavior of `drop`. We fix this issue by introducing a drop range analysis that finds portions of the code where a value is guaranteed to be dropped. If a value is dropped at all suspend points, then it is no longer included in the generator type. Note that we are using "dropped" in a generic sense to include any case in which a value has been moved. That is, we do not only look at calls to the `drop` function. There are several phases to the drop tracking algorithm, and we'll go into more detail below. 1. Use `ExprUseVisitor` to find values that are consumed and borrowed. 2. `DropRangeVisitor` uses consume and borrow information to gather drop and reinitialization events, as well as build a control flow graph. 3. We then propagate drop and reinitialization information through the CFG until we reach a fix point (see `DropRanges::propagate_to_fixpoint`). 4. When recording a type (see `InteriorVisitor::record`), we check the computed drop ranges to see if that value is definitely dropped at the suspend point. If so, we skip including it in the type. ## 1. Use `ExprUseVisitor` to find values that are consumed and borrowed. We use `ExprUseVisitor` to identify the places where values are consumed. We track both the `hir_id` of the value, and the `hir_id` of the expression that consumes it. For example, in the expression `[Foo]`, the `Foo` is consumed by the array expression, so after the array expression we can consider the `Foo` temporary to be dropped. In this process, we also collect values that are borrowed. The reason is that the MIR transform for generators conservatively assumes anything borrowed is live across a suspend point (see `rustc_mir_transform::generator::locals_live_across_suspend_points`). We match this behavior here as well. ## 2. Gather drop events, reinitialization events, and control flow graph After finding the values of interest, we perform a post-order traversal over the HIR tree to find the points where these values are dropped or reinitialized. We use the post-order index of each event because this is how the existing generator interior analysis refers to the position of suspend points and the scopes of variables. During this traversal, we also record branching and merging information to handle control flow constructs such as `if`, `match`, and `loop`. This is necessary because values may be dropped along some control flow paths but not others. ## 3. Iterate to fixed point The previous pass found the interesting events and locations, but now we need to find the actual ranges where things are dropped. Upon entry, we have a list of nodes ordered by their position in the post-order traversal. Each node has a set of successors. For each node we additionally keep a bitfield with one bit per potentially consumed value. The bit is set if we the value is dropped along all paths entering this node. To compute the drop information, we first reverse the successor edges to find each node's predecessors. Then we iterate through each node, and for each node we set its dropped value bitfield to the intersection of all incoming dropped value bitfields. If any bitfield for any node changes, we re-run the propagation loop again. ## 4. Ignore dropped values across suspend points At this point we have a data structure where we can ask whether a value is guaranteed to be dropped at any post order index for the HIR tree. We use this information in `InteriorVisitor` to check whether a value in question is dropped at a particular suspend point. If it is, we do not include that value's type in the generator type. Note that we had to augment the region scope tree to include all yields in scope, rather than just the last one as we did before. r? `@nikomatsakis`
2022-01-20More clean upGuillaume Gomez-8/+4
2022-01-20Extra cfg_hide a bit to handle inner cfgsGuillaume Gomez-16/+11
2022-01-20Update doc_auto_cfg testGuillaume Gomez-2/+8
2022-01-20Exclude "test" from doc_auto_cfg renderingGuillaume Gomez-16/+50
2022-01-20add script to prevent point releases with same number as existing onesPietro Albini-0/+34
2022-01-20Rollup merge of #93108 - lnicola:rust-analyzer-2022-01-20, r=lnicolaMatthias Krüger-16/+18
:arrow_up: rust-analyzer r? `@ghost`
2022-01-20Rollup merge of #93038 - GuillaumeGomez:block-doc-comments, r=notriddleMatthias Krüger-2/+15
Fix star handling in block doc comments Fixes #92872. Some extra explanation about this PR and why https://github.com/rust-lang/rust/pull/92357 created this regression: when we merge doc comment kinds for example in: ```rust /// he /** * hello */ #[doc = "boom"] ``` We don't want to remove the empty lines between them. However, to correctly compute the "horizontal trim", we still need it, so instead, I put back a part of the "vertical trim" directly in the "horizontal trim" computation so it doesn't impact the output buffer but allows us to correctly handle the stars. r? `@camelid`
2022-01-20Rollup merge of #92861 - jsha:mobile-column-flex, r=GuillaumeGomezMatthias Krüger-15/+43
Rustdoc mobile: put out-of-band info on its own line Before this, the item name and the stability, source link, and "collapse all docs" would compete for room on a single line, resulting in awkward wrapping behavior on mobile. This gives a separate line for that out-of-band information. It also removes the "copy path" icon on mobile to make a little more room. Demo: https://rustdoc.crud.net/jsha/mobile-column-flex/std/string/struct.String.html r? `@GuillaumeGomez`
2022-01-20Rollup merge of #92704 - 5225225:std_mem_transmute_ref_t_mut_t, ↵Matthias Krüger-2/+2
r=michaelwoerister Change lint message to be stronger for &T -> &mut T transmute The old message implied that it's only UB if you use the reference to mutate, which (as far as I know) is not true. As in, the following program has UB, and a &T -> &mut T transmute is effectively an `unreachable_unchecked`. ```rust fn main() { #[allow(mutable_transmutes)] unsafe { let _ = std::mem::transmute::<&i32, &mut i32>(&0); } } ``` In the future, it might be a good idea to use the edition system to make this a hard error, since I don't think it is *ever* defined behaviour? Unless we rule that `&UnsafeCell<i32> -> &mut i32` is fine. (That, and you always could just use `.get()`, so you're not losing anything)
2022-01-20Rollup merge of #92680 - camelid:assoc-item-cleanup, r=petrochenkovMatthias Krüger-35/+53
intra-doc: Use the impl's assoc item where possible Before, the trait's associated item would be used. Now, the impl's associated item is used. The only exception is for impls that use default values for associated items set by the trait. In that case, the trait's associated item is still used. As an example of the old and new behavior, take this code: trait MyTrait { type AssocTy; } impl MyTrait for String { type AssocTy = u8; } Before, when resolving a link to `String::AssocTy`, `resolve_associated_trait_item` would return the associated item for `MyTrait::AssocTy`. Now, it would return the associated item for `<String as MyTrait>::AssocTy`, as it claims in its docs. r? `@petrochenkov`
2022-01-20Rollup merge of #92582 - lcnr:generic-arg-infer, r=BoxyUwUMatthias Krüger-216/+375
improve `_` constants in item signature handling removing the "type" from the error messages does slightly worsen the error messages for types, but figuring out whether the placeholder is for a type or a constant and correctly dealing with that seemed fairly difficult to me so I took the easy way out :sparkles: Imo the error message is still clear enough. r? `@BoxyUwU` cc `@estebank`
2022-01-20Rollup merge of #92183 - tmandry:issue-74256, r=estebankMatthias Krüger-174/+133
Point at correct argument when async fn output type lifetime disagrees with signature Fixes most of #74256. ## Problems fixed This PR fixes a couple of related problems in the error reporting code. ### Highlighting the wrong argument First, the error reporting code was looking at the desugared return type of an `async fn` to decide which parameter to highlight. For example, a function like ```rust async fn async_fn(self: &Struct, f: &u32) -> &u32 { f } ``` desugars to ```rust async fn async_fn<'a, 'b>(self: &'a Struct, f: &'b u32) -> impl Future<Output = &'a u32> + 'a + 'b { f } ``` Since `f: &'b u32` is returned but the output type is `&'a u32`, the error would occur when checking that `'a: 'b`. The reporting code would look to see if the "offending" lifetime `'b` was included in the return type, and because the code was looking at the desugared future type, it was included. So it defaulted to reporting that the source of the other lifetime `'a` (the `self` type) was the problem, when it was really the type of `f`. (Note that if it had chosen instead to look at `'a` first, it too would have been included in the output type, and it would have arbitrarily reported the error (correctly this time) on the type of `f`.) Looking at the actual future type isn't useful for this reason; it captures all input lifetimes. Using the written return type for `async fn` solves this problem and results in less confusing error messages for the user. This isn't a perfect fix, unfortunately; writing the "manually desugared" form of the above function still results in the wrong parameter being highlighted. Looking at the output type of every `impl Future` return type doesn't feel like a very principled approach, though it might work. The problem would remain for function signatures that look like the desugared one above but use different traits. There may be deeper changes required to pinpoint which part of each type is conflicting. ### Lying about await point capture causing lifetime conflicts The second issue fixed by this PR is the unnecessary complexity in `try_report_anon_anon_conflict`. It turns out that the root cause I suggested in https://github.com/rust-lang/rust/issues/76547#issuecomment-692863608 wasn't really the root cause. Adding special handling to report that a variable was captured over an await point only made the error messages less correct and pointed to a problem other than the one that actually occurred. Given the above discussion, it's easy to see why: `async fn`s capture all input lifetimes in their return type, so holding an argument across an await point should never cause a lifetime conflict! Removing the special handling simplified the code and improved the error messages (though they still aren't very good!) ## Future work * Fix error reporting on the "desugared" form of this code * Get the `suggest_adding_lifetime_params` suggestion firing on these examples * cc #42703, I think r? `@estebank`
2022-01-20Rollup merge of #91694 - euclio:stability-improvements, r=GuillaumeGomezMatthias Krüger-37/+73
rustdoc: decouple stability and const-stability This PR tweaks the stability rendering code to consider stability and const-stability separately. This fixes two issues: - Stabilities that match the enclosing item are now always omitted, even if the item has const-stability as well (#90552) - Const-stable unstable functions will now have their (const-) stability rendered. Fixes #90552.
2022-01-20Rollup merge of #91606 - joshtriplett:stabilize-print-link-args, r=pnkfelixMatthias Krüger-9/+15
Stabilize `-Z print-link-args` as `--print link-args` We have stable options for adding linker arguments; we should have a stable option to help debug linker arguments. Add documentation for the new option. In the documentation, make it clear that the *exact* format of the output is not a stable guarantee.
2022-01-20:arrow_up: rust-analyzerLaurențiu Nicola-16/+18
2022-01-19rustdoc: auto create output directory when "--output-format json"Artem Kryvokrysenko-4/+8
This PR allows rustdoc to automatically create output directory in case it does not exist (when run with `--output-format json`). This fixes rustdoc crash: ```` $ rustdoc --output-format json -Z unstable-options src/main.rs error: couldn't generate documentation: No such file or directory (os error 2) | = note: failed to create or modify "doc/main.json" error: aborting due to previous error ```` With this fix behavior of `rustdoc --output-format json` becomes consistent with `rustdoc --output-format html` (which already auto-creates output directory if it's missing)
2022-01-19Rustdoc mobile: put out-of-band on its own lineJacob Hoffman-Andrews-15/+43
Before this, the item name and the stability, source link, and "collapse all docs" would compete for room on a single line, resulting in awkward wrapping behavior on mobile. This gives a separate line for that out-of-band information. It also removes the "copy path" icon on mobile to make a little more room. Also, switch to flex-wrap: wrap, so anytime there's not enough room for `source`, it gets bumped to the next line.
2022-01-19Support --bless for pp-exact pretty printer testsDavid Tolnay-1/+13
2022-01-19Simplify error reporting code, remove await point wordingTyler Mandry-135/+100
2022-01-19NiceRegionError: Use written return type for async fnTyler Mandry-139/+133
2022-01-19src/test/rustdoc-json: Check for `struct_field`s in `variant_tuple_struct.rs`Martin Nordholts-2/+4
The presence of `struct_field`s is being checked for already in `variant_struct.rs`. We should also check for them in `variant_tuple_struct.rs`.
2022-01-19Fix scroll offset when jumping to internal idJacob Hoffman-Andrews-1/+14
2022-01-19Add tests to ensure that let_chains works with if_let_guardCaio-2/+26
2022-01-19Fix test directives; comment out calls broken on windows-gnuRichard Cobbe-5/+11
2022-01-19Rollup merge of #93005 - GuillaumeGomez:templates-in-html, r=notriddleMatthias Krüger-1/+3
Move back templates into html folder Follow-up of https://github.com/rust-lang/rust/pull/92526. r? `@notriddle`
2022-01-19Rollup merge of #92800 - ehuss:docs-fallback, r=Mark-SimulacrumMatthias Krüger-45/+68
Add manifest docs fallback. This adds a fallback so that the rustup manifest will contain the rust-docs component for all hosts. There is a mapping so that the docs that get downloaded are roughly close to the actual host. There inevitably will be things that don't match. Ideally the standard library docs would be the same for every platform (`cfg(doc)` goes a long way towards this), but there are still lots of minor differences. Closes #69525
2022-01-19Rollup merge of #92316 - petrochenkov:extmangle, r=wesleywiserMatthias Krüger-16/+55
mangling_v0: Skip extern blocks during mangling There's no need to include the dummy `Nt` into the symbol name, items in extern blocks belong to their parent modules for all purposes except for inheriting the ABI and attributes. Follow up to https://github.com/rust-lang/rust/pull/92032 (There's also a drive-by fix to the `rust-demangler` tool's tests, which don't run on CI, I initially attempted using them for testing this PR.)
2022-01-19Only suggest adding `!` to expressions that can be macro invocationEsteban Kuber-23/+68
2022-01-19Add assert that fallback targets must be available.Eric Huss-1/+4
2022-01-19Add test for block doc commentsGuillaume Gomez-0/+13
2022-01-19Correctly handle starts in block doc commentsGuillaume Gomez-2/+2
2022-01-19Move back templates into html folderGuillaume Gomez-1/+3
2022-01-19Rollup merge of #93062 - ehuss:update-books, r=ehussMatthias Krüger-0/+0
Update books ## nomicon 1 commits in c05c452b36358821bf4122f9c418674edd1d713d..66d097d3d80e8f88c288c6879c7c2b909ecf8ad4 2021-12-13 15:23:48 +0900 to 2022-01-05 05:45:21 +0900 - Fix typo / type error in FFI code example (rust-lang/nomicon#327) ## reference 8 commits in f8ba2f12df60ee19b96de24ae5b73af3de8a446b..4dee6eb63d728ffb9e7a2ed443e9ada9275c69d2 2022-01-03 11:02:08 -0800 to 2022-01-18 09:26:33 -0800 - (minor) Remove Expression Path sub-types splits in Pattern specs (rust-lang/reference#1138) - Document destructuring assignment (rust-lang/reference#1116) - Document the 2021 edition changes to macros-by-example `pat` metavariables (rust-lang/reference#1135) - Improve the documentation of macros-by-example metavariable names (rust-lang/reference#1130) - trait-bounds.md: add pronoun 'that' (rust-lang/reference#1131) - Say that macros-by-example `ident` metavariables can match raw identifiers (rust-lang/reference#1133) - State in the UAX31 profile description that a lone `_` is not an identifier (rust-lang/reference#1129) - Document syntax reserved in Rust 2021 (rust-lang/reference#1128) ## book 17 commits in d3740fb7aad0ea4a80ae20f64dee3a8cfc0c5c3c..f17df27fc14696912c48b8b7a7a8fa49e648088d 2022-01-03 21:46:04 -0500 to 2022-01-18 17:46:28 -0500 - Add a notice to the top of all nostarch snapshots - Fix quotes - Grammar (minor): 'or' → 'and' for enum variants - Propagate edits of chapter 8 to src - Replies to nostarch edits - more edits - ch8 from nostarch - Fix grammar and line wrapping - Merge remote-tracking branch 'origin/pr/2880' - Remove wikipedia link - Merge remote-tracking branch 'origin/pr/2927' - Snapshot of ch14 for nostarch - Backport fixes to chapter 14 noticed while doing nostarch snapshot - Fix usage of find piped into xargs - Adjust some more line numbers of Cargo.toml includes - Merge branch '2909' - Merge remote-tracking branch 'parkerziegler/fix/ch14-add-one-naming' ## rustc-dev-guide 7 commits in 875464457c4104686faf667f47848aa7b0f0a744..78dd6a4684cf8d6b72275fab6d0429ea40b66338 2021-12-28 22:17:49 -0600 to 2022-01-18 14:44:26 -0300 - Reorganize and expand the testing chapters. (rust-lang/rustc-dev-guide#1281) - Add inline assembly internals (rust-lang/rustc-dev-guide#1266) - Spelling: Rename `rust` to `Rust` (rust-lang/rustc-dev-guide#1288) - Clean up section about FCPs (rust-lang/rustc-dev-guide#1287) - Address more review comments in rust-lang/rustc-dev-guide#1286. - Address review comments in rust-lang/rustc-dev-guide#1286. - Streamline "Getting Started" some more.
2022-01-19Rollup merge of #92797 - jsha:fewer-lines, r=GuillaumeGomezMatthias Krüger-22/+6
Remove horizontal lines at top of page They are not needed to separate the search bar and the title, which are visually distinct on their own. Part of #59840 Demo: https://rustdoc.crud.net/jsha/fewer-lines/std/string/struct.String.html r? `@GuillaumeGomez`
2022-01-19Rollup merge of #92783 - FabianWolff:issue-92726, r=nikomatsakisMatthias Krüger-0/+33
Annotate dead code lint with notes about ignored derived impls Fixes #92726. CC `@pmetzger,` is this what you had in mind? r? `@nikomatsakis`
2022-01-19Rollup merge of #88642 - c410-f3r:let_chains_2, r=matthewjasperMatthias Krüger-304/+463
Formally implement let chains ## Let chains My longest and hardest contribution since #64010. Thanks to `@Centril` for creating the RFC and special thanks to `@matthewjasper` for helping me since the beginning of this journey. In fact, `@matthewjasper` did much of the complicated MIR stuff so it's true to say that this feature wouldn't be possible without him. Thanks again `@matthewjasper!` With the changes proposed in this PR, it will be possible to chain let expressions along side local variable declarations or ordinary conditional expressions. In other words, do much of what the `if_chain` crate already does. ## Other considerations * `if let guard` and `let ... else` features need special care and should be handled in a following PR. * Irrefutable patterns are allowed within a let chain context * ~~Three Clippy lints were already converted to start dogfooding and help detect possible corner cases~~ cc #53667
2022-01-18Update booksEric Huss-0/+0