Skip to content

Why are region parameters not allowed on type parameters? #3277

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
bblum opened this issue Aug 25, 2012 · 3 comments
Closed

Why are region parameters not allowed on type parameters? #3277

bblum opened this issue Aug 25, 2012 · 3 comments
Labels
A-lifetimes Area: Lifetimes / regions

Comments

@bblum
Copy link
Contributor

bblum commented Aug 25, 2012

unsafe fn transmute_region<T>(x: T/&a) -> T/&b {
    unsafe { unsafe::transmute(x) }
}

refuses to compile with:

trans.rs:1:33: 1:34 error: region parameters are not allowed on this type
trans.rs:1 unsafe fn transmute_region<T>(x: T/&a) -> T/&b {
                                            ^
trans.rs:1:42: 1:43 error: region parameters are not allowed on this type
trans.rs:1 unsafe fn transmute_region<T>(x: T/&a) -> T/&b {
                                                     ^

Is there some unsafety lurking, is it impossible to implement, or is it just not implemented?

@nikomatsakis
Copy link
Contributor

It would be akin to writing T<S>. Type variables do not themselves take region parameters, only type paths (like, the name of a type def'n or a nominal type) do. Basically you can use the /& notation anywhere you could attach a type parameter. The bounds on type variables should be able to be region-bounded---but that is not fully implemented.

@bblum
Copy link
Contributor Author

bblum commented Aug 27, 2012

sure - I guess that'd be getting pretty close to higher-kinded polymorphism (or perhaps exactly that). I'm not sure I follow the last thing, though - do you mean region-bounded traits, like T: foo/&a?

@nikomatsakis
Copy link
Contributor

Yes, I mean precisely that.

RalfJung pushed a commit to RalfJung/rust that referenced this issue Jan 28, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-lifetimes Area: Lifetimes / regions
Projects
None yet
Development

No branches or pull requests

2 participants