1. 26 12月, 2021 1 次提交
  2. 25 12月, 2021 6 次提交
    • B
      Auto merge of #92227 - Kobzol:rustdoc-doc-hidden, r=jyn514 · c096176f
      bors 提交于
      Rustdoc: use `is_doc_hidden` method on more places
      
      While profiling `rustdoc`, I noticed that finding out if some item is marked with `#[doc(hidden)]` is relatively hot, so I tried to optimize it.
      
      I noticed that there is already a method called `is_doc_hidden` on `TyCtxt`, but it wasn't used much, so I replaced the manual calls to `attrs(...).has_word(...)` with this method. Just by doing that, perf. was improved locally, although I'm not sure if the semantics of the previous calls and this method are the same?
      
      As another step, I tried to querify `is_doc_hidden`, but I didn't include that here until we see the perf. results from the first commit and until I find whether this change is OK at all :)
      
      Can I ask for a perf. run? Thanks.
      
      r? `@jyn514`
      c096176f
    • B
      Auto merge of #92247 - lnicola:rust-analyzer-2021-12-24, r=lnicola · 67491a22
      bors 提交于
       rust-analyzer
      
      r? `@ghost`
      67491a22
    • B
      Auto merge of #92229 - fee1-dead:fix-rustdoc-const-drop, r=dtolnay · 83bde521
      bors 提交于
      Do not display `~const Drop` in rustdoc
      
      Although `T: ~const Drop` is still at an experimental stage, we have already begun inserting these bounds in libstd. This change hides them from rustdoc because 1. `~const` should not be documented in general as it is not yet official syntax; 2. users are not expected to know what `~const Drop` means yet.
      83bde521
    • M
      rustdoc: remove unused Hash impl · 551829b6
      Michael Howell 提交于
      551829b6
    • B
      Auto merge of #92135 - AngelicosPhosphoros:typeid_inline_74362, r=dtolnay · 475b00aa
      bors 提交于
      Add `#[inline]` modifier to `TypeId::of`
      
      It was already inlined but it happened only in 4th InlinerPass on my testcase.
      With `#[inline]` modifier it happens on 2nd pass.
      
      Closes #74362
      475b00aa
    • B
      Auto merge of #92156 - petrochenkov:ctorkind, r=davidtwco · aad4f103
      bors 提交于
      rustc_metadata: Merge `get_ctor_def_id` and `get_ctor_kind`
      
      Also avoid decoding the whole `ty::AssocItem` to get a `has_self` flag.
      
      A small optimization and cleanup extracted from https://github.com/rust-lang/rust/pull/89059.
      aad4f103
  3. 24 12月, 2021 15 次提交
    • B
      5956600e
    • R
      update Miri · 88fb8625
      Ralf Jung 提交于
      88fb8625
    • B
      Auto merge of #92226 - woppopo:const_black_box, r=joshtriplett · fca4b155
      bors 提交于
      Constify `core::intrinsics::black_box` and `core::hint::black_box`.
      
      `core::intrinsics::black_box` is already constified, but it wasn't marked as const (see: https://github.com/rust-lang/rust/blob/master/compiler/rustc_const_eval/src/interpret/intrinsics.rs#L471).
      
      Tracking issue: None
      fca4b155
    • L
      rust-analyzer · 46418848
      Laurențiu Nicola 提交于
      46418848
    • B
      Auto merge of #91342 - RalfJung:fn-abi, r=eddyb,oli-obk · 59337cdd
      bors 提交于
      CTFE eval_fn_call: use FnAbi to determine argument skipping and compatibility
      
      This makes use of the `FnAbi` type in CTFE/Miri, which `@EddyB` has been saying for years is what we should do.^^ `FnAbi` is used to
      - determine which arguments to skip (rather than the previous heuristic of skipping ZST arguments with the Rust ABI)
      - impose further restrictions on whether caller and callee are consistent in how a given argument is passed
      
      I was hoping it would also simplify the code, but that is not the case -- the previous type compatibility checks are still required (AFAIK), only the ZST skipping is gone and that took barely any code. We also need some hacks because `FnAbi` assumes a certain way of implementing `caller_location` (by passing extra arguments), but Miri can just read the caller location from the call stack so it doesn't need those arguments. (The fact that every backend has to separately implement support for these arguments seems suboptimal -- looks like this might have been better implemented on the MIR level.) To avoid having to implement those unnecessary arguments in Miri, we just compute *whether* the argument is present on the caller/callee side, but don't actually pass that argument around.
      
      I have no idea if this looks the way `@EddyB` thinks it should look... but it makes Miri's test suite pass. ;)
      One of rustc's tests fails unfortunately (`ui/const-generics/issues/issue-67739.rs`), some const generic code that is evaluated too early -- I think that should raise `TooGeneric` but instead it ICEs. My assumption is this is some FnAbi code that has not been properly tested on polymorphic code, but it might also be me calling that FnAbi code the wrong way.
      
      r? `@oli-obk` `@EddyB`
      Fixes https://github.com/rust-lang/rust/issues/56166
      Miri PR at https://github.com/rust-lang/miri/pull/1928
      59337cdd
    • B
      Auto merge of #92220 - nnethercote:RawVec-dont-recompute-capacity, r=joshtriplett · e6f1f04e
      bors 提交于
      RawVec: don't recompute capacity after allocating.
      
      Currently it sets the capacity to `ptr.len() / mem::size_of::<T>()`
      after any buffer allocation/reallocation. This would be useful if
      allocators ever returned a `NonNull<[u8]>` with a size larger than
      requested. But this never happens, so it's not useful.
      
      Removing this slightly reduces the size of generated LLVM IR, and
      slightly speeds up the hot path of `RawVec` growth.
      
      r? `@ghost`
      e6f1f04e
    • B
      Auto merge of #92222 - nnethercote:rm-global_allocator-rustc-rustdoc, r=alexcrichton · d6d12b6a
      bors 提交于
      Remove useless `#[global_allocator]` from rustc and rustdoc.
      
      This was added in #83152, which has several errors in its comments.
      
      This commit also fix up the comments, which are quite wrong and
      misleading.
      
      r? `@alexcrichton`
      d6d12b6a
    • B
      Auto merge of #92232 - matthiaskrgr:rollup-eqdac7z, r=matthiaskrgr · c09a9529
      bors 提交于
      Rollup of 5 pull requests
      
      Successful merges:
      
       - #90625 (Add `UnwindSafe` to `Once`)
       - #92121 (disable test with self-referential generator on Miri)
       - #92166 (Fixed a small typo in ui test comments)
       - #92203 (Store a `DefId` instead of an `AdtDef` in `AggregateKind::Adt`)
       - #92231 (Update books)
      
      Failed merges:
      
      r? `@ghost`
      `@rustbot` modify labels: rollup
      c09a9529
    • M
      Rollup merge of #92231 - ehuss:update-books, r=ehuss · 996fb282
      Matthias Krüger 提交于
      Update books
      
      ## nomicon
      
      1 commits in 49681ea4a9fa81173dbe9ffed74b4d4a35eae9e3..c05c452b36358821bf4122f9c418674edd1d713d
      2021-11-24 16:27:28 +0900 to 2021-12-13 15:23:48 +0900
      - Update the guidance on uninitialized data with ptr::addr_of_mut (rust-lang/nomicon#325)
      
      ## reference
      
      3 commits in 954f3d441ad880737a13e241108f791a4d2a38cd..06f9e61931bcf58b91dfe6c924057e42ce273ee1
      2021-11-29 11:11:30 -0800 to 2021-12-17 07:31:40 -0800
      - keep consistent for primitive types (rust-lang/reference#1118)
      - README.md: link to mdbook docs (rust-lang/reference#1117)
      - Say that `...` range patterns are rejected in the 2021 edition (rust-lang/reference#1114)
      
      ## book
      
      4 commits in 5f9358faeb1f46e19b8a23a21e79fd7fe150491e..8a0bb3c96e71927b80fa2286d7a5a5f2547c6aa4
      2021-12-05 21:33:16 -0500 to 2021-12-22 20:54:27 -0500
      - Propagate edits back
      - Fix number disagreement. Fixes rust-lang/book#2858.
      - Wrap some code in main to make scopes clearer. Fixes rust-lang/book#2830.
      - Respond to ch5 nostarch edits
      
      ## rustc-dev-guide
      
      9 commits in a374e7d8bb6b79de45b92295d06b4ac0ef35bc09..9bf0028b557798ddd07a6f652e4d0c635d3d6620
      2021-12-03 09:26:47 -0800 to 2021-12-20 21:53:57 +0900
      - remove rustfix item in test intro (rust-lang/rustc-dev-guide#1277)
      - Move date-check comment to fix Markdown syntax
      - Update humor docs for special-casing ferris emoji
      - Fix some broken links (rust-lang/rustc-dev-guide#1274)
      - Update rustdoc internals
      - Update HIR chapter to use `HirId` instead of `NodeId`
      - Fix some broken links
      - Update src/getting-started.md
      - Improve documentation on r?
      996fb282
    • M
      Rollup merge of #92203 - Aaron1011:mir-adt-def, r=oli-obk · 8a61ae04
      Matthias Krüger 提交于
      Store a `DefId` instead of an `AdtDef` in `AggregateKind::Adt`
      
      The `AggregateKind` enum ends up in the final mir `Body`. Currently,
      any changes to `AdtDef` (regardless of how significant they are)
      will legitimately cause the overall result of `optimized_mir` to change,
      invalidating any codegen re-use involving that mir.
      
      This will get worse once we start hashing the `Span` inside `FieldDef`
      (which is itself contained in `AdtDef`).
      
      To try to reduce these kinds of invalidations, this commit changes
      `AggregateKind::Adt` to store just the `DefId`, instead of the full
      `AdtDef`. This allows the result of `optimized_mir` to be unchanged
      if the `AdtDef` changes in a way that doesn't actually affect any
      of the MIR we build.
      8a61ae04
    • M
      Rollup merge of #92166 - fee1-dead:patch-2, r=jyn514 · cf7ee697
      Matthias Krüger 提交于
      Fixed a small typo in ui test comments
      cf7ee697
    • M
      Rollup merge of #92121 - RalfJung:miri-core-test, r=kennytm · 94b9b5f3
      Matthias Krüger 提交于
      disable test with self-referential generator on Miri
      
      Running the libcore test suite in Miri currently fails due to the known incompatibility of self-referential generators with Miri's aliasing checks (https://github.com/rust-lang/unsafe-code-guidelines/issues/148). So let's disable that test in Miri for now.
      94b9b5f3
    • M
      Rollup merge of #90625 - Milo123459:ref-unwind-safe, r=dtolnay · 40c67206
      Matthias Krüger 提交于
      Add `UnwindSafe` to `Once`
      
      Fixes #43469
      40c67206
    • E
      Update books · b4678870
      Eric Huss 提交于
      b4678870
    • B
      Auto merge of #92110 - nagisa:def-inlining, r=nikic · 77497c74
      bors 提交于
      Backport LLVM changes to disable deferred inlining
      
      Fixes #91128
      
      I was thinking of how to best add the test case from the issue, and I think rust perf infrastructure would probably be the best place for something like it.
      77497c74
  4. 23 12月, 2021 18 次提交
    • D
      Do not display `~const Drop` in rustdoc · 2e8b4a75
      Deadbeef 提交于
      2e8b4a75
    • B
      Auto merge of #92177 - GuillaumeGomez:pattern-matching-outside-loop, r=camelid · 489296d8
      bors 提交于
      Move pattern matching outside of the loop
      
      Not sure if worth it but it's been bugging me for a while now.
      
      r? `@camelid`
      489296d8
    • W
      Constify `core::intrinsics::black_box` · 72f15ea2
      woppopo 提交于
      72f15ea2
    • J
      Rustdoc: use `is_doc_hidden` method on more places · 0ec3199b
      Jakub Beránek 提交于
      0ec3199b
    • B
      Auto merge of #92167 - pierwill:chalk-update, r=jackh726 · c1d301bb
      bors 提交于
      Update chalk to 0.75.0
      
      - Compute flags in `intern_ty`
      - Remove `tracing-serde` from `PERMITTED_DEPENDENCIES`
      - Bump `tracing-tree` to 0.2.0
      - Bump `tracing-subscriber` to 0.3.3
      c1d301bb
    • N
      Remove useless `#[global_allocator]` from rustc and rustdoc. · bb23bfc2
      Nicholas Nethercote 提交于
      This was added in #83152, which has several errors in its comments.
      
      This commit also fix up the comments, which are quite wrong and
      misleading.
      bb23bfc2
    • B
      Auto merge of #92155 - m-ou-se:panic-fn, r=eddyb · 390bb340
      bors 提交于
      Use panic() instead of panic!() in some places in core.
      
      See https://github.com/rust-lang/rust/pull/92068 and https://github.com/rust-lang/rust/pull/92140.
      
      This avoids the `panic!()` macro in a few potentially hot paths. This becomes more relevant when switching `core` to Rust 2021, as it'll avoid format_args!() and save some compilation time. (It doesn't make a huge difference, but still.) (Also the errors in const panic become slightly nicer.)
      390bb340
    • B
      Auto merge of #92216 - matthiaskrgr:rollup-luplvuc, r=matthiaskrgr · 5aa0239b
      bors 提交于
      Rollup of 7 pull requests
      
      Successful merges:
      
       - #88858 (Allow reverse iteration of lowercase'd/uppercase'd chars)
       - #91544 (Fix duplicate derive clone suggestion)
       - #92026 (Add some JSDoc comments to rustdoc JS)
       - #92117 (kmc-solid: Add `std::sys::solid::fs::File::read_buf`)
       - #92139 (Change Backtrace::enabled atomic from SeqCst to Relaxed)
       - #92146 (Don't emit shared files when scraping examples from dependencies in Rustdoc)
       - #92208 (Quote bat script command line)
      
      Failed merges:
      
      r? `@ghost`
      `@rustbot` modify labels: rollup
      5aa0239b
    • M
      Rollup merge of #92208 - ChrisDenton:win-bat-cmd, r=dtolnay · 3afed8fc
      Matthias Krüger 提交于
      Quote bat script command line
      
      Fixes #91991
      
      [`CreateProcessW`](https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw#parameters) should only be used to run exe files but it does have some (undocumented) special handling for files with `.bat` and `.cmd` extensions. Essentially those magic extensions will cause the parameters to be automatically rewritten. Example pseudo Rust code (note that `CreateProcess` starts with an optional application name followed by the application arguments):
      ```rust
      // These arguments...
      CreateProcess(None, `@"foo.bat` "hello world""`@,` ...);
      // ...are rewritten as
      CreateProcess(Some(r"C:\Windows\System32\cmd.exe"), `@""foo.bat` "hello world"""`@,` ...);
      ```
      
      However, when setting the first parameter (the application name) as we now do, it will omit the extra level of quotes around the arguments:
      
      ```rust
      // These arguments...
      CreateProcess(Some("foo.bat"), `@"foo.bat` "hello world""`@,` ...);
      // ...are rewritten as
      CreateProcess(Some(r"C:\Windows\System32\cmd.exe"), `@"foo.bat` "hello world""`@,` ...);
      ```
      
      This means the arguments won't be passed to the script as intended.
      
      Note that running batch files this way is undocumented but people have relied on this so we probably shouldn't break it.
      3afed8fc
    • M
      Rollup merge of #92146 - willcrichton:example-analyzer, r=jyn514 · 051d91a5
      Matthias Krüger 提交于
      Don't emit shared files when scraping examples from dependencies in Rustdoc
      
      This PR fixes #91605. The issue is that `Context::init` gets called when scraping dependencies. By default, just calling `init` calls into `write_shared` and `build_index` which register the scraped crate into a list that later gets used for the Rustdoc sidebar. The fix is to ensure that `write_shared` is not called when scraping.
      
      r? `@jyn514`
      051d91a5
    • M
      Rollup merge of #92139 - dtolnay:backtrace, r=m-ou-se · 12e49077
      Matthias Krüger 提交于
      Change Backtrace::enabled atomic from SeqCst to Relaxed
      
      This atomic is not synchronizing anything outside of its own value, so we don't need the `Acquire`/`Release` guarantee that all memory operations prior to the store are visible after the subsequent load, nor the `SeqCst` guarantee of all threads seeing all of the sequentially consistent operations in the same order.
      
      Using `Relaxed` reduces the overhead of `Backtrace::capture()` in the case that backtraces are not enabled.
      
      ## Benchmark
      
      ```rust
      #![feature(backtrace)]
      
      use std::backtrace::Backtrace;
      use std::sync::atomic::{AtomicUsize, Ordering};
      use std::thread;
      use std::time::Instant;
      
      fn main() {
          let begin = Instant::now();
          let mut threads = Vec::new();
          for _ in 0..64 {
              threads.push(thread::spawn(|| {
                  for _ in 0..10_000_000 {
                      let _ = Backtrace::capture();
                      static LOL: AtomicUsize = AtomicUsize::new(0);
                      LOL.store(1, Ordering::Release);
                  }
              }));
          }
          for thread in threads {
              let _ = thread.join();
          }
          println!("{:?}", begin.elapsed());
      }
      ```
      
      **Before:**&ensp;6.73 seconds
      **After:**&ensp;5.18 seconds
      12e49077
    • M
      Rollup merge of #92117 - solid-rs:fix-kmc-solid-read-buf, r=yaahc · 554ad50f
      Matthias Krüger 提交于
      kmc-solid: Add `std::sys::solid::fs::File::read_buf`
      
      This PR adds `std::sys::solid::fs::File::read_buf` to catch up with the changes introduced by #81156 and fix the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets..
      554ad50f
    • M
      Rollup merge of #92026 - jsha:jsdoc-search, r=GuillaumeGomez · 9f68b6e0
      Matthias Krüger 提交于
      Add some JSDoc comments to rustdoc JS
      
      This follows the Closure Compiler dialect of JSDoc, so we can use it to do some basic type checking. We don't plan to compile with Closure Compiler, just use it to check types. See https://github.com/google/closure-compiler/wiki/ for details.
      
      To try checking the annotations, run:
      
      ```
      npm i -g google-closure-compiler
      google-closure-compiler -W VERBOSE build/x86_64-unknown-linux-gnu/doc/{search-index1.59.0.js,crates1.59.0.js} src/librustdoc/html/static/js/{search.js,main.js,storage.js} --externs src/librustdoc/html/static/js/externs.js >/dev/null
      ```
      
      You'll see some warnings that "String continuations are not recommended". I'm not addressing those right now.
      
      [Discussed on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/266220-rustdoc/topic/doc.20format.20for.20JS/near/265209466).
      
      r? `@GuillaumeGomez`
      9f68b6e0
    • M
      Rollup merge of #91544 - rukai:91492, r=wesleywiser · d8bf974d
      Matthias Krüger 提交于
      Fix duplicate derive clone suggestion
      
      closes https://github.com/rust-lang/rust/issues/91492
      
      The addition of:
      ```rust
      derives.sort();
      derives.dedup();
      ```
      is what actually solves the problem.
      The rest is just cleanup.
      
      I want to improve the diagnostic message to provide the suggestion as a proper diff but ran into some problems, so I'll attempt that again in a follow up PR.
      d8bf974d
    • M
      Rollup merge of #88858 - spektom:to_lower_upper_rev, r=dtolnay · 60625a6e
      Matthias Krüger 提交于
      Allow reverse iteration of lowercase'd/uppercase'd chars
      
      The PR implements `DoubleEndedIterator` trait for `ToLowercase` and `ToUppercase`.
      
      This enables reverse iteration of lowercase/uppercase variants of character sequences.
      One of use cases:  determining whether a char sequence is a suffix of another one.
      
      Example:
      
      ```rust
      fn endswith_ignore_case(s1: &str, s2: &str) -> bool {
          for eob in s1
              .chars()
              .flat_map(|c| c.to_lowercase())
              .rev()
              .zip_longest(s2.chars().flat_map(|c| c.to_lowercase()).rev())
          {
              match eob {
                  EitherOrBoth::Both(c1, c2) => {
                      if c1 != c2 {
                          return false;
                      }
                  }
                  EitherOrBoth::Left(_) => return true,
                  EitherOrBoth::Right(_) => return false,
              }
          }
          true
      }
      ```
      60625a6e
    • B
      Auto merge of #90408 - pierwill:untrack-localdefid-90317, r=cjgillot · e9830929
      bors 提交于
      Remove `PartialOrd`, `Ord` from `LocalDefId`
      
      Part of work on https://github.com/rust-lang/rust/issues/90317.
      e9830929
    • J
      Add some JSDoc comments to rustdoc JS · 7ba086c6
      Jacob Hoffman-Andrews 提交于
      This follows the Closure Compiler dialect of JSDoc, so we
      can use it to do some basic type checking. We don't plan to
      compile with Closure Compiler, just use it to check types. See
      https://github.com/google/closure-compiler/wiki/ for details.
      7ba086c6
    • A
      Store a `DefId` instead of an `AdtDef` in `AggregateKind::Adt` · cac431ba
      Aaron Hill 提交于
      The `AggregateKind` enum ends up in the final mir `Body`. Currently,
      any changes to `AdtDef` (regardless of how significant they are)
      will legitimately cause the overall result of `optimized_mir` to change,
      invalidating any codegen re-use involving that mir.
      
      This will get worse once we start hashing the `Span` inside `FieldDef`
      (which is itself contained in `AdtDef`).
      
      To try to reduce these kinds of invalidations, this commit changes
      `AggregateKind::Adt` to store just the `DefId`, instead of the full
      `AdtDef`. This allows the result of `optimized_mir` to be unchanged
      if the `AdtDef` changes in a way that doesn't actually affect any
      of the MIR we build.
      cac431ba