Merge from rust-lang/rust
This commit is contained in:
commit
36e41b57e9
1273 changed files with 15902 additions and 10527 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit ce948f4616e3d4277e30c75c8bb01e094910df39
|
||||
Subproject commit 1d1d646c06a84c1aa53967b394b7f1218f85db82
|
||||
|
|
@ -362,7 +362,7 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
|
|||
}
|
||||
} else if let ItemKind::ForeignMod { .. } = item.kind {
|
||||
continue;
|
||||
} else if let ItemKind::GlobalAsm(_) = item.kind {
|
||||
} else if let ItemKind::GlobalAsm { .. } = item.kind {
|
||||
continue;
|
||||
} else if let ItemKind::Use(path, use_kind) = item.kind {
|
||||
if path.segments.is_empty() {
|
||||
|
|
@ -467,7 +467,7 @@ fn convert_module_item_kind(value: &ItemKind<'_>) -> SourceItemOrderingModuleIte
|
|||
ItemKind::Macro(..) => Macro,
|
||||
ItemKind::Mod(..) => Mod,
|
||||
ItemKind::ForeignMod { .. } => ForeignMod,
|
||||
ItemKind::GlobalAsm(..) => GlobalAsm,
|
||||
ItemKind::GlobalAsm { .. } => GlobalAsm,
|
||||
ItemKind::TyAlias(..) => TyAlias,
|
||||
ItemKind::Enum(..) => Enum,
|
||||
ItemKind::Struct(..) => Struct,
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ impl<'tcx> LateLintPass<'tcx> for AssigningClones {
|
|||
&& !cx.tcx.is_builtin_derived(resolved_impl)
|
||||
// Don't suggest calling a function we're implementing.
|
||||
&& resolved_impl.as_local().is_none_or(|block_id| {
|
||||
cx.tcx.hir().parent_owner_iter(e.hir_id).all(|(id, _)| id.def_id != block_id)
|
||||
cx.tcx.hir_parent_owner_iter(e.hir_id).all(|(id, _)| id.def_id != block_id)
|
||||
})
|
||||
&& let resolved_assoc_items = cx.tcx.associated_items(resolved_impl)
|
||||
// Only suggest if `clone_from`/`clone_into` is explicitly implemented
|
||||
|
|
|
|||
|
|
@ -52,11 +52,10 @@ declare_lint_pass!(DefaultNumericFallback => [DEFAULT_NUMERIC_FALLBACK]);
|
|||
|
||||
impl<'tcx> LateLintPass<'tcx> for DefaultNumericFallback {
|
||||
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &Body<'tcx>) {
|
||||
let hir = cx.tcx.hir();
|
||||
// NOTE: this is different from `clippy_utils::is_inside_always_const_context`.
|
||||
// Inline const supports type inference.
|
||||
let is_parent_const = matches!(
|
||||
hir.body_const_context(hir.body_owner_def_id(body.id())),
|
||||
cx.tcx.hir_body_const_context(cx.tcx.hir_body_owner_def_id(body.id())),
|
||||
Some(ConstContext::Const { inline: false } | ConstContext::Static(_))
|
||||
);
|
||||
let mut visitor = NumericFallbackVisitor::new(cx, is_parent_const);
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@ pub fn check(
|
|||
if !check_private_items
|
||||
&& cx
|
||||
.tcx
|
||||
.hir()
|
||||
.parent_iter(owner_id.into())
|
||||
.hir_parent_iter(owner_id.into())
|
||||
.any(|(id, _node)| is_doc_hidden(cx.tcx.hir().attrs(id)))
|
||||
{
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1057,7 +1057,7 @@ impl<'tcx> Visitor<'tcx> for FindPanicUnwrap<'_, 'tcx> {
|
|||
"assert" | "assert_eq" | "assert_ne"
|
||||
)
|
||||
{
|
||||
self.is_const = self.cx.tcx.hir().is_inside_const_context(expr.hir_id);
|
||||
self.is_const = self.cx.tcx.hir_is_inside_const_context(expr.hir_id);
|
||||
self.panic_span = Some(macro_call.span);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ impl<'tcx> LateLintPass<'tcx> for UnportableVariant {
|
|||
if let ItemKind::Enum(def, _) = &item.kind {
|
||||
for var in def.variants {
|
||||
if let Some(anon_const) = &var.disr_expr {
|
||||
let def_id = cx.tcx.hir().body_owner_def_id(anon_const.body);
|
||||
let def_id = cx.tcx.hir_body_owner_def_id(anon_const.body);
|
||||
let mut ty = cx.tcx.type_of(def_id.to_def_id()).instantiate_identity();
|
||||
let constant = cx
|
||||
.tcx
|
||||
|
|
|
|||
|
|
@ -80,8 +80,7 @@ impl<'tcx> LateLintPass<'tcx> for BoxedLocal {
|
|||
|
||||
let parent_id = cx
|
||||
.tcx
|
||||
.hir()
|
||||
.get_parent_item(cx.tcx.local_def_id_to_hir_id(fn_def_id))
|
||||
.hir_get_parent_item(cx.tcx.local_def_id_to_hir_id(fn_def_id))
|
||||
.def_id;
|
||||
|
||||
let mut trait_self_ty = None;
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ impl<'tcx> LateLintPass<'tcx> for Exit {
|
|||
&& let ExprKind::Path(ref path) = path_expr.kind
|
||||
&& let Some(def_id) = cx.qpath_res(path, path_expr.hir_id).opt_def_id()
|
||||
&& cx.tcx.is_diagnostic_item(sym::process_exit, def_id)
|
||||
&& let parent = cx.tcx.hir().get_parent_item(e.hir_id)
|
||||
&& let parent = cx.tcx.hir_get_parent_item(e.hir_id)
|
||||
&& let OwnerNode::Item(Item{kind: ItemKind::Fn{ .. }, ..}) = cx.tcx.hir_owner_node(parent)
|
||||
// If the next item up is a function we check if it is an entry point
|
||||
// and only then emit a linter warning
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ fn report(cx: &LateContext<'_>, param: &GenericParam<'_>, generics: &Generics<'_
|
|||
|
||||
pub(super) fn check_fn<'tcx>(cx: &LateContext<'_>, kind: &'tcx FnKind<'_>, body: &'tcx Body<'_>, hir_id: HirId) {
|
||||
if let FnKind::ItemFn(_, generics, _) = kind
|
||||
&& cx.tcx.visibility(cx.tcx.hir().body_owner_def_id(body.id())).is_public()
|
||||
&& cx.tcx.visibility(cx.tcx.hir_body_owner_def_id(body.id())).is_public()
|
||||
&& !is_in_test(cx.tcx, hir_id)
|
||||
{
|
||||
for param in generics.params {
|
||||
|
|
@ -57,7 +57,7 @@ pub(super) fn check_impl_item(cx: &LateContext<'_>, impl_item: &ImplItem<'_>) {
|
|||
&& let hir::Impl { of_trait, .. } = *impl_
|
||||
&& of_trait.is_none()
|
||||
&& let body = cx.tcx.hir_body(body_id)
|
||||
&& cx.tcx.visibility(cx.tcx.hir().body_owner_def_id(body.id())).is_public()
|
||||
&& cx.tcx.visibility(cx.tcx.hir_body_owner_def_id(body.id())).is_public()
|
||||
&& !is_in_test(cx.tcx, impl_item.hir_id())
|
||||
{
|
||||
for param in impl_item.generics.params {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ pub(super) fn check_impl_item(cx: &LateContext<'_>, item: &ImplItem<'_>, ignored
|
|||
&& let Some(did) = trait_item_def_id_of_impl(items, item.owner_id)
|
||||
&& !is_from_ignored_trait(trait_ref, ignored_traits)
|
||||
{
|
||||
let mut param_idents_iter = cx.tcx.hir().body_param_names(body_id);
|
||||
let mut param_idents_iter = cx.tcx.hir_body_param_names(body_id);
|
||||
let mut default_param_idents_iter = cx.tcx.fn_arg_names(did).iter().copied();
|
||||
|
||||
let renames = RenamedFnArgs::new(&mut default_param_idents_iter, &mut param_idents_iter);
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ impl IndexingSlicing {
|
|||
impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
|
||||
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
if let ExprKind::Index(array, index, _) = &expr.kind
|
||||
&& (!self.suppress_restriction_lint_in_const || !cx.tcx.hir().is_inside_const_context(expr.hir_id))
|
||||
&& (!self.suppress_restriction_lint_in_const || !cx.tcx.hir_is_inside_const_context(expr.hir_id))
|
||||
&& let expr_ty = cx.typeck_results().expr_ty(array)
|
||||
&& let mut deref = deref_chain(cx, expr_ty)
|
||||
&& deref.any(|l| {
|
||||
|
|
@ -181,7 +181,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
|
|||
span_lint_and_then(cx, INDEXING_SLICING, expr.span, "slicing may panic", |diag| {
|
||||
diag.help(help_msg);
|
||||
|
||||
if cx.tcx.hir().is_inside_const_context(expr.hir_id) {
|
||||
if cx.tcx.hir_is_inside_const_context(expr.hir_id) {
|
||||
diag.note(note);
|
||||
}
|
||||
});
|
||||
|
|
@ -223,7 +223,7 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
|
|||
span_lint_and_then(cx, INDEXING_SLICING, expr.span, "indexing may panic", |diag| {
|
||||
diag.help("consider using `.get(n)` or `.get_mut(n)` instead");
|
||||
|
||||
if cx.tcx.hir().is_inside_const_context(expr.hir_id) {
|
||||
if cx.tcx.hir_is_inside_const_context(expr.hir_id) {
|
||||
diag.note(note);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -94,7 +94,6 @@ impl Finiteness {
|
|||
}
|
||||
|
||||
impl From<bool> for Finiteness {
|
||||
#[must_use]
|
||||
fn from(b: bool) -> Self {
|
||||
if b { Infinite } else { Finite }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackArrays {
|
|||
&& let ty::Array(element_type, cst) = cx.typeck_results().expr_ty(expr).kind()
|
||||
&& let Some(element_count) = cst.try_to_target_usize(cx.tcx)
|
||||
&& let Ok(element_size) = cx.layout_of(*element_type).map(|l| l.size.bytes())
|
||||
&& !cx.tcx.hir().parent_iter(expr.hir_id).any(|(_, node)| {
|
||||
&& !cx.tcx.hir_parent_iter(expr.hir_id).any(|(_, node)| {
|
||||
matches!(
|
||||
node,
|
||||
Node::Item(Item {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ pub(super) fn check<'tcx>(
|
|||
}
|
||||
|
||||
fn get_parent_fn_ret_ty<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'_>) -> Option<FnRetTy<'tcx>> {
|
||||
for (_, parent_node) in cx.tcx.hir().parent_iter(expr.hir_id) {
|
||||
for (_, parent_node) in cx.tcx.hir_parent_iter(expr.hir_id) {
|
||||
match parent_node {
|
||||
// Skip `Coroutine` closures, these are the body of `async fn`, not async closures.
|
||||
// This is because we still need to backtrack one parent node to get the `OpaqueDef` ty.
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ fn last_stmt_and_ret<'tcx>(
|
|||
}
|
||||
None
|
||||
}
|
||||
let mut parent_iter = cx.tcx.hir().parent_iter(expr.hir_id);
|
||||
let mut parent_iter = cx.tcx.hir_parent_iter(expr.hir_id);
|
||||
if let Some((node_hir, Node::Stmt(..))) = parent_iter.next()
|
||||
// This should be the loop
|
||||
// This should be the function body
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ pub(super) fn check<'tcx>(
|
|||
|
||||
// ensure that the indexed variable was declared before the loop, see #601
|
||||
if let Some(indexed_extent) = indexed_extent {
|
||||
let parent_def_id = cx.tcx.hir().get_parent_item(expr.hir_id);
|
||||
let parent_def_id = cx.tcx.hir_get_parent_item(expr.hir_id);
|
||||
let region_scope_tree = cx.tcx.region_scope_tree(parent_def_id);
|
||||
let pat_extent = region_scope_tree.var_scope(pat.hir_id.local_id).unwrap();
|
||||
if region_scope_tree.is_subscope_of(indexed_extent, pat_extent) {
|
||||
|
|
@ -256,7 +256,7 @@ impl<'tcx> VarVisitor<'_, 'tcx> {
|
|||
let res = self.cx.qpath_res(seqpath, seqexpr.hir_id);
|
||||
match res {
|
||||
Res::Local(hir_id) => {
|
||||
let parent_def_id = self.cx.tcx.hir().get_parent_item(expr.hir_id);
|
||||
let parent_def_id = self.cx.tcx.hir_get_parent_item(expr.hir_id);
|
||||
let extent = self
|
||||
.cx
|
||||
.tcx
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualFloatMethods {
|
|||
&& exprs.iter_mut().partition_in_place(|i| path_to_local(i).is_some()) == 2
|
||||
&& !expr.span.in_external_macro(cx.sess().source_map())
|
||||
&& (
|
||||
is_not_const(cx.tcx, cx.tcx.hir().enclosing_body_owner(expr.hir_id).into())
|
||||
is_not_const(cx.tcx, cx.tcx.hir_enclosing_body_owner(expr.hir_id).into())
|
||||
|| self.msrv.meets(msrvs::CONST_FLOAT_CLASSIFY)
|
||||
)
|
||||
&& let [first, second, const_1, const_2] = exprs
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ fn find_method_sugg_for_if_let<'tcx>(
|
|||
// type needs to be considered, not just the inner type of the branch being matched on.
|
||||
// Note the last expression in a block is dropped after all local bindings.
|
||||
let check_ty = if has_else
|
||||
|| (keyword == "if" && matches!(cx.tcx.hir().parent_iter(expr.hir_id).next(), Some((_, Node::Block(..)))))
|
||||
|| (keyword == "if" && matches!(cx.tcx.hir_parent_iter(expr.hir_id).next(), Some((_, Node::Block(..)))))
|
||||
{
|
||||
op_ty
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &'_ Expr<'_>, receiver: &Expr<'_
|
|||
|
||||
fn is_under_cfg(cx: &LateContext<'_>, id: HirId) -> bool {
|
||||
cx.tcx
|
||||
.hir()
|
||||
.parent_id_iter(id)
|
||||
.hir_parent_id_iter(id)
|
||||
.any(|id| cx.tcx.hir().attrs(id).iter().any(|attr| attr.has_name(sym::cfg)))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use rustc_span::sym;
|
|||
use super::ITER_NTH_ZERO;
|
||||
|
||||
pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr<'_>, arg: &hir::Expr<'_>) {
|
||||
if let OwnerNode::Item(item) = cx.tcx.hir_owner_node(cx.tcx.hir().get_parent_item(expr.hir_id))
|
||||
if let OwnerNode::Item(item) = cx.tcx.hir_owner_node(cx.tcx.hir_get_parent_item(expr.hir_id))
|
||||
&& let def_id = item.owner_id.to_def_id()
|
||||
&& is_trait_method(cx, expr, sym::Iterator)
|
||||
&& let Some(Constant::Int(0)) = ConstEvalCtxt::new(cx).eval(arg)
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ fn peel_ptr_cast<'tcx>(e: &'tcx Expr<'tcx>) -> &'tcx Expr<'tcx> {
|
|||
/// ^ given this `x` expression, returns the `foo(...)` expression
|
||||
fn peel_ptr_cast_ancestors<'tcx>(cx: &LateContext<'tcx>, e: &'tcx Expr<'tcx>) -> &'tcx Expr<'tcx> {
|
||||
let mut prev = e;
|
||||
for (_, node) in cx.tcx.hir().parent_iter(e.hir_id) {
|
||||
for (_, node) in cx.tcx.hir_parent_iter(e.hir_id) {
|
||||
if let Node::Expr(e) = node
|
||||
&& get_cast_target(e).is_some()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ pub(crate) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, arg: &Expr<'_>, name:
|
|||
};
|
||||
let mut prev_expr = e;
|
||||
|
||||
for (_, parent) in cx.tcx.hir().parent_iter(e.hir_id) {
|
||||
for (_, parent) in cx.tcx.hir_parent_iter(e.hir_id) {
|
||||
if let Node::Expr(e) = parent {
|
||||
match e.kind {
|
||||
ExprKind::Field(_, name)
|
||||
|
|
|
|||
|
|
@ -4671,7 +4671,7 @@ impl<'tcx> LateLintPass<'tcx> for Methods {
|
|||
return;
|
||||
}
|
||||
let name = impl_item.ident.name.as_str();
|
||||
let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id()).def_id;
|
||||
let parent = cx.tcx.hir_get_parent_item(impl_item.hir_id()).def_id;
|
||||
let item = cx.tcx.hir().expect_item(parent);
|
||||
let self_ty = cx.tcx.type_of(item.owner_id).instantiate_identity();
|
||||
|
||||
|
|
|
|||
|
|
@ -58,8 +58,7 @@ pub(super) fn check<'tcx>(
|
|||
unwrap_or_span: unwrap_arg.span,
|
||||
};
|
||||
|
||||
let map = cx.tcx.hir();
|
||||
let body = map.body_owned_by(map.enclosing_body_owner(expr.hir_id));
|
||||
let body = cx.tcx.hir_body_owned_by(cx.tcx.hir_enclosing_body_owner(expr.hir_id));
|
||||
|
||||
// Visit the body, and return if we've found a reference
|
||||
if reference_visitor.visit_body(body).is_break() {
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ pub(super) fn check<'tcx>(
|
|||
let in_sugg_method_implementation = {
|
||||
matches!(
|
||||
suggested_method_def_id.as_local(),
|
||||
Some(local_def_id) if local_def_id == cx.tcx.hir().get_parent_item(receiver.hir_id).def_id
|
||||
Some(local_def_id) if local_def_id == cx.tcx.hir_get_parent_item(receiver.hir_id).def_id
|
||||
)
|
||||
};
|
||||
if in_sugg_method_implementation {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ pub(super) fn check(
|
|||
};
|
||||
let manual = count == 2 && msrv.meets(msrvs::STR_SPLIT_ONCE);
|
||||
|
||||
match parse_iter_usage(cx, expr.span.ctxt(), cx.tcx.hir().parent_iter(expr.hir_id)) {
|
||||
match parse_iter_usage(cx, expr.span.ctxt(), cx.tcx.hir_parent_iter(expr.hir_id)) {
|
||||
Some(usage) if needless(usage.kind) => lint_needless(cx, method_name, expr, self_arg, pat_arg),
|
||||
Some(usage) if manual => check_manual_split_once(cx, method_name, expr, self_arg, pat_arg, &usage),
|
||||
None if manual => {
|
||||
|
|
@ -127,7 +127,7 @@ fn check_manual_split_once_indirect(
|
|||
pat_arg: &Expr<'_>,
|
||||
) -> Option<()> {
|
||||
let ctxt = expr.span.ctxt();
|
||||
let mut parents = cx.tcx.hir().parent_iter(expr.hir_id);
|
||||
let mut parents = cx.tcx.hir_parent_iter(expr.hir_id);
|
||||
if let (_, Node::LetStmt(local)) = parents.next()?
|
||||
&& let PatKind::Binding(BindingMode::MUT, iter_binding_id, _, None) = local.pat.kind
|
||||
&& let (iter_stmt_id, Node::Stmt(_)) = parents.next()?
|
||||
|
|
@ -220,7 +220,7 @@ fn indirect_usage<'tcx>(
|
|||
ControlFlow::Continue(Descend::from(path_to_binding.is_none()))
|
||||
});
|
||||
|
||||
let mut parents = cx.tcx.hir().parent_iter(path_to_binding?.hir_id);
|
||||
let mut parents = cx.tcx.hir_parent_iter(path_to_binding?.hir_id);
|
||||
let iter_usage = parse_iter_usage(cx, ctxt, &mut parents)?;
|
||||
|
||||
let (parent_id, _) = parents.find(|(_, node)| {
|
||||
|
|
|
|||
|
|
@ -494,7 +494,7 @@ fn get_input_traits_and_projections<'tcx>(
|
|||
|
||||
#[expect(clippy::too_many_lines)]
|
||||
fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<'a>) -> bool {
|
||||
for (_, node) in cx.tcx.hir().parent_iter(expr.hir_id) {
|
||||
for (_, node) in cx.tcx.hir_parent_iter(expr.hir_id) {
|
||||
match node {
|
||||
Node::Stmt(_) => return true,
|
||||
Node::Block(..) => {},
|
||||
|
|
|
|||
|
|
@ -121,9 +121,9 @@ impl Visitor<'_> for IdentVisitor<'_, '_> {
|
|||
// Check whether the node is part of a `use` statement. We don't want to emit a warning if the user
|
||||
// has no control over the type.
|
||||
let usenode = opt_as_use_node(node).or_else(|| {
|
||||
cx.tcx
|
||||
.hir()
|
||||
.parent_iter(hir_id)
|
||||
cx
|
||||
.tcx
|
||||
.hir_parent_iter(hir_id)
|
||||
.find_map(|(_, node)| opt_as_use_node(node))
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingConstForFn {
|
|||
|
||||
// Const fns are not allowed as methods in a trait.
|
||||
{
|
||||
let parent = cx.tcx.hir().get_parent_item(hir_id).def_id;
|
||||
let parent = cx.tcx.hir_get_parent_item(hir_id).def_id;
|
||||
if parent != CRATE_DEF_ID {
|
||||
if let hir::Node::Item(item) = cx.tcx.hir_node_by_def_id(parent) {
|
||||
if let hir::ItemKind::Trait(..) = &item.kind {
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ fn is_unreachable(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
|
|||
| sym::core_panic_2015_macro
|
||||
| sym::std_panic_2015_macro
|
||||
| sym::core_panic_2021_macro
|
||||
) && !cx.tcx.hir().is_inside_const_context(expr.hir_id))
|
||||
) && !cx.tcx.hir_is_inside_const_context(expr.hir_id))
|
||||
|| matches!(
|
||||
diag_name,
|
||||
sym::unimplemented_macro | sym::todo_macro | sym::unreachable_macro | sym::unreachable_2015_macro
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
|||
| hir::ItemKind::Union(..) => {},
|
||||
hir::ItemKind::ExternCrate(..)
|
||||
| hir::ItemKind::ForeignMod { .. }
|
||||
| hir::ItemKind::GlobalAsm(..)
|
||||
| hir::ItemKind::GlobalAsm { .. }
|
||||
| hir::ItemKind::Impl { .. }
|
||||
| hir::ItemKind::Use(..) => note_prev_span_then_ret!(self.prev_span, it.span),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
|
|||
| hir::ItemKind::Static(..)
|
||||
| hir::ItemKind::Struct(..)
|
||||
| hir::ItemKind::TraitAlias(..)
|
||||
| hir::ItemKind::GlobalAsm(..)
|
||||
| hir::ItemKind::GlobalAsm { .. }
|
||||
| hir::ItemKind::TyAlias(..)
|
||||
| hir::ItemKind::Union(..)
|
||||
| hir::ItemKind::ExternCrate(..)
|
||||
|
|
|
|||
|
|
@ -41,8 +41,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBorrowedRef {
|
|||
&& !ref_pat.span.from_expansion()
|
||||
&& cx
|
||||
.tcx
|
||||
.hir()
|
||||
.parent_iter(ref_pat.hir_id)
|
||||
.hir_parent_iter(ref_pat.hir_id)
|
||||
.map_while(|(_, parent)| if let Node::Pat(pat) = parent { Some(pat) } else { None })
|
||||
// Do not lint patterns that are part of an OR `|` pattern, the binding mode must match in all arms
|
||||
.all(|pat| !matches!(pat.kind, PatKind::Or(_)))
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBorrowsForGenericArgs<'tcx> {
|
|||
if self
|
||||
.possible_borrowers
|
||||
.last()
|
||||
.is_some_and(|&(local_def_id, _)| local_def_id == cx.tcx.hir().body_owner_def_id(body.id()))
|
||||
.is_some_and(|&(local_def_id, _)| local_def_id == cx.tcx.hir_body_owner_def_id(body.id()))
|
||||
{
|
||||
self.possible_borrowers.pop();
|
||||
}
|
||||
|
|
@ -359,7 +359,7 @@ fn referent_used_exactly_once<'tcx>(
|
|||
&& let StatementKind::Assign(box (_, Rvalue::Ref(_, _, place))) = statement.kind
|
||||
&& !place.is_indirect_first_projection()
|
||||
{
|
||||
let body_owner_local_def_id = cx.tcx.hir().enclosing_body_owner(reference.hir_id);
|
||||
let body_owner_local_def_id = cx.tcx.hir_enclosing_body_owner(reference.hir_id);
|
||||
if possible_borrowers
|
||||
.last()
|
||||
.is_none_or(|&(local_def_id, _)| local_def_id != body_owner_local_def_id)
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ fn check<'tcx>(
|
|||
|
||||
impl<'tcx> LateLintPass<'tcx> for NeedlessLateInit {
|
||||
fn check_local(&mut self, cx: &LateContext<'tcx>, local: &'tcx LetStmt<'tcx>) {
|
||||
let mut parents = cx.tcx.hir().parent_iter(local.hir_id);
|
||||
let mut parents = cx.tcx.hir_parent_iter(local.hir_id);
|
||||
if let LetStmt {
|
||||
init: None,
|
||||
pat:
|
||||
|
|
|
|||
|
|
@ -350,9 +350,8 @@ impl MutablyUsedVariablesCtxt<'_> {
|
|||
// The goal here is to find if the current scope is unsafe or not. It stops when it finds
|
||||
// a function or an unsafe block.
|
||||
fn is_in_unsafe_block(&self, item: HirId) -> bool {
|
||||
let hir = self.tcx.hir();
|
||||
for (parent, node) in hir.parent_iter(item) {
|
||||
if let Some(fn_sig) = hir.fn_sig_by_hir_id(parent) {
|
||||
for (parent, node) in self.tcx.hir_parent_iter(item) {
|
||||
if let Some(fn_sig) = self.tcx.hir_fn_sig_by_hir_id(parent) {
|
||||
return fn_sig.header.is_unsafe();
|
||||
} else if let Node::Block(block) = node {
|
||||
if matches!(block.rules, BlockCheckMode::UnsafeBlock(_)) {
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ impl<'tcx> LateLintPass<'tcx> for NewWithoutDefault {
|
|||
if sig.decl.inputs.is_empty()
|
||||
&& name == sym::new
|
||||
&& cx.effective_visibilities.is_reachable(impl_item.owner_id.def_id)
|
||||
&& let self_def_id = cx.tcx.hir().get_parent_item(id.into())
|
||||
&& let self_def_id = cx.tcx.hir_get_parent_item(id.into())
|
||||
&& let self_ty = cx.tcx.type_of(self_def_id).instantiate_identity()
|
||||
&& self_ty == return_ty(cx, id)
|
||||
&& let Some(default_trait_id) = cx.tcx.get_diagnostic_item(sym::Default)
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ impl NoEffect {
|
|||
stmt.span,
|
||||
"statement with no effect",
|
||||
|diag| {
|
||||
for parent in cx.tcx.hir().parent_iter(stmt.hir_id) {
|
||||
for parent in cx.tcx.hir_parent_iter(stmt.hir_id) {
|
||||
if let Node::Item(item) = parent.1
|
||||
&& let ItemKind::Fn { .. } = item.kind
|
||||
&& let Node::Block(block) = cx.tcx.parent_hir_node(stmt.hir_id)
|
||||
|
|
|
|||
|
|
@ -344,7 +344,7 @@ impl<'tcx> LateLintPass<'tcx> for NonCopyConst<'tcx> {
|
|||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx ImplItem<'_>) {
|
||||
if let ImplItemKind::Const(_, body_id) = &impl_item.kind {
|
||||
let item_def_id = cx.tcx.hir().get_parent_item(impl_item.hir_id()).def_id;
|
||||
let item_def_id = cx.tcx.hir_get_parent_item(impl_item.hir_id()).def_id;
|
||||
let item = cx.tcx.hir().expect_item(item_def_id);
|
||||
|
||||
match &item.kind {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ impl<'tcx> LateLintPass<'tcx> for NonZeroSuggestions {
|
|||
check_non_zero_conversion(cx, rhs, Applicability::MachineApplicable);
|
||||
} else {
|
||||
// Check if the parent expression is a binary operation
|
||||
let parent_is_binary = cx.tcx.hir().parent_iter(expr.hir_id).any(|(_, node)| {
|
||||
let parent_is_binary = cx.tcx.hir_parent_iter(expr.hir_id).any(|(_, node)| {
|
||||
matches!(node, rustc_hir::Node::Expr(parent_expr) if matches!(parent_expr.kind, ExprKind::Binary(..)))
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -349,10 +349,10 @@ impl<'tcx> LateLintPass<'tcx> for ArithmeticSideEffects {
|
|||
}
|
||||
|
||||
fn check_body(&mut self, cx: &LateContext<'_>, body: &hir::Body<'_>) {
|
||||
let body_owner = cx.tcx.hir().body_owner(body.id());
|
||||
let body_owner_def_id = cx.tcx.hir().body_owner_def_id(body.id());
|
||||
let body_owner = cx.tcx.hir_body_owner(body.id());
|
||||
let body_owner_def_id = cx.tcx.hir_body_owner_def_id(body.id());
|
||||
|
||||
let body_owner_kind = cx.tcx.hir().body_owner_kind(body_owner_def_id);
|
||||
let body_owner_kind = cx.tcx.hir_body_owner_kind(body_owner_def_id);
|
||||
if let hir::BodyOwnerKind::Const { .. } | hir::BodyOwnerKind::Static(_) = body_owner_kind {
|
||||
let body_span = cx.tcx.hir().span_with_body(body_owner);
|
||||
if let Some(span) = self.const_span
|
||||
|
|
@ -365,7 +365,7 @@ impl<'tcx> LateLintPass<'tcx> for ArithmeticSideEffects {
|
|||
}
|
||||
|
||||
fn check_body_post(&mut self, cx: &LateContext<'_>, body: &hir::Body<'_>) {
|
||||
let body_owner = cx.tcx.hir().body_owner(body.id());
|
||||
let body_owner = cx.tcx.hir_body_owner(body.id());
|
||||
let body_span = cx.tcx.hir().span(body_owner);
|
||||
if let Some(span) = self.const_span
|
||||
&& span.contains(body_span)
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ pub(super) fn check<'tcx>(
|
|||
let rty = cx.typeck_results().expr_ty(rhs);
|
||||
if let Some((_, lang_item)) = binop_traits(op.node)
|
||||
&& let Some(trait_id) = cx.tcx.lang_items().get(lang_item)
|
||||
&& let parent_fn = cx.tcx.hir().get_parent_item(e.hir_id).def_id
|
||||
&& let parent_fn = cx.tcx.hir_get_parent_item(e.hir_id).def_id
|
||||
&& trait_ref_of_method(cx, parent_fn).is_none_or(|t| t.path.res.def_id() != trait_id)
|
||||
&& implements_trait(cx, ty, trait_id, &[rty.into()])
|
||||
{
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ fn needs_parenthesis(cx: &LateContext<'_>, binary: &Expr<'_>, child: &Expr<'_>)
|
|||
// the parent HIR node is an expression, or if the parent HIR node
|
||||
// is a Block or Stmt, and the new left hand side would need
|
||||
// parenthesis be treated as a statement rather than an expression.
|
||||
if let Some((_, parent)) = cx.tcx.hir().parent_iter(binary.hir_id).next() {
|
||||
if let Some((_, parent)) = cx.tcx.hir_parent_iter(binary.hir_id).next() {
|
||||
match parent {
|
||||
Node::Expr(_) => return Parens::Needed,
|
||||
Node::Block(_) | Node::Stmt(_) => {
|
||||
|
|
@ -142,7 +142,7 @@ fn needs_parenthesis(cx: &LateContext<'_>, binary: &Expr<'_>, child: &Expr<'_>)
|
|||
// This would mean that the rustfix suggestion will appear at the start of a line, which causes
|
||||
// these expressions to be interpreted as statements if they do not have parenthesis.
|
||||
let mut prev_id = binary.hir_id;
|
||||
for (_, parent) in cx.tcx.hir().parent_iter(binary.hir_id) {
|
||||
for (_, parent) in cx.tcx.hir_parent_iter(binary.hir_id) {
|
||||
if let Node::Expr(expr) = parent
|
||||
&& let ExprKind::Binary(_, lhs, _) | ExprKind::Cast(lhs, _) | ExprKind::Unary(_, lhs) = expr.kind
|
||||
&& lhs.hir_id == prev_id
|
||||
|
|
|
|||
|
|
@ -68,10 +68,10 @@ impl Context {
|
|||
}
|
||||
|
||||
pub fn enter_body(&mut self, cx: &LateContext<'_>, body: &hir::Body<'_>) {
|
||||
let body_owner = cx.tcx.hir().body_owner(body.id());
|
||||
let body_owner_def_id = cx.tcx.hir().body_owner_def_id(body.id());
|
||||
let body_owner = cx.tcx.hir_body_owner(body.id());
|
||||
let body_owner_def_id = cx.tcx.hir_body_owner_def_id(body.id());
|
||||
|
||||
match cx.tcx.hir().body_owner_kind(body_owner_def_id) {
|
||||
match cx.tcx.hir_body_owner_kind(body_owner_def_id) {
|
||||
hir::BodyOwnerKind::Static(_) | hir::BodyOwnerKind::Const { .. } => {
|
||||
let body_span = cx.tcx.hir().span_with_body(body_owner);
|
||||
|
||||
|
|
@ -82,12 +82,12 @@ impl Context {
|
|||
}
|
||||
self.const_span = Some(body_span);
|
||||
},
|
||||
hir::BodyOwnerKind::Fn | hir::BodyOwnerKind::Closure => (),
|
||||
hir::BodyOwnerKind::Fn | hir::BodyOwnerKind::Closure | hir::BodyOwnerKind::GlobalAsm => (),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn body_post(&mut self, cx: &LateContext<'_>, body: &hir::Body<'_>) {
|
||||
let body_owner = cx.tcx.hir().body_owner(body.id());
|
||||
let body_owner = cx.tcx.hir_body_owner(body.id());
|
||||
let body_span = cx.tcx.hir().span_with_body(body_owner);
|
||||
|
||||
if let Some(span) = self.const_span {
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for PanicUnimplemented {
|
|||
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
if let Some(macro_call) = root_macro_call_first_node(cx, expr) {
|
||||
if is_panic(cx, macro_call.def_id) {
|
||||
if cx.tcx.hir().is_inside_const_context(expr.hir_id)
|
||||
if cx.tcx.hir_is_inside_const_context(expr.hir_id)
|
||||
|| self.allow_panic_in_tests && is_in_test(cx.tcx, expr.hir_id)
|
||||
{
|
||||
return;
|
||||
|
|
@ -139,7 +139,7 @@ impl<'tcx> LateLintPass<'tcx> for PanicUnimplemented {
|
|||
&& let Res::Def(DefKind::Fn, def_id) = expr_path.res
|
||||
&& match_def_path(cx, def_id, &paths::PANIC_ANY)
|
||||
{
|
||||
if cx.tcx.hir().is_inside_const_context(expr.hir_id)
|
||||
if cx.tcx.hir_is_inside_const_context(expr.hir_id)
|
||||
|| self.allow_panic_in_tests && is_in_test(cx.tcx, expr.hir_id)
|
||||
{
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -186,8 +186,7 @@ impl<'tcx> LateLintPass<'tcx> for Ptr {
|
|||
}
|
||||
|
||||
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &Body<'tcx>) {
|
||||
let hir = cx.tcx.hir();
|
||||
let mut parents = hir.parent_iter(body.value.hir_id);
|
||||
let mut parents = cx.tcx.hir_parent_iter(body.value.hir_id);
|
||||
let (item_id, sig, is_trait_item) = match parents.next() {
|
||||
Some((_, Node::Item(i))) => {
|
||||
if let ItemKind::Fn { sig, .. } = &i.kind {
|
||||
|
|
|
|||
|
|
@ -205,7 +205,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClone {
|
|||
let node = mir.source_scopes[scope]
|
||||
.local_data
|
||||
.as_ref()
|
||||
.assert_crate_local()
|
||||
.unwrap_crate_local()
|
||||
.lint_root;
|
||||
|
||||
if let Some(snip) = span.get_source_text(cx)
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantLocals {
|
|||
/// assert_static(closure);
|
||||
/// ```
|
||||
fn is_by_value_closure_capture(cx: &LateContext<'_>, redefinition: HirId, root_variable: HirId) -> bool {
|
||||
let closure_def_id = cx.tcx.hir().enclosing_body_owner(redefinition);
|
||||
let closure_def_id = cx.tcx.hir_enclosing_body_owner(redefinition);
|
||||
|
||||
cx.tcx.is_closure_like(closure_def_id.to_def_id())
|
||||
&& cx.tcx.closure_captures(closure_def_id).iter().any(|c| {
|
||||
|
|
@ -122,8 +122,7 @@ fn find_binding(pat: &Pat<'_>, name: Ident) -> Option<BindingMode> {
|
|||
|
||||
/// Check if a rebinding of a local changes the effect of assignments to the binding.
|
||||
fn affects_assignments(cx: &LateContext<'_>, mutability: Mutability, bind: HirId, rebind: HirId) -> bool {
|
||||
let hir = cx.tcx.hir();
|
||||
|
||||
// the binding is mutable and the rebinding is in a different scope than the original binding
|
||||
mutability == Mutability::Mut && hir.get_enclosing_scope(bind) != hir.get_enclosing_scope(rebind)
|
||||
mutability == Mutability::Mut
|
||||
&& cx.tcx.hir_get_enclosing_scope(bind) != cx.tcx.hir_get_enclosing_scope(rebind)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,8 +177,7 @@ declare_lint_pass!(Return => [LET_AND_RETURN, NEEDLESS_RETURN, NEEDLESS_RETURN_W
|
|||
/// because of the never-ness of `return` expressions
|
||||
fn stmt_needs_never_type(cx: &LateContext<'_>, stmt_hir_id: HirId) -> bool {
|
||||
cx.tcx
|
||||
.hir()
|
||||
.parent_iter(stmt_hir_id)
|
||||
.hir_parent_iter(stmt_hir_id)
|
||||
.find_map(|(_, node)| if let Node::Expr(expr) = node { Some(expr) } else { None })
|
||||
.is_some_and(|e| {
|
||||
cx.typeck_results()
|
||||
|
|
@ -203,7 +202,7 @@ impl<'tcx> LateLintPass<'tcx> for Return {
|
|||
&& is_res_lang_ctor(cx, path_res(cx, maybe_constr), ResultErr)
|
||||
|
||||
// Ensure this is not the final stmt, otherwise removing it would cause a compile error
|
||||
&& let OwnerNode::Item(item) = cx.tcx.hir_owner_node(cx.tcx.hir().get_parent_item(expr.hir_id))
|
||||
&& let OwnerNode::Item(item) = cx.tcx.hir_owner_node(cx.tcx.hir_get_parent_item(expr.hir_id))
|
||||
&& let ItemKind::Fn { body, .. } = item.kind
|
||||
&& let block = cx.tcx.hir_body(body).value
|
||||
&& let ExprKind::Block(block, _) = block.kind
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ impl<'tcx> LateLintPass<'tcx> for SelfNamedConstructors {
|
|||
_ => return,
|
||||
}
|
||||
|
||||
let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id()).def_id;
|
||||
let parent = cx.tcx.hir_get_parent_item(impl_item.hir_id()).def_id;
|
||||
let item = cx.tcx.hir().expect_item(parent);
|
||||
let self_ty = cx.tcx.type_of(item.owner_id).instantiate_identity();
|
||||
let ret_ty = return_ty(cx, impl_item.owner_id);
|
||||
|
|
|
|||
|
|
@ -149,17 +149,15 @@ impl<'tcx> LateLintPass<'tcx> for Shadow {
|
|||
}
|
||||
|
||||
fn check_body(&mut self, cx: &LateContext<'_>, body: &Body<'_>) {
|
||||
let hir = cx.tcx.hir();
|
||||
let owner_id = hir.body_owner_def_id(body.id());
|
||||
if !matches!(hir.body_owner_kind(owner_id), BodyOwnerKind::Closure) {
|
||||
let owner_id = cx.tcx.hir_body_owner_def_id(body.id());
|
||||
if !matches!(cx.tcx.hir_body_owner_kind(owner_id), BodyOwnerKind::Closure) {
|
||||
self.bindings.push((FxHashMap::default(), owner_id));
|
||||
}
|
||||
}
|
||||
|
||||
fn check_body_post(&mut self, cx: &LateContext<'_>, body: &Body<'_>) {
|
||||
let hir = cx.tcx.hir();
|
||||
if !matches!(
|
||||
hir.body_owner_kind(hir.body_owner_def_id(body.id())),
|
||||
cx.tcx.hir_body_owner_kind(cx.tcx.hir_body_owner_def_id(body.id())),
|
||||
BodyOwnerKind::Closure
|
||||
) {
|
||||
self.bindings.pop();
|
||||
|
|
@ -226,9 +224,9 @@ fn lint_shadow(cx: &LateContext<'_>, pat: &Pat<'_>, shadowed: HirId, span: Span)
|
|||
|
||||
/// Returns true if the expression is a simple transformation of a local binding such as `&x`
|
||||
fn is_self_shadow(cx: &LateContext<'_>, pat: &Pat<'_>, mut expr: &Expr<'_>, hir_id: HirId) -> bool {
|
||||
let hir = cx.tcx.hir();
|
||||
let is_direct_binding = hir
|
||||
.parent_iter(pat.hir_id)
|
||||
let is_direct_binding = cx
|
||||
.tcx
|
||||
.hir_parent_iter(pat.hir_id)
|
||||
.map_while(|(_id, node)| match node {
|
||||
Node::Pat(pat) => Some(pat),
|
||||
_ => None,
|
||||
|
|
@ -261,14 +259,14 @@ fn is_self_shadow(cx: &LateContext<'_>, pat: &Pat<'_>, mut expr: &Expr<'_>, hir_
|
|||
/// For closure arguments passed to a method call, returns the method call, and the `HirId` of the
|
||||
/// closure (which will later be skipped). This is for <https://github.com/rust-lang/rust-clippy/issues/10780>
|
||||
fn find_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<(&'tcx Expr<'tcx>, Option<HirId>)> {
|
||||
for (hir_id, node) in cx.tcx.hir().parent_iter(hir_id) {
|
||||
for (hir_id, node) in cx.tcx.hir_parent_iter(hir_id) {
|
||||
let init = match node {
|
||||
Node::Arm(_) | Node::Pat(_) | Node::PatField(_) | Node::Param(_) => continue,
|
||||
Node::Expr(expr) => match expr.kind {
|
||||
ExprKind::Match(e, _, _) | ExprKind::Let(&LetExpr { init: e, .. }) => Some((e, None)),
|
||||
// If we're a closure argument, then a parent call is also an associated item.
|
||||
ExprKind::Closure(_) => {
|
||||
if let Some((_, node)) = cx.tcx.hir().parent_iter(hir_id).next() {
|
||||
if let Some((_, node)) = cx.tcx.hir_parent_iter(hir_id).next() {
|
||||
match node {
|
||||
Node::Expr(expr) => match expr.kind {
|
||||
ExprKind::MethodCall(_, _, _, _) | ExprKind::Call(_, _) => Some((expr, Some(hir_id))),
|
||||
|
|
|
|||
|
|
@ -232,8 +232,7 @@ impl<'ap, 'lc, 'others, 'stmt, 'tcx> StmtsChecker<'ap, 'lc, 'others, 'stmt, 'tcx
|
|||
let block_is_ancestor = self
|
||||
.cx
|
||||
.tcx
|
||||
.hir()
|
||||
.parent_iter(self.ap.curr_block_hir_id)
|
||||
.hir_parent_iter(self.ap.curr_block_hir_id)
|
||||
.any(|(id, _)| id == apa.first_block_hir_id);
|
||||
if last_stmt_is_not_dummy && last_stmt_is_not_curr && (block_equals_curr || block_is_ancestor) {
|
||||
apa.has_expensive_expr_after_last_attr = true;
|
||||
|
|
|
|||
|
|
@ -90,8 +90,7 @@ impl SingleCallFn {
|
|||
|| fn_span.in_external_macro(cx.sess().source_map())
|
||||
|| cx
|
||||
.tcx
|
||||
.hir()
|
||||
.maybe_body_owned_by(fn_def_id)
|
||||
.hir_maybe_body_owned_by(fn_def_id)
|
||||
.is_none_or(|body| is_in_test_function(cx.tcx, body.value.hir_id))
|
||||
|| match cx.tcx.hir_node(fn_hir_id) {
|
||||
Node::Item(item) => is_from_proc_macro(cx, item),
|
||||
|
|
|
|||
|
|
@ -63,11 +63,11 @@ impl<'tcx> LateLintPass<'tcx> for SuspiciousImpl {
|
|||
|
||||
// Check for more than one binary operation in the implemented function
|
||||
// Linting when multiple operations are involved can result in false positives
|
||||
&& let parent_fn = cx.tcx.hir().get_parent_item(expr.hir_id).def_id
|
||||
&& let parent_fn = cx.tcx.hir_get_parent_item(expr.hir_id).def_id
|
||||
&& let hir::Node::ImplItem(impl_item) = cx.tcx.hir_node_by_def_id(parent_fn)
|
||||
&& let hir::ImplItemKind::Fn(_, body_id) = impl_item.kind
|
||||
&& let body = cx.tcx.hir_body(body_id)
|
||||
&& let parent_fn = cx.tcx.hir().get_parent_item(expr.hir_id).def_id
|
||||
&& let parent_fn = cx.tcx.hir_get_parent_item(expr.hir_id).def_id
|
||||
&& let Some(trait_ref) = trait_ref_of_method(cx, parent_fn)
|
||||
&& let trait_id = trait_ref.path.res.def_id()
|
||||
&& ![binop_trait_id, op_assign_trait_id].contains(&trait_id)
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use rustc_middle::ty::Ty;
|
|||
use super::EAGER_TRANSMUTE;
|
||||
|
||||
fn peel_parent_unsafe_blocks<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) -> Option<&'tcx Expr<'tcx>> {
|
||||
for (_, parent) in cx.tcx.hir().parent_iter(expr.hir_id) {
|
||||
for (_, parent) in cx.tcx.hir_parent_iter(expr.hir_id) {
|
||||
match parent {
|
||||
Node::Block(_) => {},
|
||||
Node::Expr(e) if let ExprKind::Block(..) = e.kind => {},
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use rustc_middle::ty::Ty;
|
|||
use crate::transmute::MISSING_TRANSMUTE_ANNOTATIONS;
|
||||
|
||||
fn get_parent_local_binding_ty<'tcx>(cx: &LateContext<'tcx>, expr_hir_id: HirId) -> Option<LetStmt<'tcx>> {
|
||||
let mut parent_iter = cx.tcx.hir().parent_iter(expr_hir_id);
|
||||
let mut parent_iter = cx.tcx.hir_parent_iter(expr_hir_id);
|
||||
if let Some((_, node)) = parent_iter.next() {
|
||||
match node {
|
||||
Node::LetStmt(local) => Some(*local),
|
||||
|
|
@ -28,8 +28,8 @@ fn get_parent_local_binding_ty<'tcx>(cx: &LateContext<'tcx>, expr_hir_id: HirId)
|
|||
}
|
||||
|
||||
fn is_function_block(cx: &LateContext<'_>, expr_hir_id: HirId) -> bool {
|
||||
let def_id = cx.tcx.hir().enclosing_body_owner(expr_hir_id);
|
||||
if let Some(body) = cx.tcx.hir().maybe_body_owned_by(def_id) {
|
||||
let def_id = cx.tcx.hir_enclosing_body_owner(expr_hir_id);
|
||||
if let Some(body) = cx.tcx.hir_maybe_body_owned_by(def_id) {
|
||||
return body.value.peel_blocks().hir_id == expr_hir_id;
|
||||
}
|
||||
false
|
||||
|
|
|
|||
|
|
@ -375,8 +375,7 @@ impl<'tcx> LateLintPass<'tcx> for Types {
|
|||
) {
|
||||
let is_in_trait_impl = if let hir::Node::Item(item) = cx.tcx.hir_node_by_def_id(
|
||||
cx.tcx
|
||||
.hir()
|
||||
.get_parent_item(cx.tcx.local_def_id_to_hir_id(def_id))
|
||||
.hir_get_parent_item(cx.tcx.local_def_id_to_hir_id(def_id))
|
||||
.def_id,
|
||||
) {
|
||||
matches!(item.kind, ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }))
|
||||
|
|
@ -420,7 +419,7 @@ impl<'tcx> LateLintPass<'tcx> for Types {
|
|||
ImplItemKind::Const(ty, _) => {
|
||||
let is_in_trait_impl = if let hir::Node::Item(item) = cx
|
||||
.tcx
|
||||
.hir_node_by_def_id(cx.tcx.hir().get_parent_item(item.hir_id()).def_id)
|
||||
.hir_node_by_def_id(cx.tcx.hir_get_parent_item(item.hir_id()).def_id)
|
||||
{
|
||||
matches!(item.kind, ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }))
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ fn get_impl_trait_def_id(cx: &LateContext<'_>, method_def_id: LocalDefId) -> Opt
|
|||
owner_id,
|
||||
..
|
||||
}),
|
||||
)) = cx.tcx.hir().parent_iter(hir_id).next()
|
||||
)) = cx.tcx.hir_parent_iter(hir_id).next()
|
||||
// We exclude `impl` blocks generated from rustc's proc macros.
|
||||
&& !cx.tcx.has_attr(*owner_id, sym::automatically_derived)
|
||||
// It is a implementation of a trait.
|
||||
|
|
@ -216,7 +216,7 @@ fn check_to_string(cx: &LateContext<'_>, method_span: Span, method_def_id: Local
|
|||
owner_id,
|
||||
..
|
||||
}),
|
||||
)) = cx.tcx.hir().parent_iter(hir_id).next()
|
||||
)) = cx.tcx.hir_parent_iter(hir_id).next()
|
||||
// We exclude `impl` blocks generated from rustc's proc macros.
|
||||
&& !cx.tcx.has_attr(*owner_id, sym::automatically_derived)
|
||||
// It is a implementation of a trait.
|
||||
|
|
@ -331,8 +331,8 @@ impl UnconditionalRecursion {
|
|||
&& let [return_expr] = get_return_calls_in_body(body).as_slice()
|
||||
&& let ExprKind::Call(call_expr, _) = return_expr.kind
|
||||
// We need to use typeck here to infer the actual function being called.
|
||||
&& let body_def_id = cx.tcx.hir().enclosing_body_owner(call_expr.hir_id)
|
||||
&& let Some(body_owner) = cx.tcx.hir().maybe_body_owned_by(body_def_id)
|
||||
&& let body_def_id = cx.tcx.hir_enclosing_body_owner(call_expr.hir_id)
|
||||
&& let Some(body_owner) = cx.tcx.hir_maybe_body_owned_by(body_def_id)
|
||||
&& let typeck = cx.tcx.typeck_body(body_owner.id())
|
||||
&& let Some(call_def_id) = typeck.type_dependent_def_id(call_expr.hir_id)
|
||||
{
|
||||
|
|
@ -367,7 +367,7 @@ impl UnconditionalRecursion {
|
|||
kind: ItemKind::Impl(impl_),
|
||||
..
|
||||
}),
|
||||
)) = cx.tcx.hir().parent_iter(hir_id).next()
|
||||
)) = cx.tcx.hir_parent_iter(hir_id).next()
|
||||
&& let Some(implemented_ty_id) = get_hir_ty_def_id(cx.tcx, *impl_.self_ty)
|
||||
&& {
|
||||
self.init_default_impl_for_type_if_needed(cx);
|
||||
|
|
|
|||
|
|
@ -291,7 +291,7 @@ fn expr_has_unnecessary_safety_comment<'tcx>(
|
|||
expr: &'tcx hir::Expr<'tcx>,
|
||||
comment_pos: BytePos,
|
||||
) -> Option<Span> {
|
||||
if cx.tcx.hir().parent_iter(expr.hir_id).any(|(_, ref node)| {
|
||||
if cx.tcx.hir_parent_iter(expr.hir_id).any(|(_, ref node)| {
|
||||
matches!(
|
||||
node,
|
||||
Node::Block(Block {
|
||||
|
|
@ -604,10 +604,9 @@ fn span_from_macro_expansion_has_safety_comment(cx: &LateContext<'_>, span: Span
|
|||
|
||||
fn get_body_search_span(cx: &LateContext<'_>) -> Option<Span> {
|
||||
let body = cx.enclosing_body?;
|
||||
let map = cx.tcx.hir();
|
||||
let mut span = cx.tcx.hir_body(body).value.span;
|
||||
let mut maybe_global_var = false;
|
||||
for (_, node) in map.parent_iter(body.hir_id) {
|
||||
for (_, node) in cx.tcx.hir_parent_iter(body.hir_id) {
|
||||
match node {
|
||||
Node::Expr(e) => span = e.span,
|
||||
Node::Block(_) | Node::Arm(_) | Node::Stmt(_) | Node::LetStmt(_) => (),
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ fn is_unreachable_or_panic(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool {
|
|||
return false;
|
||||
};
|
||||
if is_panic(cx, macro_call.def_id) {
|
||||
return !cx.tcx.hir().is_inside_const_context(expr.hir_id);
|
||||
return !cx.tcx.hir_is_inside_const_context(expr.hir_id);
|
||||
}
|
||||
matches!(cx.tcx.item_name(macro_call.def_id).as_str(), "unreachable")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ impl<'tcx> Visitor<'tcx> for PeekableVisitor<'_, 'tcx> {
|
|||
|
||||
fn visit_expr(&mut self, ex: &'tcx Expr<'tcx>) -> ControlFlow<()> {
|
||||
if path_to_local_id(ex, self.expected_hir_id) {
|
||||
for (_, node) in self.cx.tcx.hir().parent_iter(ex.hir_id) {
|
||||
for (_, node) in self.cx.tcx.hir_parent_iter(ex.hir_id) {
|
||||
match node {
|
||||
Node::Expr(expr) => {
|
||||
match expr.kind {
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ impl<'tcx> LateLintPass<'tcx> for UnusedSelf {
|
|||
if impl_item.span.from_expansion() {
|
||||
return;
|
||||
}
|
||||
let parent = cx.tcx.hir().get_parent_item(impl_item.hir_id()).def_id;
|
||||
let parent = cx.tcx.hir_get_parent_item(impl_item.hir_id()).def_id;
|
||||
let parent_item = cx.tcx.hir().expect_item(parent);
|
||||
let assoc_item = cx.tcx.associated_item(impl_item.owner_id);
|
||||
let contains_todo = |cx, body: &'_ Body<'_>| -> bool {
|
||||
|
|
|
|||
|
|
@ -132,8 +132,7 @@ impl<'tcx> LateLintPass<'tcx> for Author {
|
|||
}
|
||||
|
||||
fn check_item(cx: &LateContext<'_>, hir_id: HirId) {
|
||||
let hir = cx.tcx.hir();
|
||||
if let Some(body) = hir.maybe_body_owned_by(hir_id.expect_owner().def_id) {
|
||||
if let Some(body) = cx.tcx.hir_maybe_body_owned_by(hir_id.expect_owner().def_id) {
|
||||
check_node(cx, hir_id, |v| {
|
||||
v.expr(&v.bind("expr", body.value));
|
||||
});
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ impl<'tcx> LateLintPass<'tcx> for LintWithoutLintPass {
|
|||
output: &mut self.registered_lints,
|
||||
cx,
|
||||
};
|
||||
let body = cx.tcx.hir().body_owned_by(
|
||||
let body = cx.tcx.hir_body_owned_by(
|
||||
impl_item_refs
|
||||
.iter()
|
||||
.find(|iiref| iiref.ident.as_str() == "lint_vec")
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ impl LateLintPass<'_> for ZeroSizedMapValues {
|
|||
}
|
||||
|
||||
fn in_trait_impl(cx: &LateContext<'_>, hir_id: HirId) -> bool {
|
||||
let parent_id = cx.tcx.hir().get_parent_item(hir_id);
|
||||
let second_parent_id = cx.tcx.hir().get_parent_item(parent_id.into()).def_id;
|
||||
let parent_id = cx.tcx.hir_get_parent_item(hir_id);
|
||||
let second_parent_id = cx.tcx.hir_get_parent_item(parent_id.into()).def_id;
|
||||
if let Node::Item(item) = cx.tcx.hir_node_by_def_id(second_parent_id) {
|
||||
if let ItemKind::Impl(hir::Impl { of_trait: Some(_), .. }) = item.kind {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -351,21 +351,18 @@ pub enum FullInt {
|
|||
}
|
||||
|
||||
impl PartialEq for FullInt {
|
||||
#[must_use]
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.cmp(other) == Ordering::Equal
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialOrd for FullInt {
|
||||
#[must_use]
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl Ord for FullInt {
|
||||
#[must_use]
|
||||
fn cmp(&self, other: &Self) -> Ordering {
|
||||
use FullInt::{S, U};
|
||||
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ impl<'hir> IfLet<'hir> {
|
|||
if_else,
|
||||
) = expr.kind
|
||||
{
|
||||
let mut iter = cx.tcx.hir().parent_iter(expr.hir_id);
|
||||
let mut iter = cx.tcx.hir_parent_iter(expr.hir_id);
|
||||
if let Some((_, Node::Block(Block { stmts: [], .. }))) = iter.next() {
|
||||
if let Some((
|
||||
_,
|
||||
|
|
|
|||
|
|
@ -968,7 +968,10 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
|
|||
self.hash_expr(out_expr);
|
||||
}
|
||||
},
|
||||
InlineAsmOperand::Const { anon_const } | InlineAsmOperand::SymFn { anon_const } => {
|
||||
InlineAsmOperand::SymFn { expr } => {
|
||||
self.hash_expr(expr);
|
||||
}
|
||||
InlineAsmOperand::Const { anon_const } => {
|
||||
self.hash_body(anon_const.body);
|
||||
},
|
||||
InlineAsmOperand::SymStatic { path, def_id: _ } => self.hash_qpath(path),
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ pub fn find_binding_init<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<
|
|||
///
|
||||
/// e.g. returns true for `x` in `fn f(x: usize) { .. }` and `let x = 1;` but false for `let x;`
|
||||
pub fn local_is_initialized(cx: &LateContext<'_>, local: HirId) -> bool {
|
||||
for (_, node) in cx.tcx.hir().parent_iter(local) {
|
||||
for (_, node) in cx.tcx.hir_parent_iter(local) {
|
||||
match node {
|
||||
Node::Pat(..) | Node::PatField(..) => {},
|
||||
Node::LetStmt(let_stmt) => return let_stmt.init.is_some(),
|
||||
|
|
@ -227,7 +227,7 @@ pub fn local_is_initialized(cx: &LateContext<'_>, local: HirId) -> bool {
|
|||
///
|
||||
/// The current context is determined based on the current body which is set before calling a lint's
|
||||
/// entry point (any function on `LateLintPass`). If you need to check in a different context use
|
||||
/// `tcx.hir().is_inside_const_context(_)`.
|
||||
/// `tcx.hir_is_inside_const_context(_)`.
|
||||
///
|
||||
/// Do not call this unless the `LateContext` has an enclosing body. For release build this case
|
||||
/// will safely return `false`, but debug builds will ICE. Note that `check_expr`, `check_block`,
|
||||
|
|
@ -237,8 +237,7 @@ pub fn is_in_const_context(cx: &LateContext<'_>) -> bool {
|
|||
debug_assert!(cx.enclosing_body.is_some(), "`LateContext` has no enclosing body");
|
||||
cx.enclosing_body.is_some_and(|id| {
|
||||
cx.tcx
|
||||
.hir()
|
||||
.body_const_context(cx.tcx.hir().body_owner_def_id(id))
|
||||
.hir_body_const_context(cx.tcx.hir_body_owner_def_id(id))
|
||||
.is_some()
|
||||
})
|
||||
}
|
||||
|
|
@ -251,8 +250,7 @@ pub fn is_in_const_context(cx: &LateContext<'_>) -> bool {
|
|||
/// * associated constants
|
||||
pub fn is_inside_always_const_context(tcx: TyCtxt<'_>, hir_id: HirId) -> bool {
|
||||
use ConstContext::{Const, ConstFn, Static};
|
||||
let hir = tcx.hir();
|
||||
let Some(ctx) = hir.body_const_context(hir.enclosing_body_owner(hir_id)) else {
|
||||
let Some(ctx) = tcx.hir_body_const_context(tcx.hir_enclosing_body_owner(hir_id)) else {
|
||||
return false;
|
||||
};
|
||||
match ctx {
|
||||
|
|
@ -808,7 +806,7 @@ pub fn get_trait_def_id(tcx: TyCtxt<'_>, path: &[&str]) -> Option<DefId> {
|
|||
pub fn trait_ref_of_method<'tcx>(cx: &LateContext<'tcx>, def_id: LocalDefId) -> Option<&'tcx TraitRef<'tcx>> {
|
||||
// Get the implemented trait for the current function
|
||||
let hir_id = cx.tcx.local_def_id_to_hir_id(def_id);
|
||||
let parent_impl = cx.tcx.hir().get_parent_item(hir_id);
|
||||
let parent_impl = cx.tcx.hir_get_parent_item(hir_id);
|
||||
if parent_impl != hir::CRATE_OWNER_ID
|
||||
&& let Node::Item(item) = cx.tcx.hir_node_by_def_id(parent_impl.def_id)
|
||||
&& let ItemKind::Impl(impl_) = &item.kind
|
||||
|
|
@ -1119,7 +1117,7 @@ pub fn capture_local_usage(cx: &LateContext<'_>, e: &Expr<'_>) -> CaptureKind {
|
|||
let mut capture = CaptureKind::Value;
|
||||
let mut capture_expr_ty = e;
|
||||
|
||||
for (parent_id, parent) in cx.tcx.hir().parent_iter(e.hir_id) {
|
||||
for (parent_id, parent) in cx.tcx.hir_parent_iter(e.hir_id) {
|
||||
if let [
|
||||
Adjustment {
|
||||
kind: Adjust::Deref(_) | Adjust::Borrow(AutoBorrow::Ref(..)),
|
||||
|
|
@ -1338,13 +1336,13 @@ pub fn is_entrypoint_fn(cx: &LateContext<'_>, def_id: DefId) -> bool {
|
|||
|
||||
/// Returns `true` if the expression is in the program's `#[panic_handler]`.
|
||||
pub fn is_in_panic_handler(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
|
||||
let parent = cx.tcx.hir().get_parent_item(e.hir_id);
|
||||
let parent = cx.tcx.hir_get_parent_item(e.hir_id);
|
||||
Some(parent.to_def_id()) == cx.tcx.lang_items().panic_impl()
|
||||
}
|
||||
|
||||
/// Gets the name of the item the expression is in, if available.
|
||||
pub fn get_item_name(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<Symbol> {
|
||||
let parent_id = cx.tcx.hir().get_parent_item(expr.hir_id).def_id;
|
||||
let parent_id = cx.tcx.hir_get_parent_item(expr.hir_id).def_id;
|
||||
match cx.tcx.hir_node_by_def_id(parent_id) {
|
||||
Node::Item(Item { ident, .. })
|
||||
| Node::TraitItem(TraitItem { ident, .. })
|
||||
|
|
@ -1409,9 +1407,9 @@ pub fn get_parent_expr_for_hir<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> O
|
|||
|
||||
/// Gets the enclosing block, if any.
|
||||
pub fn get_enclosing_block<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId) -> Option<&'tcx Block<'tcx>> {
|
||||
let map = &cx.tcx.hir();
|
||||
let enclosing_node = map
|
||||
.get_enclosing_scope(hir_id)
|
||||
let enclosing_node = cx
|
||||
.tcx
|
||||
.hir_get_enclosing_scope(hir_id)
|
||||
.map(|enclosing_id| cx.tcx.hir_node(enclosing_id));
|
||||
enclosing_node.and_then(|node| match node {
|
||||
Node::Block(block) => Some(block),
|
||||
|
|
@ -1435,7 +1433,7 @@ pub fn get_enclosing_loop_or_multi_call_closure<'tcx>(
|
|||
cx: &LateContext<'tcx>,
|
||||
expr: &Expr<'_>,
|
||||
) -> Option<&'tcx Expr<'tcx>> {
|
||||
for (_, node) in cx.tcx.hir().parent_iter(expr.hir_id) {
|
||||
for (_, node) in cx.tcx.hir_parent_iter(expr.hir_id) {
|
||||
match node {
|
||||
Node::Expr(e) => match e.kind {
|
||||
ExprKind::Closure { .. }
|
||||
|
|
@ -1455,7 +1453,7 @@ pub fn get_enclosing_loop_or_multi_call_closure<'tcx>(
|
|||
|
||||
/// Gets the parent node if it's an impl block.
|
||||
pub fn get_parent_as_impl(tcx: TyCtxt<'_>, id: HirId) -> Option<&Impl<'_>> {
|
||||
match tcx.hir().parent_iter(id).next() {
|
||||
match tcx.hir_parent_iter(id).next() {
|
||||
Some((
|
||||
_,
|
||||
Node::Item(Item {
|
||||
|
|
@ -1533,7 +1531,7 @@ pub fn peel_blocks_with_stmt<'a>(mut expr: &'a Expr<'a>) -> &'a Expr<'a> {
|
|||
|
||||
/// Checks if the given expression is the else clause of either an `if` or `if let` expression.
|
||||
pub fn is_else_clause(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool {
|
||||
let mut iter = tcx.hir().parent_iter(expr.hir_id);
|
||||
let mut iter = tcx.hir_parent_iter(expr.hir_id);
|
||||
match iter.next() {
|
||||
Some((
|
||||
_,
|
||||
|
|
@ -1550,7 +1548,7 @@ pub fn is_else_clause(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool {
|
|||
/// returns `true` for both the `init` and the `else` part
|
||||
pub fn is_inside_let_else(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool {
|
||||
let mut child_id = expr.hir_id;
|
||||
for (parent_id, node) in tcx.hir().parent_iter(child_id) {
|
||||
for (parent_id, node) in tcx.hir_parent_iter(child_id) {
|
||||
if let Node::LetStmt(LetStmt {
|
||||
init: Some(init),
|
||||
els: Some(els),
|
||||
|
|
@ -1570,7 +1568,7 @@ pub fn is_inside_let_else(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool {
|
|||
/// Checks if the given expression is the else clause of a `let else` expression
|
||||
pub fn is_else_clause_in_let_else(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool {
|
||||
let mut child_id = expr.hir_id;
|
||||
for (parent_id, node) in tcx.hir().parent_iter(child_id) {
|
||||
for (parent_id, node) in tcx.hir_parent_iter(child_id) {
|
||||
if let Node::LetStmt(LetStmt { els: Some(els), .. }) = node
|
||||
&& els.hir_id == child_id
|
||||
{
|
||||
|
|
@ -1648,7 +1646,7 @@ pub fn is_integer_const(cx: &LateContext<'_>, e: &Expr<'_>, value: u128) -> bool
|
|||
if is_integer_literal(e, value) {
|
||||
return true;
|
||||
}
|
||||
let enclosing_body = cx.tcx.hir().enclosing_body_owner(e.hir_id);
|
||||
let enclosing_body = cx.tcx.hir_enclosing_body_owner(e.hir_id);
|
||||
if let Some(Constant::Int(v)) =
|
||||
ConstEvalCtxt::with_env(cx.tcx, cx.typing_env(), cx.tcx.typeck(enclosing_body)).eval(e)
|
||||
{
|
||||
|
|
@ -1963,7 +1961,7 @@ pub fn any_parent_has_attr(tcx: TyCtxt<'_>, node: HirId, symbol: Symbol) -> bool
|
|||
return true;
|
||||
}
|
||||
prev_enclosing_node = Some(enclosing_node);
|
||||
enclosing_node = map.get_parent_item(enclosing_node).into();
|
||||
enclosing_node = tcx.hir_get_parent_item(enclosing_node).into();
|
||||
}
|
||||
|
||||
false
|
||||
|
|
@ -1972,8 +1970,8 @@ pub fn any_parent_has_attr(tcx: TyCtxt<'_>, node: HirId, symbol: Symbol) -> bool
|
|||
/// Checks if the given HIR node is inside an `impl` block with the `automatically_derived`
|
||||
/// attribute.
|
||||
pub fn in_automatically_derived(tcx: TyCtxt<'_>, id: HirId) -> bool {
|
||||
tcx.hir()
|
||||
.parent_owner_iter(id)
|
||||
tcx
|
||||
.hir_parent_owner_iter(id)
|
||||
.filter(|(_, node)| matches!(node, OwnerNode::Item(item) if matches!(item.kind, ItemKind::Impl(_))))
|
||||
.any(|(id, _)| {
|
||||
has_attr(
|
||||
|
|
@ -2204,7 +2202,7 @@ pub fn is_expr_identity_function(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool
|
|||
/// Returns both the node and the `HirId` of the closest child node.
|
||||
pub fn get_expr_use_or_unification_node<'tcx>(tcx: TyCtxt<'tcx>, expr: &Expr<'_>) -> Option<(Node<'tcx>, HirId)> {
|
||||
let mut child_id = expr.hir_id;
|
||||
let mut iter = tcx.hir().parent_iter(child_id);
|
||||
let mut iter = tcx.hir_parent_iter(child_id);
|
||||
loop {
|
||||
match iter.next() {
|
||||
None => break None,
|
||||
|
|
@ -2583,7 +2581,7 @@ pub fn is_in_test_function(tcx: TyCtxt<'_>, id: HirId) -> bool {
|
|||
with_test_item_names(tcx, tcx.parent_module(id), |names| {
|
||||
let node = tcx.hir_node(id);
|
||||
once((id, node))
|
||||
.chain(tcx.hir().parent_iter(id))
|
||||
.chain(tcx.hir_parent_iter(id))
|
||||
// Since you can nest functions we need to collect all until we leave
|
||||
// function scope
|
||||
.any(|(_id, node)| {
|
||||
|
|
@ -2619,8 +2617,8 @@ pub fn is_cfg_test(tcx: TyCtxt<'_>, id: HirId) -> bool {
|
|||
|
||||
/// Checks if any parent node of `HirId` has `#[cfg(test)]` attribute applied
|
||||
pub fn is_in_cfg_test(tcx: TyCtxt<'_>, id: HirId) -> bool {
|
||||
tcx.hir()
|
||||
.parent_id_iter(id)
|
||||
tcx
|
||||
.hir_parent_id_iter(id)
|
||||
.any(|parent_id| is_cfg_test(tcx, parent_id))
|
||||
}
|
||||
|
||||
|
|
@ -2634,8 +2632,8 @@ pub fn inherits_cfg(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
|
|||
let hir = tcx.hir();
|
||||
|
||||
tcx.has_attr(def_id, sym::cfg)
|
||||
|| hir
|
||||
.parent_iter(tcx.local_def_id_to_hir_id(def_id))
|
||||
|| tcx
|
||||
.hir_parent_iter(tcx.local_def_id_to_hir_id(def_id))
|
||||
.flat_map(|(parent_id, _)| hir.attrs(parent_id))
|
||||
.any(|attr| attr.has_name(sym::cfg))
|
||||
}
|
||||
|
|
@ -2655,8 +2653,7 @@ pub fn walk_to_expr_usage<'tcx, T>(
|
|||
e: &Expr<'tcx>,
|
||||
mut f: impl FnMut(HirId, Node<'tcx>, HirId) -> ControlFlow<T>,
|
||||
) -> Option<ControlFlow<T, (Node<'tcx>, HirId)>> {
|
||||
let map = cx.tcx.hir();
|
||||
let mut iter = map.parent_iter(e.hir_id);
|
||||
let mut iter = cx.tcx.hir_parent_iter(e.hir_id);
|
||||
let mut child_id = e.hir_id;
|
||||
|
||||
while let Some((parent_id, parent)) = iter.next() {
|
||||
|
|
@ -2679,7 +2676,7 @@ pub fn walk_to_expr_usage<'tcx, T>(
|
|||
ExprKind::If(child, ..) | ExprKind::Match(child, ..) if child.hir_id != child_id => child_id = parent_id,
|
||||
ExprKind::Break(Destination { target_id: Ok(id), .. }, _) => {
|
||||
child_id = id;
|
||||
iter = map.parent_iter(id);
|
||||
iter = cx.tcx.hir_parent_iter(id);
|
||||
},
|
||||
ExprKind::Block(..) | ExprKind::DropTemps(_) => child_id = parent_id,
|
||||
_ => return Some(ControlFlow::Continue((parent, child_id))),
|
||||
|
|
@ -2762,7 +2759,7 @@ impl<'tcx> ExprUseCtxt<'tcx> {
|
|||
|
||||
Node::Expr(use_expr) => match use_expr.kind {
|
||||
ExprKind::Ret(_) => ExprUseNode::Return(OwnerId {
|
||||
def_id: cx.tcx.hir().body_owner_def_id(cx.enclosing_body.unwrap()),
|
||||
def_id: cx.tcx.hir_body_owner_def_id(cx.enclosing_body.unwrap()),
|
||||
}),
|
||||
|
||||
ExprKind::Closure(closure) => ExprUseNode::Return(OwnerId { def_id: closure.def_id }),
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ pub fn first_node_in_macro(cx: &LateContext<'_>, node: &impl HirNode) -> Option<
|
|||
// get the parent node, possibly skipping over a statement
|
||||
// if the parent is not found, it is sensible to return `Some(root)`
|
||||
let hir = cx.tcx.hir();
|
||||
let mut parent_iter = hir.parent_iter(node.hir_id());
|
||||
let mut parent_iter = cx.tcx.hir_parent_iter(node.hir_id());
|
||||
let (parent_id, _) = match parent_iter.next() {
|
||||
None => return Some(ExpnId::root()),
|
||||
Some((_, Node::Stmt(_))) => match parent_iter.next() {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ pub fn visit_local_usage(locals: &[Local], mir: &Body<'_>, location: Location) -
|
|||
locals.len()
|
||||
];
|
||||
|
||||
traversal::Postorder::new(&mir.basic_blocks, location.block, ())
|
||||
traversal::Postorder::new(&mir.basic_blocks, location.block, None)
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
.rev()
|
||||
|
|
@ -136,8 +136,8 @@ pub fn used_exactly_once(mir: &Body<'_>, local: Local) -> Option<bool> {
|
|||
/// Returns the `mir::Body` containing the node associated with `hir_id`.
|
||||
#[allow(clippy::module_name_repetitions)]
|
||||
pub fn enclosing_mir(tcx: TyCtxt<'_>, hir_id: HirId) -> Option<&Body<'_>> {
|
||||
let body_owner_local_def_id = tcx.hir().enclosing_body_owner(hir_id);
|
||||
if tcx.hir().body_owner_kind(body_owner_local_def_id).is_fn_or_closure() {
|
||||
let body_owner_local_def_id = tcx.hir_enclosing_body_owner(hir_id);
|
||||
if tcx.hir_body_owner_kind(body_owner_local_def_id).is_fn_or_closure() {
|
||||
Some(tcx.optimized_mir(body_owner_local_def_id.to_def_id()))
|
||||
} else {
|
||||
None
|
||||
|
|
|
|||
|
|
@ -267,7 +267,7 @@ pub fn implements_trait_with_env_from_iter<'tcx>(
|
|||
// through calling `body_owner_kind`, which would panic if the callee
|
||||
// does not have a body.
|
||||
if let Some(callee_id) = callee_id {
|
||||
let _ = tcx.hir().body_owner_kind(callee_id);
|
||||
let _ = tcx.hir_body_owner_kind(callee_id);
|
||||
}
|
||||
|
||||
let ty = tcx.erase_regions(ty);
|
||||
|
|
@ -705,7 +705,7 @@ pub fn ty_sig<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> Option<ExprFnSig<'t
|
|||
ty::Closure(id, subs) => {
|
||||
let decl = id
|
||||
.as_local()
|
||||
.and_then(|id| cx.tcx.hir().fn_decl_by_hir_id(cx.tcx.local_def_id_to_hir_id(id)));
|
||||
.and_then(|id| cx.tcx.hir_fn_decl_by_hir_id(cx.tcx.local_def_id_to_hir_id(id)));
|
||||
Some(ExprFnSig::Closure(decl, subs.as_closure().sig()))
|
||||
},
|
||||
ty::FnDef(id, subs) => Some(ExprFnSig::Sig(cx.tcx.fn_sig(id).instantiate(cx.tcx, subs), Some(id))),
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@ LL | | };
|
|||
= help: to override `-D warnings` add `#[allow(clippy::async_yields_async)]`
|
||||
help: consider awaiting this value
|
||||
|
|
||||
LL ~ async {
|
||||
LL + 3
|
||||
LL + }.await
|
||||
LL | async {
|
||||
LL | 3
|
||||
LL ~ }.await
|
||||
|
|
||||
|
||||
error: an async construct yields a type which is itself awaitable
|
||||
|
|
@ -46,9 +46,9 @@ LL | | };
|
|||
|
|
||||
help: consider awaiting this value
|
||||
|
|
||||
LL ~ async {
|
||||
LL + 3
|
||||
LL + }.await
|
||||
LL | async {
|
||||
LL | 3
|
||||
LL ~ }.await
|
||||
|
|
||||
|
||||
error: an async construct yields a type which is itself awaitable
|
||||
|
|
|
|||
|
|
@ -13,9 +13,8 @@ LL + let x: &str = s;
|
|||
|
|
||||
help: if you would like to deref, try using `&**`
|
||||
|
|
||||
LL - let x: &str = &*s;
|
||||
LL + let x: &str = &**s;
|
||||
|
|
||||
LL | let x: &str = &**s;
|
||||
| +
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,8 @@ LL | let _ = foo as i8;
|
|||
= help: to override `-D warnings` add `#[allow(clippy::fn_to_numeric_cast_any)]`
|
||||
help: did you mean to invoke the function?
|
||||
|
|
||||
LL - let _ = foo as i8;
|
||||
LL + let _ = foo() as i8;
|
||||
|
|
||||
LL | let _ = foo() as i8;
|
||||
| ++
|
||||
|
||||
error: casting function pointer `foo` to `i16`
|
||||
--> tests/ui/fn_to_numeric_cast_any.rs:26:13
|
||||
|
|
@ -20,9 +19,8 @@ LL | let _ = foo as i16;
|
|||
|
|
||||
help: did you mean to invoke the function?
|
||||
|
|
||||
LL - let _ = foo as i16;
|
||||
LL + let _ = foo() as i16;
|
||||
|
|
||||
LL | let _ = foo() as i16;
|
||||
| ++
|
||||
|
||||
error: casting function pointer `foo` to `i32`
|
||||
--> tests/ui/fn_to_numeric_cast_any.rs:28:13
|
||||
|
|
@ -32,9 +30,8 @@ LL | let _ = foo as i32;
|
|||
|
|
||||
help: did you mean to invoke the function?
|
||||
|
|
||||
LL - let _ = foo as i32;
|
||||
LL + let _ = foo() as i32;
|
||||
|
|
||||
LL | let _ = foo() as i32;
|
||||
| ++
|
||||
|
||||
error: casting function pointer `foo` to `i64`
|
||||
--> tests/ui/fn_to_numeric_cast_any.rs:30:13
|
||||
|
|
@ -44,9 +41,8 @@ LL | let _ = foo as i64;
|
|||
|
|
||||
help: did you mean to invoke the function?
|
||||
|
|
||||
LL - let _ = foo as i64;
|
||||
LL + let _ = foo() as i64;
|
||||
|
|
||||
LL | let _ = foo() as i64;
|
||||
| ++
|
||||
|
||||
error: casting function pointer `foo` to `i128`
|
||||
--> tests/ui/fn_to_numeric_cast_any.rs:32:13
|
||||
|
|
@ -56,9 +52,8 @@ LL | let _ = foo as i128;
|
|||
|
|
||||
help: did you mean to invoke the function?
|
||||
|
|
||||
LL - let _ = foo as i128;
|
||||
LL + let _ = foo() as i128;
|
||||
|
|
||||
LL | let _ = foo() as i128;
|
||||
| ++
|
||||
|
||||
error: casting function pointer `foo` to `isize`
|
||||
--> tests/ui/fn_to_numeric_cast_any.rs:34:13
|
||||
|
|
@ -68,9 +63,8 @@ LL | let _ = foo as isize;
|
|||
|
|
||||
help: did you mean to invoke the function?
|
||||
|
|
||||
LL - let _ = foo as isize;
|
||||
LL + let _ = foo() as isize;
|
||||
|
|
||||
LL | let _ = foo() as isize;
|
||||
| ++
|
||||
|
||||
error: casting function pointer `foo` to `u8`
|
||||
--> tests/ui/fn_to_numeric_cast_any.rs:37:13
|
||||
|
|
@ -80,9 +74,8 @@ LL | let _ = foo as u8;
|
|||
|
|
||||
help: did you mean to invoke the function?
|
||||
|
|
||||
LL - let _ = foo as u8;
|
||||
LL + let _ = foo() as u8;
|
||||
|
|
||||
LL | let _ = foo() as u8;
|
||||
| ++
|
||||
|
||||
error: casting function pointer `foo` to `u16`
|
||||
--> tests/ui/fn_to_numeric_cast_any.rs:39:13
|
||||
|
|
@ -92,9 +85,8 @@ LL | let _ = foo as u16;
|
|||
|
|
||||
help: did you mean to invoke the function?
|
||||
|
|
||||
LL - let _ = foo as u16;
|
||||
LL + let _ = foo() as u16;
|
||||
|
|
||||
LL | let _ = foo() as u16;
|
||||
| ++
|
||||
|
||||
error: casting function pointer `foo` to `u32`
|
||||
--> tests/ui/fn_to_numeric_cast_any.rs:41:13
|
||||
|
|
@ -104,9 +96,8 @@ LL | let _ = foo as u32;
|
|||
|
|
||||
help: did you mean to invoke the function?
|
||||
|
|
||||
LL - let _ = foo as u32;
|
||||
LL + let _ = foo() as u32;
|
||||
|
|
||||
LL | let _ = foo() as u32;
|
||||
| ++
|
||||
|
||||
error: casting function pointer `foo` to `u64`
|
||||
--> tests/ui/fn_to_numeric_cast_any.rs:43:13
|
||||
|
|
@ -116,9 +107,8 @@ LL | let _ = foo as u64;
|
|||
|
|
||||
help: did you mean to invoke the function?
|
||||
|
|
||||
LL - let _ = foo as u64;
|
||||
LL + let _ = foo() as u64;
|
||||
|
|
||||
LL | let _ = foo() as u64;
|
||||
| ++
|
||||
|
||||
error: casting function pointer `foo` to `u128`
|
||||
--> tests/ui/fn_to_numeric_cast_any.rs:45:13
|
||||
|
|
@ -128,9 +118,8 @@ LL | let _ = foo as u128;
|
|||
|
|
||||
help: did you mean to invoke the function?
|
||||
|
|
||||
LL - let _ = foo as u128;
|
||||
LL + let _ = foo() as u128;
|
||||
|
|
||||
LL | let _ = foo() as u128;
|
||||
| ++
|
||||
|
||||
error: casting function pointer `foo` to `usize`
|
||||
--> tests/ui/fn_to_numeric_cast_any.rs:47:13
|
||||
|
|
@ -140,9 +129,8 @@ LL | let _ = foo as usize;
|
|||
|
|
||||
help: did you mean to invoke the function?
|
||||
|
|
||||
LL - let _ = foo as usize;
|
||||
LL + let _ = foo() as usize;
|
||||
|
|
||||
LL | let _ = foo() as usize;
|
||||
| ++
|
||||
|
||||
error: casting function pointer `Struct::static_method` to `usize`
|
||||
--> tests/ui/fn_to_numeric_cast_any.rs:52:13
|
||||
|
|
@ -152,9 +140,8 @@ LL | let _ = Struct::static_method as usize;
|
|||
|
|
||||
help: did you mean to invoke the function?
|
||||
|
|
||||
LL - let _ = Struct::static_method as usize;
|
||||
LL + let _ = Struct::static_method() as usize;
|
||||
|
|
||||
LL | let _ = Struct::static_method() as usize;
|
||||
| ++
|
||||
|
||||
error: casting function pointer `f` to `usize`
|
||||
--> tests/ui/fn_to_numeric_cast_any.rs:57:5
|
||||
|
|
@ -164,9 +151,8 @@ LL | f as usize
|
|||
|
|
||||
help: did you mean to invoke the function?
|
||||
|
|
||||
LL - f as usize
|
||||
LL + f() as usize
|
||||
|
|
||||
LL | f() as usize
|
||||
| ++
|
||||
|
||||
error: casting function pointer `T::static_method` to `usize`
|
||||
--> tests/ui/fn_to_numeric_cast_any.rs:62:5
|
||||
|
|
@ -176,9 +162,8 @@ LL | T::static_method as usize
|
|||
|
|
||||
help: did you mean to invoke the function?
|
||||
|
|
||||
LL - T::static_method as usize
|
||||
LL + T::static_method() as usize
|
||||
|
|
||||
LL | T::static_method() as usize
|
||||
| ++
|
||||
|
||||
error: casting function pointer `(clos as fn(u32) -> u32)` to `usize`
|
||||
--> tests/ui/fn_to_numeric_cast_any.rs:69:13
|
||||
|
|
@ -188,9 +173,8 @@ LL | let _ = (clos as fn(u32) -> u32) as usize;
|
|||
|
|
||||
help: did you mean to invoke the function?
|
||||
|
|
||||
LL - let _ = (clos as fn(u32) -> u32) as usize;
|
||||
LL + let _ = (clos as fn(u32) -> u32)() as usize;
|
||||
|
|
||||
LL | let _ = (clos as fn(u32) -> u32)() as usize;
|
||||
| ++
|
||||
|
||||
error: casting function pointer `foo` to `*const ()`
|
||||
--> tests/ui/fn_to_numeric_cast_any.rs:74:13
|
||||
|
|
@ -200,9 +184,8 @@ LL | let _ = foo as *const ();
|
|||
|
|
||||
help: did you mean to invoke the function?
|
||||
|
|
||||
LL - let _ = foo as *const ();
|
||||
LL + let _ = foo() as *const ();
|
||||
|
|
||||
LL | let _ = foo() as *const ();
|
||||
| ++
|
||||
|
||||
error: aborting due to 17 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -78,9 +78,8 @@ LL | pub fn map(map: &mut HashMap<i32, i32>) {}
|
|||
|
|
||||
help: add a type parameter for `BuildHasher`
|
||||
|
|
||||
LL - pub fn map(map: &mut HashMap<i32, i32>) {}
|
||||
LL + pub fn map<S: ::std::hash::BuildHasher>(map: &mut HashMap<i32, i32, S>) {}
|
||||
|
|
||||
LL | pub fn map<S: ::std::hash::BuildHasher>(map: &mut HashMap<i32, i32, S>) {}
|
||||
| +++++++++++++++++++++++++++++ +++
|
||||
|
||||
error: parameter of type `HashSet` should be generalized over different hashers
|
||||
--> tests/ui/implicit_hasher.rs:70:22
|
||||
|
|
@ -90,9 +89,8 @@ LL | pub fn set(set: &mut HashSet<i32>) {}
|
|||
|
|
||||
help: add a type parameter for `BuildHasher`
|
||||
|
|
||||
LL - pub fn set(set: &mut HashSet<i32>) {}
|
||||
LL + pub fn set<S: ::std::hash::BuildHasher>(set: &mut HashSet<i32, S>) {}
|
||||
|
|
||||
LL | pub fn set<S: ::std::hash::BuildHasher>(set: &mut HashSet<i32, S>) {}
|
||||
| +++++++++++++++++++++++++++++ +++
|
||||
|
||||
error: impl for `HashMap` should be generalized over different hashers
|
||||
--> tests/ui/implicit_hasher.rs:76:43
|
||||
|
|
@ -116,9 +114,8 @@ LL | pub async fn election_vote(_data: HashMap<i32, i32>) {}
|
|||
|
|
||||
help: add a type parameter for `BuildHasher`
|
||||
|
|
||||
LL - pub async fn election_vote(_data: HashMap<i32, i32>) {}
|
||||
LL + pub async fn election_vote<S: ::std::hash::BuildHasher>(_data: HashMap<i32, i32, S>) {}
|
||||
|
|
||||
LL | pub async fn election_vote<S: ::std::hash::BuildHasher>(_data: HashMap<i32, i32, S>) {}
|
||||
| +++++++++++++++++++++++++++++ +++
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ LL | true
|
|||
help: add `return` as shown
|
||||
|
|
||||
LL | return true
|
||||
|
|
||||
| ++++++
|
||||
|
||||
error: missing `return` statement
|
||||
--> tests/ui/implicit_return.rs:19:15
|
||||
|
|
@ -122,7 +122,7 @@ LL | format!("test {}", "test")
|
|||
help: add `return` as shown
|
||||
|
|
||||
LL | return format!("test {}", "test")
|
||||
|
|
||||
| ++++++
|
||||
|
||||
error: missing `return` statement
|
||||
--> tests/ui/implicit_return.rs:90:5
|
||||
|
|
@ -133,7 +133,7 @@ LL | m!(true, false)
|
|||
help: add `return` as shown
|
||||
|
|
||||
LL | return m!(true, false)
|
||||
|
|
||||
| ++++++
|
||||
|
||||
error: missing `return` statement
|
||||
--> tests/ui/implicit_return.rs:96:13
|
||||
|
|
@ -169,10 +169,8 @@ LL | | }
|
|||
|
|
||||
help: add `return` as shown
|
||||
|
|
||||
LL ~ return loop {
|
||||
LL + m!(true);
|
||||
LL + }
|
||||
|
|
||||
LL | return loop {
|
||||
| ++++++
|
||||
|
||||
error: missing `return` statement
|
||||
--> tests/ui/implicit_return.rs:130:5
|
||||
|
|
@ -183,7 +181,7 @@ LL | true
|
|||
help: add `return` as shown
|
||||
|
|
||||
LL | return true
|
||||
|
|
||||
| ++++++
|
||||
|
||||
error: aborting due to 16 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -99,9 +99,8 @@ LL + let fail8 = 123;
|
|||
|
|
||||
help: if you mean to use an octal constant, use `0o`
|
||||
|
|
||||
LL - let fail8 = 0123;
|
||||
LL + let fail8 = 0o123;
|
||||
|
|
||||
LL | let fail8 = 0o123;
|
||||
| +
|
||||
|
||||
error: integer type suffix should not be separated by an underscore
|
||||
--> tests/ui/literals.rs:48:16
|
||||
|
|
|
|||
|
|
@ -196,11 +196,9 @@ LL | | }
|
|||
| |_________^
|
||||
help: try
|
||||
|
|
||||
LL ~ for n in vec![
|
||||
LL +
|
||||
LL + Some(1),
|
||||
LL + Some(2),
|
||||
LL + Some(3)
|
||||
LL | for n in vec![
|
||||
...
|
||||
LL | Some(3)
|
||||
LL ~ ].iter().flatten() {
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -14,9 +14,8 @@ LL + let _bad1 = "\x1b[0m";
|
|||
|
|
||||
help: if a null escape is intended, disambiguate using
|
||||
|
|
||||
LL - let _bad1 = "\033[0m";
|
||||
LL + let _bad1 = "\x0033[0m";
|
||||
|
|
||||
LL | let _bad1 = "\x0033[0m";
|
||||
| ++
|
||||
|
||||
error: octal-looking escape in a literal
|
||||
--> tests/ui/octal_escapes.rs:6:19
|
||||
|
|
@ -31,9 +30,8 @@ LL + let _bad2 = b"\x1b[0m";
|
|||
|
|
||||
help: if a null escape is intended, disambiguate using
|
||||
|
|
||||
LL - let _bad2 = b"\033[0m";
|
||||
LL + let _bad2 = b"\x0033[0m";
|
||||
|
|
||||
LL | let _bad2 = b"\x0033[0m";
|
||||
| ++
|
||||
|
||||
error: octal-looking escape in a literal
|
||||
--> tests/ui/octal_escapes.rs:7:20
|
||||
|
|
@ -48,9 +46,8 @@ LL + let _bad3 = "\\\x1b[0m";
|
|||
|
|
||||
help: if a null escape is intended, disambiguate using
|
||||
|
|
||||
LL - let _bad3 = "\\\033[0m";
|
||||
LL + let _bad3 = "\\\x0033[0m";
|
||||
|
|
||||
LL | let _bad3 = "\\\x0033[0m";
|
||||
| ++
|
||||
|
||||
error: octal-looking escape in a literal
|
||||
--> tests/ui/octal_escapes.rs:9:18
|
||||
|
|
@ -65,9 +62,8 @@ LL + let _bad4 = "\x0a34567";
|
|||
|
|
||||
help: if a null escape is intended, disambiguate using
|
||||
|
|
||||
LL - let _bad4 = "\01234567";
|
||||
LL + let _bad4 = "\x001234567";
|
||||
|
|
||||
LL | let _bad4 = "\x001234567";
|
||||
| ++
|
||||
|
||||
error: octal-looking escape in a literal
|
||||
--> tests/ui/octal_escapes.rs:10:20
|
||||
|
|
@ -77,14 +73,12 @@ LL | let _bad5 = "\0\03";
|
|||
|
|
||||
help: if an octal escape is intended, use a hex escape instead
|
||||
|
|
||||
LL - let _bad5 = "\0\03";
|
||||
LL + let _bad5 = "\0\x03";
|
||||
|
|
||||
LL | let _bad5 = "\0\x03";
|
||||
| +
|
||||
help: if a null escape is intended, disambiguate using
|
||||
|
|
||||
LL - let _bad5 = "\0\03";
|
||||
LL + let _bad5 = "\0\x0003";
|
||||
|
|
||||
LL | let _bad5 = "\0\x0003";
|
||||
| +++
|
||||
|
||||
error: octal-looking escape in a literal
|
||||
--> tests/ui/octal_escapes.rs:11:23
|
||||
|
|
@ -99,9 +93,8 @@ LL + let _bad6 = "Text-\x2d\077-MoreText";
|
|||
|
|
||||
help: if a null escape is intended, disambiguate using
|
||||
|
|
||||
LL - let _bad6 = "Text-\055\077-MoreText";
|
||||
LL + let _bad6 = "Text-\x0055\077-MoreText";
|
||||
|
|
||||
LL | let _bad6 = "Text-\x0055\077-MoreText";
|
||||
| ++
|
||||
|
||||
error: octal-looking escape in a literal
|
||||
--> tests/ui/octal_escapes.rs:11:27
|
||||
|
|
@ -116,9 +109,8 @@ LL + let _bad6 = "Text-\055\x3f-MoreText";
|
|||
|
|
||||
help: if a null escape is intended, disambiguate using
|
||||
|
|
||||
LL - let _bad6 = "Text-\055\077-MoreText";
|
||||
LL + let _bad6 = "Text-\055\x0077-MoreText";
|
||||
|
|
||||
LL | let _bad6 = "Text-\055\x0077-MoreText";
|
||||
| ++
|
||||
|
||||
error: octal-looking escape in a literal
|
||||
--> tests/ui/octal_escapes.rs:14:31
|
||||
|
|
@ -128,14 +120,12 @@ LL | let _bad7 = "EvenMoreText-\01\02-ShortEscapes";
|
|||
|
|
||||
help: if an octal escape is intended, use a hex escape instead
|
||||
|
|
||||
LL - let _bad7 = "EvenMoreText-\01\02-ShortEscapes";
|
||||
LL + let _bad7 = "EvenMoreText-\x01\02-ShortEscapes";
|
||||
|
|
||||
LL | let _bad7 = "EvenMoreText-\x01\02-ShortEscapes";
|
||||
| +
|
||||
help: if a null escape is intended, disambiguate using
|
||||
|
|
||||
LL - let _bad7 = "EvenMoreText-\01\02-ShortEscapes";
|
||||
LL + let _bad7 = "EvenMoreText-\x0001\02-ShortEscapes";
|
||||
|
|
||||
LL | let _bad7 = "EvenMoreText-\x0001\02-ShortEscapes";
|
||||
| +++
|
||||
|
||||
error: octal-looking escape in a literal
|
||||
--> tests/ui/octal_escapes.rs:14:34
|
||||
|
|
@ -145,14 +135,12 @@ LL | let _bad7 = "EvenMoreText-\01\02-ShortEscapes";
|
|||
|
|
||||
help: if an octal escape is intended, use a hex escape instead
|
||||
|
|
||||
LL - let _bad7 = "EvenMoreText-\01\02-ShortEscapes";
|
||||
LL + let _bad7 = "EvenMoreText-\01\x02-ShortEscapes";
|
||||
|
|
||||
LL | let _bad7 = "EvenMoreText-\01\x02-ShortEscapes";
|
||||
| +
|
||||
help: if a null escape is intended, disambiguate using
|
||||
|
|
||||
LL - let _bad7 = "EvenMoreText-\01\02-ShortEscapes";
|
||||
LL + let _bad7 = "EvenMoreText-\01\x0002-ShortEscapes";
|
||||
|
|
||||
LL | let _bad7 = "EvenMoreText-\01\x0002-ShortEscapes";
|
||||
| +++
|
||||
|
||||
error: octal-looking escape in a literal
|
||||
--> tests/ui/octal_escapes.rs:17:19
|
||||
|
|
@ -162,14 +150,12 @@ LL | let _bad8 = "锈\01锈";
|
|||
|
|
||||
help: if an octal escape is intended, use a hex escape instead
|
||||
|
|
||||
LL - let _bad8 = "锈\01锈";
|
||||
LL + let _bad8 = "锈\x01锈";
|
||||
|
|
||||
LL | let _bad8 = "锈\x01锈";
|
||||
| +
|
||||
help: if a null escape is intended, disambiguate using
|
||||
|
|
||||
LL - let _bad8 = "锈\01锈";
|
||||
LL + let _bad8 = "锈\x0001锈";
|
||||
|
|
||||
LL | let _bad8 = "锈\x0001锈";
|
||||
| +++
|
||||
|
||||
error: octal-looking escape in a literal
|
||||
--> tests/ui/octal_escapes.rs:18:19
|
||||
|
|
@ -184,9 +170,8 @@ LL + let _bad9 = "锈\x09锈";
|
|||
|
|
||||
help: if a null escape is intended, disambiguate using
|
||||
|
|
||||
LL - let _bad9 = "锈\011锈";
|
||||
LL + let _bad9 = "锈\x0011锈";
|
||||
|
|
||||
LL | let _bad9 = "锈\x0011锈";
|
||||
| ++
|
||||
|
||||
error: aborting due to 11 previous errors
|
||||
|
||||
|
|
|
|||
|
|
@ -8,9 +8,8 @@ LL | let _ = cow.to_owned();
|
|||
= help: to override `-D warnings` add `#[allow(clippy::suspicious_to_owned)]`
|
||||
help: depending on intent, either make the Cow an Owned variant
|
||||
|
|
||||
LL - let _ = cow.to_owned();
|
||||
LL + let _ = cow.into_owned();
|
||||
|
|
||||
LL | let _ = cow.into_owned();
|
||||
| ++
|
||||
help: or clone the Cow itself
|
||||
|
|
||||
LL - let _ = cow.to_owned();
|
||||
|
|
@ -25,9 +24,8 @@ LL | let _ = cow.to_owned();
|
|||
|
|
||||
help: depending on intent, either make the Cow an Owned variant
|
||||
|
|
||||
LL - let _ = cow.to_owned();
|
||||
LL + let _ = cow.into_owned();
|
||||
|
|
||||
LL | let _ = cow.into_owned();
|
||||
| ++
|
||||
help: or clone the Cow itself
|
||||
|
|
||||
LL - let _ = cow.to_owned();
|
||||
|
|
@ -42,9 +40,8 @@ LL | let _ = cow.to_owned();
|
|||
|
|
||||
help: depending on intent, either make the Cow an Owned variant
|
||||
|
|
||||
LL - let _ = cow.to_owned();
|
||||
LL + let _ = cow.into_owned();
|
||||
|
|
||||
LL | let _ = cow.into_owned();
|
||||
| ++
|
||||
help: or clone the Cow itself
|
||||
|
|
||||
LL - let _ = cow.to_owned();
|
||||
|
|
@ -59,9 +56,8 @@ LL | let _ = cow.to_owned();
|
|||
|
|
||||
help: depending on intent, either make the Cow an Owned variant
|
||||
|
|
||||
LL - let _ = cow.to_owned();
|
||||
LL + let _ = cow.into_owned();
|
||||
|
|
||||
LL | let _ = cow.into_owned();
|
||||
| ++
|
||||
help: or clone the Cow itself
|
||||
|
|
||||
LL - let _ = cow.to_owned();
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ LL | | /// 200 characters so I needed to write something longeeeeeeer.
|
|||
= help: to override `-D warnings` add `#[allow(clippy::too_long_first_doc_paragraph)]`
|
||||
help: add an empty line
|
||||
|
|
||||
LL ~ /// A very short summary.
|
||||
LL | /// A very short summary.
|
||||
LL + ///
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ LL | | //! 200 characters so I needed to write something longeeeeeeer.
|
|||
= help: to override `-D warnings` add `#[allow(clippy::too_long_first_doc_paragraph)]`
|
||||
help: add an empty line
|
||||
|
|
||||
LL ~ //! A very short summary.
|
||||
LL + //!
|
||||
LL | //! A very short summary.
|
||||
LL ~ //!
|
||||
LL ~ //! A much longer explanation that goes into a lot more detail about
|
||||
|
|
||||
|
||||
|
|
|
|||
|
|
@ -215,8 +215,10 @@ pub struct Config {
|
|||
/// `None` then these tests will be ignored.
|
||||
pub run_clang_based_tests_with: Option<String>,
|
||||
|
||||
/// The directory containing the tests to run
|
||||
pub src_base: PathBuf,
|
||||
/// The directory containing the sources.
|
||||
pub src_root: PathBuf,
|
||||
/// The directory containing the test suite sources. Must be a subdirectory of `src_root`.
|
||||
pub src_test_suite_root: PathBuf,
|
||||
|
||||
/// The directory where programs should be built
|
||||
pub build_base: PathBuf,
|
||||
|
|
|
|||
|
|
@ -1026,19 +1026,6 @@ impl Config {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn find_rust_src_root(&self) -> Option<PathBuf> {
|
||||
let mut path = self.src_base.clone();
|
||||
let path_postfix = Path::new("src/etc/lldb_batchmode.py");
|
||||
|
||||
while path.pop() {
|
||||
if path.join(&path_postfix).is_file() {
|
||||
return Some(path);
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
fn parse_edition(&self, line: &str) -> Option<String> {
|
||||
self.parse_name_value_directive(line, "edition")
|
||||
}
|
||||
|
|
@ -1098,7 +1085,7 @@ fn expand_variables(mut value: String, config: &Config) -> String {
|
|||
}
|
||||
|
||||
if value.contains(SRC_BASE) {
|
||||
value = value.replace(SRC_BASE, &config.src_base.to_string_lossy());
|
||||
value = value.replace(SRC_BASE, &config.src_test_suite_root.to_str().unwrap());
|
||||
}
|
||||
|
||||
if value.contains(BUILD_BASE) {
|
||||
|
|
|
|||
|
|
@ -153,7 +153,8 @@ impl ConfigBuilder {
|
|||
"--run-lib-path=",
|
||||
"--python=",
|
||||
"--jsondocck-path=",
|
||||
"--src-base=",
|
||||
"--src-root=",
|
||||
"--src-test-suite-root=",
|
||||
"--build-base=",
|
||||
"--sysroot-base=",
|
||||
"--cc=c",
|
||||
|
|
@ -465,7 +466,10 @@ fn profiler_runtime() {
|
|||
#[test]
|
||||
fn asm_support() {
|
||||
let asms = [
|
||||
#[cfg(bootstrap)]
|
||||
("avr-unknown-gnu-atmega328", false),
|
||||
#[cfg(not(bootstrap))]
|
||||
("avr-none", false),
|
||||
("i686-unknown-netbsd", true),
|
||||
("riscv32gc-unknown-linux-gnu", true),
|
||||
("riscv64imac-unknown-none-elf", true),
|
||||
|
|
@ -891,8 +895,6 @@ fn test_needs_target_has_atomic() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
// FIXME: this test will fail against stage 0 until #137037 changes reach beta.
|
||||
#[cfg_attr(bootstrap, ignore)]
|
||||
fn test_rustc_abi() {
|
||||
let config = cfg().target("i686-unknown-linux-gnu").build();
|
||||
assert_eq!(config.target_cfg().rustc_abi, Some("x86-sse2".to_string()));
|
||||
|
|
|
|||
|
|
@ -61,7 +61,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
|||
.optopt("", "jsondoclint-path", "path to jsondoclint to use for doc tests", "PATH")
|
||||
.optopt("", "run-clang-based-tests-with", "path to Clang executable", "PATH")
|
||||
.optopt("", "llvm-filecheck", "path to LLVM's FileCheck binary", "DIR")
|
||||
.reqopt("", "src-base", "directory to scan for test files", "PATH")
|
||||
.reqopt("", "src-root", "directory containing sources", "PATH")
|
||||
.reqopt("", "src-test-suite-root", "directory containing test suite sources", "PATH")
|
||||
.reqopt("", "build-base", "directory to deposit test outputs", "PATH")
|
||||
.reqopt("", "sysroot-base", "directory containing the compiler sysroot", "PATH")
|
||||
.reqopt("", "stage", "stage number under test", "N")
|
||||
|
|
@ -243,7 +244,6 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
|||
|| header::extract_llvm_version_from_binary(&matches.opt_str("llvm-filecheck")?),
|
||||
);
|
||||
|
||||
let src_base = opt_path(matches, "src-base");
|
||||
let run_ignored = matches.opt_present("ignored");
|
||||
let with_rustc_debug_assertions = matches.opt_present("with-rustc-debug-assertions");
|
||||
let with_std_debug_assertions = matches.opt_present("with-std-debug-assertions");
|
||||
|
|
@ -300,6 +300,15 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
|||
None => panic!("`--stage` is required"),
|
||||
};
|
||||
|
||||
let src_root = opt_path(matches, "src-root");
|
||||
let src_test_suite_root = opt_path(matches, "src-test-suite-root");
|
||||
assert!(
|
||||
src_test_suite_root.starts_with(&src_root),
|
||||
"`src-root` must be a parent of `src-test-suite-root`: `src-root`=`{}`, `src-test-suite-root` = `{}`",
|
||||
src_root.display(),
|
||||
src_test_suite_root.display()
|
||||
);
|
||||
|
||||
Config {
|
||||
bless: matches.opt_present("bless"),
|
||||
compile_lib_path: make_absolute(opt_path(matches, "compile-lib-path")),
|
||||
|
|
@ -314,7 +323,10 @@ pub fn parse_config(args: Vec<String>) -> Config {
|
|||
run_clang_based_tests_with: matches.opt_str("run-clang-based-tests-with"),
|
||||
llvm_filecheck: matches.opt_str("llvm-filecheck").map(PathBuf::from),
|
||||
llvm_bin_dir: matches.opt_str("llvm-bin-dir").map(PathBuf::from),
|
||||
src_base,
|
||||
|
||||
src_root,
|
||||
src_test_suite_root,
|
||||
|
||||
build_base: opt_path(matches, "build-base"),
|
||||
sysroot_base: opt_path(matches, "sysroot-base"),
|
||||
|
||||
|
|
@ -422,7 +434,10 @@ pub fn log_config(config: &Config) {
|
|||
logv(c, format!("rustc_path: {:?}", config.rustc_path.display()));
|
||||
logv(c, format!("cargo_path: {:?}", config.cargo_path));
|
||||
logv(c, format!("rustdoc_path: {:?}", config.rustdoc_path));
|
||||
logv(c, format!("src_base: {:?}", config.src_base.display()));
|
||||
|
||||
logv(c, format!("src_root: {}", config.src_root.display()));
|
||||
logv(c, format!("src_test_suite_root: {}", config.src_test_suite_root.display()));
|
||||
|
||||
logv(c, format!("build_base: {:?}", config.build_base.display()));
|
||||
logv(c, format!("stage: {}", config.stage));
|
||||
logv(c, format!("stage_id: {}", config.stage_id));
|
||||
|
|
@ -620,20 +635,29 @@ struct TestCollector {
|
|||
/// regardless of whether any filters/tests were specified on the command-line,
|
||||
/// because filtering is handled later by libtest.
|
||||
pub fn collect_and_make_tests(config: Arc<Config>) -> Vec<test::TestDescAndFn> {
|
||||
debug!("making tests from {:?}", config.src_base.display());
|
||||
debug!("making tests from {}", config.src_test_suite_root.display());
|
||||
let common_inputs_stamp = common_inputs_stamp(&config);
|
||||
let modified_tests = modified_tests(&config, &config.src_base).unwrap_or_else(|err| {
|
||||
panic!("modified_tests got error from dir: {}, error: {}", config.src_base.display(), err)
|
||||
});
|
||||
let modified_tests =
|
||||
modified_tests(&config, &config.src_test_suite_root).unwrap_or_else(|err| {
|
||||
panic!(
|
||||
"modified_tests got error from dir: {}, error: {}",
|
||||
config.src_test_suite_root.display(),
|
||||
err
|
||||
)
|
||||
});
|
||||
let cache = HeadersCache::load(&config);
|
||||
|
||||
let cx = TestCollectorCx { config, cache, common_inputs_stamp, modified_tests };
|
||||
let mut collector =
|
||||
TestCollector { tests: vec![], found_path_stems: HashSet::new(), poisoned: false };
|
||||
|
||||
collect_tests_from_dir(&cx, &mut collector, &cx.config.src_base, Path::new("")).unwrap_or_else(
|
||||
|reason| panic!("Could not read tests from {}: {reason}", cx.config.src_base.display()),
|
||||
);
|
||||
collect_tests_from_dir(&cx, &mut collector, &cx.config.src_test_suite_root, Path::new(""))
|
||||
.unwrap_or_else(|reason| {
|
||||
panic!(
|
||||
"Could not read tests from {}: {reason}",
|
||||
cx.config.src_test_suite_root.display()
|
||||
)
|
||||
});
|
||||
|
||||
let TestCollector { tests, found_path_stems, poisoned } = collector;
|
||||
|
||||
|
|
@ -655,7 +679,7 @@ pub fn collect_and_make_tests(config: Arc<Config>) -> Vec<test::TestDescAndFn> {
|
|||
/// common to some subset of tests, and are hopefully unlikely to be modified
|
||||
/// while working on other tests.)
|
||||
fn common_inputs_stamp(config: &Config) -> Stamp {
|
||||
let rust_src_dir = config.find_rust_src_root().expect("Could not find Rust source root");
|
||||
let src_root = &config.src_root;
|
||||
|
||||
let mut stamp = Stamp::from_path(&config.rustc_path);
|
||||
|
||||
|
|
@ -670,17 +694,17 @@ fn common_inputs_stamp(config: &Config) -> Stamp {
|
|||
"src/etc/lldb_providers.py",
|
||||
];
|
||||
for file in &pretty_printer_files {
|
||||
let path = rust_src_dir.join(file);
|
||||
let path = src_root.join(file);
|
||||
stamp.add_path(&path);
|
||||
}
|
||||
|
||||
stamp.add_dir(&rust_src_dir.join("src/etc/natvis"));
|
||||
stamp.add_dir(&src_root.join("src/etc/natvis"));
|
||||
|
||||
stamp.add_dir(&config.run_lib_path);
|
||||
|
||||
if let Some(ref rustdoc_path) = config.rustdoc_path {
|
||||
stamp.add_path(&rustdoc_path);
|
||||
stamp.add_path(&rust_src_dir.join("src/etc/htmldocck.py"));
|
||||
stamp.add_path(&src_root.join("src/etc/htmldocck.py"));
|
||||
}
|
||||
|
||||
// Re-run coverage tests if the `coverage-dump` tool was modified,
|
||||
|
|
@ -689,10 +713,10 @@ fn common_inputs_stamp(config: &Config) -> Stamp {
|
|||
stamp.add_path(coverage_dump_path)
|
||||
}
|
||||
|
||||
stamp.add_dir(&rust_src_dir.join("src/tools/run-make-support"));
|
||||
stamp.add_dir(&src_root.join("src/tools/run-make-support"));
|
||||
|
||||
// Compiletest itself.
|
||||
stamp.add_dir(&rust_src_dir.join("src/tools/compiletest/"));
|
||||
stamp.add_dir(&src_root.join("src/tools/compiletest"));
|
||||
|
||||
stamp
|
||||
}
|
||||
|
|
@ -933,10 +957,7 @@ fn files_related_to_test(
|
|||
}
|
||||
|
||||
// `minicore.rs` test auxiliary: we need to make sure tests get rerun if this changes.
|
||||
//
|
||||
// FIXME(jieyouxu): untangle these paths, we should provide both a path to root `tests/` or
|
||||
// `tests/auxiliary/` and the test suite in question. `src_base` is also a terrible name.
|
||||
related.push(config.src_base.parent().unwrap().join("auxiliary").join("minicore.rs"));
|
||||
related.push(config.src_root.join("tests").join("auxiliary").join("minicore.rs"));
|
||||
|
||||
related
|
||||
}
|
||||
|
|
@ -1026,10 +1047,8 @@ fn make_test_name(
|
|||
testpaths: &TestPaths,
|
||||
revision: Option<&str>,
|
||||
) -> test::TestName {
|
||||
// Print the name of the file, relative to the repository root.
|
||||
// `src_base` looks like `/path/to/rust/tests/ui`
|
||||
let root_directory = config.src_base.parent().unwrap().parent().unwrap();
|
||||
let path = testpaths.file.strip_prefix(root_directory).unwrap();
|
||||
// Print the name of the file, relative to the sources root.
|
||||
let path = testpaths.file.strip_prefix(&config.src_root).unwrap();
|
||||
let debugger = match config.debugger {
|
||||
Some(d) => format!("-{}", d),
|
||||
None => String::new(),
|
||||
|
|
|
|||
|
|
@ -1365,7 +1365,7 @@ impl<'test> TestCx<'test> {
|
|||
//
|
||||
// Note: avoid adding a subdirectory of an already filtered directory here, otherwise the
|
||||
// same slice of text will be double counted and the truncation might not happen.
|
||||
add_path(&self.config.src_base);
|
||||
add_path(&self.config.src_test_suite_root);
|
||||
add_path(&self.config.build_base);
|
||||
|
||||
read2_abbreviated(child, &filter_paths_from_len).expect("failed to read output")
|
||||
|
|
@ -1471,7 +1471,7 @@ impl<'test> TestCx<'test> {
|
|||
// Similarly, vendored sources shouldn't be shown when running from a dist tarball.
|
||||
rustc.arg("-Z").arg(format!(
|
||||
"ignore-directory-in-diagnostics-source-blocks={}",
|
||||
self.config.find_rust_src_root().unwrap().join("vendor").display(),
|
||||
self.config.src_root.join("vendor").to_str().unwrap(),
|
||||
));
|
||||
|
||||
// Optionally prevent default --sysroot if specified in test compile-flags.
|
||||
|
|
@ -1632,7 +1632,7 @@ impl<'test> TestCx<'test> {
|
|||
if self.props.remap_src_base {
|
||||
rustc.arg(format!(
|
||||
"--remap-path-prefix={}={}",
|
||||
self.config.src_base.display(),
|
||||
self.config.src_test_suite_root.to_str().unwrap(),
|
||||
FAKE_SRC_BASE,
|
||||
));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -257,11 +257,8 @@ impl TestCx<'_> {
|
|||
println!("Adb process is already finished.");
|
||||
}
|
||||
} else {
|
||||
let rust_src_root =
|
||||
self.config.find_rust_src_root().expect("Could not find Rust source root");
|
||||
let rust_pp_module_rel_path = Path::new("./src/etc");
|
||||
let rust_pp_module_abs_path =
|
||||
rust_src_root.join(rust_pp_module_rel_path).to_str().unwrap().to_owned();
|
||||
let rust_pp_module_abs_path = self.config.src_root.join("src").join("etc");
|
||||
let rust_pp_module_abs_path = rust_pp_module_abs_path.to_str().unwrap();
|
||||
// write debugger script
|
||||
let mut script_str = String::with_capacity(2048);
|
||||
script_str.push_str(&format!("set charset {}\n", Self::charset()));
|
||||
|
|
@ -338,7 +335,7 @@ impl TestCx<'_> {
|
|||
let pythonpath = if let Ok(pp) = std::env::var("PYTHONPATH") {
|
||||
format!("{pp}:{rust_pp_module_abs_path}")
|
||||
} else {
|
||||
rust_pp_module_abs_path
|
||||
rust_pp_module_abs_path.to_string()
|
||||
};
|
||||
gdb.args(debugger_opts).env("PYTHONPATH", pythonpath);
|
||||
|
||||
|
|
@ -407,11 +404,8 @@ impl TestCx<'_> {
|
|||
// Make LLDB emit its version, so we have it documented in the test output
|
||||
script_str.push_str("version\n");
|
||||
|
||||
// Switch LLDB into "Rust mode"
|
||||
let rust_src_root =
|
||||
self.config.find_rust_src_root().expect("Could not find Rust source root");
|
||||
let rust_pp_module_rel_path = Path::new("./src/etc");
|
||||
let rust_pp_module_abs_path = rust_src_root.join(rust_pp_module_rel_path);
|
||||
// Switch LLDB into "Rust mode".
|
||||
let rust_pp_module_abs_path = self.config.src_root.join("src/etc");
|
||||
|
||||
script_str.push_str(&format!(
|
||||
"command script import {}/lldb_lookup.py\n",
|
||||
|
|
@ -445,7 +439,7 @@ impl TestCx<'_> {
|
|||
let debugger_script = self.make_out_name("debugger.script");
|
||||
|
||||
// Let LLDB execute the script via lldb_batchmode.py
|
||||
let debugger_run_result = self.run_lldb(&exe_file, &debugger_script, &rust_src_root);
|
||||
let debugger_run_result = self.run_lldb(&exe_file, &debugger_script);
|
||||
|
||||
if !debugger_run_result.status.success() {
|
||||
self.fatal_proc_rec("Error while running LLDB", &debugger_run_result);
|
||||
|
|
@ -456,18 +450,13 @@ impl TestCx<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
fn run_lldb(
|
||||
&self,
|
||||
test_executable: &Path,
|
||||
debugger_script: &Path,
|
||||
rust_src_root: &Path,
|
||||
) -> ProcRes {
|
||||
fn run_lldb(&self, test_executable: &Path, debugger_script: &Path) -> ProcRes {
|
||||
// Prepare the lldb_batchmode which executes the debugger script
|
||||
let lldb_script_path = rust_src_root.join("src/etc/lldb_batchmode.py");
|
||||
let lldb_script_path = self.config.src_root.join("src/etc/lldb_batchmode.py");
|
||||
let pythonpath = if let Ok(pp) = std::env::var("PYTHONPATH") {
|
||||
format!("{pp}:{}", self.config.lldb_python_dir.as_ref().unwrap())
|
||||
} else {
|
||||
self.config.lldb_python_dir.as_ref().unwrap().to_string()
|
||||
self.config.lldb_python_dir.clone().unwrap()
|
||||
};
|
||||
self.run_command_to_procres(
|
||||
Command::new(&self.config.python)
|
||||
|
|
|
|||
|
|
@ -9,12 +9,11 @@ impl TestCx<'_> {
|
|||
|
||||
self.document(&out_dir, &self.testpaths);
|
||||
|
||||
let root = self.config.find_rust_src_root().unwrap();
|
||||
let file_stem =
|
||||
self.testpaths.file.file_stem().and_then(|f| f.to_str()).expect("no file stem");
|
||||
let res = self.run_command_to_procres(
|
||||
Command::new(&nodejs)
|
||||
.arg(root.join("src/tools/rustdoc-js/tester.js"))
|
||||
.arg(self.config.src_root.join("src/tools/rustdoc-js/tester.js"))
|
||||
.arg("--doc-folder")
|
||||
.arg(out_dir)
|
||||
.arg("--crate-name")
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ impl TestCx<'_> {
|
|||
|
||||
fn run_rmake_legacy_test(&self) {
|
||||
let cwd = env::current_dir().unwrap();
|
||||
let src_root = self.config.src_base.parent().unwrap().parent().unwrap();
|
||||
let src_root = cwd.join(&src_root);
|
||||
|
||||
// FIXME(Zalathar): This should probably be `output_base_dir` to avoid
|
||||
// an unnecessary extra subdirectory, but since legacy Makefile tests
|
||||
|
|
@ -51,7 +49,7 @@ impl TestCx<'_> {
|
|||
.stderr(Stdio::piped())
|
||||
.env("TARGET", &self.config.target)
|
||||
.env("PYTHON", &self.config.python)
|
||||
.env("S", src_root)
|
||||
.env("S", &self.config.src_root)
|
||||
.env("RUST_BUILD_STAGE", &self.config.stage_id)
|
||||
.env("RUSTC", cwd.join(&self.config.rustc_path))
|
||||
.env("TMPDIR", &tmpdir)
|
||||
|
|
@ -181,28 +179,10 @@ impl TestCx<'_> {
|
|||
// library.
|
||||
// 2. We need to run the recipe binary.
|
||||
|
||||
// So we assume the rust-lang/rust project setup looks like the following (our `.` is the
|
||||
// top-level directory, irrelevant entries to our purposes omitted):
|
||||
//
|
||||
// ```
|
||||
// . // <- `source_root`
|
||||
// ├── build/ // <- `build_root`
|
||||
// ├── compiler/
|
||||
// ├── library/
|
||||
// ├── src/
|
||||
// │ └── tools/
|
||||
// │ └── run_make_support/
|
||||
// └── tests
|
||||
// └── run-make/
|
||||
// ```
|
||||
|
||||
// `source_root` is the top-level directory containing the rust-lang/rust checkout.
|
||||
let source_root =
|
||||
self.config.find_rust_src_root().expect("could not determine rust source root");
|
||||
// `self.config.build_base` is actually the build base folder + "test" + test suite name, it
|
||||
// looks like `build/<host_triple>/test/run-make`. But we want `build/<host_triple>/`. Note
|
||||
// that the `build` directory does not need to be called `build`, nor does it need to be
|
||||
// under `source_root`, so we must compute it based off of `self.config.build_base`.
|
||||
// under `src_root`, so we must compute it based off of `self.config.build_base`.
|
||||
let build_root =
|
||||
self.config.build_base.parent().and_then(Path::parent).unwrap().to_path_buf();
|
||||
|
||||
|
|
@ -389,10 +369,9 @@ impl TestCx<'_> {
|
|||
.env("TARGET", &self.config.target)
|
||||
// Some tests unfortunately still need Python, so provide path to a Python interpreter.
|
||||
.env("PYTHON", &self.config.python)
|
||||
// Provide path to checkout root. This is the top-level directory containing
|
||||
// rust-lang/rust checkout.
|
||||
.env("SOURCE_ROOT", &source_root)
|
||||
// Path to the build directory. This is usually the same as `source_root.join("build").join("host")`.
|
||||
// Provide path to sources root.
|
||||
.env("SOURCE_ROOT", &self.config.src_root)
|
||||
// Path to the host build directory.
|
||||
.env("BUILD_ROOT", &build_root)
|
||||
// Provide path to stage-corresponding rustc.
|
||||
.env("RUSTC", &self.config.rustc_path)
|
||||
|
|
@ -408,11 +387,11 @@ impl TestCx<'_> {
|
|||
.env("LLVM_COMPONENTS", &self.config.llvm_components);
|
||||
|
||||
if let Some(ref cargo) = self.config.cargo_path {
|
||||
cmd.env("CARGO", source_root.join(cargo));
|
||||
cmd.env("CARGO", cargo);
|
||||
}
|
||||
|
||||
if let Some(ref rustdoc) = self.config.rustdoc_path {
|
||||
cmd.env("RUSTDOC", source_root.join(rustdoc));
|
||||
cmd.env("RUSTDOC", rustdoc);
|
||||
}
|
||||
|
||||
if let Some(ref node) = self.config.nodejs {
|
||||
|
|
|
|||
|
|
@ -17,9 +17,10 @@ impl TestCx<'_> {
|
|||
if self.props.check_test_line_numbers_match {
|
||||
self.check_rustdoc_test_option(proc_res);
|
||||
} else {
|
||||
let root = self.config.find_rust_src_root().unwrap();
|
||||
let mut cmd = Command::new(&self.config.python);
|
||||
cmd.arg(root.join("src/etc/htmldocck.py")).arg(&out_dir).arg(&self.testpaths.file);
|
||||
cmd.arg(self.config.src_root.join("src/etc/htmldocck.py"))
|
||||
.arg(&out_dir)
|
||||
.arg(&self.testpaths.file);
|
||||
if self.config.bless {
|
||||
cmd.arg("--bless");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 7f3b207c4413c9d715fd54b36b8a8fd3179e0b67
|
||||
Subproject commit 5004a8f6f5d8468b64fae457afb7d96e1784c783
|
||||
|
|
@ -2,6 +2,7 @@
|
|||
name = "error_index_generator"
|
||||
version = "0.0.0"
|
||||
edition = "2021"
|
||||
workspace = "../rustbook"
|
||||
|
||||
[dependencies]
|
||||
mdbook = { version = "0.4", default-features = false, features = ["search"] }
|
||||
|
|
|
|||
|
|
@ -11,10 +11,6 @@ pub enum Error {
|
|||
Io(#[from] std::io::Error),
|
||||
#[error("Failed get output from cargo-metadata: {0:?}")]
|
||||
GettingMetadata(#[from] cargo_metadata::Error),
|
||||
#[error("Failed to run cargo vendor: {0:?}")]
|
||||
LaunchingVendor(std::io::Error),
|
||||
#[error("Failed to complete cargo vendor")]
|
||||
RunningVendor,
|
||||
#[error("Bad path {0:?} whilst scraping files")]
|
||||
Scraping(PathBuf),
|
||||
}
|
||||
|
|
@ -43,25 +39,19 @@ pub struct PackageMetadata {
|
|||
pub is_in_libstd: Option<bool>,
|
||||
}
|
||||
|
||||
/// Use `cargo metadata` and `cargo vendor` to get a list of dependencies and their license data.
|
||||
/// Use `cargo metadata` to get a list of dependencies and their license data. License files will
|
||||
/// also be pulled from the vendor path (generated by bootstrap).
|
||||
///
|
||||
/// This will involve running `cargo vendor` into `vendor_path` so we can
|
||||
/// grab the license files.
|
||||
///
|
||||
/// Any dependency with a path beginning with `root_path` is ignored, as we
|
||||
/// assume `reuse` has covered it already.
|
||||
/// Any dependency with a path beginning with `root_path` is ignored, as we assume `reuse` has
|
||||
/// covered it already.
|
||||
pub fn get_metadata_and_notices(
|
||||
cargo: &Path,
|
||||
vendor_path: &Path,
|
||||
root_path: &Path,
|
||||
manifest_paths: &[&Path],
|
||||
manifest_paths: &[PathBuf],
|
||||
) -> Result<BTreeMap<Package, PackageMetadata>, Error> {
|
||||
let mut output = get_metadata(cargo, root_path, manifest_paths)?;
|
||||
|
||||
// Now do a cargo-vendor and grab everything
|
||||
println!("Vendoring deps into {}...", vendor_path.display());
|
||||
run_cargo_vendor(cargo, &vendor_path, manifest_paths)?;
|
||||
|
||||
// Now for each dependency we found, go and grab any important looking files
|
||||
for (package, metadata) in output.iter_mut() {
|
||||
load_important_files(package, metadata, &vendor_path)?;
|
||||
|
|
@ -77,7 +67,7 @@ pub fn get_metadata_and_notices(
|
|||
pub fn get_metadata(
|
||||
cargo: &Path,
|
||||
root_path: &Path,
|
||||
manifest_paths: &[&Path],
|
||||
manifest_paths: &[PathBuf],
|
||||
) -> Result<BTreeMap<Package, PackageMetadata>, Error> {
|
||||
let mut output = BTreeMap::new();
|
||||
// Look at the metadata for each manifest
|
||||
|
|
@ -113,28 +103,6 @@ pub fn get_metadata(
|
|||
Ok(output)
|
||||
}
|
||||
|
||||
/// Run cargo-vendor, fetching into the given dir
|
||||
fn run_cargo_vendor(cargo: &Path, dest: &Path, manifest_paths: &[&Path]) -> Result<(), Error> {
|
||||
let mut vendor_command = std::process::Command::new(cargo);
|
||||
vendor_command.env("RUSTC_BOOTSTRAP", "1");
|
||||
vendor_command.arg("vendor");
|
||||
vendor_command.arg("--quiet");
|
||||
vendor_command.arg("--versioned-dirs");
|
||||
for manifest_path in manifest_paths {
|
||||
vendor_command.arg("-s");
|
||||
vendor_command.arg(manifest_path);
|
||||
}
|
||||
vendor_command.arg(dest);
|
||||
|
||||
let vendor_status = vendor_command.status().map_err(Error::LaunchingVendor)?;
|
||||
|
||||
if !vendor_status.success() {
|
||||
return Err(Error::RunningVendor);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Add important files off disk into this dependency.
|
||||
///
|
||||
/// Maybe one-day Cargo.toml will contain enough information that we don't need
|
||||
|
|
|
|||
|
|
@ -17,29 +17,36 @@ mod cargo_metadata;
|
|||
fn main() -> Result<(), Error> {
|
||||
let dest_file = env_path("DEST")?;
|
||||
let libstd_dest_file = env_path("DEST_LIBSTD")?;
|
||||
let out_dir = env_path("OUT_DIR")?;
|
||||
let src_dir = env_path("SRC_DIR")?;
|
||||
let vendor_dir = env_path("VENDOR_DIR")?;
|
||||
let cargo = env_path("CARGO")?;
|
||||
let license_metadata = env_path("LICENSE_METADATA")?;
|
||||
|
||||
let root_path = std::path::absolute(".")?;
|
||||
let cargo_manifests = env_string("CARGO_MANIFESTS")?
|
||||
.split(",")
|
||||
.map(|manifest| manifest.into())
|
||||
.collect::<Vec<PathBuf>>();
|
||||
let library_manifests = cargo_manifests
|
||||
.iter()
|
||||
.filter(|path| {
|
||||
if let Ok(stripped) = path.strip_prefix(&src_dir) {
|
||||
stripped.starts_with("library")
|
||||
} else {
|
||||
panic!("manifest {path:?} not relative to source dir {src_dir:?}");
|
||||
}
|
||||
})
|
||||
.cloned()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
// Scan Cargo dependencies
|
||||
let mut collected_cargo_metadata = cargo_metadata::get_metadata_and_notices(
|
||||
&cargo,
|
||||
&out_dir.join("vendor"),
|
||||
&root_path,
|
||||
&[
|
||||
Path::new("./Cargo.toml"),
|
||||
Path::new("./src/tools/cargo/Cargo.toml"),
|
||||
Path::new("./library/Cargo.toml"),
|
||||
],
|
||||
)?;
|
||||
let mut collected_cargo_metadata =
|
||||
cargo_metadata::get_metadata_and_notices(&cargo, &vendor_dir, &src_dir, &cargo_manifests)?;
|
||||
|
||||
let library_collected_cargo_metadata = cargo_metadata::get_metadata_and_notices(
|
||||
&cargo,
|
||||
&out_dir.join("library-vendor"),
|
||||
&root_path,
|
||||
&[Path::new("./library/Cargo.toml")],
|
||||
&vendor_dir,
|
||||
&src_dir,
|
||||
&library_manifests,
|
||||
)?;
|
||||
|
||||
for (key, value) in collected_cargo_metadata.iter_mut() {
|
||||
|
|
@ -54,7 +61,7 @@ fn main() -> Result<(), Error> {
|
|||
let library_collected_tree_metadata = Metadata {
|
||||
files: collected_tree_metadata
|
||||
.files
|
||||
.trim_clone(&Path::new("./library"), &Path::new("."))
|
||||
.trim_clone(&src_dir.join("library"), &src_dir)
|
||||
.unwrap(),
|
||||
};
|
||||
|
||||
|
|
@ -193,6 +200,17 @@ struct License {
|
|||
copyright: Vec<String>,
|
||||
}
|
||||
|
||||
/// Grab an environment variable as string, or fail nicely.
|
||||
fn env_string(var: &str) -> Result<String, Error> {
|
||||
match std::env::var(var) {
|
||||
Ok(var) => Ok(var),
|
||||
Err(std::env::VarError::NotUnicode(_)) => {
|
||||
anyhow::bail!("environment variable {var} is not utf-8")
|
||||
}
|
||||
Err(std::env::VarError::NotPresent) => anyhow::bail!("missing environment variable {var}"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Grab an environment variable as a PathBuf, or fail nicely.
|
||||
fn env_path(var: &str) -> Result<PathBuf, Error> {
|
||||
if let Some(var) = std::env::var_os(var) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ pub struct Args {
|
|||
#[arg(long)]
|
||||
target_cpu: Option<String>,
|
||||
|
||||
/// The target features
|
||||
#[arg(long)]
|
||||
target_feature: Option<String>,
|
||||
|
||||
/// Write output to the filename
|
||||
#[arg(short, long)]
|
||||
output: PathBuf,
|
||||
|
|
@ -49,7 +53,7 @@ fn main() -> anyhow::Result<()> {
|
|||
|
||||
let args = Args::parse();
|
||||
|
||||
let mut linker = Session::new(args.target, args.target_cpu, args.output);
|
||||
let mut linker = Session::new(args.target, args.target_cpu, args.target_feature, args.output);
|
||||
|
||||
linker.add_exported_symbols(args.export_symbol);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use crate::{Optimization, Target};
|
|||
pub struct Session {
|
||||
target: Target,
|
||||
cpu: Option<String>,
|
||||
feature: Option<String>,
|
||||
symbols: Vec<String>,
|
||||
|
||||
/// A file that `llvm-link` supports, like a bitcode file or an archive.
|
||||
|
|
@ -21,7 +22,12 @@ pub struct Session {
|
|||
}
|
||||
|
||||
impl Session {
|
||||
pub fn new(target: crate::Target, cpu: Option<String>, out_path: PathBuf) -> Self {
|
||||
pub fn new(
|
||||
target: crate::Target,
|
||||
cpu: Option<String>,
|
||||
feature: Option<String>,
|
||||
out_path: PathBuf,
|
||||
) -> Self {
|
||||
let link_path = out_path.with_extension("o");
|
||||
let opt_path = out_path.with_extension("optimized.o");
|
||||
let sym_path = out_path.with_extension("symbols.txt");
|
||||
|
|
@ -29,6 +35,7 @@ impl Session {
|
|||
Session {
|
||||
target,
|
||||
cpu,
|
||||
feature,
|
||||
symbols: Vec::new(),
|
||||
files: Vec::new(),
|
||||
link_path,
|
||||
|
|
@ -134,6 +141,10 @@ impl Session {
|
|||
lcc_command.arg("--mcpu").arg(mcpu);
|
||||
}
|
||||
|
||||
if let Some(mattr) = &self.feature {
|
||||
lcc_command.arg(&format!("--mattr={}", mattr));
|
||||
}
|
||||
|
||||
let lcc_output = lcc_command
|
||||
.arg(&self.opt_path)
|
||||
.arg("-o").arg(&self.out_path)
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
this.write_scalar(Scalar::from_bool(branch), dest)?;
|
||||
}
|
||||
|
||||
"floorf16" | "ceilf16" | "truncf16" | "roundf16" | "rintf16" => {
|
||||
"floorf16" | "ceilf16" | "truncf16" | "roundf16" | "round_ties_even_f16" => {
|
||||
let [f] = check_arg_count(args)?;
|
||||
let f = this.read_scalar(f)?.to_f16()?;
|
||||
let mode = match intrinsic_name {
|
||||
|
|
@ -153,14 +153,14 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
"ceilf16" => Round::TowardPositive,
|
||||
"truncf16" => Round::TowardZero,
|
||||
"roundf16" => Round::NearestTiesToAway,
|
||||
"rintf16" => Round::NearestTiesToEven,
|
||||
"round_ties_even_f16" => Round::NearestTiesToEven,
|
||||
_ => bug!(),
|
||||
};
|
||||
let res = f.round_to_integral(mode).value;
|
||||
let res = this.adjust_nan(res, &[f]);
|
||||
this.write_scalar(res, dest)?;
|
||||
}
|
||||
"floorf32" | "ceilf32" | "truncf32" | "roundf32" | "rintf32" => {
|
||||
"floorf32" | "ceilf32" | "truncf32" | "roundf32" | "round_ties_even_f32" => {
|
||||
let [f] = check_arg_count(args)?;
|
||||
let f = this.read_scalar(f)?.to_f32()?;
|
||||
let mode = match intrinsic_name {
|
||||
|
|
@ -168,14 +168,14 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
"ceilf32" => Round::TowardPositive,
|
||||
"truncf32" => Round::TowardZero,
|
||||
"roundf32" => Round::NearestTiesToAway,
|
||||
"rintf32" => Round::NearestTiesToEven,
|
||||
"round_ties_even_f32" => Round::NearestTiesToEven,
|
||||
_ => bug!(),
|
||||
};
|
||||
let res = f.round_to_integral(mode).value;
|
||||
let res = this.adjust_nan(res, &[f]);
|
||||
this.write_scalar(res, dest)?;
|
||||
}
|
||||
"floorf64" | "ceilf64" | "truncf64" | "roundf64" | "rintf64" => {
|
||||
"floorf64" | "ceilf64" | "truncf64" | "roundf64" | "round_ties_even_f64" => {
|
||||
let [f] = check_arg_count(args)?;
|
||||
let f = this.read_scalar(f)?.to_f64()?;
|
||||
let mode = match intrinsic_name {
|
||||
|
|
@ -183,14 +183,14 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
"ceilf64" => Round::TowardPositive,
|
||||
"truncf64" => Round::TowardZero,
|
||||
"roundf64" => Round::NearestTiesToAway,
|
||||
"rintf64" => Round::NearestTiesToEven,
|
||||
"round_ties_even_f64" => Round::NearestTiesToEven,
|
||||
_ => bug!(),
|
||||
};
|
||||
let res = f.round_to_integral(mode).value;
|
||||
let res = this.adjust_nan(res, &[f]);
|
||||
this.write_scalar(res, dest)?;
|
||||
}
|
||||
"floorf128" | "ceilf128" | "truncf128" | "roundf128" | "rintf128" => {
|
||||
"floorf128" | "ceilf128" | "truncf128" | "roundf128" | "round_ties_even_f128" => {
|
||||
let [f] = check_arg_count(args)?;
|
||||
let f = this.read_scalar(f)?.to_f128()?;
|
||||
let mode = match intrinsic_name {
|
||||
|
|
@ -198,7 +198,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
|
|||
"ceilf128" => Round::TowardPositive,
|
||||
"truncf128" => Round::TowardZero,
|
||||
"roundf128" => Round::NearestTiesToAway,
|
||||
"rintf128" => Round::NearestTiesToEven,
|
||||
"round_ties_even_f128" => Round::NearestTiesToEven,
|
||||
_ => bug!(),
|
||||
};
|
||||
let res = f.round_to_integral(mode).value;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue