New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework treatment of `$crate` in procedural macros #56647

Merged
merged 6 commits into from Dec 20, 2018

Conversation

Projects
None yet
6 participants
@petrochenkov
Copy link
Contributor

petrochenkov commented Dec 9, 2018

Important clarification: $crate below means "processed $crate" or "output $crate". In the input of a decl macro $crate is just two separate tokens, but in the output of a decl macro $crate is a single keyword identifier (#55640 (comment)).

First of all, this PR removes the eliminate_crate_var hack.
$crate::foo is no longer replaced with ::foo or ::crate_name::foo in the input of derive proc macros, it's passed to the macro instead with its precise span and hygiene data, and can be treated as any other path segment keyword (like crate or self) after that. (Note: eliminate_crate_var was never used for non-derive proc macros.)

This creates an annoying problem - derive macros still may stringify their input before processing and expect $crate survive that stringification and refer to the same crate (the Rust 1.15-1.29 way of doing things).
Moreover, the input of proc macro attributes and derives (but not fn-like proc macros) also effectively survives stringification before being passed to the macro (also for legacy implementation reasons).

So we kind of resurrect the eliminate_crate_var hack in reduced form, but apply it only to AST pretty-printing.
If an AST fragment is pretty-printed, the resulting text will have $crate replaced with crate or ::crate_name. This should be enough to keep all the legacy cases working.

Closes #55640
Closes #56622
r? @ghost

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Dec 9, 2018

@dtolnay

This comment was marked as resolved.

Copy link
Member

dtolnay commented Dec 9, 2018

In the input of a decl macro $crate is just two separate tokens, but in the output of a decl macro $crate is a single keyword identifier

Edit: missed the word "decl".

+1 for passing $ crate in as two tokens, particularly because the Rust grammar allows there to be whitespace in between.

Is it an error if a decl macro outputs $ crate as two tokens? It shouldn't be, because we want a decl macro that just does input.into_iter().collect() to be supported without needing further processing inside the macro.

@dtolnay

dtolnay approved these changes Dec 9, 2018

Copy link
Member

dtolnay left a comment

src/test/ui/proc-macro/dollar-crate.stdout looks good to me.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Dec 10, 2018

@bors: r+

This sounds like a solid strategy to me, thanks @petrochenkov!

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Dec 10, 2018

@bors: r+

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Dec 10, 2018

@bors: r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 10, 2018

📌 Commit 66a76b4 has been approved by alexcrichton

@petrochenkov petrochenkov force-pushed the petrochenkov:dcrate2 branch from 66a76b4 to 52d89f6 Dec 10, 2018

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Dec 10, 2018

@bors r-

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Dec 10, 2018

@bors r=alexcrichton
(Added a test with $crate referring to other crate.)

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 10, 2018

📌 Commit 52d89f6 has been approved by alexcrichton

Centril added a commit to Centril/rust that referenced this pull request Dec 16, 2018

Rollup merge of rust-lang#56647 - petrochenkov:dcrate2, r=alexcrichton
Rework treatment of `$crate` in procedural macros

Important clarification: `$crate` below means "processed `$crate`" or "output `$crate`". In the input of a decl macro `$crate` is just two separate tokens, but in the *output of a decl macro* `$crate` is a single keyword identifier (rust-lang#55640 (comment)).

First of all, this PR removes the `eliminate_crate_var` hack.
`$crate::foo` is no longer replaced with `::foo` or `::crate_name::foo` in the input of derive proc macros, it's passed to the macro instead with its precise span and hygiene data, and can be treated as any other path segment keyword (like `crate` or `self`) after that. (Note: `eliminate_crate_var` was never used for non-derive proc macros.)

This creates an annoying problem - derive macros still may stringify their input before processing and expect `$crate` survive that stringification and refer to the same crate (the Rust 1.15-1.29 way of doing things).
Moreover, the input of proc macro attributes and derives (but not fn-like proc macros) also effectively survives stringification before being passed to the macro (also for legacy implementation reasons).

So we kind of resurrect the `eliminate_crate_var` hack in reduced form, but apply it only to AST pretty-printing.
If an AST fragment is pretty-printed, the resulting *text* will have `$crate` replaced with `crate` or `::crate_name`. This should be enough to keep all the legacy cases working.

Closes rust-lang#55640
Closes rust-lang#56622
r? @ghost

bors added a commit that referenced this pull request Dec 16, 2018

Auto merge of #56873 - Centril:rollup, r=Centril
Rollup of 22 pull requests

Successful merges:

 - #53506 (Documentation for impl From for AtomicBool and other Atomic types)
 - #56343 (Remove not used mod)
 - #56439 (Clearer error message for dead assign)
 - #56640 (Add FreeBSD unsigned char platforms to std::os::raw)
 - #56647 (Rework treatment of `$crate` in procedural macros)
 - #56648 (Fix BTreeMap UB)
 - #56672 (Document time of back operations of a Linked List)
 - #56706 (Make `const unsafe fn` bodies `unsafe`)
 - #56737 (`TokenStream` improvements)
 - #56742 (infer: remove Box from a returned Iterator)
 - #56761 (Suggest using `.display()` when trying to print a `Path`)
 - #56781 (Update LLVM submodule)
 - #56789 (rustc: Add an unstable `simd_select_bitmask` intrinsic)
 - #56790 (Make RValue::Discriminant a normal Shallow read)
 - #56793 (rustdoc: look for comments when scraping attributes/crates from doctests)
 - #56826 (rustc: Add the `cmpxchg16b` target feature on x86/x86_64)
 - #56832 (std: Use `rustc_demangle` from crates.io)
 - #56844 (Improve CSS rule)
 - #56850 (Fixed issue with using `Self` ctor in typedefs)
 - #56855 (Remove u8 cttz hack)
 - #56857 (Fix a small mistake regarding NaNs in a deprecation message)
 - #56858 (Fix doc of `std::fs::canonicalize`)

Failed merges:

r? @ghost
@Centril

This comment has been minimized.

Copy link
Contributor

Centril commented Dec 16, 2018

This PR might have failed #56873 (comment); might possibly also have been due to being combined with #56737.

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 17, 2018

⌛️ Testing commit 52d89f6 with merge 995baf7...

bors added a commit that referenced this pull request Dec 17, 2018

Auto merge of #56647 - petrochenkov:dcrate2, r=alexcrichton
Rework treatment of `$crate` in procedural macros

Important clarification: `$crate` below means "processed `$crate`" or "output `$crate`". In the input of a decl macro `$crate` is just two separate tokens, but in the *output of a decl macro* `$crate` is a single keyword identifier (#55640 (comment)).

First of all, this PR removes the `eliminate_crate_var` hack.
`$crate::foo` is no longer replaced with `::foo` or `::crate_name::foo` in the input of derive proc macros, it's passed to the macro instead with its precise span and hygiene data, and can be treated as any other path segment keyword (like `crate` or `self`) after that. (Note: `eliminate_crate_var` was never used for non-derive proc macros.)

This creates an annoying problem - derive macros still may stringify their input before processing and expect `$crate` survive that stringification and refer to the same crate (the Rust 1.15-1.29 way of doing things).
Moreover, the input of proc macro attributes and derives (but not fn-like proc macros) also effectively survives stringification before being passed to the macro (also for legacy implementation reasons).

So we kind of resurrect the `eliminate_crate_var` hack in reduced form, but apply it only to AST pretty-printing.
If an AST fragment is pretty-printed, the resulting *text* will have `$crate` replaced with `crate` or `::crate_name`. This should be enough to keep all the legacy cases working.

Closes #55640
Closes #56622
r? @ghost
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 17, 2018

💔 Test failed - status-travis

@petrochenkov petrochenkov force-pushed the petrochenkov:dcrate2 branch from a5d4544 to f756257 Dec 19, 2018

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Dec 19, 2018

@bors r=alexcrichton

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 19, 2018

📌 Commit f756257 has been approved by alexcrichton

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Dec 19, 2018

@bors r-

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Dec 19, 2018

@bors r=alexcrichton

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 19, 2018

📌 Commit edab6c7 has been approved by alexcrichton

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 20, 2018

⌛️ Testing commit edab6c7 with merge 029fea7...

bors added a commit that referenced this pull request Dec 20, 2018

Auto merge of #56647 - petrochenkov:dcrate2, r=alexcrichton
Rework treatment of `$crate` in procedural macros

Important clarification: `$crate` below means "processed `$crate`" or "output `$crate`". In the input of a decl macro `$crate` is just two separate tokens, but in the *output of a decl macro* `$crate` is a single keyword identifier (#55640 (comment)).

First of all, this PR removes the `eliminate_crate_var` hack.
`$crate::foo` is no longer replaced with `::foo` or `::crate_name::foo` in the input of derive proc macros, it's passed to the macro instead with its precise span and hygiene data, and can be treated as any other path segment keyword (like `crate` or `self`) after that. (Note: `eliminate_crate_var` was never used for non-derive proc macros.)

This creates an annoying problem - derive macros still may stringify their input before processing and expect `$crate` survive that stringification and refer to the same crate (the Rust 1.15-1.29 way of doing things).
Moreover, the input of proc macro attributes and derives (but not fn-like proc macros) also effectively survives stringification before being passed to the macro (also for legacy implementation reasons).

So we kind of resurrect the `eliminate_crate_var` hack in reduced form, but apply it only to AST pretty-printing.
If an AST fragment is pretty-printed, the resulting *text* will have `$crate` replaced with `crate` or `::crate_name`. This should be enough to keep all the legacy cases working.

Closes #55640
Closes #56622
r? @ghost
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 20, 2018

💔 Test failed - status-travis

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Dec 20, 2018

The job dist-various-1 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
[01:06:02] CC_armebv7r_none_eabi=arm-none-eabi-gcc
[01:06:02] S=/checkout
[01:06:02] _=/bin/sh
[01:06:02] TOOLSTATE_REPO_ACCESS_TOKEN=[secure]
[01:06:02] TRAVIS=true
[01:06:02] RUST_RELEASE_CHANNEL=nightly
[01:06:02] PATH=/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[01:06:02] RUN_MAKE_TARGETS=thumbv6m-none-eabi,thumbv7m-none-eabi,thumbv7em-none-eabi,thumbv7em-none-eabihf
[01:06:02] RUSTC=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc
[01:06:02] RUST_BUILD_STAGE=stage2-thumbv6m-none-eabi
[01:06:02] BOOTSTRAP_PYTHON=/usr/bin/python2.7
[01:06:02] SCRIPT=python2.7 ../x.py test --target thumbv6m-none-eabi,thumbv7m-none-eabi,thumbv7em-none-eabi,thumbv7em-none-eabihf src/test/run-make &&       python2.7 ../x.py dist --target asmjs-unknown-emscripten,wasm32-unknown-emscripten,x86_64-rumprun-netbsd,mips-unknown-linux-musl,mipsel-unknown-linux-musl,arm-unknown-linux-musleabi,arm-unknown-linux-musleabihf,armv5te-unknown-linux-gnueabi,armv5te-unknown-linux-musleabi,armv7-unknown-linux-musleabihf,aarch64-unknown-linux-musl,sparc64-unknown-linux-gnu,x86_64-unknown-redox,thumbv6m-none-eabi,thumbv7m-none-eabi,thumbv7em-none-eabi,thumbv7em-none-eabihf,riscv32imc-unknown-none-elf,riscv32imac-unknown-none-elf,armebv7r-none-eabi,armebv7r-none-eabihf,armv7r-none-eabi,armv7r-none-eabihf
[01:06:02] AR=ar
[01:06:02] TRAVIS_BRANCH=auto
[01:06:02] RUSTC_BOOTSTRAP=1
[01:06:02] HOST_RPATH_DIR=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib
[01:06:02] SCCACHE_BUCKET=rust-lang-ci-sccache2
[01:06:02] PWD=/checkout/obj
[01:06:02] CI_JOB_NAME=dist-various-1
[01:06:02] TARGET_RPATH_DIR=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/thumbv6m-none-eabi/lib
[01:06:02] LD_LIB_PATH_ENVVAR=LD_LIBRARY_PATH
[01:06:02] PYTHON=/usr/bin/python2.7
[01:06:02] HOME=/home/user
[01:06:02] LD_LIBRARY_PATH=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib
[01:06:02] HOSTNAME=ad7265132efd
[01:06:02] CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc
[01:06:02] SHLVL=2
[01:06:02] CC= 
[01:06:02] BUILD_DIR=/checkout/obj/build
[01:06:02] BUILD_DIR=/checkout/obj/build
[01:06:02] RUST_TEST_TMPDIR=/checkout/obj/build/tmp
[01:06:02] LLVM_CXXFLAGS=
[01:06:02] RUSTFLAGS=--cap-lints=allow
[01:06:02] STAGING_DIR=/tmp
[01:06:02] TMPDIR=/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/thumb-none-cortex-m/thumb-none-cortex-m
[01:06:02] TARGETS=asmjs-unknown-emscripten,wasm32-unknown-emscripten,x86_64-rumprun-netbsd,mips-unknown-linux-musl,mipsel-unknown-linux-musl,arm-unknown-linux-musleabi,arm-unknown-linux-musleabihf,armv5te-unknown-linux-gnueabi,armv5te-unknown-linux-musleabi,armv7-unknown-linux-musleabihf,aarch64-unknown-linux-musl,sparc64-unknown-linux-gnu,x86_64-unknown-redox,thumbv6m-none-eabi,thumbv7m-none-eabi,thumbv7em-none-eabi,thumbv7em-none-eabihf,riscv32imc-unknown-none-elf,riscv32imac-unknown-none-elf,armebv7r-none-eabi,armebv7r-none-eabihf,armv7r-none-eabi,armv7r-none-eabihf
[01:06:02] RUST_CONFIGURE_ARGS=--musl-root-armv5te=/musl-armv5te       --musl-root-arm=/musl-arm       --musl-root-armhf=/musl-armhf       --musl-root-armv7=/musl-armv7       --musl-root-aarch64=/musl-aarch64       --musl-root-mips=/musl-mips       --musl-root-mipsel=/musl-mipsel       --enable-emscripten       --disable-docs --set build.print-step-timings --enable-verbose-tests --enable-sccache --disable-manage-submodules --enable-locked-deps --enable-cargo-native-static --set rust.codegen-units-std=1 --disable-dist-src --release-channel=nightly --enable-llvm-static-stdcpp --set rust.remap-debuginfo --enable-missing-tools
[01:06:02] MAKEFLAGS=
[01:06:02] MFLAGS=
[01:06:02] BOOTSTRAP_PARENT_ID=1084
[01:06:02] BOOTSTRAP_PARENT_ID=1084
[01:06:02] __COMPAT_LAYER=RunAsInvoker
[01:06:02] CC_x86_64_unknown_redox=x86_64-unknown-redox-gcc
[01:06:02] BUILD=x86_64-unknown-linux-gnu
[01:06:02] CXX= 
[01:06:02] AWS_ACCESS_KEY_ID=[secure]
[01:06:02] CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc
[01:06:02] CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc
[01:06:02] CARGO_HOME=/cargo
[01:06:02] RUSTC_LINKER=arm-none-eabi-gcc
[01:06:02] SCCACHE_REGION=us-west-1
[01:06:02] CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc
[01:06:02] LLVM_COMPONENTS=
[01:06:02] TERM=xterm
[01:06:02] MAKELEVEL=1
[01:06:02] mkdir -p /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/thumb-none-cortex-m/thumb-none-cortex-m
[01:06:02] cd /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/thumb-none-cortex-m/thumb-none-cortex-m && rm -rf cortex-m
[01:06:02] cd /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/thumb-none-cortex-m/thumb-none-cortex-m && bash -x /checkout/src/test/run-make/thumb-none-cortex-m/../git_clone_sha1.sh cortex-m https://github.com/rust-embedded/cortex-m a448e9156e2cb1e556e5441fd65426952ef4b927 
[01:06:02] Makefile:31: recipe for target 'all' failed
[01:06:02] 
[01:06:02] ------------------------------------------
[01:06:02] stderr:
[01:06:02] stderr:
[01:06:02] ------------------------------------------
[01:06:02] + PROJECT_NAME=cortex-m
[01:06:02] + URL=https://github.com/rust-embedded/cortex-m
[01:06:02] + SHA1=a448e9156e2cb1e556e5441fd65426952ef4b927
[01:06:02] + git clone https://github.com/rust-embedded/cortex-m cortex-m
[01:06:02] Cloning into 'cortex-m'...
[01:06:02] fatal: unable to access 'https://github.com/rust-embedded/cortex-m/': Could not resolve host: github.com
[01:06:02] + err_exit
[01:06:02] + echo ERROR:
[01:06:02] + exit 1
[01:06:02] make: *** [all] Error 1
[01:06:02] ------------------------------------------
[01:06:02] 
[01:06:02] thread '[run-make] run-make/thumb-none-cortex-m' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3255:9
[01:06:02] note: Run with `RUST_BACKTRACE=1` for a backtrace.
---
[01:06:02] status: exit code: 2
[01:06:02] command: "make"
[01:06:02] stdout:
[01:06:02] ------------------------------------------
[01:06:02] bash script.sh
[01:06:02] AWS_ACCESS_KEY_ID=[secure]
[01:06:02] AWS_SECRET_ACCESS_KEY=[secure]
[01:06:02] BOOTSTRAP_PARENT_ID=1084
[01:06:02] BOOTSTRAP_PYTHON=/usr/bin/python2.7
[01:06:02] BUILD_DIR=/checkout/obj/build
[01:06:02] CARGO=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo
[01:06:02] CARGO_HOME=/cargo
[01:06:02] CC_armebv7r_none_eabi=arm-none-eabi-gcc
[01:06:02] CC_armebv7r_none_eabi=arm-none-eabi-gcc
[01:06:02] CC_mips_unknown_linux_musl=mips-openwrt-linux-gcc
[01:06:02] CC_mipsel_unknown_linux_musl=mipsel-openwrt-linux-gcc
[01:06:02] CC_sparc64_unknown_linux_gnu=sparc64-linux-gnu-gcc
[01:06:02] CC_x86_64_unknown_redox=x86_64-unknown-redox-gcc
[01:06:02] CI_JOB_NAME=dist-various-1
[01:06:02] DEPLOY=1
[01:06:02] HERE=/checkout/src/test/run-make/thumb-none-qemu
[01:06:02] HOME=/home/user
[01:06:02] HOSTNAME=ad7265132efd
[01:06:02] HOST_RPATH_DIR=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib
[01:06:02] LD_LIBRARY_PATH=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib
[01:06:02] LD_LIB_PATH_ENVVAR=LD_LIBRARY_PATH
[01:06:02] LLVM_CXXFLAGS=
[01:06:02] MAKEFLAGS=
[01:06:02] MAKELEVEL=1
[01:06:02] MFLAGS=
[01:06:02] MFLAGS=
[01:06:02] PATH=/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[01:06:02] PWD=/checkout/src/test/run-make/thumb-none-qemu
[01:06:02] PYTHON=/usr/bin/python2.7
[01:06:02] RUN_MAKE_TARGETS=thumbv6m-none-eabi,thumbv7m-none-eabi,thumbv7em-none-eabi,thumbv7em-none-eabihf
[01:06:02] RUSTC=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc
[01:06:02] RUST_CONFIGURE_ARGS=--musl-root-armv5te=/musl-armv5te       --musl-root-arm=/musl-arm       --musl-root-armhf=/musl-armhf       --musl-root-armv7=/musl-armv7       --musl-root-aarch64=/musl-aarch64       --musl-root-mips=/musl-mips       --musl-root-mipsel=/musl-mipsel       --enable-emscripten       --disable-docs --set build.print-step-timings --enable-verbose-tests --enable-sccache --disable-manage-submodules --enable-locked-deps --enable-cargo-native-static --set rust.codegen-units-std=1 --disable-dist-src --release-channel=nightly --enable-llvm-static-stdcpp --set rust.remap-debuginfo --enable-missing-tools
[01:06:02] RUST_RELEASE_CHANNEL=nightly
[01:06:02] S=/checkout
[01:06:02] SCCACHE_BUCKET=rust-lang-ci-sccache2
[01:06:02] SCCACHE_REGION=us-west-1
[01:06:02] SCRIPT=python2.7 ../x.py test --target thumbv6m-none-eabi,thumbv7m-none-eabi,thumbv7em-none-eabi,thumbv7em-none-eabihf src/test/run-make &&       python2.7 ../x.py dist --target asmjs-unknown-emscripten,wasm32-unknown-emscripten,x86_64-rumprun-netbsd,mips-unknown-linux-musl,mipsel-unknown-linux-musl,arm-unknown-linux-musleabi,arm-unknown-linux-musleabihf,armv5te-unknown-linux-gnueabi,armv5te-unknown-linux-musleabi,armv7-unknown-linux-musleabihf,aarch64-unknown-linux-musl,sparc64-unknown-linux-gnu,x86_64-unknown-redox,thumbv6m-none-eabi,thumbv7m-none-eabi,thumbv7em-none-eabi,thumbv7em-none-eabihf,riscv32imc-unknown-none-elf,riscv32imac-unknown-none-elf,armebv7r-none-eabi,armebv7r-none-eabihf,armv7r-none-eabi,armv7r-none-eabihf
[01:06:02] SHLVL=3
[01:06:02] SRC=/checkout
[01:06:02] STAGING_DIR=/tmp
[01:06:02] TARGET=thumbv6m-none-eabi
[01:06:02] TARGETS=asmjs-unknown-emscripten,wasm32-unknown-emscripten,x86_64-rumprun-netbsd,mips-unknown-linux-musl,mipsel-unknown-linux-musl,arm-unknown-linux-musleabi,arm-unknown-linux-musleabihf,armv5te-unknown-linux-gnueabi,armv5te-unknown-linux-musleabi,armv7-unknown-linux-musleabihf,aarch64-unknown-linux-musl,sparc64-unknown-linux-gnu,x86_64-unknown-redox,thumbv6m-none-eabi,thumbv7m-none-eabi,thumbv7em-none-eabi,thumbv7em-none-eabihf,riscv32imc-unknown-none-elf,riscv32imac-unknown-none-elf,armebv7r-none-eabi,armebv7r-none-eabihf,armv7r-none-eabi,armv7r-none-eabihf
[01:06:02] TARGET_RPATH_DIR=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/thumbv6m-none-eabi/lib
[01:06:02] TERM=xterm
[01:06:02] TMPDIR=/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/thumb-none-qemu/thumb-none-qemu
[01:06:02] TRAVIS=true
[01:06:02] TRAVIS_BRANCH=auto
[01:06:02] TRAVIS_BRANCH=auto
[01:06:02] WORK_DIR=/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/thumb-none-qemu/thumb-none-qemu
[01:06:02] _=/usr/bin/env
[01:06:02] __COMPAT_LAYER=RunAsInvoker
[01:06:02] /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/thumb-none-qemu/thumb-none-qemu /checkout/src/test/run-make/thumb-none-qemu
[01:06:02] /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/thumb-none-qemu/thumb-none-qemu/example /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/thumb-none-qemu/thumb-none-qemu /checkout/src/test/run-make/thumb-none-qemu
[01:06:02] Makefile:27: recipe for target 'all' failed
[01:06:02] ------------------------------------------
[01:06:02] stderr:
[01:06:02] ------------------------------------------
[01:06:02] ------------------------------------------
[01:06:02] + CRATE=example
[01:06:02] + env
[01:06:02] + sort
[01:06:02] + mkdir -p /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/thumb-none-qemu/thumb-none-qemu
[01:06:02] + pushd /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make/thumb-none-qemu/thumb-none-qemu
[01:06:02] + rm -rf example
[01:06:02] + cp -a /checkout/src/test/run-make/thumb-none-qemu/example .
[01:06:02] + pushd example
[01:06:02] + grep 'x = 42'
[01:06:02] + env RUSTC_BOOTSTRAP=1 'RUSTFLAGS=-C linker=arm-none-eabi-ld -C link-arg=-Tlink.x' /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo run --target thumbv6m-none-eabi
[01:06:02] warning: spurious network error (2 tries remaining): curl error: Could not resolve host: github.com
[01:06:02] ; class=Net (12)
[01:06:02] warning: spurious network error (1 tries remaining): curl error: Could not resolve host: github.com
[01:06:02] ; class=Net (12)
[01:06:02] ; class=Net (12)
[01:06:02] error: failed to load source for a dependency on `cortex-m`
[01:06:02] Caused by:
[01:06:02]   Unable to update registry `https://github.com/rust-lang/crates.io-index`
[01:06:02] 
[01:06:02] Caused by:
[01:06:02] Caused by:
[01:06:02]   failed to fetch `https://github.com/rust-lang/crates.io-index`
[01:06:02] 
[01:06:02] Caused by:
[01:06:02]   curl error: Could not resolve host: github.com
[01:06:02] ; class=Net (12)
[01:06:02] make: *** [all] Error 1
[01:06:02] ------------------------------------------
[01:06:02] 
[01:06:02] thread '[run-make] run-make/thumb-none-qemu' panicked at 'explicit panic', src/tools/compiletest/src/runtest.rs:3255:9
[01:06:02] 
---
[01:06:02] 
[01:06:02] thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:503:22
[01:06:02] 
[01:06:02] 
[01:06:02] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/thumbv6m-none-eabi/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/run-make" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make" "--stage-id" "stage2-thumbv6m-none-eabi" "--mode" "run-make" "--target" "thumbv6m-none-eabi" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--linker" "arm-none-eabi-gcc" "--host-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/thumbv6m-none-eabi/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--llvm-version" "8.0.0svn\n" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:06:02] 
[01:06:02] 
[01:06:02] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test --target thumbv6m-none-eabi,thumbv7m-none-eabi,thumbv7em-none-eabi,thumbv7em-none-eabihf src/test/run-make
[01:06:02] Build completed unsuccessfully in 1:02:27
---
travis_time:end:1270d4f0:start=1545290499090501603,finish=1545290499100758313,duration=10256710
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0abc74eb
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:100c4850
travis_time:start:100c4850
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:0adfcbe0
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@petrochenkov

This comment has been minimized.

Copy link
Contributor

petrochenkov commented Dec 20, 2018

Spurious (Could not resolve host: github.com).
@bors retry

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 20, 2018

⌛️ Testing commit edab6c7 with merge 9622f9d...

bors added a commit that referenced this pull request Dec 20, 2018

Auto merge of #56647 - petrochenkov:dcrate2, r=alexcrichton
Rework treatment of `$crate` in procedural macros

Important clarification: `$crate` below means "processed `$crate`" or "output `$crate`". In the input of a decl macro `$crate` is just two separate tokens, but in the *output of a decl macro* `$crate` is a single keyword identifier (#55640 (comment)).

First of all, this PR removes the `eliminate_crate_var` hack.
`$crate::foo` is no longer replaced with `::foo` or `::crate_name::foo` in the input of derive proc macros, it's passed to the macro instead with its precise span and hygiene data, and can be treated as any other path segment keyword (like `crate` or `self`) after that. (Note: `eliminate_crate_var` was never used for non-derive proc macros.)

This creates an annoying problem - derive macros still may stringify their input before processing and expect `$crate` survive that stringification and refer to the same crate (the Rust 1.15-1.29 way of doing things).
Moreover, the input of proc macro attributes and derives (but not fn-like proc macros) also effectively survives stringification before being passed to the macro (also for legacy implementation reasons).

So we kind of resurrect the `eliminate_crate_var` hack in reduced form, but apply it only to AST pretty-printing.
If an AST fragment is pretty-printed, the resulting *text* will have `$crate` replaced with `crate` or `::crate_name`. This should be enough to keep all the legacy cases working.

Closes #55640
Closes #56622
r? @ghost
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Dec 20, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing 9622f9d to master...

@bors bors merged commit edab6c7 into rust-lang:master Dec 20, 2018

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment