Auto merge of #122190 - matthiaskrgr:rollup-9ol4y30, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #121025 (add known-bug tests for derive failure to detect packed repr) - #121194 (Refactor pre-getopts command line argument handling) - #121563 (Use `ControlFlow` in visitors.) - #122173 (Don't ICE in CTFE if raw/fn-ptr types differ) - #122175 (Bless tidy issues order) - #122179 (rustc: Fix typo) - #122181 (Fix crash in internal late lint checking) - #122183 (interpret: update comment about read_discriminant on uninhabited variants) Failed merges: - #122076 (Tweak the way we protect in-place function arguments in interpreters) - #122132 (Diagnostic renaming 3) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
commit
a655e648a9
76 changed files with 823 additions and 459 deletions
|
@ -1,5 +1,6 @@
|
|||
use super::potentially_plural_count;
|
||||
use crate::errors::{LifetimesOrBoundsMismatchOnTrait, MethodShouldReturnFuture};
|
||||
use core::ops::ControlFlow;
|
||||
use hir::def_id::{DefId, DefIdMap, LocalDefId};
|
||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
||||
use rustc_errors::{codes::*, pluralize, struct_span_code_err, Applicability, ErrorGuaranteed};
|
||||
|
@ -1565,24 +1566,24 @@ fn compare_synthetic_generics<'tcx>(
|
|||
let (sig, _) = impl_m.expect_fn();
|
||||
let input_tys = sig.decl.inputs;
|
||||
|
||||
struct Visitor(Option<Span>, hir::def_id::LocalDefId);
|
||||
struct Visitor(hir::def_id::LocalDefId);
|
||||
impl<'v> intravisit::Visitor<'v> for Visitor {
|
||||
fn visit_ty(&mut self, ty: &'v hir::Ty<'v>) {
|
||||
intravisit::walk_ty(self, ty);
|
||||
type Result = ControlFlow<Span>;
|
||||
fn visit_ty(&mut self, ty: &'v hir::Ty<'v>) -> Self::Result {
|
||||
if let hir::TyKind::Path(hir::QPath::Resolved(None, path)) = ty.kind
|
||||
&& let Res::Def(DefKind::TyParam, def_id) = path.res
|
||||
&& def_id == self.1.to_def_id()
|
||||
&& def_id == self.0.to_def_id()
|
||||
{
|
||||
self.0 = Some(ty.span);
|
||||
ControlFlow::Break(ty.span)
|
||||
} else {
|
||||
intravisit::walk_ty(self, ty)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut visitor = Visitor(None, impl_def_id);
|
||||
for ty in input_tys {
|
||||
intravisit::Visitor::visit_ty(&mut visitor, ty);
|
||||
}
|
||||
let span = visitor.0?;
|
||||
let span = input_tys.iter().find_map(|ty| {
|
||||
intravisit::Visitor::visit_ty(&mut Visitor(impl_def_id), ty).break_value()
|
||||
})?;
|
||||
|
||||
let bounds = impl_m.generics.bounds_for_param(impl_def_id).next()?.bounds;
|
||||
let bounds = bounds.first()?.span().to(bounds.last()?.span());
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
//! the types in HIR to identify late-bound lifetimes and assign their Debruijn indices. This file
|
||||
//! is also responsible for assigning their semantics to implicit lifetimes in trait objects.
|
||||
|
||||
use core::ops::ControlFlow;
|
||||
use rustc_ast::visit::walk_list;
|
||||
use rustc_data_structures::fx::{FxHashSet, FxIndexMap, FxIndexSet};
|
||||
use rustc_errors::{codes::*, struct_span_code_err};
|
||||
|
@ -417,23 +418,18 @@ impl<'a, 'tcx> Visitor<'tcx> for BoundVarContext<'a, 'tcx> {
|
|||
{
|
||||
if let &hir::ClosureBinder::For { span: for_sp, .. } = binder {
|
||||
fn span_of_infer(ty: &hir::Ty<'_>) -> Option<Span> {
|
||||
struct V(Option<Span>);
|
||||
|
||||
struct V;
|
||||
impl<'v> Visitor<'v> for V {
|
||||
fn visit_ty(&mut self, t: &'v hir::Ty<'v>) {
|
||||
match t.kind {
|
||||
_ if self.0.is_some() => (),
|
||||
hir::TyKind::Infer => {
|
||||
self.0 = Some(t.span);
|
||||
}
|
||||
_ => intravisit::walk_ty(self, t),
|
||||
type Result = ControlFlow<Span>;
|
||||
fn visit_ty(&mut self, t: &'v hir::Ty<'v>) -> Self::Result {
|
||||
if matches!(t.kind, hir::TyKind::Infer) {
|
||||
ControlFlow::Break(t.span)
|
||||
} else {
|
||||
intravisit::walk_ty(self, t)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut v = V(None);
|
||||
v.visit_ty(ty);
|
||||
v.0
|
||||
V.visit_ty(ty).break_value()
|
||||
}
|
||||
|
||||
let infer_in_rt_sp = match fn_decl.output {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
use core::ops::ControlFlow;
|
||||
use rustc_errors::{Applicability, StashKey};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{DefId, LocalDefId};
|
||||
|
@ -675,19 +676,16 @@ pub fn type_alias_is_lazy<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> bool {
|
|||
if tcx.features().lazy_type_alias {
|
||||
return true;
|
||||
}
|
||||
struct HasTait {
|
||||
has_type_alias_impl_trait: bool,
|
||||
}
|
||||
struct HasTait;
|
||||
impl<'tcx> Visitor<'tcx> for HasTait {
|
||||
fn visit_ty(&mut self, t: &'tcx hir::Ty<'tcx>) {
|
||||
type Result = ControlFlow<()>;
|
||||
fn visit_ty(&mut self, t: &'tcx hir::Ty<'tcx>) -> Self::Result {
|
||||
if let hir::TyKind::OpaqueDef(..) = t.kind {
|
||||
self.has_type_alias_impl_trait = true;
|
||||
ControlFlow::Break(())
|
||||
} else {
|
||||
hir::intravisit::walk_ty(self, t);
|
||||
hir::intravisit::walk_ty(self, t)
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut has_tait = HasTait { has_type_alias_impl_trait: false };
|
||||
has_tait.visit_ty(tcx.hir().expect_item(def_id).expect_ty_alias().0);
|
||||
has_tait.has_type_alias_impl_trait
|
||||
HasTait.visit_ty(tcx.hir().expect_item(def_id).expect_ty_alias().0).is_break()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue