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 HIR inlining #49991

Merged
merged 1 commit into from
Apr 20, 2018
Merged

Remove HIR inlining #49991

merged 1 commit into from
Apr 20, 2018

Conversation

wesleywiser
Copy link
Member

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

Nice, thanks @wesleywiser! I'll take a look as soon as I find the time.

@michaelwoerister
Copy link
Member

Looks great, @wesleywiser! Two things I'm wondering:

Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

👍

associated_container.hash_stable(hcx, hasher);
qualif.hash_stable(hcx, hasher);
}
}
}
}

#[derive(RustcEncodable, RustcDecodable)]
pub struct ConstData {
pub rendered: String,
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 expected to gain more fields? If no, how about making t a newtype called RenderedConst?

Also 🚨documentation police🚨 please add some docs

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not aware of any additional data we need at this time. I'd be happy to change it and I'll add some docs too 👍

@@ -254,9 +253,9 @@ define_maps! { <'tcx>
[] fn item_attrs: ItemAttrs(DefId) -> Lrc<[ast::Attribute]>,
[] fn trans_fn_attrs: trans_fn_attrs(DefId) -> TransFnAttrs,
[] fn fn_arg_names: FnArgNames(DefId) -> Vec<ast::Name>,
[] fn rendered_const: RenderedConst(DefId) -> String,
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is essentially self explanatory. Still, a short doc comment would be awesome

@wesleywiser
Copy link
Member Author

@michaelwoerister

Does this code also need to handle statics?

I don't believe so. I was unable to find a failing test case for statics and all of the existing rustdoc tests pass after handling Const and AssociatedConst.

Could the schema::Entry::ast field be removed entirely?

I think I ran into some issues when I tried that but I don't remember clearly. I will investigate that tonight.

@Mark-Simulacrum
Copy link
Member

@bors try

@bors
Copy link
Contributor

bors commented Apr 16, 2018

⌛ Trying commit 26b3203 with merge 6bdc8be...

bors added a commit that referenced this pull request Apr 16, 2018
@wesleywiser
Copy link
Member Author

schema::Entry::ast is still used by the typeck_tables_of query which calls item_body_tables and the const_is_rvalue_promotable_to_static query which calls a function of the same name.

@bors
Copy link
Contributor

bors commented Apr 17, 2018

☀️ Test successful - status-travis
State: approved= try=True

@wesleywiser wesleywiser force-pushed the remove_hir_inlining branch from 26b3203 to fee5c82 Compare April 17, 2018 00:47
@wesleywiser
Copy link
Member Author

Added docs & newtype wrapper.

@michaelwoerister
Copy link
Member

I don't believe so. I was unable to find a failing test case for statics and all of the existing rustdoc tests pass after handling Const and AssociatedConst.

👍

schema::Entry::ast is still used by the typeck_tables_of query which calls item_body_tables and the const_is_rvalue_promotable_to_static query which calls a function of the same name.

You might be able to remove the metadata-based version of the typeck_tables_of query, since it shouldn't be called by for external items anymore. About const_is_rvalue_promotable_to_static I'm not sure. @eddyb or @oli-obk might know more.

@bors
Copy link
Contributor

bors commented Apr 17, 2018

☔ The latest upstream changes (presumably #49882) made this pull request unmergeable. Please resolve the merge conflicts.

@oli-obk
Copy link
Contributor

oli-obk commented Apr 17, 2018

You'd need to move the rvalue_promotable_to_static field up from the Ast to the Entry

// with them.
pub fingerprint: ich::Fingerprint,
}

#[derive(Clone)]
pub struct ExternBodyNestedBodies {
Copy link
Member

Choose a reason for hiding this comment

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

Can this be removed too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, good catch!

@@ -289,7 +289,7 @@ impl_stable_hash_for!(struct Entry<'tcx> {

#[derive(Copy, Clone, RustcEncodable, RustcDecodable)]
pub enum EntryKind<'tcx> {
Const(u8),
Const(u8, Lazy<RenderedConst>),
Copy link
Member

Choose a reason for hiding this comment

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

You could replace the u8 here and in AssociatedConst with a struct ConstQualif { mir: u8, ast_promotable: bool }.

Copy link
Member Author

Choose a reason for hiding this comment

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

What does ast_promotable mean?

Copy link
Member

Choose a reason for hiding this comment

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

The rvalue_promotable_to_static: bool field that's currently in Ast.

@wesleywiser wesleywiser force-pushed the remove_hir_inlining branch from fee5c82 to 4a77d35 Compare April 20, 2018 00:34
@wesleywiser
Copy link
Member Author

Implemented feedback & rebased.

@michaelwoerister
Copy link
Member

Thanks a lot, @wesleywiser! Very pleasing to see this go :)

@bors r+

@bors
Copy link
Contributor

bors commented Apr 20, 2018

📌 Commit 4a77d35 has been approved by michaelwoerister

@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 Apr 20, 2018
@bors
Copy link
Contributor

bors commented Apr 20, 2018

⌛ Testing commit 4a77d35 with merge 1a44439...

bors added a commit that referenced this pull request Apr 20, 2018
@bors
Copy link
Contributor

bors commented Apr 20, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: michaelwoerister
Pushing 1a44439 to master...

@bors bors merged commit 4a77d35 into rust-lang:master Apr 20, 2018
} else if let hir::ImplItemKind::Method(ref sig, _) = ast_item.node {
let generics = self.tcx.generics_of(def_id);
let types = generics.parent_types as usize + generics.types.len();
let needs_inline = types > 0 || tcx.trans_fn_attrs(def_id).requests_inline() &&
Copy link
Member

@varkor varkor Apr 20, 2018

Choose a reason for hiding this comment

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

This changes the behaviour as && binds more tightly — was this intentional?

Copy link
Member

Choose a reason for hiding this comment

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

No, that was not intentional. Good catch!

Copy link
Member

Choose a reason for hiding this comment

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

Also, this would be nicer with a match instead of chained if lets. @wesleywiser, would you mind making a PR with a fix?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, looks like I messed this up when I pulled the latest changes into my branch. I've opened a quick PR that fixes this (#50114). I'll send a follow up tonight that uses a match for this instead.

wesleywiser added a commit to wesleywiser/rust that referenced this pull request Apr 20, 2018
When I rebased rust-lang#49991 on `master`, I messed up the merge for this line. I'm reverting this back to the way it was in f15e5c1.
kennytm added a commit to kennytm/rust that referenced this pull request Apr 20, 2018
…ster

Fix bad merge in rust-lang#49991

When I rebased rust-lang#49991 on `master`, I messed up the merge for this line. I'm reverting this back to the way it was in f15e5c1.

r? @michaelwoerister
bors added a commit that referenced this pull request Apr 20, 2018
Rollup of 7 pull requests

Successful merges:

 - #50031 (Clarified E0015 message.)
 - #50058 (Added build disk usage information)
 - #50081 (Update stdsimd submodule)
 - #50083 (wasm: Increase default stack size to 1MB)
 - #50104 (Disable auto-detection of libxml2 when compiling llvm.)
 - #50114 (Fix bad merge in #49991)
 - #50117 (must explicitly request file name when using with_file_name.)

Failed merges:
bors added a commit that referenced this pull request Apr 23, 2018
@@ -375,14 +373,37 @@ impl<'a, 'gcx> HashStable<StableHashingContext<'a>> for EntryKind<'gcx> {
EntryKind::AssociatedType(associated_container) => {
associated_container.hash_stable(hcx, hasher);
}
EntryKind::AssociatedConst(associated_container, qualif) => {
EntryKind::AssociatedConst(associated_container, qualif, _) => {
Copy link
Member

Choose a reason for hiding this comment

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

This ignores the last field, but EntryKind::Const above doesn't. cc @michaelwoerister

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that's wrong. I'll open a PR for that.

@@ -869,6 +871,13 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
!self.tcx.sess.opts.output_types.should_trans()
}

fn const_qualif(&self, mir: u8, body_id: hir::BodyId) -> ConstQualif {
Copy link
Member

Choose a reason for hiding this comment

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

This should ideally call mir_const_qualif itself instead of taking the value as an argument.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Why would that keep the AST promotability but not the MIR one? I think you just never need either for trait associated consts.

wesleywiser added a commit to wesleywiser/rust that referenced this pull request Apr 25, 2018
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Apr 26, 2018
U007D pushed a commit to humanenginuity/rust that referenced this pull request Apr 30, 2018
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