10
10
11
11
//! # Standalone Tests for the Inference Module
12
12
13
- use diagnostic;
14
- use diagnostic:: Emitter ;
15
13
use driver;
16
14
use rustc_lint;
17
15
use rustc_resolve as resolve;
@@ -34,9 +32,10 @@ use rustc::front::map as hir_map;
34
32
use rustc:: session:: { self , config} ;
35
33
use std:: rc:: Rc ;
36
34
use syntax:: { abi, ast} ;
37
- use syntax:: codemap;
38
35
use syntax:: codemap:: { Span , CodeMap , DUMMY_SP } ;
39
- use syntax:: diagnostic:: { Level , RenderSpan , Bug , Fatal , Error , Warning , Note , Help } ;
36
+ use syntax:: errors;
37
+ use syntax:: errors:: emitter:: Emitter ;
38
+ use syntax:: errors:: { Level , RenderSpan } ;
40
39
use syntax:: parse:: token;
41
40
use syntax:: feature_gate:: UnstableFeatures ;
42
41
@@ -60,8 +59,8 @@ struct ExpectErrorEmitter {
60
59
61
60
fn remove_message ( e : & mut ExpectErrorEmitter , msg : & str , lvl : Level ) {
62
61
match lvl {
63
- Bug | Fatal | Error => { }
64
- Warning | Note | Help => {
62
+ Level :: Bug | Level :: Fatal | Level :: Error => { }
63
+ Level :: Warning | Level :: Note | Level :: Help => {
65
64
return ;
66
65
}
67
66
}
@@ -79,14 +78,14 @@ fn remove_message(e: &mut ExpectErrorEmitter, msg: &str, lvl: Level) {
79
78
80
79
impl Emitter for ExpectErrorEmitter {
81
80
fn emit ( & mut self ,
82
- _cmsp : Option < ( & codemap :: CodeMap , Span ) > ,
81
+ _sp : Option < Span > ,
83
82
msg : & str ,
84
83
_: Option < & str > ,
85
84
lvl : Level ) {
86
85
remove_message ( self , msg, lvl) ;
87
86
}
88
87
89
- fn custom_emit ( & mut self , _cm : & codemap :: CodeMap , _sp : RenderSpan , msg : & str , lvl : Level ) {
88
+ fn custom_emit ( & mut self , _sp : RenderSpan , msg : & str , lvl : Level ) {
90
89
remove_message ( self , msg, lvl) ;
91
90
}
92
91
}
@@ -105,13 +104,11 @@ fn test_env<F>(source_string: &str,
105
104
let mut options = config:: basic_options ( ) ;
106
105
options. debugging_opts . verbose = true ;
107
106
options. unstable_features = UnstableFeatures :: Allow ;
108
- let codemap = CodeMap :: new ( ) ;
109
- let diagnostic_handler = diagnostic:: Handler :: with_emitter ( true , emitter) ;
110
- let span_diagnostic_handler = diagnostic:: SpanHandler :: new ( diagnostic_handler, codemap) ;
107
+ let diagnostic_handler = errors:: Handler :: with_emitter ( true , false , emitter) ;
111
108
112
109
let cstore = Rc :: new ( CStore :: new ( token:: get_ident_interner ( ) ) ) ;
113
- let sess = session:: build_session_ ( options, None , span_diagnostic_handler ,
114
- cstore. clone ( ) ) ;
110
+ let sess = session:: build_session_ ( options, None , diagnostic_handler ,
111
+ Rc :: new ( CodeMap :: new ( ) ) , cstore. clone ( ) ) ;
115
112
rustc_lint:: register_builtins ( & mut sess. lint_store . borrow_mut ( ) , Some ( & sess) ) ;
116
113
let krate_config = Vec :: new ( ) ;
117
114
let input = config:: Input :: Str ( source_string. to_string ( ) ) ;
@@ -366,13 +363,6 @@ impl<'a, 'tcx> Env<'a, 'tcx> {
366
363
self . infcx . glb ( true , trace)
367
364
}
368
365
369
- pub fn make_lub_ty ( & self , t1 : Ty < ' tcx > , t2 : Ty < ' tcx > ) -> Ty < ' tcx > {
370
- match self . lub ( ) . relate ( & t1, & t2) {
371
- Ok ( t) => t,
372
- Err ( ref e) => panic ! ( "unexpected error computing LUB: {}" , e) ,
373
- }
374
- }
375
-
376
366
/// Checks that `t1 <: t2` is true (this may register additional
377
367
/// region checks).
378
368
pub fn check_sub ( & self , t1 : Ty < ' tcx > , t2 : Ty < ' tcx > ) {
0 commit comments