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 10 pull requests #109438

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9261fd0
Nested impl traits trigger opaque_hidden_inferred_bound too much
compiler-errors Feb 27, 2023
d7049ca
add the --json flag to compiletest
pietroalbini Mar 1, 2023
d2f3806
render compiletest output with render_tests
pietroalbini Mar 2, 2023
f96774b
add support for terse output
pietroalbini Mar 2, 2023
f816d3a
add a splash of color
pietroalbini Mar 2, 2023
9388c8e
record tests in build metrics
pietroalbini Mar 2, 2023
b14b355
add support for benchmarks
pietroalbini Mar 2, 2023
50b3583
switch all tests to use render_tests
pietroalbini Mar 2, 2023
ad9a444
avoid overlapping stderr
pietroalbini Mar 2, 2023
f23e205
do not use render_tests for clippy
pietroalbini Mar 2, 2023
9a1ff1b
handle non-json output in stdout
pietroalbini Mar 3, 2023
4958272
change approach to prevent interleaving compiletest message
pietroalbini Mar 3, 2023
3248ab7
fix name of the field containing the ignore reason
pietroalbini Mar 6, 2023
c015d0d
switch to termcolor
pietroalbini Mar 7, 2023
f7a9702
rustdoc: Cleanup parent module tracking for doc links
petrochenkov Mar 18, 2023
ae47810
rustdoc: Factor out some doc link resolution code into a separate fun…
petrochenkov Mar 19, 2023
69a82f7
add myself to mailmap
aDotInTheVoid Mar 19, 2023
9f80c75
Walk un-shifted nested `impl Trait` in trait when setting up default …
compiler-errors Mar 16, 2023
239ec6c
drive-by: Fix a comment in TyCtxt::fold_regions and remove an unused …
compiler-errors Mar 17, 2023
5b4fa5b
fix typo
lcnr Mar 20, 2023
8e4e55e
Support aggregate expressions
cbeuw Mar 20, 2023
e24f5ac
Fix off-by-one in mir syntax doc
cbeuw Mar 20, 2023
f404f33
Use builtin_index instead of match
cbeuw Mar 20, 2023
e4a4064
adapt tests/codegen/vec-shrink-panik for LLVM 17
krasimirgg Mar 20, 2023
5058cc8
not *all* retags might be explicit in Runtime MIR
RalfJung Mar 20, 2023
93eeb12
Refactor `handle_missing_lit`.
nnethercote Feb 1, 2023
3ecc354
Rollup merge of #108541 - compiler-errors:lol-nested-rpits, r=oli-obk
Noratrieb Mar 21, 2023
d3749f0
Rollup merge of #108659 - ferrocene:pa-test-metrics, r=Mark-Simulacrum
Noratrieb Mar 21, 2023
38e6c35
Rollup merge of #109240 - compiler-errors:dont-binder-twice, r=oli-obk
Noratrieb Mar 21, 2023
3d6676a
Rollup merge of #109312 - petrochenkov:docice5, r=GuillaumeGomez
Noratrieb Mar 21, 2023
17c9f27
Rollup merge of #109385 - lcnr:typo, r=Dylan-DPC
Noratrieb Mar 21, 2023
bb98a8e
Rollup merge of #109386 - aDotInTheVoid:mailmap, r=WaffleLapkin
Noratrieb Mar 21, 2023
a352a17
Rollup merge of #109390 - cbeuw:aggregate-lit, r=oli-obk
Noratrieb Mar 21, 2023
aa8d357
Rollup merge of #109394 - krasimirgg:llvm-17-vec-panic, r=nikic
Noratrieb Mar 21, 2023
27a9dcf
Rollup merge of #109408 - RalfJung:retags, r=compiler-errors
Noratrieb Mar 21, 2023
b567a1c
Rollup merge of #109415 - nnethercote:refactor-handle_missing_lit, r=…
Noratrieb Mar 21, 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
15 changes: 1 addition & 14 deletions compiler/rustc_middle/src/ty/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ where
// Region folder

impl<'tcx> TyCtxt<'tcx> {
/// Folds the escaping and free regions in `value` using `f`, and
/// sets `skipped_regions` to true if any late-bound region was found
/// and skipped.
/// Folds the escaping and free regions in `value` using `f`.
pub fn fold_regions<T>(
self,
value: T,
Expand All @@ -64,17 +62,6 @@ impl<'tcx> TyCtxt<'tcx> {
{
value.fold_with(&mut RegionFolder::new(self, &mut f))
}

pub fn super_fold_regions<T>(
self,
value: T,
mut f: impl FnMut(ty::Region<'tcx>, ty::DebruijnIndex) -> ty::Region<'tcx>,
) -> T
where
T: TypeSuperFoldable<TyCtxt<'tcx>>,
{
value.super_fold_with(&mut RegionFolder::new(self, &mut f))
}
}

/// Folds over the substructure of a type, visiting its component
Expand Down
42 changes: 26 additions & 16 deletions compiler/rustc_ty_utils/src/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ use rustc_middle::ty::{
TyCtxt, TypeSuperVisitable, TypeVisitable, TypeVisitor,
};
use rustc_session::config::TraitSolver;
use rustc_span::def_id::{DefId, CRATE_DEF_ID};
use rustc_span::{
def_id::{DefId, CRATE_DEF_ID},
DUMMY_SP,
};
use rustc_trait_selection::traits;

fn sized_constraint_for_ty<'tcx>(
Expand Down Expand Up @@ -275,16 +278,22 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ImplTraitInTraitFinder<'_, 'tcx> {
}

fn visit_ty(&mut self, ty: Ty<'tcx>) -> std::ops::ControlFlow<Self::BreakTy> {
if let ty::Alias(ty::Projection, alias_ty) = *ty.kind()
&& self.tcx.is_impl_trait_in_trait(alias_ty.def_id)
&& self.tcx.impl_trait_in_trait_parent_fn(alias_ty.def_id) == self.fn_def_id
&& self.seen.insert(alias_ty.def_id)
if let ty::Alias(ty::Projection, unshifted_alias_ty) = *ty.kind()
&& self.tcx.is_impl_trait_in_trait(unshifted_alias_ty.def_id)
&& self.tcx.impl_trait_in_trait_parent_fn(unshifted_alias_ty.def_id) == self.fn_def_id
&& self.seen.insert(unshifted_alias_ty.def_id)
{
// We have entered some binders as we've walked into the
// bounds of the RPITIT. Shift these binders back out when
// constructing the top-level projection predicate.
let alias_ty = self.tcx.fold_regions(alias_ty, |re, _| {
let shifted_alias_ty = self.tcx.fold_regions(unshifted_alias_ty, |re, depth| {
if let ty::ReLateBound(index, bv) = re.kind() {
if depth != ty::INNERMOST {
return self.tcx.mk_re_error_with_message(
DUMMY_SP,
"we shouldn't walk non-predicate binders with `impl Trait`...",
);
}
self.tcx.mk_re_late_bound(index.shifted_out_to_binder(self.depth), bv)
} else {
re
Expand All @@ -295,26 +304,27 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ImplTraitInTraitFinder<'_, 'tcx> {
// the `type_of` of the trait's associated item. If we're using the old lowering
// strategy, then just reinterpret the associated type like an opaque :^)
let default_ty = if self.tcx.lower_impl_trait_in_trait_to_assoc_ty() {
self
.tcx
.type_of(alias_ty.def_id)
.subst(self.tcx, alias_ty.substs)
self.tcx.type_of(shifted_alias_ty.def_id).subst(self.tcx, shifted_alias_ty.substs)
} else {
self.tcx.mk_alias(ty::Opaque, alias_ty)
self.tcx.mk_alias(ty::Opaque, shifted_alias_ty)
};

self.predicates.push(
ty::Binder::bind_with_vars(
ty::ProjectionPredicate {
projection_ty: alias_ty,
term: default_ty.into(),
},
ty::ProjectionPredicate { projection_ty: shifted_alias_ty, term: default_ty.into() },
self.bound_vars,
)
.to_predicate(self.tcx),
);

for bound in self.tcx.item_bounds(alias_ty.def_id).subst_iter(self.tcx, alias_ty.substs)
// We walk the *un-shifted* alias ty, because we're tracking the de bruijn
// binder depth, and if we were to walk `shifted_alias_ty` instead, we'd
// have to reset `self.depth` back to `ty::INNERMOST` or something. It's
// easier to just do this.
for bound in self
.tcx
.item_bounds(unshifted_alias_ty.def_id)
.subst_iter(self.tcx, unshifted_alias_ty.substs)
{
bound.visit_with(self);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ trait Trait {
fn method(&self) -> impl Trait<Type = impl Sized + '_>;
}

trait Trait2 {
type Type;

fn method(&self) -> impl Trait2<Type = impl Trait2<Type = impl Sized + '_> + '_>;
}

fn main() {}