fn parse(db: &dyn ParseDatabase, file: FileId) {
    let writer = StandardStream::stderr(ColorChoice::Auto);
    let config = Config::default();

    let diag = Diagnostic::error()
        .with_message("This is a crime")
        .with_labels(vec![Label::new(
            LabelStyle::Primary,
            FileId(0),
            db.line_range(file, 14).unwrap().start..db.line_range(file, 20).unwrap().end - 1,
        )]);

    // Using `FileCache::upcast` we can take anything that implements `Upcast<dyn SourceDatabase` and use it for emitting errors
    term::emit(&mut writer.lock(), &config, &FileCache::upcast(db), &diag).unwrap();
}
// Right now all this does is emit an error, but that's just an example
Right now all this does is emit an error, but that's just an example
Right now all this does is emit an error but that ' s just an example
fn parse(db: &dyn ParseDatabase, file: FileId) {
    let writer = StandardStream::stderr(ColorChoice::Auto);
    let config = Config::default();
    let diag = Diagnostic::error()
        .with_message("This is a crime")
        .with_labels(vec![Label::new(
            LabelStyle::Primary,
            FileId(0),
            db.line_range(file, 14).unwrap().start..db.line_range(file, 20).unwrap().end - 1,
        )]);
    // Using `FileCache::upcast` we can take anything that implements `Upcast<dyn SourceDatabase` and use it for emitting errors
    term::emit(&mut writer.lock(), &config, &FileCache::upcast(db), &diag).unwrap();
}
fn parse ( db : & dyn ParseDatabase , file : FileId ) { let writer = StandardStream :: stderr ( ColorChoice :: Auto ) ; let config = Config :: default ( ) ; let diag = Diagnostic :: error ( ) . with_message ( " " ) . with_labels ( vec ! [ Label new ( LabelStyle Primary FileId ( 0 ) db line_range ( file 14 ) unwrap ( ) start db line_range ( file 20 ) unwrap ( ) end 1 ) ] ) ; // Using `FileCache::upcast` we can take anything that implements `Upcast<dyn SourceDatabase` and use it for emitting errors term :: emit ( & mut writer . lock ( ) , & config , & FileCache :: upcast ( db ) , & diag ) . unwrap ( ) ; }
Right now all this does is emit an error, but that's just an example
Right now all this does is emit an error but that ' s just an example
db
&dyn ParseDatabase
file
FileId
db
&dyn ParseDatabase
file
FileId