Skip to content

Generic type can't be inferred through lambda block #1471

Closed
@brson

Description

@brson
Contributor
type actor<T> = {                                                                                                                                              
    unused: bool                                                                                                                                               
};                                                                                                                                                             

type self<T> = {                                                                                                                                               
    unused: bool                                                                                                                                               
};                                                                                                                                                             

fn act<T:send>(+behavior: sendfn(self<T>)) -> actor<T> {                                                                                                       
    {unused: true}                                                                                                                                             
}                                                                                                                                                              

tag in {                                                                                                                                                       
    preprocess([u8]);                                                                                                                                          
    exit;                                                                                                                                                      
}                                                                                                                                                              

fn mk() -> actor<in> {                                                                                                                                         
    act {|self|                                                                                                                                                
    }                                                                                                                                                          
}                                                                                                                                                              

fn main() {                                                                                                                                                    
}
../src/test/run-pass/block-infer.rs:19:4: 19:7 error: cannot determine a type for this expression
../src/test/run-pass/block-infer.rs:19     act {|self|

Writing act::<in> allows it to work.

Activity

brson

brson commented on Jan 9, 2012

@brson
ContributorAuthor

Writing act::<in> {|self: self<in>| doesn't work either.

brson

brson commented on Feb 6, 2012

@brson
ContributorAuthor

This doesn't have to do with lambda blocks at all. The following also doesn't work:

type actor<T> = {                                                                                                                                                             
    unused: bool                                                                                                                                                              
};                                                                                                                                                                            

fn act2<T:send>() -> actor<T> {                                                                                                                                               
}                                                                                                                                                                             

enum in {                                                                                                                                                                     
    preprocess([u8]),                                                                                                                                                         
    exit                                                                                                                                                                      
}                                                                                                                                                                             

fn mk() -> actor<in> {                                                                                                                                                        
    act2()                                                                                                                                                                    
}                                                                                                                                                                             

fn main() {                                                                                                                                                                   
}                                                                                                                                                                             
added a commit that references this issue on Oct 7, 2022
added a commit that references this issue on Oct 8, 2022

Rollup merge of rust-lang#102788 - joshtriplett:bump-rustc-dev-guide,…

870032b
added a commit that references this issue on Oct 8, 2022

Rollup merge of rust-lang#102788 - joshtriplett:bump-rustc-dev-guide,…

c2bd2f3
added a commit that references this issue on Oct 8, 2022

Rollup merge of rust-lang#102788 - joshtriplett:bump-rustc-dev-guide,…

dcc9316
added a commit that references this issue on Oct 8, 2022

Rollup merge of rust-lang#102788 - joshtriplett:bump-rustc-dev-guide,…

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @brson

        Issue actions

          Generic type can't be inferred through lambda block · Issue #1471 · rust-lang/rust