Skip to content

Conversation

compiler-errors
Copy link
Member

We weren't visiting the const generic default argument in rustc_resolve::late::lifetimes. This seems to fix the issue, and we deny any non-'static lifetimes anyways.

Fixes #93647

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Feb 5, 2022
@rust-highfive
Copy link
Contributor

r? @estebank

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 5, 2022
@lcnr
Copy link
Contributor

lcnr commented Feb 5, 2022

can you add a test for

struct Foo<'a, const N: usize = {
    let x: &'a ();
    3
}>(&'a ());

completely missed lifetimes in const param defaults, this should error.

after that r=me, thanks

@lcnr lcnr added the beta-nominated Nominated for backporting to the compiler in the beta channel. label Feb 5, 2022
@lcnr
Copy link
Contributor

lcnr commented Feb 5, 2022

missed lifetimes in const parameter defaults, which are currently stable on beta. Shouldn't stabilize them with this oversight

@lcnr
Copy link
Contributor

lcnr commented Feb 5, 2022

r? @lcnr

@rust-highfive rust-highfive assigned lcnr and unassigned estebank Feb 5, 2022
@compiler-errors
Copy link
Member Author

done. this catches that too, since the logic of detecting non-'static lifetimes was baked into region resolution for consts already.

@@ -0,0 +1,10 @@
struct Foo<
'a,
Copy link
Member Author

Choose a reason for hiding this comment

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

haha rustfmt is so weird, i swear i didn't do this

Copy link
Contributor

Choose a reason for hiding this comment

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

^^

@lcnr
Copy link
Contributor

lcnr commented Feb 5, 2022

thanks for the fix ❤️

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Feb 5, 2022

📌 Commit bcf9884 has been approved by lcnr

@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 Feb 5, 2022
@lcnr lcnr added A-const-generics Area: const generics (parameters and arguments) F-const_generics_defaults `#![feature(const_generics_defaults)]` labels Feb 5, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 5, 2022
… r=lcnr

Resolve lifetimes for const generic defaults

We weren't visiting the const generic default argument in `rustc_resolve::late::lifetimes`. This seems to fix the issue, and we deny any non-`'static` lifetimes anyways.

Fixes rust-lang#93647
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 6, 2022
…askrgr

Rollup of 9 pull requests

Successful merges:

 - rust-lang#91939 (Clarify error on casting larger integers to char)
 - rust-lang#92300 (mips64-openwrt-linux-musl: Add Tier 3 target)
 - rust-lang#92383 (Add new target armv7-unknown-linux-uclibceabi (softfloat))
 - rust-lang#92651 (Remove "up here" arrow on item-infos)
 - rust-lang#93556 (Change struct expr pretty printing to match rustfmt style)
 - rust-lang#93649 (Add regression tests for issue 80309)
 - rust-lang#93657 (Update CPU idle tracking for apple hosts)
 - rust-lang#93659 (Refactor conditional)
 - rust-lang#93669 (Resolve lifetimes for const generic defaults)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit cbf4b46 into rust-lang:master Feb 6, 2022
@rustbot rustbot added this to the 1.60.0 milestone Feb 6, 2022
Alexendoo added a commit to rust-lang/glacier that referenced this pull request Feb 7, 2022
That was fixed separately by rust-lang/rust#93669

Closes #1109
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 8, 2022
…thewjasper

update comment wrt const param defaults

after rust-lang#93669 i looked through all other uses of `GenericParamKind::Const` again to detect if we missed the `default` there as well, but afaict we really only missed lifetime resolution '^^ at least i found an outdated comment :3
@apiraino
Copy link
Contributor

Beta backport approved as per compiler team on Zulip

@rustbot label +beta-accepted

@rustbot rustbot added the beta-accepted Accepted for backporting to the compiler in the beta channel. label Feb 10, 2022
@Mark-Simulacrum Mark-Simulacrum removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Feb 11, 2022
@Mark-Simulacrum Mark-Simulacrum modified the milestones: 1.60.0, 1.59.0 Feb 11, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 12, 2022
…ulacrum

[beta] backports

This backports:

*  Complete removal of #[main] attribute from compiler rust-lang#93753
*  Resolve lifetimes for const generic defaults rust-lang#93669
*  backport llvm fix for issue 91671. rust-lang#93426
*  Fix invalid special casing of the unreachable! macro rust-lang#93179
*  Fix hashing for windows paths containing a CurDir component rust-lang#93697

r? `@Mark-Simulacrum`
@compiler-errors compiler-errors deleted the const-generic-args branch April 7, 2022 04:32
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) beta-accepted Accepted for backporting to the compiler in the beta channel. F-const_generics_defaults `#![feature(const_generics_defaults)]` 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Const generic defaults ICE: No bound vars found
8 participants