Skip to content

Commit 8f5609e

Browse files
committed
Fix edition used for include macro parsing
1 parent a324e46 commit 8f5609e

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

crates/hir-expand/src/builtin_fn_macro.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::{
1818
name, quote,
1919
quote::dollar_crate,
2020
tt::{self, DelimSpan},
21-
ExpandError, ExpandResult, HirFileIdExt, MacroCallId, MacroFileIdExt,
21+
ExpandError, ExpandResult, HirFileIdExt, Lookup as _, MacroCallId,
2222
};
2323

2424
macro_rules! register_builtin {
@@ -687,8 +687,8 @@ fn relative_file(
687687
path_str: &str,
688688
allow_recursion: bool,
689689
) -> Result<EditionedFileId, ExpandError> {
690-
let call_site =
691-
call_id.as_macro_file().parent(db).original_file_respecting_includes(db).file_id();
690+
let lookup = call_id.lookup(db);
691+
let call_site = lookup.kind.file_id().original_file_respecting_includes(db).file_id();
692692
let path = AnchoredPath { anchor: call_site, path: path_str };
693693
let res = db
694694
.resolve_path(path)
@@ -697,7 +697,7 @@ fn relative_file(
697697
if res == call_site && !allow_recursion {
698698
Err(ExpandError::other(format!("recursive inclusion of `{path_str}`")))
699699
} else {
700-
Ok(EditionedFileId::new(res, Edition::CURRENT_FIXME))
700+
Ok(EditionedFileId::new(res, db.crate_graph()[lookup.krate].edition))
701701
}
702702
}
703703

crates/rust-analyzer/src/cli/diagnostics.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ use project_model::{CargoConfig, RustLibSource};
55
use rustc_hash::FxHashSet;
66

77
use hir::{db::HirDatabase, Crate, HirFileIdExt, Module};
8-
use ide::{AnalysisHost, AssistResolveStrategy, DiagnosticsConfig, Severity};
9-
use ide_db::base_db::SourceDatabaseExt;
8+
use ide::{AnalysisHost, AssistResolveStrategy, Diagnostic, DiagnosticsConfig, Severity};
9+
use ide_db::{base_db::SourceDatabaseExt, LineIndexDatabase};
1010
use load_cargo::{load_workspace_at, LoadCargoConfig, ProcMacroServerChoice};
1111

1212
use crate::cli::flags;
@@ -74,7 +74,11 @@ impl flags::Diagnostics {
7474
found_error = true;
7575
}
7676

77-
println!("{diagnostic:?}");
77+
let Diagnostic { code, message, range, severity, .. } = diagnostic;
78+
let line_index = db.line_index(range.file_id);
79+
let start = line_index.line_col(range.range.start());
80+
let end = line_index.line_col(range.range.end());
81+
println!("{severity:?} {code:?} from {start:?} to {end:?}: {message}");
7882
}
7983

8084
visited_files.insert(file_id);

xtask/src/metrics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use std::{
66
time::{Instant, SystemTime, UNIX_EPOCH},
77
};
88

9-
use anyhow::{bail, format_err};
9+
use anyhow::format_err;
1010
use xshell::{cmd, Shell};
1111

1212
use crate::flags::{self, MeasurementType};
@@ -193,7 +193,7 @@ impl Metrics {
193193
impl Host {
194194
fn new(sh: &Shell) -> anyhow::Result<Host> {
195195
if cfg!(not(target_os = "linux")) {
196-
bail!("can only collect metrics on Linux ");
196+
return Ok(Host { os: "unknown".into(), cpu: "unknown".into(), mem: "unknown".into() });
197197
}
198198

199199
let os = read_field(sh, "/etc/os-release", "PRETTY_NAME=")?.trim_matches('"').to_owned();

0 commit comments

Comments
 (0)