mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
tut tut tut
This commit is contained in:
parent
de1026a67b
commit
f697955c1e
@ -1272,9 +1272,7 @@ pub fn parse_macro_name_and_helper_attrs(
|
|||||||
// Once we've located the `#[proc_macro_derive]` attribute, verify
|
// Once we've located the `#[proc_macro_derive]` attribute, verify
|
||||||
// that it's of the form `#[proc_macro_derive(Foo)]` or
|
// that it's of the form `#[proc_macro_derive(Foo)]` or
|
||||||
// `#[proc_macro_derive(Foo, attributes(A, ..))]`
|
// `#[proc_macro_derive(Foo, attributes(A, ..))]`
|
||||||
let Some(list) = attr.meta_item_list() else {
|
let list = attr.meta_item_list()?;
|
||||||
return None;
|
|
||||||
};
|
|
||||||
if list.len() != 1 && list.len() != 2 {
|
if list.len() != 1 && list.len() != 2 {
|
||||||
diag.span_err(attr.span, "attribute must have either one or two arguments");
|
diag.span_err(attr.span, "attribute must have either one or two arguments");
|
||||||
return None;
|
return None;
|
||||||
|
@ -1714,7 +1714,7 @@ impl<R: Idx, C: Idx> SparseBitMatrix<R, C> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn row(&self, row: R) -> Option<&HybridBitSet<C>> {
|
pub fn row(&self, row: R) -> Option<&HybridBitSet<C>> {
|
||||||
if let Some(Some(row)) = self.rows.get(row) { Some(row) } else { None }
|
self.rows.get(row)?.as_ref()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Intersects `row` with `set`. `set` can be either `BitSet` or
|
/// Intersects `row` with `set`. `set` can be either `BitSet` or
|
||||||
|
@ -25,21 +25,16 @@ pub(crate) fn find_anon_type<'tcx>(
|
|||||||
region: Region<'tcx>,
|
region: Region<'tcx>,
|
||||||
br: &ty::BoundRegionKind,
|
br: &ty::BoundRegionKind,
|
||||||
) -> Option<(&'tcx hir::Ty<'tcx>, &'tcx hir::FnSig<'tcx>)> {
|
) -> Option<(&'tcx hir::Ty<'tcx>, &'tcx hir::FnSig<'tcx>)> {
|
||||||
if let Some(anon_reg) = tcx.is_suitable_region(region) {
|
let anon_reg = tcx.is_suitable_region(region)?;
|
||||||
let hir_id = tcx.hir().local_def_id_to_hir_id(anon_reg.def_id);
|
let hir_id = tcx.hir().local_def_id_to_hir_id(anon_reg.def_id);
|
||||||
let Some(fn_sig) = tcx.hir().get(hir_id).fn_sig() else {
|
let fn_sig = tcx.hir().get(hir_id).fn_sig()?;
|
||||||
return None
|
|
||||||
};
|
|
||||||
|
|
||||||
fn_sig
|
fn_sig
|
||||||
.decl
|
.decl
|
||||||
.inputs
|
.inputs
|
||||||
.iter()
|
.iter()
|
||||||
.find_map(|arg| find_component_for_bound_region(tcx, arg, br))
|
.find_map(|arg| find_component_for_bound_region(tcx, arg, br))
|
||||||
.map(|ty| (ty, fn_sig))
|
.map(|ty| (ty, fn_sig))
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This method creates a FindNestedTypeVisitor which returns the type corresponding
|
// This method creates a FindNestedTypeVisitor which returns the type corresponding
|
||||||
|
@ -336,9 +336,7 @@ fn evaluate_candidate<'tcx>(
|
|||||||
Some(poss)
|
Some(poss)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let Some((_, child)) = targets.iter().next() else {
|
let (_, child) = targets.iter().next()?;
|
||||||
return None
|
|
||||||
};
|
|
||||||
let child_terminator = &bbs[child].terminator();
|
let child_terminator = &bbs[child].terminator();
|
||||||
let TerminatorKind::SwitchInt {
|
let TerminatorKind::SwitchInt {
|
||||||
switch_ty: child_ty,
|
switch_ty: child_ty,
|
||||||
|
@ -338,9 +338,7 @@ pub(super) fn check_for_substitution<'a>(
|
|||||||
ch: char,
|
ch: char,
|
||||||
err: &mut Diagnostic,
|
err: &mut Diagnostic,
|
||||||
) -> Option<token::TokenKind> {
|
) -> Option<token::TokenKind> {
|
||||||
let Some(&(_u_char, u_name, ascii_char)) = UNICODE_ARRAY.iter().find(|&&(c, _, _)| c == ch) else {
|
let &(_u_char, u_name, ascii_char) = UNICODE_ARRAY.iter().find(|&&(c, _, _)| c == ch)?;
|
||||||
return None;
|
|
||||||
};
|
|
||||||
|
|
||||||
let span = Span::with_root_ctxt(pos, pos + Pos::from_usize(ch.len_utf8()));
|
let span = Span::with_root_ctxt(pos, pos + Pos::from_usize(ch.len_utf8()));
|
||||||
|
|
||||||
|
@ -1183,9 +1183,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
|
|||||||
ident: Symbol,
|
ident: Symbol,
|
||||||
kind: &AssocItemKind,
|
kind: &AssocItemKind,
|
||||||
) -> Option<Symbol> {
|
) -> Option<Symbol> {
|
||||||
let Some((module, _)) = &self.current_trait_ref else {
|
let (module, _) = self.current_trait_ref.as_ref()?;
|
||||||
return None;
|
|
||||||
};
|
|
||||||
if ident == kw::Underscore {
|
if ident == kw::Underscore {
|
||||||
// We do nothing for `_`.
|
// We do nothing for `_`.
|
||||||
return None;
|
return None;
|
||||||
|
@ -757,7 +757,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||||||
formal_args: &[Ty<'tcx>],
|
formal_args: &[Ty<'tcx>],
|
||||||
) -> Option<Vec<Ty<'tcx>>> {
|
) -> Option<Vec<Ty<'tcx>>> {
|
||||||
let formal_ret = self.resolve_vars_with_obligations(formal_ret);
|
let formal_ret = self.resolve_vars_with_obligations(formal_ret);
|
||||||
let Some(ret_ty) = expected_ret.only_has_type(self) else { return None };
|
let ret_ty = expected_ret.only_has_type(self)?;
|
||||||
|
|
||||||
// HACK(oli-obk): This is a hack to keep RPIT and TAIT in sync wrt their behaviour.
|
// HACK(oli-obk): This is a hack to keep RPIT and TAIT in sync wrt their behaviour.
|
||||||
// Without it, the inference
|
// Without it, the inference
|
||||||
|
@ -1305,7 +1305,7 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
|
|||||||
fn maybe_expand_private_type_alias(cx: &mut DocContext<'_>, path: &hir::Path<'_>) -> Option<Type> {
|
fn maybe_expand_private_type_alias(cx: &mut DocContext<'_>, path: &hir::Path<'_>) -> Option<Type> {
|
||||||
let Res::Def(DefKind::TyAlias, def_id) = path.res else { return None };
|
let Res::Def(DefKind::TyAlias, def_id) = path.res else { return None };
|
||||||
// Substitute private type aliases
|
// Substitute private type aliases
|
||||||
let Some(def_id) = def_id.as_local() else { return None };
|
let def_id = def_id.as_local()?;
|
||||||
let alias = if !cx.cache.access_levels.is_exported(def_id.to_def_id()) {
|
let alias = if !cx.cache.access_levels.is_exported(def_id.to_def_id()) {
|
||||||
&cx.tcx.hir().expect_item(def_id).kind
|
&cx.tcx.hir().expect_item(def_id).kind
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user