Skip to content

Rollup of 9 pull requests #79122

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

Closed
wants to merge 36 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6e88e96
Support repr(simd) on ADTs containing a single array field
gnzlbg Jul 13, 2019
9bb4202
update ui tests
KodrAus Nov 8, 2020
899d9b9
Fix test checking that into_boxed_slice does not panic
tmiasko Nov 12, 2020
28463aa
Ensure that closure call is not removed by MIR optimizations in a test
tmiasko Nov 12, 2020
d54ea4f
Fix codegen test for issue 37945
tmiasko Nov 12, 2020
540b5db
remove const_generics from codegen tests
KodrAus Nov 13, 2020
045105b
remove internal simd_size_and_ty from llvm backend
KodrAus Nov 13, 2020
74f2941
tweak new codegen test to work on local
KodrAus Nov 14, 2020
e0f3119
Introduce `TypeVisitor::BreakTy`
LeSeulArtichaut Nov 5, 2020
17b395d
Use `TypeVisitor::BreakTy` in `structural_match::Search`
LeSeulArtichaut Nov 5, 2020
23feec3
Use `TypeVisitor::BreakTy` in `ProhibitOpaqueVisitor`
LeSeulArtichaut Nov 5, 2020
29b140a
Use `TypeVisitor::BreakTy` in `HasTypeFlagsVisitor`
LeSeulArtichaut Nov 5, 2020
44f7d8f
Use `TypeVisitor::BreakTy` in `HasEscapingVarsVisitor`
LeSeulArtichaut Nov 5, 2020
df6e87c
Use `TypeVisitor::BreakTy` in `UnresolvedTypeFinder`
LeSeulArtichaut Nov 6, 2020
65cdc21
Set the default `BreakTy` to `!`
LeSeulArtichaut Nov 14, 2020
07b37cf
Use `TypeVisitor::BreakTy` in `ProhibitOpaqueTypes`
LeSeulArtichaut Nov 14, 2020
7565809
add a canary test for complex repr(simd)
KodrAus Nov 14, 2020
f27d56d
Limit storage duration of inlined always live locals
tmiasko Nov 15, 2020
e217fc4
fix up tidy
KodrAus Nov 15, 2020
43bfbb1
Add column number support to Backtrace
est31 Nov 12, 2020
f6e6a15
Remove dead `TypeFoldable::visit_tys_shallow` method
LeSeulArtichaut Nov 15, 2020
1861a38
Ensure that the source code display is working with DOS backline
GuillaumeGomez Oct 14, 2020
af869c2
document that __rust_alloc is also magic to our LLVM fork
RalfJung Nov 15, 2020
0c52044
Add test to ensure that no DOS backline (\r\n) doesn't create extra b…
GuillaumeGomez Nov 15, 2020
7986bb8
Don't warn about invalid HTML tags in code blocks
GuillaumeGomez Nov 16, 2020
bbd302b
Add test to ensure that "invalid HTML tag" lint isn't fired in code b…
GuillaumeGomez Nov 16, 2020
a78966d
clarify `span_label` documentation
euclio Nov 16, 2020
0ad71f3
Rollup merge of #77939 - GuillaumeGomez:fix-source-code-dos-backline,…
Dylan-DPC Nov 17, 2020
975b50d
Rollup merge of #78779 - LeSeulArtichaut:ty-visitor-return, r=oli-obk
Dylan-DPC Nov 17, 2020
80c3b55
Rollup merge of #78863 - KodrAus:feat/simd-array, r=oli-obk
Dylan-DPC Nov 17, 2020
5a6cbaf
Rollup merge of #78967 - tmiasko:codegen-tests, r=cuviper
Dylan-DPC Nov 17, 2020
d037be3
Rollup merge of #79002 - est31:backtrace_colno, r=dtolnay
Dylan-DPC Nov 17, 2020
77dc14a
Rollup merge of #79027 - tmiasko:inline-always-live-locals, r=oli-obk
Dylan-DPC Nov 17, 2020
7c50422
Rollup merge of #79077 - RalfJung:llvm-magic, r=Mark-Simulacrum
Dylan-DPC Nov 17, 2020
f25688b
Rollup merge of #79088 - euclio:span-label-doc, r=estebank
Dylan-DPC Nov 17, 2020
da0319b
Rollup merge of #79097 - GuillaumeGomez:code-block-invalid-html-tag-l…
Dylan-DPC Nov 17, 2020
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
Use TypeVisitor::BreakTy in structural_match::Search
  • Loading branch information
LeSeulArtichaut committed Nov 14, 2020
commit 17b395d29609e9a52aeddec658ae6d57f62260cc
51 changes: 15 additions & 36 deletions compiler/rustc_trait_selection/src/traits/structural_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ pub fn search_for_structural_match_violation<'tcx>(
) -> Option<NonStructuralMatchTy<'tcx>> {
// FIXME: we should instead pass in an `infcx` from the outside.
tcx.infer_ctxt().enter(|infcx| {
let mut search = Search { infcx, span, found: None, seen: FxHashSet::default() };
ty.visit_with(&mut search);
search.found
ty.visit_with(&mut Search { infcx, span, seen: FxHashSet::default() }).break_value()
})
}

Expand Down Expand Up @@ -116,9 +114,6 @@ struct Search<'a, 'tcx> {

infcx: InferCtxt<'a, 'tcx>,

/// Records first ADT that does not implement a structural-match trait.
found: Option<NonStructuralMatchTy<'tcx>>,

/// Tracks ADTs previously encountered during search, so that
/// we will not recur on them again.
seen: FxHashSet<hir::def_id::DefId>,
Expand All @@ -135,38 +130,33 @@ impl Search<'a, 'tcx> {
}

impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
type BreakTy = NonStructuralMatchTy<'tcx>;

fn visit_ty(&mut self, ty: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
debug!("Search visiting ty: {:?}", ty);

let (adt_def, substs) = match *ty.kind() {
ty::Adt(adt_def, substs) => (adt_def, substs),
ty::Param(_) => {
self.found = Some(NonStructuralMatchTy::Param);
return ControlFlow::BREAK;
return ControlFlow::Break(NonStructuralMatchTy::Param);
}
ty::Dynamic(..) => {
self.found = Some(NonStructuralMatchTy::Dynamic);
return ControlFlow::BREAK;
return ControlFlow::Break(NonStructuralMatchTy::Dynamic);
}
ty::Foreign(_) => {
self.found = Some(NonStructuralMatchTy::Foreign);
return ControlFlow::BREAK;
return ControlFlow::Break(NonStructuralMatchTy::Foreign);
}
ty::Opaque(..) => {
self.found = Some(NonStructuralMatchTy::Opaque);
return ControlFlow::BREAK;
return ControlFlow::Break(NonStructuralMatchTy::Opaque);
}
ty::Projection(..) => {
self.found = Some(NonStructuralMatchTy::Projection);
return ControlFlow::BREAK;
return ControlFlow::Break(NonStructuralMatchTy::Projection);
}
ty::Generator(..) | ty::GeneratorWitness(..) => {
self.found = Some(NonStructuralMatchTy::Generator);
return ControlFlow::BREAK;
return ControlFlow::Break(NonStructuralMatchTy::Generator);
}
ty::Closure(..) => {
self.found = Some(NonStructuralMatchTy::Closure);
return ControlFlow::BREAK;
return ControlFlow::Break(NonStructuralMatchTy::Closure);
}
ty::RawPtr(..) => {
// structural-match ignores substructure of
Expand Down Expand Up @@ -206,8 +196,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {

ty::Array(..) | ty::Slice(_) | ty::Ref(..) | ty::Tuple(..) => {
// First check all contained types and then tell the caller to continue searching.
ty.super_visit_with(self);
return ControlFlow::CONTINUE;
return ty.super_visit_with(self);
}
ty::Infer(_) | ty::Placeholder(_) | ty::Bound(..) => {
bug!("unexpected type during structural-match checking: {:?}", ty);
Expand All @@ -227,8 +216,7 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {

if !self.type_marked_structural(ty) {
debug!("Search found ty: {:?}", ty);
self.found = Some(NonStructuralMatchTy::Adt(&adt_def));
return ControlFlow::BREAK;
return ControlFlow::Break(NonStructuralMatchTy::Adt(&adt_def));
}

// structural-match does not care about the
Expand All @@ -244,20 +232,11 @@ impl<'a, 'tcx> TypeVisitor<'tcx> for Search<'a, 'tcx> {
// even though we skip super_visit_with, we must recur on
// fields of ADT.
let tcx = self.tcx();
for field_ty in adt_def.all_fields().map(|field| field.ty(tcx, substs)) {
adt_def.all_fields().map(|field| field.ty(tcx, substs)).try_for_each(|field_ty| {
let ty = self.tcx().normalize_erasing_regions(ty::ParamEnv::empty(), field_ty);
debug!("structural-match ADT: field_ty={:?}, ty={:?}", field_ty, ty);

if ty.visit_with(self).is_break() {
// found an ADT without structural-match; halt visiting!
assert!(self.found.is_some());
return ControlFlow::BREAK;
}
}

// Even though we do not want to recur on substs, we do
// want our caller to continue its own search.
ControlFlow::CONTINUE
ty.visit_with(self)
})
}
}

Expand Down