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

associated_item table is not populated after type error. #40343

Closed
nrc opened this issue Mar 8, 2017 · 4 comments
Closed

associated_item table is not populated after type error. #40343

nrc opened this issue Mar 8, 2017 · 4 comments
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@nrc
Copy link
Member

nrc commented Mar 8, 2017

This is the underlying cause of the ICE in #39957. I worked around it in save-analysis, but @eddyb (cc) asked me to file an issue since it might cause bugs elsewhere.

Example code:

#![feature(try_from)]
use std::convert::TryFrom;

struct Test;
impl Test {
    fn foo(&self) -> &'static str {
        "asdf"
    }
}

impl TryFrom for Test {} //~ ERROR: wrong number of type arguments: expected 1, found 0

Because of the error on the last line, we never create the associated_item table on the tcx, which means that both impl_of_method and trait_of_item return None for foo.

@arielb1
Copy link
Contributor

arielb1 commented Mar 8, 2017

associated_item is constructed on demand:

pub fn associated_item(self, def_id: DefId) -> AssociatedItem {
, so I wonder what is going on here. Can you confirm that impl_of_method returns None?

@eddyb
Copy link
Member

eddyb commented Mar 8, 2017

@arielb1 The solution proposed on IRC is to remove both of those and instead have a way of checking if a an arbitrary DefId is an associated item and/or get an Option<ty::AssociatedItem> from it.
It's fairly simple, for cross-crate you check describe_def and locally the variant of hir::map::Node.

@arielb1
Copy link
Contributor

arielb1 commented Mar 8, 2017

@eddyb

Well, now that we have "HIR" AssociatedItem, we can move it to the HIR map.

@eddyb
Copy link
Member

eddyb commented Mar 8, 2017

Right, that'd make sense. There's a bunch of these that should be moved to HIR.

@Mark-Simulacrum Mark-Simulacrum added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label May 27, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 27, 2017
@cjgillot cjgillot closed this as completed Mar 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants