1. 28 3月, 2021 17 次提交
    • D
      Rollup merge of #82993 - camelid:source-use-diag, r=jyn514 · f665e5a4
      Dylan DPC 提交于
      rustdoc: Use diagnostics for error when including sources
      
      This error probably almost never happens, but we should still use the
      diagnostic infrastructure. My guess is that the error was added back
      before rustdoc used the rustc diagnostic infrastructure (it was all
      `println!` and `eprintln!` back then!) and since it likely rarely occurs
      and this code doesn't change that much, no one thought to transition it
      to using diagnostics.
      
      Note that the old error was actually a warning (it didn't stop the rest
      of doc building). It seems very unlikely that this would fail without
      the rest of the doc build failing, so it makes more sense for it to be a
      hard error.
      
      The error looks like this:
      
          error: failed to render source code for `src/test/rustdoc/smart-punct.rs`: "bar": foo
            --> src/test/rustdoc/smart-punct.rs:3:1
             |
          3  | / #![crate_name = "foo"]
          4  | |
          5  | | //! This is the "start" of the 'document'! How'd you know that "it's" ...
          6  | | //!
          ...  |
          22 | | //! I say "don't smart-punct me -- please!"
          23 | | //! ```
             | |_______^
      
      I wasn't sure how to trigger the error, so to create that message I
      temporarily made rustdoc always emit it. That's also why it says "bar"
      and "foo" instead of a real error message.
      
      Note that the span of the diagnostic starts at line 3 because line 1 of
      that file is a (non-doc) comment and line 2 is a blank line.
      f665e5a4
    • D
      Rollup merge of #82917 - cuviper:iter-zip, r=m-ou-se · b2e25431
      Dylan DPC 提交于
      Add function core::iter::zip
      
      This makes it a little easier to `zip` iterators:
      
      ```rust
      for (x, y) in zip(xs, ys) {}
      // vs.
      for (x, y) in xs.into_iter().zip(ys) {}
      ```
      
      You can `zip(&mut xs, &ys)` for the conventional `iter_mut()` and
      `iter()`, respectively. This can also support arbitrary nesting, where
      it's easier to see the item layout than with arbitrary `zip` chains:
      
      ```rust
      for ((x, y), z) in zip(zip(xs, ys), zs) {}
      for (x, (y, z)) in zip(xs, zip(ys, zs)) {}
      // vs.
      for ((x, y), z) in xs.into_iter().zip(ys).zip(xz) {}
      for (x, (y, z)) in xs.into_iter().zip((ys.into_iter().zip(xz)) {}
      ```
      
      It may also format more nicely, especially when the first iterator is a
      longer chain of methods -- for example:
      
      ```rust
          iter::zip(
              trait_ref.substs.types().skip(1),
              impl_trait_ref.substs.types().skip(1),
          )
          // vs.
          trait_ref
              .substs
              .types()
              .skip(1)
              .zip(impl_trait_ref.substs.types().skip(1))
      ```
      
      This replaces the tuple-pair `IntoIterator` in #78204.
      There is prior art for the utility of this in [`itertools::zip`].
      
      [`itertools::zip`]: https://docs.rs/itertools/0.10.0/itertools/fn.zip.html
      b2e25431
    • D
      Rollup merge of #82626 - lcnr:encode_with_shorthandb, r=estebank · ebea9d94
      Dylan DPC 提交于
      update array missing `IntoIterator` msg
      
      fixes #82602
      
      r? ```@estebank``` do you know whether we can use the expr span in `rustc_on_unimplemented`? The label isn't too great rn
      ebea9d94
    • D
      Rollup merge of #82525 - RalfJung:unaligned-ref-warn, r=petrochenkov · a900677e
      Dylan DPC 提交于
      make unaligned_references future-incompat lint warn-by-default
      
      and also remove the safe_packed_borrows lint that it replaces.
      
      `std::ptr::addr_of!` has hit beta now and will hit stable in a month, so I propose we start fixing https://github.com/rust-lang/rust/issues/27060 for real: creating a reference to a field of a packed struct needs to eventually become a hard error; this PR makes it a warn-by-default future-incompat lint. (The lint already existed, this just raises its default level.) At the same time I removed the corresponding code from unsafety checking; really there's no reason an `unsafe` block should make any difference here.
      
      For references to packed fields outside `unsafe` blocks, this means `unaligned_refereces` replaces the previous `safe_packed_borrows` warning with a link to https://github.com/rust-lang/rust/issues/82523 (and no more talk about unsafe blocks making any difference). So behavior barely changes, the warning is just worded differently. For references to packed fields inside `unsafe` blocks, this PR shows a new future-incompat warning.
      
      Closes https://github.com/rust-lang/rust/issues/46043 because that lint no longer exists.
      a900677e
    • D
      Rollup merge of #81351 - lcnr:big-money-big-prices, r=oli-obk · 520c9a25
      Dylan DPC 提交于
      combine: stop eagerly evaluating consts
      
      `super_relate_consts` eagerly evaluates constants which doesn't seem too great.
      
      I now also finally understand why all of the unused substs test passed. The reason being
      that we just evaluated the constants in `super_relate_consts` 😆
      
      While this change isn't strictly necessary as evaluating consts here doesn't hurt, it still feels a lot cleaner to do it this way
      
      r? `@oli-obk` `@nikomatsakis`
      520c9a25
    • J
      Add the tracking issue for `#![feature(iter_zip)]` · f0a6052d
      Josh Stone 提交于
      f0a6052d
    • B
      Auto merge of #83573 - JohnTitor:rollup-28jnzsr, r=JohnTitor · afaf33dc
      bors 提交于
      Rollup of 10 pull requests
      
      Successful merges:
      
       - #79399 (Use detailed and shorter fs error explaination)
       - #83348 (format macro argument parsing fix)
       - #83462 (ExitStatus: print "exit status: {}" rather than "exit code: {}" on unix)
       - #83526 (lazily calls some fns)
       - #83558 (Use DebugStruct::finish_non_exhaustive() in std.)
       - #83559 (Fix Debug implementation for RwLock{Read,Write}Guard.)
       - #83560 (Derive Debug for io::Chain instead of manually implementing it.)
       - #83561 (Improve Debug implementations of Mutex and RwLock.)
       - #83567 (Update rustup cross-compilation docs link)
       - #83569 (Add regression tests for #56445)
      
      Failed merges:
      
      r? `@ghost`
      `@rustbot` modify labels: rollup
      afaf33dc
    • Y
      Rollup merge of #83569 - sjakobi:issue56445-regression-test, r=jackh726 · 1ad7c528
      Yuki Okushi 提交于
      Add regression tests for #56445
      
      Closes #56445.
      1ad7c528
    • Y
      Rollup merge of #83567 - jonjensen:patch-1, r=GuillaumeGomez · 69acaf33
      Yuki Okushi 提交于
      Update rustup cross-compilation docs link
      69acaf33
    • Y
      Rollup merge of #83561 - m-ou-se:lock-debug, r=jackh726 · a800d7f6
      Yuki Okushi 提交于
      Improve Debug implementations of Mutex and RwLock.
      
      This improves the Debug implementations of Mutex and RwLock.
      
      They now show the poison flag and use debug_non_exhaustive. (See #67364.)
      a800d7f6
    • Y
      Rollup merge of #83560 - m-ou-se:io-chain-debug, r=sfackler · 8ad5f214
      Yuki Okushi 提交于
      Derive Debug for io::Chain instead of manually implementing it.
      
      This derives Debug for io::Chain instead of manually implementing it.
      
      The manual implementation has the same bounds, so I don't think there's any reason for a manual implementation. The names used in the derive implementation are even nicer (`first`/`second`) than the manual implementation (`t`/`u`), and include the `done_first` field too.
      8ad5f214
    • Y
      Rollup merge of #83559 - m-ou-se:rwlock-guard-debug-fix, r=jackh726 · 5dc29e18
      Yuki Okushi 提交于
      Fix Debug implementation for RwLock{Read,Write}Guard.
      
      This would attempt to print the Debug representation of the lock that the guard has locked, which will try to lock again, fail, and just print `"<locked>"` unhelpfully.
      
      After this change, this just prints the contents of the mutex, like the other smart pointers (and MutexGuard) do.
      
      MutexGuard had this problem too: https://github.com/rust-lang/rust/issues/57702
      5dc29e18
    • Y
      Rollup merge of #83558 - m-ou-se:use-finish-non-exhaustive, r=jackh726 · 53cc8065
      Yuki Okushi 提交于
      Use DebugStruct::finish_non_exhaustive() in std.
      
      See https://github.com/rust-lang/rust/issues/67364
      53cc8065
    • Y
      Rollup merge of #83526 - klensy:lazy-too, r=petrochenkov · fa70398d
      Yuki Okushi 提交于
      lazily calls some fns
      
      Replaced some fn's with it's lazy variants.
      fa70398d
    • Y
      Rollup merge of #83462 - ijackson:exitstatus-message-wording, r=joshtriplett · 3f41fdd2
      Yuki Okushi 提交于
      ExitStatus: print "exit status: {}" rather than "exit code: {}" on unix
      
      Proper Unix terminology is "exit status" (vs "wait status").  "exit
      code" is imprecise on Unix and therefore unclear.  (As far as I can
      tell, "exit code" is correct terminology on Windows.)
      
      This new wording is unfortunately inconsistent with the identifier
      names in the Rust stdlib.
      
      It is the identifier names that are wrong, as discussed at length in eg
        https://doc.rust-lang.org/nightly/std/process/struct.ExitStatus.html
        https://doc.rust-lang.org/nightly/std/os/unix/process/trait.ExitStatusExt.html
      
      Unfortunately for API stability reasons it would be a lot of work, and
      a lot of disruption, to change the names in the stdlib (eg to rename
      `std::process::ExitStatus` to `std::process::ChildStatus` or
      something), but we should fix the message output.  Many (probably
      most) readers of these messages about exit statuses will be users and
      system administrators, not programmers, who won't even know that Rust
      has this wrong terminology.
      
      So I think the right thing is to fix the documentation (as I have
      already done) and, now, the terminology in the implementation.
      
      This is a user-visible change to the behaviour of all Rust programs
      which run Unix subprocesses.  Hopefully no-one is matching against the
      exit status string, except perhaps in tests.
      3f41fdd2
    • Y
      Rollup merge of #83348 - osa1:issue83344, r=jackh726 · 973fb4b7
      Yuki Okushi 提交于
      format macro argument parsing fix
      
      When the character next to `{}` is "shifted" (when mapping a byte index
      in the format string to span) we should avoid shifting the span end
      index, so first map the index of `}` to span, then bump the span,
      instead of first mapping the next byte index to a span (which causes
      bumping the end span too much).
      
      Regression test added.
      
      Fixes #83344
      
      ---
      
      r? ```@estebank```
      973fb4b7
    • Y
      Rollup merge of #79399 - pickfire:patch-3, r=JohnTitor · 1f33a6a0
      Yuki Okushi 提交于
      Use detailed and shorter fs error explaination
      
      Includes suggestion from `@the8472` https://github.com/rust-lang/rust/issues/79390#issuecomment-733263336
      1f33a6a0
  2. 27 3月, 2021 23 次提交
    • R
      make unaligned_refereces future-incompat lint warn-by-default, and remove the... · fb4f48e0
      Ralf Jung 提交于
      make unaligned_refereces future-incompat lint warn-by-default, and remove the safe_packed_borrows lint that it replaces
      fb4f48e0
    • L
      update tests · e461dddf
      lcnr 提交于
      e461dddf
    • B
      combine: stop eagerly evaluating consts · 42150fb8
      Bastian Kauschke 提交于
      42150fb8
    • S
      Add regression tests for #56445 · 09275802
      Simon Jakobi 提交于
      Closes #56445.
      09275802
    • J
      Update rustup cross-compilation docs link · d5bcdd34
      Jon Jensen 提交于
      d5bcdd34
    • B
      Auto merge of #83245 - the8472:generalize-slice-fill, r=m-ou-se · 10100388
      bors 提交于
      Generalize and inline slice::fill specializations
      
      This makes the memset specialization applicable to more types. And since the code now lives in a generic method it is also eligible for cross-crate inlining which  should fix #83235
      10100388
    • I
      Use detailed and shorter fs error explaination · 5495ce08
      Ivan Tham 提交于
      Includes suggestion from the8472 https://github.com/rust-lang/rust/issues/79390#issuecomment-733263336
      
      More detail error explanation in fs doc
      5495ce08
    • M
      Improve Debug implementations of Mutex and RwLock. · 5402abc4
      Mara Bos 提交于
      They now show the poison flag and use debug_non_exhaustive.
      5402abc4
    • M
      Derive Debug for io::Chain instead of manually implementing it. · 7c01e6c3
      Mara Bos 提交于
      The manual implementation has the same bounds, so I don't think there's
      any reason for a manual implementation. The names used in the derive
      implementation are even nicer (`first`/`second`) than the manual
      implementation (`t`/`u`), and include the `done_first` field too.
      7c01e6c3
    • M
      Fix Debug implementation for RwLock{Read,Write}Guard. · d7301539
      Mara Bos 提交于
      This would attempt to print the Debug representation of the lock that
      the guard has locked, which will try to lock again, fail, and just print
      "<locked>" unhelpfully.
      
      After this change, this just prints the contents of the mutex, like the
      other smart pointers (and MutexGuard) do.
      d7301539
    • M
      Use DebugStruct::finish_non_exhaustive() in std. · 2afa4cc9
      Mara Bos 提交于
      2afa4cc9
    • B
      Auto merge of #78618 - workingjubilee:ieee754-fmt, r=m-ou-se · aef11409
      bors 提交于
      Add IEEE 754 compliant fmt/parse of -0, infinity, NaN
      
      This pull request improves the Rust float formatting/parsing libraries to comply with IEEE 754's formatting expectations around certain special values, namely signed zero, the infinities, and NaN. It also adds IEEE 754 compliance tests that, while less stringent in certain places than many of the existing flt2dec/dec2flt capability tests, are intended to serve as the beginning of a roadmap to future compliance with the standard. Some relevant documentation is also adjusted with clarifying remarks.
      
      This PR follows from discussion in https://github.com/rust-lang/rfcs/issues/1074, and closes #24623.
      
      The most controversial change here is likely to be that -0 is now printed as -0. Allow me to explain: While there appears to be community support for an opt-in toggle of printing floats as if they exist in the naively expected domain of numbers, i.e. not the extended reals (where floats live), IEEE 754-2019 is clear that a float converted to a string should be capable of being transformed into the original floating point bit-pattern when it satisfies certain conditions (namely, when it is an actual numeric value i.e. not a NaN and the original and destination float width are the same). -0 is given special attention here as a value that should have its sign preserved. In addition, the vast majority of other programming languages not only output `-0` but output `-0.0` here.
      
      While IEEE 754 offers a broad leeway in how to handle producing what it calls a "decimal character sequence", it is clear that the operations a language provides should be capable of round tripping, and it is confusing to advertise the f32 and f64 types as binary32 and binary64 yet have the most basic way of producing a string and then reading it back into a floating point number be non-conformant with the standard. Further, existing documentation suggested that e.g. -0 would be printed with -0 regardless of the presence of the `+` fmt character, but it prints "+0" instead if given such (which was what led to the opening of #24623).
      
      There are other parsing and formatting issues for floating point numbers which prevent Rust from complying with the standard, as well as other well-documented challenges on the arithmetic level, but I hope that this can be the beginning of motion towards solving those challenges.
      aef11409
    • Ö
      format macro argument parsing fix · 5b9bac2a
      Ömer Sinan Ağacan 提交于
      When the character next to `{}` is "shifted" (when mapping a byte index
      in the format string to span) we should avoid shifting the span end
      index, so first map the index of `}` to span, then bump the span,
      instead of first mapping the next byte index to a span (which causes
      bumping the end span too much).
      
      Regression test added.
      
      Fixes #83344
      5b9bac2a
    • B
      Auto merge of #83547 - JohnTitor:rollup-qh7j6hg, r=JohnTitor · feaac19f
      bors 提交于
      Rollup of 9 pull requests
      
      Successful merges:
      
       - #83239 (Remove/replace some outdated crates from the dependency tree)
       - #83328 (Fixes to inline assmebly tests)
       - #83343 (Simplify and fix byte skipping in format! string parser)
       - #83388 (Make # pretty print format easier to discover)
       - #83431 (Tell GitHub to highlight `config.toml.example` as TOML)
       - #83508 (Use the direct link to the platform support page)
       - #83511 (compiletest: handle llvm_version with suffix like "12.0.0libcxx")
       - #83524 (Document that the SocketAddr memory representation is not stable)
       - #83525 (fix doc comment for `ty::Dynamic`)
      
      Failed merges:
      
      r? `@ghost`
      `@rustbot` modify labels: rollup
      feaac19f
    • K
      lazily calls some fns · 229d1999
      klensy 提交于
      229d1999
    • Y
      Rollup merge of #83525 - rust-lang:lcnr-doc-patch, r=jonas-schievink · 1b01e0d3
      Yuki Okushi 提交于
      fix doc comment for `ty::Dynamic`
      1b01e0d3
    • Y
      Rollup merge of #83524 - faern:document-socketaddr-mem-layout, r=sfackler · d340f63c
      Yuki Okushi 提交于
      Document that the SocketAddr memory representation is not stable
      
      Intended to help out with #78802. Work has been put into finding and fixing code that assumes the memory layout of `SocketAddrV4` and `SocketAddrV6`. But it turns out there are cases where new code continues to make the same assumption ([example](https://github.com/spacejam/seaslug/commit/96927dc2b7b918860a79c4eb6336051e52c6137a#diff-917db3d8ca6f862ebf42726b23c72a12b35e584e497ebdb24e474348d7c6ffb6R610-R621)).
      
      The memory layout of a type in `std` is never part of the public API. Unless explicitly stated I guess. But since that is invalidly relied upon by a considerable amount of code for these particular types, it might make sense to explicitly document this. This can be temporary. Once #78802 lands it does not make sense to rely on the layout any longer, and this documentation can also be removed.
      d340f63c
    • Y
      Rollup merge of #83511 - 12101111:fix-llvm-version-suffix, r=Mark-Simulacrum · e675d255
      Yuki Okushi 提交于
      compiletest: handle llvm_version with suffix like "12.0.0libcxx"
      
      The previous code only remove the suffix begin with `-`, but Gentoo Linux [define `LLVM_VERSION_SUFFIX="libcxx"`](https://github.com/gentoo/gentoo/blob/604d79f327176eecb05293d7154e24231229cb31/sys-devel/llvm/llvm-11.1.0.ebuild#L378) when llvm is linked to libc++ and lead to a panic:
      
      ```
      thread 'main' panicked at 'Malformed version component: ParseIntError { kind: InvalidDigit }', src/tools/compiletest/src/header.rs:968:28
      ```
      
      This new code will handle all suffix not beginning with digit or dot.
      e675d255
    • Y
      Rollup merge of #83508 - JohnTitor:platform-support-link, r=joshtriplett · 60cf7729
      Yuki Okushi 提交于
      Use the direct link to the platform support page
      60cf7729
    • Y
      Rollup merge of #83431 - camelid:config-example-gitattributes, r=Mark-Simulacrum · 9df2b5f8
      Yuki Okushi 提交于
      Tell GitHub to highlight `config.toml.example` as TOML
      
      This should be a nice small quality of life improvement when looking at
      `config.toml.example` on GitHub or looking at diffs of it in PRs.
      9df2b5f8
    • Y
      Rollup merge of #83388 - alamb:alamb/fmt-dcs, r=Mark-Simulacrum · c1432679
      Yuki Okushi 提交于
      Make # pretty print format easier to discover
      
      # Rationale:
      
      I use (cargo cult?) three formats in rust:  `{}`, debug `{:?}`, and pretty-print debug `{:#?}`. I discovered `{:#?}` in some blog post or guide when I started working in Rust. While `#` is documented I think it is hard to discover. So taking the good advice of ```@carols10cents```  I am trying to improve the docs with a PR
      
      As a reminder "pretty print" means that where `{:?}` will print something like
      ```
      foo: { b1: 1, b2: 2}
      ```
      
      `{:#?}` will prints something like
      ```
      foo {
        b1: 1
        b2: 3
      }
      ```
      
      # Changes
      Add an example to `fmt` to try and make it easier to discover `#`
      c1432679
    • Y
      Rollup merge of #83343 - osa1:issue83340, r=jackh726 · d7216bae
      Yuki Okushi 提交于
      Simplify and fix byte skipping in format! string parser
      
      Fixes '\\' handling in format strings.
      
      Fixes #83340
      d7216bae
    • Y
      Rollup merge of #83328 - tmiasko:asm-test, r=joshtriplett · 14d0d51f
      Yuki Okushi 提交于
      Fixes to inline assmebly tests
      
      * Join test thread to make assertion effective in sym.rs test case
      * Use a single codegen unit to reduce non-determinism in srcloc.rs test #82886
      14d0d51f