Skip to content

Commit 36b61e5

Browse files
committed
Auto merge of rust-lang#116923 - fmease:rollup-ev7q387, r=fmease
Rollup of 7 pull requests Successful merges: - rust-lang#116663 (Don't ICE when encountering unresolved regions in `fully_resolve`) - rust-lang#116761 (Fix podman detection in CI scripts) - rust-lang#116795 (Add `#[track_caller]` to `Option::unwrap_or_else`) - rust-lang#116829 (Make `#[repr(Rust)]` incompatible with other (non-modifier) representation hints like `C` and `simd`) - rust-lang#116883 (Change my name in mailmap) - rust-lang#116908 (Tweak wording of type errors involving type params) - rust-lang#116912 (Some renaming nits for `rustc_type_ir`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 020d008 + 8aa1d71 commit 36b61e5

File tree

46 files changed

+264
-125
lines changed

Some content is hidden

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

46 files changed

+264
-125
lines changed

.mailmap

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Benoît Cortier <benoit.cortier@fried-world.eu>
7474
Bheesham Persaud <bheesham123@hotmail.com> Bheesham Persaud <bheesham.persaud@live.ca>
7575
Björn Steinbrink <bsteinbr@gmail.com> <B.Steinbrink@gmx.de>
7676
blake2-ppc <ulrik.sverdrup@gmail.com> <blake2-ppc>
77+
blyxyas <blyxyas@gmail.com> Alejandra González <blyxyas@gmail.com>
7778
boolean_coercion <booleancoercion@gmail.com>
7879
Boris Egorov <jightuse@gmail.com> <egorov@linux.com>
7980
bors <bors@rust-lang.org> bors[bot] <26634292+bors[bot]@users.noreply.github.com>

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

+19-4
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
8585
{
8686
let p_def_id = tcx.generics_of(body_owner_def_id).type_param(p, tcx).def_id;
8787
let p_span = tcx.def_span(p_def_id);
88+
let expected = match (values.expected.kind(), values.found.kind()) {
89+
(ty::Param(_), _) => "expected ",
90+
(_, ty::Param(_)) => "found ",
91+
_ => "",
92+
};
8893
if !sp.contains(p_span) {
89-
diag.span_label(p_span, "this type parameter");
94+
diag.span_label(p_span, format!("{expected}this type parameter"));
9095
}
9196
let hir = tcx.hir();
9297
let mut note = true;
@@ -168,8 +173,13 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
168173
| (ty::Dynamic(..) | ty::Alias(ty::Opaque, ..), ty::Param(p)) => {
169174
let generics = tcx.generics_of(body_owner_def_id);
170175
let p_span = tcx.def_span(generics.type_param(p, tcx).def_id);
176+
let expected = match (values.expected.kind(), values.found.kind()) {
177+
(ty::Param(_), _) => "expected ",
178+
(_, ty::Param(_)) => "found ",
179+
_ => "",
180+
};
171181
if !sp.contains(p_span) {
172-
diag.span_label(p_span, "this type parameter");
182+
diag.span_label(p_span, format!("{expected}this type parameter"));
173183
}
174184
diag.help("type parameters must be constrained to match other types");
175185
if tcx.sess.teach(&diag.get_code().unwrap()) {
@@ -209,7 +219,7 @@ impl<T> Trait<T> for X {
209219
let generics = tcx.generics_of(body_owner_def_id);
210220
let p_span = tcx.def_span(generics.type_param(p, tcx).def_id);
211221
if !sp.contains(p_span) {
212-
diag.span_label(p_span, "this type parameter");
222+
diag.span_label(p_span, "expected this type parameter");
213223
}
214224
diag.help(format!(
215225
"every closure has a distinct type and so could not always match the \
@@ -219,8 +229,13 @@ impl<T> Trait<T> for X {
219229
(ty::Param(p), _) | (_, ty::Param(p)) => {
220230
let generics = tcx.generics_of(body_owner_def_id);
221231
let p_span = tcx.def_span(generics.type_param(p, tcx).def_id);
232+
let expected = match (values.expected.kind(), values.found.kind()) {
233+
(ty::Param(_), _) => "expected ",
234+
(_, ty::Param(_)) => "found ",
235+
_ => "",
236+
};
222237
if !sp.contains(p_span) {
223-
diag.span_label(p_span, "this type parameter");
238+
diag.span_label(p_span, format!("{expected}this type parameter"));
224239
}
225240
}
226241
(ty::Alias(ty::Projection | ty::Inherent, proj_ty), _)

compiler/rustc_infer/src/infer/mod.rs

+20-7
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use rustc_middle::ty::{self, GenericParamDefKind, InferConst, InferTy, Ty, TyCtx
3636
use rustc_middle::ty::{ConstVid, EffectVid, FloatVid, IntVid, TyVid};
3737
use rustc_middle::ty::{GenericArg, GenericArgKind, GenericArgs, GenericArgsRef};
3838
use rustc_span::symbol::Symbol;
39-
use rustc_span::Span;
39+
use rustc_span::{Span, DUMMY_SP};
4040

4141
use std::cell::{Cell, RefCell};
4242
use std::fmt;
@@ -1422,12 +1422,25 @@ impl<'tcx> InferCtxt<'tcx> {
14221422
/// This method is idempotent, but it not typically not invoked
14231423
/// except during the writeback phase.
14241424
pub fn fully_resolve<T: TypeFoldable<TyCtxt<'tcx>>>(&self, value: T) -> FixupResult<'tcx, T> {
1425-
let value = resolve::fully_resolve(self, value);
1426-
assert!(
1427-
value.as_ref().map_or(true, |value| !value.has_infer()),
1428-
"`{value:?}` is not fully resolved"
1429-
);
1430-
value
1425+
match resolve::fully_resolve(self, value) {
1426+
Ok(value) => {
1427+
if value.has_non_region_infer() {
1428+
bug!("`{value:?}` is not fully resolved");
1429+
}
1430+
if value.has_infer_regions() {
1431+
let guar = self
1432+
.tcx
1433+
.sess
1434+
.delay_span_bug(DUMMY_SP, format!("`{value:?}` is not fully resolved"));
1435+
Ok(self.tcx.fold_regions(value, |re, _| {
1436+
if re.is_var() { ty::Region::new_error(self.tcx, guar) } else { re }
1437+
}))
1438+
} else {
1439+
Ok(value)
1440+
}
1441+
}
1442+
Err(e) => Err(e),
1443+
}
14311444
}
14321445

14331446
// Instantiates the bound variables in a given binder with fresh inference

compiler/rustc_lint/src/async_fn_in_trait.rs

-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ declare_lint! {
5858
///
5959
///
6060
/// ```rust
61-
/// # #![feature(return_position_impl_trait_in_trait)]
6261
/// use core::future::Future;
6362
/// pub trait Trait {
6463
/// fn method(&self) -> impl Future<Output = ()> + Send { async {} }

compiler/rustc_middle/src/ty/context.rs

+12-15
Original file line numberDiff line numberDiff line change
@@ -80,43 +80,40 @@ use std::ops::{Bound, Deref};
8080

8181
#[allow(rustc::usage_of_ty_tykind)]
8282
impl<'tcx> Interner for TyCtxt<'tcx> {
83+
type DefId = DefId;
8384
type AdtDef = ty::AdtDef<'tcx>;
84-
type GenericArgsRef = ty::GenericArgsRef<'tcx>;
85+
type GenericArgs = ty::GenericArgsRef<'tcx>;
8586
type GenericArg = ty::GenericArg<'tcx>;
86-
type DefId = DefId;
8787
type Binder<T> = Binder<'tcx, T>;
88-
type Ty = Ty<'tcx>;
89-
type Const = ty::Const<'tcx>;
90-
type Region = Region<'tcx>;
9188
type Predicate = Predicate<'tcx>;
89+
type PredicateKind = ty::PredicateKind<'tcx>;
9290
type TypeAndMut = TypeAndMut<'tcx>;
9391
type Mutability = hir::Mutability;
9492
type Movability = hir::Movability;
95-
type PolyFnSig = PolyFnSig<'tcx>;
96-
type ListBinderExistentialPredicate = &'tcx List<PolyExistentialPredicate<'tcx>>;
97-
type BinderListTy = Binder<'tcx, &'tcx List<Ty<'tcx>>>;
98-
type ListTy = &'tcx List<Ty<'tcx>>;
93+
type Ty = Ty<'tcx>;
94+
type Tys = &'tcx List<Ty<'tcx>>;
9995
type AliasTy = ty::AliasTy<'tcx>;
10096
type ParamTy = ParamTy;
10197
type BoundTy = ty::BoundTy;
102-
type PlaceholderType = ty::PlaceholderType;
98+
type PlaceholderTy = ty::PlaceholderType;
10399
type InferTy = InferTy;
104100
type ErrorGuaranteed = ErrorGuaranteed;
105-
type PredicateKind = ty::PredicateKind<'tcx>;
101+
type BoundExistentialPredicates = &'tcx List<PolyExistentialPredicate<'tcx>>;
102+
type PolyFnSig = PolyFnSig<'tcx>;
106103
type AllocId = crate::mir::interpret::AllocId;
107-
104+
type Const = ty::Const<'tcx>;
108105
type InferConst = ty::InferConst<'tcx>;
109106
type AliasConst = ty::UnevaluatedConst<'tcx>;
107+
type PlaceholderConst = ty::PlaceholderConst<'tcx>;
110108
type ParamConst = ty::ParamConst;
111109
type BoundConst = ty::BoundVar;
112-
type PlaceholderConst = ty::PlaceholderConst<'tcx>;
113110
type ValueConst = ty::ValTree<'tcx>;
114111
type ExprConst = ty::Expr<'tcx>;
115-
112+
type Region = Region<'tcx>;
116113
type EarlyBoundRegion = ty::EarlyBoundRegion;
117114
type BoundRegion = ty::BoundRegion;
118115
type FreeRegion = ty::FreeRegion;
119-
type RegionVid = ty::RegionVid;
116+
type InferRegion = ty::RegionVid;
120117
type PlaceholderRegion = ty::PlaceholderRegion;
121118

122119
fn ty_and_mut_to_parts(

compiler/rustc_passes/src/check_attr.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -1776,6 +1776,7 @@ impl CheckAttrVisitor<'_> {
17761776
.collect();
17771777

17781778
let mut int_reprs = 0;
1779+
let mut is_explicit_rust = false;
17791780
let mut is_c = false;
17801781
let mut is_simd = false;
17811782
let mut is_transparent = false;
@@ -1787,7 +1788,9 @@ impl CheckAttrVisitor<'_> {
17871788
}
17881789

17891790
match hint.name_or_empty() {
1790-
sym::Rust => {}
1791+
sym::Rust => {
1792+
is_explicit_rust = true;
1793+
}
17911794
sym::C => {
17921795
is_c = true;
17931796
match target {
@@ -1897,12 +1900,16 @@ impl CheckAttrVisitor<'_> {
18971900

18981901
// Error on repr(transparent, <anything else>).
18991902
if is_transparent && hints.len() > 1 {
1900-
let hint_spans: Vec<_> = hint_spans.clone().collect();
1903+
let hint_spans = hint_spans.clone().collect();
19011904
self.tcx.sess.emit_err(errors::TransparentIncompatible {
19021905
hint_spans,
19031906
target: target.to_string(),
19041907
});
19051908
}
1909+
if is_explicit_rust && (int_reprs > 0 || is_c || is_simd) {
1910+
let hint_spans = hint_spans.clone().collect();
1911+
self.tcx.sess.emit_err(errors::ReprConflicting { hint_spans });
1912+
}
19061913
// Warn on repr(u8, u16), repr(C, simd), and c-like-enum-repr(C, u8)
19071914
if (int_reprs > 1)
19081915
|| (is_simd && is_c)
@@ -1919,7 +1926,7 @@ impl CheckAttrVisitor<'_> {
19191926
CONFLICTING_REPR_HINTS,
19201927
hir_id,
19211928
hint_spans.collect::<Vec<Span>>(),
1922-
errors::ReprConflicting,
1929+
errors::ReprConflictingLint,
19231930
);
19241931
}
19251932
}

compiler/rustc_passes/src/errors.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -558,9 +558,16 @@ pub struct ReprIdent {
558558
pub span: Span,
559559
}
560560

561+
#[derive(Diagnostic)]
562+
#[diag(passes_repr_conflicting, code = "E0566")]
563+
pub struct ReprConflicting {
564+
#[primary_span]
565+
pub hint_spans: Vec<Span>,
566+
}
567+
561568
#[derive(LintDiagnostic)]
562569
#[diag(passes_repr_conflicting, code = "E0566")]
563-
pub struct ReprConflicting;
570+
pub struct ReprConflictingLint;
564571

565572
#[derive(Diagnostic)]
566573
#[diag(passes_used_static)]

compiler/rustc_type_ir/src/lib.rs

+22-12
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,43 @@ pub use ty_info::*;
4242
pub trait HashStableContext {}
4343

4444
pub trait Interner: Sized {
45+
type DefId: Clone + Debug + Hash + Ord;
4546
type AdtDef: Clone + Debug + Hash + Ord;
46-
type GenericArgsRef: Clone
47+
48+
type GenericArgs: Clone
4749
+ DebugWithInfcx<Self>
4850
+ Hash
4951
+ Ord
5052
+ IntoIterator<Item = Self::GenericArg>;
5153
type GenericArg: Clone + DebugWithInfcx<Self> + Hash + Ord;
52-
type DefId: Clone + Debug + Hash + Ord;
54+
5355
type Binder<T>;
54-
type Ty: Clone + DebugWithInfcx<Self> + Hash + Ord;
55-
type Const: Clone + DebugWithInfcx<Self> + Hash + Ord;
56-
type Region: Clone + DebugWithInfcx<Self> + Hash + Ord;
56+
57+
// Predicates
5758
type Predicate;
59+
type PredicateKind: Clone + Debug + Hash + PartialEq + Eq;
60+
5861
type TypeAndMut: Clone + Debug + Hash + Ord;
5962
type Mutability: Clone + Debug + Hash + Ord;
6063
type Movability: Clone + Debug + Hash + Ord;
61-
type PolyFnSig: Clone + DebugWithInfcx<Self> + Hash + Ord;
62-
type ListBinderExistentialPredicate: Clone + DebugWithInfcx<Self> + Hash + Ord;
63-
type BinderListTy: Clone + DebugWithInfcx<Self> + Hash + Ord;
64-
type ListTy: Clone + Debug + Hash + Ord + IntoIterator<Item = Self::Ty>;
64+
65+
// Kinds of tys
66+
type Ty: Clone + DebugWithInfcx<Self> + Hash + Ord;
67+
type Tys: Clone + Debug + Hash + Ord + IntoIterator<Item = Self::Ty>;
6568
type AliasTy: Clone + DebugWithInfcx<Self> + Hash + Ord;
6669
type ParamTy: Clone + Debug + Hash + Ord;
6770
type BoundTy: Clone + Debug + Hash + Ord;
68-
type PlaceholderType: Clone + Debug + Hash + Ord;
71+
type PlaceholderTy: Clone + Debug + Hash + Ord;
6972
type InferTy: Clone + DebugWithInfcx<Self> + Hash + Ord;
73+
74+
// Things stored inside of tys
7075
type ErrorGuaranteed: Clone + Debug + Hash + Ord;
71-
type PredicateKind: Clone + Debug + Hash + PartialEq + Eq;
76+
type BoundExistentialPredicates: Clone + DebugWithInfcx<Self> + Hash + Ord;
77+
type PolyFnSig: Clone + DebugWithInfcx<Self> + Hash + Ord;
7278
type AllocId: Clone + Debug + Hash + Ord;
7379

80+
// Kinds of consts
81+
type Const: Clone + DebugWithInfcx<Self> + Hash + Ord;
7482
type InferConst: Clone + DebugWithInfcx<Self> + Hash + Ord;
7583
type AliasConst: Clone + DebugWithInfcx<Self> + Hash + Ord;
7684
type PlaceholderConst: Clone + Debug + Hash + Ord;
@@ -79,10 +87,12 @@ pub trait Interner: Sized {
7987
type ValueConst: Clone + Debug + Hash + Ord;
8088
type ExprConst: Clone + DebugWithInfcx<Self> + Hash + Ord;
8189

90+
// Kinds of regions
91+
type Region: Clone + DebugWithInfcx<Self> + Hash + Ord;
8292
type EarlyBoundRegion: Clone + Debug + Hash + Ord;
8393
type BoundRegion: Clone + Debug + Hash + Ord;
8494
type FreeRegion: Clone + Debug + Hash + Ord;
85-
type RegionVid: Clone + DebugWithInfcx<Self> + Hash + Ord;
95+
type InferRegion: Clone + DebugWithInfcx<Self> + Hash + Ord;
8696
type PlaceholderRegion: Clone + Debug + Hash + Ord;
8797

8898
fn ty_and_mut_to_parts(ty_and_mut: Self::TypeAndMut) -> (Self::Ty, Self::Mutability);

compiler/rustc_type_ir/src/structural_impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ impl<I: Interner, T: TypeVisitable<I>, Ix: Idx> TypeVisitable<I> for IndexVec<Ix
208208

209209
pub trait InferCtxtLike<I: Interner> {
210210
fn universe_of_ty(&self, ty: I::InferTy) -> Option<UniverseIndex>;
211-
fn universe_of_lt(&self, lt: I::RegionVid) -> Option<UniverseIndex>;
211+
fn universe_of_lt(&self, lt: I::InferRegion) -> Option<UniverseIndex>;
212212
fn universe_of_ct(&self, ct: I::InferConst) -> Option<UniverseIndex>;
213213
}
214214

@@ -219,7 +219,7 @@ impl<I: Interner> InferCtxtLike<I> for core::convert::Infallible {
219219
fn universe_of_ct(&self, _ct: <I as Interner>::InferConst) -> Option<UniverseIndex> {
220220
match *self {}
221221
}
222-
fn universe_of_lt(&self, _lt: <I as Interner>::RegionVid) -> Option<UniverseIndex> {
222+
fn universe_of_lt(&self, _lt: <I as Interner>::InferRegion) -> Option<UniverseIndex> {
223223
match *self {}
224224
}
225225
}

0 commit comments

Comments
 (0)