Skip to content

Commit a44a2b8

Browse files
committed
Auto merge of rust-lang#124945 - matthiaskrgr:rollup-r6395sn, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - rust-lang#124915 (`rustc_target` cleanups) - rust-lang#124927 (opt-dist: use xz2 instead of xz crate) - rust-lang#124936 (analyse visitor: build proof tree in probe) - rust-lang#124943 (always use `GenericArgsRef`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8f9080d + 2f7df58 commit a44a2b8

File tree

21 files changed

+139
-77
lines changed

21 files changed

+139
-77
lines changed

Cargo.lock

+1-10
Original file line numberDiff line numberDiff line change
@@ -2760,7 +2760,7 @@ dependencies = [
27602760
"tabled",
27612761
"tar",
27622762
"tempfile",
2763-
"xz",
2763+
"xz2",
27642764
"zip",
27652765
]
27662766

@@ -6586,15 +6586,6 @@ dependencies = [
65866586
"rustix",
65876587
]
65886588

6589-
[[package]]
6590-
name = "xz"
6591-
version = "0.1.0"
6592-
source = "registry+https://github.com/rust-lang/crates.io-index"
6593-
checksum = "3c887690ff2a2e233e8e49633461521f98ec57fbff9d59a884c9a4f04ec1da34"
6594-
dependencies = [
6595-
"xz2",
6596-
]
6597-
65986589
[[package]]
65996590
name = "xz2"
66006591
version = "0.1.7"

compiler/rustc_hir_typeck/src/method/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
315315
trait_def_id: DefId,
316316
self_ty: Ty<'tcx>,
317317
opt_input_types: Option<&[Ty<'tcx>]>,
318-
) -> (traits::PredicateObligation<'tcx>, &'tcx ty::List<ty::GenericArg<'tcx>>) {
318+
) -> (traits::PredicateObligation<'tcx>, ty::GenericArgsRef<'tcx>) {
319319
// Construct a trait-reference `self_ty : Trait<input_tys>`
320320
let args = GenericArgs::for_item(self.tcx, trait_def_id, |param, _| {
321321
match param.kind {
@@ -365,7 +365,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
365365
m_name: Ident,
366366
trait_def_id: DefId,
367367
obligation: traits::PredicateObligation<'tcx>,
368-
args: &'tcx ty::List<ty::GenericArg<'tcx>>,
368+
args: ty::GenericArgsRef<'tcx>,
369369
) -> Option<InferOk<'tcx, MethodCallee<'tcx>>> {
370370
debug!(?obligation);
371371

compiler/rustc_hir_typeck/src/pat.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
16761676
unmentioned_fields: &mut Vec<(&'tcx ty::FieldDef, Ident)>,
16771677
pat: &'tcx Pat<'tcx>,
16781678
variant: &ty::VariantDef,
1679-
args: &'tcx ty::List<ty::GenericArg<'tcx>>,
1679+
args: ty::GenericArgsRef<'tcx>,
16801680
) -> Diag<'tcx> {
16811681
let tcx = self.tcx;
16821682
let (field_names, t, plural) = if let [field] = inexistent_fields {

compiler/rustc_lint/src/for_loops_over_fallibles.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{
99
use hir::{Expr, Pat};
1010
use rustc_hir as hir;
1111
use rustc_infer::{infer::TyCtxtInferExt, traits::ObligationCause};
12-
use rustc_middle::ty::{self, List};
12+
use rustc_middle::ty;
1313
use rustc_session::{declare_lint, declare_lint_pass};
1414
use rustc_span::{sym, Span};
1515
use rustc_trait_selection::traits::ObligationCtxt;
@@ -123,7 +123,7 @@ fn extract_iterator_next_call<'tcx>(
123123
fn suggest_question_mark<'tcx>(
124124
cx: &LateContext<'tcx>,
125125
adt: ty::AdtDef<'tcx>,
126-
args: &List<ty::GenericArg<'tcx>>,
126+
args: ty::GenericArgsRef<'tcx>,
127127
span: Span,
128128
) -> bool {
129129
let Some(body_id) = cx.enclosing_body else { return false };

compiler/rustc_middle/src/ty/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2331,7 +2331,7 @@ impl<'tcx> TyCtxt<'tcx> {
23312331
pub fn mk_args_from_iter<I, T>(self, iter: I) -> T::Output
23322332
where
23332333
I: Iterator<Item = T>,
2334-
T: CollectAndApply<GenericArg<'tcx>, &'tcx List<GenericArg<'tcx>>>,
2334+
T: CollectAndApply<GenericArg<'tcx>, ty::GenericArgsRef<'tcx>>,
23352335
{
23362336
T::collect_and_apply(iter, |xs| self.mk_args(xs))
23372337
}

compiler/rustc_middle/src/ty/print/pretty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
977977
fn pretty_print_opaque_impl_type(
978978
&mut self,
979979
def_id: DefId,
980-
args: &'tcx ty::List<ty::GenericArg<'tcx>>,
980+
args: ty::GenericArgsRef<'tcx>,
981981
) -> Result<(), PrintError> {
982982
let tcx = self.tcx();
983983

compiler/rustc_target/src/lib.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@
77
//! more 'stuff' here in the future. It does not have a dependency on
88
//! LLVM.
99
10+
// tidy-alphabetical-start
11+
#![allow(internal_features)]
1012
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")]
1113
#![doc(rust_logo)]
12-
#![feature(min_exhaustive_patterns)]
13-
#![feature(rustdoc_internals)]
1414
#![feature(assert_matches)]
1515
#![feature(iter_intersperse)]
1616
#![feature(let_chains)]
17+
#![feature(min_exhaustive_patterns)]
1718
#![feature(rustc_attrs)]
18-
#![feature(step_trait)]
19-
#![allow(internal_features)]
19+
#![feature(rustdoc_internals)]
20+
// tidy-alphabetical-end
2021

2122
use std::path::{Path, PathBuf};
2223

compiler/rustc_target/src/spec/mod.rs

-13
Original file line numberDiff line numberDiff line change
@@ -603,19 +603,6 @@ impl LinkSelfContainedDefault {
603603
self == LinkSelfContainedDefault::False
604604
}
605605

606-
/// Returns whether the target spec explicitly requests self-contained linking, i.e. not via
607-
/// inference.
608-
pub fn is_linker_enabled(self) -> bool {
609-
match self {
610-
LinkSelfContainedDefault::True => true,
611-
LinkSelfContainedDefault::False => false,
612-
LinkSelfContainedDefault::WithComponents(c) => {
613-
c.contains(LinkSelfContainedComponents::LINKER)
614-
}
615-
_ => false,
616-
}
617-
}
618-
619606
/// Returns the key to use when serializing the setting to json:
620607
/// - individual components in a `link-self-contained` object value
621608
/// - the other variants as a backwards-compatible `crt-objects-fallback` string

compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs

+1
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ pub(in crate::solve) fn make_canonical_state<'tcx, T: TypeFoldable<TyCtxt<'tcx>>
409409
/// This currently assumes that unifying the var values trivially succeeds.
410410
/// Adding any inference constraints which weren't present when originally
411411
/// computing the canonical query can result in bugs.
412+
#[instrument(level = "debug", skip(infcx, span, param_env))]
412413
pub(in crate::solve) fn instantiate_canonical_state<'tcx, T: TypeFoldable<TyCtxt<'tcx>>>(
413414
infcx: &InferCtxt<'tcx>,
414415
span: Span,

compiler/rustc_trait_selection/src/solve/inspect/analyse.rs

+33-11
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
146146
/// inference constraints, and optionally the args of an impl if this candidate
147147
/// came from a `CandidateSource::Impl`. This function modifies the state of the
148148
/// `infcx`.
149+
#[instrument(
150+
level = "debug",
151+
skip_all,
152+
fields(goal = ?self.goal.goal, nested_goals = ?self.nested_goals)
153+
)]
149154
pub fn instantiate_nested_goals_and_opt_impl_args(
150155
&self,
151156
span: Span,
@@ -213,10 +218,23 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
213218
};
214219
let goal =
215220
goal.with(infcx.tcx, ty::NormalizesTo { alias, term: unconstrained_term });
216-
let proof_tree = EvalCtxt::enter_root(infcx, GenerateProofTree::Yes, |ecx| {
217-
ecx.evaluate_goal_raw(GoalEvaluationKind::Root, GoalSource::Misc, goal)
218-
})
219-
.1;
221+
// We have to use a `probe` here as evaluating a `NormalizesTo` can constrain the
222+
// expected term. This means that candidates which only fail due to nested goals
223+
// and which normalize to a different term then the final result could ICE: when
224+
// building their proof tree, the expected term was unconstrained, but when
225+
// instantiating the candidate it is already constrained to the result of another
226+
// candidate.
227+
let proof_tree = infcx
228+
.probe(|_| {
229+
EvalCtxt::enter_root(infcx, GenerateProofTree::Yes, |ecx| {
230+
ecx.evaluate_goal_raw(
231+
GoalEvaluationKind::Root,
232+
GoalSource::Misc,
233+
goal,
234+
)
235+
})
236+
})
237+
.1;
220238
InspectGoal::new(
221239
infcx,
222240
self.goal.depth + 1,
@@ -225,13 +243,17 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
225243
source,
226244
)
227245
}
228-
_ => InspectGoal::new(
229-
infcx,
230-
self.goal.depth + 1,
231-
infcx.evaluate_root_goal(goal, GenerateProofTree::Yes).1.unwrap(),
232-
None,
233-
source,
234-
),
246+
_ => {
247+
// We're using a probe here as evaluating a goal could constrain
248+
// inference variables by choosing one candidate. If we then recurse
249+
// into another candidate who ends up with different inference
250+
// constraints, we get an ICE if we already applied the constraints
251+
// from the chosen candidate.
252+
let proof_tree = infcx
253+
.probe(|_| infcx.evaluate_root_goal(goal, GenerateProofTree::Yes).1)
254+
.unwrap();
255+
InspectGoal::new(infcx, self.goal.depth + 1, proof_tree, None, source)
256+
}
235257
})
236258
.collect();
237259

compiler/rustc_trait_selection/src/traits/misc.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_infer::infer::canonical::Canonical;
1010
use rustc_infer::infer::{RegionResolutionError, TyCtxtInferExt};
1111
use rustc_infer::traits::query::NoSolution;
1212
use rustc_infer::{infer::outlives::env::OutlivesEnvironment, traits::FulfillmentError};
13-
use rustc_middle::ty::{self, AdtDef, GenericArg, List, Ty, TyCtxt, TypeVisitableExt};
13+
use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt, TypeVisitableExt};
1414
use rustc_span::DUMMY_SP;
1515

1616
use super::outlives_bounds::InferCtxtExt;
@@ -129,7 +129,7 @@ pub fn all_fields_implement_trait<'tcx>(
129129
param_env: ty::ParamEnv<'tcx>,
130130
self_type: Ty<'tcx>,
131131
adt: AdtDef<'tcx>,
132-
args: &'tcx List<GenericArg<'tcx>>,
132+
args: ty::GenericArgsRef<'tcx>,
133133
parent_cause: ObligationCause<'tcx>,
134134
lang_item: LangItem,
135135
) -> Result<(), Vec<(&'tcx ty::FieldDef, Ty<'tcx>, InfringingFieldsReason<'tcx>)>> {

src/tools/clippy/clippy_lints/src/default_union_representation.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_help;
22
use rustc_hir::{HirId, Item, ItemKind};
33
use rustc_lint::{LateContext, LateLintPass};
44
use rustc_middle::ty::layout::LayoutOf;
5-
use rustc_middle::ty::{self, FieldDef, GenericArg, List};
5+
use rustc_middle::ty::{self, FieldDef};
66
use rustc_session::declare_lint_pass;
77
use rustc_span::sym;
88

@@ -85,7 +85,7 @@ fn is_union_with_two_non_zst_fields<'tcx>(cx: &LateContext<'tcx>, item: &Item<'t
8585
}
8686
}
8787

88-
fn is_zst<'tcx>(cx: &LateContext<'tcx>, field: &FieldDef, args: &'tcx List<GenericArg<'tcx>>) -> bool {
88+
fn is_zst<'tcx>(cx: &LateContext<'tcx>, field: &FieldDef, args: ty::GenericArgsRef<'tcx>) -> bool {
8989
let ty = field.ty(cx.tcx, args);
9090
if let Ok(layout) = cx.layout_of(ty) {
9191
layout.is_zst()

src/tools/clippy/clippy_lints/src/needless_borrows_for_generic_args.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use rustc_infer::infer::TyCtxtInferExt;
1313
use rustc_lint::{LateContext, LateLintPass};
1414
use rustc_middle::mir::{Rvalue, StatementKind};
1515
use rustc_middle::ty::{
16-
self, ClauseKind, EarlyBinder, FnSig, GenericArg, GenericArgKind, List, ParamTy, ProjectionPredicate, Ty,
16+
self, ClauseKind, EarlyBinder, FnSig, GenericArg, GenericArgKind, ParamTy, ProjectionPredicate, Ty,
1717
};
1818
use rustc_session::impl_lint_pass;
1919
use rustc_span::symbol::sym;
@@ -161,7 +161,7 @@ fn needless_borrow_count<'tcx>(
161161
cx: &LateContext<'tcx>,
162162
possible_borrowers: &mut Vec<(LocalDefId, PossibleBorrowerMap<'tcx, 'tcx>)>,
163163
fn_id: DefId,
164-
callee_args: &'tcx List<GenericArg<'tcx>>,
164+
callee_args: ty::GenericArgsRef<'tcx>,
165165
arg_index: usize,
166166
param_ty: ParamTy,
167167
mut expr: &Expr<'tcx>,

src/tools/clippy/clippy_utils/src/ty.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc_middle::traits::EvaluationResult;
1919
use rustc_middle::ty::layout::ValidityRequirement;
2020
use rustc_middle::ty::{
2121
self, AdtDef, AliasTy, AssocKind, Binder, BoundRegion, FnSig, GenericArg, GenericArgKind, GenericArgsRef,
22-
GenericParamDefKind, IntTy, List, ParamEnv, Region, RegionKind, ToPredicate, TraitRef, Ty, TyCtxt,
22+
GenericParamDefKind, IntTy, ParamEnv, Region, RegionKind, ToPredicate, TraitRef, Ty, TyCtxt,
2323
TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, UintTy, VariantDef, VariantDiscr,
2424
};
2525
use rustc_span::symbol::Ident;
@@ -961,7 +961,11 @@ pub struct AdtVariantInfo {
961961

962962
impl AdtVariantInfo {
963963
/// Returns ADT variants ordered by size
964-
pub fn new<'tcx>(cx: &LateContext<'tcx>, adt: AdtDef<'tcx>, subst: &'tcx List<GenericArg<'tcx>>) -> Vec<Self> {
964+
pub fn new<'tcx>(
965+
cx: &LateContext<'tcx>,
966+
adt: AdtDef<'tcx>,
967+
subst: GenericArgsRef<'tcx>
968+
) -> Vec<Self> {
965969
let mut variants_size = adt
966970
.variants()
967971
.iter()

src/tools/opt-dist/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ camino = "1"
1616
reqwest = { version = "0.11", features = ["blocking"] }
1717
zip = { version = "0.6", default-features = false, features = ["deflate"] }
1818
tar = "0.4"
19-
xz = "0.1"
19+
xz = { version = "0.1", package = "xz2" }
2020
serde = { version = "1", features = ["derive"] }
2121
serde_json = "1"
2222
glob = "0.3"

tests/crashes/124702.rs

-14
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//@ compile-flags: -Znext-solver=coherence
2+
//@ check-pass
3+
4+
// A regression test for #124791. Computing ambiguity causes
5+
// for the overlap of the `ToString` impls caused an ICE.
6+
#![crate_type = "lib"]
7+
#![feature(min_specialization)]
8+
trait Display {}
9+
10+
trait ToOwned {
11+
type Owned;
12+
}
13+
14+
impl<T> ToOwned for T {
15+
type Owned = T;
16+
}
17+
18+
struct Cow<B: ?Sized>(B);
19+
20+
impl<B: ?Sized> Display for Cow<B>
21+
where
22+
B: ToOwned,
23+
B::Owned: Display,
24+
{
25+
}
26+
27+
impl Display for () {}
28+
29+
trait ToString {
30+
fn to_string();
31+
}
32+
33+
impl<T: Display + ?Sized> ToString for T {
34+
default fn to_string() {}
35+
}
36+
37+
impl ToString for Cow<str> {
38+
fn to_string() {}
39+
}
40+
41+
impl ToOwned for str {
42+
type Owned = ();
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ compile-flags: -Znext-solver=coherence
2+
3+
// A regression test for #124791. Computing ambiguity causes
4+
// for the overlap of the `ToString` impls caused an ICE.
5+
#![crate_type = "lib"]
6+
trait ToOwned {
7+
type Owned;
8+
}
9+
impl<T> ToOwned for T {
10+
type Owned = u8;
11+
}
12+
impl ToOwned for str {
13+
type Owned = i8;
14+
}
15+
16+
trait Overlap {}
17+
impl<T: ToOwned<Owned = i8> + ?Sized> Overlap for T {}
18+
impl Overlap for str {}
19+
//~^ ERROR conflicting implementations of trait `Overlap`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0119]: conflicting implementations of trait `Overlap` for type `str`
2+
--> $DIR/ambiguity-causes-canonical-state-ice-2.rs:18:1
3+
|
4+
LL | impl<T: ToOwned<Owned = i8> + ?Sized> Overlap for T {}
5+
| --------------------------------------------------- first implementation here
6+
LL | impl Overlap for str {}
7+
| ^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `str`
8+
9+
error: aborting due to 1 previous error
10+
11+
For more information about this error, try `rustc --explain E0119`.

tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ where
6161
// entering the cycle from `A` fails, but would work if we were to use the cache
6262
// result of `B<X>`.
6363
impls_trait::<A<X>, _, _, _>();
64-
//~^ ERROR the trait bound `A<X>: Trait<i32, u8, u8>` is not satisfied
64+
//~^ ERROR the trait bound `A<X>: Trait<_, _, _>` is not satisfied
6565
}
6666

6767
fn main() {

0 commit comments

Comments
 (0)