1. 10 9月, 2018 14 次提交
  2. 09 9月, 2018 9 次提交
    • B
      Auto merge of #53902 - dtolnay:group, r=petrochenkov · 40fc8ba5
      bors 提交于
      proc_macro::Group::span_open and span_close
      
      Before this addition, every delimited group like `(`...`)` `[`...`]` `{`...`}` has only a single Span that covers the full source location from opening delimiter to closing delimiter. This makes it impossible for a procedural macro to trigger an error pointing to just the opening or closing delimiter. The Rust compiler does not seem to have the same limitation:
      
      ```rust
      mod m {
          type T =
      }
      ```
      
      ```console
      error: expected type, found `}`
       --> src/main.rs:3:1
        |
      3 | }
        | ^
      ```
      
      On that same input, a procedural macro would be forced to trigger the error on the last token inside the block, on the entire block, or on the next token after the block, none of which is really what you want for an error like above.
      
      This commit adds `group.span_open()` and `group.span_close()` which access the Span associated with just the opening delimiter and just the closing delimiter of the group. Relevant to Syn as we implement real error messages for when parsing fails in a procedural macro: https://github.com/dtolnay/syn/issues/476.
      
      ```diff
        impl Group {
            fn span(&self) -> Span;
      +     fn span_open(&self) -> Span;
      +     fn span_close(&self) -> Span;
        }
      ```
      
      Fixes #48187
      r? @alexcrichton
      40fc8ba5
    • B
      Auto merge of #53998 - eddyb:issue-53728, r=oli-obk · df6ba0c4
      bors 提交于
      rustc_codegen_llvm: don't assume offsets are always aligned.
      
      Fixes #53728 by taking into account not just overall type alignment and the field's alignment when determining whether a field is aligned or not ("packed"), but also the field's offset within the type.
      
      Previously, rustc assumed that the offset was always at least as aligned as `min(struct.align, field.align)`. However, there's no real reason to have that assumption, and it obviously can't always be true after we implement `#[repr(align(N), pack(K))]`. There's also a case today where that assumption is not true, involving niche discriminants in enums:
      
      Suppose that we have the code in #53728:
      ```Rust
      #[repr(u16)]
      enum DeviceKind {
          Nil = 0,
      }
      
      #[repr(packed)]
      struct DeviceInfo {
          endianness: u8,
          device_kind: DeviceKind,
      }
      
      struct Wrapper {
          device_info: DeviceInfo,
          data: u32
      }
      ```
      
      Observe the layout of `Option<Wrapper>`. It has an alignment of 4 because of the `u32`. `device_info.device_kind` is a good niche field to use, which means the enum ends up with this layout:
      ```
      size = 8
      align = 4
      fields = [
          { offset=1, type=u16 } // discriminant, .<Some>.device_info.device_kind
      ]
      ```
      
      And here we have an discriminant with alignment 2 (`u16`) but offset 1.
      df6ba0c4
    • D
      Rename sp_lo to sp_open · 57d6ada9
      David Tolnay 提交于
      57d6ada9
    • B
      Auto merge of #53988 - eddyb:issue-53770, r=petrochenkov · 3d2fc456
      bors 提交于
      rustc_resolve: only prepend CrateRoot to a non-keyword segment.
      
      Fixes #53770 by treating `use` paths as absolute in a finer-grained manner, specifically:
      ```rust
      use {a, crate::b, self::c, super::d};
      ```
      Used to be interpreted as if it were (when `uniform_paths` is not enabled):
      ```rust
      use ::{a, crate::b, self::c, super::d};
      ```
      With this PR, the `CrateRoot` pseudo-keyword indicating an absolute path is only inserted when the first path segment is found (if it's not a keyword), i.e. the example behaves like:
      ```rust
      use {::a, crate::b, self::c, super::d};
      ```
      This should (finally) make `use {path};` fully equivalent to `use path;`.
      
      r? @petrochenkov cc @cramertj @joshtriplett @nikomatsakis
      3d2fc456
    • B
      Auto merge of #53960 - estebank:issue-51303, r=nagisa · dac76020
      bors 提交于
      Fix incorrect outer function type parameter message
      
      Fix #51303.
      dac76020
    • D
      Track distinct spans for open and close delimiter · a1dd39e7
      David Tolnay 提交于
      a1dd39e7
    • B
      Auto merge of #53949 - estebank:unclosed-delim, r=nikomatsakis · 004bc5a3
      bors 提交于
      Improve messages for un-closed delimiter errors
      004bc5a3
    • B
      Auto merge of #53909 - mikhail-m1:53643, r=nikomatsakis · 0198a1ea
      bors 提交于
      Skip a shared borrow of a immutable local variables
      
      issue #53643
      
      r? @nikomatsakis
      0198a1ea
    • B
      Auto merge of #53903 - GabrielMajeri:opt-miri-array-slice, r=oli-obk · 968d95e9
      bors 提交于
      Optimize miri checking of integer array/slices
      
      This pull request implements the optimization described in #53845 (the  `E-easy` part of that issue, not the refactoring). Instead of checking every element of an integral array, we can check the whole memory range at once.
      
      r? @RalfJung
      968d95e9
  3. 08 9月, 2018 17 次提交