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

Cleanup syntax::attr #63146

Merged
merged 8 commits into from
Aug 3, 2019
Merged

Cleanup syntax::attr #63146

merged 8 commits into from
Aug 3, 2019

Conversation

Mark-Simulacrum
Copy link
Member

Mostly removing needless arguments to constructors

r? @petrochenkov

.decode((self, sess))
.map(|mut attr| {
// Need new unique IDs: old thread-local IDs won't map to new threads.
attr.id = attr::mk_attr_id();
Copy link
Member Author

Choose a reason for hiding this comment

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

This is due to the related change which implement Decodable/Encodable on AttrId via mk_attr_id and encode_nil. I'm not sure if they're actually equivalent, though. It feels like they should be.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this the only place where attributes are decoded?
Perhaps incremental could decode them in the old way as an index, or something like that?

Copy link
Member Author

Choose a reason for hiding this comment

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

AFAICT, this is the only place where attributes are decoded, but I'm not sure how to check (cc @eddyb?)

I'm not sure what you mean by "incremental could decode them in the old way" -- is that referring to a place where it'd be good to check whether we're doing the right decoding?

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAICT, this is the only place where attributes are decoded

Yeah, looks like that, at least from searching .decode( and ::decode(.
I thought about maybe commenting out the impl and trying to build, but looks like that's not feasible because everything including attributes derives RustcEncodable and RustcDecodable.
(By incremental I meant some place in incremental compilation that decodes things from cache.)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed (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.
2019-07-30T19:14:22.1101588Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-07-30T19:14:22.1285474Z ##[command]git config gc.auto 0
2019-07-30T19:14:22.1356949Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-07-30T19:14:22.1419780Z ##[command]git config --get-all http.proxy
2019-07-30T19:14:22.1565803Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/63146/merge:refs/remotes/pull/63146/merge
---
2019-07-30T19:14:57.9740526Z do so (now or later) by using -b with the checkout command again. Example:
2019-07-30T19:14:57.9740570Z 
2019-07-30T19:14:57.9740775Z   git checkout -b <new-branch-name>
2019-07-30T19:14:57.9740801Z 
2019-07-30T19:14:57.9740841Z HEAD is now at 4e5b9fdf3 Merge 12766c9392dd00a663d8607060d13a8d42b907f8 into f690098e6d65ad7b33dc7fdefccc387806782027
2019-07-30T19:14:57.9929242Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-07-30T19:14:57.9932193Z ==============================================================================
2019-07-30T19:14:57.9932246Z Task         : Bash
2019-07-30T19:14:57.9932287Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-07-30T19:46:09.8463138Z    Compiling rustc_asan v0.0.0 (/checkout/src/librustc_asan)
2019-07-30T19:46:10.4916559Z    Compiling rustc_msan v0.0.0 (/checkout/src/librustc_msan)
2019-07-30T19:46:10.5631163Z    Compiling rustc_lsan v0.0.0 (/checkout/src/librustc_lsan)
2019-07-30T19:46:11.3108028Z    Compiling rustc-std-workspace-core v1.0.0 (/checkout/src/tools/rustc-std-workspace-core)
2019-07-30T19:46:11.4466630Z error[E0658]: internal implementation detail
2019-07-30T19:46:11.4467188Z   --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/compiler_builtins-0.1.18/src/float/cmp.rs:7:1
2019-07-30T19:46:11.4467441Z    |
2019-07-30T19:46:11.4467731Z 7  | / enum Result {
2019-07-30T19:46:11.4468044Z 8  | |     Less,
2019-07-30T19:46:11.4468348Z 9  | |     Equal,
2019-07-30T19:46:11.4468636Z 10 | |     Greater,
2019-07-30T19:46:11.4468925Z 11 | |     Unordered,
2019-07-30T19:46:11.4469485Z    | |_^
2019-07-30T19:46:11.4469692Z    |
2019-07-30T19:46:11.4469692Z    |
2019-07-30T19:46:11.4470385Z    = note: for more information, see ***/issues/29642
2019-07-30T19:46:11.4470776Z    = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
2019-07-30T19:46:12.2629600Z error: aborting due to previous error
2019-07-30T19:46:12.2629767Z 
2019-07-30T19:46:12.2630050Z For more information about this error, try `rustc --explain E0658`.
2019-07-30T19:46:12.2715141Z error: Could not compile `compiler_builtins`.
2019-07-30T19:46:12.2715141Z error: Could not compile `compiler_builtins`.
2019-07-30T19:46:12.2715782Z warning: build failed, waiting for other jobs to finish...
2019-07-30T19:46:13.2851704Z error: build failed
2019-07-30T19:46:13.2873397Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "2" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "--message-format" "json"
2019-07-30T19:46:13.2873568Z expected success, got: exit code: 101
2019-07-30T19:46:13.2885513Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-07-30T19:46:13.2885815Z Build completed unsuccessfully in 0:24:20
2019-07-30T19:46:15.9256415Z ##[error]Bash exited with code '1'.
2019-07-30T19:46:15.9293104Z ##[section]Starting: Checkout
2019-07-30T19:46:15.9294971Z ==============================================================================
2019-07-30T19:46:15.9295163Z Task         : Get sources
2019-07-30T19:46:15.9295205Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

@Mark-Simulacrum
Copy link
Member Author

Dropped ce34fd858a7a802a376f53789a34f9c844080a24 since I suspect it caused the test failure and is in any case sort of orthogonal to this PR's main thrust.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-6.0 of your PR failed (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.
2019-07-30T20:37:54.9719935Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-07-30T20:37:54.9892734Z ##[command]git config gc.auto 0
2019-07-30T20:37:54.9957535Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-07-30T20:37:55.0007374Z ##[command]git config --get-all http.proxy
2019-07-30T20:37:55.0144145Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/63146/merge:refs/remotes/pull/63146/merge
---
2019-07-30T20:38:29.1497317Z do so (now or later) by using -b with the checkout command again. Example:
2019-07-30T20:38:29.1498798Z 
2019-07-30T20:38:29.1501126Z   git checkout -b <new-branch-name>
2019-07-30T20:38:29.1502582Z 
2019-07-30T20:38:29.1504000Z HEAD is now at bede0c8fc Merge b8ad424cfe62aecb0477e6a1ea5ca1a3d5fb03d8 into f690098e6d65ad7b33dc7fdefccc387806782027
2019-07-30T20:38:29.1648050Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-07-30T20:38:29.1651191Z ==============================================================================
2019-07-30T20:38:29.1651249Z Task         : Bash
2019-07-30T20:38:29.1651309Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-07-30T21:07:15.5670265Z    Compiling rustc_asan v0.0.0 (/checkout/src/librustc_asan)
2019-07-30T21:07:16.1852654Z    Compiling rustc_msan v0.0.0 (/checkout/src/librustc_msan)
2019-07-30T21:07:16.8104767Z    Compiling rustc_tsan v0.0.0 (/checkout/src/librustc_tsan)
2019-07-30T21:07:17.5346897Z    Compiling rustc-std-workspace-core v1.0.0 (/checkout/src/tools/rustc-std-workspace-core)
2019-07-30T21:07:17.6732188Z error[E0658]: internal implementation detail
2019-07-30T21:07:17.6738065Z   --> /cargo/registry/src/git.luolix.top-1ecc6299db9ec823/compiler_builtins-0.1.18/src/float/cmp.rs:7:1
2019-07-30T21:07:17.6742917Z    |
2019-07-30T21:07:17.6748894Z 7  | / enum Result {
2019-07-30T21:07:17.6754373Z 8  | |     Less,
2019-07-30T21:07:17.6755596Z 9  | |     Equal,
2019-07-30T21:07:17.6755911Z 10 | |     Greater,
2019-07-30T21:07:17.6756234Z 11 | |     Unordered,
2019-07-30T21:07:17.6761413Z    | |_^
2019-07-30T21:07:17.6761642Z    |
2019-07-30T21:07:17.6761642Z    |
2019-07-30T21:07:17.6762099Z    = note: for more information, see ***/issues/29642
2019-07-30T21:07:17.6765868Z    = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable
2019-07-30T21:07:18.4554002Z error: aborting due to previous error
2019-07-30T21:07:18.4554962Z 
2019-07-30T21:07:18.4555673Z For more information about this error, try `rustc --explain E0658`.
2019-07-30T21:07:18.4642523Z error: Could not compile `compiler_builtins`.
2019-07-30T21:07:18.4642523Z error: Could not compile `compiler_builtins`.
2019-07-30T21:07:18.4652717Z warning: build failed, waiting for other jobs to finish...
2019-07-30T21:07:19.2343488Z error: build failed
2019-07-30T21:07:19.2357206Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "2" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "--message-format" "json"
2019-07-30T21:07:19.2357411Z expected success, got: exit code: 101
2019-07-30T21:07:19.2368919Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-07-30T21:07:19.2369944Z Build completed unsuccessfully in 0:22:40
2019-07-30T21:07:21.9427236Z ##[error]Bash exited with code '1'.
2019-07-30T21:07:21.9465372Z ##[section]Starting: Checkout
2019-07-30T21:07:21.9467465Z ==============================================================================
2019-07-30T21:07:21.9467523Z Task         : Get sources
2019-07-30T21:07:21.9467605Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

/// Returns an outer attribute with the given value and span.
pub fn mk_spanned_attr_outer(sp: Span, id: AttrId, item: MetaItem) -> Attribute {
pub fn mk_attr_outer(item: MetaItem) -> Attribute {
Copy link
Contributor

Choose a reason for hiding this comment

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

inner/outer are identical save for style -- consider a helper function that takes in the style.

@Mark-Simulacrum
Copy link
Member Author

Hm, okay, compilation failure looks to not be due to the attr id changes. I'll have to dig in to why that's happening...

@jonas-schievink jonas-schievink added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 31, 2019
@petrochenkov
Copy link
Contributor

I didn't read the PR yet, but if the errors are about #[allow_internal_unstable] not working, then the reason is spans.

As I recently mentioned elsewhere, AstBuilder is bad at keeping spans and their SyntaxContext part in particular (which is responsible for allowing internal unstable too).
(Attribute-building functions in syntax::attr are also a part of AstBuilder logically.)

Some code using the builder relies, intentionally or not, on span contexts being lost or otherwise not preserved.
So, if the builder is fixed to propagate all spans correctly, that code will need to be fixed as well.

@Mark-Simulacrum
Copy link
Member Author

d4227f6 fixes the previous error.

@Mark-Simulacrum Mark-Simulacrum added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 31, 2019
@petrochenkov
Copy link
Contributor

r=me with the question about attribute ID decoding answered

@petrochenkov petrochenkov 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-review Status: Awaiting review from the assignee but also interested parties. labels Jul 31, 2019
@petrochenkov
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jul 31, 2019

📌 Commit c146344 has been approved by petrochenkov

@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 Jul 31, 2019
Centril added a commit to Centril/rust that referenced this pull request Jul 31, 2019
…chenkov

Cleanup syntax::attr

Mostly removing needless arguments to constructors

r? @petrochenkov
Centril added a commit to Centril/rust that referenced this pull request Aug 1, 2019
…chenkov

Cleanup syntax::attr

Mostly removing needless arguments to constructors

r? @petrochenkov
Centril added a commit to Centril/rust that referenced this pull request Aug 1, 2019
…chenkov

Cleanup syntax::attr

Mostly removing needless arguments to constructors

r? @petrochenkov
Centril added a commit to Centril/rust that referenced this pull request Aug 3, 2019
…chenkov

Cleanup syntax::attr

Mostly removing needless arguments to constructors

r? @petrochenkov
bors added a commit that referenced this pull request Aug 3, 2019
Rollup of 5 pull requests

Successful merges:

 - #62954 (Fix typo in Delimited::open_tt)
 - #63146 (Cleanup syntax::attr)
 - #63218 (rustbuild: RISC-V is no longer an experimental LLVM target)
 - #63227 (dead_code: Properly inspect fields in struct patterns with type relative paths)
 - #63229 (A bit of Miri error cleanup)

Failed merges:

r? @ghost
@bors bors merged commit c146344 into rust-lang:master Aug 3, 2019
bors added a commit to rust-lang/cargo that referenced this pull request Aug 4, 2019
Remove unused AstBuilder

This was removed in a recent rustc PR (rust-lang/rust#63146), replaced with inherent impls.
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