Skip to content

Add hir::GenericArg::Infer#83484

Merged
bors merged 3 commits intorust-lang:masterfrom
JulianKnodt:infer
Jul 27, 2021
Merged

Add hir::GenericArg::Infer#83484
bors merged 3 commits intorust-lang:masterfrom
JulianKnodt:infer

Conversation

@JulianKnodt
Copy link
Contributor

@JulianKnodt JulianKnodt commented Mar 25, 2021

In order to extend inference to consts, make an Infer type on hir::GenericArg.

@JulianKnodt JulianKnodt changed the title [WIP] Add hir::GenericArg::Infer Add hir::GenericArg::Infer Mar 27, 2021
@JulianKnodt JulianKnodt marked this pull request as ready for review March 27, 2021 05:10
@rust-log-analyzer

This comment has been minimized.

@JulianKnodt JulianKnodt force-pushed the infer branch 4 times, most recently from 9c81041 to 5d2b04a Compare March 27, 2021 17:37
@JulianKnodt
Copy link
Contributor Author

JulianKnodt commented Mar 27, 2021

r? @lcnr
I'm not sure if you intended for const inference to work here yet, I didn't add it (but can if it's already possible)

@JulianKnodt
Copy link
Contributor Author

@rustbot label: +S-waiting-on-review

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 27, 2021
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@JulianKnodt
Copy link
Contributor Author

@rustbot label: +S-waiting-on-review -S-waiting-on-author

Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

after this r=me 😅 thanks for working on this ❤️

Copy link
Contributor

Choose a reason for hiding this comment

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

for this to work you have to modify fn opt_const_param_of to also run for GenericArg::Infer, don't you?

For that we probably want to remove the filter(|arg| arg.is_const()) and such and instead look at all const and type parameters to find the right one. Feel free to either add a FIXME in that method or implement it in this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed them all to match on GenericArg::Infer | GenericArg::Const which may need to be changed since some code depends on matching on GenericParamDefKind::Const, but need to double check that

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Copy link
Contributor

Choose a reason for hiding this comment

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

this isn't quite right, further down we use the arg_index while filtering by matches!(param.kind, ty::GenericParamDefKind::Const { .. }) so we can get mismatches here. I think we want to filter with !arg.is_lifetime()

Copy link
Contributor Author

@JulianKnodt JulianKnodt Jul 26, 2021

Choose a reason for hiding this comment

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

hm just changing it to lifetimes doesn't seem to work, is there any reason to filter later and instead just move the conditional into the position call: position(|a| matches!(a, Infer|Const) && ...)? and have nth(index)
(sorry, it's a bit late where I am so will get to this tmrw)

Copy link
Contributor

Choose a reason for hiding this comment

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

you also have to modify the GenericParamKind filter when searching for the param in the generics.

Copy link
Contributor

Choose a reason for hiding this comment

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

i.e. use !is_lifetime both when computing and when using the arg_index

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've been trying to finagle this, but it seems to be more annoying than this small change, so I'll just leave a FIXME

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@lcnr
Copy link
Contributor

lcnr commented Jul 27, 2021

@bors r=oli-obk,lcnr

@bors
Copy link
Collaborator

bors commented Jul 27, 2021

📌 Commit 8759f00 has been approved by oli-obk,lcnr

@lcnr
Copy link
Contributor

lcnr commented Jul 27, 2021

while I assume it won't matter, better safe than sorry
@bors rollup=never

@bors
Copy link
Collaborator

bors commented Jul 27, 2021

⌛ Testing commit 8759f00 with merge cc4cb3f8f09c50d50407106fee4b008df6e11b1e...

@bors
Copy link
Collaborator

bors commented Jul 27, 2021

💔 Test failed - checks-actions

@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@lcnr
Copy link
Contributor

lcnr commented Jul 27, 2021

@bors retry

@bors
Copy link
Collaborator

bors commented Jul 27, 2021

⌛ Testing commit 8759f00 with merge fd853c0...

@bors
Copy link
Collaborator

bors commented Jul 27, 2021

☀️ Test successful - checks-actions
Approved by: oli-obk,lcnr
Pushing fd853c0 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-const-generics Area: const generics (parameters and arguments) merged-by-bors This PR was explicitly merged by bors. 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.

9 participants