Stream: t-compiler/rust-analyzer

Topic: Path::from_src

Edwin Cheng (Dec 18 2019 at 17:25, on Zulip):

@matklad Do you think now is a good time/idea to change

fn Path::from_src(path: ast::Path, hygiene: &Hygiene)


fn Path::from_src(InFile<path: ast::Path>)

And then construct the hygiene inside this function instead ?

Florian Diebold (Dec 18 2019 at 17:35, on Zulip):

you'd probably need the db to get from a HirFileId to the Hygiene?

Edwin Cheng (Dec 18 2019 at 17:50, on Zulip):

Oh... yes, we need it. :(

Edwin Cheng (Dec 18 2019 at 17:54, on Zulip):

Or can we change Hygiene such that it only store FileId instead ? And change DollarCrate to DollarCrate(MacroFile) ?

Edwin Cheng (Dec 18 2019 at 18:00, on Zulip):

OTOH, right nowTypeRef::from_ast are using Path::from_ast which is lack of Hygiene information.
But passing InFile<ast::whatever> is much easier than passing a hygiene (or db) through the whole lowering infer-structure, right ?

matklad (Dec 18 2019 at 21:09, on Zulip):

@Edwin Cheng this needs some design, but I imagine that, rather than having Path::from_src, we should have

struct LowerCtx {
    hygiene: Hygiene,
    db: DB, // not sure if really needed
    source_map // very much to be designed

impl LowerCtx {
  fn lower_path(ast: &ast::Path) -> hir::Path
  fn lower_type(ty: &ast::TypeRef) -> hir::TypeRef
Last update: Jul 29 2021 at 22:00UTC