1. 29 7月, 2017 1 次提交
    • A
      syntax: Capture a `TokenStream` when parsing items · 4886ec86
      Alex Crichton 提交于
      This is then later used by `proc_macro` to generate a new
      `proc_macro::TokenTree` which preserves span information. Unfortunately this
      isn't a bullet-proof approach as it doesn't handle the case when there's still
      other attributes on the item, especially inner attributes.
      
      Despite this the intention here is to solve the primary use case for procedural
      attributes, attached to functions as outer attributes, likely bare. In this
      situation we should be able to now yield a lossless stream of tokens to preserve
      span information.
      4886ec86
  2. 28 7月, 2017 17 次提交
    • A
      Add a failing test for errors in proc macros · 036300aa
      Alex Crichton 提交于
      This test currently fails because the tokenization of an AST item during the
      expansion of a procedural macro attribute rounds-trips through strings, losing
      span information.
      036300aa
    • A
      proc_macro: Use an item's tokens if available · 36f2816a
      Alex Crichton 提交于
      This partly resolves the `FIXME` located in `src/libproc_macro/lib.rs` when
      interpreting interpolated tokens. All instances of `ast::Item` which have a list
      of tokens attached to them now use that list of tokens to losslessly get
      converted into a `TokenTree` instead of going through stringification and losing
      span information.
      
      cc #43081
      36f2816a
    • A
      syntax: Add `tokens: Option<TokenStream>` to Item · 9b2f7624
      Alex Crichton 提交于
      This commit adds a new field to the `Item` AST node in libsyntax to optionally
      contain the original token stream that the item itself was parsed from. This is
      currently `None` everywhere but is intended for use later with procedural
      macros.
      9b2f7624
    • B
      Auto merge of #43221 - MaulingMonkey:natvis-improvements, r=michaelwoerister · 6f815ca7
      bors 提交于
      Embed MSVC .natvis files into .pdbs and mangle debuginfo for &str, *T, and [T].
      
      No idea if these changes are reasonable - please feel free to suggest changes/rewrites.  And these are some of my first real commits to any rust codebase - *don't* be gentle, and nitpick away, I need to learn! ;)
      
      ### Overview
      Embedding `.natvis` files into `.pdb`s allows MSVC (and potentially other debuggers) to automatically pick up the visualizers without having to do any additional configuration (other than to perhaps add the relevant .pdb paths to symbol search paths.)
      
      The native debug engine for MSVC parses the type names, making various C++ish assumptions about what they mean and adding various limitations to valid type names.  `&str` cannot be matched against a visualizer, but if we emit `str&` instead, it'll be recognized as a reference to a `str`, solving the problem.  `[T]` is similarly problematic, but emitting `slice<T>` instead works fine as it looks like a template.  I've been unable to get e.g. `slice<u32>&` to match visualizers in VS2015u3, so I've gone with `str*` and `slice<u32>*` instead.
      
      ### Possible Issues
      * I'm not sure if `slice<T>` is a great mangling for `[T]` or if I should worry about name collisions.
      * I'm not sure if `linker.rs` is the right place to be enumerating natvis files.
      * I'm not sure if these type name mangling changes should actually be MSVC specific.  I recall seeing gdb visualizer tests that might be broken if made more general?  I'm hesitant to mess with them without a gdb install.  But perhaps I'm just wracking up technical debt.
        Should I try `pacman -S mingw-w64-x86_64-gdb` and to make things consistent?
      * I haven't touched `const` / `mut` yet, and I'm worried MSVC might trip up on `mut` or their placement.
      * I may like terse oneliners too much.
      * I don't know if there's broader implications for messing with debug type names here.
      * I may have been mistaken about bellow test failures being ignorable / unrelated to this changelist.
      
      ### Test Failures on `x86_64-pc-windows-gnu`
      
      ```
      ---- [debuginfo-gdb] debuginfo-gdb\associated-types.rs stdout ----
              thread '[debuginfo-gdb] debuginfo-gdb\associated-types.rs' panicked at 'gdb not available but debuginfo gdb debuginfo test requested', src\tools\compiletest\src\runtest.rs:48:16
      note: Run with `RUST_BACKTRACE=1` for a backtrace.
      
      [...identical panic causes omitted...]
      
      ---- [debuginfo-gdb] debuginfo-gdb\vec.rs stdout ----
              thread '[debuginfo-gdb] debuginfo-gdb\vec.rs' panicked at 'gdb not available but debuginfo gdb debuginfo test requested', src\tools\compiletest\src\runtest.rs:48:16
      ```
      
      ### Relevant Issues
      * https://github.com/rust-lang/rust/issues/40460 Metaissue for Visual Studio debugging Rust
      * https://github.com/rust-lang/rust/issues/36503 Investigate natvis for improved msvc debugging
      * https://github.com/PistonDevelopers/VisualRust/issues/160 Debug visualization of Rust data structures
      
      ### Pretty Pictures
      ![Collapsed Watch Window](https://user-images.githubusercontent.com/75894/28180998-e44c7516-67bb-11e7-8b48-d4f9605973ae.png)
      ![Expanded Watch Window](https://user-images.githubusercontent.com/75894/28181000-e8da252e-67bb-11e7-96b8-d613310c04dc.png)
      6f815ca7
    • B
      Auto merge of #43505 - eddyb:poly-const-eval-layout-of, r=nikomatsakis · 71678437
      bors 提交于
      rustc_const_eval: always require Substs and a ParamEnv.
      
      Fixes #43357 by tracking the `Substs` and `ParamEnv` for const-evaluation in generic contexts.
      71678437
    • B
      Auto merge of #43238 - estebank:try-on-unimplemented-2, r=alexcrichton · 4d5150ce
      bors 提交于
      Use `rustc_on_unimplemented`'s trait name argument in `try`
      
      Follow up to #43000 and #43001. Fix #42694.
      4d5150ce
    • B
      Auto merge of #43432 - pczarn:macro-parser-description, r=jseyfried · a9a07078
      bors 提交于
      Make the macro parser theory description more accurate
      
      The macro parser is described as an NFA, not an Earley parser.
      a9a07078
    • E
      4f7834e3
    • B
      Auto merge of #43217 - pnkfelix:alloc-requires-align-it-in-u32, r=alexcrichton · 63b3a03d
      bors 提交于
      Add precondition to `Layout` that the `align` fit in a u32.
      
      Add precondition to `Layout` that the `align` not exceed 2^31.
      
      This precondition takes the form of a behavorial change in `Layout::from_size_align` (so it returns `None` if the input `align` is too large) and a new requirement for safe usage of `Layout::from_size_align_unchecked`.
      
      Fix #30170.
      63b3a03d
    • B
      Auto merge of #43438 - petrochenkov:path, r=jseyfried · 8a78a12a
      bors 提交于
      syntax: Simplify parsing of paths
      
      Discern between `Path` and `Path<>` in AST (but not in HIR).
      Give span to angle bracketed generic arguments (`::<'a, T>` in `path::segment::<'a, T>`).
      
      This is a refactoring in preparation for https://internals.rust-lang.org/t/macro-path-uses-novel-syntax/5561/3, but it doesn't add anything to the grammar yet.
      
      r? @jseyfried
      8a78a12a
    • V
      1e8a7f68
    • V
      Give span to angle bracketed generic arguments · 128f565d
      Vadim Petrochenkov 提交于
      128f565d
    • V
      Discern between `Path` and `Path<>` in AST · ce3beb60
      Vadim Petrochenkov 提交于
      ce3beb60
    • V
      Simplify parsing of paths · da77a1a0
      Vadim Petrochenkov 提交于
      da77a1a0
    • B
      Auto merge of #43443 - bitshifter:issue-43317, r=nikomatsakis · 52a33096
      bors 提交于
      Improve checking of conflicting packed and align representation hints on structs and unions.
      
      Fixes #43317 and improves #33626.
      52a33096
    • E
      60cf5428
    • B
      Auto merge of #43482 - Mark-Simulacrum:single-rustdoc, r=alexcrichton · 5cc1baa2
      bors 提交于
      Compile rustdoc on-demand
      
      Fixes #43284, fixes #38318, and fixes #39505.
      
      Doesn't directly help with https://github.com/rust-lang/rust/issues/42686, since we need to rebuild just as much. In fact, this hurts it, since `./x.py doc --stage 0` will now fail. I'm not sure if it did before, but with these changes it runs into the problem where we attempt to use artifacts from bootstrap rustc with a non-bootstrap rustdoc, running into version conflicts. I believe this is solvable, but leaving for a future PR.
      
      This means that rustdoc will no longer be compiled when compiling rustc, by default. However, it is still built from `./x.py build` (for hosts, but not targets, since we don't produce compiler toolchains for them) and will be built for doc tests and crate tests.
      
      After this, the recommended workflow if you want a rustdoc is: `./x.py build --stage 1 src/tools/rustdoc` which will give you a working rustdoc in `build/triple/stage1/bin/rustdoc`. Note that you can add `src/libstd` onto the command to compile libstd as well so that the rustdoc can easily compile crates in the wild. `./x.py doc --stage 1 src/libstd` will document `libstd` with a freshly built rustdoc (if necessary), and will not rebuild rustc on modifications to rustdoc.
      
      r? @alexcrichton
      5cc1baa2
  3. 27 7月, 2017 20 次提交
  4. 26 7月, 2017 2 次提交