1
1
//! Used by `rustc` when loading a plugin.
2
2
3
+ use crate :: errors:: { LoadPluginError , MalformedPluginAttribute } ;
3
4
use crate :: Registry ;
4
5
use libloading:: Library ;
5
6
use rustc_ast:: Crate ;
6
- use rustc_errors:: struct_span_err;
7
7
use rustc_metadata:: locator;
8
8
use rustc_session:: cstore:: MetadataLoader ;
9
9
use rustc_session:: Session ;
10
10
use rustc_span:: symbol:: { sym, Ident } ;
11
- use rustc_span:: Span ;
12
11
13
- use std:: borrow:: ToOwned ;
14
12
use std:: env;
15
13
use std:: mem;
16
14
use std:: path:: PathBuf ;
17
15
18
16
/// Pointer to a registrar function.
19
17
type PluginRegistrarFn = fn ( & mut Registry < ' _ > ) ;
20
18
21
- fn call_malformed_plugin_attribute ( sess : & Session , span : Span ) {
22
- struct_span_err ! ( sess, span, E0498 , "malformed `plugin` attribute" )
23
- . span_label ( span, "malformed attribute" )
24
- . emit ( ) ;
25
- }
26
-
27
19
/// Read plugin metadata and dynamically load registrar functions.
28
20
pub fn load_plugins (
29
21
sess : & Session ,
@@ -42,7 +34,9 @@ pub fn load_plugins(
42
34
Some ( ident) if plugin. is_word ( ) => {
43
35
load_plugin ( & mut plugins, sess, metadata_loader, ident)
44
36
}
45
- _ => call_malformed_plugin_attribute ( sess, plugin. span ( ) ) ,
37
+ _ => {
38
+ sess. emit_err ( MalformedPluginAttribute { span : plugin. span ( ) } ) ;
39
+ }
46
40
}
47
41
}
48
42
}
@@ -60,7 +54,7 @@ fn load_plugin(
60
54
let fun = dylink_registrar ( lib) . unwrap_or_else ( |err| {
61
55
// This is fatal: there are almost certainly macros we need inside this crate, so
62
56
// continuing would spew "macro undefined" errors.
63
- sess. span_fatal ( ident. span , & err. to_string ( ) ) ;
57
+ sess. emit_fatal ( LoadPluginError { span : ident. span , msg : err. to_string ( ) } ) ;
64
58
} ) ;
65
59
plugins. push ( fun) ;
66
60
}
0 commit comments