diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-01-03 08:56:17 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-03 08:56:17 +0000 |
| commit | 520b8a5a4dde032ba6118efb02801611191acc4e (patch) | |
| tree | 811cd86e5c9a2803bc3d38f19f4ad86e60be1d18 /crates/rust-analyzer/src | |
| parent | 3bf4cec79932de0a49338f6b87dc20f85dc3a509 (diff) | |
| parent | 40cd6cdf67dcfad89a80ff3a662bec2dfd983d67 (diff) | |
| download | rust-520b8a5a4dde032ba6118efb02801611191acc4e.tar.gz rust-520b8a5a4dde032ba6118efb02801611191acc4e.zip | |
Merge #7115
7115: Migrate HasSource::source to return Option r=matklad a=nick96 I've made a start on fixing #6913 based on the provided work plan, migrating `HasSource::source` to return an `Option`. The simple cases are migrated but there are a few that I'm unsure exactly how they should be handled: - Logging the processing of functions in `AnalysisStatsCmd::run`: In verbose mode it includes the path to the module containing the function and the syntax range. I've handled this with an if-let but would it be better to blow up here with `expect`? I'm not 100% on the code paths but if we're processing a function definition then the source should exist. I've handled `source()` in all code paths as `None` being a valid return value but are there some cases where we should just blow up? Also, all I've done is bubble up the returned `None`s, there may be some places where we can recover and still provide something. Co-authored-by: Nick Spain <nicholas.spain@stileeducation.com> Co-authored-by: Nick Spain <nicholas.spain96@gmail.com>
Diffstat (limited to 'crates/rust-analyzer/src')
| -rw-r--r-- | crates/rust-analyzer/src/cli/analysis_stats.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/rust-analyzer/src/cli/analysis_stats.rs b/crates/rust-analyzer/src/cli/analysis_stats.rs index a23fb7a33a4..9445aec074d 100644 --- a/crates/rust-analyzer/src/cli/analysis_stats.rs +++ b/crates/rust-analyzer/src/cli/analysis_stats.rs @@ -161,11 +161,12 @@ impl AnalysisStatsCmd { } let mut msg = format!("processing: {}", full_name); if verbosity.is_verbose() { - let src = f.source(db); - let original_file = src.file_id.original_file(db); - let path = vfs.file_path(original_file); - let syntax_range = src.value.syntax().text_range(); - format_to!(msg, " ({} {:?})", path, syntax_range); + if let Some(src) = f.source(db) { + let original_file = src.file_id.original_file(db); + let path = vfs.file_path(original_file); + let syntax_range = src.value.syntax().text_range(); + format_to!(msg, " ({} {:?})", path, syntax_range); + } } if verbosity.is_spammy() { bar.println(msg.to_string()); |
