Skip to content
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

petrochenkov
Copy link
Contributor

@petrochenkov 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
Copy link
Contributor Author

cc @dtolnay @eddyb
r? @alexcrichton

@dtolnay

This comment has been minimized.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@alexcrichton
Copy link
Member

@bors: r+

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

@alexcrichton
Copy link
Member

@bors: r+

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Dec 10, 2018

📌 Commit 66a76b456801a4c409f5f7cfc2013e669dc04855 has been approved by alexcrichton

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Dec 10, 2018
@petrochenkov
Copy link
Contributor Author

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 10, 2018
@petrochenkov
Copy link
Contributor Author

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

@bors
Copy link
Contributor

bors commented Dec 10, 2018

📌 Commit 52d89f64fa3835229d8e4b495820a598b2b9bebc has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 10, 2018
@Centril
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
Copy link
Contributor

bors commented Dec 17, 2018

⌛ Testing commit 52d89f64fa3835229d8e4b495820a598b2b9bebc with merge 995baf76c1a4bf0b4e7ce8e604a168297c0c5806...

@bors
Copy link
Contributor

bors commented Dec 17, 2018

💔 Test failed - status-travis

@bors
Copy link
Contributor

bors commented Dec 19, 2018

📌 Commit f756257 has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 19, 2018
@petrochenkov
Copy link
Contributor Author

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 19, 2018
@petrochenkov
Copy link
Contributor Author

@bors r=alexcrichton

@bors
Copy link
Contributor

bors commented Dec 19, 2018

📌 Commit edab6c7 has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 19, 2018
@bors
Copy link
Contributor

bors commented Dec 20, 2018

⌛ Testing commit edab6c7 with merge 029fea7a15eca70cfe0bdd01e938a100c43c9b14...

@bors
Copy link
Contributor

bors commented Dec 20, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 20, 2018
@rust-highfive
Copy link
Collaborator

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
Copy link
Contributor Author

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

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 20, 2018
@bors
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
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
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
@petrochenkov petrochenkov deleted the dcrate2 branch June 5, 2019 16:24
Centril added a commit to Centril/rust that referenced this pull request Jul 10, 2019
…ulacrum

Fix pretty-printing of `$crate` (take 4)

Pretty-print `$crate` as `crate` or `crate_name` in unstructured tokens like `a $crate c` in `foo!(a $crate c)`, but only if those tokens are printed as a part of AST pretty-printing, rather than as a standalone token stream.

Fixes rust-lang#62325
Previous iterations - rust-lang#56647, rust-lang#57155, rust-lang#57915.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants