Skip to content

Commit a47f796

Browse files
committed
Auto merge of rust-lang#113938 - Mark-Simulacrum:beta-backport, r=Mark-Simulacrum
[beta] backport This PR backports: - rust-lang#113690: allow opaques to be defined by trait queries, again - rust-lang#113631: make MCP510 behavior opt-in to avoid conflicts between the CLI and target flavors It also includes a bump of bootstrap to the released stable. r? `@Mark-Simulacrum`
2 parents aad221e + 179768c commit a47f796

File tree

5 files changed

+351
-419
lines changed

5 files changed

+351
-419
lines changed

compiler/rustc_codegen_ssa/src/back/link.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -2970,10 +2970,25 @@ fn add_lld_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
29702970
return;
29712971
}
29722972

2973+
let self_contained_linker = sess.opts.cg.link_self_contained.linker();
2974+
2975+
// FIXME: some targets default to using `lld`, but users can only override the linker on the CLI
2976+
// and cannot yet select the precise linker flavor to opt out of that. See for example issue
2977+
// #113597 for the `thumbv6m-none-eabi` target: a driver is used, and its default linker
2978+
// conflicts with the target's flavor, causing unexpected arguments being passed.
2979+
//
2980+
// Until the new `LinkerFlavor`-like CLI options are stabilized, we only adopt MCP510's behavior
2981+
// if its dedicated unstable CLI flags are used, to keep the current sub-optimal stable
2982+
// behavior.
2983+
let using_mcp510 =
2984+
self_contained_linker || sess.opts.cg.linker_flavor.is_some_and(|f| f.is_unstable());
2985+
if !using_mcp510 && !unstable_use_lld {
2986+
return;
2987+
}
2988+
29732989
// 1. Implement the "self-contained" part of this feature by adding rustc distribution
29742990
// directories to the tool's search path.
2975-
let self_contained_linker = sess.opts.cg.link_self_contained.linker() || unstable_use_lld;
2976-
if self_contained_linker {
2991+
if self_contained_linker || unstable_use_lld {
29772992
for path in sess.get_tools_search_paths(false) {
29782993
cmd.arg({
29792994
let mut arg = OsString::from("-B");

compiler/rustc_trait_selection/src/infer.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::traits::query::evaluate_obligation::InferCtxtExt as _;
2-
use crate::traits::{self, ObligationCtxt};
2+
use crate::traits::{self, DefiningAnchor, ObligationCtxt};
33

44
use rustc_hir::def_id::DefId;
55
use rustc_hir::lang_items::LangItem;
@@ -80,7 +80,7 @@ impl<'tcx> InferCtxtExt<'tcx> for InferCtxt<'tcx> {
8080

8181
pub trait InferCtxtBuilderExt<'tcx> {
8282
fn enter_canonical_trait_query<K, R>(
83-
&mut self,
83+
self,
8484
canonical_key: &Canonical<'tcx, K>,
8585
operation: impl FnOnce(&ObligationCtxt<'_, 'tcx>, K) -> Result<R, NoSolution>,
8686
) -> Result<CanonicalQueryResponse<'tcx, R>, NoSolution>
@@ -108,7 +108,7 @@ impl<'tcx> InferCtxtBuilderExt<'tcx> for InferCtxtBuilder<'tcx> {
108108
/// have `'tcx` be free on this function so that we can talk about
109109
/// `K: TypeFoldable<TyCtxt<'tcx>>`.)
110110
fn enter_canonical_trait_query<K, R>(
111-
&mut self,
111+
self,
112112
canonical_key: &Canonical<'tcx, K>,
113113
operation: impl FnOnce(&ObligationCtxt<'_, 'tcx>, K) -> Result<R, NoSolution>,
114114
) -> Result<CanonicalQueryResponse<'tcx, R>, NoSolution>
@@ -117,8 +117,9 @@ impl<'tcx> InferCtxtBuilderExt<'tcx> for InferCtxtBuilder<'tcx> {
117117
R: Debug + TypeFoldable<TyCtxt<'tcx>>,
118118
Canonical<'tcx, QueryResponse<'tcx, R>>: ArenaAllocatable<'tcx>,
119119
{
120-
let (infcx, key, canonical_inference_vars) =
121-
self.build_with_canonical(DUMMY_SP, canonical_key);
120+
let (infcx, key, canonical_inference_vars) = self
121+
.with_opaque_type_inference(DefiningAnchor::Bubble)
122+
.build_with_canonical(DUMMY_SP, canonical_key);
122123
let ocx = ObligationCtxt::new(&infcx);
123124
let value = operation(&ocx, key)?;
124125
ocx.make_canonicalized_query_response(canonical_inference_vars, value)

0 commit comments

Comments
 (0)