Skip to content

Commit bad13a9

Browse files
committed
Auto merge of rust-lang#139390 - matthiaskrgr:rollup-l64euwx, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#139041 (Remove `rustc_middle::ty::util::ExplicitSelf`.) - rust-lang#139328 (Fix 2024 edition doctest panic output) - rust-lang#139339 (unstable book: document tait) - rust-lang#139348 (AsyncDestructor: replace fields with impl_did) - rust-lang#139353 (Fix `Debug` impl for `LateParamRegionKind`.) - rust-lang#139366 (ToSocketAddrs: fix typo) - rust-lang#139374 (Use the span of the whole bound when the diagnostic talks about a bound) - rust-lang#139378 (Use target-agnostic LLD flags in bootstrap for `use-lld`) - rust-lang#139384 (Add `compiletest` adhoc_group for `r? compiletest`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 17ffbc8 + a612ee7 commit bad13a9

32 files changed

+274
-128
lines changed

compiler/rustc_borrowck/src/diagnostics/mutability_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, 'infcx, 'tcx> {
969969
}
970970
};
971971

972-
// If we can detect the expression to be an function or method call where the closure was
972+
// If we can detect the expression to be a function or method call where the closure was
973973
// an argument, we point at the function or method definition argument...
974974
if let Some((callee_def_id, call_span, call_args)) = get_call_details() {
975975
let arg_pos = call_args

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

+22-13
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ use rustc_hir::{self as hir, AmbigArg, GenericParamKind, ImplItemKind, intravisi
1212
use rustc_infer::infer::{self, InferCtxt, TyCtxtInferExt};
1313
use rustc_infer::traits::util;
1414
use rustc_middle::ty::error::{ExpectedFound, TypeError};
15-
use rustc_middle::ty::util::ExplicitSelf;
1615
use rustc_middle::ty::{
1716
self, BottomUpFolder, GenericArgs, GenericParamDefKind, Ty, TyCtxt, TypeFoldable, TypeFolder,
1817
TypeSuperFoldable, TypeVisitableExt, TypingMode, Upcast,
@@ -995,6 +994,26 @@ impl<'tcx> ty::FallibleTypeFolder<TyCtxt<'tcx>> for RemapHiddenTyRegions<'tcx> {
995994
}
996995
}
997996

997+
/// Gets the string for an explicit self declaration, e.g. "self", "&self",
998+
/// etc.
999+
fn get_self_string<'tcx, P>(self_arg_ty: Ty<'tcx>, is_self_ty: P) -> String
1000+
where
1001+
P: Fn(Ty<'tcx>) -> bool,
1002+
{
1003+
if is_self_ty(self_arg_ty) {
1004+
"self".to_owned()
1005+
} else if let ty::Ref(_, ty, mutbl) = self_arg_ty.kind()
1006+
&& is_self_ty(*ty)
1007+
{
1008+
match mutbl {
1009+
hir::Mutability::Not => "&self".to_owned(),
1010+
hir::Mutability::Mut => "&mut self".to_owned(),
1011+
}
1012+
} else {
1013+
format!("self: {self_arg_ty}")
1014+
}
1015+
}
1016+
9981017
fn report_trait_method_mismatch<'tcx>(
9991018
infcx: &InferCtxt<'tcx>,
10001019
mut cause: ObligationCause<'tcx>,
@@ -1020,12 +1039,7 @@ fn report_trait_method_mismatch<'tcx>(
10201039
if trait_m.fn_has_self_parameter =>
10211040
{
10221041
let ty = trait_sig.inputs()[0];
1023-
let sugg = match ExplicitSelf::determine(ty, |ty| ty == impl_trait_ref.self_ty()) {
1024-
ExplicitSelf::ByValue => "self".to_owned(),
1025-
ExplicitSelf::ByReference(_, hir::Mutability::Not) => "&self".to_owned(),
1026-
ExplicitSelf::ByReference(_, hir::Mutability::Mut) => "&mut self".to_owned(),
1027-
_ => format!("self: {ty}"),
1028-
};
1042+
let sugg = get_self_string(ty, |ty| ty == impl_trait_ref.self_ty());
10291043

10301044
// When the `impl` receiver is an arbitrary self type, like `self: Box<Self>`, the
10311045
// span points only at the type `Box<Self`>, but we want to cover the whole
@@ -1238,12 +1252,7 @@ fn compare_self_type<'tcx>(
12381252
.build_with_typing_env(ty::TypingEnv::non_body_analysis(tcx, method.def_id));
12391253
let self_arg_ty = tcx.liberate_late_bound_regions(method.def_id, self_arg_ty);
12401254
let can_eq_self = |ty| infcx.can_eq(param_env, untransformed_self_ty, ty);
1241-
match ExplicitSelf::determine(self_arg_ty, can_eq_self) {
1242-
ExplicitSelf::ByValue => "self".to_owned(),
1243-
ExplicitSelf::ByReference(_, hir::Mutability::Not) => "&self".to_owned(),
1244-
ExplicitSelf::ByReference(_, hir::Mutability::Mut) => "&mut self".to_owned(),
1245-
_ => format!("self: {self_arg_ty}"),
1246-
}
1255+
get_self_string(self_arg_ty, can_eq_self)
12471256
};
12481257

12491258
match (trait_m.fn_has_self_parameter, impl_m.fn_has_self_parameter) {

compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
838838
| PredicateFilter::SelfOnly
839839
| PredicateFilter::SelfAndAssociatedTypeBounds => {
840840
match constness {
841-
hir::BoundConstness::Always(span) => {
841+
hir::BoundConstness::Always(_) => {
842842
if polarity == ty::PredicatePolarity::Positive {
843843
bounds.push((
844844
poly_trait_ref
@@ -864,7 +864,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
864864
// in `lower_assoc_item_constraint`.
865865
PredicateFilter::ConstIfConst | PredicateFilter::SelfConstIfConst => {
866866
match constness {
867-
hir::BoundConstness::Maybe(span) => {
867+
hir::BoundConstness::Maybe(_) => {
868868
if polarity == ty::PredicatePolarity::Positive {
869869
bounds.push((
870870
poly_trait_ref

compiler/rustc_middle/src/ty/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1147,10 +1147,8 @@ pub struct Destructor {
11471147
// FIXME: consider combining this definition with regular `Destructor`
11481148
#[derive(Copy, Clone, Debug, HashStable, Encodable, Decodable)]
11491149
pub struct AsyncDestructor {
1150-
/// The `DefId` of the async destructor future constructor
1151-
pub ctor: DefId,
1152-
/// The `DefId` of the async destructor future type
1153-
pub future: DefId,
1150+
/// The `DefId` of the `impl AsyncDrop`
1151+
pub impl_did: LocalDefId,
11541152
}
11551153

11561154
#[derive(Clone, Copy, PartialEq, Eq, HashStable, TyEncodable, TyDecodable)]

compiler/rustc_middle/src/ty/significant_drop_order.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub fn ty_dtor_span<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Option<Span> {
154154
let dtor = if let Some(dtor) = tcx.adt_destructor(did) {
155155
dtor.did
156156
} else if let Some(dtor) = tcx.adt_async_destructor(did) {
157-
dtor.future
157+
return Some(tcx.source_span(dtor.impl_did));
158158
} else {
159159
return Some(try_local_did_span(did));
160160
};

compiler/rustc_middle/src/ty/structural_impls.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ impl fmt::Debug for ty::LateParamRegion {
8686
impl fmt::Debug for ty::LateParamRegionKind {
8787
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
8888
match *self {
89-
ty::LateParamRegionKind::Anon(idx) => write!(f, "BrAnon({idx})"),
89+
ty::LateParamRegionKind::Anon(idx) => write!(f, "LateAnon({idx})"),
9090
ty::LateParamRegionKind::Named(did, name) => {
9191
if did.is_crate_root() {
92-
write!(f, "BrNamed({name})")
92+
write!(f, "LateNamed({name})")
9393
} else {
94-
write!(f, "BrNamed({did:?}, {name})")
94+
write!(f, "LateNamed({did:?}, {name})")
9595
}
9696
}
97-
ty::LateParamRegionKind::ClosureEnv => write!(f, "BrEnv"),
97+
ty::LateParamRegionKind::ClosureEnv => write!(f, "LateEnv"),
9898
}
9999
}
100100
}

compiler/rustc_middle/src/ty/util.rs

+3-61
Original file line numberDiff line numberDiff line change
@@ -455,26 +455,17 @@ impl<'tcx> TyCtxt<'tcx> {
455455
continue;
456456
}
457457

458-
let [future, ctor] = self.associated_item_def_ids(impl_did) else {
459-
self.dcx().span_delayed_bug(
460-
self.def_span(impl_did),
461-
"AsyncDrop impl without async_drop function or Dropper type",
462-
);
463-
continue;
464-
};
465-
466-
if let Some((_, _, old_impl_did)) = dtor_candidate {
458+
if let Some(old_impl_did) = dtor_candidate {
467459
self.dcx()
468460
.struct_span_err(self.def_span(impl_did), "multiple async drop impls found")
469461
.with_span_note(self.def_span(old_impl_did), "other impl here")
470462
.delay_as_bug();
471463
}
472464

473-
dtor_candidate = Some((*future, *ctor, impl_did));
465+
dtor_candidate = Some(impl_did);
474466
}
475467

476-
let (future, ctor, _) = dtor_candidate?;
477-
Some(ty::AsyncDestructor { future, ctor })
468+
Some(ty::AsyncDestructor { impl_did: dtor_candidate? })
478469
}
479470

480471
/// Returns async drop glue morphology for a definition. To get async drop
@@ -1561,55 +1552,6 @@ impl<'tcx> Ty<'tcx> {
15611552
}
15621553
}
15631554

1564-
pub enum ExplicitSelf<'tcx> {
1565-
ByValue,
1566-
ByReference(ty::Region<'tcx>, hir::Mutability),
1567-
ByRawPointer(hir::Mutability),
1568-
ByBox,
1569-
Other,
1570-
}
1571-
1572-
impl<'tcx> ExplicitSelf<'tcx> {
1573-
/// Categorizes an explicit self declaration like `self: SomeType`
1574-
/// into either `self`, `&self`, `&mut self`, `Box<Self>`, or
1575-
/// `Other`.
1576-
/// This is mainly used to require the arbitrary_self_types feature
1577-
/// in the case of `Other`, to improve error messages in the common cases,
1578-
/// and to make `Other` dyn-incompatible.
1579-
///
1580-
/// Examples:
1581-
///
1582-
/// ```ignore (illustrative)
1583-
/// impl<'a> Foo for &'a T {
1584-
/// // Legal declarations:
1585-
/// fn method1(self: &&'a T); // ExplicitSelf::ByReference
1586-
/// fn method2(self: &'a T); // ExplicitSelf::ByValue
1587-
/// fn method3(self: Box<&'a T>); // ExplicitSelf::ByBox
1588-
/// fn method4(self: Rc<&'a T>); // ExplicitSelf::Other
1589-
///
1590-
/// // Invalid cases will be caught by `check_method_receiver`:
1591-
/// fn method_err1(self: &'a mut T); // ExplicitSelf::Other
1592-
/// fn method_err2(self: &'static T) // ExplicitSelf::ByValue
1593-
/// fn method_err3(self: &&T) // ExplicitSelf::ByReference
1594-
/// }
1595-
/// ```
1596-
///
1597-
pub fn determine<P>(self_arg_ty: Ty<'tcx>, is_self_ty: P) -> ExplicitSelf<'tcx>
1598-
where
1599-
P: Fn(Ty<'tcx>) -> bool,
1600-
{
1601-
use self::ExplicitSelf::*;
1602-
1603-
match *self_arg_ty.kind() {
1604-
_ if is_self_ty(self_arg_ty) => ByValue,
1605-
ty::Ref(region, ty, mutbl) if is_self_ty(ty) => ByReference(region, mutbl),
1606-
ty::RawPtr(ty, mutbl) if is_self_ty(ty) => ByRawPointer(mutbl),
1607-
_ if self_arg_ty.boxed_ty().is_some_and(is_self_ty) => ByBox,
1608-
_ => Other,
1609-
}
1610-
}
1611-
}
1612-
16131555
/// Returns a list of types such that the given type needs drop if and only if
16141556
/// *any* of the returned types need drop. Returns `Err(AlwaysRequiresDrop)` if
16151557
/// this type always needs drop.

library/std/src/net/socket_addr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ use crate::{io, iter, option, slice, vec};
101101
/// assert_eq!(err.kind(), io::ErrorKind::InvalidInput);
102102
/// ```
103103
///
104-
/// [`TcpStream::connect`] is an example of an function that utilizes
104+
/// [`TcpStream::connect`] is an example of a function that utilizes
105105
/// `ToSocketAddrs` as a trait bound on its parameter in order to accept
106106
/// different types:
107107
///

src/bootstrap/src/utils/helpers.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -474,13 +474,13 @@ pub fn linker_flags(
474474
if stage == 0 && target.is_windows() {
475475
args.push("-Clink-arg=-fuse-ld=lld".to_string());
476476
} else {
477-
args.push("-Clinker-flavor=gnu-lld-cc".to_string());
477+
args.push("-Zlinker-features=+lld".to_string());
478478
}
479479
// FIXME(kobzol): remove this flag once MCP510 gets stabilized
480480
args.push("-Zunstable-options".to_string());
481481
}
482482
LldMode::SelfContained => {
483-
args.push("-Clinker-flavor=gnu-lld-cc".to_string());
483+
args.push("-Zlinker-features=+lld".to_string());
484484
args.push("-Clink-self-contained=+linker".to_string());
485485
// FIXME(kobzol): remove this flag once MCP510 gets stabilized
486486
args.push("-Zunstable-options".to_string());

0 commit comments

Comments
 (0)