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

Commit 3f2b2ee

Browse files
committed
Auto merge of rust-lang#104758 - Manishearth:rollup-rh1tfum, r=Manishearth
Rollup of 6 pull requests Successful merges: - rust-lang#103488 (Allow opaque types in trait impl headers and rely on coherence to reject unsound cases) - rust-lang#104359 (Refactor must_use lint into two parts) - rust-lang#104612 (Lower return type outside async block creation) - rust-lang#104621 (Fix --extern library finding errors) - rust-lang#104647 (enable fuzzy_provenance_casts lint in liballoc and libstd) - rust-lang#104750 (Bump `fd-lock` in `bootstrap` again) Failed merges: - rust-lang#104732 (Refactor `ty::ClosureKind` related stuff) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 008bc1d + 42afb70 commit 3f2b2ee

File tree

98 files changed

+902
-540
lines changed

Some content is hidden

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

98 files changed

+902
-540
lines changed

compiler/rustc_ast_lowering/src/expr.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -588,17 +588,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
588588
&mut self,
589589
capture_clause: CaptureBy,
590590
closure_node_id: NodeId,
591-
ret_ty: Option<AstP<Ty>>,
591+
ret_ty: Option<hir::FnRetTy<'hir>>,
592592
span: Span,
593593
async_gen_kind: hir::AsyncGeneratorKind,
594594
body: impl FnOnce(&mut Self) -> hir::Expr<'hir>,
595595
) -> hir::ExprKind<'hir> {
596-
let output = match ret_ty {
597-
Some(ty) => hir::FnRetTy::Return(
598-
self.lower_ty(&ty, &ImplTraitContext::Disallowed(ImplTraitPosition::AsyncBlock)),
599-
),
600-
None => hir::FnRetTy::DefaultReturn(self.lower_span(span)),
601-
};
596+
let output = ret_ty.unwrap_or_else(|| hir::FnRetTy::DefaultReturn(self.lower_span(span)));
602597

603598
// Resume argument type. We let the compiler infer this to simplify the lowering. It is
604599
// fully constrained by `future::from_generator`.
@@ -1003,8 +998,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
1003998
// Transform `async |x: u8| -> X { ... }` into
1004999
// `|x: u8| future_from_generator(|| -> X { ... })`.
10051000
let body_id = this.lower_fn_body(&outer_decl, |this| {
1006-
let async_ret_ty =
1007-
if let FnRetTy::Ty(ty) = &decl.output { Some(ty.clone()) } else { None };
1001+
let async_ret_ty = if let FnRetTy::Ty(ty) = &decl.output {
1002+
let itctx = ImplTraitContext::Disallowed(ImplTraitPosition::AsyncBlock);
1003+
Some(hir::FnRetTy::Return(this.lower_ty(&ty, &itctx)))
1004+
} else {
1005+
None
1006+
};
1007+
10081008
let async_body = this.make_async_expr(
10091009
capture_clause,
10101010
inner_closure_id,

compiler/rustc_borrowck/src/type_check/relate_tys.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ use rustc_infer::infer::nll_relate::{NormalizationStrategy, TypeRelating, TypeRe
22
use rustc_infer::infer::NllRegionVariableOrigin;
33
use rustc_infer::traits::PredicateObligations;
44
use rustc_middle::mir::ConstraintCategory;
5-
use rustc_middle::ty::error::TypeError;
65
use rustc_middle::ty::relate::TypeRelation;
7-
use rustc_middle::ty::{self, Const, Ty};
6+
use rustc_middle::ty::{self, Ty};
87
use rustc_span::Span;
98
use rustc_trait_selection::traits::query::Fallible;
109

@@ -141,13 +140,6 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
141140
);
142141
}
143142

144-
// We don't have to worry about the equality of consts during borrow checking
145-
// as consts always have a static lifetime.
146-
// FIXME(oli-obk): is this really true? We can at least have HKL and with
147-
// inline consts we may have further lifetimes that may be unsound to treat as
148-
// 'static.
149-
fn const_equate(&mut self, _a: Const<'tcx>, _b: Const<'tcx>) {}
150-
151143
fn normalization() -> NormalizationStrategy {
152144
NormalizationStrategy::Eager
153145
}
@@ -156,10 +148,7 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
156148
true
157149
}
158150

159-
fn register_opaque_type_obligations(
160-
&mut self,
161-
obligations: PredicateObligations<'tcx>,
162-
) -> Result<(), TypeError<'tcx>> {
151+
fn register_obligations(&mut self, obligations: PredicateObligations<'tcx>) {
163152
self.type_checker
164153
.fully_perform_op(
165154
self.locations,
@@ -172,6 +161,5 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for NllTypeRelatingDelegate<'_, '_, 'tcx>
172161
},
173162
)
174163
.unwrap();
175-
Ok(())
176164
}
177165
}

compiler/rustc_error_messages/locales/en-US/metadata.ftl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ metadata_crate_location_unknown_type =
275275
extern location for {$crate_name} is of an unknown type: {$path}
276276
277277
metadata_lib_filename_form =
278-
file name should be lib*.rlib or {dll_prefix}*.{dll_suffix}
278+
file name should be lib*.rlib or {$dll_prefix}*{$dll_suffix}
279279
280280
metadata_multiple_import_name_type =
281281
multiple `import_name_type` arguments in a single `#[link]` attribute

compiler/rustc_hir_analysis/src/check/dropck.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ impl<'tcx> TypeRelation<'tcx> for SimpleEqRelation<'tcx> {
244244
self.tcx
245245
}
246246

247+
fn intercrate(&self) -> bool {
248+
false
249+
}
250+
247251
fn param_env(&self) -> ty::ParamEnv<'tcx> {
248252
self.param_env
249253
}
@@ -256,6 +260,10 @@ impl<'tcx> TypeRelation<'tcx> for SimpleEqRelation<'tcx> {
256260
true
257261
}
258262

263+
fn mark_ambiguous(&mut self) {
264+
bug!()
265+
}
266+
259267
fn relate_with_variance<T: Relate<'tcx>>(
260268
&mut self,
261269
_: ty::Variance,

compiler/rustc_hir_analysis/src/coherence/orphan.rs

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use rustc_data_structures::fx::FxHashSet;
55
use rustc_errors::{struct_span_err, DelayDm};
66
use rustc_errors::{Diagnostic, ErrorGuaranteed};
77
use rustc_hir as hir;
8-
use rustc_middle::ty::subst::GenericArgKind;
98
use rustc_middle::ty::subst::InternalSubsts;
109
use rustc_middle::ty::util::IgnoreRegions;
1110
use rustc_middle::ty::{
@@ -47,58 +46,6 @@ fn do_orphan_check_impl<'tcx>(
4746
let sp = tcx.def_span(def_id);
4847
let tr = impl_.of_trait.as_ref().unwrap();
4948

50-
// Ensure no opaque types are present in this impl header. See issues #76202 and #86411 for examples,
51-
// and #84660 where it would otherwise allow unsoundness.
52-
if trait_ref.has_opaque_types() {
53-
trace!("{:#?}", item);
54-
// First we find the opaque type in question.
55-
for ty in trait_ref.substs {
56-
for ty in ty.walk() {
57-
let ty::subst::GenericArgKind::Type(ty) = ty.unpack() else { continue };
58-
let ty::Opaque(def_id, _) = *ty.kind() else { continue };
59-
trace!(?def_id);
60-
61-
// Then we search for mentions of the opaque type's type alias in the HIR
62-
struct SpanFinder<'tcx> {
63-
sp: Span,
64-
def_id: DefId,
65-
tcx: TyCtxt<'tcx>,
66-
}
67-
impl<'v, 'tcx> hir::intravisit::Visitor<'v> for SpanFinder<'tcx> {
68-
#[instrument(level = "trace", skip(self, _id))]
69-
fn visit_path(&mut self, path: &'v hir::Path<'v>, _id: hir::HirId) {
70-
// You can't mention an opaque type directly, so we look for type aliases
71-
if let hir::def::Res::Def(hir::def::DefKind::TyAlias, def_id) = path.res {
72-
// And check if that type alias's type contains the opaque type we're looking for
73-
for arg in self.tcx.type_of(def_id).walk() {
74-
if let GenericArgKind::Type(ty) = arg.unpack() {
75-
if let ty::Opaque(def_id, _) = *ty.kind() {
76-
if def_id == self.def_id {
77-
// Finally we update the span to the mention of the type alias
78-
self.sp = path.span;
79-
return;
80-
}
81-
}
82-
}
83-
}
84-
}
85-
hir::intravisit::walk_path(self, path)
86-
}
87-
}
88-
89-
let mut visitor = SpanFinder { sp, def_id, tcx };
90-
hir::intravisit::walk_item(&mut visitor, item);
91-
let reported = tcx
92-
.sess
93-
.struct_span_err(visitor.sp, "cannot implement trait on type alias impl trait")
94-
.span_note(tcx.def_span(def_id), "type alias impl trait defined here")
95-
.emit();
96-
return Err(reported);
97-
}
98-
}
99-
span_bug!(sp, "opaque type not found, but `has_opaque_types` is set")
100-
}
101-
10249
match traits::orphan_check(tcx, item.owner_id.to_def_id()) {
10350
Ok(()) => {}
10451
Err(err) => emit_orphan_check_error(

compiler/rustc_hir_analysis/src/impl_wf_check/min_specialization.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ fn trait_predicate_kind<'tcx>(
517517
| ty::PredicateKind::ClosureKind(..)
518518
| ty::PredicateKind::ConstEvaluatable(..)
519519
| ty::PredicateKind::ConstEquate(..)
520+
| ty::PredicateKind::Ambiguous
520521
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
521522
}
522523
}

compiler/rustc_hir_analysis/src/outlives/explicit.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ impl<'tcx> ExplicitPredicatesMap<'tcx> {
5959
| ty::PredicateKind::Coerce(..)
6060
| ty::PredicateKind::ConstEvaluatable(..)
6161
| ty::PredicateKind::ConstEquate(..)
62+
| ty::PredicateKind::Ambiguous
6263
| ty::PredicateKind::TypeWellFormedFromEnv(..) => (),
6364
}
6465
}

compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
702702
// code is looking for a self type of an unresolved
703703
// inference variable.
704704
| ty::PredicateKind::ClosureKind(..)
705+
| ty::PredicateKind::Ambiguous
705706
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
706707
},
707708
)

compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
803803
| ty::PredicateKind::TypeOutlives(..)
804804
| ty::PredicateKind::ConstEvaluatable(..)
805805
| ty::PredicateKind::ConstEquate(..)
806+
| ty::PredicateKind::Ambiguous
806807
| ty::PredicateKind::TypeWellFormedFromEnv(..) => None,
807808
}
808809
});

compiler/rustc_infer/src/infer/at.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ impl<'tcx> InferCtxt<'tcx> {
8181
.normalize_fn_sig_for_diagnostic
8282
.as_ref()
8383
.map(|f| f.clone()),
84+
intercrate: self.intercrate,
8485
}
8586
}
8687
}

0 commit comments

Comments
 (0)