Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
82336c1
wasm target feature: exception handling
mirkootter May 1, 2023
00ce5e8
add wasm eh intrinsics
mirkootter May 1, 2023
35cdb28
add comment
mirkootter May 7, 2023
82730b4
wasm exception handling
mirkootter May 1, 2023
12ad662
add comment regarding `__gxx_wasm_personality_v0`
mirkootter May 21, 2023
744ec64
fix comment (review change)
mirkootter May 22, 2023
8af8a95
Migrate some rustc_builtin_macros to SessionDiagnostic
He1pa Jun 21, 2023
d8d09b0
Declare a `run-coverage` test mode/suite in bootstrap
Zalathar Jun 12, 2023
5b51d9c
Extract a common function for setting up environment vars
Zalathar Jun 12, 2023
a32cdee
Introduce `exec_compiled_test_general`
Zalathar Jun 12, 2023
75d01f8
Remember whether `failure-status` was explicitly specified
Zalathar Jun 12, 2023
a42bbd0
Move the `RUSTC_PROFILER_SUPPORT` check into `CachedNeedsConditions`
Zalathar Jun 12, 2023
22e119b
Add a custom `run-coverage` mode to compiletest
Zalathar Jun 12, 2023
e0625b4
Migrate most of the existing coverage tests over to `run-coverage`
Zalathar Jun 12, 2023
d05653c
Declare a `run-coverage-rustdoc` suite for coverage tests that need `…
Zalathar Jun 12, 2023
9d2564a
Expand `run-coverage` to support the remaining `coverage-reports` tests
Zalathar Jun 12, 2023
a2c0b38
Migrate the remaining `run-make/coverage-reports` tests over to `run-…
Zalathar Jun 12, 2023
edd051c
Re-bless the newly-migrated tests
Zalathar Jun 12, 2023
7b4e75b
Remove the old `coverage-reports` and `coverage` directories
Zalathar Jun 12, 2023
453603a
fix typo
He1pa Jun 28, 2023
aafc801
Make the Elaboratable trait take clauses
compiler-errors Jun 29, 2023
cde54ff
refactor `tool_doc!` so that it can accept additional arguments.
onur-ozkan Jun 3, 2023
4dcce38
resolve: Remove artificial import ambiguity errors
petrochenkov May 29, 2023
35c6a1d
Fix type privacy lints error message
Bryanskiy Jun 29, 2023
4696a92
Rollup merge of #111322 - mirkootter:master, r=davidtwco
matthiaskrgr Jun 29, 2023
be0a96f
Rollup merge of #112086 - petrochenkov:impambig, r=oli-obk
matthiaskrgr Jun 29, 2023
93a97c7
Rollup merge of #112234 - ozkanonur:hotfix, r=jyn514
matthiaskrgr Jun 29, 2023
f00db43
Rollup merge of #112300 - Zalathar:run-coverage, r=wesleywiser
matthiaskrgr Jun 29, 2023
f135815
Rollup merge of #112795 - He1pa:translation_builtin_macros, r=davidtwco
matthiaskrgr Jun 29, 2023
5d74664
Rollup merge of #113144 - compiler-errors:elaborate-clauses, r=oli-obk
matthiaskrgr Jun 29, 2023
4338683
Rollup merge of #113161 - Bryanskiy:err_msg, r=petrochenkov
matthiaskrgr Jun 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make the Elaboratable trait take clauses
  • Loading branch information
compiler-errors committed Jun 29, 2023
commit aafc801d691fb216d3975b0719ad1dd1b3eab527
82 changes: 42 additions & 40 deletions compiler/rustc_infer/src/traits/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ pub struct Elaborator<'tcx, O> {
pub trait Elaboratable<'tcx> {
fn predicate(&self) -> ty::Predicate<'tcx>;

// Makes a new `Self` but with a different predicate.
fn child(&self, predicate: ty::Predicate<'tcx>) -> Self;
// Makes a new `Self` but with a different clause that comes from elaboration.
fn child(&self, clause: ty::Clause<'tcx>) -> Self;

// Makes a new `Self` but with a different predicate and a different cause
// code (if `Self` has one).
// Makes a new `Self` but with a different clause and a different cause
// code (if `Self` has one, such as [`PredicateObligation`]).
fn child_with_derived_cause(
&self,
predicate: ty::Predicate<'tcx>,
clause: ty::Clause<'tcx>,
span: Span,
parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
index: usize,
Expand All @@ -99,18 +99,18 @@ impl<'tcx> Elaboratable<'tcx> for PredicateObligation<'tcx> {
self.predicate
}

fn child(&self, predicate: ty::Predicate<'tcx>) -> Self {
fn child(&self, clause: ty::Clause<'tcx>) -> Self {
Obligation {
cause: self.cause.clone(),
param_env: self.param_env,
recursion_depth: 0,
predicate,
predicate: clause.as_predicate(),
}
}

fn child_with_derived_cause(
&self,
predicate: ty::Predicate<'tcx>,
clause: ty::Clause<'tcx>,
span: Span,
parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
index: usize,
Expand All @@ -123,7 +123,12 @@ impl<'tcx> Elaboratable<'tcx> for PredicateObligation<'tcx> {
span,
}))
});
Obligation { cause, param_env: self.param_env, recursion_depth: 0, predicate }
Obligation {
cause,
param_env: self.param_env,
recursion_depth: 0,
predicate: clause.as_predicate(),
}
}
}

Expand All @@ -132,18 +137,18 @@ impl<'tcx> Elaboratable<'tcx> for ty::Predicate<'tcx> {
*self
}

fn child(&self, predicate: ty::Predicate<'tcx>) -> Self {
predicate
fn child(&self, clause: ty::Clause<'tcx>) -> Self {
clause.as_predicate()
}

fn child_with_derived_cause(
&self,
predicate: ty::Predicate<'tcx>,
clause: ty::Clause<'tcx>,
_span: Span,
_parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
_index: usize,
) -> Self {
predicate
clause.as_predicate()
}
}

Expand All @@ -152,18 +157,18 @@ impl<'tcx> Elaboratable<'tcx> for (ty::Predicate<'tcx>, Span) {
self.0
}

fn child(&self, predicate: ty::Predicate<'tcx>) -> Self {
(predicate, self.1)
fn child(&self, clause: ty::Clause<'tcx>) -> Self {
(clause.as_predicate(), self.1)
}

fn child_with_derived_cause(
&self,
predicate: ty::Predicate<'tcx>,
clause: ty::Clause<'tcx>,
_span: Span,
_parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
_index: usize,
) -> Self {
(predicate, self.1)
(clause.as_predicate(), self.1)
}
}

Expand All @@ -172,18 +177,18 @@ impl<'tcx> Elaboratable<'tcx> for (ty::Clause<'tcx>, Span) {
self.0.as_predicate()
}

fn child(&self, predicate: ty::Predicate<'tcx>) -> Self {
(predicate.expect_clause(), self.1)
fn child(&self, clause: ty::Clause<'tcx>) -> Self {
(clause, self.1)
}

fn child_with_derived_cause(
&self,
predicate: ty::Predicate<'tcx>,
clause: ty::Clause<'tcx>,
_span: Span,
_parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
_index: usize,
) -> Self {
(predicate.expect_clause(), self.1)
(clause, self.1)
}
}

Expand All @@ -192,18 +197,18 @@ impl<'tcx> Elaboratable<'tcx> for ty::Clause<'tcx> {
self.as_predicate()
}

fn child(&self, predicate: ty::Predicate<'tcx>) -> Self {
predicate.expect_clause()
fn child(&self, clause: ty::Clause<'tcx>) -> Self {
clause
}

fn child_with_derived_cause(
&self,
predicate: ty::Predicate<'tcx>,
clause: ty::Clause<'tcx>,
_span: Span,
_parent_trait_pred: ty::PolyTraitPredicate<'tcx>,
_index: usize,
) -> Self {
predicate.expect_clause()
clause
}
}

Expand Down Expand Up @@ -252,14 +257,13 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
};

let obligations =
predicates.predicates.iter().enumerate().map(|(index, &(mut pred, span))| {
predicates.predicates.iter().enumerate().map(|(index, &(mut clause, span))| {
// when parent predicate is non-const, elaborate it to non-const predicates.
if data.constness == ty::BoundConstness::NotConst {
pred = pred.without_const(tcx);
clause = clause.without_const(tcx);
}
elaboratable.child_with_derived_cause(
pred.subst_supertrait(tcx, &bound_predicate.rebind(data.trait_ref))
.as_predicate(),
clause.subst_supertrait(tcx, &bound_predicate.rebind(data.trait_ref)),
span,
bound_predicate.rebind(data),
index,
Expand Down Expand Up @@ -333,26 +337,25 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
if r.is_late_bound() {
None
} else {
Some(ty::PredicateKind::Clause(ty::ClauseKind::RegionOutlives(
ty::OutlivesPredicate(r, r_min),
Some(ty::ClauseKind::RegionOutlives(ty::OutlivesPredicate(
r, r_min,
)))
}
}

Component::Param(p) => {
let ty = tcx.mk_ty_param(p.index, p.name);
Some(ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(
ty::OutlivesPredicate(ty, r_min),
)))
Some(ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(ty, r_min)))
}

Component::UnresolvedInferenceVariable(_) => None,

Component::Alias(alias_ty) => {
// We might end up here if we have `Foo<<Bar as Baz>::Assoc>: 'a`.
// With this, we can deduce that `<Bar as Baz>::Assoc: 'a`.
Some(ty::PredicateKind::Clause(ty::ClauseKind::TypeOutlives(
ty::OutlivesPredicate(alias_ty.to_ty(tcx), r_min),
Some(ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(
alias_ty.to_ty(tcx),
r_min,
)))
}

Expand All @@ -362,10 +365,9 @@ impl<'tcx, O: Elaboratable<'tcx>> Elaborator<'tcx, O> {
None
}
})
.map(|predicate_kind| {
bound_predicate.rebind(predicate_kind).to_predicate(tcx)
})
.map(|predicate| elaboratable.child(predicate)),
.map(|clause| {
elaboratable.child(bound_predicate.rebind(clause).to_predicate(tcx))
}),
);
}
ty::PredicateKind::Clause(ty::ClauseKind::TypeWellFormedFromEnv(..)) => {
Expand Down