1. 17 9月, 2021 40 次提交
    • B
      Auto merge of #89047 - GuillaumeGomez:rollup-29gmr02, r=GuillaumeGomez · 207d9558
      bors 提交于
      Rollup of 10 pull requests
      
      Successful merges:
      
       - #86422 (Emit clearer diagnostics for parens around `for` loop heads)
       - #87460 (Point to closure when emitting 'cannot move out' for captured variable)
       - #87566 (Recover invalid assoc type bounds using `==`)
       - #88666 (Improve build command for compiler docs)
       - #88899 (Do not issue E0071 if a type error has already been reported)
       - #88949 (Fix handling of `hir::GenericArg::Infer` in `wrong_number_of_generic_args.rs`)
       - #88953 (Add chown functions to std::os::unix::fs to change the owner and group of files)
       - #88954 (Allow `panic!("{}", computed_str)` in const fn.)
       - #88964 (Add rustdoc version into the help popup)
       - #89012 (Suggest removing `#![feature]` for library features that have been stabilized)
      
      Failed merges:
      
      r? `@ghost`
      `@rustbot` modify labels: rollup
      207d9558
    • G
      Rollup merge of #89012 - vishadGoyal:issue-88802-fix, r=jyn514 · 101a88f9
      Guillaume Gomez 提交于
      Suggest removing `#![feature]` for library features that have been stabilized
      
      Issue: https://github.com/rust-lang/rust/issues/88802
      Delayed the check if #![feature] has been used to enable lib features in a non-nightly build to occur after TyCtxt has been constructed.
      101a88f9
    • G
      Rollup merge of #88964 - GuillaumeGomez:version-help, r=Nemo157 · 833358b9
      Guillaume Gomez 提交于
      Add rustdoc version into the help popup
      
      After a discussion with a rustdoc user about a specific behaviour, we realized we were not talking about the same version. To add on top of it, it was actually not that simple to find out the version since it was hosted documentation.
      
      So to simplify things, I added the version into the help popup:
      
      ![Screenshot from 2021-09-16 10-45-52](https://user-images.githubusercontent.com/3050060/133581128-b93b460a-e1cb-4a31-9f2f-97c7a916cfcc.png)
      
      Does the version format looks or would you prefer that I add more information? We can also add the commit hash, commit date, host and release.
      
      cc `@rust-lang/rustdoc`
      r? `@jyn514`
      833358b9
    • G
      Rollup merge of #88954 - nbdd0121:panic3, r=oli-obk · eb62779f
      Guillaume Gomez 提交于
      Allow `panic!("{}", computed_str)` in const fn.
      
      Special-case `panic!("{}", arg)` and translate it to `panic_display(&arg)`. `panic_display` will behave like `panic_any` in cosnt eval and behave like `panic!(format_args!("{}", arg))` in runtime.
      
      This should bring Rust 2015 and 2021 to feature parity in terms of `const_panic`; and hopefully would unblock the stabilisation of #51999.
      
      `@rustbot` modify labels: +T-compiler +T-libs +A-const-eval +A-const-fn
      
      r? `@oli-obk`
      eb62779f
    • G
      Rollup merge of #88953 - joshtriplett:chown, r=dtolnay · 723d2793
      Guillaume Gomez 提交于
      Add chown functions to std::os::unix::fs to change the owner and group of files
      
      This is a straightforward wrapper that uses the existing helpers for C
      string handling and errno handling.
      
      Having this available is convenient for UNIX utility programs written in
      Rust, and avoids having to call unsafe functions like `libc::chown`
      directly and handle errors manually, in a program that may otherwise be
      entirely safe code.
      
      In addition, these functions provide a more Rustic interface by
      accepting appropriate traits and using `None` rather than `-1`.
      723d2793
    • G
      Rollup merge of #88949 - FabianWolff:issue-87563, r=estebank · 6f5c0984
      Guillaume Gomez 提交于
      Fix handling of `hir::GenericArg::Infer` in `wrong_number_of_generic_args.rs`
      
      Fixes #87563. More precisely, I have fixed the "index out of bounds" error, which is what #87563 is about. The example given there still ICEs due to running into this `todo!()`, but I'd say that this is a separate issue:
      https://github.com/rust-lang/rust/blob/c3c0f80d6081092faff801542dd82f0e2420152b/compiler/rustc_typeck/src/astconv/mod.rs#L460-L463
      6f5c0984
    • G
      Rollup merge of #88899 - FabianWolff:issue-88844, r=matthewjasper · 307f2ddf
      Guillaume Gomez 提交于
      Do not issue E0071 if a type error has already been reported
      
      Fixes #88844. A suggested fix is already included in the error message for E0412, so with my changes, E0071 is simply not emitted anymore if the type in question is a "type error". This makes sense, I think, because we cannot confidently state that something is "not a struct" if we couldn't resolve it properly; and it's unnecessary to pollute the output with this additional error message, as it is a direct consequence of the former error.
      
      I have also addressed the issue mentioned in https://github.com/rust-lang/rust/issues/88844#issuecomment-917324856 by changing the fixed example in the documentation to more closely match the erroneous code example.
      307f2ddf
    • G
      Rollup merge of #88666 - GuillaumeGomez:compiler-docs, r=Mark-Simulacrum · 765f1533
      Guillaume Gomez 提交于
      Improve build command for compiler docs
      
      It was rather complicated to document rustc crates. With this, you can directly run:
      
      ```console
      x.py doc compiler
      x.py doc compiler/rustc_hir_pretty
      ```
      
      The second commit adds the handling of the `--open` flag.
      
      r? `@Mark-Simulacrum`
      765f1533
    • G
      Rollup merge of #87566 - JohnTitor:find-eqeq-on-assoc-type-bounds, r=estebank · 1b789671
      Guillaume Gomez 提交于
      Recover invalid assoc type bounds using `==`
      
      Fix #87493
      r? `@estebank`
      1b789671
    • G
      Rollup merge of #87460 - FabianWolff:issue-87456, r=Aaron1011 · aed7f000
      Guillaume Gomez 提交于
      Point to closure when emitting 'cannot move out' for captured variable
      
      Attempts to fix #87456. The error message now points to the capturing closure, but I was not able to explain _why_ the closure implements `Fn` or `FnMut` (`TypeckResults::closure_kind_origins` did not contain anything for the closure in question).
      
      cc `@Aaron1011`
      aed7f000
    • G
      Rollup merge of #86422 - JohnTitor:clearer-parens-err-for-loop, r=estebank · b6d0ccab
      Guillaume Gomez 提交于
      Emit clearer diagnostics for parens around `for` loop heads
      
      Fixes #63113
      r? `@estebank`
      b6d0ccab
    • G
      Add rustdoc version into the help popup · cd3f4da2
      Guillaume Gomez 提交于
      cd3f4da2
    • G
      57ee7a63
    • G
      bc49c3b6
    • B
      Auto merge of #88945 - Aaron1011:no-projection-completion, r=wesleywiser,jackh726 · e0c38af2
      bors 提交于
      Remove concept of 'completion' from the projection cache
      
      Fixes #88910
      
      When we initially store a `NormalizedTy` in the projection cache,
      we discard all obligations that we can (while ensuring that we
      don't cause any issues with incremental compilation).
      
      Marking a projection cache entry as 'completed' discards all
      obligations associated with it. This can only cause problems,
      since any obligations stored in the cache are there for a reason
      (e.g. they evaluate to `EvaluatedToOkModuloRegions`).
      
      This commit removes `complete` and `complete_normalized` entirely.
      e0c38af2
    • B
      Auto merge of #89037 - JohnTitor:rollup-rd9btbs, r=JohnTitor · 1c03f0d0
      bors 提交于
      Rollup of 10 pull requests
      
      Successful merges:
      
       - #86382 (Make diagnostics clearer for `?` operators)
       - #87529 (Fix ICE in `improper_ctypes_definitions` lint with all-ZST transparent types)
       - #88339 (Add TcpListener::into_incoming and IntoIncoming)
       - #88735 (Don't lint about missing code examples in derived traits)
       - #88751 (Couple of changes to FileSearch and SearchPath)
       - #88883 (Move some tests to more reasonable directories - 7)
       - #88887 (Const Deref)
       - #88911 (Improve error message for type mismatch in generator arguments)
       - #89014 (PassWrapper: handle separate Module*SanitizerPass)
       - #89033 (Set the library path in sysroot-crates-are-unstable)
      
      Failed merges:
      
      r? `@ghost`
      `@rustbot` modify labels: rollup
      1c03f0d0
    • Y
      Apply review comments · ee99bb39
      Yuki Okushi 提交于
      ee99bb39
    • Y
      Rollup merge of #89033 - cuviper:sysroot-lib-path, r=Mark-Simulacrum · 4d5bcbe9
      Yuki Okushi 提交于
      Set the library path in sysroot-crates-are-unstable
      
      Most of the `run-make-fulldeps` tests use a make-driven rustc command
      that includes `HOST_RPATH_DIR` in the library path, but this particular
      test runs from python instead. When the toolchain is built without
      `rpath` enabled, we need that library path in the environment so it can
      find its own libraries.
      4d5bcbe9
    • Y
      Rollup merge of #89014 - durin42:llvm-14-module-pass-manager, r=nikic · 3cff47b6
      Yuki Okushi 提交于
      PassWrapper: handle separate Module*SanitizerPass
      
      Change ab41eef9aca3 in LLVM split MemorySanitizerPass into
      MemorySanitizerPass for functions and ModuleMemorySanitizerPass for
      modules. There's a related change for ThreadSanitizerPass, and in here
      since we're using a ModulePassManager I only add the module flavor of
      the pass on LLVM 14.
      
      r? `@nikic` cc `@nagisa`
      3cff47b6
    • Y
      Rollup merge of #88911 - FabianWolff:issue-88653, r=petrochenkov · c97ff098
      Yuki Okushi 提交于
      Improve error message for type mismatch in generator arguments
      
      Fixes #88653. The code example given there is invalid because the `Generator` trait (unlike the `Fn` traits) does not take the generator arguments in tupled-up form (because there can only be one argument, from my understanding). Hence, the type error in the example in #88653 is correct, because the given generator takes a `bool` argument, whereas the function's return type talks about a generator with a `(bool,)` argument.
      
      The error message is both confusing and wrong, though: It is wrong because it displays the wrong "expected signature", and it is confusing because both the "expected" and "found" notes point at the same span. With my changes, I get the following, more helpful output:
      ```
      error[E0631]: type mismatch in generator arguments
       --> test.rs:5:22
        |
      5 | fn foo(bar: bool) -> impl Generator<(bool,)> {
        |                      ^^^^^^^^^^^^^^^^^^^^^^^ expected signature of `fn((bool,)) -> _`
      6 |     |bar| {
        |     ----- found signature of `fn(bool) -> _`
      ```
      c97ff098
    • Y
      Rollup merge of #88887 - fee1-dead:const-deref, r=oli-obk · 5d14396e
      Yuki Okushi 提交于
      Const Deref
      
      Implements `const Deref`/`const DerefMut` for `&mut T`, `&T`, `Cow<'_, B>` and `ManuallyDrop<T>`
      5d14396e
    • Y
      Rollup merge of #88883 - c410-f3r:tests, r=petrochenkov · 5e910373
      Yuki Okushi 提交于
      Move some tests to more reasonable directories - 7
      
      cc #73494
      r? ``@petrochenkov``
      5e910373
    • Y
      Rollup merge of #88751 - bjorn3:move_filesearch, r=oli-obk · a84d39c7
      Yuki Okushi 提交于
      Couple of changes to FileSearch and SearchPath
      
      * Turn a couple of regular comments into doc comments
      * Move `get_tools_search_paths` from `FileSearch` to `Session`
      * Use Lrc instead of Option to avoid duplication of a `SearchPath`
      a84d39c7
    • Y
      Rollup merge of #88735 - hnj2:patch-1, r=GuillaumeGomez · 758c7bcc
      Yuki Okushi 提交于
      Don't lint about missing code examples in derived traits
      
      When the `missing_doc_code_examples` lint is performed it also requires that derived Trait implementations have a code example for each member etc., which causes undesirable behavior.
      
      # Examples
      
      With `missing_doc_code_examples` enable we are not able to use the `Clone` derive macro due to the generated code not being documented:
      ```rust
      #[deny(rustdoc::missing_doc_code_examples)]
      
      /// docs
      /// ```
      /// let s = SomeStruct;
      /// ```
      #[derive(Clone)]
      pub struct SomeStruct;
      ```
      yields:
      ```
       Documenting testt v0.1.0 (<redacted>)
      error: missing code example in this documentation
       --> src/lib.rs:7:10
        |
      7 | #[derive(Clone)]
        |          ^^^^^
        |
      note: the lint level is defined here
       --> src/lib.rs:1:8
        |
      1 | #[deny(rustdoc::missing_doc_code_examples)]
        |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      
      error: missing code example in this documentation
       --> src/lib.rs:7:10
        |
      7 | #[derive(Clone)]
        |          ^^^^^
      
      error: could not document `testt`
      
      Caused by:
        process didn't exit successfully: `rustdoc ...
      ```
      
      closes #81775
      758c7bcc
    • Y
      Rollup merge of #88339 - piegamesde:master, r=joshtriplett · 0f06e366
      Yuki Okushi 提交于
      Add TcpListener::into_incoming and IntoIncoming
      
      The `incoming` method is really useful, however for some use cases the borrow
      this introduces is needlessly restricting. Thus, an owned variant is added.
      
      r? ``@joshtriplett``
      0f06e366
    • Y
      Rollup merge of #87529 - FabianWolff:issue-87496, r=nikomatsakis · 81dc2169
      Yuki Okushi 提交于
      Fix ICE in `improper_ctypes_definitions` lint with all-ZST transparent types
      
      Fixes #87496. There is also another function in the same file that looks fishy, but I haven't been able to produce an ICE there, and in any case, it's not related to #87496:
      https://github.com/rust-lang/rust/blob/fd853c00e255559255885aadff9e93a1760c8728/compiler/rustc_lint/src/types.rs#L720-L734
      
      r? ```@JohnTitor```
      81dc2169
    • Y
      Rollup merge of #86382 - JohnTitor:try-desugar, r=estebank · f4f7704e
      Yuki Okushi 提交于
      Make diagnostics clearer for `?` operators
      
      Re-submission of #75029, fixes #71309
      This also revives the `content` methods removed by #83185.
      r? `@estebank`
      f4f7704e
    • Y
      Recover invalid assoc type bounds using `==` · 9342be55
      Yuki Okushi 提交于
      9342be55
    • Y
      Use `multipart_suggestion` · e9bf73cb
      Yuki Okushi 提交于
      e9bf73cb
    • Y
      58765d61
    • Y
      Make diagnostics clearer for `?` operators · 378300a6
      Yuki Okushi 提交于
      378300a6
    • B
      Auto merge of #88934 - tmiasko:trace-log, r=davidtwco · 38e57642
      bors 提交于
      Avoid unnecessary formatting when trace log level is disabled
      38e57642
    • B
      Auto merge of #88832 - pcwalton:debug-unit-variant-fast-path, r=oli-obk · 78a46eff
      bors 提交于
      Introduce a fast path that avoids the `debug_tuple` abstraction when deriving Debug for unit-like enum variants.
      
      The intent here is to allow LLVM to remove the switch entirely in favor of an
      indexed load from a table of constant strings, which is likely what the
      programmer would write in C. Unfortunately, LLVM currently doesn't perform this
      optimization due to a bug, but there is [a
      patch](https://reviews.llvm.org/D109565) that fixes this issue. I've verified
      that, with that patch applied on top of this commit, Debug for unit-like tuple
      variants becomes a load, reducing the O(n) code bloat to O(1).
      
      Note that inlining `DebugTuple::finish()` wasn't enough to allow LLVM to
      optimize the code properly; I had to avoid the abstraction entirely. Not using
      the abstraction is likely better for compile time anyway.
      
      Part of #88793.
      
      r? `@oli-obk`
      78a46eff
    • J
      Set the library path in sysroot-crates-are-unstable · 67edf944
      Josh Stone 提交于
      Most of the `run-make-fulldeps` tests use a make-driven rustc command
      that includes `HOST_RPATH_DIR` in the library path, but this particular
      test runs from python instead. When the toolchain is built without
      `rpath` enabled, we need that library path in the environment so it can
      find its own libraries.
      67edf944
    • H
      Don't lint about missing code examples in derived traits · 5f464bb7
      Hans 提交于
      Fixes #81775
      5f464bb7
    • B
      Auto merge of #88719 - estebank:point-at-arg-for-obligation, r=nagisa · e3662105
      bors 提交于
      Point at argument instead of call for their obligations
      
      When an obligation is introduced by a specific `fn` argument, point at
      the argument instead of the `fn` call if the obligation fails to be
      fulfilled.
      
      Move the information about pointing at the call argument expression in
      an unmet obligation span from the `FulfillmentError` to a new
      `ObligationCauseCode`.
      
      When giving an error about an obligation introduced by a function call
      that an argument doesn't fulfill, and that argument is a block, add a
      span_label pointing at the innermost tail expression.
      
      Current output:
      
      ```
      error[E0425]: cannot find value `x` in this scope
       --> f10.rs:4:14
        |
      4 |         Some(x * 2)
        |              ^ not found in this scope
      
      error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<_>`
       --> f10.rs:2:31
        |
      2 |       let p = Some(45).and_then({
        |  ______________________--------_^
        | |                      |
        | |                      required by a bound introduced by this call
      3 | |         |x| println!("doubling {}", x);
      4 | |         Some(x * 2)
        | |         -----------
      5 | |     });
        | |_____^ expected an `FnOnce<({integer},)>` closure, found `Option<_>`
        |
        = help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>`
      ```
      
      Previous output:
      
      ```
      error[E0425]: cannot find value `x` in this scope
       --> f10.rs:4:14
        |
      4 |         Some(x * 2)
        |              ^ not found in this scope
      
      error[E0277]: expected a `FnOnce<({integer},)>` closure, found `Option<_>`
       --> f10.rs:2:22
        |
      2 |     let p = Some(45).and_then({
        |                      ^^^^^^^^ expected an `FnOnce<({integer},)>` closure, found `Option<_>`
        |
        = help: the trait `FnOnce<({integer},)>` is not implemented for `Option<_>`
      ```
      
      Partially address #27300. Will require rebasing on top of #88546.
      e3662105
    • B
      Auto merge of #89019 - Manishearth:rollup-5qp8a5s, r=Manishearth · e4828d5b
      bors 提交于
      Rollup of 10 pull requests
      
      Successful merges:
      
       - #88292 (Enable --generate-link-to-definition for rustc's docs)
       - #88729 (Recover from `Foo(a: 1, b: 2)`)
       - #88875 (cleanup(rustc_trait_selection): remove vestigial code from rustc_on_unimplemented)
       - #88892 (Move object safety suggestions to the end of the error)
       - #88928 (Document the closure arguments for `reduce`.)
       - #88976 (Clean up and add doc comments for CStr)
       - #88983 (Allow calling `get_body_with_borrowck_facts` without `-Z polonius`)
       - #88985 (Update clobber_abi list to include k[1-7] regs)
       - #88986 (Update the backtrace crate)
       - #89009 (Fix typo in `break` docs)
      
      Failed merges:
      
      r? `@ghost`
      `@rustbot` modify labels: rollup
      e4828d5b
    • A
      bc4d8af1
    • V
      delay error for enabling unstable lib features · 9f7e281d
      Vishad Goyal 提交于
      If #![feature] is used outside the nightly channel for only lib
      features, the check will be delayed to the stability pass after
      parsing. This is done so that appropriate help messages can be shown if
      the #![feature] has been used needlessly
      9f7e281d
    • M
      Rollup merge of #89009 - tatami4:master, r=Mark-Simulacrum · d9fa3561
      Manish Goregaokar 提交于
      Fix typo in `break` docs
      d9fa3561