Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 074ae21

Browse files
committed
Collect crate files after expansion but before analysis
Reason for that being so that non-syntax errors should still allow us to reason about which file belongs to a given crate, which specifically allows us to run a formatter even if the code contains type errors or similar.
1 parent 8ee1721 commit 074ae21

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

rls/src/build/rustc.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl rustc_driver::Callbacks for RlsRustcCalls {
166166
Compilation::Continue
167167
}
168168

169-
fn after_analysis(&mut self, compiler: &interface::Compiler) -> Compilation {
169+
fn after_expansion(&mut self, compiler: &interface::Compiler) -> Compilation {
170170
let sess = compiler.session();
171171
let input = compiler.input();
172172
let crate_name = compiler.crate_name().unwrap().peek().clone();
@@ -189,11 +189,20 @@ impl rustc_driver::Callbacks for RlsRustcCalls {
189189
},
190190
};
191191

192+
// We populate the file -> edition mapping only after expansion since it
193+
// can pull additional input files
192194
let mut input_files = self.input_files.lock().unwrap();
193195
for file in fetch_input_files(sess) {
194196
input_files.entry(file).or_default().insert(krate.clone());
195197
}
196198

199+
Compilation::Continue
200+
}
201+
202+
fn after_analysis(&mut self, compiler: &interface::Compiler) -> Compilation {
203+
let input = compiler.input();
204+
let crate_name = compiler.crate_name().unwrap().peek().clone();
205+
197206
// Guaranteed to not be dropped yet in the pipeline thanks to the
198207
// `config.opts.debugging_opts.save_analysis` value being set to `true`.
199208
let expanded_crate = &compiler.expansion().unwrap().peek().0;

0 commit comments

Comments
 (0)