about summary refs log tree commit diff
AgeCommit message (Collapse)AuthorLines
2021-11-07Auto merge of #90635 - matthiaskrgr:rustdoc_compl, r=GuillaumeGomezbors-5/+4
rustdoc: clippy::complexity fixes
2021-11-06Auto merge of #90661 - matthiaskrgr:rollup-1umbdlx, r=matthiaskrgrbors-93/+304
Rollup of 6 pull requests Successful merges: - #90487 (Add a chapter on reading Rustdoc output) - #90508 (Apply adjustments for field expression even if inaccessible) - #90627 (Suggest dereference of `Box` when inner type is expected) - #90642 (use matches!() macro in more places) - #90646 (type error go brrrrrrrr) - #90649 (Run reveal_all on MIR when inlining is activated.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-11-06Rollup merge of #90649 - cjgillot:reveal-all-2, r=lcnrMatthias Krüger-2/+4
Run reveal_all on MIR when inlining is activated. Fix logic error in https://github.com/rust-lang/rust/pull/85254 which prevented the pass from running when needed. Fixes https://github.com/rust-lang/rust/issues/78442 r? ``@lcnr``
2021-11-06Rollup merge of #90646 - BoxyUwU:funky_ice, r=estebankMatthias Krüger-2/+51
type error go brrrrrrrr Fixes #90444 when we relate something like: `fn(fn((), (), u32))` with `fn(fn((), (), ()))` we relate the inner fn ptrs: `fn((), (), u32)` with `fn((), (), ())` yielding a `TypeError::ArgumentSorts(_, 2)` which we then use as the `TypeError` for the `fn(fn(..))` which later causes the ICE as the `2` does not correspond to any input or output types in `fn(_)` r? `@estebank`
2021-11-06Rollup merge of #90642 - matthiaskrgr:clippy_matches, r=cjgillotMatthias Krüger-86/+49
use matches!() macro in more places
2021-11-06Rollup merge of #90627 - camelid:suggest-box-deref, r=davidtwcoMatthias Krüger-0/+58
Suggest dereference of `Box` when inner type is expected For example: enum Ty { Unit, List(Box<Ty>), } fn foo(x: Ty) -> Ty { match x { Ty::Unit => Ty::Unit, Ty::List(elem) => foo(elem), } } Before, the only suggestion was to rewrap `inner` with `Ty::Wrapper`, which is unhelpful and confusing: error[E0308]: mismatched types --> src/test/ui/suggestions/boxed-variant-field.rs:9:31 | 9 | Ty::List(elem) => foo(elem), | ^^^^ | | | expected enum `Ty`, found struct `Box` | help: try using a variant of the expected enum: `Ty::List(elem)` | = note: expected enum `Ty` found struct `Box<Ty>` Now, rustc will first suggest dereferencing the `Box`, which is most likely what the user intended: error[E0308]: mismatched types --> src/test/ui/suggestions/boxed-variant-field.rs:9:31 | 9 | Ty::List(elem) => foo(elem), | ^^^^ expected enum `Ty`, found struct `Box` | = note: expected enum `Ty` found struct `Box<Ty>` help: try dereferencing the `Box` | 9 | Ty::List(elem) => foo(*elem), | + help: try using a variant of the expected enum | 9 | Ty::List(elem) => foo(Ty::List(elem)), | ~~~~~~~~~~~~~~ r? ``@davidtwco``
2021-11-06Rollup merge of #90508 - nbdd0121:issue-90483, r=davidtwcoMatthias Krüger-3/+34
Apply adjustments for field expression even if inaccessible The adjustments are used later by ExprUseVisitor to build Place projections and without adjustments it can produce invalid result. Fix #90483 ``@rustbot`` label: T-compiler
2021-11-06Rollup merge of #90487 - NoraCodes:nora/how-to-read-rustdoc, r=jyn514Matthias Krüger-0/+108
Add a chapter on reading Rustdoc output Includes documentation for: - general page structure - navigation - searching - themes - deep-linking Doesn't include docs on the settings page. Per https://github.com/rust-lang/rust/issues/90309
2021-11-06Auto merge of #90655 - the8472:drain-dot-dot, r=jyn514bors-6/+6
Replace some uses of vec.drain(..) with vec.into_iter() IntoIter should optimize better than Drain
2021-11-06Suggest dereference of `Box` when inner type is expectedNoah Lev-0/+58
For example: enum Ty { Unit, List(Box<Ty>), } fn foo(x: Ty) -> Ty { match x { Ty::Unit => Ty::Unit, Ty::List(elem) => foo(elem), } } Before, the only suggestion was to rewrap `elem` with `Ty::List`, which is unhelpful and confusing: error[E0308]: mismatched types --> src/test/ui/suggestions/boxed-variant-field.rs:9:31 | 9 | Ty::List(elem) => foo(elem), | ^^^^ | | | expected enum `Ty`, found struct `Box` | help: try using a variant of the expected enum: `Ty::List(elem)` | = note: expected enum `Ty` found struct `Box<Ty>` Now, rustc will first suggest dereferencing the `Box`, which is most likely what the user intended: error[E0308]: mismatched types --> src/test/ui/suggestions/boxed-variant-field.rs:9:31 | 9 | Ty::List(elem) => foo(elem), | ^^^^ expected enum `Ty`, found struct `Box` | = note: expected enum `Ty` found struct `Box<Ty>` help: try dereferencing the `Box` | 9 | Ty::List(elem) => foo(*elem), | + help: try using a variant of the expected enum | 9 | Ty::List(elem) => foo(Ty::List(elem)), | ~~~~~~~~~~~~~~
2021-11-06Replace some uses of vec.drain(..) with vec.into_iter()The8472-6/+6
IntoIter should optimize better than Drain
2021-11-06Auto merge of #90559 - rusticstuff:optimize-bidi-detection, r=davidtwcobors-16/+46
Optimize bidi character detection. Should fix most of the performance regression of the bidi character detection (#90514), to be confirmed with a perf run.
2021-11-06use matches!() macro in more placesMatthias Krüger-86/+49
2021-11-06Run reveal_all on MIR more often.Camille GILLOT-2/+4
2021-11-06Auto merge of #90641 - matthiaskrgr:mut, r=cjgillotbors-1/+1
pointee_info_at() does not need mutable access
2021-11-06type error go brrrrrrrrEllen-2/+51
2021-11-06Auto merge of #90617 - tmiasko:time-trace-threads, r=wesleywiserbors-56/+128
Initialize LLVM time trace profiler on each code generation thread In https://reviews.llvm.org/D71059 LLVM 11, the time trace profiler was extended to support multiple threads. `timeTraceProfilerInitialize` creates a thread local profiler instance. When a thread finishes `timeTraceProfilerFinishThread` moves a thread local instance into a global collection of instances. Finally when all codegen work is complete `timeTraceProfilerWrite` writes data from the current thread local instance and the instances in global collection of instances. Previously, the profiler was intialized on a single thread only. Since this thread performs no code generation on its own, the resulting profile was empty. Update LLVM codegen to initialize & finish time trace profiler on each code generation thread. cc `@tmandry` r? `@wesleywiser`
2021-11-06Auto merge of #90297 - dtolnay:dotzero, r=petrochenkovbors-2/+20
Append .0 to unsuffixed float if it would otherwise become int token Previously the unsuffixed f32/f64 constructors of `proc_macro::Literal` would create literal tokens that are definitely not a float: ```rust Literal::f32_unsuffixed(10.0) // 10 Literal::f32_suffixed(10.0) // 10f32 Literal::f64_unsuffixed(10.0) // 10 Literal::f64_suffixed(10.0) // 10f64 ``` Notice that the `10` are actually integer tokens if you were to reparse them, not float tokens. This diff updates `Literal::f32_unsuffixed` and `Literal::f64_unsuffixed` to produce tokens that unambiguously parse as a float. This matches longstanding behavior of the proc-macro2 crate's implementation of these APIs dating back at least 3.5 years, so it's likely an unobjectionable behavior. ```rust Literal::f32_unsuffixed(10.0) // 10.0 Literal::f32_suffixed(10.0) // 10f32 Literal::f64_unsuffixed(10.0) // 10.0 Literal::f64_suffixed(10.0) // 10f64 ``` Fixes https://github.com/dtolnay/syn/issues/1085.
2021-11-06Auto merge of #89970 - jackh726:gats_diagnostics, r=nikomatsakisbors-61/+694
Implementation of GATs outlives lint See #87479 for background. Closes #87479 The basic premise of this lint/error is to require the user to write where clauses on a GAT when those bounds can be implied or proven from any function on the trait returning that GAT. ## Intuitive Explanation (Attempt) ## Let's take this trait definition as an example: ```rust trait Iterable { type Item<'x>; fn iter<'a>(&'a self) -> Self::Item<'a>; } ``` Let's focus on the `iter` function. The first thing to realize is that we know that `Self: 'a` because of `&'a self`. If an impl wants `Self::Item` to contain any data with references, then those references must be derived from `&'a self`. Thus, they must live only as long as `'a`. Furthermore, because of the `Self: 'a` implied bound, they must live only as long as `Self`. Since it's `'a` is used in place of `'x`, it is reasonable to assume that any value of `Self::Item<'x>`, and thus `'x`, will only be able to live as long as `Self`. Therefore, we require this bound on `Item` in the trait. As another example: ```rust trait Deserializer<T> { type Out<'x>; fn deserialize<'a>(&self, input: &'a T) -> Self::Out<'a>; } ``` The intuition is similar here, except rather than a `Self: 'a` implied bound, we have a `T: 'a` implied bound. Thus, the data on `Self::Out<'a>` is derived from `&'a T`, and thus it is reasonable to expect that the lifetime `'x` will always be less than `T`. ## Implementation Algorithm ## * Given a GAT `<P0 as Trait<P1..Pi>>::G<Pi...Pn>` declared as `trait T<A1..Ai> for A0 { type G<Ai...An>; }` used in return type of one associated function `F` * Given env `E` (including implied bounds) for `F` * For each lifetime parameter `'a` in `P0...Pn`: * For each other type parameter `Pi != 'a` in `P0...Pn`: // FIXME: this include of lifetime parameters too * If `E => (P: 'a)`: * Require where clause `Ai: 'a` ## Follow-up questions ## * What should we do when we don't pass params exactly? For this example: ```rust trait Des { type Out<'x, D>; fn des<'z, T>(&self, data: &'z Wrap<T>) -> Self::Out<'z, Wrap<T>>; } ``` Should we be requiring a `D: 'x` clause? We pass `Wrap<T>` as `D` and `'z` as `'x`, and should be able to prove that `Wrap<T>: 'z`. r? `@nikomatsakis`
2021-11-05Review commentsjackh726-22/+51
2021-11-06Auto merge of #88441 - jackh726:closure_norm, r=nikomatsakisbors-87/+263
Normalize obligations for closure confirmation Based on #90017 Fixes #74261 Fixes #71955 Fixes #88459 r? `@nikomatsakis`
2021-11-06pointee_info_at() does not need mutable accessMatthias Krüger-1/+1
2021-11-05Auto merge of #90631 - matthiaskrgr:rollup-a5tzjh3, r=matthiaskrgrbors-196/+384
Rollup of 5 pull requests Successful merges: - #89942 (Reorder `widening_impl`s to make the doc clearer) - #90569 (Fix tests using `only-i686` to use the correct `only-x86` directive) - #90597 (Warn for variables that are no longer captured) - #90623 (Remove more checks for LLVM < 12) - #90626 (Properly register text_direction_codepoint_in_comment lint.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-11-05rustdoc: clippy::complexity fixesMatthias Krüger-5/+4
2021-11-05Rollup merge of #90626 - rusticstuff:be-more-accepting, r=jyn514Matthias Krüger-0/+10
Properly register text_direction_codepoint_in_comment lint. This makes it known to the compiler so it can be configured like with `#![allow(text_direction_codepoint_in_comment)]`. Fixes #90614.
2021-11-05Rollup merge of #90623 - cuviper:llvm-12, r=nikicMatthias Krüger-27/+24
Remove more checks for LLVM < 12 We already updated the minimum to 12 in #90175, but we missed a few `get_version()` checks.
2021-11-05Rollup merge of #90597 - nikomatsakis:issue-90465, r=wesleywiserMatthias Krüger-147/+328
Warn for variables that are no longer captured r? `@wesleywiser` cc `@rust-lang/wg-rfc-2229` Fixes #90465
2021-11-05Rollup merge of #90569 - wesleywiser:fix_only_i686_tests, r=Mark-SimulacrumMatthias Krüger-4/+4
Fix tests using `only-i686` to use the correct `only-x86` directive We translate `i686` to `x86` which means tests marked as `only-i686` never ran. Update those tests to use `only-x86`. We parse the `only-` architecture directive here https://github.com/rust-lang/rust/blob/27143a9094b55a00d5f440b05b0cb4233b300d33/src/tools/compiletest/src/util.rs#L160-L168 and we translate `i686` to `x86` here https://github.com/rust-lang/rust/blob/27143a9094b55a00d5f440b05b0cb4233b300d33/src/tools/compiletest/src/util.rs#L56
2021-11-05Rollup merge of #89942 - JohnTitor:reorder-widening_impl, r=dtolnayMatthias Krüger-18/+18
Reorder `widening_impl`s to make the doc clearer Fixes #88736 This moves `{widening,carrying}_mul`s to the bottom to place consts on the top.
2021-11-05Add a chapter on reading Rustdoc outputLeonora Tindall-0/+108
Includes documentation for: - general page structure - navigation - searching - themes - deep-linking Doesn't include docs on the settings page.
2021-11-05Update LLVM comments around NoAliasMutRefJosh Stone-5/+8
2021-11-05Properly register text_direction_codepoint_in_comment lint.Hans Kratz-0/+10
2021-11-05Add test to confirm fnn_unsuffixed does not emit exponent notationDavid Tolnay-0/+6
2021-11-05Auto merge of #90583 - willcrichton:example-analyzer, r=jyn514bors-13/+142
Fix ICE when rustdoc is scraping examples inside of a proc macro This PR provides a clearer semantics for how --scrape-examples interacts with macros. If an expression's span AND it's enclosing item's span both are not `from_expansion`, then the example will be scraped. The added test case `rustdoc-scrape-examples-macros` shows a variety of situations. * A macro-rules macro that takes a function call as input: good * A macro-rules macro that generates a function call as output: bad * A proc-macro that generates a function call as output: bad * An attribute macro that generates a function call as output: bad * An attribute macro that takes a function call as input: good, if the proc macro is designed to propagate the input spans I ran this updated rustdoc on pyo3 and confirmed that it successfully scrapes examples from inside a proc macro, eg <img width="1013" alt="Screen Shot 2021-11-04 at 1 11 28 PM" src="https://user-images.githubusercontent.com/663326/140412691-81a3bb6b-a448-4a1b-a293-f7a795553634.png"> (cc `@mejrs)` Additionally, this PR fixes an ordering bug in the highlighting logic. Fixes https://github.com/rust-lang/rust/issues/90567. r? `@jyn514`
2021-11-05Update the documented default of -Zmutable-noaliasJosh Stone-1/+1
2021-11-05Reorder `widening_impl`s to make the doc clearerYuki Okushi-18/+18
2021-11-05Move outline-atomics to aarch64-linux target definitionsJosh Stone-6/+9
2021-11-05Remove some minor checks for LLVM < 12Josh Stone-15/+6
2021-11-05Initialize LLVM time trace profiler on each code generation threadTomasz Miąsko-56/+128
In https://reviews.llvm.org/D71059 LLVM 11, the time trace profiler was extended to support multiple threads. `timeTraceProfilerInitialize` creates a thread local profiler instance. When a thread finishes `timeTraceProfilerFinishThread` moves a thread local instance into a global collection of instances. Finally when all codegen work is complete `timeTraceProfilerWrite` writes data from the current thread local instance and the instances in global collection of instances. Previously, the profiler was intialized on a single thread only. Since this thread performs no code generation on its own, the resulting profile was empty. Update LLVM codegen to initialize & finish time trace profiler on each code generation thread.
2021-11-05apply suggestions from code reviewNiko Matsakis-61/+63
2021-11-05Fix rustdoc-scrape-examples-macros test not being cross-platformWill Crichton-1/+2
2021-11-05Auto merge of #90616 - mathstuf:error_codes-comment-uniformity, r=GuillaumeGomezbors-20/+19
error_codes: uniformly comment error codes
2021-11-05error_codes: uniformly comment error codesBen Boeckel-20/+19
2021-11-05Auto merge of #90604 - mbartlett21:iterator-reexports, r=kennytmbors-1/+6
Re-export some iterators from `core` in `std` These iterators seem to have been forgotten to be re-exported from `std` (through `alloc`) These are stable: `core::slice::{SplitInclusive, SplitInclusiveMut}` This one is still unstable: `core::slice::EscapeAscii` (cc #77174)
2021-11-05Auto merge of #90577 - matthiaskrgr:clippy_perf_nov, r=petrochenkovbors-13/+13
clippy::perf fixes
2021-11-05Fix `str::SplitInclusive` stabilisation datembartlett21-1/+1
2021-11-05Add feature to `alloc` so we can re-export.mbartlett21-0/+1
2021-11-05Re-export `core::slice::EscapeAscii`mbartlett21-0/+2
2021-11-05Re-export `core::slice::SplitInclusive[Mut]`mbartlett21-0/+2
2021-11-05Auto merge of #90598 - JohnTitor:rollup-kz1qioz, r=JohnTitorbors-96/+182
Rollup of 9 pull requests Successful merges: - #90507 (Suggest `extern crate alloc` when using undeclared module `alloc`) - #90530 (Simplify js tester a bit) - #90533 (Add note about x86 instruction prefixes in asm! to unstable book) - #90537 (Update aarch64 `target_feature` list for LLVM 12.) - #90544 (Demote metadata load warning to "info".) - #90554 (Clean up some `-Z unstable-options` in tests.) - #90556 (Add more text and examples to `carrying_{add|mul}`) - #90563 (rustbot allow labels) - #90571 (Fix missing bottom border for headings in sidebar) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup