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

Remove usages of Term::as_str and mark it for removal #49823

Merged
merged 1 commit into from
May 10, 2018

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Apr 9, 2018

Returning references to rustc internal data structures is a bad idea since their lifetimes are unrelated to the lifetimes of proc_macro values.

See #46972 and the Taming thread-local storage section of https://internals.rust-lang.org/t/parallelizing-rustc-using-rayon/6606

r? @alexcrichton

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 9, 2018
@TimNN
Copy link
Contributor

TimNN commented Apr 9, 2018

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.
[00:00:47] configure: rust.quiet-tests     := True
---
[00:06:58] error[E0599]: no method named `as_str` found for type `&Term` in the current scope
[00:06:58]    --> libproc_macro/lib.rs:736:14
[00:06:58]     |
[00:06:58] 736 |         self.as_str().fmt(f)
[00:06:58]     |              ^^^^^^
[00:06:58]
[00:06:59] error[E0599]: no method named `as_str` found for type `Term` in the current scope
[00:06:59]    --> libproc_macro/quote.rs:186:40
[00:06:59]     |
[00:06:59] 186 |         quote!(::Term::new((quote self.as_str()), (quote self.span())))
[00:06:59]     |                                        ^^^^^^
[00:06:59]     |
[00:06:59]    ::: libproc_macro/lib.rs:686:1
[00:06:59]     |
[00:06:59] 686 | pub struct Term {
[00:06:59]     | --------------- method `as_str` not found for this
[00:06:59]
[00:06:59] error: aborting due to 2 previous errors
[00:06:59]
[00:06:59] For more information about this error, try `rustc --explain E0599`.
[00:06:59] error: Could not compile `proc_macro`.
[00:06:59]
[00:06:59] Caused by:
[00:06:59]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc --crate-name proc_macro libproc_macro/lib.rs --color always --error-format json --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 -C metadata=6e4119b5ec8457a3 -C extra-filename=-6e4119b5ec8457a3 --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps --extern rustc_data_structures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_data_structures-93cb1ddd29ab61a4.so --extern syntax=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax-d3b6fcf798f7d22a.so --extern rustc_errors=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_errors-609e2421d03f9c9a.so --extern syntax_pos=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax_pos-9f3518d56a01456f.so` (exit code: 101)
[00:06:59] warning: build failed, waiting for other jobs to finish...
[00:07:09] error: build failed
[00:07:09] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "--release" "--locked" "--color" "always" "--features" " jemalloc" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json"
[00:07:09] expected success, got: exit code: 101
[00:07:09] thread 'main' panicked at 'cargo must succeed', bootstrap/compile.rs:1085:9
[00:07:09] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[00:07:09] travis_fold:end:stage0-rustc
[00:07:09] travis_time:end:stage0-rustc:start=1523311840034999165,finish=1523311976282252106,duration=136247252941
[00:07:09] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap build
[00:07:09] Build completed unsuccessfully in 0:02:29
[00:07:09] Makefile:28: recipe for target 'all' failed
[00:07:09] make: *** [all] Error 1
---
121664 ./obj/build/bootstrap/debug/incremental/bootstrap-351vorei3hhuv/s-ezyvpuqw47-r07ced-179sb4yv5t1yk
---
10012 ./src/llvm/test/MC/AMDGPU
9648 ./src/llvm/test/MC/Disassembler/AMDGPU
---
$ ls -lat $HOME/Library/Logs/DiagnosticReports/
ls: cannot access /home/travis/Library/Logs/DiagnosticReports/: No such file or directory
travis_time:end:040871be:start=1523311976827397498,finish=1523311976834701564,duration=7304066
travis_fold:end:after_failure.2
travis_fold:start:after_failure.3
travis_time:start:1aa653d0
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'co

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)

@TimNN
Copy link
Contributor

TimNN commented Apr 9, 2018

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.
[00:00:47] configure: rust.quiet-tests     := True
---
[00:45:35] ............................................................................i.......................
[00:45:41] ...................i................................................................................
---
[00:46:17] .................................................................................................i..
[00:46:25] .......................................................................i............................
---
[00:47:22] .............................................i......................................................
---
[00:51:22] .............................i......................................................................
[00:51:37] ..............................................................i.....................................
[00:51:53] ...............................................i....................................................
[00:52:13] ....................................................................................................
[00:52:35] ....................................................................................................
[00:52:57] ....................................................................................................
[00:53:22] ...i...............................................................................................i
[00:53:49] ..................................................................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:53:59] ..................
[00:54:29] ....................................................................................................
[00:55:04] .................................................................ii.................................
[00:55:51] ............................i....................................................i.ii.....test [run-pass] run-pass/saturating-float-casts.rs has been running for over 60 seconds
[00:55:56] ..........
[00:56:36] .........................................................................................iiiiiii....
---
[00:58:51] ...................i............................................................ii.iii..............
[00:58:58] ....................................................................................................
[00:59:06] .........i..............................i...........................................................
[00:59:14] ....................................................................................................
[00:59:21] .....................i..............................................................................
[00:59:29] ....................................................................................................
[00:59:39] ....................................................................................................
[00:59:50] ....................................................................................................
[01:00:01] ....................................................................................................
[01:00:14] ....................................................................................................
[01:00:23] ..............i.....................................................................................
[01:00:32] ..................i..ii.............................................................................
[01:00:43] ....................................................................................................
[01:00:53] ....................................................................................................
[01:01:02] .....................................................................................i..............
[01:01:13] ...............................i....................................................................
---
[01:01:51] ...........................i........................................................................
[01:01:52] ....................................................................i...............................
[01:01:54] ................i.......................................................
---
[01:02:09] .............i........................
---
[01:02:39] i...i..ii....i.............ii.........iii......i..i...i...ii..i..i..ii.....
---
[01:02:43] i.......i......................i.......
---
[01:03:22] iiii.......i..i........i..i.i.............i..........iiii...........i...i..........ii.i.i.......ii..
[01:03:24] ....ii...
---
[01:05:21] ...................................F......................................test [run-pass] run-pass-fulldeps/myriad-closures.rs has been running for over 60 seconds
---
[01:07:45] error: auxiliary build of "/checkout/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs" failed to compile:
[01:07:45] status: exit code: 101
[01:07:45] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass-fulldeps" "--target=x86_64-unknown-linux-gnu" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass-fulldeps/macro-quote-cond.stage2-x86_64-unknown-linux-gnu.aux" "-Crpath" "-O" "-Zmiri" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass-fulldeps/macro-quote-cond.stage2-x86_64-unknown-linux-gnu.aux"
---
[01:07:45] error[E0599]: no method named `as_str` found for type `proc_macro::Term` in the current scope
[01:07:45]   --> /checkout/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs:36:43
[01:07:45]    |
[01:07:45] 36 |             TokenTree::Term(word) => word.as_str() == "else",
---
[01:07:45] 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/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/run-pass-fulldeps" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass-fulldeps" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "run-pass" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-3.9/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zmiri -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zmiri -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "3.9.1\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:07:45] expected success, got: exit code: 101
[01:07:45]
[01:07:45]
[01:07:45] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:07:45] Build completed unsuccessfully in 0:23:27
[01:07:45] make: *** [check] Error 1
[01:07:45] Makefile:58: recipe for target 'check' failed
---
$ ls -lat $HOME/Library/Logs/DiagnosticReports/
ls: cannot access /home/travis/Library/Logs/DiagnosticReports/: No such file or directory
travis_time:end:013f2202:start=1523317263969249995,finish=1523317263989728092,duration=20478097
travis_fold:end:after_failure.2
travis_fold:start:after_failure.3
travis_time:start:158b8abb
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; -exec head -750 {} \; -exec echo travis_fold":"end:crashlog \; || true
find: `/home/travis/Library/Logs/DiagnosticReports': No such file or directory
travis_time:end:158b8abb:start=1523317263999738313,finish=1523317264011064105,duration=11325792
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:0878c311
$ dmesg | grep -i kill
[   11.164918] init: failsafe main process (1095) killed by TERM signal

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)

@TimNN
Copy link
Contributor

TimNN commented Apr 10, 2018

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.
[00:00:47] configure: rust.quiet-tests     := True
---
[00:43:52] ............................................................................i.......................
[00:43:58] ...................i................................................................................
---
[00:44:33] .................................................................................................i..
[00:44:40] .......................................................................i............................
---
[00:45:36] .............................................i......................................................
---
[00:49:24] .............................i......................................................................
[00:49:38] ..............................................................i.....................................
[00:49:53] ...............................................i....................................................
[00:50:13] ....................................................................................................
[00:50:34] ....................................................................................................
[00:50:55] ....................................................................................................
[00:51:20] ...i...............................................................................................i
[00:51:48] ......................................................................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:51:56] ..............
[00:52:26] ....................................................................................................
[00:53:01] .................................................................ii.................................
[00:53:47] ............................i....................................................i.ii.....test [run-pass] run-pass/saturating-float-casts.rs has been running for over 60 seconds
[00:53:52] ..........
[00:54:32] .........................................................................................iiiiiii....
---
[00:56:45] ...................i............................................................ii.iii..............
[00:56:52] ....................................................................................................
[00:57:00] .........i..............................i...........................................................
[00:57:08] ....................................................................................................
[00:57:14] .....................i..............................................................................
[00:57:22] ....................................................................................................
[00:57:32] ....................................................................................................
[00:57:42] ....................................................................................................
[00:57:53] ....................................................................................................
[00:58:05] ....................................................................................................
[00:58:13] ..............i.....................................................................................
[00:58:23] ..................i..ii.............................................................................
[00:58:32] ....................................................................................................
[00:58:42] ....................................................................................................
[00:58:51] .....................................................................................i..............
[00:59:02] ...............................i....................................................................
---
[00:59:37] ...........................i........................................................................
[00:59:39] ....................................................................i...............................
[00:59:40] ................i.......................................................
---
[00:59:55] .............i........................
---
[01:00:25] i...i..ii....i.............ii.........iii......i..i...i...ii..i..i..ii.....
---
[01:00:28] i.......i......................i.......
---
[01:01:06] iiii.......i..i........i..i.i.............i..........iiii...........i...i..........ii.i.i.......ii..
[01:01:07] ....ii...
---
[01:03:02] ...................................F.........................................test [run-pass] run-pass-fulldeps/myriad-closures.rs has been running for over 60 seconds
[01:05:23] .........
[01:05:23] failures:
[01:05:23]
[01:05:23] ---- [run-pass] run-pass-fulldeps/macro-quote-cond.rs stdout ----
[01:05:23]
[01:05:23] error: auxiliary build of "/checkout/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs" failed to compile:
[01:05:23] status: exit code: 101
[01:05:23] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass-fulldeps" "--target=x86_64-unknown-linux-gnu" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass-fulldeps/macro-quote-cond.stage2-x86_64-unknown-linux-gnu.aux" "-Crpath" "-O" "-Zmiri" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass-fulldeps/macro-quote-cond.stage2-x86_64-unknown-linux-gnu.aux"
---
[01:05:23] error[E0277]: the trait bound `str: std::cmp::PartialEq<&str>` is not satisfied
[01:05:23]   --> /checkout/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs:36:56
[01:05:23]    |
[01:05:23] 36 |             TokenTree::Term(word) => *word.to_string() == "else",
[01:05:23]    |                                                        ^^ can't compare `str` with `&str`
[01:05:23]    |
[01:05:23]    = help: the trait `std::cmp::PartialEq<&str>` is not implemented for `str`
---
[01:05:23] 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/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/run-pass-fulldeps" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-pass-fulldeps" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "run-pass" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-3.9/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zmiri -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zmiri -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "3.9.1\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:05:23] expected success, got: exit code: 101
[01:05:23]
[01:05:23]
[01:05:23] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:05:23] Build completed unsuccessfully in 0:22:46
[01:05:23] Makefile:58: recipe for target 'check' failed
[01:05:23] make: *** [check] Error 1

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)

@Zoxc Zoxc force-pushed the term-str branch 2 times, most recently from c1fa468 to 8988a63 Compare April 10, 2018 01:07
@TimNN
Copy link
Contributor

TimNN commented Apr 10, 2018

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.
[00:00:46] configure: rust.quiet-tests     := True
---
[00:42:55] ............................................................................i.......................
[00:43:01] ...................i................................................................................
---
[00:43:36] .................................................................................................i..
[00:43:43] .......................................................................i............................
---
[00:44:37] .............................................i......................................................
---
[00:48:20] .............................i......................................................................
[00:48:34] ..............................................................i.....................................
[00:48:50] ...............................................i....................................................
[00:49:09] ....................................................................................................
[00:49:31] ....................................................................................................
[00:49:51] ....................................................................................................
[00:50:16] ...i...............................................................................................i
[00:50:44] .......................................................................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:50:51] .............
[00:51:20] ....................................................................................................
[00:51:53] .................................................................ii.................................
[00:52:41] ............................i....................................................i.ii..........test [run-pass] run-pass/saturating-float-casts.rs has been running for over 60 seconds
[00:52:44] .....
[00:53:22] .........................................................................................iiiiiii....
---
[00:55:32] ...................i............................................................ii.iii..............
[00:55:39] ....................................................................................................
[00:55:47] .........i..............................i...........................................................
[00:55:54] ....................................................................................................
[00:56:01] .....................i..............................................................................
[00:56:09] ....................................................................................................
[00:56:18] ....................................................................................................
[00:56:28] ....................................................................................................
[00:56:39] ....................................................................................................
[00:56:52] ....................................................................................................
[00:57:00] ..............i.....................................................................................
[00:57:09] ..................i..ii.............................................................................
[00:57:19] ....................................................................................................
[00:57:29] ....................................................................................................
[00:57:38] .....................................................................................i..............
[00:57:48] ...............................i....................................................................
---
[00:58:24] ...........................i........................................................................
[00:58:26] ....................................................................i...............................
[00:58:27] ................i.......................................................
---
[00:58:42] .............i........................
---
[00:59:10] i...i..ii....i.............ii.........iii......i..i...i...ii..i..i..ii.....
---
[00:59:13] i.......i......................i.......
---
[00:59:50] iiii.......i..i........i..i.i.............i..........iiii...........i...i..........ii.i.i.......ii..
[00:59:52] ....ii...
---
[01:04:38] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:486:22
[01:04:38] .......................F............................
[01:04:38] failures:
[01:04:38]
[01:04:38] ---- [compile-fail] compile-fail-fulldeps/proc-macro/attributes-included.rs stdout ----
[01:04:38]
[01:04:38] error: auxiliary build of "/checkout/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attributes-included.rs" failed to compile:
[01:04:38] status: exit code: 101
[01:04:38] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attributes-included.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail-fulldeps" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail-fulldeps/proc-macro/attributes-included.stage2-x86_64-unknown-linux-gnu.aux" "-Crpath" "-O" "-Zmiri" "-Zunstable-options" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail-fulldeps/proc-macro/attributes-included.stage2-x86_64-unknown-linux-gnu.aux"
---
[01:04:38] {"message":"no method named `as_str` found for type `&proc_macro::Term` in the current scope","code":{"code":"E0599","explanation":"\nThis error occurs when a method is used on a type which doesn't implement it:\n\nErroneous code example:\n\n```compile_fail,E0599\nstruct Mouth;\n\nlet x = Mouth;\nx.chocolate(); // error: no method named `chocolate` found for type `Mouth`\n               //        in the current scope\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attributes-included.rs","byte_start":2686,"byte_end":2692,"line_start":89,"line_end":89,"column_start":53,"column_end":59,"is_primary":true,"text":[{"text":"        TokenTree::Term(tt) => assert_eq!(\"doc\", tt.as_str()),","highlight_start":53,"highlight_end":59}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0599]: no method named `as_str` found for type `&proc_macro::Term` in the current scope\n  --> /checkout/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attributes-included.rs:89:53\n   |\nLL |         TokenTree::Term(tt) => assert_eq!(\"doc\", tt.as_str()),\n   |                                                     ^^^^^^\n\n"}
[01:04:38] {"message":"no method named `as_str` found for type `&proc_macro::Term` in the current scope","code":{"code":"E0599","explanation":"\nThis error occurs when a method is used on a type which doesn't implement it:\n\nErroneous code example:\n\n```compile_fail,E0599\nstruct Mouth;\n\nlet x = Mouth;\nx.chocolate(); // error: no method named `chocolate` found for type `Mouth`\n               //        in the current scope\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attributes-included.rs","byte_start":3536,"byte_end":3542,"line_start":121,"line_end":121,"column_start":46,"column_end":52,"is_primary":true,"text":[{"text":"        TokenTree::Term(tt) => assert_eq!(tt.as_str(), \"fn\"),","highlight_start":46,"highlight_end":52}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0599]: no method named `as_str` found for type `&proc_macro::Term` in the current scope\n  --> /checkout/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attributes-included.rs:121:46\n   |\nLL |         TokenTree::Term(tt) => assert_eq!(tt.as_str(), \"fn\"),\n   |                                              ^^^^^^\n\n"}
[01:04:38] {"message":"no method named `as_str` found for type `&proc_macro::Term` in the current scope","code":{"code":"E0599","explanation":"\nThis error occurs when a method is used on a type which doesn't implement it:\n\nErroneous code example:\n\n```compile_fail,E0599\nstruct Mouth;\n\nlet x = Mouth;\nx.chocolate(); // error: no method named `chocolate` found for type `Mouth`\n               //        in the current scope\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attributes-included.rs","byte_start":3662,"byte_end":3668,"line_start":125,"line_end":125,"column_start":46,"column_end":52,"is_primary":true,"text":[{"text":"        TokenTree::Term(tt) => assert_eq!(tt.as_str(), \"foo\"),","highlight_start":46,"highlight_end":52}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0599]: no method named `as_str` found for type `&proc_macro::Term` in the current scope\n  --> /checkout/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attributes-included.rs:125:46\n   |\nLL |         TokenTree::Term(tt) => assert_eq!(tt.as_str(), \"foo\"),\n   |                                              ^^^^^^\n\n"}
[01:04:38] {"message":"aborting due to 3 previous errors","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to 3 previous errors\n\n"}
[01:04:38] {"message":"For more information about this error, try `rustc --explain E0599`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0599`.\n"}
---
[01:04:38] 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/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/compile-fail-fulldeps" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail-fulldeps" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "compile-fail" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-3.9/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zmiri -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zmiri -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "3.9.1\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[01:04:38] expected success, got: exit code: 101
[01:04:38]
[01:04:38]
[01:04:38] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:04:38] Build completed unsuccessfully in 0:23:01
[01:04:38] make: *** [check] Error 1
[01:04:38] Makefile:58: recipe for target 'check' failed
---
$ ls -lat $HOME/Library/Logs/DiagnosticReports/
ls: cannot access /home/travis/Library/Logs/DiagnosticReports/: No such file or directory
travis_time:end:37640cec:start=1523326250043798910,finish=1523326250052703169,duration=8904259
travis_fold:end:after_failure.2
travis_fold:start:after_failure.3
travis_time:start:10ce25fe
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; -exec head -750 {} \; -exec echo travis_fold":"end:crashlog \; || true
find: `/home/travis/Library/Logs/DiagnosticReports': No such file or directory
travis_time:end:10ce25fe:start=1523326250060450167,finish=1523326250068704804,duration=8254637
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:05cb7900
$ dmesg | grep -i kill
[   11.149527] init: failsafe main process (1093) killed by TERM signal

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)

@TimNN
Copy link
Contributor

TimNN commented Apr 10, 2018

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.
[00:00:48] configure: rust.quiet-tests     := True
---
[00:45:41] ............................................................................i.......................
[00:45:48] ...................i................................................................................
---
[00:46:24] .................................................................................................i..
[00:46:32] .......................................................................i............................
---
[00:47:28] .............................................i......................................................
---
[00:51:23] .............................i......................................................................
[00:51:38] ..............................................................i.....................................
[00:51:54] ...............................................i....................................................
[00:52:14] ....................................................................................................
[00:52:36] ....................................................................................................
[00:52:58] ....................................................................................................
[00:53:23] ...i...............................................................................................i
[00:53:50] ..................................................................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:54:00] ..................
[00:54:30] ....................................................................................................
[00:55:06] .................................................................ii.................................
[00:55:52] ............................i....................................................i.ii.....test [run-pass] run-pass/saturating-float-casts.rs has been running for over 60 seconds
[00:55:57] ..........
[00:56:37] .........................................................................................iiiiiii....
---
[00:58:49] ...................i............................................................ii.iii..............
[00:58:57] ....................................................................................................
[00:59:05] .........i..............................i...........................................................
[00:59:13] ....................................................................................................
[00:59:20] .....................i..............................................................................
[00:59:28] ....................................................................................................
[00:59:38] ....................................................................................................
[00:59:48] ....................................................................................................
[00:59:59] ....................................................................................................
[01:00:13] ....................................................................................................
[01:00:21] ..............i.....................................................................................
[01:00:31] ..................i..ii.............................................................................
[01:00:41] ....................................................................................................
[01:00:51] ....................................................................................................
[01:01:01] .....................................................................................i..............
[01:01:11] ...............................i....................................................................
---
[01:01:49] ...........................i........................................................................
[01:01:50] ....................................................................i...............................
[01:01:52] ................i.......................................................
---
[01:02:07] .............i........................
---
[01:02:38] i...i..ii....i.............ii.........iii......i..i...i...ii..i..i..ii.....
---
[01:02:42] i.......i......................i.......
---
[01:03:21] iiii.......i..i........i..i.i.............i..........iiii...........i...i..........ii.i.i.......ii..
[01:03:23] ....ii...
---
[01:08:29] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:486:22
[01:08:29] .....................F..............................
[01:08:29] failures:
[01:08:29]
[01:08:29] ---- [compile-fail] compile-fail-fulldeps/proc-macro/attributes-included.rs stdout ----
[01:08:29]
[01:08:29] error: auxiliary build of "/checkout/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attributes-included.rs" failed to compile:
[01:08:29] status: exit code: 101
[01:08:29] command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attributes-included.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail-fulldeps" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail-fulldeps/proc-macro/attributes-included.stage2-x86_64-unknown-linux-gnu.aux" "-Crpath" "-O" "-Zmiri" "-Zunstable-options" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail-fulldeps/proc-macro/attributes-included.stage2-x86_64-unknown-linux-gnu.aux"
---
[01:08:29] {"message":"no method named `as_str` found for type `&proc_macro::Term` in the current scope","code":{"code":"E0599","explanation":"\nThis error occurs when a method is used on a type which doesn't implement it:\n\nErroneous code example:\n\n```compile_fail,E0599\nstruct Mouth;\n\nlet x = Mouth;\nx.chocolate(); // error: no method named `chocolate` found for type `Mouth`\n               //        in the current scope\n```\n"},"level":"error","spans":[{"file_name":"/checkout/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attributes-included.rs","byte_start":2686,"byte_end":2692,"line_start":89,"line_end":89,"column_start":53,"column_end":59,"is_primary":true,"text":[{"text":"        TokenTree::Term(tt) => assert_eq!(\"doc\", tt.as_str()),","highlight_start":53,"highlight_end":59}],"label":null,"suggested_replacement":null,"expansion":null}],"children":[],"rendered":"error[E0599]: no method named `as_str` found for type `&proc_macro::Term` in the current scope\n  --> /checkout/src/test/compile-fail-fulldeps/proc-macro/auxiliary/attributes-included.rs:89:53\n   |\nLL |         TokenTree::Term(tt) => assert_eq!(\"doc\", tt.as_str()),\n   |                                                     ^^^^^^\n\n"}
[01:08:29] {"message":"aborting due to previous error","code":null,"level":"error","spans":[],"children":[],"rendered":"error: aborting due to previous error\n\n"}
[01:08:29] {"message":"For more information about this error, try `rustc --explain E0599`.","code":null,"level":"","spans":[],"children":[],"rendered":"For more information about this error, try `rustc --explain E0599`.\n"}
---
[01:08:29] 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/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/compile-fail-fulldeps" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/compile-fail-fulldeps" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "compile-fail" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-3.9/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zmiri -Zunstablebuild/bootstrap/debug/incremental/bootstrap-351vorei3hhuv/s-ezz0rycasw-149kv7d-179sb4yv5t1yk
---
102728 ./obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/incremental/core-31lccp6wy7orz/s-ezz1v62dyp-1pq6uau-6xnnylbd6ghy
100676 ./obj/build/bootstrap/debug/incremental/bootstrap-zki88qpb4pjm
100672 ./obj/build/bootstrap/debug/incremental/bootstrap-zki88qpb4pjm/s-ezz1y35h76-13viz3i-1raxz7drp4c1e

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)

@alexcrichton
Copy link
Member

cc @dtolnay and @nrc, do y'all have thoughts on this?

@@ -711,8 +711,8 @@ impl Term {

/// Get a reference to the interned string.
#[unstable(feature = "proc_macro", issue = "38356")]
pub fn as_str(&self) -> &str {
unsafe { &*(&*self.sym.as_str() as *const str) }
pub fn to_string(&self) -> String {
Copy link
Member

Choose a reason for hiding this comment

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

If we go with this change I don't think we'd keep this as a method as it's already inherited through the ToString trait.

@alexcrichton
Copy link
Member

@Zoxc can you lay out the concerns motivating this as well? The links above didn't really convey to me why Term shouldn't implement as_str but should implement Display

@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 10, 2018

There isn't a mechanism to ensure that the &str returned by as_str actually lives as long as the Term. I haven't come up with a non-contrived example to exploit that though.

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.

I am on board with removing as_str in favor of the Display impl (no to_string inherent method) but unless there is an immediate soundness concern I would prefer to hold off and batch this with the next round of proc-macro2 breaking changes. We can file an issue here or in proc-macro2 to remember to follow up.

@pietroalbini
Copy link
Member

Ping from triage! What's the status of this PR?

@alexcrichton
Copy link
Member

I think we're likely to merge this but in the meantime we'd prefer to avoid a breaking change to proc_macro and wait for stabilization to happen to simply avoid stabilizing this method.

@pietroalbini
Copy link
Member

So, I guess this is blocked on the stabilization of proc_macro?

@pietroalbini pietroalbini added S-blocked Status: Blocked on something else such as an RFC or other implementation work. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 23, 2018
@alexcrichton
Copy link
Member

Hm yeah I think so.

I'm gonna close this for now but we will very intentionally leave this out of the first round of stabilization. Once the first round of stabilization lands I think we're definitely safe to remove this.

@Zoxc if this needs to be removed sooner though for other technical reasons we can of course go ahead and land it!

@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 23, 2018

@alexcrichton Is that noted down somewhere? Should I add a comment that it should not be stabilized? We could also remove the existing usages of this.

@alexcrichton
Copy link
Member

@Zoxc this was incorporated into the FCP proposal, but yeah if there are existing usages it'd be great to remove them!

@Zoxc
Copy link
Contributor Author

Zoxc commented Apr 23, 2018

I don't see as_str mentioned there. So I would like to keep this open or add a comment to as_str indicating that it should not be stabilized.

@alexcrichton
Copy link
Member

Ah yes that's what I mean, its absence indicates that it's not being stabilized. A lot of stuff in proc_macro won't get stabilized. I'll probably be the one doing the stabilization, and I assure you I won't forget to leave this one unstable :)

@Zoxc Zoxc changed the title Replace Term::as_str with Term::to_string Remove usages of Term::as_str and mark it for removal Apr 25, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 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.
[00:01:28]  Downloading toml v0.4.6
[00:01:28] error: unable to get packages from source
[00:01:28] 
[00:01:28] Caused by:
[00:01:28]   failed to get 200 response from `https://crates.io/api/v1/crates/toml/0.4.6/download`, got 404
[00:01:28] failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml --locked
[00:01:28] Build completed unsuccessfully in 0:00:41
[00:01:28] make: *** [prepare] Error 1
[00:01:28] Makefile:81: recipe for target 'prepare' failed
[00:01:30]  Downloading toml v0.4.6
[00:01:30] error: unable to get packages from source
[00:01:30] 
[00:01:30] Caused by:
[00:01:30] Caused by:
[00:01:30]   failed to get 200 response from `https://crates.io/api/v1/crates/toml/0.4.6/download`, got 404
[00:01:30] failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml --locked
[00:01:30] Build completed unsuccessfully in 0:00:01
[00:01:30] Makefile:81: recipe for target 'prepare' failed
[00:01:30] make: *** [prepare] Error 1
[00:01:30]  Downloading toml v0.4.6
[00:01:30] error: unable to get packages from source
[00:01:30] 
[00:01:30] Caused by:
[00:01:30] Caused by:
[00:01:30]   failed to get 200 response from `https://crates.io/api/v1/crates/toml/0.4.6/download`, got 404
[00:01:30] failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml --locked
[00:01:30] Build completed unsuccessfully in 0:00:00
[00:01:30] Makefile:81: recipe for target 'prepare' failed
[00:01:30] make: *** [prepare] Error 1
[00:01:31]  Downloading lazy_static v0.2.11
[00:01:31] error: unable to get packages from source
[00:01:31] 
[00:01:31] Caused by:
[00:01:31] Caused by:
[00:01:31]   failed to get 200 response from `https://crates.io/api/v1/crates/lazy_static/0.2.11/download`, got 404
[00:01:31] failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml --locked
[00:01:31] Build completed unsuccessfully in 0:00:00
[00:01:31] Makefile:81: recipe for target 'prepare' failed
[00:01:31] make: *** [prepare] Error 1
[00:01:32]  Downloading libc v0.2.40
[00:01:32] error: unable to get packages from source
[00:01:32] 
[00:01:32] Caused by:
[00:01:32] Caused by:
[00:01:32]   failed to get 200 response from `https://crates.io/api/v1/crates/libc/0.2.40/download`, got 404
[00:01:32] failed to run: /checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo build --manifest-path /checkout/src/bootstrap/Cargo.toml --locked
[00:01:32] Build completed unsuccessfully in 0:00:00
[00:01:32] Makefile:81: recipe for target 'prepare' failed
[00:01:32] make: *** [prepare] Error 1
[00:01:32] The command has failed after 5 attempts.

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 1.
travis_time:start:03c2a66a
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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)

@Zoxc Zoxc added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-blocked Status: Blocked on something else such as an RFC or other implementation work. labels Apr 30, 2018
@eddyb
Copy link
Member

eddyb commented May 5, 2018

Note that this PR is obsoleted by #49219, which itself has to come up with a scheme for as_str.

@pietroalbini
Copy link
Member

Ping from triage @alexcrichton! What's the status on this?

@alexcrichton
Copy link
Member

@bors: r+

Should be good to go now!

@bors
Copy link
Contributor

bors commented May 10, 2018

📌 Commit 221b7ca 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-review Status: Awaiting review from the assignee but also interested parties. labels May 10, 2018
alexcrichton added a commit to alexcrichton/rust that referenced this pull request May 10, 2018
Remove usages of Term::as_str and mark it for removal

Returning references to rustc internal data structures is a bad idea since their lifetimes are unrelated to the lifetimes of proc_macro values.

See rust-lang#46972 and the `Taming thread-local storage` section of https://internals.rust-lang.org/t/parallelizing-rustc-using-rayon/6606

r? @alexcrichton
@bors
Copy link
Contributor

bors commented May 10, 2018

⌛ Testing commit 221b7ca with merge 9e3caa2...

bors added a commit that referenced this pull request May 10, 2018
Remove usages of Term::as_str and mark it for removal

Returning references to rustc internal data structures is a bad idea since their lifetimes are unrelated to the lifetimes of proc_macro values.

See #46972 and the `Taming thread-local storage` section of https://internals.rust-lang.org/t/parallelizing-rustc-using-rayon/6606

r? @alexcrichton
@bors
Copy link
Contributor

bors commented May 10, 2018

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

@bors bors merged commit 221b7ca into rust-lang:master May 10, 2018
@Zoxc Zoxc deleted the term-str branch May 10, 2018 18:42
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.

8 participants