1. 14 12月, 2020 8 次提交
    • G
      Rollup merge of #79918 - woodruffw-forks:ww/doc-initializer-side-effects, r=dtolnay · 5d8b2a5b
      Guillaume Gomez 提交于
      doc(array,vec): add notes about side effects when empty-initializing
      
      Copying some context from a conversation in the Rust discord:
      
      * Both `vec![T; 0]` and `[T; 0]` are syntactically valid, and produce empty containers of their respective types
      
      * Both *also* have side effects:
      
      ```rust
      fn side_effect() -> String {
          println!("side effect!");
      
          "foo".into()
      }
      
      fn main() {
          println!("before!");
      
          let x = vec![side_effect(); 0];
      
          let y = [side_effect(); 0];
      
          println!("{:?}, {:?}", x, y);
      }
      ```
      
      produces:
      
      ```
      before!
      side effect!
      side effect!
      [], []
      ```
      
      This PR just adds two small notes to each's documentation, warning users that side effects can occur.
      
      I've also submitted a clippy proposal: https://github.com/rust-lang/rust-clippy/issues/6439
      5d8b2a5b
    • B
      Auto merge of #79959 - JohnTitor:tidy-entries, r=petrochenkov · 3c45bff2
      bors 提交于
      Check the number of entries in UI test on tidy
      
      This helps #73494 to be resolved.
      
      r? `@petrochenkov`
      3c45bff2
    • B
      Auto merge of #79944 - sivadeilra:syms_proc_macro_testing, r=petrochenkov · 331e7401
      bors 提交于
      Improve error handling in `symbols` proc-macro
      
      This improves how the `symbols` proc-macro handles errors.
      If it finds an error in its input, the macro does not panic.
      Instead, it still produces an output token stream. That token
      stream will contain `compile_error!(...)` macro invocations.
      This will still cause compilation to fail (which is what we want),
      but it will prevent meaningless errors caused by the output not
      containing symbols that the macro normally generates.
      
      This solves a small (but annoying) problem. When you're editing
      rustc_span/src/symbol.rs, and you get something wrong (dup
      symbol name, misordered symbol), you want to get only the errors
      that are relevant, not a burst of errors that are irrelevant.
      This change also uses the correct Span when reporting errors,
      so you get errors that point to the correct place in
      rustc_span/src/symbol.rs where something is wrong.
      
      This also adds several unit tests which test the `symbols` proc-macro.
      
      This commit also makes it easy to run the `symbols` proc-macro
      as an ordinary Cargo test. Just run `cargo test`. This makes it
      easier to do development on the macro itself, such as running it
      under a debugger.
      
      This commit also uses the `Punctuated` type in `syn` for parsing
      comma-separated lists, rather than doing it manually.
      
      The output of the macro is not changed at all by this commit,
      so rustc should be completely unchanged. This just improves
      quality of life during development.
      331e7401
    • Y
      Check the number of entries in UI test · adda964b
      Yuki Okushi 提交于
      adda964b
    • B
      Auto merge of #80005 - ssomers:btree_cleanup_3, r=Mark-Simulacrum · 7feab000
      bors 提交于
      BTreeMap: declare clear_parent_link directly on the root it needs
      
      r? `@Mark-Simulacrum`
      7feab000
    • A
      ./x.py fmt · 1a5b9b03
      Arlie Davis 提交于
      1a5b9b03
    • B
      Auto merge of #79978 - Aaron1011:fix/capture-broken-token, r=petrochenkov · 803c6021
      bors 提交于
      Properly capture trailing 'unglued' token
      
      If we try to capture the `Vec<u8>` in `Option<Vec<u8>>`, we'll
      need to capture a `>` token which was 'unglued' from a `>>` token.
      The processing of unglueing a token for parsing purposes bypasses the
      usual capturing infrastructure, so we currently lose the trailing `>`.
      As a result, we fall back to the reparsed `TokenStream`, causing us to
      lose spans.
      
      This commit makes token capturing keep track of a trailing 'unglued'
      token. Note that we don't need to care about unglueing except at the end
      of the captured tokens - if we capture both the first and second unglued
      tokens, then we'll end up capturing the full 'glued' token, which
      already works correctly.
      803c6021
    • B
      Auto merge of #79987 - ssomers:btree_cleanup_4, r=Mark-Simulacrum · 69ff39ee
      bors 提交于
      BTreeMap: detect bulk_steal's count-1 underflow in release builds too
      
      r? `@Mark-Simulacrum`
      69ff39ee
  2. 13 12月, 2020 32 次提交