Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 7a5d2d0

Browse files
committed
Auto merge of rust-lang#114358 - matthiaskrgr:rollup-d810m9e, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#114178 (Account for macros when suggesting a new let binding) - rust-lang#114199 (Don't unsize coerce infer vars in select in new solver) - rust-lang#114301 (Don't check unnecessarily that impl trait is RPIT) - rust-lang#114314 (Tweaks to `adt_sized_constraint`) - rust-lang#114322 (Fix invalid slice coercion suggestion reported in turbofish) - rust-lang#114340 ([rustc_attr][nit] Replace `filter` + `is_some` with `map_or`.) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 90bb418 + 4876afb commit 7a5d2d0

File tree

25 files changed

+168
-69
lines changed

25 files changed

+168
-69
lines changed

compiler/rustc_attr/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn rust_version_symbol() -> Symbol {
2828
}
2929

3030
pub fn is_builtin_attr(attr: &Attribute) -> bool {
31-
attr.is_doc_comment() || attr.ident().filter(|ident| is_builtin_attr_name(ident.name)).is_some()
31+
attr.is_doc_comment() || attr.ident().is_some_and(|ident| is_builtin_attr_name(ident.name))
3232
}
3333

3434
enum AttrError {

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2133,13 +2133,14 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
21332133
self.current -= 1;
21342134
}
21352135
fn visit_expr(&mut self, expr: &hir::Expr<'tcx>) {
2136-
if self.span == expr.span {
2136+
if self.span == expr.span.source_callsite() {
21372137
self.found = self.current;
21382138
}
21392139
walk_expr(self, expr);
21402140
}
21412141
}
21422142
let source_info = self.body.source_info(location);
2143+
let proper_span = proper_span.source_callsite();
21432144
if let Some(scope) = self.body.source_scopes.get(source_info.scope)
21442145
&& let ClearCrossCrate::Set(scope_data) = &scope.local_data
21452146
&& let Some(node) = self.infcx.tcx.hir().find(scope_data.lint_root)

compiler/rustc_hir_analysis/src/astconv/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
14621462
let traits: Vec<_> =
14631463
self.probe_traits_that_match_assoc_ty(qself_ty, assoc_ident);
14641464

1465-
// Don't print `TyErr` to the user.
1465+
// Don't print `ty::Error` to the user.
14661466
self.report_ambiguous_associated_type(
14671467
span,
14681468
&[qself_ty.to_string()],

compiler/rustc_hir_analysis/src/check/wfcheck.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,8 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
555555
for (region_a, region_a_idx) in &regions {
556556
// Ignore `'static` lifetimes for the purpose of this lint: it's
557557
// because we know it outlives everything and so doesn't give meaningful
558-
// clues
559-
if let ty::ReStatic = **region_a {
558+
// clues. Also ignore `ReError`, to avoid knock-down errors.
559+
if let ty::ReStatic | ty::ReError(_) = **region_a {
560560
continue;
561561
}
562562
// For each region argument (e.g., `'a` in our example), check for a
@@ -599,8 +599,9 @@ fn gather_gat_bounds<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
599599
// on the GAT itself.
600600
for (region_b, region_b_idx) in &regions {
601601
// Again, skip `'static` because it outlives everything. Also, we trivially
602-
// know that a region outlives itself.
603-
if ty::ReStatic == **region_b || region_a == region_b {
602+
// know that a region outlives itself. Also ignore `ReError`, to avoid
603+
// knock-down errors.
604+
if matches!(**region_b, ty::ReStatic | ty::ReError(_)) || region_a == region_b {
604605
continue;
605606
}
606607
if region_known_to_outlive(

compiler/rustc_hir_typeck/src/closure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
795795

796796
/// Converts the types that the user supplied, in case that doing
797797
/// so should yield an error, but returns back a signature where
798-
/// all parameters are of type `TyErr`.
798+
/// all parameters are of type `ty::Error`.
799799
fn error_sig_of_closure(
800800
&self,
801801
decl: &hir::FnDecl<'_>,

compiler/rustc_infer/src/infer/error_reporting/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2567,15 +2567,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
25672567
None,
25682568
);
25692569
if let Some(infer::RelateParamBound(_, t, _)) = origin {
2570-
let return_impl_trait =
2571-
self.tcx.return_type_impl_trait(generic_param_scope).is_some();
25722570
let t = self.resolve_vars_if_possible(t);
25732571
match t.kind() {
25742572
// We've got:
25752573
// fn get_later<G, T>(g: G, dest: &mut T) -> impl FnOnce() + '_
25762574
// suggest:
25772575
// fn get_later<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + 'a
2578-
ty::Closure(..) | ty::Alias(ty::Opaque, ..) if return_impl_trait => {
2576+
ty::Closure(..) | ty::Alias(ty::Opaque, ..) => {
25792577
new_binding_suggestion(&mut err, type_param_span);
25802578
}
25812579
_ => {

compiler/rustc_infer/src/infer/lexical_region_resolve/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,10 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
942942
generic_ty: Ty<'tcx>,
943943
min: ty::Region<'tcx>,
944944
) -> bool {
945+
if let ty::ReError(_) = *min {
946+
return true;
947+
}
948+
945949
match bound {
946950
VerifyBound::IfEq(verify_if_eq_b) => {
947951
let verify_if_eq_b = var_values.normalize(self.region_rels.tcx, *verify_if_eq_b);

compiler/rustc_middle/src/query/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ rustc_queries! {
706706
separate_provide_extern
707707
}
708708

709-
query adt_sized_constraint(key: DefId) -> &'tcx [Ty<'tcx>] {
709+
query adt_sized_constraint(key: DefId) -> ty::EarlyBinder<&'tcx ty::List<Ty<'tcx>>> {
710710
desc { |tcx| "computing `Sized` constraints for `{}`", tcx.def_path_str(key) }
711711
}
712712

compiler/rustc_middle/src/ty/adt.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -562,18 +562,10 @@ impl<'tcx> AdtDef<'tcx> {
562562
tcx.adt_destructor(self.did())
563563
}
564564

565-
/// Returns a list of types such that `Self: Sized` if and only
566-
/// if that type is `Sized`, or `TyErr` if this type is recursive.
567-
///
568-
/// Oddly enough, checking that the sized-constraint is `Sized` is
569-
/// actually more expressive than checking all members:
570-
/// the `Sized` trait is inductive, so an associated type that references
571-
/// `Self` would prevent its containing ADT from being `Sized`.
572-
///
573-
/// Due to normalization being eager, this applies even if
574-
/// the associated type is behind a pointer (e.g., issue #31299).
575-
pub fn sized_constraint(self, tcx: TyCtxt<'tcx>) -> ty::EarlyBinder<&'tcx [Ty<'tcx>]> {
576-
ty::EarlyBinder::bind(tcx.adt_sized_constraint(self.did()))
565+
/// Returns a list of types such that `Self: Sized` if and only if that
566+
/// type is `Sized`, or `ty::Error` if this type has a recursive layout.
567+
pub fn sized_constraint(self, tcx: TyCtxt<'tcx>) -> ty::EarlyBinder<&'tcx ty::List<Ty<'tcx>>> {
568+
tcx.adt_sized_constraint(self.did())
577569
}
578570
}
579571

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, LOCAL_CRATE};
5050
use rustc_hir::definitions::Definitions;
5151
use rustc_hir::intravisit::Visitor;
5252
use rustc_hir::lang_items::LangItem;
53-
use rustc_hir::{
54-
Constness, ExprKind, HirId, ImplItemKind, ItemKind, Node, TraitCandidate, TraitItemKind,
55-
};
53+
use rustc_hir::{Constness, HirId, Node, TraitCandidate};
5654
use rustc_index::IndexVec;
5755
use rustc_macros::HashStable;
5856
use rustc_query_system::dep_graph::DepNodeIndex;
@@ -1077,31 +1075,6 @@ impl<'tcx> TyCtxt<'tcx> {
10771075
return None;
10781076
}
10791077

1080-
pub fn return_type_impl_trait(self, scope_def_id: LocalDefId) -> Option<(Ty<'tcx>, Span)> {
1081-
// `type_of()` will fail on these (#55796, #86483), so only allow `fn`s or closures.
1082-
match self.hir().get_by_def_id(scope_def_id) {
1083-
Node::Item(&hir::Item { kind: ItemKind::Fn(..), .. }) => {}
1084-
Node::TraitItem(&hir::TraitItem { kind: TraitItemKind::Fn(..), .. }) => {}
1085-
Node::ImplItem(&hir::ImplItem { kind: ImplItemKind::Fn(..), .. }) => {}
1086-
Node::Expr(&hir::Expr { kind: ExprKind::Closure { .. }, .. }) => {}
1087-
_ => return None,
1088-
}
1089-
1090-
let ret_ty = self.type_of(scope_def_id).instantiate_identity();
1091-
match ret_ty.kind() {
1092-
ty::FnDef(_, _) => {
1093-
let sig = ret_ty.fn_sig(self);
1094-
let output = self.erase_late_bound_regions(sig.output());
1095-
output.is_impl_trait().then(|| {
1096-
let hir_id = self.hir().local_def_id_to_hir_id(scope_def_id);
1097-
let fn_decl = self.hir().fn_decl_by_hir_id(hir_id).unwrap();
1098-
(output, fn_decl.output.span())
1099-
})
1100-
}
1101-
_ => None,
1102-
}
1103-
}
1104-
11051078
/// Checks if the bound region is in Impl Item.
11061079
pub fn is_bound_region_in_impl_item(self, suitable_region_binding_scope: LocalDefId) -> bool {
11071080
let container_id = self.parent(suitable_region_binding_scope.to_def_id());

0 commit comments

Comments
 (0)