@@ -6,6 +6,7 @@ use rustc::hir::Node;
66use rustc:: hir:: def_id:: DefId ;
77use rustc:: infer:: InferCtxt ;
88use rustc:: lint:: builtin:: UNUSED_MUT ;
9+ use rustc:: lint:: builtin:: { MUTABLE_BORROW_RESERVATION_CONFLICT } ;
910use rustc:: middle:: borrowck:: SignalledError ;
1011use rustc:: mir:: { AggregateKind , BasicBlock , BorrowCheckResult , BorrowKind } ;
1112use rustc:: mir:: {
@@ -26,7 +27,7 @@ use std::collections::BTreeMap;
2627use std:: mem;
2728use std:: rc:: Rc ;
2829
29- use syntax_pos:: Span ;
30+ use syntax_pos:: { Span , DUMMY_SP } ;
3031
3132use crate :: dataflow:: indexes:: { BorrowIndex , InitIndex , MoveOutIndex , MovePathIndex } ;
3233use crate :: dataflow:: move_paths:: { HasMoveData , LookupResult , MoveData , MoveError } ;
@@ -262,11 +263,19 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
262263 }
263264 mbcx. analyze_results ( & mut state) ; // entry point for DataflowResultsConsumer
264265
265- // Buffer any reservation warnings.
266+ // Convert any reservation warnings into lints .
266267 let reservation_warnings = mem:: replace ( & mut mbcx. reservation_warnings , Default :: default ( ) ) ;
267268 for ( _, ( place, span, context, bk, borrow) ) in reservation_warnings {
268- let mut diag = mbcx. report_conflicting_borrow ( context, ( & place, span) , bk, & borrow) ;
269- downgrade_if_error ( & mut diag) ;
269+ let mut initial_diag = mbcx. report_conflicting_borrow ( context, ( & place, span) , bk, & borrow) ;
270+
271+ // Span and message don't matter; we overwrite them below anyway
272+ let mut diag = mbcx. infcx . tcx . struct_span_lint_hir (
273+ MUTABLE_BORROW_RESERVATION_CONFLICT , id, DUMMY_SP , "" ) ;
274+
275+ diag. message = initial_diag. styled_message ( ) . clone ( ) ;
276+ diag. span = initial_diag. span . clone ( ) ;
277+
278+ initial_diag. cancel ( ) ;
270279 diag. buffer ( & mut mbcx. errors_buffer ) ;
271280 }
272281
0 commit comments