Skip to content

Commit a9c7e02

Browse files
Add lang item for Future::Output
1 parent 7f11d6f commit a9c7e02

File tree

6 files changed

+8
-29
lines changed

6 files changed

+8
-29
lines changed

compiler/rustc_hir/src/lang_items.rs

+1
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ language_item_table! {
238238
Iterator, sym::iterator, iterator_trait, Target::Trait, GenericRequirement::Exact(0);
239239
FusedIterator, sym::fused_iterator, fused_iterator_trait, Target::Trait, GenericRequirement::Exact(0);
240240
Future, sym::future_trait, future_trait, Target::Trait, GenericRequirement::Exact(0);
241+
FutureOutput, sym::future_output, future_output, Target::AssocTy, GenericRequirement::Exact(0);
241242
AsyncIterator, sym::async_iterator, async_iterator_trait, Target::Trait, GenericRequirement::Exact(0);
242243

243244
CoroutineState, sym::coroutine_state, coroutine_state, Target::Enum, GenericRequirement::None;

compiler/rustc_hir_analysis/src/collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ pub fn suggest_impl_trait<'tcx>(
14781478
),
14791479
(
14801480
infcx.tcx.lang_items().future_trait(),
1481-
infcx.tcx.get_diagnostic_item(sym::FutureOutput),
1481+
infcx.tcx.lang_items().future_output(),
14821482
format_as_assoc,
14831483
),
14841484
(

compiler/rustc_span/src/symbol.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ symbols! {
210210
FsPermissions,
211211
FusedIterator,
212212
Future,
213-
FutureOutput,
214213
GlobalAlloc,
215214
Hash,
216215
HashMap,
@@ -914,6 +913,7 @@ symbols! {
914913
fundamental,
915914
fused_iterator,
916915
future,
916+
future_output,
917917
future_trait,
918918
gdb_script_file,
919919
ge,

compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -454,12 +454,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_async_callable<'tc
454454
.rebind(ty::TraitRef::new(tcx, future_trait_def_id, [sig.output()]))
455455
.upcast(tcx),
456456
];
457-
let future_output_def_id = tcx
458-
.associated_items(future_trait_def_id)
459-
.filter_by_name_unhygienic(sym::Output)
460-
.next()
461-
.unwrap()
462-
.def_id;
457+
let future_output_def_id = tcx.require_lang_item(LangItem::FutureOutput, None);
463458
let future_output_ty = Ty::new_projection(tcx, future_output_def_id, [sig.output()]);
464459
Ok((
465460
bound_sig.rebind(AsyncCallableRelevantTypes {
@@ -510,12 +505,7 @@ pub(in crate::solve) fn extract_tupled_inputs_and_output_from_async_callable<'tc
510505
);
511506
}
512507

513-
let future_output_def_id = tcx
514-
.associated_items(future_trait_def_id)
515-
.filter_by_name_unhygienic(sym::Output)
516-
.next()
517-
.unwrap()
518-
.def_id;
508+
let future_output_def_id = tcx.require_lang_item(LangItem::FutureOutput, None);
519509
let future_output_ty = Ty::new_projection(tcx, future_output_def_id, [sig.output()]);
520510
Ok((
521511
bound_sig.rebind(AsyncCallableRelevantTypes {

compiler/rustc_trait_selection/src/traits/project.rs

+2-14
Original file line numberDiff line numberDiff line change
@@ -1880,13 +1880,7 @@ fn confirm_async_closure_candidate<'cx, 'tcx>(
18801880
let term = match item_name {
18811881
sym::CallOnceFuture | sym::CallRefFuture => sig.output(),
18821882
sym::Output => {
1883-
let future_trait_def_id = tcx.require_lang_item(LangItem::Future, None);
1884-
let future_output_def_id = tcx
1885-
.associated_items(future_trait_def_id)
1886-
.filter_by_name_unhygienic(sym::Output)
1887-
.next()
1888-
.unwrap()
1889-
.def_id;
1883+
let future_output_def_id = tcx.require_lang_item(LangItem::FutureOutput, None);
18901884
Ty::new_projection(tcx, future_output_def_id, [sig.output()])
18911885
}
18921886
name => bug!("no such associated type: {name}"),
@@ -1919,13 +1913,7 @@ fn confirm_async_closure_candidate<'cx, 'tcx>(
19191913
let term = match item_name {
19201914
sym::CallOnceFuture | sym::CallRefFuture => sig.output(),
19211915
sym::Output => {
1922-
let future_trait_def_id = tcx.require_lang_item(LangItem::Future, None);
1923-
let future_output_def_id = tcx
1924-
.associated_items(future_trait_def_id)
1925-
.filter_by_name_unhygienic(sym::Output)
1926-
.next()
1927-
.unwrap()
1928-
.def_id;
1916+
let future_output_def_id = tcx.require_lang_item(LangItem::FutureOutput, None);
19291917
Ty::new_projection(tcx, future_output_def_id, [sig.output()])
19301918
}
19311919
name => bug!("no such associated type: {name}"),

library/core/src/future/future.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ use crate::task::{Context, Poll};
3535
pub trait Future {
3636
/// The type of value produced on completion.
3737
#[stable(feature = "futures_api", since = "1.36.0")]
38-
#[rustc_diagnostic_item = "FutureOutput"]
38+
#[cfg_attr(not(bootstrap), lang = "future_output")]
3939
type Output;
4040

4141
/// Attempt to resolve the future to a final value, registering

0 commit comments

Comments
 (0)