]> git.lizzy.rs Git - rust.git/commitdiff
Just lint changes
authorAlex <blyxyas@gmail.com>
Fri, 21 Oct 2022 17:46:47 +0000 (19:46 +0200)
committerAlex <blyxyas@gmail.com>
Tue, 25 Oct 2022 18:30:37 +0000 (20:30 +0200)
CHANGELOG.md
clippy_lints/src/lib.register_lints.rs [new file with mode: 0644]
clippy_lints/src/lib.register_restriction.rs [new file with mode: 0644]
clippy_lints/src/lib.rs
clippy_lints/src/suspicious_xor_used_as_pow.rs [new file with mode: 0644]
src/docs.rs [new file with mode: 0644]
src/docs/suspicious_xor_used_as_pow.txt [new file with mode: 0644]
tests/ui/eq_op.rs
tests/ui/eq_op.stderr
tests/ui/suspicious_xor_used_as_pow.rs [new file with mode: 0644]
tests/ui/suspicious_xor_used_as_pow.stderr [new file with mode: 0644]

index 7e91365c69a3b2f542661eccc745f0bd2274dd5a..10111be596aee8c6511cdea0f813b899c32cc75f 100644 (file)
@@ -4250,6 +4250,7 @@ Released 2018-09-13
 [`suspicious_splitn`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_splitn
 [`suspicious_to_owned`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_to_owned
 [`suspicious_unary_op_formatting`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_unary_op_formatting
+[`suspicious_xor_used_as_pow`]: https://rust-lang.github.io/rust-clippy/master/index.html#suspicious_xor_used_as_pow
 [`swap_ptr_to_ref`]: https://rust-lang.github.io/rust-clippy/master/index.html#swap_ptr_to_ref
 [`tabs_in_doc_comments`]: https://rust-lang.github.io/rust-clippy/master/index.html#tabs_in_doc_comments
 [`temporary_assignment`]: https://rust-lang.github.io/rust-clippy/master/index.html#temporary_assignment
diff --git a/clippy_lints/src/lib.register_lints.rs b/clippy_lints/src/lib.register_lints.rs
new file mode 100644 (file)
index 0000000..3d4e05b
--- /dev/null
@@ -0,0 +1,621 @@
+// This file was generated by `cargo dev update_lints`.
+// Use that command to update this file and do not edit by hand.
+// Manual edits will be overwritten.
+
+store.register_lints(&[
+    #[cfg(feature = "internal")]
+    utils::internal_lints::clippy_lints_internal::CLIPPY_LINTS_INTERNAL,
+    #[cfg(feature = "internal")]
+    utils::internal_lints::collapsible_calls::COLLAPSIBLE_SPAN_LINT_CALLS,
+    #[cfg(feature = "internal")]
+    utils::internal_lints::compiler_lint_functions::COMPILER_LINT_FUNCTIONS,
+    #[cfg(feature = "internal")]
+    utils::internal_lints::if_chain_style::IF_CHAIN_STYLE,
+    #[cfg(feature = "internal")]
+    utils::internal_lints::interning_defined_symbol::INTERNING_DEFINED_SYMBOL,
+    #[cfg(feature = "internal")]
+    utils::internal_lints::interning_defined_symbol::UNNECESSARY_SYMBOL_STR,
+    #[cfg(feature = "internal")]
+    utils::internal_lints::invalid_paths::INVALID_PATHS,
+    #[cfg(feature = "internal")]
+    utils::internal_lints::lint_without_lint_pass::DEFAULT_DEPRECATION_REASON,
+    #[cfg(feature = "internal")]
+    utils::internal_lints::lint_without_lint_pass::DEFAULT_LINT,
+    #[cfg(feature = "internal")]
+    utils::internal_lints::lint_without_lint_pass::INVALID_CLIPPY_VERSION_ATTRIBUTE,
+    #[cfg(feature = "internal")]
+    utils::internal_lints::lint_without_lint_pass::LINT_WITHOUT_LINT_PASS,
+    #[cfg(feature = "internal")]
+    utils::internal_lints::lint_without_lint_pass::MISSING_CLIPPY_VERSION_ATTRIBUTE,
+    #[cfg(feature = "internal")]
+    utils::internal_lints::msrv_attr_impl::MISSING_MSRV_ATTR_IMPL,
+    #[cfg(feature = "internal")]
+    utils::internal_lints::outer_expn_data_pass::OUTER_EXPN_EXPN_DATA,
+    #[cfg(feature = "internal")]
+    utils::internal_lints::produce_ice::PRODUCE_ICE,
+    #[cfg(feature = "internal")]
+    utils::internal_lints::unnecessary_def_path::UNNECESSARY_DEF_PATH,
+    almost_complete_letter_range::ALMOST_COMPLETE_LETTER_RANGE,
+    approx_const::APPROX_CONSTANT,
+    as_conversions::AS_CONVERSIONS,
+    asm_syntax::INLINE_ASM_X86_ATT_SYNTAX,
+    asm_syntax::INLINE_ASM_X86_INTEL_SYNTAX,
+    assertions_on_constants::ASSERTIONS_ON_CONSTANTS,
+    assertions_on_result_states::ASSERTIONS_ON_RESULT_STATES,
+    async_yields_async::ASYNC_YIELDS_ASYNC,
+    attrs::ALLOW_ATTRIBUTES_WITHOUT_REASON,
+    attrs::BLANKET_CLIPPY_RESTRICTION_LINTS,
+    attrs::DEPRECATED_CFG_ATTR,
+    attrs::DEPRECATED_SEMVER,
+    attrs::EMPTY_LINE_AFTER_OUTER_ATTR,
+    attrs::INLINE_ALWAYS,
+    attrs::MISMATCHED_TARGET_OS,
+    attrs::USELESS_ATTRIBUTE,
+    await_holding_invalid::AWAIT_HOLDING_INVALID_TYPE,
+    await_holding_invalid::AWAIT_HOLDING_LOCK,
+    await_holding_invalid::AWAIT_HOLDING_REFCELL_REF,
+    blocks_in_if_conditions::BLOCKS_IN_IF_CONDITIONS,
+    bool_assert_comparison::BOOL_ASSERT_COMPARISON,
+    bool_to_int_with_if::BOOL_TO_INT_WITH_IF,
+    booleans::NONMINIMAL_BOOL,
+    booleans::OVERLY_COMPLEX_BOOL_EXPR,
+    borrow_deref_ref::BORROW_DEREF_REF,
+    box_default::BOX_DEFAULT,
+    cargo::CARGO_COMMON_METADATA,
+    cargo::MULTIPLE_CRATE_VERSIONS,
+    cargo::NEGATIVE_FEATURE_NAMES,
+    cargo::REDUNDANT_FEATURE_NAMES,
+    cargo::WILDCARD_DEPENDENCIES,
+    casts::AS_PTR_CAST_MUT,
+    casts::AS_UNDERSCORE,
+    casts::BORROW_AS_PTR,
+    casts::CAST_ABS_TO_UNSIGNED,
+    casts::CAST_ENUM_CONSTRUCTOR,
+    casts::CAST_ENUM_TRUNCATION,
+    casts::CAST_LOSSLESS,
+    casts::CAST_NAN_TO_INT,
+    casts::CAST_POSSIBLE_TRUNCATION,
+    casts::CAST_POSSIBLE_WRAP,
+    casts::CAST_PRECISION_LOSS,
+    casts::CAST_PTR_ALIGNMENT,
+    casts::CAST_REF_TO_MUT,
+    casts::CAST_SIGN_LOSS,
+    casts::CAST_SLICE_DIFFERENT_SIZES,
+    casts::CAST_SLICE_FROM_RAW_PARTS,
+    casts::CHAR_LIT_AS_U8,
+    casts::FN_TO_NUMERIC_CAST,
+    casts::FN_TO_NUMERIC_CAST_ANY,
+    casts::FN_TO_NUMERIC_CAST_WITH_TRUNCATION,
+    casts::PTR_AS_PTR,
+    casts::UNNECESSARY_CAST,
+    checked_conversions::CHECKED_CONVERSIONS,
+    cognitive_complexity::COGNITIVE_COMPLEXITY,
+    collapsible_if::COLLAPSIBLE_ELSE_IF,
+    collapsible_if::COLLAPSIBLE_IF,
+    comparison_chain::COMPARISON_CHAIN,
+    copies::BRANCHES_SHARING_CODE,
+    copies::IFS_SAME_COND,
+    copies::IF_SAME_THEN_ELSE,
+    copies::SAME_FUNCTIONS_IN_IF_CONDITION,
+    copy_iterator::COPY_ITERATOR,
+    crate_in_macro_def::CRATE_IN_MACRO_DEF,
+    create_dir::CREATE_DIR,
+    dbg_macro::DBG_MACRO,
+    default::DEFAULT_TRAIT_ACCESS,
+    default::FIELD_REASSIGN_WITH_DEFAULT,
+    default_instead_of_iter_empty::DEFAULT_INSTEAD_OF_ITER_EMPTY,
+    default_numeric_fallback::DEFAULT_NUMERIC_FALLBACK,
+    default_union_representation::DEFAULT_UNION_REPRESENTATION,
+    dereference::EXPLICIT_AUTO_DEREF,
+    dereference::EXPLICIT_DEREF_METHODS,
+    dereference::NEEDLESS_BORROW,
+    dereference::REF_BINDING_TO_REFERENCE,
+    derivable_impls::DERIVABLE_IMPLS,
+    derive::DERIVE_HASH_XOR_EQ,
+    derive::DERIVE_ORD_XOR_PARTIAL_ORD,
+    derive::DERIVE_PARTIAL_EQ_WITHOUT_EQ,
+    derive::EXPL_IMPL_CLONE_ON_COPY,
+    derive::UNSAFE_DERIVE_DESERIALIZE,
+    disallowed_macros::DISALLOWED_MACROS,
+    disallowed_methods::DISALLOWED_METHODS,
+    disallowed_names::DISALLOWED_NAMES,
+    disallowed_script_idents::DISALLOWED_SCRIPT_IDENTS,
+    disallowed_types::DISALLOWED_TYPES,
+    doc::DOC_LINK_WITH_QUOTES,
+    doc::DOC_MARKDOWN,
+    doc::MISSING_ERRORS_DOC,
+    doc::MISSING_PANICS_DOC,
+    doc::MISSING_SAFETY_DOC,
+    doc::NEEDLESS_DOCTEST_MAIN,
+    double_parens::DOUBLE_PARENS,
+    drop_forget_ref::DROP_COPY,
+    drop_forget_ref::DROP_NON_DROP,
+    drop_forget_ref::DROP_REF,
+    drop_forget_ref::FORGET_COPY,
+    drop_forget_ref::FORGET_NON_DROP,
+    drop_forget_ref::FORGET_REF,
+    drop_forget_ref::UNDROPPED_MANUALLY_DROPS,
+    duplicate_mod::DUPLICATE_MOD,
+    else_if_without_else::ELSE_IF_WITHOUT_ELSE,
+    empty_drop::EMPTY_DROP,
+    empty_enum::EMPTY_ENUM,
+    empty_structs_with_brackets::EMPTY_STRUCTS_WITH_BRACKETS,
+    entry::MAP_ENTRY,
+    enum_clike::ENUM_CLIKE_UNPORTABLE_VARIANT,
+    enum_variants::ENUM_VARIANT_NAMES,
+    enum_variants::MODULE_INCEPTION,
+    enum_variants::MODULE_NAME_REPETITIONS,
+    equatable_if_let::EQUATABLE_IF_LET,
+    escape::BOXED_LOCAL,
+    eta_reduction::REDUNDANT_CLOSURE,
+    eta_reduction::REDUNDANT_CLOSURE_FOR_METHOD_CALLS,
+    excessive_bools::FN_PARAMS_EXCESSIVE_BOOLS,
+    excessive_bools::STRUCT_EXCESSIVE_BOOLS,
+    exhaustive_items::EXHAUSTIVE_ENUMS,
+    exhaustive_items::EXHAUSTIVE_STRUCTS,
+    exit::EXIT,
+    explicit_write::EXPLICIT_WRITE,
+    fallible_impl_from::FALLIBLE_IMPL_FROM,
+    float_literal::EXCESSIVE_PRECISION,
+    float_literal::LOSSY_FLOAT_LITERAL,
+    floating_point_arithmetic::IMPRECISE_FLOPS,
+    floating_point_arithmetic::SUBOPTIMAL_FLOPS,
+    format::USELESS_FORMAT,
+    format_args::FORMAT_IN_FORMAT_ARGS,
+    format_args::TO_STRING_IN_FORMAT_ARGS,
+    format_args::UNINLINED_FORMAT_ARGS,
+    format_args::UNUSED_FORMAT_SPECS,
+    format_impl::PRINT_IN_FORMAT_IMPL,
+    format_impl::RECURSIVE_FORMAT_IMPL,
+    format_push_string::FORMAT_PUSH_STRING,
+    formatting::POSSIBLE_MISSING_COMMA,
+    formatting::SUSPICIOUS_ASSIGNMENT_FORMATTING,
+    formatting::SUSPICIOUS_ELSE_FORMATTING,
+    formatting::SUSPICIOUS_UNARY_OP_FORMATTING,
+    from_over_into::FROM_OVER_INTO,
+    from_str_radix_10::FROM_STR_RADIX_10,
+    functions::DOUBLE_MUST_USE,
+    functions::MUST_USE_CANDIDATE,
+    functions::MUST_USE_UNIT,
+    functions::NOT_UNSAFE_PTR_ARG_DEREF,
+    functions::RESULT_LARGE_ERR,
+    functions::RESULT_UNIT_ERR,
+    functions::TOO_MANY_ARGUMENTS,
+    functions::TOO_MANY_LINES,
+    future_not_send::FUTURE_NOT_SEND,
+    if_let_mutex::IF_LET_MUTEX,
+    if_not_else::IF_NOT_ELSE,
+    if_then_some_else_none::IF_THEN_SOME_ELSE_NONE,
+    implicit_hasher::IMPLICIT_HASHER,
+    implicit_return::IMPLICIT_RETURN,
+    implicit_saturating_add::IMPLICIT_SATURATING_ADD,
+    implicit_saturating_sub::IMPLICIT_SATURATING_SUB,
+    inconsistent_struct_constructor::INCONSISTENT_STRUCT_CONSTRUCTOR,
+    index_refutable_slice::INDEX_REFUTABLE_SLICE,
+    indexing_slicing::INDEXING_SLICING,
+    indexing_slicing::OUT_OF_BOUNDS_INDEXING,
+    infinite_iter::INFINITE_ITER,
+    infinite_iter::MAYBE_INFINITE_ITER,
+    inherent_impl::MULTIPLE_INHERENT_IMPL,
+    inherent_to_string::INHERENT_TO_STRING,
+    inherent_to_string::INHERENT_TO_STRING_SHADOW_DISPLAY,
+    init_numbered_fields::INIT_NUMBERED_FIELDS,
+    inline_fn_without_body::INLINE_FN_WITHOUT_BODY,
+    int_plus_one::INT_PLUS_ONE,
+    invalid_upcast_comparisons::INVALID_UPCAST_COMPARISONS,
+    invalid_utf8_in_unchecked::INVALID_UTF8_IN_UNCHECKED,
+    items_after_statements::ITEMS_AFTER_STATEMENTS,
+    iter_not_returning_iterator::ITER_NOT_RETURNING_ITERATOR,
+    large_const_arrays::LARGE_CONST_ARRAYS,
+    large_enum_variant::LARGE_ENUM_VARIANT,
+    large_include_file::LARGE_INCLUDE_FILE,
+    large_stack_arrays::LARGE_STACK_ARRAYS,
+    len_zero::COMPARISON_TO_EMPTY,
+    len_zero::LEN_WITHOUT_IS_EMPTY,
+    len_zero::LEN_ZERO,
+    let_if_seq::USELESS_LET_IF_SEQ,
+    let_underscore::LET_UNDERSCORE_DROP,
+    let_underscore::LET_UNDERSCORE_LOCK,
+    let_underscore::LET_UNDERSCORE_MUST_USE,
+    lifetimes::EXTRA_UNUSED_LIFETIMES,
+    lifetimes::NEEDLESS_LIFETIMES,
+    literal_representation::DECIMAL_LITERAL_REPRESENTATION,
+    literal_representation::INCONSISTENT_DIGIT_GROUPING,
+    literal_representation::LARGE_DIGIT_GROUPS,
+    literal_representation::MISTYPED_LITERAL_SUFFIXES,
+    literal_representation::UNREADABLE_LITERAL,
+    literal_representation::UNUSUAL_BYTE_GROUPINGS,
+    loops::EMPTY_LOOP,
+    loops::EXPLICIT_COUNTER_LOOP,
+    loops::EXPLICIT_INTO_ITER_LOOP,
+    loops::EXPLICIT_ITER_LOOP,
+    loops::FOR_KV_MAP,
+    loops::ITER_NEXT_LOOP,
+    loops::MANUAL_FIND,
+    loops::MANUAL_FLATTEN,
+    loops::MANUAL_MEMCPY,
+    loops::MISSING_SPIN_LOOP,
+    loops::MUT_RANGE_BOUND,
+    loops::NEEDLESS_COLLECT,
+    loops::NEEDLESS_RANGE_LOOP,
+    loops::NEVER_LOOP,
+    loops::SAME_ITEM_PUSH,
+    loops::SINGLE_ELEMENT_LOOP,
+    loops::WHILE_IMMUTABLE_CONDITION,
+    loops::WHILE_LET_LOOP,
+    loops::WHILE_LET_ON_ITERATOR,
+    macro_use::MACRO_USE_IMPORTS,
+    main_recursion::MAIN_RECURSION,
+    manual_assert::MANUAL_ASSERT,
+    manual_async_fn::MANUAL_ASYNC_FN,
+    manual_bits::MANUAL_BITS,
+    manual_clamp::MANUAL_CLAMP,
+    manual_instant_elapsed::MANUAL_INSTANT_ELAPSED,
+    manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE,
+    manual_rem_euclid::MANUAL_REM_EUCLID,
+    manual_retain::MANUAL_RETAIN,
+    manual_string_new::MANUAL_STRING_NEW,
+    manual_strip::MANUAL_STRIP,
+    map_unit_fn::OPTION_MAP_UNIT_FN,
+    map_unit_fn::RESULT_MAP_UNIT_FN,
+    match_result_ok::MATCH_RESULT_OK,
+    matches::COLLAPSIBLE_MATCH,
+    matches::INFALLIBLE_DESTRUCTURING_MATCH,
+    matches::MANUAL_FILTER,
+    matches::MANUAL_MAP,
+    matches::MANUAL_UNWRAP_OR,
+    matches::MATCH_AS_REF,
+    matches::MATCH_BOOL,
+    matches::MATCH_LIKE_MATCHES_MACRO,
+    matches::MATCH_ON_VEC_ITEMS,
+    matches::MATCH_OVERLAPPING_ARM,
+    matches::MATCH_REF_PATS,
+    matches::MATCH_SAME_ARMS,
+    matches::MATCH_SINGLE_BINDING,
+    matches::MATCH_STR_CASE_MISMATCH,
+    matches::MATCH_WILDCARD_FOR_SINGLE_VARIANTS,
+    matches::MATCH_WILD_ERR_ARM,
+    matches::NEEDLESS_MATCH,
+    matches::REDUNDANT_PATTERN_MATCHING,
+    matches::REST_PAT_IN_FULLY_BOUND_STRUCTS,
+    matches::SIGNIFICANT_DROP_IN_SCRUTINEE,
+    matches::SINGLE_MATCH,
+    matches::SINGLE_MATCH_ELSE,
+    matches::TRY_ERR,
+    matches::WILDCARD_ENUM_MATCH_ARM,
+    matches::WILDCARD_IN_OR_PATTERNS,
+    mem_forget::MEM_FORGET,
+    mem_replace::MEM_REPLACE_OPTION_WITH_NONE,
+    mem_replace::MEM_REPLACE_WITH_DEFAULT,
+    mem_replace::MEM_REPLACE_WITH_UNINIT,
+    methods::BIND_INSTEAD_OF_MAP,
+    methods::BYTES_COUNT_TO_LEN,
+    methods::BYTES_NTH,
+    methods::CASE_SENSITIVE_FILE_EXTENSION_COMPARISONS,
+    methods::CHARS_LAST_CMP,
+    methods::CHARS_NEXT_CMP,
+    methods::CLONED_INSTEAD_OF_COPIED,
+    methods::CLONE_DOUBLE_REF,
+    methods::CLONE_ON_COPY,
+    methods::CLONE_ON_REF_PTR,
+    methods::COLLAPSIBLE_STR_REPLACE,
+    methods::ERR_EXPECT,
+    methods::EXPECT_FUN_CALL,
+    methods::EXPECT_USED,
+    methods::EXTEND_WITH_DRAIN,
+    methods::FILETYPE_IS_FILE,
+    methods::FILTER_MAP_IDENTITY,
+    methods::FILTER_MAP_NEXT,
+    methods::FILTER_NEXT,
+    methods::FLAT_MAP_IDENTITY,
+    methods::FLAT_MAP_OPTION,
+    methods::FROM_ITER_INSTEAD_OF_COLLECT,
+    methods::GET_FIRST,
+    methods::GET_LAST_WITH_LEN,
+    methods::GET_UNWRAP,
+    methods::IMPLICIT_CLONE,
+    methods::INEFFICIENT_TO_STRING,
+    methods::INSPECT_FOR_EACH,
+    methods::INTO_ITER_ON_REF,
+    methods::IS_DIGIT_ASCII_RADIX,
+    methods::ITERATOR_STEP_BY_ZERO,
+    methods::ITER_CLONED_COLLECT,
+    methods::ITER_COUNT,
+    methods::ITER_KV_MAP,
+    methods::ITER_NEXT_SLICE,
+    methods::ITER_NTH,
+    methods::ITER_NTH_ZERO,
+    methods::ITER_ON_EMPTY_COLLECTIONS,
+    methods::ITER_ON_SINGLE_ITEMS,
+    methods::ITER_OVEREAGER_CLONED,
+    methods::ITER_SKIP_NEXT,
+    methods::ITER_WITH_DRAIN,
+    methods::MANUAL_FILTER_MAP,
+    methods::MANUAL_FIND_MAP,
+    methods::MANUAL_OK_OR,
+    methods::MANUAL_SATURATING_ARITHMETIC,
+    methods::MANUAL_SPLIT_ONCE,
+    methods::MANUAL_STR_REPEAT,
+    methods::MAP_CLONE,
+    methods::MAP_COLLECT_RESULT_UNIT,
+    methods::MAP_ERR_IGNORE,
+    methods::MAP_FLATTEN,
+    methods::MAP_IDENTITY,
+    methods::MAP_UNWRAP_OR,
+    methods::MUT_MUTEX_LOCK,
+    methods::NAIVE_BYTECOUNT,
+    methods::NEEDLESS_OPTION_AS_DEREF,
+    methods::NEEDLESS_OPTION_TAKE,
+    methods::NEEDLESS_SPLITN,
+    methods::NEW_RET_NO_SELF,
+    methods::NONSENSICAL_OPEN_OPTIONS,
+    methods::NO_EFFECT_REPLACE,
+    methods::OBFUSCATED_IF_ELSE,
+    methods::OK_EXPECT,
+    methods::OPTION_AS_REF_DEREF,
+    methods::OPTION_FILTER_MAP,
+    methods::OPTION_MAP_OR_NONE,
+    methods::OR_FUN_CALL,
+    methods::OR_THEN_UNWRAP,
+    methods::PATH_BUF_PUSH_OVERWRITE,
+    methods::RANGE_ZIP_WITH_LEN,
+    methods::REPEAT_ONCE,
+    methods::RESULT_MAP_OR_INTO_OPTION,
+    methods::SEARCH_IS_SOME,
+    methods::SHOULD_IMPLEMENT_TRAIT,
+    methods::SINGLE_CHAR_ADD_STR,
+    methods::SINGLE_CHAR_PATTERN,
+    methods::SKIP_WHILE_NEXT,
+    methods::STABLE_SORT_PRIMITIVE,
+    methods::STRING_EXTEND_CHARS,
+    methods::SUSPICIOUS_MAP,
+    methods::SUSPICIOUS_SPLITN,
+    methods::SUSPICIOUS_TO_OWNED,
+    methods::UNINIT_ASSUMED_INIT,
+    methods::UNIT_HASH,
+    methods::UNNECESSARY_FILTER_MAP,
+    methods::UNNECESSARY_FIND_MAP,
+    methods::UNNECESSARY_FOLD,
+    methods::UNNECESSARY_JOIN,
+    methods::UNNECESSARY_LAZY_EVALUATIONS,
+    methods::UNNECESSARY_SORT_BY,
+    methods::UNNECESSARY_TO_OWNED,
+    methods::UNWRAP_OR_ELSE_DEFAULT,
+    methods::UNWRAP_USED,
+    methods::USELESS_ASREF,
+    methods::VEC_RESIZE_TO_ZERO,
+    methods::VERBOSE_FILE_READS,
+    methods::WRONG_SELF_CONVENTION,
+    methods::ZST_OFFSET,
+    minmax::MIN_MAX,
+    misc::SHORT_CIRCUIT_STATEMENT,
+    misc::TOPLEVEL_REF_ARG,
+    misc::USED_UNDERSCORE_BINDING,
+    misc::ZERO_PTR,
+    misc_early::BUILTIN_TYPE_SHADOW,
+    misc_early::DOUBLE_NEG,
+    misc_early::DUPLICATE_UNDERSCORE_ARGUMENT,
+    misc_early::MIXED_CASE_HEX_LITERALS,
+    misc_early::REDUNDANT_PATTERN,
+    misc_early::SEPARATED_LITERAL_SUFFIX,
+    misc_early::UNNEEDED_FIELD_PATTERN,
+    misc_early::UNNEEDED_WILDCARD_PATTERN,
+    misc_early::UNSEPARATED_LITERAL_SUFFIX,
+    misc_early::ZERO_PREFIXED_LITERAL,
+    mismatching_type_param_order::MISMATCHING_TYPE_PARAM_ORDER,
+    missing_const_for_fn::MISSING_CONST_FOR_FN,
+    missing_doc::MISSING_DOCS_IN_PRIVATE_ITEMS,
+    missing_enforced_import_rename::MISSING_ENFORCED_IMPORT_RENAMES,
+    missing_inline::MISSING_INLINE_IN_PUBLIC_ITEMS,
+    missing_trait_methods::MISSING_TRAIT_METHODS,
+    mixed_read_write_in_expression::DIVERGING_SUB_EXPRESSION,
+    mixed_read_write_in_expression::MIXED_READ_WRITE_IN_EXPRESSION,
+    module_style::MOD_MODULE_FILES,
+    module_style::SELF_NAMED_MODULE_FILES,
+    multi_assignments::MULTI_ASSIGNMENTS,
+    mut_key::MUTABLE_KEY_TYPE,
+    mut_mut::MUT_MUT,
+    mut_reference::UNNECESSARY_MUT_PASSED,
+    mutable_debug_assertion::DEBUG_ASSERT_WITH_MUT_CALL,
+    mutex_atomic::MUTEX_ATOMIC,
+    mutex_atomic::MUTEX_INTEGER,
+    needless_arbitrary_self_type::NEEDLESS_ARBITRARY_SELF_TYPE,
+    needless_bool::BOOL_COMPARISON,
+    needless_bool::NEEDLESS_BOOL,
+    needless_borrowed_ref::NEEDLESS_BORROWED_REFERENCE,
+    needless_continue::NEEDLESS_CONTINUE,
+    needless_for_each::NEEDLESS_FOR_EACH,
+    needless_late_init::NEEDLESS_LATE_INIT,
+    needless_parens_on_range_literals::NEEDLESS_PARENS_ON_RANGE_LITERALS,
+    needless_pass_by_value::NEEDLESS_PASS_BY_VALUE,
+    needless_question_mark::NEEDLESS_QUESTION_MARK,
+    needless_update::NEEDLESS_UPDATE,
+    neg_cmp_op_on_partial_ord::NEG_CMP_OP_ON_PARTIAL_ORD,
+    neg_multiply::NEG_MULTIPLY,
+    new_without_default::NEW_WITHOUT_DEFAULT,
+    no_effect::NO_EFFECT,
+    no_effect::NO_EFFECT_UNDERSCORE_BINDING,
+    no_effect::UNNECESSARY_OPERATION,
+    non_copy_const::BORROW_INTERIOR_MUTABLE_CONST,
+    non_copy_const::DECLARE_INTERIOR_MUTABLE_CONST,
+    non_expressive_names::JUST_UNDERSCORES_AND_DIGITS,
+    non_expressive_names::MANY_SINGLE_CHAR_NAMES,
+    non_expressive_names::SIMILAR_NAMES,
+    non_octal_unix_permissions::NON_OCTAL_UNIX_PERMISSIONS,
+    non_send_fields_in_send_ty::NON_SEND_FIELDS_IN_SEND_TY,
+    nonstandard_macro_braces::NONSTANDARD_MACRO_BRACES,
+    octal_escapes::OCTAL_ESCAPES,
+    only_used_in_recursion::ONLY_USED_IN_RECURSION,
+    operators::ABSURD_EXTREME_COMPARISONS,
+    operators::ARITHMETIC_SIDE_EFFECTS,
+    operators::ASSIGN_OP_PATTERN,
+    operators::BAD_BIT_MASK,
+    operators::CMP_NAN,
+    operators::CMP_OWNED,
+    operators::DOUBLE_COMPARISONS,
+    operators::DURATION_SUBSEC,
+    operators::EQ_OP,
+    operators::ERASING_OP,
+    operators::FLOAT_ARITHMETIC,
+    operators::FLOAT_CMP,
+    operators::FLOAT_CMP_CONST,
+    operators::FLOAT_EQUALITY_WITHOUT_ABS,
+    operators::IDENTITY_OP,
+    operators::INEFFECTIVE_BIT_MASK,
+    operators::INTEGER_ARITHMETIC,
+    operators::INTEGER_DIVISION,
+    operators::MISREFACTORED_ASSIGN_OP,
+    operators::MODULO_ARITHMETIC,
+    operators::MODULO_ONE,
+    operators::NEEDLESS_BITWISE_BOOL,
+    operators::OP_REF,
+    operators::PTR_EQ,
+    operators::SELF_ASSIGNMENT,
+    operators::VERBOSE_BIT_MASK,
+    option_env_unwrap::OPTION_ENV_UNWRAP,
+    option_if_let_else::OPTION_IF_LET_ELSE,
+    overflow_check_conditional::OVERFLOW_CHECK_CONDITIONAL,
+    panic_in_result_fn::PANIC_IN_RESULT_FN,
+    panic_unimplemented::PANIC,
+    panic_unimplemented::TODO,
+    panic_unimplemented::UNIMPLEMENTED,
+    panic_unimplemented::UNREACHABLE,
+    partial_pub_fields::PARTIAL_PUB_FIELDS,
+    partialeq_ne_impl::PARTIALEQ_NE_IMPL,
+    partialeq_to_none::PARTIALEQ_TO_NONE,
+    pass_by_ref_or_value::LARGE_TYPES_PASSED_BY_VALUE,
+    pass_by_ref_or_value::TRIVIALLY_COPY_PASS_BY_REF,
+    pattern_type_mismatch::PATTERN_TYPE_MISMATCH,
+    precedence::PRECEDENCE,
+    ptr::CMP_NULL,
+    ptr::INVALID_NULL_PTR_USAGE,
+    ptr::MUT_FROM_REF,
+    ptr::PTR_ARG,
+    ptr_offset_with_cast::PTR_OFFSET_WITH_CAST,
+    pub_use::PUB_USE,
+    question_mark::QUESTION_MARK,
+    ranges::MANUAL_RANGE_CONTAINS,
+    ranges::RANGE_MINUS_ONE,
+    ranges::RANGE_PLUS_ONE,
+    ranges::REVERSED_EMPTY_RANGES,
+    rc_clone_in_vec_init::RC_CLONE_IN_VEC_INIT,
+    read_zero_byte_vec::READ_ZERO_BYTE_VEC,
+    redundant_clone::REDUNDANT_CLONE,
+    redundant_closure_call::REDUNDANT_CLOSURE_CALL,
+    redundant_else::REDUNDANT_ELSE,
+    redundant_field_names::REDUNDANT_FIELD_NAMES,
+    redundant_pub_crate::REDUNDANT_PUB_CRATE,
+    redundant_slicing::DEREF_BY_SLICING,
+    redundant_slicing::REDUNDANT_SLICING,
+    redundant_static_lifetimes::REDUNDANT_STATIC_LIFETIMES,
+    ref_option_ref::REF_OPTION_REF,
+    reference::DEREF_ADDROF,
+    regex::INVALID_REGEX,
+    regex::TRIVIAL_REGEX,
+    return_self_not_must_use::RETURN_SELF_NOT_MUST_USE,
+    returns::LET_AND_RETURN,
+    returns::NEEDLESS_RETURN,
+    same_name_method::SAME_NAME_METHOD,
+    self_named_constructors::SELF_NAMED_CONSTRUCTORS,
+    semicolon_if_nothing_returned::SEMICOLON_IF_NOTHING_RETURNED,
+    serde_api::SERDE_API_MISUSE,
+    shadow::SHADOW_REUSE,
+    shadow::SHADOW_SAME,
+    shadow::SHADOW_UNRELATED,
+    single_char_lifetime_names::SINGLE_CHAR_LIFETIME_NAMES,
+    single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS,
+    size_of_in_element_count::SIZE_OF_IN_ELEMENT_COUNT,
+    slow_vector_initialization::SLOW_VECTOR_INITIALIZATION,
+    std_instead_of_core::ALLOC_INSTEAD_OF_CORE,
+    std_instead_of_core::STD_INSTEAD_OF_ALLOC,
+    std_instead_of_core::STD_INSTEAD_OF_CORE,
+    strings::STRING_ADD,
+    strings::STRING_ADD_ASSIGN,
+    strings::STRING_FROM_UTF8_AS_BYTES,
+    strings::STRING_LIT_AS_BYTES,
+    strings::STRING_SLICE,
+    strings::STRING_TO_STRING,
+    strings::STR_TO_STRING,
+    strings::TRIM_SPLIT_WHITESPACE,
+    strlen_on_c_strings::STRLEN_ON_C_STRINGS,
+    suspicious_operation_groupings::SUSPICIOUS_OPERATION_GROUPINGS,
+    suspicious_trait_impl::SUSPICIOUS_ARITHMETIC_IMPL,
+    suspicious_trait_impl::SUSPICIOUS_OP_ASSIGN_IMPL,
+    suspicious_xor_used_as_pow::SUSPICIOUS_XOR_USED_AS_POW,
+    swap::ALMOST_SWAPPED,
+    swap::MANUAL_SWAP,
+    swap_ptr_to_ref::SWAP_PTR_TO_REF,
+    tabs_in_doc_comments::TABS_IN_DOC_COMMENTS,
+    temporary_assignment::TEMPORARY_ASSIGNMENT,
+    to_digit_is_some::TO_DIGIT_IS_SOME,
+    trailing_empty_array::TRAILING_EMPTY_ARRAY,
+    trait_bounds::TRAIT_DUPLICATION_IN_BOUNDS,
+    trait_bounds::TYPE_REPETITION_IN_BOUNDS,
+    transmute::CROSSPOINTER_TRANSMUTE,
+    transmute::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS,
+    transmute::TRANSMUTE_BYTES_TO_STR,
+    transmute::TRANSMUTE_FLOAT_TO_INT,
+    transmute::TRANSMUTE_INT_TO_BOOL,
+    transmute::TRANSMUTE_INT_TO_CHAR,
+    transmute::TRANSMUTE_INT_TO_FLOAT,
+    transmute::TRANSMUTE_NUM_TO_BYTES,
+    transmute::TRANSMUTE_PTR_TO_PTR,
+    transmute::TRANSMUTE_PTR_TO_REF,
+    transmute::TRANSMUTE_UNDEFINED_REPR,
+    transmute::TRANSMUTING_NULL,
+    transmute::UNSOUND_COLLECTION_TRANSMUTE,
+    transmute::USELESS_TRANSMUTE,
+    transmute::WRONG_TRANSMUTE,
+    types::BORROWED_BOX,
+    types::BOX_COLLECTION,
+    types::LINKEDLIST,
+    types::OPTION_OPTION,
+    types::RC_BUFFER,
+    types::RC_MUTEX,
+    types::REDUNDANT_ALLOCATION,
+    types::TYPE_COMPLEXITY,
+    types::VEC_BOX,
+    undocumented_unsafe_blocks::UNDOCUMENTED_UNSAFE_BLOCKS,
+    unicode::INVISIBLE_CHARACTERS,
+    unicode::NON_ASCII_LITERAL,
+    unicode::UNICODE_NOT_NFC,
+    uninit_vec::UNINIT_VEC,
+    unit_return_expecting_ord::UNIT_RETURN_EXPECTING_ORD,
+    unit_types::LET_UNIT_VALUE,
+    unit_types::UNIT_ARG,
+    unit_types::UNIT_CMP,
+    unnamed_address::FN_ADDRESS_COMPARISONS,
+    unnamed_address::VTABLE_ADDRESS_COMPARISONS,
+    unnecessary_owned_empty_strings::UNNECESSARY_OWNED_EMPTY_STRINGS,
+    unnecessary_self_imports::UNNECESSARY_SELF_IMPORTS,
+    unnecessary_wraps::UNNECESSARY_WRAPS,
+    unnested_or_patterns::UNNESTED_OR_PATTERNS,
+    unsafe_removed_from_name::UNSAFE_REMOVED_FROM_NAME,
+    unused_async::UNUSED_ASYNC,
+    unused_io_amount::UNUSED_IO_AMOUNT,
+    unused_peekable::UNUSED_PEEKABLE,
+    unused_rounding::UNUSED_ROUNDING,
+    unused_self::UNUSED_SELF,
+    unused_unit::UNUSED_UNIT,
+    unwrap::PANICKING_UNWRAP,
+    unwrap::UNNECESSARY_UNWRAP,
+    unwrap_in_result::UNWRAP_IN_RESULT,
+    upper_case_acronyms::UPPER_CASE_ACRONYMS,
+    use_self::USE_SELF,
+    useless_conversion::USELESS_CONVERSION,
+    vec::USELESS_VEC,
+    vec_init_then_push::VEC_INIT_THEN_PUSH,
+    wildcard_imports::ENUM_GLOB_USE,
+    wildcard_imports::WILDCARD_IMPORTS,
+    write::PRINTLN_EMPTY_STRING,
+    write::PRINT_LITERAL,
+    write::PRINT_STDERR,
+    write::PRINT_STDOUT,
+    write::PRINT_WITH_NEWLINE,
+    write::USE_DEBUG,
+    write::WRITELN_EMPTY_STRING,
+    write::WRITE_LITERAL,
+    write::WRITE_WITH_NEWLINE,
+    zero_div_zero::ZERO_DIVIDED_BY_ZERO,
+    zero_sized_map_values::ZERO_SIZED_MAP_VALUES,
+])
diff --git a/clippy_lints/src/lib.register_restriction.rs b/clippy_lints/src/lib.register_restriction.rs
new file mode 100644 (file)
index 0000000..aa82966
--- /dev/null
@@ -0,0 +1,91 @@
+// This file was generated by `cargo dev update_lints`.
+// Use that command to update this file and do not edit by hand.
+// Manual edits will be overwritten.
+
+store.register_group(true, "clippy::restriction", Some("clippy_restriction"), vec![
+    LintId::of(as_conversions::AS_CONVERSIONS),
+    LintId::of(asm_syntax::INLINE_ASM_X86_ATT_SYNTAX),
+    LintId::of(asm_syntax::INLINE_ASM_X86_INTEL_SYNTAX),
+    LintId::of(assertions_on_result_states::ASSERTIONS_ON_RESULT_STATES),
+    LintId::of(attrs::ALLOW_ATTRIBUTES_WITHOUT_REASON),
+    LintId::of(casts::AS_UNDERSCORE),
+    LintId::of(casts::FN_TO_NUMERIC_CAST_ANY),
+    LintId::of(create_dir::CREATE_DIR),
+    LintId::of(dbg_macro::DBG_MACRO),
+    LintId::of(default_numeric_fallback::DEFAULT_NUMERIC_FALLBACK),
+    LintId::of(default_union_representation::DEFAULT_UNION_REPRESENTATION),
+    LintId::of(disallowed_script_idents::DISALLOWED_SCRIPT_IDENTS),
+    LintId::of(else_if_without_else::ELSE_IF_WITHOUT_ELSE),
+    LintId::of(empty_drop::EMPTY_DROP),
+    LintId::of(empty_structs_with_brackets::EMPTY_STRUCTS_WITH_BRACKETS),
+    LintId::of(exhaustive_items::EXHAUSTIVE_ENUMS),
+    LintId::of(exhaustive_items::EXHAUSTIVE_STRUCTS),
+    LintId::of(exit::EXIT),
+    LintId::of(float_literal::LOSSY_FLOAT_LITERAL),
+    LintId::of(format_push_string::FORMAT_PUSH_STRING),
+    LintId::of(if_then_some_else_none::IF_THEN_SOME_ELSE_NONE),
+    LintId::of(implicit_return::IMPLICIT_RETURN),
+    LintId::of(indexing_slicing::INDEXING_SLICING),
+    LintId::of(inherent_impl::MULTIPLE_INHERENT_IMPL),
+    LintId::of(large_include_file::LARGE_INCLUDE_FILE),
+    LintId::of(let_underscore::LET_UNDERSCORE_MUST_USE),
+    LintId::of(literal_representation::DECIMAL_LITERAL_REPRESENTATION),
+    LintId::of(matches::REST_PAT_IN_FULLY_BOUND_STRUCTS),
+    LintId::of(matches::TRY_ERR),
+    LintId::of(matches::WILDCARD_ENUM_MATCH_ARM),
+    LintId::of(mem_forget::MEM_FORGET),
+    LintId::of(methods::CLONE_ON_REF_PTR),
+    LintId::of(methods::EXPECT_USED),
+    LintId::of(methods::FILETYPE_IS_FILE),
+    LintId::of(methods::GET_UNWRAP),
+    LintId::of(methods::MAP_ERR_IGNORE),
+    LintId::of(methods::UNWRAP_USED),
+    LintId::of(methods::VERBOSE_FILE_READS),
+    LintId::of(misc_early::SEPARATED_LITERAL_SUFFIX),
+    LintId::of(misc_early::UNNEEDED_FIELD_PATTERN),
+    LintId::of(misc_early::UNSEPARATED_LITERAL_SUFFIX),
+    LintId::of(missing_doc::MISSING_DOCS_IN_PRIVATE_ITEMS),
+    LintId::of(missing_enforced_import_rename::MISSING_ENFORCED_IMPORT_RENAMES),
+    LintId::of(missing_inline::MISSING_INLINE_IN_PUBLIC_ITEMS),
+    LintId::of(missing_trait_methods::MISSING_TRAIT_METHODS),
+    LintId::of(mixed_read_write_in_expression::MIXED_READ_WRITE_IN_EXPRESSION),
+    LintId::of(module_style::MOD_MODULE_FILES),
+    LintId::of(module_style::SELF_NAMED_MODULE_FILES),
+    LintId::of(operators::ARITHMETIC_SIDE_EFFECTS),
+    LintId::of(operators::FLOAT_ARITHMETIC),
+    LintId::of(operators::FLOAT_CMP_CONST),
+    LintId::of(operators::INTEGER_ARITHMETIC),
+    LintId::of(operators::INTEGER_DIVISION),
+    LintId::of(operators::MODULO_ARITHMETIC),
+    LintId::of(panic_in_result_fn::PANIC_IN_RESULT_FN),
+    LintId::of(panic_unimplemented::PANIC),
+    LintId::of(panic_unimplemented::TODO),
+    LintId::of(panic_unimplemented::UNIMPLEMENTED),
+    LintId::of(panic_unimplemented::UNREACHABLE),
+    LintId::of(partial_pub_fields::PARTIAL_PUB_FIELDS),
+    LintId::of(pattern_type_mismatch::PATTERN_TYPE_MISMATCH),
+    LintId::of(pub_use::PUB_USE),
+    LintId::of(redundant_slicing::DEREF_BY_SLICING),
+    LintId::of(same_name_method::SAME_NAME_METHOD),
+    LintId::of(shadow::SHADOW_REUSE),
+    LintId::of(shadow::SHADOW_SAME),
+    LintId::of(shadow::SHADOW_UNRELATED),
+    LintId::of(single_char_lifetime_names::SINGLE_CHAR_LIFETIME_NAMES),
+    LintId::of(std_instead_of_core::ALLOC_INSTEAD_OF_CORE),
+    LintId::of(std_instead_of_core::STD_INSTEAD_OF_ALLOC),
+    LintId::of(std_instead_of_core::STD_INSTEAD_OF_CORE),
+    LintId::of(strings::STRING_ADD),
+    LintId::of(strings::STRING_SLICE),
+    LintId::of(strings::STRING_TO_STRING),
+    LintId::of(strings::STR_TO_STRING),
+    LintId::of(suspicious_xor_used_as_pow::SUSPICIOUS_XOR_USED_AS_POW),
+    LintId::of(types::RC_BUFFER),
+    LintId::of(types::RC_MUTEX),
+    LintId::of(undocumented_unsafe_blocks::UNDOCUMENTED_UNSAFE_BLOCKS),
+    LintId::of(unicode::NON_ASCII_LITERAL),
+    LintId::of(unnecessary_self_imports::UNNECESSARY_SELF_IMPORTS),
+    LintId::of(unwrap_in_result::UNWRAP_IN_RESULT),
+    LintId::of(write::PRINT_STDERR),
+    LintId::of(write::PRINT_STDOUT),
+    LintId::of(write::USE_DEBUG),
+])
index 01da11958e2a660a1b37d2c059e969ddf223db8c..197d8f2dc0810de27e30c586720b7ecb82f127d2 100644 (file)
 mod strlen_on_c_strings;
 mod suspicious_operation_groupings;
 mod suspicious_trait_impl;
+mod suspicious_xor_used_as_pow;
 mod swap;
 mod swap_ptr_to_ref;
 mod tabs_in_doc_comments;
@@ -916,6 +917,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
     store.register_early_pass(|| Box::new(partial_pub_fields::PartialPubFields));
     store.register_late_pass(|_| Box::new(missing_trait_methods::MissingTraitMethods));
     store.register_late_pass(|_| Box::new(from_raw_with_void_ptr::FromRawWithVoidPtr));
+    store.register_late_pass(|_| Box::new(suspicious_xor_used_as_pow::ConfusingXorAndPow));
     // add lints here, do not remove this comment, it's used in `new_lint`
 }
 
diff --git a/clippy_lints/src/suspicious_xor_used_as_pow.rs b/clippy_lints/src/suspicious_xor_used_as_pow.rs
new file mode 100644 (file)
index 0000000..b4168d6
--- /dev/null
@@ -0,0 +1,53 @@
+use clippy_utils::{numeric_literal::NumericLiteral, source::snippet_with_context};
+use rustc_errors::Applicability;
+use rustc_hir::{BinOpKind, Expr, ExprKind};
+use rustc_lint::{LateContext, LateLintPass, LintContext};
+use rustc_middle::lint::in_external_macro;
+use rustc_session::{declare_lint_pass, declare_tool_lint};
+
+declare_clippy_lint! {
+    /// ### What it does
+    /// Warns for a Bitwise XOR (`^`) operator being probably confused as a powering. It will not trigger if any of the numbers are not in decimal.
+    /// ### Why is this bad?
+    ///        It's most probably a typo and may lead to unexpected behaviours.
+    /// ### Example
+    /// ```rust
+    /// let x = 3_i32 ^ 4_i32;
+    /// ```
+    /// Use instead:
+    /// ```rust
+    /// let x = 3_i32.pow(4);
+    /// ```
+    #[clippy::version = "1.65.0"]
+    pub SUSPICIOUS_XOR_USED_AS_POW,
+    restriction,
+    "XOR (`^`) operator possibly used as exponentiation operator"
+}
+declare_lint_pass!(ConfusingXorAndPow => [SUSPICIOUS_XOR_USED_AS_POW]);
+
+impl LateLintPass<'_> for ConfusingXorAndPow {
+    fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) {
+        if !in_external_macro(cx.sess(), expr.span) &&
+               let ExprKind::Binary(op, left, right) = &expr.kind &&
+            op.node == BinOpKind::BitXor &&
+            left.span.ctxt() == right.span.ctxt() &&
+            let ExprKind::Lit(lit_left) = &left.kind &&
+            let ExprKind::Lit(lit_right) = &right.kind &&
+            let snip_left = snippet_with_context(cx, lit_left.span, lit_left.span.ctxt(), "..", &mut Applicability::MaybeIncorrect) &&
+            let snip_right = snippet_with_context(cx, lit_right.span, lit_right.span.ctxt(), "..", &mut Applicability::MaybeIncorrect) &&
+            let Some(left_val) = NumericLiteral::from_lit_kind(&snip_left.0, &lit_left.node) &&
+            let Some(right_val) = NumericLiteral::from_lit_kind(&snip_right.0, &lit_right.node) &&
+                       left_val.is_decimal() &&
+                       right_val.is_decimal() {
+                                       clippy_utils::diagnostics::span_lint_and_sugg(
+                                               cx,
+                                               SUSPICIOUS_XOR_USED_AS_POW,
+                                               expr.span,
+                                               "`^` is not the exponentiation operator",
+                                               "did you mean to write",
+                                               format!("{}.pow({})", left_val.format(), right_val.format()),
+                                               Applicability::MaybeIncorrect,
+                                           );
+               }
+    }
+}
diff --git a/src/docs.rs b/src/docs.rs
new file mode 100644 (file)
index 0000000..0f46e3f
--- /dev/null
@@ -0,0 +1,607 @@
+// autogenerated. Please look at /clippy_dev/src/update_lints.rs
+
+macro_rules! include_lint {
+    ($file_name: expr) => {
+        include_str!($file_name)
+    };
+}
+
+macro_rules! docs {
+    ($($lint_name: expr,)*) => {
+        pub fn explain(lint: &str) {
+            println!("{}", match lint {
+                $(
+                    $lint_name => include_lint!(concat!("docs/", concat!($lint_name, ".txt"))),
+                )*
+                _ => "unknown lint",
+            })
+        }
+    }
+}
+
+docs! {
+    "absurd_extreme_comparisons",
+    "alloc_instead_of_core",
+    "allow_attributes_without_reason",
+    "almost_complete_letter_range",
+    "almost_swapped",
+    "approx_constant",
+    "arithmetic_side_effects",
+    "as_conversions",
+    "as_ptr_cast_mut",
+    "as_underscore",
+    "assertions_on_constants",
+    "assertions_on_result_states",
+    "assign_op_pattern",
+    "async_yields_async",
+    "await_holding_invalid_type",
+    "await_holding_lock",
+    "await_holding_refcell_ref",
+    "bad_bit_mask",
+    "bind_instead_of_map",
+    "blanket_clippy_restriction_lints",
+    "blocks_in_if_conditions",
+    "bool_assert_comparison",
+    "bool_comparison",
+    "bool_to_int_with_if",
+    "borrow_as_ptr",
+    "borrow_deref_ref",
+    "borrow_interior_mutable_const",
+    "borrowed_box",
+    "box_collection",
+    "box_default",
+    "boxed_local",
+    "branches_sharing_code",
+    "builtin_type_shadow",
+    "bytes_count_to_len",
+    "bytes_nth",
+    "cargo_common_metadata",
+    "case_sensitive_file_extension_comparisons",
+    "cast_abs_to_unsigned",
+    "cast_enum_constructor",
+    "cast_enum_truncation",
+    "cast_lossless",
+    "cast_nan_to_int",
+    "cast_possible_truncation",
+    "cast_possible_wrap",
+    "cast_precision_loss",
+    "cast_ptr_alignment",
+    "cast_ref_to_mut",
+    "cast_sign_loss",
+    "cast_slice_different_sizes",
+    "cast_slice_from_raw_parts",
+    "char_lit_as_u8",
+    "chars_last_cmp",
+    "chars_next_cmp",
+    "checked_conversions",
+    "clone_double_ref",
+    "clone_on_copy",
+    "clone_on_ref_ptr",
+    "cloned_instead_of_copied",
+    "cmp_nan",
+    "cmp_null",
+    "cmp_owned",
+    "cognitive_complexity",
+    "collapsible_else_if",
+    "collapsible_if",
+    "collapsible_match",
+    "collapsible_str_replace",
+    "comparison_chain",
+    "comparison_to_empty",
+    "copy_iterator",
+    "crate_in_macro_def",
+    "create_dir",
+    "crosspointer_transmute",
+    "dbg_macro",
+    "debug_assert_with_mut_call",
+    "decimal_literal_representation",
+    "declare_interior_mutable_const",
+    "default_instead_of_iter_empty",
+    "default_numeric_fallback",
+    "default_trait_access",
+    "default_union_representation",
+    "deprecated_cfg_attr",
+    "deprecated_semver",
+    "deref_addrof",
+    "deref_by_slicing",
+    "derivable_impls",
+    "derive_hash_xor_eq",
+    "derive_ord_xor_partial_ord",
+    "derive_partial_eq_without_eq",
+    "disallowed_macros",
+    "disallowed_methods",
+    "disallowed_names",
+    "disallowed_script_idents",
+    "disallowed_types",
+    "diverging_sub_expression",
+    "doc_link_with_quotes",
+    "doc_markdown",
+    "double_comparisons",
+    "double_must_use",
+    "double_neg",
+    "double_parens",
+    "drop_copy",
+    "drop_non_drop",
+    "drop_ref",
+    "duplicate_mod",
+    "duplicate_underscore_argument",
+    "duration_subsec",
+    "else_if_without_else",
+    "empty_drop",
+    "empty_enum",
+    "empty_line_after_outer_attr",
+    "empty_loop",
+    "empty_structs_with_brackets",
+    "enum_clike_unportable_variant",
+    "enum_glob_use",
+    "enum_variant_names",
+    "eq_op",
+    "equatable_if_let",
+    "erasing_op",
+    "err_expect",
+    "excessive_precision",
+    "exhaustive_enums",
+    "exhaustive_structs",
+    "exit",
+    "expect_fun_call",
+    "expect_used",
+    "expl_impl_clone_on_copy",
+    "explicit_auto_deref",
+    "explicit_counter_loop",
+    "explicit_deref_methods",
+    "explicit_into_iter_loop",
+    "explicit_iter_loop",
+    "explicit_write",
+    "extend_with_drain",
+    "extra_unused_lifetimes",
+    "fallible_impl_from",
+    "field_reassign_with_default",
+    "filetype_is_file",
+    "filter_map_identity",
+    "filter_map_next",
+    "filter_next",
+    "flat_map_identity",
+    "flat_map_option",
+    "float_arithmetic",
+    "float_cmp",
+    "float_cmp_const",
+    "float_equality_without_abs",
+    "fn_address_comparisons",
+    "fn_params_excessive_bools",
+    "fn_to_numeric_cast",
+    "fn_to_numeric_cast_any",
+    "fn_to_numeric_cast_with_truncation",
+    "for_kv_map",
+    "forget_copy",
+    "forget_non_drop",
+    "forget_ref",
+    "format_in_format_args",
+    "format_push_string",
+    "from_iter_instead_of_collect",
+    "from_over_into",
+    "from_str_radix_10",
+    "future_not_send",
+    "get_first",
+    "get_last_with_len",
+    "get_unwrap",
+    "identity_op",
+    "if_let_mutex",
+    "if_not_else",
+    "if_same_then_else",
+    "if_then_some_else_none",
+    "ifs_same_cond",
+    "implicit_clone",
+    "implicit_hasher",
+    "implicit_return",
+    "implicit_saturating_add",
+    "implicit_saturating_sub",
+    "imprecise_flops",
+    "inconsistent_digit_grouping",
+    "inconsistent_struct_constructor",
+    "index_refutable_slice",
+    "indexing_slicing",
+    "ineffective_bit_mask",
+    "inefficient_to_string",
+    "infallible_destructuring_match",
+    "infinite_iter",
+    "inherent_to_string",
+    "inherent_to_string_shadow_display",
+    "init_numbered_fields",
+    "inline_always",
+    "inline_asm_x86_att_syntax",
+    "inline_asm_x86_intel_syntax",
+    "inline_fn_without_body",
+    "inspect_for_each",
+    "int_plus_one",
+    "integer_arithmetic",
+    "integer_division",
+    "into_iter_on_ref",
+    "invalid_null_ptr_usage",
+    "invalid_regex",
+    "invalid_upcast_comparisons",
+    "invalid_utf8_in_unchecked",
+    "invisible_characters",
+    "is_digit_ascii_radix",
+    "items_after_statements",
+    "iter_cloned_collect",
+    "iter_count",
+    "iter_kv_map",
+    "iter_next_loop",
+    "iter_next_slice",
+    "iter_not_returning_iterator",
+    "iter_nth",
+    "iter_nth_zero",
+    "iter_on_empty_collections",
+    "iter_on_single_items",
+    "iter_overeager_cloned",
+    "iter_skip_next",
+    "iter_with_drain",
+    "iterator_step_by_zero",
+    "just_underscores_and_digits",
+    "large_const_arrays",
+    "large_digit_groups",
+    "large_enum_variant",
+    "large_include_file",
+    "large_stack_arrays",
+    "large_types_passed_by_value",
+    "len_without_is_empty",
+    "len_zero",
+    "let_and_return",
+    "let_underscore_drop",
+    "let_underscore_lock",
+    "let_underscore_must_use",
+    "let_unit_value",
+    "linkedlist",
+    "lossy_float_literal",
+    "macro_use_imports",
+    "main_recursion",
+    "manual_assert",
+    "manual_async_fn",
+    "manual_bits",
+    "manual_clamp",
+    "manual_filter",
+    "manual_filter_map",
+    "manual_find",
+    "manual_find_map",
+    "manual_flatten",
+    "manual_instant_elapsed",
+    "manual_map",
+    "manual_memcpy",
+    "manual_non_exhaustive",
+    "manual_ok_or",
+    "manual_range_contains",
+    "manual_rem_euclid",
+    "manual_retain",
+    "manual_saturating_arithmetic",
+    "manual_split_once",
+    "manual_str_repeat",
+    "manual_string_new",
+    "manual_strip",
+    "manual_swap",
+    "manual_unwrap_or",
+    "many_single_char_names",
+    "map_clone",
+    "map_collect_result_unit",
+    "map_entry",
+    "map_err_ignore",
+    "map_flatten",
+    "map_identity",
+    "map_unwrap_or",
+    "match_as_ref",
+    "match_bool",
+    "match_like_matches_macro",
+    "match_on_vec_items",
+    "match_overlapping_arm",
+    "match_ref_pats",
+    "match_result_ok",
+    "match_same_arms",
+    "match_single_binding",
+    "match_str_case_mismatch",
+    "match_wild_err_arm",
+    "match_wildcard_for_single_variants",
+    "maybe_infinite_iter",
+    "mem_forget",
+    "mem_replace_option_with_none",
+    "mem_replace_with_default",
+    "mem_replace_with_uninit",
+    "min_max",
+    "mismatched_target_os",
+    "mismatching_type_param_order",
+    "misrefactored_assign_op",
+    "missing_const_for_fn",
+    "missing_docs_in_private_items",
+    "missing_enforced_import_renames",
+    "missing_errors_doc",
+    "missing_inline_in_public_items",
+    "missing_panics_doc",
+    "missing_safety_doc",
+    "missing_spin_loop",
+    "missing_trait_methods",
+    "mistyped_literal_suffixes",
+    "mixed_case_hex_literals",
+    "mixed_read_write_in_expression",
+    "mod_module_files",
+    "module_inception",
+    "module_name_repetitions",
+    "modulo_arithmetic",
+    "modulo_one",
+    "multi_assignments",
+    "multiple_crate_versions",
+    "multiple_inherent_impl",
+    "must_use_candidate",
+    "must_use_unit",
+    "mut_from_ref",
+    "mut_mut",
+    "mut_mutex_lock",
+    "mut_range_bound",
+    "mutable_key_type",
+    "mutex_atomic",
+    "mutex_integer",
+    "naive_bytecount",
+    "needless_arbitrary_self_type",
+    "needless_bitwise_bool",
+    "needless_bool",
+    "needless_borrow",
+    "needless_borrowed_reference",
+    "needless_collect",
+    "needless_continue",
+    "needless_doctest_main",
+    "needless_for_each",
+    "needless_late_init",
+    "needless_lifetimes",
+    "needless_match",
+    "needless_option_as_deref",
+    "needless_option_take",
+    "needless_parens_on_range_literals",
+    "needless_pass_by_value",
+    "needless_question_mark",
+    "needless_range_loop",
+    "needless_return",
+    "needless_splitn",
+    "needless_update",
+    "neg_cmp_op_on_partial_ord",
+    "neg_multiply",
+    "negative_feature_names",
+    "never_loop",
+    "new_ret_no_self",
+    "new_without_default",
+    "no_effect",
+    "no_effect_replace",
+    "no_effect_underscore_binding",
+    "non_ascii_literal",
+    "non_octal_unix_permissions",
+    "non_send_fields_in_send_ty",
+    "nonminimal_bool",
+    "nonsensical_open_options",
+    "nonstandard_macro_braces",
+    "not_unsafe_ptr_arg_deref",
+    "obfuscated_if_else",
+    "octal_escapes",
+    "ok_expect",
+    "only_used_in_recursion",
+    "op_ref",
+    "option_as_ref_deref",
+    "option_env_unwrap",
+    "option_filter_map",
+    "option_if_let_else",
+    "option_map_or_none",
+    "option_map_unit_fn",
+    "option_option",
+    "or_fun_call",
+    "or_then_unwrap",
+    "out_of_bounds_indexing",
+    "overflow_check_conditional",
+    "overly_complex_bool_expr",
+    "panic",
+    "panic_in_result_fn",
+    "panicking_unwrap",
+    "partial_pub_fields",
+    "partialeq_ne_impl",
+    "partialeq_to_none",
+    "path_buf_push_overwrite",
+    "pattern_type_mismatch",
+    "possible_missing_comma",
+    "precedence",
+    "print_in_format_impl",
+    "print_literal",
+    "print_stderr",
+    "print_stdout",
+    "print_with_newline",
+    "println_empty_string",
+    "ptr_arg",
+    "ptr_as_ptr",
+    "ptr_eq",
+    "ptr_offset_with_cast",
+    "pub_use",
+    "question_mark",
+    "range_minus_one",
+    "range_plus_one",
+    "range_zip_with_len",
+    "rc_buffer",
+    "rc_clone_in_vec_init",
+    "rc_mutex",
+    "read_zero_byte_vec",
+    "recursive_format_impl",
+    "redundant_allocation",
+    "redundant_clone",
+    "redundant_closure",
+    "redundant_closure_call",
+    "redundant_closure_for_method_calls",
+    "redundant_else",
+    "redundant_feature_names",
+    "redundant_field_names",
+    "redundant_pattern",
+    "redundant_pattern_matching",
+    "redundant_pub_crate",
+    "redundant_slicing",
+    "redundant_static_lifetimes",
+    "ref_binding_to_reference",
+    "ref_option_ref",
+    "repeat_once",
+    "rest_pat_in_fully_bound_structs",
+    "result_large_err",
+    "result_map_or_into_option",
+    "result_map_unit_fn",
+    "result_unit_err",
+    "return_self_not_must_use",
+    "reversed_empty_ranges",
+    "same_functions_in_if_condition",
+    "same_item_push",
+    "same_name_method",
+    "search_is_some",
+    "self_assignment",
+    "self_named_constructors",
+    "self_named_module_files",
+    "semicolon_if_nothing_returned",
+    "separated_literal_suffix",
+    "serde_api_misuse",
+    "shadow_reuse",
+    "shadow_same",
+    "shadow_unrelated",
+    "short_circuit_statement",
+    "should_implement_trait",
+    "significant_drop_in_scrutinee",
+    "similar_names",
+    "single_char_add_str",
+    "single_char_lifetime_names",
+    "single_char_pattern",
+    "single_component_path_imports",
+    "single_element_loop",
+    "single_match",
+    "single_match_else",
+    "size_of_in_element_count",
+    "skip_while_next",
+    "slow_vector_initialization",
+    "stable_sort_primitive",
+    "std_instead_of_alloc",
+    "std_instead_of_core",
+    "str_to_string",
+    "string_add",
+    "string_add_assign",
+    "string_extend_chars",
+    "string_from_utf8_as_bytes",
+    "string_lit_as_bytes",
+    "string_slice",
+    "string_to_string",
+    "strlen_on_c_strings",
+    "struct_excessive_bools",
+    "suboptimal_flops",
+    "suspicious_arithmetic_impl",
+    "suspicious_assignment_formatting",
+    "suspicious_else_formatting",
+    "suspicious_map",
+    "suspicious_op_assign_impl",
+    "suspicious_operation_groupings",
+    "suspicious_splitn",
+    "suspicious_to_owned",
+    "suspicious_unary_op_formatting",
+    "suspicious_xor_used_as_pow",
+    "swap_ptr_to_ref",
+    "tabs_in_doc_comments",
+    "temporary_assignment",
+    "to_digit_is_some",
+    "to_string_in_format_args",
+    "todo",
+    "too_many_arguments",
+    "too_many_lines",
+    "toplevel_ref_arg",
+    "trailing_empty_array",
+    "trait_duplication_in_bounds",
+    "transmute_bytes_to_str",
+    "transmute_float_to_int",
+    "transmute_int_to_bool",
+    "transmute_int_to_char",
+    "transmute_int_to_float",
+    "transmute_num_to_bytes",
+    "transmute_ptr_to_ptr",
+    "transmute_ptr_to_ref",
+    "transmute_undefined_repr",
+    "transmutes_expressible_as_ptr_casts",
+    "transmuting_null",
+    "trim_split_whitespace",
+    "trivial_regex",
+    "trivially_copy_pass_by_ref",
+    "try_err",
+    "type_complexity",
+    "type_repetition_in_bounds",
+    "undocumented_unsafe_blocks",
+    "undropped_manually_drops",
+    "unicode_not_nfc",
+    "unimplemented",
+    "uninit_assumed_init",
+    "uninit_vec",
+    "uninlined_format_args",
+    "unit_arg",
+    "unit_cmp",
+    "unit_hash",
+    "unit_return_expecting_ord",
+    "unnecessary_cast",
+    "unnecessary_filter_map",
+    "unnecessary_find_map",
+    "unnecessary_fold",
+    "unnecessary_join",
+    "unnecessary_lazy_evaluations",
+    "unnecessary_mut_passed",
+    "unnecessary_operation",
+    "unnecessary_owned_empty_strings",
+    "unnecessary_self_imports",
+    "unnecessary_sort_by",
+    "unnecessary_to_owned",
+    "unnecessary_unwrap",
+    "unnecessary_wraps",
+    "unneeded_field_pattern",
+    "unneeded_wildcard_pattern",
+    "unnested_or_patterns",
+    "unreachable",
+    "unreadable_literal",
+    "unsafe_derive_deserialize",
+    "unsafe_removed_from_name",
+    "unseparated_literal_suffix",
+    "unsound_collection_transmute",
+    "unused_async",
+    "unused_format_specs",
+    "unused_io_amount",
+    "unused_peekable",
+    "unused_rounding",
+    "unused_self",
+    "unused_unit",
+    "unusual_byte_groupings",
+    "unwrap_in_result",
+    "unwrap_or_else_default",
+    "unwrap_used",
+    "upper_case_acronyms",
+    "use_debug",
+    "use_self",
+    "used_underscore_binding",
+    "useless_asref",
+    "useless_attribute",
+    "useless_conversion",
+    "useless_format",
+    "useless_let_if_seq",
+    "useless_transmute",
+    "useless_vec",
+    "vec_box",
+    "vec_init_then_push",
+    "vec_resize_to_zero",
+    "verbose_bit_mask",
+    "verbose_file_reads",
+    "vtable_address_comparisons",
+    "while_immutable_condition",
+    "while_let_loop",
+    "while_let_on_iterator",
+    "wildcard_dependencies",
+    "wildcard_enum_match_arm",
+    "wildcard_imports",
+    "wildcard_in_or_patterns",
+    "write_literal",
+    "write_with_newline",
+    "writeln_empty_string",
+    "wrong_self_convention",
+    "wrong_transmute",
+    "zero_divided_by_zero",
+    "zero_prefixed_literal",
+    "zero_ptr",
+    "zero_sized_map_values",
+    "zst_offset",
+
+}
diff --git a/src/docs/suspicious_xor_used_as_pow.txt b/src/docs/suspicious_xor_used_as_pow.txt
new file mode 100644 (file)
index 0000000..2cae549
--- /dev/null
@@ -0,0 +1,12 @@
+### What it does
+Warns for a Bitwise XOR (`^`) operator being probably confused as a powering. It will not trigger if any of the numbers are not in decimal.
+### Why is this bad?
+       It's most probably a typo and may lead to unexpected behaviours.
+### Example
+```
+let x = 3_i32 ^ 4_i32;
+```
+Use instead:
+```
+let x = 3_i32.pow(4);
+```
\ No newline at end of file
index 422f9486503d2396a484653531936afe7aa18814..e737955026523f973ba31a9f74c5f0f54d6c7ff9 100644 (file)
@@ -2,6 +2,7 @@
 
 #![warn(clippy::eq_op)]
 #![allow(clippy::double_parens, clippy::identity_op, clippy::nonminimal_bool)]
+#![allow(clippy::suspicious_xor_used_as_pow)]
 
 fn main() {
     // simple values and comparisons
index 313ceed2b41facad2b115d1b36d0d77bbb4693a2..d365ab27edc28d5d7ebbe85836dfcf5a2fe8bf11 100644 (file)
@@ -1,5 +1,5 @@
 error: equal expressions as operands to `==`
-  --> $DIR/eq_op.rs:8:13
+  --> $DIR/eq_op.rs:9:13
    |
 LL |     let _ = 1 == 1;
    |             ^^^^^^
@@ -7,163 +7,163 @@ LL |     let _ = 1 == 1;
    = note: `-D clippy::eq-op` implied by `-D warnings`
 
 error: equal expressions as operands to `==`
-  --> $DIR/eq_op.rs:9:13
+  --> $DIR/eq_op.rs:10:13
    |
 LL |     let _ = "no" == "no";
    |             ^^^^^^^^^^^^
 
 error: equal expressions as operands to `!=`
-  --> $DIR/eq_op.rs:11:13
+  --> $DIR/eq_op.rs:12:13
    |
 LL |     let _ = false != false;
    |             ^^^^^^^^^^^^^^
 
 error: equal expressions as operands to `<`
-  --> $DIR/eq_op.rs:12:13
+  --> $DIR/eq_op.rs:13:13
    |
 LL |     let _ = 1.5 < 1.5;
    |             ^^^^^^^^^
 
 error: equal expressions as operands to `>=`
-  --> $DIR/eq_op.rs:13:13
+  --> $DIR/eq_op.rs:14:13
    |
 LL |     let _ = 1u64 >= 1u64;
    |             ^^^^^^^^^^^^
 
 error: equal expressions as operands to `&`
-  --> $DIR/eq_op.rs:16:13
+  --> $DIR/eq_op.rs:17:13
    |
 LL |     let _ = (1u32 as u64) & (1u32 as u64);
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: equal expressions as operands to `^`
-  --> $DIR/eq_op.rs:19:17
+  --> $DIR/eq_op.rs:20:17
    |
 LL |         let _ = 1 ^ ((((((1))))));
    |                 ^^^^^^^^^^^^^^^^^
 
 error: equal expressions as operands to `<`
-  --> $DIR/eq_op.rs:23:13
+  --> $DIR/eq_op.rs:24:13
    |
 LL |     let _ = (-(2) < -(2));
    |             ^^^^^^^^^^^^^
 
 error: equal expressions as operands to `==`
-  --> $DIR/eq_op.rs:24:13
+  --> $DIR/eq_op.rs:25:13
    |
 LL |     let _ = ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1));
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: equal expressions as operands to `&`
-  --> $DIR/eq_op.rs:24:14
+  --> $DIR/eq_op.rs:25:14
    |
 LL |     let _ = ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1));
    |              ^^^^^^^^^^^^^^^^^
 
 error: equal expressions as operands to `&`
-  --> $DIR/eq_op.rs:24:35
+  --> $DIR/eq_op.rs:25:35
    |
 LL |     let _ = ((1 + 1) & (1 + 1) == (1 + 1) & (1 + 1));
    |                                   ^^^^^^^^^^^^^^^^^
 
 error: equal expressions as operands to `==`
-  --> $DIR/eq_op.rs:25:13
+  --> $DIR/eq_op.rs:26:13
    |
 LL |     let _ = (1 * 2) + (3 * 4) == 1 * 2 + 3 * 4;
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: equal expressions as operands to `!=`
-  --> $DIR/eq_op.rs:28:13
+  --> $DIR/eq_op.rs:29:13
    |
 LL |     let _ = ([1] != [1]);
    |             ^^^^^^^^^^^^
 
 error: equal expressions as operands to `!=`
-  --> $DIR/eq_op.rs:29:13
+  --> $DIR/eq_op.rs:30:13
    |
 LL |     let _ = ((1, 2) != (1, 2));
    |             ^^^^^^^^^^^^^^^^^^
 
 error: equal expressions as operands to `==`
-  --> $DIR/eq_op.rs:33:13
+  --> $DIR/eq_op.rs:34:13
    |
 LL |     let _ = 1 + 1 == 2;
    |             ^^^^^^^^^^
 
 error: equal expressions as operands to `==`
-  --> $DIR/eq_op.rs:34:13
+  --> $DIR/eq_op.rs:35:13
    |
 LL |     let _ = 1 - 1 == 0;
    |             ^^^^^^^^^^
 
 error: equal expressions as operands to `-`
-  --> $DIR/eq_op.rs:34:13
+  --> $DIR/eq_op.rs:35:13
    |
 LL |     let _ = 1 - 1 == 0;
    |             ^^^^^
 
 error: equal expressions as operands to `-`
-  --> $DIR/eq_op.rs:36:13
+  --> $DIR/eq_op.rs:37:13
    |
 LL |     let _ = 1 - 1;
    |             ^^^^^
 
 error: equal expressions as operands to `/`
-  --> $DIR/eq_op.rs:37:13
+  --> $DIR/eq_op.rs:38:13
    |
 LL |     let _ = 1 / 1;
    |             ^^^^^
 
 error: equal expressions as operands to `&&`
-  --> $DIR/eq_op.rs:38:13
+  --> $DIR/eq_op.rs:39:13
    |
 LL |     let _ = true && true;
    |             ^^^^^^^^^^^^
 
 error: equal expressions as operands to `||`
-  --> $DIR/eq_op.rs:40:13
+  --> $DIR/eq_op.rs:41:13
    |
 LL |     let _ = true || true;
    |             ^^^^^^^^^^^^
 
 error: equal expressions as operands to `&&`
-  --> $DIR/eq_op.rs:45:13
+  --> $DIR/eq_op.rs:46:13
    |
 LL |     let _ = a == b && b == a;
    |             ^^^^^^^^^^^^^^^^
 
 error: equal expressions as operands to `&&`
-  --> $DIR/eq_op.rs:46:13
+  --> $DIR/eq_op.rs:47:13
    |
 LL |     let _ = a != b && b != a;
    |             ^^^^^^^^^^^^^^^^
 
 error: equal expressions as operands to `&&`
-  --> $DIR/eq_op.rs:47:13
+  --> $DIR/eq_op.rs:48:13
    |
 LL |     let _ = a < b && b > a;
    |             ^^^^^^^^^^^^^^
 
 error: equal expressions as operands to `&&`
-  --> $DIR/eq_op.rs:48:13
+  --> $DIR/eq_op.rs:49:13
    |
 LL |     let _ = a <= b && b >= a;
    |             ^^^^^^^^^^^^^^^^
 
 error: equal expressions as operands to `==`
-  --> $DIR/eq_op.rs:51:13
+  --> $DIR/eq_op.rs:52:13
    |
 LL |     let _ = a == a;
    |             ^^^^^^
 
 error: equal expressions as operands to `/`
-  --> $DIR/eq_op.rs:61:20
+  --> $DIR/eq_op.rs:62:20
    |
 LL |     const D: u32 = A / A;
    |                    ^^^^^
 
 error: equal expressions as operands to `==`
-  --> $DIR/eq_op.rs:92:5
+  --> $DIR/eq_op.rs:93:5
    |
 LL |     (n1.inner.0).0 == (n1.inner.0).0 && (n1.inner.1).0 == (n2.inner.1).0 && (n1.inner.2).0 == (n2.inner.2).0
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/ui/suspicious_xor_used_as_pow.rs b/tests/ui/suspicious_xor_used_as_pow.rs
new file mode 100644 (file)
index 0000000..eb9fc63
--- /dev/null
@@ -0,0 +1,34 @@
+#![allow(unused)]
+#![warn(clippy::suspicious_xor_used_as_pow)]
+#![allow(clippy::eq_op)]
+
+macro_rules! macro_test {
+    () => {
+        13
+    };
+}
+
+macro_rules! macro_test_inside {
+    () => {
+        1 ^ 2 // should warn even if inside macro
+    };
+}
+
+fn main() {
+    // Should warn:
+    let _ = 2 ^ 5;
+    let _ = 2i32 ^ 9i32;
+    let _ = 2i32 ^ 2i32;
+    let _ = 50i32 ^ 3i32;
+    let _ = 5i32 ^ 8i32;
+    let _ = 2i32 ^ 32i32;
+    macro_test_inside!();
+
+    // Should not warn:
+    let x = 0x02;
+    let _ = x ^ 2;
+    let _ = 2 ^ x;
+    let _ = x ^ 5;
+    let _ = 10 ^ 0b0101;
+    let _ = 2i32 ^ macro_test!();
+}
diff --git a/tests/ui/suspicious_xor_used_as_pow.stderr b/tests/ui/suspicious_xor_used_as_pow.stderr
new file mode 100644 (file)
index 0000000..8bb3c8f
--- /dev/null
@@ -0,0 +1,51 @@
+error: `^` is not the exponentiation operator
+  --> $DIR/suspicious_xor_used_as_pow.rs:19:13
+   |
+LL |     let _ = 2 ^ 5;
+   |             ^^^^^ help: did you mean to write: `2.pow(5)`
+   |
+   = note: `-D clippy::suspicious-xor-used-as-pow` implied by `-D warnings`
+
+error: `^` is not the exponentiation operator
+  --> $DIR/suspicious_xor_used_as_pow.rs:20:13
+   |
+LL |     let _ = 2i32 ^ 9i32;
+   |             ^^^^^^^^^^^ help: did you mean to write: `2_i32.pow(9_i32)`
+
+error: `^` is not the exponentiation operator
+  --> $DIR/suspicious_xor_used_as_pow.rs:21:13
+   |
+LL |     let _ = 2i32 ^ 2i32;
+   |             ^^^^^^^^^^^ help: did you mean to write: `2_i32.pow(2_i32)`
+
+error: `^` is not the exponentiation operator
+  --> $DIR/suspicious_xor_used_as_pow.rs:22:13
+   |
+LL |     let _ = 50i32 ^ 3i32;
+   |             ^^^^^^^^^^^^ help: did you mean to write: `50_i32.pow(3_i32)`
+
+error: `^` is not the exponentiation operator
+  --> $DIR/suspicious_xor_used_as_pow.rs:23:13
+   |
+LL |     let _ = 5i32 ^ 8i32;
+   |             ^^^^^^^^^^^ help: did you mean to write: `5_i32.pow(8_i32)`
+
+error: `^` is not the exponentiation operator
+  --> $DIR/suspicious_xor_used_as_pow.rs:24:13
+   |
+LL |     let _ = 2i32 ^ 32i32;
+   |             ^^^^^^^^^^^^ help: did you mean to write: `2_i32.pow(32_i32)`
+
+error: `^` is not the exponentiation operator
+  --> $DIR/suspicious_xor_used_as_pow.rs:13:9
+   |
+LL |         1 ^ 2 // should warn even if inside macro
+   |         ^^^^^ help: did you mean to write: `1.pow(2)`
+...
+LL |     macro_test_inside!();
+   |     -------------------- in this macro invocation
+   |
+   = note: this error originates in the macro `macro_test_inside` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 7 previous errors
+