Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e2806a5

Browse files
committedApr 23, 2025·
Auto merge of rust-lang#140180 - ChrisDenton:rollup-5pvs08u, r=ChrisDenton
Rollup of 7 pull requests Successful merges: - rust-lang#140142 (Some more graphviz tweaks) - rust-lang#140146 (Update `compiler_builtins` to 0.1.156) - rust-lang#140147 (Clean: rename `open_braces` to `open_delimiters` in lexer and move `make_unclosed_delims_error` into `diagnostics.rs`.) - rust-lang#140160 (Use `is_lang_item` and `as_lang_item` instead of handrolling their logic) - rust-lang#140163 (Validate extension in `PathBuf::add_extension`) - rust-lang#140173 (Ping Mara when touching format_args!() internals.) - rust-lang#140175 (`rc""` more clear error message) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 645d0ad + ecb9775 commit e2806a5

File tree

41 files changed

+373
-355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+373
-355
lines changed
 

‎compiler/rustc_ast_lowering/src/path.rs‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rustc_hir as hir;
55
use rustc_hir::GenericArg;
66
use rustc_hir::def::{DefKind, PartialRes, Res};
77
use rustc_hir::def_id::DefId;
8-
use rustc_middle::span_bug;
8+
use rustc_middle::{span_bug, ty};
99
use rustc_session::parse::add_feature_diagnostics;
1010
use rustc_span::{BytePos, DUMMY_SP, DesugaringKind, Ident, Span, Symbol, sym};
1111
use smallvec::{SmallVec, smallvec};
@@ -590,14 +590,10 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
590590
/// lowering of `async Fn()` bounds to desugar to another trait like `LendingFn`.
591591
fn map_trait_to_async_trait(&self, def_id: DefId) -> Option<DefId> {
592592
let lang_items = self.tcx.lang_items();
593-
if Some(def_id) == lang_items.fn_trait() {
594-
lang_items.async_fn_trait()
595-
} else if Some(def_id) == lang_items.fn_mut_trait() {
596-
lang_items.async_fn_mut_trait()
597-
} else if Some(def_id) == lang_items.fn_once_trait() {
598-
lang_items.async_fn_once_trait()
599-
} else {
600-
None
593+
match self.tcx.fn_trait_kind_from_def_id(def_id)? {
594+
ty::ClosureKind::Fn => lang_items.async_fn_trait(),
595+
ty::ClosureKind::FnMut => lang_items.async_fn_mut_trait(),
596+
ty::ClosureKind::FnOnce => lang_items.async_fn_once_trait(),
601597
}
602598
}
603599
}

‎compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,12 +1265,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
12651265
&& let CallKind::FnCall { fn_trait_id, self_ty } = kind
12661266
&& let ty::Param(_) = self_ty.kind()
12671267
&& ty == self_ty
1268-
&& [
1269-
self.infcx.tcx.lang_items().fn_once_trait(),
1270-
self.infcx.tcx.lang_items().fn_mut_trait(),
1271-
self.infcx.tcx.lang_items().fn_trait(),
1272-
]
1273-
.contains(&Some(fn_trait_id))
1268+
&& self.infcx.tcx.fn_trait_kind_from_def_id(fn_trait_id).is_some()
12741269
{
12751270
// Do not suggest `F: FnOnce() + Clone`.
12761271
false

0 commit comments

Comments
 (0)
This repository has been archived.