1. 04 3月, 2022 26 次提交
    • D
      Rollup merge of #94582 - nnethercote:fix-x-fmt-bug, r=Mark-Simulacrum · 733a1a8c
      Dylan DPC 提交于
      Fix a bug in `x.py fmt` that prevents some files being formatted.
      
      If you have a file in the repository root with the same name as a file
      somewhere within a directory, the latter currently won't get formatted.
      
      I have experienced this multiple times and not understood what was
      happening; I finally figured out the problem today. This commit fixes
      the problem.
      
      r? ```@Mark-Simulacrum```
      733a1a8c
    • D
      Rollup merge of #94575 - RalfJung:switchint-comment, r=oli-obk · 72c0c084
      Dylan DPC 提交于
      CTFE SwitchInt: update comment
      
      I just wondered why this doesn't use `binary_op`.
      
      r? ```@oli-obk```
      72c0c084
    • D
      Rollup merge of #94572 - sunfishcode:sunfishcode/handle-or, r=joshtriplett · 308efafc
      Dylan DPC 提交于
      Use `HandleOrNull` and `HandleOrInvalid` in the Windows FFI bindings.
      
      Use the new `HandleOrNull` and `HandleOrInvalid` types that were introduced
      as part of [I/O safety] in a few functions in the Windows FFI bindings.
      
      This factors out an `unsafe` block and two `unsafe` function calls in the
      Windows implementation code.
      
      And, it helps test `HandleOrNull` and `HandleOrInvalid`, and indeed, it
      turned up a bug: `OwnedHandle` also needs to be `#[repr(transparent)]`,
      as it's used inside of `HandleOrNull` and `HandleOrInvalid` which are also
      `#[repr(transparent)]`.
      
      r? ```@joshtriplett```
      
      [I/O safety]: https://github.com/rust-lang/rust/issues/87074
      308efafc
    • D
      Rollup merge of #94466 - jonhoo:bootstrap-proper-env-flags, r=Mark-Simulacrum · 958bd026
      Dylan DPC 提交于
      bootstrap: correct reading of flags for llvm
      
      First, this reverts the `CFLAGS`/`CXXFLAGS` of #93918. Those flags are
      already read by `cc` and populated into `Build` earlier on in the
      process. We shouldn't be overriding that based on `CFLAGS`, since `cc`
      also respects overrides like `CFLAGS_{TARGET}` and `HOST_CFLAGS`, which
      we want to take into account.
      
      Second, this adds the same capability to specify target-specific
      versions of `LDFLAGS` as we have through `cc` for the `C*` flags:
      https://github.com/alexcrichton/cc-rs#external-configuration-via-environment-variables
      958bd026
    • D
      Rollup merge of #94404 - pierwill:newtype-index-noord-2, r=Aaron1011 · aede21f4
      Dylan DPC 提交于
      Make Ord and PartialOrd opt-out in `newtype_index`
      
      Part of work on #90317. This will allow us to do
      
      ```diff
      rustc_index::newtype_index! {
          /// A unique ID associated with a macro invocation and expansion.
          pub struct LocalExpnId {
              ENCODABLE = custom
              DEBUG_FORMAT = "expn{}"
      +       ORD_IMPL = off
          }
      }
      ```
      aede21f4
    • D
      Rollup merge of #94339 - Amanieu:arm-d32, r=nagisa · 79c71d1f
      Dylan DPC 提交于
      ARM: Only allow using d16-d31 with asm! when supported by the target
      
      Support can be determined by checking for the "d32" LLVM feature.
      
      r? ```````````````@nagisa```````````````
      79c71d1f
    • D
      Rollup merge of #93965 - Mark-Simulacrum:owned-stdio, r=dtolnay · cdfb39ef
      Dylan DPC 提交于
      Make regular stdio lock() return 'static handles
      
      This also deletes the unstable API surface area previously added to expose this
      functionality on new methods rather than built into the current set.
      
      Closes #86845 (tracking issue for unstable API needed without this)
      
      r? ``````@dtolnay`````` to kick off T-libs-api FCP
      cdfb39ef
    • D
      Rollup merge of #93913 - bjorn3:remove_everybody_loops, r=jackh726 · c1585a17
      Dylan DPC 提交于
      Remove the everybody loops pass
      
      It isn't used anymore by rustdoc.
      
      Split out of https://github.com/rust-lang/rust/pull/92895. There has been some previous discussion there.
      c1585a17
    • D
      Rollup merge of #93418 - ojeda:no-shortcut, r=camelid · c695de05
      Dylan DPC 提交于
      rustdoc & doc: no `shortcut` for `rel="icon"`
      
      According to https://html.spec.whatwg.org/multipage/links.html#rel-icon:
      
      > For historical reasons, the `icon` keyword may be preceded by the keyword "`shortcut`".
      
      And to https://developer.mozilla.org/en-US/docs/Web/HTML/Link_types:
      
      > **Warning:** The `shortcut` link type is often seen before `icon`, but this link type is non-conforming, ignored and **web authors must not use it anymore.**
      
      While it was removed from the Rust logo case a while ago in commit 085679c8 ("Use theme-adaptive SVG favicon from other Rust sites"), it is still there for the custom logo case.
      
      Also updated a few other instances.
      Signed-off-by: NMiguel Ojeda <ojeda@kernel.org>
      c695de05
    • D
      Rollup merge of #88805 - krhancoc:master, r=dtolnay · 4c702004
      Dylan DPC 提交于
      Clarification of default socket flags
      
      This PR outlines the decision to disable inheritance of socket objects when possible to child processes in the documentation.
      4c702004
    • N
      Fix a bug in `x.py fmt` that prevents some files being formatted. · fc142eba
      Nicholas Nethercote 提交于
      If you have a file in the repository root with the same name as a file
      somewhere within a directory, the latter currently won't get formatted.
      
      I have experienced this multiple times and not understood what was
      happening; I finally figured out the problem today. This commit fixes
      the problem.
      fc142eba
    • B
      Auto merge of #94571 - matthiaskrgr:rollup-4ul5ydb, r=matthiaskrgr · 40d3040a
      bors 提交于
      Rollup of 8 pull requests
      
      Successful merges:
      
       - #92697 (Use cgroup quotas for calculating `available_parallelism`)
       - #94057 (improve comments for `simplify_type`)
       - #94547 (`parse_tt` cleanups)
       - #94550 (rustdoc: Add test for higher kinded functions generated by macros)
       - #94551 (Doc: Fix use of quote instead of backstick in Adapter::map.)
       - #94554 (Fix invalid lint_node_id being put on a removed stmt)
       - #94555 (all: fix some typos)
       - #94563 (Remove a unnecessary `..` pattern)
      
      Failed merges:
      
      r? `@ghost`
      `@rustbot` modify labels: rollup
      40d3040a
    • R
      CTFE SwitchInt: update comment · 08547818
      Ralf Jung 提交于
      08547818
    • D
      Use `HandleOrNull` and `HandleOrInvalid` in the Windows FFI bindings. · 35606490
      Dan Gohman 提交于
      Use the new `HandleOrNull` and `HandleOrInvalid` types that were introduced
      as part of [I/O safety] in a few functions in the Windows FFI bindings.
      
      This factors out an `unsafe` block and two `unsafe` function calls in the
      Windows implementation code.
      
      And, it helps test `HandleOrNull` and `HandleOrInvalid`, which indeed turned
      up a bug: `OwnedHandle` also needs to be `#[repr(transparent)]`, as it's
      used inside of `HandleOrNull` and `HandleOrInvalid` which are also
      `#[repr(transparent)]`.
      
      [I/O safety]: https://github.com/rust-lang/rust/issues/87074
      35606490
    • M
      Rollup merge of #94563 -... · cfa58dfd
      Matthias Krüger 提交于
      Rollup merge of #94563 - TaKO8Ki:remove-unnecessary-patten-for-ignoring-remaining-parts, r=Dylan-DPC
      
      Remove a unnecessary `..` pattern
      cfa58dfd
    • M
      Rollup merge of #94555 - cuishuang:master, r=oli-obk · 939c1585
      Matthias Krüger 提交于
      all: fix some typos
      Signed-off-by: Ncuishuang <imcusg@gmail.com>
      939c1585
    • M
      Rollup merge of #94554 - Urgau:stmt-node-id-ice, r=petrochenkov · 26cbf915
      Matthias Krüger 提交于
      Fix invalid lint_node_id being put on a removed stmt
      
      This pull-request remove a invalid `assign_id!` being put on an stmt node.
      
      The problem is that this node is being removed away by a cfg making it unreachable when triggering a buffered lint.
      The comment in the other match arm already tell to not assign a id because it could have a `#[cfg()]` so this is just respecting the comment.
      
      Fixes https://github.com/rust-lang/rust/issues/94523
      r? ```````@petrochenkov```````
      26cbf915
    • M
      Rollup merge of #94551 - darnuria:doc-map-backstick, r=dtolnay · 40c146ce
      Matthias Krüger 提交于
      Doc: Fix use of quote instead of backstick in Adapter::map.
      
      A little commit to fix documentation rendering and semantics in https://doc.rust-lang.org/std/iter/struct.Map.html#notes-about-side-effects `"` where used around an expression instead \`.
      
      Screenshot on doc.rust-lang.org:
      ![2022-03-03 11-21-43_backstick](https://user-images.githubusercontent.com/2827553/156546536-569b7692-7ac4-4388-8e93-c1628ddc6a0f.png)
      
      Looking forward: Maybe reworking the doc to use assert_eq like the upper paragraph:
      ```
      let v: Vec<i32> = vec![1, 2, 3].into_iter().map(|x| x + 1).rev().collect();
      
      assert_eq!(v, [4, 3, 2]);
      ```
      40c146ce
    • M
      Rollup merge of #94550 - GuillaumeGomez:HKF-macros, r=notriddle · 835eaaa7
      Matthias Krüger 提交于
      rustdoc: Add test for higher kinded functions generated by macros
      
      Fixes #75564.
      
      The problem has been solved apparently so adding a test to prevent a regression.
      
      r? ```@notriddle```
      835eaaa7
    • M
      Rollup merge of #94547 - nnethercote:parse_tt-cleanups, r=petrochenkov · 16c6594f
      Matthias Krüger 提交于
      `parse_tt` cleanups
      
      I've been looking closely at this code, and saw some opportunities to improve its readability.
      
      r? ```````@petrochenkov```````
      16c6594f
    • M
      Rollup merge of #94057 - lcnr:simplify_type-uwu, r=nikomatsakis · fec7a790
      Matthias Krüger 提交于
      improve comments for `simplify_type`
      
      Should now correctly describe what's going on. Experimented with checking the invariant for projections
      but that ended up requiring fairly involved changes. I assume that it is not possible to get unsoundness here,
      at least for now and I can pretty much guarantee that it's impossible to trigger it by accident.
      
      r? `````@nikomatsakis````` cc #92721
      fec7a790
    • M
      Rollup merge of #92697 - the8472:cgroups, r=joshtriplett · a638f50d
      Matthias Krüger 提交于
      Use cgroup quotas for calculating `available_parallelism`
      
      Automated tests for this are possible but would require a bunch of assumptions. It requires root + a recent kernel, systemd and maybe docker. And even then it would need a helper binary since the test has to run in a separate process.
      
      Limitations
      
      * only supports cgroup v2 and assumes it's mounted under `/sys/fs/cgroup`
      * procfs must be available
      * the quota gets mixed into `sched_getaffinity`, so if the latter doesn't work then quota information gets ignored too
      
      Manually tested via
      
      ```
      // spawn a new cgroup scope for the current user
      $ sudo systemd-run -p CPUQuota="300%" --uid=$(id -u) -tdS
      
      // quota.rs
      #![feature(available_parallelism)]
      fn main() {
          println!("{:?}", std::thread::available_parallelism()); // prints Ok(3)
      }
      ```
      
      strace:
      
      ```
      sched_getaffinity(3041643, 32, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]) = 32
      openat(AT_FDCWD, "/proc/self/cgroup", O_RDONLY|O_CLOEXEC) = 3
      statx(0, NULL, AT_STATX_SYNC_AS_STAT, STATX_ALL, NULL) = -1 EFAULT (Bad address)
      statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0444, stx_size=0, ...}) = 0
      lseek(3, 0, SEEK_CUR)                   = 0
      read(3, "0::/system.slice/run-u31477.serv"..., 128) = 36
      read(3, "", 92)                         = 0
      close(3)                                = 0
      statx(AT_FDCWD, "/sys/fs/cgroup/system.slice/run-u31477.service/cgroup.controllers", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0444, stx_size=0, ...}) = 0
      openat(AT_FDCWD, "/sys/fs/cgroup/system.slice/run-u31477.service/cpu.max", O_RDONLY|O_CLOEXEC) = 3
      statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=0, ...}) = 0
      lseek(3, 0, SEEK_CUR)                   = 0
      read(3, "300000 100000\n", 20)          = 14
      read(3, "", 6)                          = 0
      close(3)                                = 0
      openat(AT_FDCWD, "/sys/fs/cgroup/system.slice/cpu.max", O_RDONLY|O_CLOEXEC) = 3
      statx(3, "", AT_STATX_SYNC_AS_STAT|AT_EMPTY_PATH, STATX_ALL, {stx_mask=STATX_BASIC_STATS|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=0, ...}) = 0
      lseek(3, 0, SEEK_CUR)                   = 0
      read(3, "max 100000\n", 20)             = 11
      read(3, "", 9)                          = 0
      close(3)                                = 0
      openat(AT_FDCWD, "/sys/fs/cgroup/cpu.max", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
      sched_getaffinity(0, 128, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47]) = 40
      ```
      
      r? ```````@joshtriplett```````
      cc ```````@yoshuawuyts```````
      
      Tracking issue and previous discussion: #74479
      a638f50d
    • B
      Auto merge of #87835 - xFrednet:rfc-2383-expect-attribute-with-ids, r=wesleywiser · 10913c00
      bors 提交于
      Implementation of the `expect` attribute (RFC 2383)
      
      This is an implementation of the `expect` attribute as described in [RFC-2383](https://rust-lang.github.io/rfcs/2383-lint-reasons.html). The attribute allows the suppression of lint message by expecting them. Unfulfilled lint expectations (meaning no expected lint was caught) will emit the `unfulfilled_lint_expectations` lint at the `expect` attribute.
      
      ### Example
      #### input
      ```rs
      // required feature flag
      #![feature(lint_reasons)]
      
      #[expect(unused_mut)] // Will warn about an unfulfilled expectation
      #[expect(unused_variables)] // Will be fulfilled by x
      fn main() {
          let x = 0;
      }
      ```
      
      #### output
      
      ```txt
      warning: this lint expectation is unfulfilled
        --> $DIR/trigger_lint.rs:3:1
         |
      LL | #[expect(unused_mut)] // Will warn about an unfulfilled expectation
         |          ^^^^^^^^^^
         |
         = note: `#[warn(unfulfilled_lint_expectations)]` on by default
      ```
      
      ### Implementation
      
      This implementation introduces `Expect` as a new lint level for diagnostics, which have been expected. All lint expectations marked via the `expect` attribute are collected in the [`LintLevelsBuilder`] and assigned an ID that is stored in the new lint level. The `LintLevelsBuilder` stores all found expectations and the data needed to emit the `unfulfilled_lint_expectations` in the [`LintLevelsMap`] which is the result of the [`lint_levels()`] query.
      
      The [`rustc_errors::HandlerInner`] is the central error handler in rustc and handles the emission of all diagnostics. Lint message with the level `Expect` are suppressed during this emission, while the expectation ID is stored in a set which marks them as fulfilled. The last step is then so simply check if all expectations collected by the [`LintLevelsBuilder`] in the [`LintLevelsMap`] have been marked as fulfilled in the [`rustc_errors::HandlerInner`]. Otherwise, a new lint message will be emitted.
      
      The implementation of the `LintExpectationId` required some special handling to make it stable between sessions. Lints can be emitted during [`EarlyLintPass`]es. At this stage, it's not possible to create a stable identifier. The level instead stores an unstable identifier, which is later converted to a stable `LintExpectationId`.
      
      ### Followup TO-DOs
      All open TO-DOs have been marked with `FIXME` comments in the code. This is the combined list of them:
      
      * [ ] The current implementation doesn't cover cases where the `unfulfilled_lint_expectations` lint is actually expected by another `expect` attribute.
         * This should be easily possible, but I wanted to get some feedback before putting more work into this.
         * This could also be done in a new PR to not add to much more code to this one
      * [ ] Update unstable documentation to reflect this change.
      * [ ] Update unstable expectation ids in [`HandlerInner::stashed_diagnostics`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.HandlerInner.html#structfield.stashed_diagnostics)
      
      ### Open questions
      I also have a few open questions where I would like to get feedback on:
      1. The RFC discussion included a suggestion to change the `expect` attribute to something else. (Initiated by `@Ixrec` [here](https://github.com/rust-lang/rfcs/pull/2383#issuecomment-378424091), suggestion from `@scottmcm` to use `#[should_lint(...)]` [here](https://github.com/rust-lang/rfcs/pull/2383#issuecomment-378648877)). No real conclusion was drawn on that point from my understanding. Is this still open for discussion, or was this discarded with the merge of the RFC?
      2. How should the expect attribute deal with the new `force-warn` lint level?
      
      ---
      
      This approach was inspired by a discussion with `@LeSeulArtichaut.`
      
      RFC tracking issue: #54503
      
      Mentoring/Implementation issue: #85549
      
      [`LintLevelsBuilder`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/levels/struct.LintLevelsBuilder.html
      [`LintLevelsMap`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/lint/struct.LintLevelMap.html
      [`lint_levels()`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/context/struct.TyCtxt.html#method.lint_levels
      [`rustc_errors::HandlerInner`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_errors/struct.HandlerInner.html
      [`EarlyLintPass`]: https://doc.rust-lang.org/nightly/nightly-rustc/rustc_lint/trait.EarlyLintPass.html
      10913c00
    • P
      Make `Ord`, `PartialOrd` opt-out in `newtype_index` · c08a9a4f
      pierwill 提交于
      Also remove `step` impl if `ORD_IMPL = off`
      c08a9a4f
    • J
      bootstrap: correct reading of flags for llvm · 9c05f0b7
      Jon Gjengset 提交于
      First, this reverts the `CFLAGS`/`CXXFLAGS` of #93918. Those flags are
      already read by `cc` and populated into `Build` earlier on in the
      process. We shouldn't be overriding that based on `CFLAGS`, since `cc`
      also respects overrides like `CFLAGS_{TARGET}` and `HOST_CFLAGS`, which
      we want to take into account.
      
      Second, this adds the same capability to specify target-specific
      versions of `LDFLAGS` as we have through `cc` for the `C*` flags:
      https://github.com/alexcrichton/cc-rs#external-configuration-via-environment-variables
      
      Note that this also necessitated an update to compiletest to treat
      CXXFLAGS separately from CFLAGS.
      9c05f0b7
    • B
      Remove the everybody loops pass · 2f84484a
      bjorn3 提交于
      It isn't used anymore by rustdoc
      2f84484a
  2. 03 3月, 2022 14 次提交