Stream: t-compiler/wg-rls-2.0

Topic: root-database

pksunkara (Apr 24 2020 at 15:47, on Zulip):

Hey, I am having some issues trying to work with the RootDatabase.

    let analysis_host = WorldState::new(
        workspaces, // built from cur_dir

    let snapshot = analysis_host.analysis();

    snapshot.with_db(|db| {
            for &root in db.local_roots().iter() {
                let sr = db.source_root(root);
                println!("{:#?}", sr);

                for file_id in sr.walk() {
                    println!("{:#?}", file_id);

The output is:

SourceRoot {
    is_library: false,
    files: {},

What happened to the files that were supposed to be in the source root?

pksunkara (Apr 24 2020 at 16:07, on Zulip):

WorldState is somehow the issue. I loaded the AnalysisHost using cli::load_cargo and it worked

matklad (Apr 26 2020 at 21:16, on Zulip):

The files are loaded asynchronosly

matklad (Apr 26 2020 at 21:17, on Zulip):

Ie, creating world-state starts the process of scanning files, but you need to handle vfs tasks to complete it

pksunkara (Apr 26 2020 at 21:39, on Zulip):


pksunkara (May 03 2020 at 12:33, on Zulip):

@matklad Just to confirm, looks like load_cargo is not loading library_roots. Is that right?

pksunkara (May 03 2020 at 17:53, on Zulip):

Maybe not loading libraries is the reason I am getting the following error:

pksunkara (May 03 2020 at 17:54, on Zulip):
        .with_db(|db| {
            let semantics = Semantics::new(db);
            // stuff
pksunkara (May 03 2020 at 17:54, on Zulip):
thread 'main' panicked at '

Failed to lookup METHOD_CALL_EXPR@91..14349 in this Semantics.
Make sure to use only query nodes, derived from this instance of Semantics.
root node:   SOURCE_FILE@0..14424
known nodes:

', <::std::macros::panic macros>:5:6
pksunkara (May 03 2020 at 22:01, on Zulip):

I have got the visitor we were talking about working to get some basic code analysis allowed but I am blocked on the above issue trying to get semantics info incorporated into the visitor

Last update: Sep 22 2020 at 01:30UTC