rust-analyzer/crates/ra_hir_def/src/diagnostics.rs
Aleksey Kladov 3c72fc0573 Anchor file-system operations to the file, and not to the source root.
Anchoring to the SourceRoot wont' work if the path is absolute:

  #[path = "/tmp/foo.rs"]
  mod foo;

Anchoring to a file will.

However, we *should* anchor, instead of just producing an abs path.

I can imagine a situation where, for example, rust-analyzer processes
crates from different machines (or, for example, from in-memory git
branch), where the same absolute path in different crates might refer
to different files in the end!
2020-06-16 18:45:58 +02:00

27 lines
627 B
Rust

//! Diagnostics produced by `hir_def`.
use std::any::Any;
use hir_expand::diagnostics::Diagnostic;
use ra_syntax::{ast, AstPtr, SyntaxNodePtr};
use hir_expand::{HirFileId, InFile};
#[derive(Debug)]
pub struct UnresolvedModule {
pub file: HirFileId,
pub decl: AstPtr<ast::Module>,
pub candidate: String,
}
impl Diagnostic for UnresolvedModule {
fn message(&self) -> String {
"unresolved module".to_string()
}
fn source(&self) -> InFile<SyntaxNodePtr> {
InFile::new(self.file, self.decl.clone().into())
}
fn as_any(&self) -> &(dyn Any + Send + 'static) {
self
}
}