Skip to content

Conversation

@jackh726
Copy link
Member

@jackh726 jackh726 commented Oct 20, 2021

Closes #89122

Blocked on lang FCP

r? @nikomatsakis

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

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Oct 23, 2021

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

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

As discussed on our call, let's change this to store a usize "split point" instead.

@apiraino apiraino added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 28, 2021
@nikomatsakis

This comment has been minimized.

@rfcbot

This comment has been minimized.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Nov 5, 2021
@lcnr
Copy link
Contributor

lcnr commented Nov 5, 2021

One concern I have are generic constants, for example

const SIZE_OF<T>: usize = std::mem::size_of::<T>();

trait IsEqual: 'static {
    const TO<U: 'static>: bool;
}
impl<T: 'static> IsEqual for T {
    const TO<U: 'static>: bool = TypeId::of::<T>() == TypeId::of::<U>();
}

while both of these are currently not allowed in Rust, I personally quite strongly believe that we should add them in the future and want to at least want to keep this option open. Can we unambiguously parse where X after an expression? I would assume yes but am not sure myself.

impl<T: 'static> IsEqual for T {
    const TO<U>: bool = TypeId::of::<T>() == TypeId::of::<U>()
    where
        U: 'static;
}

@nikomatsakis nikomatsakis removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 5, 2021
@nikomatsakis
Copy link
Contributor

@rfcbot fcp cancel

@nikomatsakis
Copy link
Contributor

This shouldn't have been a T-compiler FCP!

@nikomatsakis nikomatsakis added the T-lang Relevant to the language team label Nov 5, 2021
@nikomatsakis

This comment has been minimized.

@nikomatsakis
Copy link
Contributor

nikomatsakis commented Nov 5, 2021

@lcnr

One concern I have are generic constants, for example

const SIZE_OF<T>: usize = std::mem::size_of::<T>();

trait IsEqual: 'static {
    const TO<U: 'static>: bool;
}
impl<T: 'static> IsEqual for T {
    const TO<U: 'static>: bool = TypeId::of::<T>() == TypeId::of::<U>();
}

while both of these are currently not allowed in Rust, I personally quite strongly believe that we should add them in the future and want to at least want to keep this option open. Can we unambiguously parse where X after an expression? I would assume yes but am not sure myself.

Ah, good call! I'm glad you brought that up, we didn't discuss associated constants in the meeting. I'm not worried about parsing ambiguities, the where keyword is a pretty strong signal that we've reached the end of the expression (it's not presently used anywhere else in Rust that I know of).

I'm not 100% sure where I think where should go relative to the = though. It seems to depend a bit on the size of the constant expression.

EDIT: Upon further reflection, I think that I would probably expect where clauses to come after the value for const expressions, too, for the same reasons give above. I don't really expect "complex" const values that span many lines; though I don't doubt they will occur, I suspect it would also be better for folks to factor them out into a const fn.

@petrochenkov
Copy link
Contributor

petrochenkov commented Nov 6, 2021

@nikomatsakis

I'm not 100% sure where I think where should go relative to the = though. It seems to depend a bit on the size of the constant expression.

Do you remember the Centril's proposal to abbreviate fn foo() { result } to fn foo() = result;?
That is a very reasonable thing to do if the body is short, or the body is some kind of match or loop, and I'd still want to have it accepted one day.
(I can't find the relevant RFC PR/issue, unfortunately.)

fn foo() -> u8 = match x {
    A => 1,
    B => 2,
    C => 3,
    _ => 999,
};

What is the preferable position for where in this case?

@petrochenkov petrochenkov self-assigned this Nov 6, 2021
@petrochenkov
Copy link
Contributor

(Self-assigning, because I have some comments about the implementation as well.)

@camelid
Copy link
Member

camelid commented Nov 6, 2021

(I can't find the relevant RFC PR/issue, unfortunately.)

I believe this is it: Centril/rfcs#17

@petrochenkov
Copy link
Contributor

petrochenkov commented Nov 7, 2021

Something is wrong with the FCP here, it's still active and assigned to the compiler team.
@rfcbot fcp cancel

UPD: The previous cancel didn't work because nikomatsakis removed the T-compiler label before writing @rfcbot fcp cancel.

@petrochenkov

This comment has been minimized.

@petrochenkov petrochenkov added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed T-lang Relevant to the language team labels Nov 7, 2021
@petrochenkov
Copy link
Contributor

@rfcbot fcp cancel

@rfcbot
Copy link

rfcbot commented Nov 7, 2021

@petrochenkov proposal cancelled.

@rfcbot rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Nov 7, 2021
@bors
Copy link
Collaborator

bors commented Mar 6, 2022

⌛ Testing commit 29f0837501e6f6af372e9274d4ba575409e6f524 with merge 3e5332fe9b563beb405e82b84f4fb648b79b2780...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Mar 6, 2022

💔 Test failed - checks-actions

@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 Mar 6, 2022
@jackh726
Copy link
Member Author

jackh726 commented Mar 6, 2022

Let's try this again.

@bors r=nikomatsakis

@bors
Copy link
Collaborator

bors commented Mar 6, 2022

📌 Commit d16ec7b has been approved by nikomatsakis

@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 Mar 6, 2022
@bors
Copy link
Collaborator

bors commented Mar 6, 2022

⌛ Testing commit d16ec7b with merge ad0d1d7...

@bors
Copy link
Collaborator

bors commented Mar 6, 2022

☀️ Test successful - checks-actions
Approved by: nikomatsakis
Pushing ad0d1d7 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 6, 2022
@bors bors merged commit ad0d1d7 into rust-lang:master Mar 6, 2022
@rustbot rustbot added this to the 1.61.0 milestone Mar 6, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (ad0d1d7): comparison url.

Summary: This benchmark run did not return any relevant results.

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

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

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. 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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team