-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.F-impl_trait_in_bindings`#![feature(impl_trait_in_bindings)]``#![feature(impl_trait_in_bindings)]`requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Description
The following code should probably work. (cc @Aaron1011)
#![feature(impl_trait_in_bindings)]
static FOO: impl Copy = &FOO;
fn main() {
}
Errors:
Compiling playground v0.0.1 (/playground)
error: non-defining existential type use in defining scope
--> src/main.rs:2:25
|
2 | static FOO: impl Copy = &FOO;
| ^^^^ lifetime `'<empty>` is part of concrete type but not used in parameter list of existential type
error: aborting due to previous error
error: Could not compile `playground`.
To learn more, run the command again with --verbose.
Metadata
Metadata
Assignees
Labels
A-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.C-bugCategory: This is a bug.Category: This is a bug.F-impl_trait_in_bindings`#![feature(impl_trait_in_bindings)]``#![feature(impl_trait_in_bindings)]`requires-nightlyThis issue requires a nightly compiler in some way.This issue requires a nightly compiler in some way.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
[-]Recursive struct with impl Trait errors out early[/-][+]Recursive static with impl Trait errors out early[/+]jyn514 commentedon Jul 7, 2021
Triage: the current error for this is
@oli-obk why do you say this should compile? It seems strange that you could have a completely unconstrainted type, FOO has no defining use.
oli-obk commentedon Jul 8, 2021
I just assumed that considering that
compiles, that the impl trait version should compile, too. But we can just make a decision and declare this kind of cyclic static to be irrelevant and thus we can just ignore it. It's in the defining use scope, so it gets revealed, which would cause an infinitely deep reference (
&&&&&&&&&&...
), so it's not really useful or even well defined.