Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #98486

Merged
merged 32 commits into from
Jun 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8b1f85c
Windows: Iterative `remove_dir_all`
ChrisDenton Apr 25, 2022
8dc4696
Retry deleting a directory
ChrisDenton Apr 26, 2022
d579665
Yield the thread when waiting to delete a file
ChrisDenton Apr 28, 2022
ab3a2a0
Unify copying data from enclave to userspace
raoulstrackx Mar 29, 2022
531752f
Mitigate MMIO stale data vulnerabilities
raoulstrackx Mar 28, 2022
6f7d193
Ensure userspace allocation is 8-byte aligned
raoulstrackx Mar 23, 2022
a27aace
Test `copy_to_userspace` function
raoulstrackx Mar 22, 2022
d722944
Leak pthreax_mutex_t when it's dropped while locked.
m-ou-se Jun 16, 2022
e642c59
Leak pthreax_rwlock_t when it's dropped while locked.
m-ou-se Jun 19, 2022
6ac6866
Reverse folder hierarchy
eggyal Jun 20, 2022
75203ee
Remove unecessary references to TypeFolder::Error
eggyal Jun 21, 2022
402dceb
point to type param definition when not finding variant, method and a…
TaKO8Ki Jun 20, 2022
6a6910e
Address reviewer comments
raoulstrackx Jun 22, 2022
d23eea5
Add tracking issues to `--extern` option docs.
ehuss Jun 22, 2022
3c7f1f1
Suggest defining variable as mutable on `&mut _` type mismatch in pats
WaffleLapkin Jun 23, 2022
4c4fb71
add test
b-naber Jun 23, 2022
2e3221a
use correct substs in enum discriminant hack
b-naber Jun 23, 2022
38814fc
small refactor
b-naber Jun 24, 2022
f39c0d6
address review
b-naber Jun 24, 2022
ada2acc
Set relocation_model to Pic on emscripten target
hoodmane Jun 15, 2022
bf48b62
fmt
b-naber Jun 24, 2022
e25129b
take advantage of a labelled block
WaffleLapkin Jun 24, 2022
1dfb53b
improve wording of a suggestion
WaffleLapkin Jun 24, 2022
d7388d1
Rollup merge of #96412 - ChrisDenton:remove-dir-all, r=thomcc
matthiaskrgr Jun 25, 2022
a130521
Rollup merge of #98126 - fortanix:raoul/mitigate_stale_data_vulnerabi…
matthiaskrgr Jun 25, 2022
45ef23d
Rollup merge of #98149 - hoodmane:emscripten-pic, r=petrochenkov
matthiaskrgr Jun 25, 2022
ecefccd
Rollup merge of #98194 - m-ou-se:leak-locked-pthread-mutex, r=Amanieu
matthiaskrgr Jun 25, 2022
8257ba2
Rollup merge of #98298 - TaKO8Ki:point-to-type-param-definition, r=co…
matthiaskrgr Jun 25, 2022
65187f5
Rollup merge of #98311 - eggyal:reverse-folder-hierarchy, r=jackh726
matthiaskrgr Jun 25, 2022
95ba108
Rollup merge of #98401 - ehuss:extern-tracking, r=Dylan-DPC
matthiaskrgr Jun 25, 2022
ea07b96
Rollup merge of #98429 - b-naber:use-correct-substs-discriminant-cast…
matthiaskrgr Jun 25, 2022
1f923c2
Rollup merge of #98431 - WaffleLapkin:mut_pat_suggestions, r=compiler…
matthiaskrgr Jun 25, 2022
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
6 changes: 2 additions & 4 deletions compiler/rustc_infer/src/infer/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for OpportunisticRegionResolver<'a, 'tcx> {
.borrow_mut()
.unwrap_region_constraints()
.opportunistic_resolve_var(rid);
self.tcx().reuse_or_mk_region(r, ty::ReVar(resolved))
TypeFolder::tcx(self).reuse_or_mk_region(r, ty::ReVar(resolved))
}
_ => r,
}
Expand Down Expand Up @@ -179,15 +179,13 @@ struct FullTypeResolver<'a, 'tcx> {
infcx: &'a InferCtxt<'a, 'tcx>,
}

impl<'a, 'tcx> TypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
impl<'a, 'tcx> FallibleTypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
type Error = FixupError<'tcx>;

fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
self.infcx.tcx
}
}

impl<'a, 'tcx> FallibleTypeFolder<'tcx> for FullTypeResolver<'a, 'tcx> {
fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
if !t.needs_infer() {
Ok(t) // micro-optimize -- if there is nothing in this type that this fold affects...
Expand Down
85 changes: 34 additions & 51 deletions compiler/rustc_middle/src/ty/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
/// A convenient alternative to `try_fold_with` for use with infallible
/// folders. Do not override this method, to ensure coherence with
/// `try_fold_with`.
fn fold_with<F: TypeFolder<'tcx, Error = !>>(self, folder: &mut F) -> Self {
fn fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
self.try_fold_with(folder).into_ok()
}

Expand Down Expand Up @@ -216,7 +216,7 @@ pub trait TypeSuperFoldable<'tcx>: TypeFoldable<'tcx> {
/// A convenient alternative to `try_super_fold_with` for use with
/// infallible folders. Do not override this method, to ensure coherence
/// with `try_super_fold_with`.
fn super_fold_with<F: TypeFolder<'tcx, Error = !>>(self, folder: &mut F) -> Self {
fn super_fold_with<F: TypeFolder<'tcx>>(self, folder: &mut F) -> Self {
self.try_super_fold_with(folder).into_ok()
}

Expand All @@ -229,70 +229,46 @@ pub trait TypeSuperFoldable<'tcx>: TypeFoldable<'tcx> {
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> ControlFlow<V::BreakTy>;
}

/// This trait is implemented for every folding traversal. There is a fold
/// method defined for every type of interest. Each such method has a default
/// that does an "identity" fold. Implementations of these methods often fall
/// back to a `super_fold_with` method if the primary argument doesn't
/// satisfy a particular condition.
/// This trait is implemented for every infallible folding traversal. There is
/// a fold method defined for every type of interest. Each such method has a
/// default that does an "identity" fold. Implementations of these methods
/// often fall back to a `super_fold_with` method if the primary argument
/// doesn't satisfy a particular condition.
///
/// If this folder is fallible (and therefore its [`Error`][`TypeFolder::Error`]
/// associated type is something other than the default `!`) then
/// [`FallibleTypeFolder`] should be implemented manually. Otherwise,
/// a blanket implementation of [`FallibleTypeFolder`] will defer to
/// A blanket implementation of [`FallibleTypeFolder`] will defer to
/// the infallible methods of this trait to ensure that the two APIs
/// are coherent.
pub trait TypeFolder<'tcx>: Sized {
type Error = !;

pub trait TypeFolder<'tcx>: FallibleTypeFolder<'tcx, Error = !> {
fn tcx<'a>(&'a self) -> TyCtxt<'tcx>;

fn fold_binder<T>(&mut self, t: Binder<'tcx, T>) -> Binder<'tcx, T>
where
T: TypeFoldable<'tcx>,
Self: TypeFolder<'tcx, Error = !>,
{
t.super_fold_with(self)
}

fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx>
where
Self: TypeFolder<'tcx, Error = !>,
{
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
t.super_fold_with(self)
}

fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx>
where
Self: TypeFolder<'tcx, Error = !>,
{
fn fold_region(&mut self, r: ty::Region<'tcx>) -> ty::Region<'tcx> {
r.super_fold_with(self)
}

fn fold_const(&mut self, c: ty::Const<'tcx>) -> ty::Const<'tcx>
where
Self: TypeFolder<'tcx, Error = !>,
{
fn fold_const(&mut self, c: ty::Const<'tcx>) -> ty::Const<'tcx> {
c.super_fold_with(self)
}

fn fold_unevaluated(&mut self, uv: ty::Unevaluated<'tcx>) -> ty::Unevaluated<'tcx>
where
Self: TypeFolder<'tcx, Error = !>,
{
fn fold_unevaluated(&mut self, uv: ty::Unevaluated<'tcx>) -> ty::Unevaluated<'tcx> {
uv.super_fold_with(self)
}

fn fold_predicate(&mut self, p: ty::Predicate<'tcx>) -> ty::Predicate<'tcx>
where
Self: TypeFolder<'tcx, Error = !>,
{
fn fold_predicate(&mut self, p: ty::Predicate<'tcx>) -> ty::Predicate<'tcx> {
p.super_fold_with(self)
}

fn fold_mir_const(&mut self, c: mir::ConstantKind<'tcx>) -> mir::ConstantKind<'tcx>
where
Self: TypeFolder<'tcx, Error = !>,
{
fn fold_mir_const(&mut self, c: mir::ConstantKind<'tcx>) -> mir::ConstantKind<'tcx> {
bug!("most type folders should not be folding MIR datastructures: {:?}", c)
}
}
Expand All @@ -304,7 +280,11 @@ pub trait TypeFolder<'tcx>: Sized {
/// A blanket implementation of this trait (that defers to the relevant
/// method of [`TypeFolder`]) is provided for all infallible folders in
/// order to ensure the two APIs are coherent.
pub trait FallibleTypeFolder<'tcx>: TypeFolder<'tcx> {
pub trait FallibleTypeFolder<'tcx>: Sized {
type Error;

fn tcx<'a>(&'a self) -> TyCtxt<'tcx>;

fn try_fold_binder<T>(&mut self, t: Binder<'tcx, T>) -> Result<Binder<'tcx, T>, Self::Error>
where
T: TypeFoldable<'tcx>,
Expand Down Expand Up @@ -350,45 +330,48 @@ pub trait FallibleTypeFolder<'tcx>: TypeFolder<'tcx> {
// delegates to infallible methods to ensure coherence.
impl<'tcx, F> FallibleTypeFolder<'tcx> for F
where
F: TypeFolder<'tcx, Error = !>,
F: TypeFolder<'tcx>,
{
fn try_fold_binder<T>(&mut self, t: Binder<'tcx, T>) -> Result<Binder<'tcx, T>, Self::Error>
type Error = !;

fn tcx<'a>(&'a self) -> TyCtxt<'tcx> {
TypeFolder::tcx(self)
}

fn try_fold_binder<T>(&mut self, t: Binder<'tcx, T>) -> Result<Binder<'tcx, T>, !>
where
T: TypeFoldable<'tcx>,
{
Ok(self.fold_binder(t))
}

fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
fn try_fold_ty(&mut self, t: Ty<'tcx>) -> Result<Ty<'tcx>, !> {
Ok(self.fold_ty(t))
}

fn try_fold_region(&mut self, r: ty::Region<'tcx>) -> Result<ty::Region<'tcx>, Self::Error> {
fn try_fold_region(&mut self, r: ty::Region<'tcx>) -> Result<ty::Region<'tcx>, !> {
Ok(self.fold_region(r))
}

fn try_fold_const(&mut self, c: ty::Const<'tcx>) -> Result<ty::Const<'tcx>, Self::Error> {
fn try_fold_const(&mut self, c: ty::Const<'tcx>) -> Result<ty::Const<'tcx>, !> {
Ok(self.fold_const(c))
}

fn try_fold_unevaluated(
&mut self,
c: ty::Unevaluated<'tcx>,
) -> Result<ty::Unevaluated<'tcx>, Self::Error> {
) -> Result<ty::Unevaluated<'tcx>, !> {
Ok(self.fold_unevaluated(c))
}

fn try_fold_predicate(
&mut self,
p: ty::Predicate<'tcx>,
) -> Result<ty::Predicate<'tcx>, Self::Error> {
fn try_fold_predicate(&mut self, p: ty::Predicate<'tcx>) -> Result<ty::Predicate<'tcx>, !> {
Ok(self.fold_predicate(p))
}

fn try_fold_mir_const(
&mut self,
c: mir::ConstantKind<'tcx>,
) -> Result<mir::ConstantKind<'tcx>, Self::Error> {
) -> Result<mir::ConstantKind<'tcx>, !> {
Ok(self.fold_mir_const(c))
}
}
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_middle/src/ty/normalize_erasing_regions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,13 @@ impl<'tcx> TryNormalizeAfterErasingRegionsFolder<'tcx> {
}
}

impl<'tcx> TypeFolder<'tcx> for TryNormalizeAfterErasingRegionsFolder<'tcx> {
impl<'tcx> FallibleTypeFolder<'tcx> for TryNormalizeAfterErasingRegionsFolder<'tcx> {
type Error = NormalizationError<'tcx>;

fn tcx(&self) -> TyCtxt<'tcx> {
self.tcx
}
}

impl<'tcx> FallibleTypeFolder<'tcx> for TryNormalizeAfterErasingRegionsFolder<'tcx> {
fn try_fold_ty(&mut self, ty: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
match self.try_normalize_generic_arg_after_erasing_regions(ty.into()) {
Ok(t) => Ok(t.expect_ty()),
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/subst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ impl<'a, 'tcx> SubstFolder<'a, 'tcx> {
return val;
}

let result = ty::fold::shift_vars(self.tcx(), val, self.binders_passed);
let result = ty::fold::shift_vars(TypeFolder::tcx(self), val, self.binders_passed);
debug!("shift_vars: shifted result = {:?}", result);

result
Expand Down
Loading