about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2023-10-14Special case iterator chain checks for suggestionEsteban Küber-1/+358
When encountering method call chains of `Iterator`, check for trailing `;` in the body of closures passed into `Iterator::map`, as well as calls to `<T as Clone>::clone` when `T` is a type param and `T: !Clone`. Fix #9082.
2023-10-12Auto merge of #116510 - scottmcm:no-1-simd-v2, r=compiler-errorsbors-1/+81
Copy 1-element arrays as scalars, not vectors For `[T; 1]` it's silly to copy as `<1 x T>` when we can just copy as `T`. Inspired by https://github.com/rust-lang/rust/issues/101210#issuecomment-1732470941, which pointed out that `Option<[u8; 1]>` was codegenning worse than `Option<u8>`. (I'm not sure *why* LLVM doesn't optimize out `<1 x u8>`, but might as well just not emit it in the first place in this codepath.) --- I think I bit off too much in #116479; let me try just the scalar case first. r? `@ghost`
2023-10-12Exclude apple from assembly testScott McMurray-0/+1
2023-10-12Auto merge of #116671 - matthiaskrgr:rollup-b41rw92, r=matthiaskrgrbors-309/+335
Rollup of 5 pull requests Successful merges: - #116593 (Add unstable book page for the no-jump-tables codegen option) - #116625 (`rustc_hir_pretty` cleanups) - #116642 (Handle several `#[diagnostic::on_unimplemented]` attributes correctly) - #116654 (coverage: Clarify loop-edge detection and graph traversal) - #116669 (Fix mips platform support entries.) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-12Rollup merge of #116669 - ehuss:fix-platform-table, r=nikicMatthias Krüger-4/+0
Fix mips platform support entries. The table entries for these MIPS entries were broken because they had the wrong number of columns (from #116503). Additionally, there was a conflict with #115238, which made the same change (but on different lines, so git didn't complain).
2023-10-12Rollup merge of #116654 - Zalathar:reloop-traversal, r=oli-obkMatthias Krüger-164/+130
coverage: Clarify loop-edge detection and graph traversal This is a collection of improvements to two semi-related pieces of code: - The code in `counters` that detects which graph edges don't exit a loop, and would therefore be good candidates to have their coverage computed as an expression rather than having a physical counter. - The code in `graph` that traverses the coverage BCB graph in a particular order, and tracks loops and loop edges along the way (which is relevant to the above). I was originally only planning to make the `graph` changes, but there was going to be a lot of indentation churn in `counters` anyway, and once I started looking I noticed a lot of opportunities for simplification. --- `@rustbot` label +A-code-coverage
2023-10-12Rollup merge of #116642 - weiznich:diagnostic_on_unimplemented_improvements, ↵Matthias Krüger-12/+108
r=compiler-errors Handle several `#[diagnostic::on_unimplemented]` attributes correctly This PR fixes an issues where rustc would ignore subsequent `#[diagnostic::on_unimplemented]` attributes. The [corresponding RFC](https://rust-lang.github.io/rfcs/3368-diagnostic-attribute-namespace.html) specifies that the first matching instance of each option is used. Invalid attributes are linted and otherwise ignored.
2023-10-12Rollup merge of #116625 - nnethercote:rustc_hir_pretty, r=fee1-deadMatthias Krüger-129/+78
`rustc_hir_pretty` cleanups Just some improvements I found while looking through this code. r? ``@fee1-dead``
2023-10-12Rollup merge of #116593 - tgross35:no-jump-tables-docs, r=compiler-errorsMatthias Krüger-0/+19
Add unstable book page for the no-jump-tables codegen option See tracking issue: https://github.com/rust-lang/rust/issues/116592
2023-10-12Fix mips platform support entries.Eric Huss-4/+0
2023-10-12Auto merge of #116649 - nnethercote:improve-print_tts-precursors, r=petrochenkovbors-405/+433
Token cleanups Some precursors to #114571 that are worth merging even if the main part of #114571 doesn't get merged. r? `@petrochenkov`
2023-10-12coverage: Simplify adding BCB successors to the traversal worklistsZalathar-38/+39
2023-10-12coverage: Don't store loop backedges in the traversal contextZalathar-7/+10
As long as we store the loop header BCB, we can look up its incoming loop backedges as needed.
2023-10-12coverage: Store a graph reference in the graph traversal structZalathar-17/+16
Having to keep passing in a graph reference was a holdover from when the graph was partly mutated during traversal. As of #114354 that is no longer necessary, so we can simplify the traversal code by storing a graph reference as a field in `TraverseCoverageGraphWithLoops`.
2023-10-12coverage: Use a `VecDeque` for loop traversal worklistsZalathar-31/+18
The previous code was storing the worklist in a vector, and then selectively adding items to the start or end of the vector. That's a perfect use-case for a double-ended queue. This change also reveals that the existing code was a bit confused about which end of the worklist is the front or back. For now, items are always removed from the front of the queue (instead of the back), and code that adds items to the queue has been flipped, to preserve the existing behaviour.
2023-10-12coverage: Rename `next_bcb` to just `bcb`Zalathar-9/+10
This is the only BCB that `TraverseCoverageGraphWithLoops::next` works with, so calling it `next_bcb` just makes the code less clear.
2023-10-12coverage: Simplify the detection of reloop edges to be given expressionsZalathar-82/+57
2023-10-12Auto merge of #116600 - GuillaumeGomez:repr-enums-discriminant, r=fmeasebors-10/+122
Show enum discriminant if a compatible repr is used Follow-up of #116142. It was mentioned in the [team meeting](https://rust-lang.zulipchat.com/#narrow/stream/393423-t-rustdoc.2Fmeetings/topic/meeting.2002-10-2023/near/394504024) that an enum with a `repr` should also get its discriminants displayed. Forgot to implement it in #116142... It also allowed to uncover a bug: i was not providing the correct `DefId` in case it was a type alias to `render_enum_fields`. It's also fixed in this PR. r? `@fmease`
2023-10-12Auto merge of #116628 - gurry:116293-dup-note.rs, r=petrochenkovbors-10/+4
Fix duplicate note on internal feature gates with associated issues Fixes #116293 Note sure if I should add tests because the issue occurs only for feature gates having associated issues and that set of feature gates will change unpredictably leading to an unnecessary churn in tests.
2023-10-12Auto merge of #113487 - estebank:sugg-113174, r=oli-obkbors-27/+267
Use structured suggestion for #113174 When encountering a for loop that is rejected by the borrow checker because it is being advanced within its body, provide a structured suggestion for `while let Some(pat) = iter.next()`.
2023-10-12Fix duplicate note on internal feature gateGurinder Singh-10/+4
The BuiltinInternalFeatures gate already has a struct level #[note] attribute. The additional note field in it caused a duplicate to be displayed when it was set to Some(...) which happened when the feature had an associated issue
2023-10-12Auto merge of #116506 - Wilfred:remove_tmp_var, r=workingjubileebors-2/+1
Remove unnecessary tmp variable in default_read_exact This `tmp` variable has existed since the original implementation (added in ff81920f03866674080ac63b565cc9d30f80c450), but it's not necessary (maybe non-lexical lifetimes helped?). It's common to read std source code to understand how things actually work, and this tripped me up on my first read.
2023-10-11Auto merge of #116448 - Kobzol:bootstrap-host-flags, r=onur-ozkan,petrochenkovbors-37/+57
Pass rustc shim flags using environment variable This PR implements a generalized way of passing of host flags to the `rustc` shim in bootstrap, as proposed [here](https://github.com/rust-lang/rust/pull/116278#discussion_r1346979960). I tried to implement the bootstrap side using `OsString`, but then I realized that the shim code was using `env::var` before anyway, instead of `env::var_os`, so I just settled on a `String`. The shim side is still general and uses `env::vars_os` now. I'm not sure if we actually need to do something with the `rustdoc` shim. It *seems* to me that the env. vars passed to it (`RUSTDOC_LINKER`) and (`RUSTDOC_LLD_NO_THREADS`) could just be passed to cargo directly (or rather, the commands that they invoke in the shim could be passed directly). I'm not sure why are they set by the shim. r? `@onur-ozkan` CC `@petrochenkov`
2023-10-12Rename `tt_prepend_space` as `space_between`.Nicholas Nethercote-4/+4
And reorder the arguments. I find it easier to think about this way.
2023-10-12Use `TokenStream::token_alone` in one place.Nicholas Nethercote-4/+4
2023-10-12Reorder an expression to improve readability.Nicholas Nethercote-12/+7
2023-10-12Add a comment to `tests/ui/proc-macro/issue-75930-derive-cfg.rs`.Nicholas Nethercote-386/+416
Explaining something in the output that surprised me.
2023-10-12Rename `Token::is_op` as `Token::is_punct`.Nicholas Nethercote-4/+7
For consistency with `proc_macro::Punct`.
2023-10-11Improve code documentation a bitGuillaume Gomez-2/+2
2023-10-11Add tests for enum discriminant value display with `repr`Guillaume Gomez-0/+98
2023-10-11Show enum discriminant if a compatible repr is usedGuillaume Gomez-10/+24
2023-10-11Handle several `#[diagnostic::on_unimplemented]` attributes correctlyGeorg Semmler-12/+108
This PR fixes an issues where rustc would ignore subsequent `#[diagnostic::on_unimplemented]` attributes. The [corresponding RFC](https://rust-lang.github.io/rfcs/3368-diagnostic-attribute-namespace.html) specifies that the first matching instance of each option is used. Invalid attributes are linted and otherwise ignored.
2023-10-11Auto merge of #116640 - matthiaskrgr:rollup-xt9r5ir, r=matthiaskrgrbors-108/+132
Rollup of 5 pull requests Successful merges: - #116219 (Relate alias ty with variance) - #116315 (Do not check for impossible predicates in const-prop lint.) - #116436 (Structurally normalize for closure) - #116597 (Prevent showing methods from blanket impls of not available foreign traits to show up in the search results) - #116627 (small cleanup) r? `@ghost` `@rustbot` modify labels: rollup
2023-10-11Use structured suggestion for #113174Esteban Küber-27/+267
When encountering a for loop that is rejected by the borrow checker because it is being advanced within its body, provide a structured suggestion for `while let Some(pat) = iter.next()`.
2023-10-11Rollup merge of #116627 - fee1-dead-contrib:cleanup, r=spastorinoMatthias Krüger-6/+4
small cleanup this is exactly the same as the `lower_param_bounds` function, so use that instead
2023-10-11Rollup merge of #116597 - GuillaumeGomez:foreign-blanket-impl, r=notriddleMatthias Krüger-2/+41
Prevent showing methods from blanket impls of not available foreign traits to show up in the search results Fixes https://github.com/rust-lang/rust/issues/115480. In the case that the blanket impl trait is not available in the current crate, we prevent adding its methods in the search index. Now how I found how to fix the issue: the `equivalent` method is not generated in the documentation pages but was still added to the search index. To render impls, we iterate over `cache.impls` so I took a look at how this was generated. Inside `formats/cache.rs`, we have `CacheBuilder::populate` where we push impls into `impls` but with this condition: ```rust if cx.cache.traits.contains_key(&trait_did) { ``` I re-used this condition in `CacheBuilder::fold_item` to prevent this method from being added in `cache.search_index` or `cache.orphan_impl_items`. PS: If you want to double-check if the added test works, just comment the code I added in `cache.rs` and it should fail. r? ``@notriddle``
2023-10-11Rollup merge of #116436 - ↵Matthias Krüger-7/+36
compiler-errors:structurally-normalize-for-closure, r=lcnr Structurally normalize for closure Fixes some signature deduction problems in the new trait solver (and in the case of async, an ICE). r? lcnr
2023-10-11Rollup merge of #116315 - cjgillot:cpl-clean, r=petrochenkovMatthias Krüger-50/+11
Do not check for impossible predicates in const-prop lint. The enclosing query already checks for them, and replaces the body with a single `unreachable` if they are indeed impossible.
2023-10-11Rollup merge of #116219 - compiler-errors:relate-alias-ty-with-variance, r=lcnrMatthias Krüger-43/+40
Relate alias ty with variance In the new solver, turns out that the subst-relate branch of the alias-relate predicate was relating args invariantly even for opaques, which have variance :skull:. This change is a bit more invasive, but I'd rather not special-case it [here](https://github.com/rust-lang/rust/blob/aeaa5c30e5c9041264a2e8314b68ad84c2dc3169/compiler/rustc_trait_selection/src/solve/alias_relate.rs#L171-L190) and then have it break elsewhere. I'm doing a perf run to see if the extra call to `def_kind` is that expensive, if it is, I'll reconsider. r? ``@lcnr``
2023-10-11Auto merge of #113218 - lqd:polonius-scopes, r=jackh726bors-36/+413
Compute NLL loan scopes using the polonius model For a *location-insensitive* analysis (that is, without expressiveness improvements for users yet), this PR implements loans going out of scope using reachability and liveness, rather than checking if the issuing region's values contain a given CFG point. This is equivalent to NLL scopes and computes the same data. r? `@matthewjasper` A couple of notes: - there are some assumptions about SCC representatives, placeholders, free regions, and member constraints that I believe hold, and they're documented in the code - this passes all the UI tests with `-Zpolonius=next` -- the perf is [not terrible](https://github.com/rust-lang/rust/pull/112432#issuecomment-1749685862) and there are a bunch of ways to improve it in the future. - there's a fixme left, hopefully Matthew you know a clean way to get the information it mentions.
2023-10-11Auto merge of #115937 - oli-obk:spurious_unreachable_pattern, r=Nadrierilbors-203/+115
Prevent spurious `unreachable pattern` lints But it means we'll get more `non-exhaustive` patterns fixes https://github.com/rust-lang/rust/issues/78057 r? `@Nadrieril` `@RalfJung`
2023-10-11Remember the `ErrorReported` used to silence follow up errors instead of ↵Oli Scherer-13/+15
recreating it with `delay_span_bug`
2023-10-11Avoid emitting the non_exhaustive error if other errors already occurredOli Scherer-90/+34
2023-10-11Prevent spurious `unreachable pattern` lintsOli Scherer-191/+157
Means you'll get more `non-exhaustive` patterns
2023-10-11Auto merge of #116014 - lqd:mcp510-2-electric-boogaloo, r=petrochenkovbors-64/+159
Implement `-Clink-self-contained=-linker` opt out This implements the `-Clink-self-contained` opt out necessary to switch to lld by changing rustc's defaults instead of cargo's. Components that are enabled and disabled on the CLI are recorded, for the purpose of being merged with the ones which the target spec will declare (I'll open another PR for that tomorrow, for easier review). For MCP510, we now check whether using the self-contained linker is disabled on the CLI. Right now it would only be sensible to with `-Zgcc-ld=lld` (and I'll add some checks that we don't both enable and disable a component on the CLI in a future PR), but the goal is to simplify adding the check of the target's enabled components here in the follow-up PRs. r? `@petrochenkov`
2023-10-11Auto merge of #116623 - Nadrieril:validate-range-endpoints, r=oli-obkbors-168/+318
Fix overflow checking in range patterns When a range pattern contains an overflowing literal, if we're not careful we might not notice the overflow and use the wrapped value. This makes for confusing error messages because linting against overflowing literals is only done in a later pass. So when a range is invalid we check for overflows to provide a better error. This check didn't use to handle negative types; this PR fixes that. First commit adds tests, second cleans up without changing behavior, third does the fix. EDIT: while I was at it, I fixed a small annoyance about the span of the overflow lint on negated literals. Fixes https://github.com/rust-lang/rust/issues/94239
2023-10-11Handle private dep at the same level as masked cratesGuillaume Gomez-15/+10
2023-10-11Add regression test for #115480Guillaume Gomez-0/+32
2023-10-11Prevent showing methods from blanket impls of not available foreign traits ↵Guillaume Gomez-1/+13
to show up in the search results
2023-10-11small cleanupDeadbeef-6/+4