1. 01 1月, 2022 1 次提交
  2. 28 12月, 2021 13 次提交
    • B
      Auto merge of #92159 - petrochenkov:decoditer, r=cjgillot · e91ad5fc
      bors 提交于
      rustc_metadata: Switch crate data iteration from a callback to iterator
      
      The iteration looks more conventional this way, and some allocations are avoided.
      e91ad5fc
    • B
      Auto merge of #92088 - camelid:intra-doc-cleanup, r=Manishearth · cc65bf3d
      bors 提交于
      intra-doc: Use an enum to represent URL fragments
      
      This is a step in the direction of computing the links more lazily,
      which I think will simplify the implementation of intra-doc links.
      This will also make it easier to eventually use the actual `Res` for
      associated items, enum variants, and fields, rather than their HTML
      page's `Res`.
      
      r? `@jyn514`
      cc65bf3d
    • N
      intra-doc: Use an enum to represent URL fragments · ae2bc692
      Noah Lev 提交于
      This is a step in the direction of computing the links more lazily,
      which I think will simplify the implementation of intra-doc links.
      This will also make it easier to eventually use the actual `Res` for
      associated items, enum variants, and fields, rather than their HTML
      page's `Res`.
      ae2bc692
    • N
      Remove needless `return` · 4472d975
      Noah Lev 提交于
      4472d975
    • B
      Auto merge of #92130 - Kobzol:stable-hash-str, r=cjgillot · 41ce641a
      bors 提交于
      Use hash_stable for hashing str
      
      This seemed like an oversight. With this change the hash can go through the `HashStable` machinery directly.
      41ce641a
    • B
      Auto merge of #92329 - matthiaskrgr:rollup-l3b4fl1, r=matthiaskrgr · 4ee34f35
      bors 提交于
      Rollup of 7 pull requests
      
      Successful merges:
      
       - #90586 (Relax priv-in-pub lint on generic bounds and where clauses of trait impls.)
       - #92112 (Fix the error of checking `base_expr` twice in type_changing_struct_update)
       - #92147 (rustc_builtin_macros: make asm mod public for rustfmt)
       - #92161 (resolve: Minor miscellaneous cleanups from #89059)
       - #92264 (Remove `maybe_uninit_extra` feature from Vec docs)
       - #92303 (Add test cases for issue #26186)
       - #92307 (Fix minor typos)
      
      Failed merges:
      
      r? `@ghost`
      `@rustbot` modify labels: rollup
      4ee34f35
    • M
      Rollup merge of #92307 - hiroshi-maybe:fix-minor-typos, r=camelid · eab81297
      Matthias Krüger 提交于
      Fix minor typos
      eab81297
    • M
      Rollup merge of #92303 - Patrick-Poitras:issue-26186, r=jackh726 · 052eab54
      Matthias Krüger 提交于
      Add test cases for issue #26186
      
      Closes #26186
      
      It seems that issue #26186 has been solved at some point since the issue has been last updated. I've merged together the examples that were supplied by `@Osspial,` `@Mark-Simulacrum,` `@Diggsey,` `@eefriedman` and `@shepmaster,` so that we can add this to the testing suite and prevent these issues from re-occurring.
      052eab54
    • M
      Rollup merge of #92264 - Shadlock0133:patch-1, r=the8472 · 4d8ba219
      Matthias Krüger 提交于
      Remove `maybe_uninit_extra` feature from Vec docs
      
      In `Vec`, two doc tests are using `MaybeUninit::write` , stabilized in 1.55. This makes docs' usage of `maybe_uninit_extra` feature unnecessary.
      4d8ba219
    • M
      Rollup merge of #92161 - petrochenkov:misclean, r=cjgillot · a11414d6
      Matthias Krüger 提交于
      resolve: Minor miscellaneous cleanups from #89059
      
      `@bors` rollup=always
      a11414d6
    • M
      Rollup merge of #92147 - calebcartwright:publicize-builtin_macro-asm, r=cjgillot · a7c79c08
      Matthias Krüger 提交于
      rustc_builtin_macros: make asm mod public for rustfmt
      
      Follow up to #92016, as I'd completely missed that the mod we needed was internal
      a7c79c08
    • M
      Rollup merge of #92112 - SparrowLii:issue92010, r=cjgillot · bd77fbfe
      Matthias Krüger 提交于
      Fix the error of checking `base_expr` twice in type_changing_struct_update
      
      Fixes #92010
      bd77fbfe
    • M
      Rollup merge of #90586 - jswrenn:relax-privacy-lints, r=petrochenkov · b57a6b38
      Matthias Krüger 提交于
      Relax priv-in-pub lint on generic bounds and where clauses of trait impls.
      
      The priv-in-pub lint is a legacy mechanism of the compiler, supplanted by a reachability-based [type privacy](https://github.com/rust-lang/rfcs/blob/master/text/2145-type-privacy.md) analysis. This PR does **not** relax type privacy; it only relaxes the lint (as proposed by the type privacy RFC) in the case of trait impls.
      
      ## Current Behavior
      On public trait impls, it's currently an **error** to have a `where` bound constraining a private type with a trait:
      ```rust
      pub trait Trait {}
      pub struct Type {}
      
      struct Priv {}
      impl Trait for Priv {}
      
      impl Trait for Type
      where
          Priv: Trait // ERROR
      {}
      ```
      
      ...and it's a **warning** to have have a public type constrained by a private trait:
      ```rust
      pub trait Trait {}
      pub struct Type {}
      
      pub struct Pub {}
      trait Priv {}
      impl Priv for Pub {}
      
      impl Trait for Type
      where
          Pub: Priv // WARNING
      {}
      ```
      
      This lint applies to `where` clauses in other contexts, too; e.g. on free functions:
      ```rust
      struct Priv<T>(T);
      pub trait Pub {}
      impl<T: Pub> Pub for Priv<T> {}
      
      pub fn function<T>()
      where
          Priv<T>: Pub // WARNING
      {}
      ```
      
      **These constraints could be relaxed without issue.**
      
      ## New Behavior
      This lint is relaxed for `where` clauses on trait impls, such that it's okay to have a `where` bound constraining a private type with a trait:
      ```rust
      pub trait Trait {}
      pub struct Type {}
      
      struct Priv {}
      impl Trait for Priv {}
      
      impl Trait for Type
      where
          Priv: Trait // OK
      {}
      ```
      
      ...and it's okay to have a public type constrained by a private trait:
      ```rust
      pub trait Trait {}
      pub struct Type {}
      
      pub struct Pub {}
      trait Priv {}
      impl Priv for Pub {}
      
      impl Trait for Type
      where
          Pub: Priv // OK
      {}
      ```
      
      ## Rationale
      While the priv-in-pub lint is not essential for soundness, it *can* help programmers avoid pitfalls that would make their libraries difficult to use by others. For instance, such a lint *is* useful for free functions; e.g. if a downstream crate tries to call the `function` in the previous snippet in a generic context:
      ```rust
      fn callsite<T>()
      where
          Priv<T>: Pub // ERROR: omitting this bound is a compile error, but including it is too
      {
          function::<T>()
      }
      ```
      ...it cannot do so without repeating `function`'s `where` bound, which we cannot do because `Priv` is out-of-scope. A lint for this case is arguably helpful.
      
      However, this same reasoning **doesn't** hold for trait impls. To call an unconstrained method on a public trait impl with private bounds, you don't need to forward those private bounds, you can forward the public trait:
      ```rust
      mod upstream {
          pub trait Trait {
              fn method(&self) {}
          }
          pub struct Type<T>(T);
      
          pub struct Pub<T>(T);
          trait Priv {}
          impl<T: Priv> Priv for Pub<T> {}
      
          impl<T> Trait for Type<T>
          where
              Pub<T>: Priv // WARNING
          {}
      }
      
      mod downstream {
          use super::upstream::*;
      
          fn function<T>(value: Type<T>)
          where
              Type<T>: Trait // <- no private deets!
          {
              value.method();
          }
      }
      ```
      
      **This PR only eliminates the lint on trait impls.** It leaves it intact for all other contexts, including trait definitions, inherent impls, and function definitions. It doesn't need to exist in those cases either, but I figured I'd first target a case where it's mostly pointless.
      
      ## Other Notes
      - See discussion [on zulip](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/relax.20priv-in-pub.20lint.20for.20trait.20impl.20.60where.60.20bounds/near/222458397).
      - This PR effectively reverts #79291.
      b57a6b38
  3. 27 12月, 2021 4 次提交
  4. 26 12月, 2021 2 次提交
  5. 25 12月, 2021 9 次提交
  6. 24 12月, 2021 11 次提交
    • 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