Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

astconv/typeck unnecessarily instantiates type variables in non-root universe #79

Open
compiler-errors opened this issue Dec 14, 2023 · 1 comment · Fixed by rust-lang/rust#119106

Comments

@compiler-errors
Copy link
Member

compiler-errors commented Dec 14, 2023


When instantiating substs for ADTs, confirming methods, etc., we create new type variables in the current universe, rather than the root universe, even though these variables could be in the root universe since they represent the "surface" types of a Rust program.

This causes us to unnecessarily generalize aliases, leading to ambiguity.


TODO: minimize this test case:

use syn::Ident;
use syn::Attribute;
use syn::parse::*;

struct TypeParam {
    pub attrs: Vec<Attribute>,
    pub ident: Ident,
}

impl Parse for TypeParam {
    fn parse(input: ParseStream) -> Result<Self> {
        let attrs = input.call(Attribute::parse_outer)?;
        let ident = input.parse()?;

        Ok(TypeParam {
            attrs,
            ident,
        })
    }
}

which results in:

error[E0284]: type annotations needed: cannot satisfy `<std::result::Result<syn::Ident, syn::Error> as std::ops::Try>::Residual == <std::result::Result<_, syn::Error> as std::ops::Try>::Residual`
  --> src/lib.rs:13:34
   |
13 |         let ident = input.parse()?;
   |                                  ^ cannot satisfy `<std::result::Result<syn::Ident, syn::Error> as std::ops::Try>::Residual == <std::result::Result<_, syn::Error> as std::ops::Try>::Residual`
@compiler-errors
Copy link
Member Author

(for the record this is fixed, but could use a minimized test, which i'm too lazy to make personally)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants