+ let mut diagnostics = diagnostics.borrow_mut();
+ if diagnostics.is_empty() {
+ return;
+ }
+ // We need to fix up the stack trace, because the machine has already
+ // stepped to the next statement.
+ let mut stacktrace = this.generate_stacktrace();
+ // Remove newly pushed frames.
+ while stacktrace.len() > info.stack_size {
+ stacktrace.remove(0);
+ }
+ // Add popped frame back.
+ if stacktrace.len() < info.stack_size {
+ assert!(stacktrace.len() == info.stack_size-1, "we should never pop more than one frame at once");
+ let frame_info = FrameInfo {
+ instance: info.instance.unwrap(),
+ span: info.span,
+ lint_root: None,
+ };
+ stacktrace.insert(0, frame_info);
+ } else if let Some(instance) = info.instance {
+ // Adjust topmost frame.
+ stacktrace[0].span = info.span;
+ assert_eq!(stacktrace[0].instance, instance, "we should not pop and push a frame in one step");
+ }
+
+ // Show diagnostics.
+ for e in diagnostics.drain(..) {