@@ -29,6 +29,7 @@ use std::ascii::StrAsciiExt;
29
29
use std:: iter:: { Rev , Enumerate } ;
30
30
use std:: slice;
31
31
use std:: str:: Slice ;
32
+ use std:: fmt:: Show ;
32
33
33
34
pub struct ActiveFormattingIter < ' a , Handle > {
34
35
iter : Rev < Enumerate < slice:: Items < ' a , FormatEntry < Handle > > > > ,
@@ -50,6 +51,7 @@ pub enum PushFlag {
50
51
51
52
// These go in a trait so that we can control visibility.
52
53
pub trait TreeBuilderActions < Handle > {
54
+ fn unexpected < T : Show > ( & mut self , thing : & T ) -> ProcessResult ;
53
55
fn clear_active_formatting_to_marker ( & mut self ) ;
54
56
fn create_formatting_element_for ( & mut self , tag : Tag ) -> Handle ;
55
57
fn append_text ( & mut self , text : String ) -> ProcessResult ;
@@ -101,6 +103,14 @@ pub trait TreeBuilderActions<Handle> {
101
103
impl < ' sink , Handle : Clone , Sink : TreeSink < Handle > >
102
104
TreeBuilderActions < Handle > for super :: TreeBuilder < ' sink , Handle , Sink > {
103
105
106
+ fn unexpected < T : Show > ( & mut self , thing : & T ) -> ProcessResult {
107
+ self . sink . parse_error ( format_if ! (
108
+ self . opts. exact_errors,
109
+ "Unexpected token" ,
110
+ "Unexpected token {} in insertion mode {}" , to_escaped_string( thing) , self . mode) ) ;
111
+ Done
112
+ }
113
+
104
114
/// Iterate over the active formatting elements (with index in the list) from the end
105
115
/// to the last marker, or the beginning if there are no markers.
106
116
fn active_formatting_end_to_marker < ' a > ( & ' a self ) -> ActiveFormattingIter < ' a , Handle > {
0 commit comments