Change:
I have this code fragment: When compiled it returns the following: This is under
Very similar to .
could you try your code with latest nightly, or provide a full repro case? I believe this can be closed after .

Discussion:
// add more variants as needed to support one-time diagnostics } <del> /// Diagnostic message id - used in order to avoid emitting the same message more than once </del> <ins> /// Diagnostic message ID—used by `Session.one_time_diagnostics` to avoid /// emitting the same message more than once </ins> #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub enum DiagnosticMessageId { <ins> ErrorId(u16), // EXXXX error code as integer </ins> LintId(lint::LintId), <del> StabilityId(u32) </del> <ins> StabilityId(u32) // issue number </ins> } impl Session {

use rustc::lint::builtin::EXTRA_REQUIREMENT_IN_IMPL; use std::fmt; use syntax::ast; <ins> use session::DiagnosticMessageId; </ins> use ty::{self, AdtKind, ToPredicate, ToPolyTraitRef, Ty, TyCtxt, TypeFoldable}; use ty::error::ExpectedFound; use ty::fast_reject;

} } <del> let mut diag = struct_span_err!( self.tcx.sess, obligation.cause.span, E0271, "type mismatch resolving `{}`", predicate ); self.note_type_err(&mut diag, &obligation.cause, None, values, err); self.note_obligation_cause(&mut diag, obligation); diag.emit(); </del> <ins> let msg = format!("type mismatch resolving `{}`", predicate); let error_id = (DiagnosticMessageId::ErrorId(271), Some(obligation.cause.span), msg.clone()); let fresh = self.tcx.sess.one_time_diagnostics.borrow_mut().insert(error_id); if fresh { let mut diag = struct_span_err!( self.tcx.sess, obligation.cause.span, E0271, "type mismatch resolving `{}`", predicate ); self.note_type_err(&mut diag, &obligation.cause, None, values, err); self.note_obligation_cause(&mut diag, obligation); diag.emit(); } </ins> }); }

<ins> // Copyright 2017 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. use std::collections::HashMap; fn main() { for _ in HashMap::new().iter().cloned() {} } </ins>

<ins> error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as std::iter::Iterator>::Item == &_` --> $DIR/issue-33941.rs:14:36 | 14 |     for _ in HashMap::new().iter().cloned() {} |                                    ^^^^^^ expected tuple, found reference | = note: expected type `(&_, &_)` found type `&_` error[E0271]: type mismatch resolving `<std::collections::hash_map::Iter<'_, _, _> as std::iter::Iterator>::Item == &_` --> $DIR/issue-33941.rs:14:5 | 14 |     for _ in HashMap::new().iter().cloned() {} |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected tuple, found reference | = note: expected type `(&_, &_)` found type `&_` = note: required because of the requirements on the impl of `std::iter::Iterator` for `std::iter::Cloned<std::collections::hash_map::Iter<'_, _, _>>` error: aborting due to 2 previous errors </ins>