Skip to content

Commit

Permalink
fix: changes from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
baszalmstra committed Aug 22, 2020
1 parent ce4baed commit eb0da2c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 6 deletions.
1 change: 1 addition & 0 deletions crates/mun_compiler/src/diagnostics_snippets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use annotate_snippets::display_list::FormatOptions;
use annotate_snippets::snippet::{Annotation, AnnotationType, Slice, Snippet, SourceAnnotation};
use std::collections::HashMap;

/// Writes the specified syntax error to the output stream.
pub(crate) fn emit_syntax_error(
syntax_error: &SyntaxError,
relative_file_path: &str,
Expand Down
2 changes: 1 addition & 1 deletion crates/mun_compiler/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![allow(clippy::enum_variant_names)] // This is a HACK because we use salsa
//mod annotate;

mod db;
///! This library contains the code required to go from source code to binaries.
pub mod diagnostics;
Expand Down
2 changes: 1 addition & 1 deletion crates/mun_diagnostics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "mun_diagnostics"
version = "0.1.0"
authors = ["The Mun Team <[email protected]>"]
edition = "2018"
description = "Provides in depth diagnostic information for compiler errors"
description = "Provides in-depth diagnostic information for compiler errors"
documentation = "https://docs.mun-lang.org/v0.2"
readme = "README.md"
homepage = "https://mun-lang.org"
Expand Down
2 changes: 1 addition & 1 deletion crates/mun_diagnostics/src/hir/access_unknown_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{Diagnostic, SourceAnnotation};
use mun_hir::HirDisplay;
use mun_syntax::{ast, AstNode, TextRange};

/// An error that is emitted when trying to access a field that doesnt exist.
/// An error that is emitted when trying to access a field that doesn't exist.
///
/// ```mun
/// struct Foo {
Expand Down
7 changes: 5 additions & 2 deletions crates/mun_diagnostics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ mod hir;
use mun_hir::InFile;
use mun_syntax::TextRange;

///! This crate provides in depth human readable diagnostic information and fixes for compiler
///! This crate provides in-depth human-readable diagnostic information and fixes for compiler
///! errors that can be shared between the compiler and the language server.
///!
///! The processing of diagnostics into human readable is separated from the machine readable
///! The processing of diagnostics into human-readable is separated from the machine-readable
///! diagnostics in for instance the HIR crate for performance reasons. This enables lazily querying
///! the system for more information only when required.
Expand Down Expand Up @@ -52,12 +52,15 @@ pub trait Diagnostic {
}
}

/// When implemented enables requesting `Diagnostic`s for the implementer.
pub trait DiagnosticFor {
/// Calls the specified function `f` with an instance of a [`Diagnostic`]. This can be used
/// to perform lazy diagnostic evaluation.
fn with_diagnostic<R, F: FnMut(&dyn Diagnostic) -> R>(&self, f: F) -> R;
}

/// Like [`DiagnosticFor`], enables requesting `Diagnostic`s for the implementer but only if passed
/// a required object.
pub trait DiagnosticForWith<With> {
/// Calls the specified function `f` with an instance of a [`Diagnostic`]. This can be used
/// to perform lazy diagnostic evaluation.
Expand Down
2 changes: 1 addition & 1 deletion crates/mun_hir/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl Ty {
})
}

/// Returns true if the specified value is a valid type or whether an error occured with it.
/// Returns true if this instance represents a known type.
pub fn is_known(&self) -> bool {
match self {
Ty::Unknown => false,
Expand Down

0 comments on commit eb0da2c

Please sign in to comment.