Skip to content

Commit 1fe72d3

Browse files
committed
Auto merge of #155024 - jhpratt:rollup-PPA0SHp, r=jhpratt
Rollup of 10 pull requests Successful merges: - #150316 (Do not use non-wf input expectations from fudge when checking function calls) - #152859 (`-Znext-solver` use the trait object's own bounds instead of goal when considering builtin object bounds) - #154856 (Fix linking two dylibs together when both depend on profiler_builtins) - #153888 (Avoid stack overflow in FindExprBySpan) - #154991 (Fix ICE in next-solver TransmuteFrom candidate) - #154995 (min/max_by tests: also check result) - #155004 (core/num: Fix feature name for unstable `integer_extend_truncate` functions) - #155007 (renaming method is_impl_trait to is_opaque) - #155009 (meta: Add checkboxes to unsresolved questions in issue templates) - #155017 (Update tracking issue number of future-incompatibility lint `unstable_syntax_pre_expansion`)
2 parents d0442e2 + 1166f31 commit 1fe72d3

76 files changed

Lines changed: 739 additions & 357 deletions

File tree

Some content is hidden

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

.github/ISSUE_TEMPLATE/library_tracking_issue.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,6 @@ It's useful to link any relevant discussions and conclusions (whether on GitHub,
8383
Zulip, or the internals forum) here.
8484
-->
8585

86-
- None yet.
86+
- [ ] None yet.
8787

8888
[^1]: https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

.github/ISSUE_TEMPLATE/tracking_issue.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,12 @@ for larger features an implementation could be broken up into multiple PRs.
5555
### Unresolved Questions
5656
<!--
5757
Include any open questions that need to be answered before the feature can be
58-
stabilised.
58+
stabilised. It is useful to link related discussions and conculsions as they
59+
develop.
5960
-->
6061

61-
XXX --- list all the "unresolved questions" found in the RFC to ensure they are
62-
not forgotten
62+
- [ ] list all the "unresolved questions" found in the RFC to ensure they are
63+
not forgotten.
6364

6465
### Implementation history
6566

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2972,9 +2972,11 @@ fn add_upstream_rust_crates(
29722972
// We must always link crates `compiler_builtins` and `profiler_builtins` statically.
29732973
// Even if they were already included into a dylib
29742974
// (e.g. `libstd` when `-C prefer-dynamic` is used).
2975+
// HACK: `dependency_formats` can report `profiler_builtins` as `NotLinked`.
2976+
// See the comment in inject_profiler_runtime for why this is the case.
29752977
let linkage = data[cnum];
29762978
let link_static_crate = linkage == Linkage::Static
2977-
|| linkage == Linkage::IncludedFromDylib
2979+
|| (linkage == Linkage::IncludedFromDylib || linkage == Linkage::NotLinked)
29782980
&& (crate_info.compiler_builtins == Some(cnum)
29792981
|| crate_info.profiler_runtime == Some(cnum));
29802982

compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2167,7 +2167,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'_>, opaque_def_id: LocalDefId) -> ErrorG
21672167
for def_id in visitor.opaques {
21682168
let ty_span = tcx.def_span(def_id);
21692169
if !seen.contains(&ty_span) {
2170-
let descr = if ty.is_impl_trait() { "opaque " } else { "" };
2170+
let descr = if ty.is_opaque() { "opaque " } else { "" };
21712171
err.span_label(ty_span, format!("returning this {descr}type `{ty}`"));
21722172
seen.insert(ty_span);
21732173
}

compiler/rustc_hir_typeck/src/expr_use_visitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ impl<'tcx, Cx: TypeInformationCtxt<'tcx>, D: Delegate<'tcx>> ExprUseVisitor<'tcx
14621462
&& self
14631463
.cx
14641464
.structurally_resolve_type(self.cx.tcx().hir_span(base_place.hir_id), place_ty)
1465-
.is_impl_trait()
1465+
.is_opaque()
14661466
{
14671467
projections.push(Projection { kind: ProjectionKind::OpaqueCast, ty: node_ty });
14681468
}

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,29 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
215215
self.check_place_expr_if_unsized(fn_input_ty, arg_expr);
216216
}
217217

218+
let formal_input_tys_ns;
219+
let formal_input_tys = if self.next_trait_solver() {
220+
// In the new solver, the normalizations are done lazily.
221+
// Because of this, if we encounter unnormalized alias types inside this
222+
// fudge scope, we might lose the relationships between them and other vars
223+
// when fudging inference variables created here.
224+
// So, we utilize generalization to normalize aliases by adding a new
225+
// inference var and equating it with the type we want to pull out of the
226+
// fudge scope.
227+
formal_input_tys_ns = formal_input_tys
228+
.iter()
229+
.map(|&ty| {
230+
let generalized_ty = self.next_ty_var(call_span);
231+
self.demand_eqtype(call_span, ty, generalized_ty);
232+
generalized_ty
233+
})
234+
.collect_vec();
235+
236+
formal_input_tys_ns.as_slice()
237+
} else {
238+
formal_input_tys
239+
};
240+
218241
// First, let's unify the formal method signature with the expectation eagerly.
219242
// We use this to guide coercion inference; it's output is "fudged" which means
220243
// any remaining type variables are assigned to new, unrelated variables. This
@@ -238,37 +261,16 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
238261
let origin = self.misc(call_span);
239262
ocx.sup(&origin, self.param_env, expected_output, formal_output)?;
240263

241-
let formal_input_tys_ns;
242-
let formal_input_tys = if self.next_trait_solver() {
243-
// In the new solver, the normalizations are done lazily.
244-
// Because of this, if we encounter unnormalized alias types inside this
245-
// fudge scope, we might lose the relationships between them and other vars
246-
// when fudging inference variables created here.
247-
// So, we utilize generalization to normalize aliases by adding a new
248-
// inference var and equating it with the type we want to pull out of the
249-
// fudge scope.
250-
formal_input_tys_ns = formal_input_tys
251-
.iter()
252-
.map(|&ty| {
253-
// If we replace a (unresolved) inference var with a new inference
254-
// var, it will be eventually resolved to itself and this will
255-
// weaken type inferences as the new inference var will be fudged
256-
// out and lose all relationships with other vars while the former
257-
// will not be fudged.
258-
if ty.is_ty_var() {
259-
return ty;
260-
}
261-
262-
let generalized_ty = self.next_ty_var(call_span);
263-
ocx.eq(&origin, self.param_env, ty, generalized_ty).unwrap();
264-
generalized_ty
265-
})
266-
.collect_vec();
267-
268-
formal_input_tys_ns.as_slice()
269-
} else {
270-
formal_input_tys
271-
};
264+
// Check the well-formedness of expected input tys, as using ill-formed
265+
// expectation may cause type inference errors, see #150316.
266+
for &ty in formal_input_tys {
267+
ocx.register_obligation(traits::Obligation::new(
268+
self.tcx,
269+
self.misc(call_span),
270+
self.param_env,
271+
ty::ClauseKind::WellFormed(ty.into()),
272+
));
273+
}
272274

273275
if !ocx.try_evaluate_obligations().is_empty() {
274276
return Err(TypeError::Mismatch);

compiler/rustc_lint/src/traits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl<'tcx> LateLintPass<'tcx> for DropTraitConstraints {
9797
let def_id = trait_predicate.trait_ref.def_id;
9898
if cx.tcx.is_lang_item(def_id, LangItem::Drop) {
9999
// Explicitly allow `impl Drop`, a drop-guards-as-unnameable-type pattern.
100-
if trait_predicate.trait_ref.self_ty().is_impl_trait() {
100+
if trait_predicate.trait_ref.self_ty().is_opaque() {
101101
continue;
102102
}
103103
let Some(def_id) = cx.tcx.get_diagnostic_item(sym::needs_drop) else { return };

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3158,7 +3158,7 @@ declare_lint! {
31583158
/// ### Example
31593159
///
31603160
/// ```rust
3161-
/// #[cfg(FALSE)]
3161+
/// #[cfg(feature = "nightly")]
31623162
/// macro foo() {}
31633163
/// ```
31643164
///
@@ -3182,22 +3182,22 @@ declare_lint! {
31823182
/// ( $($tokens:tt)* ) => { $($tokens)* }
31833183
/// }
31843184
///
3185-
/// #[cfg(FALSE)]
3185+
/// #[cfg(feature = "nightly")]
31863186
/// identity! {
31873187
/// macro foo() {}
31883188
/// }
31893189
/// ```
31903190
///
31913191
/// This is a [future-incompatible] lint to transition this
3192-
/// to a hard error in the future. See [issue #65860] for more details.
3192+
/// to a hard error in the future. See [issue #154045] for more details.
31933193
///
3194-
/// [issue #65860]: https://github.com/rust-lang/rust/issues/65860
3194+
/// [issue #154045]: https://github.com/rust-lang/rust/issues/154045
31953195
/// [future-incompatible]: ../index.md#future-incompatible-lints
31963196
pub UNSTABLE_SYNTAX_PRE_EXPANSION,
31973197
Warn,
31983198
"unstable syntax can change at any point in the future, causing a hard error!",
31993199
@future_incompatible = FutureIncompatibleInfo {
3200-
reason: fcw!(FutureReleaseError #65860),
3200+
reason: fcw!(FutureReleaseError #154045),
32013201
};
32023202
}
32033203

compiler/rustc_metadata/src/creader.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,12 +1024,19 @@ impl CStore {
10241024

10251025
info!("loading profiler");
10261026

1027+
// HACK: This uses conditional despite actually being unconditional to ensure that
1028+
// there is no error emitted when two dylibs independently depend on profiler_builtins.
1029+
// This is fine as profiler_builtins is always statically linked into the dylib just
1030+
// like compiler_builtins. Unlike compiler_builtins however there is no guaranteed
1031+
// common dylib that the duplicate crate check believes the crate to be included in.
1032+
// add_upstream_rust_crates has a corresponding check that forces profiler_builtins
1033+
// to be statically linked in even when marked as NotLinked.
10271034
let name = Symbol::intern(&tcx.sess.opts.unstable_opts.profiler_runtime);
10281035
let Some(cnum) = self.resolve_crate(
10291036
tcx,
10301037
name,
10311038
DUMMY_SP,
1032-
CrateDepKind::Unconditional,
1039+
CrateDepKind::Conditional,
10331040
CrateOrigin::Injected,
10341041
) else {
10351042
return;

compiler/rustc_middle/src/ty/sty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ impl<'tcx> Ty<'tcx> {
15941594
}
15951595

15961596
#[inline]
1597-
pub fn is_impl_trait(self) -> bool {
1597+
pub fn is_opaque(self) -> bool {
15981598
matches!(self.kind(), Alias(ty::AliasTy { kind: ty::Opaque { .. }, .. }))
15991599
}
16001600

0 commit comments

Comments
 (0)