by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Artur Jamro
    @Mrowqa
    should we query hir map?
    Niko Matsakis
    @nikomatsakis
    @Mrowqa nope
    we want to use the generics_of query
    tcx.generics_of(fn_def_id);
    this will give us a &'tcx ty::Generics
    then you can use the type_param method to get the TypeParameterDef
    this is the definition of the type parameter being referenced
    (it looks like it doesn't take the index directly, but rather the ParamTy struct I pointed you at earlier)
    in particular, each type parameter has a DefId as well
    Niko Matsakis
    @nikomatsakis
    then we can call the tcx.has_attr function with that def-id and "must_root" to see if it was annotated with #[must_root] -- but there is one catch
    it appears there is a bug in has_attr that will mean it won't work on type parameters, but one you can easily fix
    I'm gonna have to go in 10 minutes due to another mtg
    Artur Jamro
    @Mrowqa
    okay
    Niko Matsakis
    @nikomatsakis
    but we've kind of reached the end of this first part -- how to support #[must_root] on type parameters
    Artur Jamro
    @Mrowqa
    we can continue after the meeting
    Niko Matsakis
    @nikomatsakis
    i.e., I think a good first goal is to get that example I was giving you to give an error
    once we've got that working, we can go to the actual example we were interested in :)
    let me just quickly leave a note on that has_attr bug I mentioned
    for future reference
    Artur Jamro
    @Mrowqa
    ok
    Niko Matsakis
    @nikomatsakis
    btw -- @Mrowqa -- please feel free to ping me or privmsg me on gitter
    Artur Jamro
    @Mrowqa
    sure, thanks
    Niko Matsakis
    @nikomatsakis
    it'll be easier for me to respond to you promptly than e-mail, sorry
    I can't keep up with All The Channels :(
    anyway, that bug:
    so if you dig into the has_attr method, you'll see that for a local def-id,
    and that method doens't include a case for NodeTyParam
    so it probably needs one additional match arm, like
    Some(NodeTyParam(tp)) => Some(&tp.attrs[..]),
    oh, hmm, it looks like the hir::TypeParam also doesn't carry attributes
    weird
    well, then we also have to extend HIR lowering to pass in the attributes
    you can see that it already accesses them from the AST in a few places
    just needs a line similar to this one:
    attrs: self.lower_attrs(&f.attrs),
    sigh, that's a bit of a yak shave :)
    anyway, ok, gotta run, I hope that made sense, read it over, and ping me later :)
    Artur Jamro
    @Mrowqa
    okay, thanks; I'll implement checking the attr on generic type and then ping you
    I haven't build the rustc so far, so maybe we'll talk about it later if there will be a need
    Niko Matsakis
    @nikomatsakis
    @Mrowqa one tip, ./x.py check is really quite a bit faster as a way to check if you code type-checks all the way through
    the rustc-guide has various x.py incantations that may be of use to you
    Artur Jamro
    @Mrowqa
    @nikomatsakis https://github.com/servo/servo/pull/20264#pullrequestreview-105093903 i pushed some changes and questions related to them. I still haven't looked into rustc.
    Niko Matsakis
    @nikomatsakis
    @Mrowqa most of the comments appear to be just .
    is that intentional?
    oh, I see, the coments are in the code
    Niko Matsakis
    @nikomatsakis
    @Mrowqa left various answers. I think it roughly looks right, nice job -- problem I think is that has_attrs is wrong
    Artur Jamro
    @Mrowqa
    @nikomatsakis I have also answered your comments.
    Niko Matsakis
    @nikomatsakis
    @Mrowqa btw it seems fine to pass in a &hir::Generics
    instead of the DefId I suggested