Skip to content

Commit 268ec72

Browse files
committed
Make Iterator a lang item
1 parent b66fe58 commit 268ec72

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

compiler/rustc_hir/src/lang_items.rs

+1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ language_item_table! {
210210

211211
FnOnceOutput, sym::fn_once_output, fn_once_output, Target::AssocTy, GenericRequirement::None;
212212

213+
Iterator, sym::iterator, iterator_trait, Target::Trait, GenericRequirement::Exact(0);
213214
Future, sym::future_trait, future_trait, Target::Trait, GenericRequirement::Exact(0);
214215
CoroutineState, sym::coroutine_state, gen_state, Target::Enum, GenericRequirement::None;
215216
Coroutine, sym::coroutine, gen_trait, Target::Trait, GenericRequirement::Minimum(1);

compiler/rustc_interface/src/passes.rs

+5
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,11 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
856856
// This check has to be run after all lints are done processing. We don't
857857
// define a lint filter, as all lint checks should have finished at this point.
858858
sess.time("check_lint_expectations", || tcx.ensure().check_expectations(None));
859+
860+
// This query is only invoked normally if a diagnostic is emitted that needs any
861+
// diagnostic item. If the crate compiles without checking any diagnostic items,
862+
// we will fail to emit overlap diagnostics. Thus we invoke it here unconditionally.
863+
let _ = tcx.all_diagnostic_items(());
859864
});
860865

861866
if sess.opts.unstable_opts.print_vtable_sizes {

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ symbols! {
910910
iter,
911911
iter_mut,
912912
iter_repeat,
913+
iterator,
913914
iterator_collect_fn,
914915
kcfi,
915916
keyword,

library/core/src/iter/traits/iterator.rs

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ fn _assert_is_object_safe(_: &dyn Iterator<Item = ()>) {}
6969
message = "`{Self}` is not an iterator"
7070
)]
7171
#[doc(notable_trait)]
72+
#[cfg_attr(not(bootstrap), lang = "iterator")]
7273
#[rustc_diagnostic_item = "Iterator"]
7374
#[must_use = "iterators are lazy and do nothing unless consumed"]
7475
pub trait Iterator {

0 commit comments

Comments
 (0)